更新时间:2021-03-18 GMT+08:00
te.lang.cce.sum(raw_tensor, axis, keepdims=False)
按某个轴求和,进行降维,支持的类型:float16、float32。int8、uint8、int32类型会被转换为float16。
该接口在reduction_compute.py中定义。
参数说明
- raw_tensor:输入tensor,tvm.tensor类型
- axis:做reduce操作的轴,取值范围:[-d,d-1],其中d是raw_tensor的维数,int或list类型
- keepdims:默认值是False,表示做reduce操作后,操作的轴长度为0,例如,原shape是(10,10,10),keepdims=False时,reduce后shape是(10,10)。若将该参数值设置为True,表示做reduce操作后,操作的轴的长度设置为1,例如,原shape是(10,10,10),keepdims=True时,reduce后shape是(10,10,1)。
返回值
res_tensor:求和后的tensor,tvm.tensor类型
调用示例
shape = (1024,1024) input_dtype = "float16" data = tvm.placeholder(shape, name="data", dtype=input_dtype) res = te.lang.cce.sum(data, axis=1)
父主题: compute接口