espnet2.enh.layers.complex_utils.is_torch_complex_tensor
Less than 1 minute
espnet2.enh.layers.complex_utils.is_torch_complex_tensor
espnet2.enh.layers.complex_utils.is_torch_complex_tensor(c)
Check if the input is a PyTorch complex tensor.
This function verifies whether the input tensor is a complex tensor created using PyTorch’s native complex support, excluding ComplexTensor from the torch_complex library.
- Parameters:c (Union *[*torch.Tensor , ComplexTensor ]) – The input tensor to check.
- Returns: True if the input is a PyTorch complex tensor, False otherwise.
- Return type: bool
Examples
>>> is_torch_complex_tensor(torch.tensor([1, 2], dtype=torch.complex64))
True
>>> is_torch_complex_tensor(torch.tensor([1, 2]))
False
>>> is_torch_complex_tensor(ComplexTensor(torch.tensor([1, 2]),
... torch.tensor([3, 4])))
False