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) – 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:
A new tensor with the specified shape.
- Return type:
- INPUT REQUIREMENTS:
input.dtypeis one of [float32,float16,bfloat16,int4,int8,int32,int64,bool]- OUTPUT GUARANTEES:
return[0].dtype==input.dtype
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))