diff --git a/imperative/python/src/tensor_utils.cpp b/imperative/python/src/tensor_utils.cpp index e8f75b34ec43d3b6f9bd0823237f8e5fe058391a..906615f5d3c42c65276102ea4962e652b7ae213f 100644 --- a/imperative/python/src/tensor_utils.cpp +++ b/imperative/python/src/tensor_utils.cpp @@ -427,8 +427,8 @@ py::object _astype_cpp(py::handle tensor, py::handle dtype_hdl) { "can not convert to numpy.dtype from %s", dtype_hdl.ptr()->ob_type->tp_name)); } - PyArray_Descr* cur = npy::dtype_mgb2np_descr(_get_dtype(tensor)).get(); - if (!dtype_equal(cur, descr)) { + auto&& cur = npy::dtype_mgb2np_descr(_get_dtype(tensor)); + if (!dtype_equal(cur.get(), descr)) { std::shared_ptr op = TypeCvt::make(npy::dtype_np2mgb_descr(descr)); py::object Op = py::cast(op); PyObject* p[2] = {Op.ptr(), tensor.ptr()};