diff --git a/imperative/python/src/tensor.cpp b/imperative/python/src/tensor.cpp index a93dc43d77ea0045ecaf2221434884a2b2adbe22..887dbd1342c2f48b98bfd3921da33deaf536aa65 100644 --- a/imperative/python/src/tensor.cpp +++ b/imperative/python/src/tensor.cpp @@ -672,7 +672,17 @@ PyObject* TensorWrapper::format() { PyObject* TensorWrapper::numpy() { auto hv = m_tensor->numpy(); if (!hv) { - PyErr_SetString(PyExc_ValueError, "tensor invalid"); + if (TransformationManager::get_instance() + .segments[TransformationManager::Segment::Eval] + .size() > 1) { + PyErr_SetString( + PyExc_ValueError, + "tensor invalid, can not infer value of this tensor under " + "trace(symbolic=True). You can try to use trace(symbolic=False) to " + "avoid this issue."); + } else { + PyErr_SetString(PyExc_ValueError, "tensor invalid"); + } return nullptr; } auto arr = py::reinterpret_steal(