sum¶
- nvtripy.sum(input: Tensor, dim: int | Sequence[int] | None = None, keepdim: bool = False) Tensor[source]¶
Returns a new tensor containing the sum of the elements of the input tensor along the specified dimension.
- Parameters:
- Returns:
A new tensor.
- Return type:
- INPUT REQUIREMENTS:
input.dtypeis one of [float32,int32,int64,float16,bfloat16]- OUTPUT GUARANTEES:
return[0].dtype==input.dtype
Example
1input = tp.reshape(tp.arange(6, dtype=tp.float32), (2, 3)) 2output = tp.sum(input, 0)
Local Variables¶>>> input tensor( [[0, 1, 2], [3, 4, 5]], dtype=float32, loc=gpu:0, shape=(2, 3)) >>> output tensor([3, 5, 7], dtype=float32, loc=gpu:0, shape=(3,))