optimize implicit convert error message

This commit is contained in:
chujinjin 2021-11-01 11:49:35 +08:00
parent 3022c7809c
commit 26410ccf75
2 changed files with 5 additions and 5 deletions

View File

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

View File

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