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

HardtanhGrad

产品支持情况

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

功能说明

  • 算子功能:激活函数Hardtanh的反向。

  • 计算公式:

    grad_selfi={0,       if  selfi>max0,       if  selfi<min1,            otherwisegrad\_self_{i} = \begin{cases} 0,\ \ \ \ \ \ \ if \ \ self_{i}>max \\ 0,\ \ \ \ \ \ \ if\ \ self_{i}<min \\ 1,\ \ \ \ \ \ \ \ \ \ \ \ otherwise \\ \end{cases}

    resi=grad_outputi×grad_selfires_{i} = grad\_output_{i} \times grad\_self_{i}

参数说明

参数名 输入/输出/属性 描述 数据类型 数据格式
result 输入 反向传播过程中上一步输出的梯度,公式中的grad_output。 BFLOAT16、FLOAT16、FLOAT ND
grad 输入 正向的输入数据,公式中的self。 BFLOAT16、FLOAT16、FLOAT ND
min_val 属性 线性范围的下限,公式中的min。 FLOAT -
max_val 属性 线性范围的上限,公式中的max。 FLOAT -
out 输出 计算得到梯度,公式中的res。 BFLOAT16、FLOAT16、FLOAT ND

约束说明

result、grad和out的shape和数据类型需要一致。

调用说明

调用方式 调用样例 说明
aclnn调用 test_aclnn_hardtanh_grad 通过aclnnHardtanhBackWard方式调用HardtanhGrad算子。
图模式 - 通过算子IR构图方式调用HardtanhGrad算子。