ttnn.conj_bw

ttnn.conj_bw(grad_tensor: ComplexTensor, input_tensor: ComplexTensor, *, memory_config: ttnn.MemoryConfig) List of ttnn.Tensor

Performs backward operations for complex conj function on input_tensor with given grad_tensor.

Parameters:
  • grad_tensor (ComplexTensor) – the input tensor.

  • input_tensor (ComplexTensor) – the input tensor.

Keyword Arguments:

memory_config (ttnn.MemoryConfig) – Memory configuration for the operation.

Returns:

List of ttnn.Tensor – the output tensor.

Note:

Example

# Create sample tensors for backward complex conjugate operation
# Create a complex input tensor
input_real = torch.rand([1, 1, 32, 32], dtype=torch.bfloat16)
input_imag = torch.rand([1, 1, 32, 32], dtype=torch.bfloat16)
input_tensor = ttnn.complex_tensor(
    ttnn.Tensor(input_real, ttnn.bfloat16).to(ttnn.TILE_LAYOUT).to(device),
    ttnn.Tensor(input_imag, ttnn.bfloat16).to(ttnn.TILE_LAYOUT).to(device),
)

# Create complex gradient tensor
grad_real = torch.rand([1, 1, 32, 32], dtype=torch.bfloat16)
grad_imag = torch.rand([1, 1, 32, 32], dtype=torch.bfloat16)
grad_tensor = ttnn.complex_tensor(
    ttnn.Tensor(grad_real, ttnn.bfloat16).to(ttnn.TILE_LAYOUT).to(device),
    ttnn.Tensor(grad_imag, ttnn.bfloat16).to(ttnn.TILE_LAYOUT).to(device),
)

# Call the conj_bw function
output = ttnn.conj_bw(grad_tensor, input_tensor, memory_config=ttnn.DRAM_MEMORY_CONFIG)
logger.info(f"Complex Conjugate Backward: {output}")