ttnn.bcast
- ttnn.bcast() None
-
Perform a binary elementwise operation
math_opbetween tensorsinput_aandinput_b, where values from tensorinput_bare broadcast.Let tensor
input_ahave shape[W0, Z0, Y0, X0]and tensorinput_bshape[W1, Z1, Y1, X1].dimdetermines the type of broadcast performed.For
dim=BcastOpDim::Wbroadcast is performed on dimensionX.Y0andY1must be the same and either (W1=1 and Z1=1) or (W0=W1 and Z0=Z1).For
dim=BcastOpDim::Hbroadcast is performed on dimensionY.X0andX1must be the same and either (W1=1 and Z1=1) or (W0=W1 and Z0=Z1).For
dim=BcastOpDim::HWbroadcast is performed on dimensionsXandY. 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