MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / GetOrCreateOpGradClosure

Method GetOrCreateOpGradClosure

oneflow/core/framework/op_expr.cpp:147–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145
146template<>
147Maybe<OpExprGradClosure> BuiltinOpExprImpl<UserOpConf>::GetOrCreateOpGradClosure() const {
148 if (!op_grad_func_.get()) {
149 CHECK_OR_RETURN((IsClassRegistered<std::string, OpExprGradFunctionIf>(proto().op_type_name())))
150 << "The gradient function for op " << proto().op_type_name()
151 << " is not found. Please check whether it has been implemented and registered correctly.";
152 op_grad_func_.reset(NewObj<std::string, OpExprGradFunctionIf>(proto().op_type_name()));
153 JUST(op_grad_func_->Init(*this));
154 }
155 return std::make_shared<OpExprGradClosure>(op_grad_func_);
156}
157
158template<>
159Maybe<autocast::AutoCastMeta> BuiltinOpExprImpl<UserOpConf>::GetOrCreateAutoCastMeta() const {

Callers 1

ApplyMethod · 0.80

Calls 3

getMethod · 0.45
resetMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected