asc.experimental.asctile.broadcast_tensors

asc.experimental.asctile.broadcast_tensors(*tensors: LocalTensor) → Tuple[LocalTensor, ...]

Broadcast all input tensors to a common shape.

This function computes the common broadcast shape using broadcast_shapes() and then broadcasts each tensor to that shape using broadcast_to().

The supported data types are the same as for broadcast_to() function.

Parameters:

tensors – Variable number of LocalTensors to broadcast

Returns:

A tuple of tensors, all broadcasted to the common shape

Return type:

Tuple[LocalTensor, …]

Raises:
  • TypeError – If any input is not a LocalTensor or has an unsupported dtype

  • RuntimeError – If the tensor shapes are incompatible and cannot be broadcast together

Examples

Broadcast multiple tensors to a common shape:

t1 = asctile.copy_in(x, [0], [256])          # shape [256]
t2 = asctile.copy_in(y, [0, 0], [16, 256])   # shape [16, 256]
t1_bc, t2_bc = broadcast_tensors(t1, t2)  # both have shape [16, 256]