!17937 Clean GradOperation inappropriate implementation.

Merge pull request !17937 from 张清华/grad_opt0
This commit is contained in:
i-robot 2021-06-08 16:46:35 +08:00 committed by Gitee
commit 431c037ff5
1 changed files with 1 additions and 1 deletions

View File

@ -354,9 +354,9 @@ class GradOperation(GradOperation_):
fn(*args, **new_kwargs)
def __call__(self, fn, weights=None):
grad_ = GradOperation(self.get_all, self.get_by_list, self.sens_param)
if self.grad_fn is not None and self.fn == fn:
return self.grad_fn
grad_ = GradOperation(self.get_all, self.get_by_list, self.sens_param)
if context.get_context("mode") == context.GRAPH_MODE:
if self.get_by_list:
@ms_function(obj=fn)