round_half_up

功能说明

将raw_tensor中每个元素向最接近的整数取整(四舍六入),当0.5或-0.5时则向远离0的方向取整(例如,-1.5向远离0取整的结果是-2,1.5向远离0取整的结果是2)。

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

约束说明

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

函数原型

te.lang.cce.round_half_up(raw_tensor)

参数说明

raw_tensor:输入tensor,tvm.tensor类型。

返回值

res_tensor:结果tensor,tvm.tensor类型,数据类型为int32。

支持的芯片型号

Atlas 训练系列产品

调用示例

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