!26784 Throw the original exception in PyNative lazy build

Merge pull request !26784 from caifubi/master-pynative-lazy-build-bug
This commit is contained in:
i-robot 2021-11-26 02:02:24 +00:00 committed by Gitee
commit 3dc58d5934
1 changed files with 13 additions and 0 deletions

View File

@ -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<bool>(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()));