ttnn.is_imag

ttnn.is_imag(input_tensor: ComplexTensor, *, memory_config: ttnn.MemoryConfig = None) ttnn.Tensor

Returns boolean tensor if value of input_tensor is imag.

Parameters:

input_tensor (ComplexTensor) – the input tensor.

Keyword Arguments:

memory_config (ttnn.MemoryConfig, optional) – Memory configuration for the operation. Defaults to None.

Returns:

ttnn.Tensor – the output tensor.

Example

# Create a complex tensor with only imaginary part
real_part = torch.zeros([1, 1, 32, 32], dtype=torch.bfloat16)
imag_part = torch.rand([1, 1, 32, 32], dtype=torch.bfloat16)
tensor = ttnn.complex_tensor(
    ttnn.Tensor(real_part, ttnn.bfloat16).to(ttnn.TILE_LAYOUT).to(device),
    ttnn.Tensor(imag_part, ttnn.bfloat16).to(ttnn.TILE_LAYOUT).to(device),
)

# Check if tensor values are purely imaginary
output = ttnn.is_imag(tensor, memory_config=ttnn.DRAM_MEMORY_CONFIG)
logger.info(f"Is imaginary: {output}")