From bd6de7162b7824f84d115d3d2f3b1fc199ba4357 Mon Sep 17 00:00:00 2001 From: caifubi Date: Thu, 25 Nov 2021 14:58:39 +0800 Subject: [PATCH] Throw original exection in PyNative lazy build --- mindspore/ccsrc/vm/backend.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mindspore/ccsrc/vm/backend.cc b/mindspore/ccsrc/vm/backend.cc index 97e6634ef48..bbe4f4ab9ec 100644 --- a/mindspore/ccsrc/vm/backend.cc +++ b/mindspore/ccsrc/vm/backend.cc @@ -27,6 +27,7 @@ #include "pipeline/jit/parse/data_converter.h" #include "ir/anf.h" #include "pybind_api/ir/base_ref_py.h" +#include "pybind_api/pybind_patch.h" #include "utils/callbacks.h" #include "utils/convert_utils.h" #include "utils/log_adapter.h" @@ -1160,6 +1161,18 @@ void MindRTBackend::LazyExecuteTaskCallback() { ms_context->set_param(MS_CTX_ENABLE_PYNATIVE_INFER, infer_flag); MS_LOG(DEBUG) << "End"; + } catch (const py::type_error &ex) { + op_lazy_builder.Reset(); + throw py::type_error(ex); + } catch (const py::value_error &ex) { + op_lazy_builder.Reset(); + throw py::value_error(ex); + } catch (const py::index_error &ex) { + op_lazy_builder.Reset(); + throw py::index_error(ex); + } catch (const py::name_error &ex) { + op_lazy_builder.Reset(); + throw py::name_error(ex); } catch (const std::exception &ex) { op_lazy_builder.Reset(); throw(std::runtime_error(ex.what()));