forked from mindspore-Ecosystem/mindspore
!17076 fix log error for pynative mode
From: @chujinjin Reviewed-by: @zhoufeng54,@kisnwang Signed-off-by: @kisnwang
This commit is contained in:
commit
04341b1dbc
|
@ -97,8 +97,8 @@ py::tuple check_bprop_out(const py::object &grads_obj, const py::tuple &py_args)
|
|||
grads = py::cast<py::tuple>(grads_obj);
|
||||
}
|
||||
if (grads.size() != py_args.size() - 2) {
|
||||
MS_EXCEPTION(ValueError) << "For user define net bprop, the gradients number: " << grads.size()
|
||||
<< " is not equal to the args number: " << py_args.size() - 2 << ".";
|
||||
MS_EXCEPTION(TypeError) << "For user define net bprop, the gradients number: " << grads.size()
|
||||
<< " is not equal to the args number: " << py_args.size() - 2 << ".";
|
||||
}
|
||||
if (MsContext::GetInstance()->get_param<bool>(MS_CTX_CHECK_BPROP_FLAG)) {
|
||||
for (size_t i = 0; i < grads.size(); i++) {
|
||||
|
|
|
@ -207,6 +207,6 @@ def test_user_define_bprop_check_number():
|
|||
context.set_context(mode=context.PYNATIVE_MODE, check_bprop=True)
|
||||
net = Net()
|
||||
grad_net = GradNet(net)
|
||||
with pytest.raises(ValueError) as ex:
|
||||
with pytest.raises(TypeError) as ex:
|
||||
ret = grad_net(x, y, sens)
|
||||
assert "For user define net bprop, the gradients number: 1 is not equal to the args number: 2." in str(ex.value)
|
||||
|
|
Loading…
Reference in New Issue