From e1e11b9a47ef06066aff1d72f589516e3e2f3a8d Mon Sep 17 00:00:00 2001 From: baihuawei Date: Mon, 13 Sep 2021 17:40:16 +0800 Subject: [PATCH] fix some bugs --- mindspore/ccsrc/debug/data_dump/dump_json_parser.cc | 6 ++++++ mindspore/ccsrc/pipeline/jit/pipeline.cc | 2 +- mindspore/ccsrc/runtime/device/cpu/kernel_select_cpu.cc | 3 ++- mindspore/ccsrc/utils/utils.h | 4 +++- mindspore/ccsrc/vm/transform.cc | 2 +- mindspore/profiler/profiling.py | 3 +++ tests/st/pynative/test_pynative_resnet50_ascend.py | 2 +- 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc b/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc index 9a676aecb5d..56f5ea53257 100644 --- a/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc +++ b/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc @@ -60,10 +60,16 @@ std::string GetIfstreamString(const std::ifstream &ifstream) { } bool DumpJsonParser::IsDumpEnabled() { + auto single_op = common::GetEnv(kGraphOpRun); auto config_path = common::GetEnv(kMindsporeDumpConfig); if (config_path.empty()) { return false; } + if (!single_op.empty() && single_op == "1") { + MS_LOG(WARNING) << "Dump is not supported when task is not sink. Please set env GRAPH_OP_RUN to 0 to enable task " + "sink, so that the data can be dumped."; + return false; + } MS_LOG(INFO) << "Dump config path is " << config_path; auto context = MsContext::GetInstance(); diff --git a/mindspore/ccsrc/pipeline/jit/pipeline.cc b/mindspore/ccsrc/pipeline/jit/pipeline.cc index 25542b0f5a4..8f0962df671 100644 --- a/mindspore/ccsrc/pipeline/jit/pipeline.cc +++ b/mindspore/ccsrc/pipeline/jit/pipeline.cc @@ -1254,7 +1254,7 @@ void InitHccl() { uint32_t device_id = ms_context->get_param(MS_CTX_DEVICE_ID); #if ENABLE_D bool task_sink = true; - auto single_op = std::getenv(kAttrGraphOpRun); + auto single_op = std::getenv(kGraphOpRun); if (single_op && std::string(single_op) == "1") { task_sink = false; } diff --git a/mindspore/ccsrc/runtime/device/cpu/kernel_select_cpu.cc b/mindspore/ccsrc/runtime/device/cpu/kernel_select_cpu.cc index d096401288f..e7cc1e1d356 100644 --- a/mindspore/ccsrc/runtime/device/cpu/kernel_select_cpu.cc +++ b/mindspore/ccsrc/runtime/device/cpu/kernel_select_cpu.cc @@ -213,7 +213,8 @@ void KernelNotSupportException(const AnfNodePtr &kernel_node, const std::vector< } operator_info << ") "; } - operator_info << "is not support."; + operator_info << "is not support. This error means the current type is not supported, please refer to the MindSpore " + "doc for supported types"; MS_EXCEPTION(TypeError) << operator_info.str() << " Trace: " << trace::DumpSourceLines(kernel_node); } diff --git a/mindspore/ccsrc/utils/utils.h b/mindspore/ccsrc/utils/utils.h index ba4fd144ba8..65be94764b5 100644 --- a/mindspore/ccsrc/utils/utils.h +++ b/mindspore/ccsrc/utils/utils.h @@ -470,7 +470,6 @@ constexpr auto kAttrMultiCallEnd = "multicall_end"; constexpr auto kAttrProfilingIterEnd = "PROFILING_ITER_END"; constexpr auto kAttrHiddenSize = "hidden_size"; constexpr auto kAttrInputSize = "input_size"; -constexpr auto kAttrGraphOpRun = "GRAPH_OP_RUN"; // primal attr key name constexpr auto kPrimalAttrForwardNodeName = "forward_node_name"; @@ -479,6 +478,9 @@ constexpr auto kPrimalAttrForwardNodeName = "forward_node_name"; constexpr auto kValueTargetSwitch = "target_switch"; constexpr auto kValueTargetOther = "target_other"; +// env key +constexpr auto kGraphOpRun = "GRAPH_OP_RUN"; + // some size const size_t kShape4dDims = 4; const size_t kShape3dDims = 3; diff --git a/mindspore/ccsrc/vm/transform.cc b/mindspore/ccsrc/vm/transform.cc index c04b2a4fc5a..981d281fdd7 100644 --- a/mindspore/ccsrc/vm/transform.cc +++ b/mindspore/ccsrc/vm/transform.cc @@ -602,7 +602,7 @@ BackendPtr CreateBackend() { backend->set_is_multi_graph_sink(false); context_ptr->set_param(MS_CTX_IS_MULTI_GRAPH_SINK, false); } else { - auto single_op = std::getenv(kAttrGraphOpRun); + auto single_op = std::getenv(kGraphOpRun); if (single_op && std::string(single_op) == "1") { context_ptr->set_param(MS_CTX_ENABLE_TASK_SINK, false); } diff --git a/mindspore/profiler/profiling.py b/mindspore/profiler/profiling.py index 1d1afe53212..af0a4b0d1a0 100644 --- a/mindspore/profiler/profiling.py +++ b/mindspore/profiler/profiling.py @@ -219,6 +219,9 @@ class Profiler: raise TypeError("The parameter profile_memory must be bool") if kwargs: logger.warning("There are invalid params which don't work.") + task_sink = os.getenv("GRAPH_OP_RUN") + if task_sink and task_sink == "1": + logger.warning("Profiling is not supported when task is not sink.") def analyse(self): """ diff --git a/tests/st/pynative/test_pynative_resnet50_ascend.py b/tests/st/pynative/test_pynative_resnet50_ascend.py index eebd3b18ce8..b7fd0316774 100644 --- a/tests/st/pynative/test_pynative_resnet50_ascend.py +++ b/tests/st/pynative/test_pynative_resnet50_ascend.py @@ -408,7 +408,7 @@ class GradWrap(Cell): @pytest.mark.level1 @pytest.mark.platform_arm_ascend_training @pytest.mark.platform_x86_ascend_training -@pytest.mark.env_onecard +@pytest.mark.env_single def test_pynative_resnet50(): context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")