For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo function
reshape_shape
def reshape_shape[output_rank: Int, input_type: DType, target_shape_type: DType](input_buf: TileTensor[input_type, Storage=input_buf.Storage, address_space=input_buf.address_space, linear_idx_type=input_buf.linear_idx_type], target_shape_buf: TileTensor[target_shape_type, Storage=target_shape_buf.Storage, address_space=target_shape_buf.address_space, linear_idx_type=target_shape_buf.linear_idx_type]) -> IndexList[output_rank]
Reads a target shape from a buffer and returns it as a static IndexList, inferring any single -1 dimension.
Copies the rank-1 target_shape_buf into a static IndexList[output_rank],
allowing at most one dimension to be specified as -1, which is then inferred
from the input's element count. Raises an error if the constraints are
violated or the inferred shape does not match the input's number of elements.
Parameters:
- βoutput_rank (
Int): Expected rank of the target shape. - βinput_type (
DType): Element type of the input buffer. - βtarget_shape_type (
DType): Element type of the target shape buffer.
Args:
- βinput_buf (
TileTensor[input_type, Storage=input_buf.Storage, address_space=input_buf.address_space, linear_idx_type=input_buf.linear_idx_type]): Source tensor whose element count constrains the inferred shape. - βtarget_shape_buf (
TileTensor[target_shape_type, Storage=target_shape_buf.Storage, address_space=target_shape_buf.address_space, linear_idx_type=target_shape_buf.linear_idx_type]): Rank-1 tensor holding the desired output dimensions, where at most one entry may be-1.
Returns:
IndexList[output_rank]: A static IndexList[output_rank] with any -1 dimension resolved.
Raises:
Error: If target_shape_buf is not rank 1, the rank does not match
output_rank, more than one -1 is present, a negative value
other than -1 appears, or the resulting element count does not
match the input.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!