ttnn.complex_tensor

ttnn.complex_tensor(real: ttnn.Tensor, imag: ttnn.Tensor) ttnn.ComplexTensor

Create a complex tensor from real and imaginary part tensors.

Parameters:
  • real (ttnn.Tensor) – the real part tensor.

  • imag (ttnn.Tensor) – the imaginary part tensor.

Returns:

ttnn.ComplexTensor – the complex tensor with real and imag parts.

Note

This operation supports tensors according to the following data types and layouts:

real and imag tensors

dtype - layout

BFLOAT16, BFLOAT8_B, BFLOAT4_B, FLOAT32, UINT32, INT32, UINT16, UINT8 - TILE

BFLOAT16, FLOAT32, UINT32, INT32, UINT16, UINT8 - ROW_MAJOR

Memory Support:
  • Interleaved: DRAM and L1

  • Height, Width, Block, and ND Sharded: DRAM and L1

Limitations:
  • The real and imag tensors must have the same shape and layout (both must be TILE or ROW_MAJOR).

Example

# Create a TT-NN complex tensor from real and imaginary parts using ttnn.Tensor constructor
real = ttnn.Tensor([1.0, 2.0], [2], ttnn.bfloat16, ttnn.ROW_MAJOR_LAYOUT, device)
imag = ttnn.Tensor([1.0, 2.0], [2], ttnn.bfloat16, ttnn.ROW_MAJOR_LAYOUT, device)
complex_tensor = ttnn.complex_tensor(real, imag)
logger.info("TT-NN complex tensor:", complex_tensor)