asc2.broadcast_to
- asc2.broadcast_to(input: LocalTensor, *shape: int) LocalTensor
Creates new tensor of a given shape broadcasting data from the input tensor.
The supported data types are:
int8,int16,int32,int64,float16,bfloat16,float32.- Parameters:
input – The input tensor
shape – The target shape (can be passed as separate integers or as an iterable, e.g. list or tuple)
- Returns:
A new tensor with the broadcasted shape
- Return type:
- Raises:
TypeError – If input is not a LocalTensor or shape contains non-integer values
RuntimeError – If the input tensor shape cannot be broadcasted to the target one or shape values are not positive
Examples
Broadcast tensor to the provided shape:
input = asc2.copy_in(x, [0], [256]) result = input.broadcast_to([16,256])
The code above may act as the following:
input: [0,1,2,3,4, ... 255] result: [[0,1,2,...255], [0,1,2,...255] ... [0,1,2,..255]]
This function can also be called as a member function on
LocalTensor, asinput.broadcast_to(...)instead ofbroadcast_to(input, ...).