forked from mindspore-Ecosystem/mindspore
optimize implicit convert error message
This commit is contained in:
parent
3022c7809c
commit
26410ccf75
|
@ -1271,10 +1271,10 @@ void ForwardExecutor::DoSignatrueCast(const PrimitivePyPtr &prim,
|
|||
}
|
||||
|
||||
if (!py::isinstance<tensor::Tensor>(obj) && !py::isinstance<py::int_>(obj) && !py::isinstance<py::float_>(obj)) {
|
||||
MS_EXCEPTION(TypeError) << "For '" << prim->name() << "', the " << i
|
||||
<< "th input is a not support implicit conversion type: "
|
||||
<< py::cast<std::string>(obj.attr("__class__").attr("__name__")) << ", and the value is "
|
||||
<< py::cast<py::str>(obj) << ".";
|
||||
MS_EXCEPTION(TypeError) << "For '" << prim->name() << "', the " << i << "th input " << signature[i].name
|
||||
<< " is a not support implicit conversion. "
|
||||
<< "Its type is " << py::cast<std::string>(obj.attr("__class__").attr("__name__"))
|
||||
<< ", and the value is " << py::cast<py::str>(obj) << ". Only support Tensor or Scalar.";
|
||||
}
|
||||
py::object cast_output = DoAutoCast(input_args[i], it->second, op_exec_info->op_name, i);
|
||||
input_args[i] = cast_output;
|
||||
|
|
|
@ -111,7 +111,7 @@ def test_float_tensor_and_str_add():
|
|||
y = "ok"
|
||||
with pytest.raises(TypeError) as er:
|
||||
ret = x + y
|
||||
assert "For 'Add', the 1th input is a not support implicit conversion type: str" in str(er.value)
|
||||
assert "For 'Add', the 1th input var is a not support implicit conversion. Its type is" in str(er.value)
|
||||
|
||||
|
||||
def test_float_tensor_and_tuple_add():
|
||||
|
|
Loading…
Reference in New Issue