change the error type from RuntimeError to TypeError

This commit is contained in:
zhousiyi 2021-07-22 06:38:12 +00:00
parent 347b0004ae
commit 9319eff958
2 changed files with 4 additions and 4 deletions

View File

@ -357,9 +357,9 @@ AnfNodePtr KPrim::BuildOutput(const FuncGraphPtr &bprop_fg, const FuncGraphPtr &
} else if (HasAbstractIOMonad(primal_node)) {
extra_node = NewValueNode(kIOMonad);
} else {
MS_LOG(EXCEPTION) << "Function: " << current_primal_fg->ToString()
<< ", has extra parameter which is not UMoand or IOMonad, but: "
<< primal_node->DebugString();
MS_EXCEPTION(TypeError) << "Function: " << current_primal_fg->ToString()
<< ", has extra parameter which is not UMoand or IOMonad, but: "
<< primal_node->DebugString();
}
extra_args.push_back(extra_node);
MS_LOG(DEBUG) << "Insert to bprop_fg for node: " << primal_node->DebugString();

View File

@ -181,7 +181,7 @@ def test_user_defined_bad_bprop():
net = GradNet(user_defined_net)
x = Tensor(np.array([2.0], np.float32))
y = Tensor(np.array([3.0], np.float32))
with pytest.raises(RuntimeError):
with pytest.raises(TypeError):
net(x, y)