From c9b5650a0f7837602b9d39c463955d5dc5dacabd Mon Sep 17 00:00:00 2001 From: liangzhibo Date: Thu, 29 Feb 2024 16:00:52 +0800 Subject: [PATCH] Enable CodeHook use strict mode --- mindspore/ccsrc/pipeline/jit/pi/common.cc | 2 ++ mindspore/ccsrc/pipeline/jit/pi/graph_capture/code_generator.cc | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mindspore/ccsrc/pipeline/jit/pi/common.cc b/mindspore/ccsrc/pipeline/jit/pi/common.cc index aef073d1060..96065f574ed 100644 --- a/mindspore/ccsrc/pipeline/jit/pi/common.cc +++ b/mindspore/ccsrc/pipeline/jit/pi/common.cc @@ -1402,7 +1402,9 @@ PyObject *EvalFrame(PyThreadState *tstate, PyFrameObject *f, int exc) { } py::object res; try { + common::SetEnv("MS_DEV_JIT_SYNTAX_LEVEL", "0"); res = CodeHook(tstate, c, f); + common::SetEnv("MS_DEV_JIT_SYNTAX_LEVEL", "2"); } catch (py::error_already_set &e) { MS_LOG(ERROR) << "execute failed with " << e.what() << " at " << std::string(py::str(reinterpret_cast(f->f_code))); diff --git a/mindspore/ccsrc/pipeline/jit/pi/graph_capture/code_generator.cc b/mindspore/ccsrc/pipeline/jit/pi/graph_capture/code_generator.cc index 6b938b0c1cc..13b286180b9 100644 --- a/mindspore/ccsrc/pipeline/jit/pi/graph_capture/code_generator.cc +++ b/mindspore/ccsrc/pipeline/jit/pi/graph_capture/code_generator.cc @@ -1082,9 +1082,7 @@ py::object MindCodeBreakGenerator::MakeCopyCode(const std::string &co_name, int } phase += ".pi_jit"; MindCompiler::CompileInfo compile_info{co_name, co_argcount, co_kwonlyargcount, co_flags}; - common::SetEnv("MS_DEV_JIT_SYNTAX_LEVEL", "0"); CallableGraph callable = mindspore::pijit::MindCompiler::Compile(func_graph, args, py::dict(), phase, compile_info); - common::SetEnv("MS_DEV_JIT_SYNTAX_LEVEL", "2"); // Set NativeFunc. auto parent = getJitCompileResults(reinterpret_cast(co_), false); if (make_graph) {