forked from mindspore-Ecosystem/mindspore
[ME] Optimize the error message of the operator module
This commit is contained in:
parent
b6ad18cb51
commit
f9a88a01bc
|
@ -347,11 +347,10 @@ FuncGraphPtr DoSignatureMetaFuncGraph::GenerateFuncGraph(const AbstractBasePtrLi
|
|||
|
||||
void RaiseExceptionForConvertRefDtype(const std::string &func_name, const std::string &ref_type,
|
||||
const std::string &target_type) {
|
||||
MS_LOG(EXCEPTION) << "For '" << func_name << "' operator, "
|
||||
<< "the type of writable argument is '" << ref_type << "', "
|
||||
<< "but the largest type in the same SignatureEnumDType is '" << target_type
|
||||
<< "'. The writable arg type is not equal to the largest type, "
|
||||
<< "so can not cast automatically.";
|
||||
MS_LOG(EXCEPTION) << "Data type conversion of parameter is not supported, so data type " << ref_type
|
||||
<< " cannot be converted to data type " << target_type << " by inserting cast automatically.\n"
|
||||
<< "For more details, please refer at "
|
||||
<< "https://www.mindspore.cn/docs/note/zh-CN/master/operator_list_implicit.html.";
|
||||
}
|
||||
void RaiseExceptionForCheckParameter(const std::string &func_name, size_t i, const std::string &source_type) {
|
||||
MS_EXCEPTION(TypeError) << "Function " << func_name << "'s input " << i << " should be a Parameter, but "
|
||||
|
|
|
@ -165,7 +165,6 @@ def test_map_param_cast():
|
|||
input_me_x = Tensor(np.random.randn(2, 3, 4, 5).astype(np.float64))
|
||||
|
||||
net = MapNet()
|
||||
with pytest.raises(Exception, match="For 'S-Prim-Assign' operator, "
|
||||
"the type of writable argument is 'float32'"):
|
||||
with pytest.raises(Exception, match="Data type conversion of parameter is not supported"):
|
||||
ret = net(input_me_x)
|
||||
print("ret:", ret)
|
||||
|
|
|
@ -132,9 +132,6 @@ def test_float_tensor_and_list_add():
|
|||
|
||||
def test_float_tensor_and_bool_tensors_add_grad():
|
||||
class Net(nn.Cell):
|
||||
def __init__(self):
|
||||
super(Net, self).__init__()
|
||||
|
||||
def construct(self, x, y):
|
||||
return x + y
|
||||
|
||||
|
@ -160,9 +157,6 @@ def test_float_tensor_and_bool_tensors_add_grad():
|
|||
|
||||
def test_float_tensor_and_int_tensors_sub_grad():
|
||||
class Net(nn.Cell):
|
||||
def __init__(self):
|
||||
super(Net, self).__init__()
|
||||
|
||||
def construct(self, x, y):
|
||||
return x - y
|
||||
|
||||
|
@ -188,9 +182,6 @@ def test_float_tensor_and_int_tensors_sub_grad():
|
|||
|
||||
def test_float16_tensor_and_float32_tensors_sub_grad():
|
||||
class Net(nn.Cell):
|
||||
def __init__(self):
|
||||
super(Net, self).__init__()
|
||||
|
||||
def construct(self, x, y):
|
||||
return x - y
|
||||
|
||||
|
@ -216,9 +207,6 @@ def test_float16_tensor_and_float32_tensors_sub_grad():
|
|||
|
||||
def test_float_tensor_and_int_add_grad():
|
||||
class Net(nn.Cell):
|
||||
def __init__(self):
|
||||
super(Net, self).__init__()
|
||||
|
||||
def construct(self, x):
|
||||
return x + 2
|
||||
|
||||
|
@ -241,9 +229,6 @@ def test_float_tensor_and_int_add_grad():
|
|||
|
||||
def test_int8_tensor_and_uint8_tensors_add_grad():
|
||||
class Net(nn.Cell):
|
||||
def __init__(self):
|
||||
super(Net, self).__init__()
|
||||
|
||||
def construct(self, x, y):
|
||||
return x + y
|
||||
|
||||
|
@ -266,6 +251,7 @@ def test_int8_tensor_and_uint8_tensors_add_grad():
|
|||
assert (ret[0].asnumpy() == sens.asnumpy()).all()
|
||||
assert (ret[1].asnumpy() == sens.asnumpy()).all()
|
||||
|
||||
|
||||
class AssignCheck(nn.Cell):
|
||||
""" NetWithNDarray definition """
|
||||
|
||||
|
@ -285,4 +271,4 @@ def test_assign_check_in_sig():
|
|||
y = Tensor(3, ms.uint8)
|
||||
with pytest.raises(RuntimeError) as e:
|
||||
net(x, y)
|
||||
assert "can not cast automatically" in e.value.args[0]
|
||||
assert "Data type conversion of parameter is not supported" in e.value.args[0]
|
||||
|
|
Loading…
Reference in New Issue