ttnn.imag_bw
- ttnn.imag_bw(grad_tensor: ttnn.Tensor, input_tensor: ComplexTensor, *, memory_config: ttnn.MemoryConfig) List of ttnn.Tensor
-
Performs backward operations for complex imaginary function on
input_tensorwith givengrad_tensor.- Parameters:
-
grad_tensor (ttnn.Tensor) – 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 imaginary part 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), ) # Gradient tensor for the imaginary part (regular tensor, not complex) grad_data = torch.rand([1, 1, 32, 32], dtype=torch.bfloat16) grad_tensor = ttnn.Tensor(grad_data, ttnn.bfloat16).to(ttnn.TILE_LAYOUT).to(device) # Call the imag_bw function output = ttnn.imag_bw(grad_tensor, input_tensor, memory_config=ttnn.DRAM_MEMORY_CONFIG) logger.info(f"Imaginary Part Backward: {output}")