diff --git a/mindspore/ccsrc/utils/context/graph_kernel_flags.cc b/mindspore/ccsrc/utils/context/graph_kernel_flags.cc index 7bc67993d6..528accaf72 100644 --- a/mindspore/ccsrc/utils/context/graph_kernel_flags.cc +++ b/mindspore/ccsrc/utils/context/graph_kernel_flags.cc @@ -152,6 +152,14 @@ void GraphKernelFlags::Refresh() { for (auto &item : flag_map) { MS_LOG(WARNING) << "Unknown GraphKernel flag: " << item.first; } + if (opt_level > 0) { + auto context = MsContext::GetInstance(); + MS_EXCEPTION_IF_NULL(context); + if (context->get_param(MS_CTX_EXECUTION_MODE) != kGraphMode) { + MS_LOG(WARNING) << "GraphKernel only support GRAPH_MODE"; + opt_level = 0; + } + } } void GraphKernelFlags::RegisterFlags(std::map *flag_map) {