昇腾社区首页
中文
注册

reduce_max

功能说明

按某个轴求最大值,进行降维。

您可以在“te/lang/cce/te_compute/reduction_compute.py”查看接口定义。

约束说明

Atlas 200/300/500 推理产品:支持的数据类型有float16、float32

Atlas 训练系列产品:支持的数据类型有float16、float32

函数原型

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

参数说明

  • 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)。
  • priority_flag:在做reduce时,控制优选精度优先还是性能优先方式。
    • True:表示精度优先。精度优先时,由于计算过程复杂,性能会有所下降。
    • False:表示性能优先。性能优先时,精度会有所下降。

    默认值“False”。

返回值

res_tensor:取最大值后的tensor,tvm.tensor类型。

支持的芯片型号

Atlas 200/300/500 推理产品

Atlas 训练系列产品

调用示例

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