| 145 | |
| 146 | template<> |
| 147 | Maybe<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 | |
| 158 | template<> |
| 159 | Maybe<autocast::AutoCastMeta> BuiltinOpExprImpl<UserOpConf>::GetOrCreateAutoCastMeta() const { |