| 102 | } |
| 103 | |
| 104 | Maybe<void> RegisterTensorHook(const std::shared_ptr<Tensor>& self, |
| 105 | const AutogradMeta::Hook& hook) { |
| 106 | CHECK_OR_RETURN(self->requires_grad()) |
| 107 | << "cannot register a hook on a tensor that doesn't require gradient"; |
| 108 | if (!self->grad_fn_node()) { JUST(AddAccumulateFunctionNode(self)); } |
| 109 | self->mut_autograd_meta()->add_hook(hook); |
| 110 | return Maybe<void>::Ok(); |
| 111 | } |
| 112 | |
| 113 | Maybe<void> RegisterTensorPostGradAccumulationHook(const std::shared_ptr<Tensor>& self, |
| 114 | const AutogradMeta::Hook& hook) { |
no test coverage detected