!22815 Update bprop error information

Merge pull request !22815 from JoyLvliang/update_bprop_error_information
This commit is contained in:
i-robot 2021-09-03 01:31:15 +00:00 committed by Gitee
commit 60d583190b
2 changed files with 2 additions and 3 deletions

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);

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():