FilesLast commitLast update
23 days ago
2 months ago
3 days ago
18 days ago
3 days ago
4 months ago
18 days ago
3 days ago
24 days ago
17 days ago
README

HardtanhGrad

English | 简体中文

Applicable Products

Product Support
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products √
Atlas inference products √
Atlas training products √

Function

  • Operator function: Backward of the Hardtanh activation function.

  • Formula:

    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}

Parameters

Parameter name Input/Output/Attribute Description Data type Data format
result Input Gradient output by the previous step in backpropagation, which is grad_output in the formula. BFLOAT16, FLOAT16, FLOAT ND
grad Input Forward input data, which is self in the formula. BFLOAT16, FLOAT16, FLOAT ND
min_val Attribute Lower limit of the linear range, which is min in the formula. FLOAT -
max_val Attribute Upper limit of the linear range, which is max in the formula. FLOAT -
out Output Computed gradient, which is res in the formula. BFLOAT16, FLOAT16, FLOAT ND

Constraints

result, grad, and out must have the same shape and data type.

Invocation Description

Invocation method Invocation sample Description
aclnn invocation test_aclnn_hardtanh_grad Invokes the HardtanhGrad operator through aclnnHardtanhBackward.
Graph-mode invocation - Invokes the HardtanhGrad operator through graph construction with the operator IR.