Skip to main content

function

reshape

reshape(v: Symbol, shape: Symbol, out_dims: List[Dim]) -> 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]): 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]) -> 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]): 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.