Help Center/ Atlas 300 Application (Model 3000)/ TE API Reference/ Compute APIs/ te.lang.cce.sum(raw_tensor, axis, keepdims=False)
Updated on 2022-03-13 GMT+08:00

te.lang.cce.sum(raw_tensor, axis, keepdims=False)

Performs the sum operation based on a certain axis to reduce dimensions. The supported types are float16 and float32. The data types int8, uint8, and int32 are converted to float16.

This API is defined in reduction_compute.py.

Parameter Description

  • raw_tensor: input tensor, tvm.tensor type
  • axis: axis for the reduce operation. The value range is [–d, d – 1]. The parameter d indicates the dimension of raw_tensor, int or list type
  • keepdims: The default value is False, indicating that the length of the operation axis is 0 after the reduce operation. For example, if the original shape is (10, 10, 10) and keepdims=False, the shape after reduce is (10, 10). If this parameter is set to True, the length of the operation axis is set to 1 after the reduce operation. For example, if the original shape is (10, 10, 10) and keepdims=True, the shape after reduce is (10, 10, 1).

Return Value

res_tensor: tensor after the sum value is obtained, tvm.tensor type

Calling Example

shape = (1024,1024)
input_dtype = "float16"
data = tvm.placeholder(shape, name="data", dtype=input_dtype)
res = te.lang.cce.sum(data, axis=1)