From bbbffbb6a9b12721eb7775c34aeee7d9e2eb2988 Mon Sep 17 00:00:00 2001 From: zhangyihui Date: Thu, 7 Jan 2021 11:44:31 +0800 Subject: [PATCH] Modify the profiling_options parameter name --- .../device/common/memory_profiling.cc | 2 +- mindspore/context.py | 37 ++++++++++++++++--- mindspore/profiler/profiling.py | 6 +-- tests/ut/python/pynative_mode/test_context.py | 8 ++-- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/mindspore/ccsrc/profiler/device/common/memory_profiling.cc b/mindspore/ccsrc/profiler/device/common/memory_profiling.cc index 3ebe30e103..a538083633 100644 --- a/mindspore/ccsrc/profiler/device/common/memory_profiling.cc +++ b/mindspore/ccsrc/profiler/device/common/memory_profiling.cc @@ -25,7 +25,7 @@ namespace mindspore { namespace profiler { -constexpr char kOutputPath[] = "result_path"; +constexpr char kOutputPath[] = "output"; std::shared_ptr MemoryProfiling::AddGraphMemoryNode(uint32_t graph_id) { std::shared_ptr node = std::make_shared(graph_id); diff --git a/mindspore/context.py b/mindspore/context.py index bbab0a395e..33818071c9 100644 --- a/mindspore/context.py +++ b/mindspore/context.py @@ -551,17 +551,43 @@ def set_context(**kwargs): enable_profiling (bool): Whether to open profiling. Default: False. profiling_options (str): Set profiling collection options, operators can profiling data here. The values of profiling collection options are as follows, supporting the collection of multiple data. + - output: the saving the path of the profiling collection result file. The directory spectified by this + parameter needs to be created in advance on the training environment (container or host side) and ensure + that the running user configured during installation has read and write permissions.It supports the + configuration of absolute or relative paths(relative to the current path when executing the command line). + The absolute path configuration starts with '/', for example:/home/data/output. + The relative path configuration directly starts with the directory name,for example:output. - training_trace: collect iterative trajectory data, that is, the training task and software information of the AI software stack, to achieve performance analysis of the training task, focusing on data enhancement, forward and backward calculation, gradient aggregation update and other related data. + The value is on/off. + - task_trace: collect task trajectory data, that is, the hardware information of the HWTS/AICore of the Ascend 910 processor, and analyze the information of beginning and ending of the task. - - op_trace: collect single operator performance data. + The value is on/off. + + - aicpu: collect profiling data enhanced by aicpu data. The value is on/off. + + - fp_point: specify the start position of the forward operator of the training network iteration trajectory, + which is used to record the start timestamp of the forward calculation.The configuration value is the name + of the first operator specified in the forward direction. when the value is empty,the system will + automatically obtain the forward operator name. + + - bp_point: specify the end position of the iteration trajectory reversal operator of the training network, + record the end timestamp of the backward calculation. The configuration value is the name of the operator + after the specified reverse. when the value is empty,the system will automatically obtain the backward + operator name. + + - aic_metrics: the values are as follows: + ArithmeticUtilization: percentage statistics of various calculation indicators. + PipeUtilization: the time-consuming ratio of calculation unit and handling unit,this item is + the default value. + Memory: percentage of external memory read and write instructions. + MemoryL0: percentage of internal memory read and write instructions. + ResourceConflictRatio: proportion of pipline queue instructions. + The profiling_options is like '{"output":'/home/data/output','training_trace':'on'}' - The profiling can choose the combination of `training_trace`, `task_trace`, `training_trace` and - `task_trace` combination, and separated by colons; a single operator can choose `op_trace`, `op_trace` - cannot be combined with `training_trace` and `task_trace`. Default: "training_trace". check_bprop (bool): Whether to check bprop. Default: False. max_device_memory (str): Sets the maximum memory available for devices. Currently, it is only supported on GPU. The format is "xxGB". Default: "1024GB". @@ -588,7 +614,8 @@ def set_context(**kwargs): >>> context.set_context(mode=context.GRAPH_MODE, ... device_target="Ascend",device_id=0, save_graphs=True, ... save_graphs_path="/mindspore") - >>> context.set_context(enable_profiling=True, profiling_options="training_trace") + >>> context.set_context(enable_profiling=True, \ + profiling_options='{"output":"/home/data/output","training_trace":"on"}') >>> context.set_context(max_device_memory="3.5GB") >>> context.set_context(print_file_path="print.pb") >>> context.set_context(max_call_depth=80) diff --git a/mindspore/profiler/profiling.py b/mindspore/profiler/profiling.py index 0a65105b50..209836e7c2 100644 --- a/mindspore/profiler/profiling.py +++ b/mindspore/profiler/profiling.py @@ -116,13 +116,13 @@ class Profiler: bp_point = os.environ.get("PROFILING_BP_END", "") profiling_options = { - "result_path": self._output_path, + "output": self._output_path, "fp_point": fp_point, "bp_point": bp_point, "training_trace": "on", "task_trace": "on", - "ai_core_metrics": "PipeUtilization", - "aicpu_trace": "on" + "aic_metrics": "PipeUtilization", + "aicpu": "on" } profiling_options = json.dumps(profiling_options) diff --git a/tests/ut/python/pynative_mode/test_context.py b/tests/ut/python/pynative_mode/test_context.py index 68ce4223b5..56eb983d84 100644 --- a/tests/ut/python/pynative_mode/test_context.py +++ b/tests/ut/python/pynative_mode/test_context.py @@ -1,4 +1,4 @@ -# Copyright 2020 Huawei Technologies Co., Ltd +# Copyright 2020-2021 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -96,13 +96,13 @@ def test_profiling_options(): with pytest.raises(TypeError): context.set_context(profiling_options=1) profiling_options = { - "result_path": "", + "output": "", "fp_point": "", "bp_point": "", "training_trace": "on", "task_trace": "on", - "ai_core_metrics": "PipeUtilization", - "aicpu_trace": "on" + "aic_metrics": "PipeUtilization", + "aicpu": "on" } profiling_options = json.dumps(profiling_options) context.set_context(profiling_options=profiling_options)