Category: Shape manipulation
Short description: Reshape operation changes dimensions of the input tensor according to the specified order. Input tensor volume is equal to output tensor volume, where volume is the product of dimensions.
Reshape takes two input tensors:
data to be resized and
shape of the new output. The values in the
shape could be
0 and any positive integer number. The two special values
0means "copy the respective dimension *(left aligned)* of the input tensor" if
special_zerois set to
true; otherwise it is a normal dimension and is applicable to empty tensors.
-1means that this dimension is calculated to keep the overall elements count the same as in the input tensor. Not more than one
-1can be used in a reshape operation.
special_zero is set to
true index of
0 cannot be larger than the rank of the input tensor.
shapeare interpreted. If special_zero is
0is interpreted as-is which means that output shape will contain a zero dimension at the specified location. Input and output tensors are empty in this case. If special_zero is
true, then all zeros in
shapeimplies the copying of corresponding dimensions from
data.shapeinto the output shape *(left aligned)*.
dataa tensor of type T and arbitrary shape. Required.
shape1D tensor of type T_SHAPE describing output shape. Required.
datainput tensor but with shape defined by
Example 1: reshape empty tensor
Example 2: reshape tensor - preserve first dim, calculate second and fix value for third dim
Example 3: reshape tensor - preserve first two dims, fix value for third dim and calculate fourth
Example 4: reshape tensor - calculate first dim and preserve second dim
Example 5: reshape tensor - preserve first dim and calculate second dim