Browse Source

!22815 Update bprop error information

Merge pull request !22815 from JoyLvliang/update_bprop_error_information
tags/v1.5.0-rc1
i-robot Gitee 4 years ago
parent
commit
60d583190b
2 changed files with 2 additions and 3 deletions
  1. +1
    -2
      mindspore/ccsrc/pipeline/pynative/pynative_execute.cc
  2. +1
    -1
      tests/ut/python/pynative_mode/test_user_define_bprop_check.py

+ 1
- 2
mindspore/ccsrc/pipeline/pynative/pynative_execute.cc View File

@@ -2367,8 +2367,7 @@ void GradExecutor::DoGradForCustomBprop(const py::object &cell, const py::object
MS_LOG(DEBUG) << "Do grad for custom bprop";
size_t par_number = py::tuple(parse::python_adapter::CallPyObjMethod(cell, "get_parameters")).size();
if (par_number > 0) {
MS_LOG(EXCEPTION) << "When user defines the net bprop, there are " << par_number
<< " parameters that is not supported in the net.";
MS_LOG(EXCEPTION) << "When user defines the net bprop, the 'Parameter' data type is not supported in the net.";
}
py::function bprop_func = py::getattr(cell, parse::CUSTOM_BPROP_NAME);
auto bprop_func_cellid = GetId(bprop_func);


+ 1
- 1
tests/ut/python/pynative_mode/test_user_define_bprop_check.py View File

@@ -177,7 +177,7 @@ def test_user_define_bprop_check_parameter():
grad_net = GradNet(net)
with pytest.raises(RuntimeError) as ex:
ret = grad_net(x, sens)
assert "When user defines the net bprop, there are 1 parameters that is not supported in the net." in str(ex.value)
assert "When user defines the net bprop, the 'Parameter' data type is not supported in the net." in str(ex.value)


def test_user_define_bprop_check_number():


Loading…
Cancel
Save