mindspore 2.7.0__cp310-cp310-win_amd64.whl → 2.7.0rc1__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/__init__.py +1 -1
- mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +2 -2
- mindspore/_extends/builtin_operations.py +3 -3
- mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
- mindspore/_extends/parse/__init__.py +3 -3
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -0
- mindspore/_extends/parse/parser.py +22 -28
- mindspore/_extends/parse/standard_method.py +1 -15
- mindspore/_extends/pijit/pijit_func_white_list.py +5 -2
- mindspore/_extends/remote/kernel_build_server_ascend.py +75 -0
- mindspore/amp.py +18 -0
- mindspore/avcodec-59.dll +0 -0
- mindspore/avdevice-59.dll +0 -0
- mindspore/avfilter-8.dll +0 -0
- mindspore/avformat-59.dll +0 -0
- mindspore/avutil-57.dll +0 -0
- mindspore/common/__init__.py +12 -18
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +38 -102
- mindspore/common/_utils.py +1 -9
- mindspore/common/api.py +106 -155
- mindspore/common/{dynamic_shape/auto_dynamic_shape.py → auto_dynamic_shape.py} +23 -17
- mindspore/common/dtype.py +57 -98
- mindspore/common/dump.py +1 -1
- mindspore/common/file_system.py +9 -59
- mindspore/common/hook_handle.py +3 -22
- mindspore/common/np_dtype.py +3 -3
- mindspore/common/parameter.py +20 -4
- mindspore/common/recompute.py +4 -2
- mindspore/common/tensor.py +52 -38
- mindspore/communication/_hccl_management.py +297 -0
- mindspore/context.py +21 -15
- mindspore/dataset/__init__.py +1 -1
- mindspore/dataset/audio/transforms.py +1 -1
- mindspore/dataset/core/config.py +1 -35
- mindspore/dataset/engine/datasets.py +315 -330
- mindspore/dataset/engine/datasets_user_defined.py +22 -38
- mindspore/dataset/transforms/c_transforms.py +2 -2
- mindspore/dataset/transforms/transforms.py +3 -3
- mindspore/dataset/vision/__init__.py +1 -1
- mindspore/dataset/vision/py_transforms.py +8 -8
- mindspore/dataset/vision/transforms.py +5 -17
- mindspore/dataset/vision/utils.py +21 -632
- mindspore/device_context/ascend/op_tuning.py +1 -35
- mindspore/dnnl.dll +0 -0
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +0 -3
- mindspore/include/api/cell.h +4 -28
- mindspore/include/api/cfg.h +7 -24
- mindspore/include/api/context.h +0 -1
- mindspore/include/api/delegate.h +2 -0
- mindspore/include/api/dual_abi_helper.h +19 -100
- mindspore/include/api/graph.h +1 -14
- mindspore/include/api/kernel.h +3 -16
- mindspore/include/api/kernel_api.h +1 -9
- mindspore/include/api/metrics/accuracy.h +0 -9
- mindspore/include/api/model.h +1 -5
- mindspore/include/api/model_group.h +0 -4
- mindspore/include/api/model_parallel_runner.h +0 -2
- mindspore/include/api/status.h +10 -48
- mindspore/include/api/types.h +1 -6
- mindspore/include/dataset/constants.h +0 -9
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/cifar10.py +2 -3
- mindspore/mindrecord/tools/cifar10_to_mr.py +5 -5
- mindspore/mindspore_backend_common.dll +0 -0
- mindspore/mindspore_backend_manager.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_cpu_res_manager.dll +0 -0
- mindspore/mindspore_dump.dll +0 -0
- mindspore/mindspore_frontend.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_memory_pool.dll +0 -0
- mindspore/mindspore_ms_backend.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mindspore_ops_host.dll +0 -0
- mindspore/mindspore_ops_kernel_common.dll +0 -0
- mindspore/mindspore_profiler.dll +0 -0
- mindspore/mindspore_pyboost.dll +0 -0
- mindspore/mindspore_pynative.dll +0 -0
- mindspore/mindspore_res_manager.dll +0 -0
- mindspore/mindspore_runtime_pipeline.dll +0 -0
- mindspore/mint/distributed/__init__.py +0 -4
- mindspore/mint/distributed/distributed.py +14 -217
- mindspore/mint/nn/layer/_functions.py +2 -1
- mindspore/mint/nn/layer/conv.py +6 -6
- mindspore/mint/nn/layer/normalization.py +3 -3
- mindspore/nn/cell.py +174 -216
- mindspore/nn/layer/activation.py +2 -4
- mindspore/nn/layer/basic.py +13 -7
- mindspore/nn/layer/image.py +1 -1
- mindspore/nn/optim/adam.py +3 -1
- mindspore/nn/optim/lamb.py +3 -1
- mindspore/nn/optim/tft_wrapper.py +3 -2
- mindspore/nn/probability/distribution/_utils/utils.py +2 -2
- mindspore/nn/wrap/cell_wrapper.py +5 -39
- mindspore/nn/wrap/grad_reducer.py +15 -0
- mindspore/numpy/array_creations.py +2 -2
- mindspore/numpy/utils_const.py +1 -1
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/grad_inner_ops.py +9 -0
- mindspore/ops/_op_impl/cpu/__init__.py +0 -1
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +2 -12
- mindspore/ops/auto_generate/gen_extend_func.py +4 -4
- mindspore/ops/auto_generate/gen_ops_def.py +16 -290
- mindspore/ops/auto_generate/gen_ops_prim.py +76 -563
- mindspore/ops/composite/base.py +1 -1
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
- mindspore/ops/function/__init__.py +0 -1
- mindspore/ops/function/array_func.py +6 -10
- mindspore/ops/function/debug_func.py +2 -4
- mindspore/ops/function/grad/grad_func.py +12 -4
- mindspore/ops/function/math_func.py +32 -44
- mindspore/ops/function/nn_func.py +20 -18
- mindspore/ops/functional.py +1 -2
- mindspore/ops/functional_overload.py +12 -23
- mindspore/ops/operations/_inner_ops.py +12 -11
- mindspore/ops/operations/array_ops.py +50 -4
- mindspore/ops/operations/comm_ops.py +15 -1
- mindspore/ops/operations/custom_ops.py +4 -10
- mindspore/ops/operations/debug_ops.py +6 -6
- mindspore/ops/operations/manually_defined/ops_def.py +12 -12
- mindspore/ops/operations/math_ops.py +5 -5
- mindspore/ops/operations/nn_ops.py +1 -1
- mindspore/ops/primitive.py +10 -3
- mindspore/ops/tensor_method.py +7 -16
- mindspore/ops_generate/pyboost/gen_pyboost_func.py +16 -0
- mindspore/parallel/_auto_parallel_context.py +15 -5
- mindspore/parallel/_parallel_serialization.py +2 -3
- mindspore/parallel/_ps_context.py +2 -2
- mindspore/parallel/_transformer/transformer.py +4 -4
- mindspore/parallel/_utils.py +11 -5
- mindspore/parallel/auto_parallel.py +9 -23
- mindspore/parallel/checkpoint_transform.py +0 -2
- mindspore/parallel/cluster/process_entity/_api.py +1 -4
- mindspore/parallel/cluster/run.py +3 -5
- mindspore/parallel/function/reshard_func.py +5 -6
- mindspore/parallel/nn/parallel_cell_wrapper.py +3 -40
- mindspore/parallel/nn/parallel_grad_reducer.py +8 -0
- mindspore/parallel/shard.py +21 -7
- mindspore/parallel/transform_safetensors.py +4 -10
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +9 -10
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +1 -1
- mindspore/profiler/common/msprof_cmd_tool.py +2 -2
- mindspore/profiler/common/path_manager.py +0 -9
- mindspore/profiler/common/profiler_context.py +2 -25
- mindspore/profiler/common/profiler_meta_data.py +0 -1
- mindspore/profiler/common/profiler_op_analyse.py +6 -10
- mindspore/{ops/_op_impl/cpu/joinedstr_op.py → profiler/common/validator/__init__.py} +1 -15
- mindspore/profiler/common/validator/validate_path.py +84 -0
- mindspore/profiler/dynamic_profiler.py +46 -91
- mindspore/profiler/envprofiler.py +5 -30
- mindspore/profiler/experimental_config.py +1 -16
- mindspore/profiler/platform/cpu_profiler.py +4 -10
- mindspore/profiler/platform/npu_profiler.py +1 -1
- mindspore/profiler/profiler.py +145 -193
- mindspore/profiler/profiler_action_controller.py +1 -1
- mindspore/profiler/profiler_interface.py +2 -2
- mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
- mindspore/runtime/__init__.py +4 -6
- mindspore/runtime/executor.py +0 -27
- mindspore/runtime/memory.py +0 -1
- mindspore/runtime/thread_bind_core.py +1 -1
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +3 -3
- mindspore/train/amp.py +3 -0
- mindspore/train/callback/_callback.py +1 -2
- mindspore/train/callback/_checkpoint.py +8 -1
- mindspore/train/callback/_flops_collector.py +6 -10
- mindspore/train/callback/_train_fault_tolerance.py +7 -3
- mindspore/train/data_sink.py +4 -4
- mindspore/train/dataset_helper.py +5 -5
- mindspore/train/model.py +20 -4
- mindspore/train/serialization.py +15 -35
- mindspore/train/train_thor/model_thor.py +2 -2
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/hooks.py +81 -0
- mindspore/utils/utils.py +8 -8
- mindspore/version.py +1 -1
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +1 -1
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +193 -192
- mindspore/_extends/parallel_compile/akg_compiler/custom.py +0 -1109
- mindspore/common/dynamic_shape/__init__.py +0 -0
- mindspore/common/dynamic_shape/enable_dynamic.py +0 -197
- /mindspore/common/{dynamic_shape/_auto_dynamic.py → _auto_dynamic.py} +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import json
|
|
17
17
|
import os
|
|
18
18
|
from collections import defaultdict
|
|
19
|
-
from mindspore.profiler.common.
|
|
19
|
+
from mindspore.profiler.common.validator.validate_path import validate_and_normalize_path
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
class OpAnalyser:
|
|
@@ -34,7 +34,7 @@ class OpAnalyser:
|
|
|
34
34
|
def __init__(self, output_path, dev_id, op_names=None):
|
|
35
35
|
"""The parser for parsing framework files."""
|
|
36
36
|
self._dev_id = dev_id
|
|
37
|
-
self._output_path =
|
|
37
|
+
self._output_path = output_path
|
|
38
38
|
self.op_names = op_names
|
|
39
39
|
self.op_name = ''
|
|
40
40
|
self.framework_list = []
|
|
@@ -66,8 +66,7 @@ class OpAnalyser:
|
|
|
66
66
|
for filename in self.framework_info_dir:
|
|
67
67
|
op_side = filename.split('_')[0]
|
|
68
68
|
framework_file_path = os.path.join(self._output_path, filename)
|
|
69
|
-
|
|
70
|
-
PathManager.check_directory_path_readable(framework_file_path)
|
|
69
|
+
framework_file_path = validate_and_normalize_path(framework_file_path)
|
|
71
70
|
with open(framework_file_path, 'r') as f_obj:
|
|
72
71
|
framework_info = f_obj.readlines()
|
|
73
72
|
for line_info in framework_info:
|
|
@@ -86,8 +85,7 @@ class OpAnalyser:
|
|
|
86
85
|
for filename in self.cpu_detail_info_dir:
|
|
87
86
|
op_side = filename.split('_')[0]
|
|
88
87
|
op_detail_file_path = os.path.join(self._output_path, filename)
|
|
89
|
-
|
|
90
|
-
PathManager.check_directory_path_readable(op_detail_file_path)
|
|
88
|
+
op_detail_file_path = validate_and_normalize_path(op_detail_file_path)
|
|
91
89
|
with open(op_detail_file_path, 'r') as f_obj:
|
|
92
90
|
op_detail_info = f_obj.readlines()
|
|
93
91
|
for line_info in op_detail_info[1:]:
|
|
@@ -101,8 +99,7 @@ class OpAnalyser:
|
|
|
101
99
|
"""Get gpu operators execute times."""
|
|
102
100
|
if self.gpu_op_type_info_dir:
|
|
103
101
|
gpu_op_type_file_path = os.path.join(self._output_path, self.gpu_op_type_info_dir[0])
|
|
104
|
-
|
|
105
|
-
PathManager.check_directory_path_readable(gpu_op_type_file_path)
|
|
102
|
+
gpu_op_type_file_path = validate_and_normalize_path(gpu_op_type_file_path)
|
|
106
103
|
with open(gpu_op_type_file_path, 'r') as fp:
|
|
107
104
|
op_type_info = fp.readlines()
|
|
108
105
|
for line_info in op_type_info[1:]:
|
|
@@ -121,8 +118,7 @@ class OpAnalyser:
|
|
|
121
118
|
for filename in self.activity_info_dir:
|
|
122
119
|
op_side = filename.split('_')[0]
|
|
123
120
|
activity_file_path = os.path.join(self._output_path, filename)
|
|
124
|
-
|
|
125
|
-
PathManager.check_directory_path_readable(activity_file_path)
|
|
121
|
+
activity_file_path = validate_and_normalize_path(activity_file_path)
|
|
126
122
|
with open(activity_file_path, 'r') as file:
|
|
127
123
|
activity_info = file.readlines()
|
|
128
124
|
for line_info in activity_info[1:]:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2020 Huawei Technologies Co., Ltd
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -12,17 +12,3 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
# ============================================================================
|
|
15
|
-
"""JoinedStr op"""
|
|
16
|
-
from mindspore.ops.op_info_register import op_info_register, CpuRegOp, DataType
|
|
17
|
-
|
|
18
|
-
joinedstr_op_info = CpuRegOp("JoinedStr") \
|
|
19
|
-
.input(0, "x", "dynamic") \
|
|
20
|
-
.output(0, "y", "dynamic") \
|
|
21
|
-
.dtype_format(DataType.I32_Default, DataType.I32_Default) \
|
|
22
|
-
.get_op_info()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@op_info_register(joinedstr_op_info)
|
|
26
|
-
def _joinedstr_cpu():
|
|
27
|
-
"""JoinedStr cpu register"""
|
|
28
|
-
return
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Copyright 2019 Huawei Technologies Co., Ltd
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ============================================================================
|
|
15
|
+
"""Validate the input path."""
|
|
16
|
+
import os
|
|
17
|
+
import re
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def check_valid_character_of_path(file_path):
|
|
21
|
+
"""
|
|
22
|
+
Validates path.
|
|
23
|
+
|
|
24
|
+
The output path of profiler only supports alphabets(a-zA-Z), digit(0-9) or {'-', '_', '.', '/'}.
|
|
25
|
+
|
|
26
|
+
Note:
|
|
27
|
+
Chinese and other paths are not supported at present.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
path (str): Normalized Path.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
bool, whether valid.
|
|
34
|
+
"""
|
|
35
|
+
re_path = r'^[/\\_a-zA-Z0-9-_.@]+$'
|
|
36
|
+
path_valid = re.fullmatch(re_path, file_path)
|
|
37
|
+
if not path_valid:
|
|
38
|
+
msg = "The output path of profiler only supports alphabets(a-zA-Z), " \
|
|
39
|
+
"digit(0-9) or {'-', '_', '.', '/', '@'}, but got the absolute path= " + file_path
|
|
40
|
+
raise RuntimeError(msg)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def validate_and_normalize_path(
|
|
44
|
+
path,
|
|
45
|
+
check_absolute_path=False,
|
|
46
|
+
allow_parent_dir=True,
|
|
47
|
+
):
|
|
48
|
+
"""
|
|
49
|
+
Validates path and returns its normalized form.
|
|
50
|
+
|
|
51
|
+
If path has a valid scheme, treat path as url, otherwise consider path a
|
|
52
|
+
unix local path.
|
|
53
|
+
|
|
54
|
+
Note:
|
|
55
|
+
File scheme (rfc8089) is currently not supported.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
path (str): Path to be normalized.
|
|
59
|
+
check_absolute_path (bool): Whether check path scheme is supported.
|
|
60
|
+
allow_parent_dir (bool): Whether allow parent dir in path.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
str, normalized path.
|
|
64
|
+
"""
|
|
65
|
+
if not path:
|
|
66
|
+
raise RuntimeError("The path is invalid!")
|
|
67
|
+
|
|
68
|
+
path_str = str(path)
|
|
69
|
+
if not allow_parent_dir:
|
|
70
|
+
path_components = path_str.split("/")
|
|
71
|
+
if ".." in path_components:
|
|
72
|
+
raise RuntimeError("The parent path is not allowed!")
|
|
73
|
+
|
|
74
|
+
# path does not have valid schema, treat it as unix local path.
|
|
75
|
+
if check_absolute_path:
|
|
76
|
+
if not path_str.startswith("/"):
|
|
77
|
+
raise RuntimeError("The path is invalid!")
|
|
78
|
+
try:
|
|
79
|
+
# most unix systems allow
|
|
80
|
+
normalized_path = os.path.realpath(path)
|
|
81
|
+
except ValueError as err:
|
|
82
|
+
raise RuntimeError("The path is invalid!") from err
|
|
83
|
+
check_valid_character_of_path(normalized_path)
|
|
84
|
+
return normalized_path
|
|
@@ -24,9 +24,7 @@ import multiprocessing
|
|
|
24
24
|
|
|
25
25
|
from mindspore import log as logger
|
|
26
26
|
from mindspore.train import Callback
|
|
27
|
-
from mindspore.profiler import tensorboard_trace_handler, schedule
|
|
28
|
-
from mindspore.profiler.profiler import Profile
|
|
29
|
-
from mindspore.profiler.experimental_config import _ExperimentalConfig
|
|
27
|
+
from mindspore.profiler import Profiler, tensorboard_trace_handler, schedule
|
|
30
28
|
from mindspore.profiler.common.file_manager import FileManager
|
|
31
29
|
from mindspore.profiler.common.path_manager import PathManager
|
|
32
30
|
from mindspore.profiler.dynamic_profile.dynamic_profiler_config_context import DynamicProfilerConfigContext
|
|
@@ -43,7 +41,7 @@ def print_msg(msg):
|
|
|
43
41
|
|
|
44
42
|
class DynamicProfilerMonitorBase(Callback):
|
|
45
43
|
"""
|
|
46
|
-
Dynamic
|
|
44
|
+
Dynamic profile callback base class implementing the dynamic profile functionality.
|
|
47
45
|
"""
|
|
48
46
|
|
|
49
47
|
NPU_MONITOR_START = "NPU_MONITOR_START"
|
|
@@ -90,23 +88,15 @@ class DynamicProfilerMonitorBase(Callback):
|
|
|
90
88
|
@no_exception_func()
|
|
91
89
|
def step_begin(self, run_context):
|
|
92
90
|
"""
|
|
93
|
-
Start
|
|
91
|
+
Start profile at the begin of step.
|
|
94
92
|
|
|
95
93
|
Args:
|
|
96
94
|
run_context (RunContext): Context of the train running.
|
|
97
95
|
"""
|
|
98
96
|
prof_json = self._get_prof_args()
|
|
99
|
-
if not prof_json:
|
|
100
|
-
return
|
|
101
|
-
if self._is_dyno:
|
|
102
|
-
# Dyno monitor process
|
|
103
|
-
if self.NPU_MONITOR_START in prof_json:
|
|
104
|
-
self._call_dyno_monitor(prof_json)
|
|
105
|
-
return
|
|
106
|
-
|
|
107
97
|
prof_args = DynamicProfilerConfigContext(prof_json)
|
|
108
98
|
if not prof_args.is_valid:
|
|
109
|
-
logger.error("Dynamic
|
|
99
|
+
logger.error("Dynamic profile json is not valid, please check the json file.")
|
|
110
100
|
return
|
|
111
101
|
|
|
112
102
|
if prof_args.start_step in (-1, self._last_start_step):
|
|
@@ -119,22 +109,16 @@ class DynamicProfilerMonitorBase(Callback):
|
|
|
119
109
|
# Prevent repeated calls of the start function within a complete interval
|
|
120
110
|
if step_num == start_step:
|
|
121
111
|
if self._is_started:
|
|
122
|
-
logger.error("Dynamic
|
|
123
|
-
"please wait the first
|
|
112
|
+
logger.error("Dynamic profile is already started at step %d, "
|
|
113
|
+
"please wait the first profile finished at step %d.",
|
|
124
114
|
self._last_start_step, self._last_stop_step)
|
|
125
115
|
return
|
|
126
116
|
|
|
127
117
|
if self._profiler is None:
|
|
128
|
-
|
|
129
|
-
prof_path = os.path.join(
|
|
130
|
-
output_path,
|
|
131
|
-
f"rank{self._rank_id}_start{start_step}_stop{stop_step}"
|
|
132
|
-
)
|
|
118
|
+
prof_path = os.path.join(self._output_path, f"rank{self._rank_id}_start{start_step}_stop{stop_step}")
|
|
133
119
|
PathManager.check_input_directory_path(prof_path)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
skip_first=0)
|
|
137
|
-
self._profiler = Profile(**profiler_config)
|
|
120
|
+
self._profiler = Profiler(on_trace_ready=tensorboard_trace_handler(dir_name=prof_path),
|
|
121
|
+
start_profile=False, **prof_args.args)
|
|
138
122
|
print_msg(f"Rank {self._rank_id} create output path {prof_path}")
|
|
139
123
|
|
|
140
124
|
self._profiler.start()
|
|
@@ -144,58 +128,10 @@ class DynamicProfilerMonitorBase(Callback):
|
|
|
144
128
|
print_msg(f"Rank {self._rank_id} Dynamic profiler start at step {start_step}, "
|
|
145
129
|
f"will stop at step {stop_step}")
|
|
146
130
|
|
|
147
|
-
@staticmethod
|
|
148
|
-
def _get_prof_config(prof_args, prof_path, start_step, stop_step, start_profile, skip_first):
|
|
149
|
-
"""
|
|
150
|
-
Get profiler config.
|
|
151
|
-
|
|
152
|
-
Args:
|
|
153
|
-
prof_args: Profiler config.
|
|
154
|
-
prof_path: Profiler output path.
|
|
155
|
-
start_step: Start step.
|
|
156
|
-
stop_step: Stop step.
|
|
157
|
-
start_profile: enable start_profile.
|
|
158
|
-
skip_first: skip first step.
|
|
159
|
-
"""
|
|
160
|
-
profiler_config = {
|
|
161
|
-
"activities": prof_args.args.get("activities"),
|
|
162
|
-
"with_stack": prof_args.args.get("with_stack"),
|
|
163
|
-
"profile_memory": prof_args.args.get("profile_memory"),
|
|
164
|
-
"parallel_strategy": prof_args.args.get("parallel_strategy"),
|
|
165
|
-
"start_profile": start_profile,
|
|
166
|
-
"record_shapes": prof_args.args.get("record_shapes"),
|
|
167
|
-
"schedule": schedule(
|
|
168
|
-
wait=0,
|
|
169
|
-
warmup=0,
|
|
170
|
-
active=stop_step - start_step + 1,
|
|
171
|
-
repeat=1,
|
|
172
|
-
skip_first=skip_first
|
|
173
|
-
),
|
|
174
|
-
"on_trace_ready": tensorboard_trace_handler(
|
|
175
|
-
dir_name=prof_path,
|
|
176
|
-
analyse_flag=prof_args.analyse,
|
|
177
|
-
async_mode=prof_args.analyse_mode == "async",
|
|
178
|
-
),
|
|
179
|
-
"experimental_config": _ExperimentalConfig(
|
|
180
|
-
profiler_level=prof_args.args.get("profiler_level"),
|
|
181
|
-
aic_metrics=prof_args.args.get("aic_metrics"),
|
|
182
|
-
l2_cache=prof_args.args.get("l2_cache"),
|
|
183
|
-
mstx=prof_args.args.get("mstx"),
|
|
184
|
-
data_simplification=prof_args.args.get("data_simplification"),
|
|
185
|
-
export_type=prof_args.args.get("export_type"),
|
|
186
|
-
mstx_domain_include=prof_args.args.get("mstx_domain_include"),
|
|
187
|
-
mstx_domain_exclude=prof_args.args.get("mstx_domain_exclude"),
|
|
188
|
-
sys_io=prof_args.args.get("sys_io"),
|
|
189
|
-
sys_interconnection=prof_args.args.get("sys_interconnection"),
|
|
190
|
-
host_sys=prof_args.args.get("host_sys")
|
|
191
|
-
)
|
|
192
|
-
}
|
|
193
|
-
return profiler_config
|
|
194
|
-
|
|
195
131
|
@no_exception_func()
|
|
196
132
|
def step_end(self, run_context):
|
|
197
133
|
"""
|
|
198
|
-
Stop
|
|
134
|
+
Stop profile at the end of step.
|
|
199
135
|
|
|
200
136
|
Args:
|
|
201
137
|
run_context (RunContext): Context of the train running.
|
|
@@ -204,22 +140,26 @@ class DynamicProfilerMonitorBase(Callback):
|
|
|
204
140
|
prof_args = DynamicProfilerConfigContext(prof_json)
|
|
205
141
|
|
|
206
142
|
if not prof_args.is_valid:
|
|
207
|
-
logger.error("Dynamic
|
|
143
|
+
logger.error("Dynamic profile json is not valid, please check the json file.")
|
|
208
144
|
return
|
|
209
145
|
|
|
210
146
|
if prof_args.stop_step == -1:
|
|
211
147
|
return
|
|
212
148
|
|
|
213
|
-
if self._profiler:
|
|
214
|
-
self._profiler.step()
|
|
215
|
-
|
|
216
149
|
cb_params = run_context.original_args()
|
|
217
150
|
step_num = cb_params.cur_step_num
|
|
218
151
|
|
|
219
152
|
if step_num == self._last_stop_step and self._is_started:
|
|
220
|
-
self._profiler
|
|
221
|
-
|
|
222
|
-
|
|
153
|
+
if self._profiler:
|
|
154
|
+
self._profiler.stop()
|
|
155
|
+
if prof_args.analyse_mode:
|
|
156
|
+
self._profiler.analyse(mode=prof_args.analyse_mode)
|
|
157
|
+
else:
|
|
158
|
+
ProfilerInterface.finalize()
|
|
159
|
+
ProfilerInterface.clear()
|
|
160
|
+
self._profiler = None
|
|
161
|
+
self._is_started = False
|
|
162
|
+
print_msg(f"Rank {self._rank_id} Dynamic profiler stop at step {step_num}")
|
|
223
163
|
|
|
224
164
|
@no_exception_func()
|
|
225
165
|
def step(self):
|
|
@@ -331,7 +271,7 @@ class DynamicProfilerMonitorBase(Callback):
|
|
|
331
271
|
|
|
332
272
|
prof_args = DynamicProfilerConfigContext(prof_json)
|
|
333
273
|
if not prof_args.is_valid:
|
|
334
|
-
logger.error("Dynamic
|
|
274
|
+
logger.error("Dynamic profile config is not valid, please check the json or dyno config.")
|
|
335
275
|
return
|
|
336
276
|
self._handle_profiler_setup(prof_args)
|
|
337
277
|
|
|
@@ -353,13 +293,14 @@ class DynamicProfilerMonitorBase(Callback):
|
|
|
353
293
|
if not (start_step >= 0 and 0 <= start_step <= stop_step):
|
|
354
294
|
self._profiler = None
|
|
355
295
|
logger.error(
|
|
356
|
-
"Rank %d Dynamic
|
|
296
|
+
"Rank %d Dynamic profile start at step %d and stop at step %d must be "
|
|
357
297
|
"greater than or equal to 0, and stop step should not be less than start step",
|
|
358
298
|
self._rank_id, start_step, stop_step
|
|
359
299
|
)
|
|
360
300
|
return
|
|
361
301
|
|
|
362
302
|
# Setup profiler configuration
|
|
303
|
+
active_steps = stop_step - start_step + 1
|
|
363
304
|
output_path = args.prof_path if args.prof_path != "./" else self._output_path
|
|
364
305
|
prof_path = os.path.join(
|
|
365
306
|
output_path,
|
|
@@ -367,12 +308,26 @@ class DynamicProfilerMonitorBase(Callback):
|
|
|
367
308
|
)
|
|
368
309
|
print_msg(f"Rank {self._rank_id} create output path {prof_path}")
|
|
369
310
|
print_msg(
|
|
370
|
-
f"Rank {self._rank_id} Dynamic
|
|
311
|
+
f"Rank {self._rank_id} Dynamic profile start at step {start_step}, "
|
|
371
312
|
f"will stop at step {stop_step}"
|
|
372
313
|
)
|
|
373
|
-
profiler_config =
|
|
374
|
-
|
|
375
|
-
|
|
314
|
+
profiler_config = {
|
|
315
|
+
"schedule": schedule(
|
|
316
|
+
wait=0,
|
|
317
|
+
warmup=0,
|
|
318
|
+
active=active_steps,
|
|
319
|
+
repeat=1,
|
|
320
|
+
skip_first=1
|
|
321
|
+
),
|
|
322
|
+
"on_trace_ready": tensorboard_trace_handler(
|
|
323
|
+
dir_name=prof_path,
|
|
324
|
+
analyse_flag=args.analyse,
|
|
325
|
+
async_mode=args.analyse_mode == "async",
|
|
326
|
+
),
|
|
327
|
+
**args.args
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
self._profiler = Profiler(**profiler_config)
|
|
376
331
|
|
|
377
332
|
def _is_valid_start_stop_step(self, step_num, start_step, stop_step):
|
|
378
333
|
"""Verify whether start_step and stop_step are valid parameters."""
|
|
@@ -591,10 +546,10 @@ if sys.version_info >= (3, 8):
|
|
|
591
546
|
|
|
592
547
|
class DynamicProfilerMonitor(DynamicProfilerMonitorBase):
|
|
593
548
|
r"""
|
|
594
|
-
This class to enable the dynamic
|
|
549
|
+
This class to enable the dynamic profile monitoring of MindSpore neural networks.
|
|
595
550
|
|
|
596
551
|
Args:
|
|
597
|
-
cfg_path (str): (Ascend only) Dynamic
|
|
552
|
+
cfg_path (str): (Ascend only) Dynamic profile json config file directory. The requirement is a shared path
|
|
598
553
|
that can be accessed by all nodes. The parameters of the json configuration file are as follows:
|
|
599
554
|
|
|
600
555
|
- start_step (int, required) - Sets the step number at which the Profiler starts collecting data.
|
|
@@ -840,10 +795,10 @@ else:
|
|
|
840
795
|
|
|
841
796
|
class DynamicProfilerMonitor(DynamicProfilerMonitorBase):
|
|
842
797
|
r"""
|
|
843
|
-
This class to enable the dynamic
|
|
798
|
+
This class to enable the dynamic profile monitoring of MindSpore neural networks.
|
|
844
799
|
|
|
845
800
|
Args:
|
|
846
|
-
cfg_path (str): Dynamic
|
|
801
|
+
cfg_path (str): Dynamic profile json config file directory. The requirement is a shared path
|
|
847
802
|
that can be accessed by all nodes.
|
|
848
803
|
output_path (str, optional): Output data path. Default: ``"./dyn_profile_data"`` .
|
|
849
804
|
poll_interval (int, optional): The polling period of the monitoring process, in seconds.
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
import os
|
|
17
17
|
import json
|
|
18
18
|
from mindspore import log as logger
|
|
19
|
-
from mindspore.profiler.profiler import
|
|
20
|
-
from mindspore.profiler.experimental_config import _ExperimentalConfig
|
|
21
|
-
from mindspore.profiler import tensorboard_trace_handler
|
|
19
|
+
from mindspore.profiler.profiler import Profiler
|
|
22
20
|
from mindspore.profiler.common.constant import (
|
|
23
21
|
ProfilerLevel,
|
|
24
22
|
AicoreMetrics,
|
|
@@ -49,31 +47,8 @@ class EnvProfiler:
|
|
|
49
47
|
|
|
50
48
|
params = cls._convert_options_to_profiler_params(options)
|
|
51
49
|
logger.info(f"params: {params}")
|
|
52
|
-
if params["
|
|
53
|
-
|
|
54
|
-
aic_metrics=params.get("aic_metrics"),
|
|
55
|
-
l2_cache=params.get("l2_cache"),
|
|
56
|
-
mstx=params.get("mstx"),
|
|
57
|
-
data_simplification=params.get("data_simplification"),
|
|
58
|
-
export_type=params.get("export_type"),
|
|
59
|
-
mstx_domain_include=params.get("mstx_domain_include"),
|
|
60
|
-
mstx_domain_exclude=params.get("mstx_domain_exclude"),
|
|
61
|
-
sys_io=params.get("sys_io"),
|
|
62
|
-
sys_interconnection=params.get("sys_interconnection"),
|
|
63
|
-
host_sys=params.get("host_sys"))
|
|
64
|
-
cls.profiler = Profile(activities=params.get("activities"),
|
|
65
|
-
with_stack=params.get("with_stack"),
|
|
66
|
-
profile_memory=params.get("profile_memory"),
|
|
67
|
-
data_process=params.get("data_process"),
|
|
68
|
-
parallel_strategy=params.get("parallel_strategy"),
|
|
69
|
-
start_profile=params.get("start_profile"),
|
|
70
|
-
hbm_ddr=params.get("hbm_ddr"),
|
|
71
|
-
pcie=params.get("pcie"),
|
|
72
|
-
sync_enable=params.get("sync_enable"),
|
|
73
|
-
record_shapes=params.get("record_shapes"),
|
|
74
|
-
on_trace_ready=tensorboard_trace_handler(params.get("output_path")),
|
|
75
|
-
experimental_config=experimental_config)
|
|
76
|
-
cls.profiler.start()
|
|
50
|
+
if params["start_profile"]:
|
|
51
|
+
cls.profiler = Profiler(**params)
|
|
77
52
|
logger.info("Profiler init success.")
|
|
78
53
|
|
|
79
54
|
def analyse(self):
|
|
@@ -84,7 +59,7 @@ class EnvProfiler:
|
|
|
84
59
|
if not self.profiler:
|
|
85
60
|
logger.info("Profiler is not initialized, skip analyse.")
|
|
86
61
|
return
|
|
87
|
-
self.profiler.
|
|
62
|
+
self.profiler.analyse()
|
|
88
63
|
logger.info("analyse end")
|
|
89
64
|
|
|
90
65
|
@classmethod
|
|
@@ -126,7 +101,7 @@ class EnvProfiler:
|
|
|
126
101
|
params["output_path"] = options["output_path"]
|
|
127
102
|
|
|
128
103
|
# if start is not set, default is False
|
|
129
|
-
params["
|
|
104
|
+
params["start_profile"] = options.get("start", False)
|
|
130
105
|
|
|
131
106
|
for param, (_, default_value) in ProfilerParameters.PARAMS.items():
|
|
132
107
|
if param in options and param not in cls.NOT_SUPPORTED_PARAMS:
|
|
@@ -59,7 +59,7 @@ class _ExperimentalConfig:
|
|
|
59
59
|
storage and l2 cache etc.
|
|
60
60
|
l2_cache (bool, optional): (Ascend only) Whether to collect l2 cache data, collect when True.
|
|
61
61
|
Default: ``False`` . The l2_cache.csv file is generated in the ASCEND_PROFILER_OUTPUT folder. In GE backend,
|
|
62
|
-
only
|
|
62
|
+
only wait and skip_first parameters in schedule configuration can be set to 0.
|
|
63
63
|
mstx (bool, optional): (Ascend only) Whether to collect light weight profiling data, collect when True.
|
|
64
64
|
Default: ``False`` .
|
|
65
65
|
data_simplification (bool, optional): (Ascend only) Whether to remove FRAMEWORK data and other redundant data.
|
|
@@ -98,21 +98,6 @@ class _ExperimentalConfig:
|
|
|
98
98
|
<https://gitee.com/mindspore/mindspore/blob/master/docs/api/api_python/mindspore/script/
|
|
99
99
|
msprof_data_collection.sh>`_.
|
|
100
100
|
|
|
101
|
-
Final deliverables by `MindStudio Insight
|
|
102
|
-
<https://www.hiascend.com/developer/download/community/result?module=pt+sto+cann>`_
|
|
103
|
-
tool visualizes the analysis results.
|
|
104
|
-
For detailed analysis, please refer to `host-side CPU data analysis
|
|
105
|
-
<https://www.hiascend.com/document/detail/zh/mindstudio/80RC1/T&ITools/Profiling/
|
|
106
|
-
atlasprofiling_16_0106.html>`_, `host-side MEM data analysis
|
|
107
|
-
<https://www.hiascend.com/document/detail/zh/mindstudio/80RC1/T&ITools/Profiling/
|
|
108
|
-
atlasprofiling_16_0107.html>`_, `host-side DISK data analysis
|
|
109
|
-
<https://www.hiascend.com/document/detail/zh/mindstudio/80RC1/T&ITools/Profiling/
|
|
110
|
-
atlasprofiling_16_0108.html>`_, `host-side NETWORK data analysis
|
|
111
|
-
<https://www.hiascend.com/document/detail/zh/mindstudio/80RC1/T&ITools/Profiling/
|
|
112
|
-
atlasprofiling_16_0109.html>`_, `host-side OSRT data analysis
|
|
113
|
-
<https://www.hiascend.com/document/detail/zh/mindstudio/80RC1/T&ITools/Profiling/
|
|
114
|
-
atlasprofiling_16_0110.html>`_.
|
|
115
|
-
|
|
116
101
|
- HostSystem.CPU: Collect the CPU utilization at the process level.
|
|
117
102
|
- HostSystem.MEM: Collect the memory utilization at the process level.
|
|
118
103
|
- HostSystem.DISK: Collect the disk I/O utilization at the process level.
|
|
@@ -16,11 +16,10 @@
|
|
|
16
16
|
import mindspore._c_expression as c_expression
|
|
17
17
|
|
|
18
18
|
from mindspore.profiler.common.registry import PROFILERS
|
|
19
|
-
from mindspore.profiler.common.constant import DeviceTarget, ProfilerActivity
|
|
19
|
+
from mindspore.profiler.common.constant import DeviceTarget, ProfilerActivity
|
|
20
20
|
from mindspore.profiler.common.util import print_msg_with_pid
|
|
21
21
|
from mindspore.profiler.common.profiler_context import ProfilerContext
|
|
22
22
|
from mindspore.profiler.common.profiler_path_manager import ProfilerPathManager
|
|
23
|
-
from mindspore.profiler.common.process_pool import MultiProcessPool
|
|
24
23
|
from mindspore.profiler.platform.base_profiler import BaseProfiler
|
|
25
24
|
from mindspore.profiler.analysis.time_converter import TimeConverter
|
|
26
25
|
from mindspore.profiler.analysis.task_manager import TaskManager
|
|
@@ -69,7 +68,7 @@ class CpuProfiler(BaseProfiler):
|
|
|
69
68
|
if ProfilerContext().device_target_set != {DeviceTarget.CPU.value}:
|
|
70
69
|
return
|
|
71
70
|
self._logger.info("CpuProfiler analyse.")
|
|
72
|
-
CPUProfilerAnalysis.online_analyse(
|
|
71
|
+
CPUProfilerAnalysis.online_analyse()
|
|
73
72
|
|
|
74
73
|
def finalize(self) -> None:
|
|
75
74
|
"""Finalize profiling data."""
|
|
@@ -82,17 +81,12 @@ class CPUProfilerAnalysis:
|
|
|
82
81
|
"""
|
|
83
82
|
|
|
84
83
|
@classmethod
|
|
85
|
-
def online_analyse(cls
|
|
84
|
+
def online_analyse(cls):
|
|
86
85
|
"""
|
|
87
86
|
Online analysis for CPU
|
|
88
87
|
"""
|
|
89
88
|
cls._pre_analyse_online()
|
|
90
|
-
|
|
91
|
-
ProfilerContext().mode = AnalysisMode.ASYNC_MODE.value
|
|
92
|
-
MultiProcessPool().add_async_job(cls._run_tasks, **ProfilerContext().to_dict())
|
|
93
|
-
else:
|
|
94
|
-
ProfilerContext().mode = AnalysisMode.SYNC_MODE.value
|
|
95
|
-
cls._run_tasks(**ProfilerContext().to_dict())
|
|
89
|
+
cls._run_tasks(**ProfilerContext().to_dict())
|
|
96
90
|
|
|
97
91
|
@classmethod
|
|
98
92
|
def _pre_analyse_online(cls):
|
|
@@ -151,7 +151,7 @@ class NpuProfiler(BaseProfiler):
|
|
|
151
151
|
"""Analyse the profiling data."""
|
|
152
152
|
self._logger.info("NpuProfiler analyse.")
|
|
153
153
|
|
|
154
|
-
NPUProfilerAnalysis.online_analyse(
|
|
154
|
+
NPUProfilerAnalysis.online_analyse()
|
|
155
155
|
|
|
156
156
|
def finalize(self) -> None:
|
|
157
157
|
"""Finalize profiling data."""
|