Skip to main content

Mojo function

broadcast_to

broadcast_to(v: Symbol, shape: List[Dim], location: Optional[_SourceLocation] = Optional(#kgen.none)) -> Symbol

Broadcasts a symbolic tensor.

Broadcasts the input tensor to the specified shape. Dimensions in the input must be one or match the target dimension.

Args:

  • v (Symbol): The input symbolic tensor to broadcast. This tensor may not contain any dynamic dimensions.
  • shape (List[Dim]): The new shape as a list of dimensions. Dynamic dimensions are not allowed.
  • location (Optional[_SourceLocation]): An optional location for a more specific error message.

Returns:

A symbolic tensor with the same elements as the original tensor, but in a new shape. Its symbolic shape is the same as shape.