文件最后提交记录最后更新时间
15 天前
1 个月前
1 个月前
29 天前
1 个月前
1 个月前
1 个月前
1 个月前
17 小时前
README

SoftplusV2Grad

产品支持情况

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

功能说明

  • 算子功能:aclnnSoftplus的反向传播,根据前向输入self和上游梯度gradOutput,计算对前向输入的梯度gradInput。

  • 计算公式:

    gradInput=gradOutput⋅{11+e(−β⋅self),β⋅self≤threshold1,β⋅self>thresholdgradInput = gradOutput \cdot \begin{cases} \dfrac{1}{1+e^{(-\beta \cdot self)}}, & \beta \cdot self \le threshold \\ 1, & \beta \cdot self > threshold \end{cases}

    β⋅self>threshold\beta \cdot self > threshold 时梯度退化为1.0(即 gradInput=gradOutputgradInput = gradOutput),避免 expexp 溢出,保证数值稳定性。

参数说明

参数名 输入/输出/属性 描述 数据类型 数据格式
input_gradients 输入 上游梯度张量,公式中的gradOutput,支持0D~8D,与input_features同dtype、满足broadcast关系。 FLOAT、FLOAT16、BFLOAT16 ND
input_features 输入 前向传播的原始输入张量,公式中的self,支持0D~8D,与input_gradients同dtype、满足broadcast关系。 FLOAT、FLOAT16、BFLOAT16 ND
beta 可选属性
  • 公式中的beta,控制softplus陡峭程度,beta越大越接近ReLU。
  • 默认值为1.0。
FLOAT -
threshold 可选属性
  • 公式中的threshold,数值稳定性阈值,超过后梯度退化为1.0。
  • 默认值为20.0。
FLOAT -
output_backprops 输出 对前向输入的梯度,公式中的gradInput,shape与dtype与input_features相同。 FLOAT、FLOAT16、BFLOAT16 ND

约束说明

  • input_gradients和input_features的dtype必须一致,不支持混合精度。
  • input_gradients和input_features满足broadcast关系,broadcast后shape与input_features相同;output_backprops的shape与input_features相同。
  • beta和threshold为Host侧标量属性,非Tensor。
  • 默认确定性实现。

调用说明

调用方式 调用样例 说明
aclnn调用 test_aclnn_softplus_v2_grad 通过aclnnSoftplusBackward接口方式调用SoftplusV2Grad算子。
图模式调用 test_geir_softplus_v2_grad 通过算子IR构图方式调用SoftplusV2Grad算子。