MCPcopy Create free account
hub / github.com/alibaba/MNN / onGrad

Method onGrad

tools/train/source/grad/ReluGrad.cpp:71–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69 mType = SEMI_LINEAR;
70 }
71 virtual std::vector<Express::VARP> onGrad(Express::EXPRP expr,
72 const std::vector<Express::VARP>& backwardOutput) override {
73 std::vector<Express::VARP> result{nullptr};
74 auto op = expr->get();
75 MNN_ASSERT(nullptr != op);
76 auto relu6 = op->main_as_Relu6();
77 MNN_ASSERT(nullptr != relu6);
78 auto input = expr->inputs()[0];
79 auto mask0 = _Cast<float>(_Greater(input, _Scalar(relu6->minValue())));
80 auto mask1 = _Cast<float>(_Less(input, _Scalar(relu6->maxValue())));
81
82 result[0] = mask0 * mask1 * backwardOutput[0];
83 return result;
84 }
85};
86static void _create() {
87 static ReluGrad _c;

Callers

nothing calls this directly

Calls 4

_GreaterFunction · 0.85
_LessFunction · 0.85
_ScalarFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected