reshape¶
- nvtripy.reshape(input: Tensor, shape: Sequence[int | DimensionSize]) Tensor [source]¶
Returns a new tensor with the contents of the input tensor in the specified shape.
- Parameters:
input (Tensor) – [dtype=T1] The input tensor.
shape (Sequence[int | DimensionSize]) – The desired compatible shape. If a shape dimension is -1, its value is inferred based on the other dimensions and the number of elements in the input. Atmost one dimension can be -1.
- Returns:
[dtype=T1] A new tensor with the specified shape.
- Return type:
Example
1input = tp.iota((2, 3), dtype=tp.float32) 2output = tp.reshape(input, (1, 6))
Local Variables¶>>> input tensor( [[0, 0, 0], [1, 1, 1]], dtype=float32, loc=gpu:0, shape=(2, 3)) >>> output tensor( [[0, 0, 0, 1, 1, 1]], dtype=float32, loc=gpu:0, shape=(1, 6))