文件最后提交记录最后更新时间
11 小时前
17 天前
6 个月前
17 天前
17 天前
17 天前
7 个月前
18 小时前
README

FatreluMul

产品支持情况

产品 是否支持
Ascend 950PR/Ascend 950DT
Atlas A3 训练系列产品/Atlas A3 推理系列产品
Atlas A2 训练系列产品/Atlas A2 推理系列产品
Atlas 200I/500 A2 推理产品 ×
Atlas 推理系列产品
Atlas 训练系列产品
Atlas Kirin X90 处理器系列产品
Atlas Kirin 9030 处理器系列产品

功能说明

  • 接口功能:

    将输入Tensor按照最后一个维度分为左右两个Tensor:x1和x2,对左边的x1进行Threshold计算,将计算结果与x2相乘。

  • 计算公式:

    给定输入张量input,最后一维的长度为2d,进行以下计算:

    1. 将input分割为两部分:

      x1=input[...,:d],x2=input[...,d:]x_1 = \text{input}[..., :d], \quad x_2 = \text{input}[..., d:]

    2. 对x1应用Threshold激活函数,定义如下:

      Threshold(x,threshold)={0if x<thresholdxif x≥threshold\text{Threshold}(x, \text{threshold}) = \begin{cases} 0 & \text{if } x < \text{threshold} \\ x & \text{if } x \geq \text{threshold} \end{cases}

      因此,计算:

      x1=Threshold(x1,threshold)x_1 = \text{Threshold}(x_1, \text{threshold})

    3. 最终输出是x1和x2的逐元素乘积:

      out=x1×x2\text{out} = x_1 \times x_2

参数说明

参数名 输入/输出/属性 描述 数据类型 数据格式
input 输入 公式中的输入input。 BFLOAT16、FLOAT16、FLOAT ND
threshold 输入
  • 公式中的输入threshold。
  • threshold不支持NaN和Inf。
BFLOAT16、FLOAT16、FLOAT ND
out 输出 公式中的out。 BFLOAT16、FLOAT16、FLOAT ND
  • Atlas Kirin X90 处理器系列产品、Atlas Kirin 9030 处理器系列产品:不支持BFLOAT16。

约束说明

典型场景尾轴为16的倍数,当尾轴为非32Byte对齐时,建议走小算子拼接逻辑。

调用说明

调用方式 调用样例 说明
aclnn调用 test_aclnn_fatrelu_mul 通过aclnnFatreluMul接口方式调用FatreluMul算子。
图模式调用 - 通过算子IR构图方式调用FatreluMul算子。