From 490c0521ac9bbda46ed1720b27908f6d353f3c08 Mon Sep 17 00:00:00 2001 From: dayschan Date: Wed, 28 Apr 2021 17:51:33 +0800 Subject: [PATCH] Disable GraphKernel in PynativeMode --- mindspore/ccsrc/utils/context/graph_kernel_flags.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mindspore/ccsrc/utils/context/graph_kernel_flags.cc b/mindspore/ccsrc/utils/context/graph_kernel_flags.cc index 7bc67993d65..528accaf726 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) {