!9224 clear resource when exception in pynative mode

From: @chujinjin
Reviewed-by: @kisnwang,@jjfeing
Signed-off-by: @jjfeing
This commit is contained in:
mindspore-ci-bot 2020-11-30 21:41:24 +08:00 committed by Gitee
commit 4bd9460e45
1 changed files with 1 additions and 0 deletions

View File

@ -1687,6 +1687,7 @@ FuncGraphPtr PynativeExecutor::MakeGradGraph(const py::object &cell, const py::a
need_replace_param = true;
size_t par_number = py::tuple(parse::python_adapter::CallPyObjMethod(cell, "get_parameters")).size();
if (par_number > 0) {
ClearRes();
MS_LOG(EXCEPTION) << "When user defines the net bprop, there are " << par_number
<< " parameters that is not supported in the net.";
}