diff --git a/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc b/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc index 72c3edb95b0..5b98240ff1a 100644 --- a/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc +++ b/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc @@ -163,8 +163,14 @@ std::string GetId(const py::object &obj) { return prefix; } - py::object ret = parse::python_adapter::CallPyFn(parse::PYTHON_MOD_PARSE_MODULE, parse::PYTHON_MOD_GET_OBJ_ID, obj); - return py::cast(ret); + if (py::isinstance(obj)) { + auto cell = py::cast(obj); + MS_EXCEPTION_IF_NULL(cell); + return std::to_string(reinterpret_cast(cell.get())); + } else { + py::object ret = parse::python_adapter::CallPyFn(parse::PYTHON_MOD_PARSE_MODULE, parse::PYTHON_MOD_GET_OBJ_ID, obj); + return py::cast(ret); + } } std::map> GetTypeIndex(const std::vector &dtypes) {