Silu
产品支持情况
功能说明
按元素做Silu运算,计算公式如下:


函数原型
template <typename T, bool isReuseSource = false>
__aicore__ inline void Silu(const LocalTensor<T>& dstLocal, const LocalTensor<T>& srcLocal, uint32_t dataSize)
参数说明
表 1 模板参数说明
|
Ascend 950PR/Ascend 950DT,支持的数据类型为:half、float。 Atlas A3 训练系列产品/Atlas A3 推理系列产品,支持的数据类型为:half、float。 Atlas A2 训练系列产品/Atlas A2 推理系列产品,支持的数据类型为:half、float。 |
|
表 2 接口参数说明
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
返回值说明
无
约束说明
- 操作数地址偏移对齐要求请参见通用说明和约束。
- 不支持源操作数与目的操作数地址重叠。
- 当前仅支持ND格式的输入,不支持其他格式。
调用示例
#include "kernel_operator.h"
AscendC::LocalTensor<srcType> dstLocal = outQueue.AllocTensor<srcType>();
AscendC::LocalTensor<srcType> srcLocal = inQueueX.DeQue<srcType>();
AscendC::Silu(dstLocal, srcLocal, dataSize);
outQueue.EnQue<srcType>(dstLocal);
inQueueX.FreeTensor(srcLocal);
结果示例如下:
输入数据(srcLocal):[3.304723 1.04788 ... -1.0512]
输出数据(dstLocal): [3.185546875 0.77587890625 ... -0.272216796875]