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

Method divideAvoidZero

tools/train/source/grad/OpGrad.cpp:68–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 return gradCommon({loss}, parameters, backwardMap, blockName);
67}
68Express::VARP OpGrad::divideAvoidZero(MNN::Express::VARP y, MNN::Express::VARP x) {
69 auto p = MNN::Express::_Abs(x);
70 auto sx = MNN::Express::_Sign(x);
71 p = MNN::Express::_Maximum(p, MNN::Express::_Scalar<float>(0.000001f));
72 return MNN::Express::_Divide(y, p) * sx;
73}
74static std::once_flag gInit;
75void OpGrad::init() {
76 std::call_once(gInit, []() {

Callers

nothing calls this directly

Calls 4

_AbsFunction · 0.85
_SignFunction · 0.85
_MaximumFunction · 0.85
_DivideFunction · 0.85

Tested by

no test coverage detected