ttnn.bcast

ttnn.bcast() None

Perform a binary elementwise operation math_op between tensors input_a and input_b, where values from tensor input_b are broadcast.

Let tensor input_a have shape [W0, Z0, Y0, X0] and tensor input_b shape [W1, Z1, Y1, X1]. dim determines the type of broadcast performed.

For dim=BcastOpDim::W broadcast is performed on dimension X. Y0 and Y1 must be the same and either (W1=1 and Z1=1) or (W0=W1 and Z0=Z1).

For dim=BcastOpDim::H broadcast is performed on dimension Y. X0 and X1 must be the same and either (W1=1 and Z1=1) or (W0=W1 and Z0=Z1).

For dim=BcastOpDim::HW broadcast is performed on dimensions X and Y. Either (W1=1 and Z1=1) or (W0=W1 and Z0=Z1) must hold for input shapes.

Both input tensors must have BFLOAT16 data type.

Output tensor will have BFLOAT16 data type.

Argument

Description

Data type

Valid range

Required

input_a

Input tensor

Tensor

Tensor of shape [W0, Z0, Y0, X0]

Yes

input_b

Input tensor to broadcast

Tensor

Tensor of shape [W1, Z1, Y1, X1]

Yes

math_op

Aggregating math operation

BcastOpMath

ADD, SUB, MUL

Yes

dim

Dimension on which to broadcast

BcastOpDim

W, H, HW

Yes

memory_config

Layout of tensor in TT Accelerator device memory banks

MemoryConfig

Default is interleaved in DRAM

No

output_tensor

Optional preallocated output tensor

Tensor

Default is None

No

:param * input_tensor_a: First Input Tensor for bcast. :param * input_tensor_b: Second Input Tensor for bcast. :param * math_op: Operation to be performed during broadcasting. :param * dim: the dimension to reduce. If None, the bcast of the flattened input is returned

:keyword * memory_config: Memory Config of the output tensor :keyword * output_tensor: Preallocated output tensor