Mojo function
reshape
reshape(v: Symbol, shape: List[Dim, 0]) -> Symbol
Reshapes a symbolic tensor.
The number and order of the elements in the tensor is unchanged. In other words, if you were to iterate over elements in the tensor by major dimension to minor dimension, the iteration order would stay the same.
If a value of -1 is present in the shape, that dimension becomes an automatically calculated dimension collecting all unspecified dimensions. Its length becomes the number of elements in the original tensor divided by the product of elements of the reshape.
Args:
- v (
Symbol
): The input symbolic tensor to reshape. This tensor may not contain any dynamic dimensions. - shape (
List[Dim, 0]
): The new shape as a list of dimensions. Dynamic dimensions are not allowed. A single dimension may be-1
.
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
.
reshape(v: Symbol, shape: Symbol, out_dims: List[Dim, 0]) -> Symbol
Reshapes a symbolic tensor.
The number and order of the elements in the tensor is unchanged. In other words, if you were to iterate over elements in the tensor by major dimension to minor dimension, the iteration order would stay the same.
If a value of -1 is present in the shape, that dimension becomes a dynamic dimension collecting all unspecified dimensions. Its length becomes the number of elements in the original tensor divided by the product of elements of the reshape.
Args:
- v (
Symbol
): The input symbolic tensor to reshape. - shape (
Symbol
): The new shape as a symbolic rank-1 tensor. The input must have integer dtype, and must either be all non-negative elements or allows a single element of -1. - out_dims (
List[Dim, 0]
): A type hint for the tensor's symbolic shape in the graph.
Returns:
A symbolic tensor with the same elements as the original tensor, but in a new shape. Its symbolic shape is the same as out_dims
.
reshape(v: Symbol, shape: List[Symbol, 0]) -> Symbol
Reshapes a symbolic tensor.
The number and order of the elements in the tensor is unchanged. In other words, if you were to iterate over elements in the tensor by major dimension to minor dimension, the iteration order would stay the same.
If a value of -1 is present in the shape, that dimension becomes a dynamic dimension collecting all unspecified dimensions. Its length becomes the number of elements in the original tensor divided by the product of elements of the reshape.
Args:
- v (
Symbol
): The input symbolic tensor to reshape. - shape (
List[Symbol, 0]
): The new shape as a list of rank-0 symbolic tensors. The inputs must have integer dtype, and must either be all non-negative elements or allows a single element of -1.
Returns:
A symbolic tensor with the same elements as the original tensor, but in a new shape. It has a rank equal to the length of shape
, but every symbolic dimension of the result is a dynamic size.
reshape(v: Symbol, shape: Symbol) -> Symbol
Reshapes a symbolic tensor.
The number and order of the elements in the tensor is unchanged. In other words, if you were to iterate over elements in the tensor by major dimension to minor dimension, the iteration order would stay the same.
If a value of -1 is present in the shape, that dimension becomes a dynamic dimension collecting all unspecified dimensions. Its length becomes the number of elements in the original tensor divided by the product of elements of the reshape.
Args:
- v (
Symbol
): The input symbolic tensor to reshape. - shape (
Symbol
): The new shape as a symbolic rank-1 tensor. The input must have integer dtype, and must either be all non-negative elements or allows a single element of -1.
Returns:
A symbolic tensor with the same elements as the original tensor, but in a new shape. It has a rank equal to the static size of shape
, but every symbolic dimension of the result is a dynamic size.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
😔 What went wrong?