跳到主要内容

Maxs

功能说明

源操作数矢量内每个元素与标量相比,如果比标量大,则取源操作数值,比标量的值小,则取标量值。

函数原型

tensor前n个数据计算:

template <typename T, bool isSetMask = true>
__aicore__ inline void Maxs(const LocalTensor<T>& dstLocal, const LocalTensor<T>& srcLocal, const T& scalarValue, const int32_t& calCount)

参数说明

表1 模板参数说明

参数名描述
T操作数数据类型。
UscalarValue数据类型。
isSetMask是否在接口内部设置mask模式和mask值。 - true,表示在接口内部设置。 - false,表示在接口外部设置。

表2 参数说明

参数名称类型说明
dstLocal输出目的操作数。 类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 LocalTensor的起始地址需要32字节对齐。 Kirin9020系列处理器,支持的数据类型为:Tensor(int16_t/int32_t/half/float)。 KirinX90系列处理器,支持的数据类型为:Tensor(int16_t/int32_t/half/float)。
srcLocal输入源操作数。 类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 LocalTensor的起始地址需要32字节对齐。 数据类型需要与目的操作数保持一致。 Kirin9020系列处理器,支持的数据类型为:Tensor(int16_t/int32_t/half/float)。 KirinX90系列处理器,支持的数据类型为:Tensor(int16_t/int32_t/half/float)。
scalarValue输入源操作数,数据类型需要与目的操作数Tensor中元素的数据类型保持一致 Kirin9020系列处理器,支持的数据类型为:Tensor(int16_t/int32_t/half/float)。 KirinX90系列处理器,支持的数据类型为:Tensor(int16_t/int32_t/half/float)。
calCount输入输入数据元素个数。

返回值

支持的型号

Kirin9020系列处理器

KirinX90系列处理器

注意事项

操作数地址偏移对齐要求请参见通用约束

调用示例

本样例中只展示Compute流程中的部分代码。如果开发者需要运行样例代码,请将该代码段拷贝并替换标量双目指令样例模板更多样例中的Compute函数即可。

tensor前n个数据计算样例:

int16_t scalar = 2;
AscendC::Maxs(dstLocal, srcLocal, scalar, 512);

结果示例如下。

输入数据(src0Local): [1 2 3 ... 512]
输入数据 scalar = 2
输出数据(dstLocal): [2 2 3 ... 512]