From 55ad5e2bc1c1a2faa1ba9505e44d519ac7e00f35 Mon Sep 17 00:00:00 2001 From: buxue Date: Mon, 15 Mar 2021 09:43:12 +0800 Subject: [PATCH] support NameError in PyNative mode --- mindspore/ccsrc/pipeline/pynative/pynative_execute.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc b/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc index 8a31302727..64491c7266 100644 --- a/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc +++ b/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc @@ -50,6 +50,7 @@ #include "pipeline/pynative/base.h" #include "pybind_api/api_register.h" +#include "pybind_api/pybind_patch.h" #include "vm/transform.h" #include "frontend/optimizer/ad/grad.h" @@ -106,6 +107,9 @@ void PynativeExecutorTry(std::function method, T } catch (const py::index_error &ex) { inst->ClearRes(); throw py::index_error(ex); + } catch (const py::name_error &ex) { + inst->ClearRes(); + throw py::name_error(ex); } catch (const std::exception &ex) { inst->ClearRes(); // re-throw this exception to Python interpreter to handle it