into_broadcast

Function into_broadcast 

Source
pub fn into_broadcast<R, T, B, D, D2>(
    tensor: TensorBase<Storage<R, T, B>, D>,
    shape: D2,
) -> TensorBase<Storage<R, T, B>, D2>
where R: DataAPI<Data = <B as DeviceRawAPI<T>>::Raw>, B: DeviceAPI<T>, D: DimAPI + DimMaxAPI<D2, Max = D2>, D2: DimAPI,
Expand description

Broadcasts an array to a specified shape.

Row/Column Major Notice

This function behaves differently on default orders (RowMajor and ColMajor) of device.

§Parameters

  • tensor: TensorAny<R, T, B, D>

    • The input tensor to be broadcasted.
    • Ownership of input tensor is taken.
  • shape: impl DimAPI

    • The shape of the desired output tensor after broadcasting.
    • Please note IxD (Vec<usize>) and Ix<N> ([usize; N]) behaves differently here. IxD will give dynamic shape tensor, while Ix<N> will give static shape tensor.

§Returns

  • TensorAny<R, T, B, D2>

    • The tensor with the given shape. It is typically not contiguous (perform to_contig afterwards if requires a contiguous owned tensor).
    • Furthermore, more than one element of a broadcasted tensor may refer to a single memory location (zero strides at the broadcasted axes).
    • Ownership of the returned tensor is transferred from the input tensor. Only the layout is modified; the underlying data remains unchanged.

§See also

Refer to to_broadcast for more detailed documentation.