pypto_pro.language.simt.rint#
产品支持情况#
Ascend 950PR/Ascend 950DT:支持
Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持
Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持
功能说明#
将源操作数舍入到最接近的整数值;源操作数位于两个整数中间时,选择偶数。
函数原型#
pypto_pro.language.simt.rint(
value: Scalar,
) -> Scalar
参数说明#
参数 |
输入/输出 |
说明 |
|---|---|---|
value |
输入 |
源操作数,Scalar类型,支持DT_FP16、DT_BF16和DT_FP32。Tensor或Tile元素需通过下标访问后传入。 |
约束说明#
只能在由@pypto_pro.language.vector_function(mode=”simt”)定义的SIMT入口函数或辅助函数中调用。
返回值说明#
返回舍入后的整数值形式,数据类型与输入一致。
调用示例#
import pypto_pro.language as pl
@pl.vector_function(mode="simt", max_threads=256)
def nearest_even(
source: pl.Tensor[[1, 256], pl.DT_FP32],
output: pl.Tensor[[1, 256], pl.DT_FP32],
):
tid = pl.simt.linear_thread_idx()
output[0, tid] = pl.simt.rint(source[0, tid])
@pl.jit()
def simt_rint_kernel(
source: pl.Tensor[[1, 256], pl.DT_FP32],
output: pl.Tensor[[1, 256], pl.DT_FP32],
):
with pl.section_vector():
nearest_even[256](source, output)