Reshape tensor

Reshape tensor

Creates a new tensor that points to the same data as the input tensor, but has a different layout. It is worth emphasizing that reshaping is essentially a zero-cost operation as the data will not be cloned.

Inputs

tensor
The input tensor.
shape
The shape of the output tensor. A 1-by-N matrix, where N is the number of dimensions in the output tensor. At most one component of the shape can be non-positive (<= 0), which causes the size of that dimension to be computed so that the number of elements in the output tensor is the same as that in the input. If the shape is empty, it will be treated as if it contained a single zero, producing a one-dimensional tensor.

Outputs

tensor
The output tensor.