mindspore 2.3.0__cp310-cp310-win_amd64.whl → 2.4.1__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 +3 -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 +50 -9
- mindspore/_extends/parse/compile_config.py +41 -0
- mindspore/_extends/parse/parser.py +9 -7
- mindspore/_extends/parse/standard_method.py +52 -14
- mindspore/_extends/pijit/pijit_func_white_list.py +350 -24
- mindspore/amp.py +24 -10
- mindspore/common/__init__.py +6 -4
- mindspore/common/_pijit_context.py +190 -0
- mindspore/common/_register_for_tensor.py +2 -1
- mindspore/common/_tensor_overload.py +139 -0
- mindspore/common/api.py +102 -87
- mindspore/common/dump.py +5 -6
- mindspore/common/generator.py +1 -7
- mindspore/common/hook_handle.py +14 -26
- mindspore/common/initializer.py +51 -15
- mindspore/common/mindir_util.py +2 -2
- mindspore/common/parameter.py +62 -15
- mindspore/common/recompute.py +39 -9
- mindspore/common/sparse_tensor.py +7 -3
- mindspore/common/tensor.py +183 -37
- mindspore/communication/__init__.py +1 -1
- mindspore/communication/_comm_helper.py +38 -3
- mindspore/communication/comm_func.py +315 -60
- mindspore/communication/management.py +14 -14
- mindspore/context.py +132 -22
- mindspore/dataset/__init__.py +1 -1
- mindspore/dataset/audio/__init__.py +1 -1
- mindspore/dataset/core/config.py +7 -0
- mindspore/dataset/core/validator_helpers.py +7 -0
- mindspore/dataset/engine/cache_client.py +1 -1
- mindspore/dataset/engine/datasets.py +72 -44
- mindspore/dataset/engine/datasets_audio.py +7 -7
- mindspore/dataset/engine/datasets_standard_format.py +53 -3
- mindspore/dataset/engine/datasets_text.py +20 -20
- mindspore/dataset/engine/datasets_user_defined.py +174 -104
- mindspore/dataset/engine/datasets_vision.py +33 -33
- mindspore/dataset/engine/iterators.py +29 -0
- mindspore/dataset/engine/obs/util.py +7 -0
- mindspore/dataset/engine/queue.py +114 -60
- mindspore/dataset/engine/serializer_deserializer.py +2 -2
- mindspore/dataset/engine/validators.py +34 -14
- mindspore/dataset/text/__init__.py +1 -4
- mindspore/dataset/transforms/__init__.py +0 -3
- mindspore/dataset/utils/line_reader.py +2 -0
- mindspore/dataset/vision/__init__.py +1 -4
- mindspore/dataset/vision/utils.py +1 -1
- mindspore/dataset/vision/validators.py +2 -1
- mindspore/{nn/extend → experimental/es}/__init__.py +4 -11
- mindspore/experimental/es/embedding_service.py +883 -0
- mindspore/{nn/layer → experimental/es}/embedding_service_layer.py +218 -30
- mindspore/experimental/llm_boost/__init__.py +21 -0
- mindspore/{nn/extend/layer → experimental/llm_boost/atb}/__init__.py +4 -8
- mindspore/experimental/llm_boost/atb/boost_base.py +211 -0
- mindspore/experimental/llm_boost/atb/llama_boost.py +115 -0
- mindspore/experimental/llm_boost/atb/qwen_boost.py +101 -0
- mindspore/experimental/llm_boost/register.py +129 -0
- mindspore/experimental/llm_boost/utils.py +31 -0
- mindspore/experimental/optim/adamw.py +85 -0
- mindspore/experimental/optim/optimizer.py +3 -0
- mindspore/hal/__init__.py +3 -3
- mindspore/hal/contiguous_tensors_handle.py +175 -0
- mindspore/hal/stream.py +18 -0
- mindspore/include/api/model_group.h +13 -1
- mindspore/include/api/types.h +10 -10
- mindspore/include/dataset/config.h +2 -2
- mindspore/include/dataset/constants.h +2 -2
- mindspore/include/dataset/execute.h +2 -2
- mindspore/include/dataset/vision.h +4 -0
- mindspore/log.py +1 -1
- mindspore/mindrecord/filewriter.py +68 -51
- mindspore/mindspore_backend.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_np_dtype.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mint/__init__.py +983 -46
- mindspore/mint/distributed/__init__.py +31 -0
- mindspore/mint/distributed/distributed.py +254 -0
- mindspore/mint/nn/__init__.py +268 -23
- mindspore/mint/nn/functional.py +125 -19
- mindspore/mint/nn/layer/__init__.py +39 -0
- mindspore/mint/nn/layer/activation.py +133 -0
- mindspore/mint/nn/layer/normalization.py +477 -0
- mindspore/mint/nn/layer/pooling.py +110 -0
- mindspore/mint/optim/adamw.py +26 -13
- mindspore/mint/special/__init__.py +63 -0
- mindspore/multiprocessing/__init__.py +2 -1
- mindspore/nn/__init__.py +0 -1
- mindspore/nn/cell.py +276 -96
- mindspore/nn/layer/activation.py +211 -44
- mindspore/nn/layer/basic.py +137 -10
- mindspore/nn/layer/embedding.py +137 -2
- mindspore/nn/layer/normalization.py +101 -5
- mindspore/nn/layer/padding.py +34 -48
- mindspore/nn/layer/pooling.py +161 -7
- mindspore/nn/layer/transformer.py +3 -3
- mindspore/nn/loss/__init__.py +2 -2
- mindspore/nn/loss/loss.py +84 -6
- mindspore/nn/optim/__init__.py +2 -1
- mindspore/nn/optim/adadelta.py +1 -1
- mindspore/nn/optim/adam.py +1 -1
- mindspore/nn/optim/lamb.py +1 -1
- mindspore/nn/optim/tft_wrapper.py +124 -0
- mindspore/nn/wrap/cell_wrapper.py +12 -23
- mindspore/nn/wrap/grad_reducer.py +5 -5
- mindspore/nn/wrap/loss_scale.py +17 -3
- mindspore/numpy/__init__.py +1 -1
- mindspore/numpy/array_creations.py +65 -68
- mindspore/numpy/array_ops.py +64 -60
- mindspore/numpy/fft.py +610 -75
- mindspore/numpy/logic_ops.py +11 -10
- mindspore/numpy/math_ops.py +85 -84
- mindspore/numpy/utils_const.py +4 -4
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/__init__.py +6 -4
- mindspore/ops/_grad_experimental/grad_array_ops.py +0 -11
- mindspore/ops/_grad_experimental/grad_comm_ops.py +67 -4
- mindspore/ops/_grad_experimental/grad_math_ops.py +0 -22
- mindspore/ops/_vmap/vmap_array_ops.py +2 -4
- mindspore/ops/_vmap/vmap_math_ops.py +17 -1
- mindspore/ops/_vmap/vmap_nn_ops.py +43 -2
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +91 -7
- mindspore/ops/auto_generate/gen_arg_dtype_cast.py +2 -0
- mindspore/ops/auto_generate/gen_extend_func.py +767 -13
- mindspore/ops/auto_generate/gen_ops_def.py +2452 -364
- mindspore/ops/auto_generate/gen_ops_prim.py +5442 -1756
- mindspore/ops/auto_generate/pyboost_inner_prim.py +176 -56
- mindspore/ops/composite/base.py +85 -48
- mindspore/ops/composite/multitype_ops/_compile_utils.py +1 -0
- mindspore/ops/composite/multitype_ops/not_in_impl.py +2 -2
- mindspore/ops/function/__init__.py +22 -0
- mindspore/ops/function/array_func.py +492 -153
- mindspore/ops/function/debug_func.py +113 -1
- mindspore/ops/function/fft_func.py +15 -2
- mindspore/ops/function/grad/grad_func.py +3 -2
- mindspore/ops/function/math_func.py +564 -207
- mindspore/ops/function/nn_func.py +817 -383
- mindspore/ops/function/other_func.py +3 -2
- mindspore/ops/function/random_func.py +402 -12
- mindspore/ops/function/reshard_func.py +13 -11
- mindspore/ops/function/sparse_unary_func.py +1 -1
- mindspore/ops/function/vmap_func.py +3 -2
- mindspore/ops/functional.py +24 -14
- mindspore/ops/op_info_register.py +3 -3
- mindspore/ops/operations/__init__.py +7 -2
- mindspore/ops/operations/_grad_ops.py +2 -76
- mindspore/ops/operations/_infer_ops.py +1 -1
- mindspore/ops/operations/_inner_ops.py +71 -94
- mindspore/ops/operations/array_ops.py +14 -146
- mindspore/ops/operations/comm_ops.py +63 -53
- mindspore/ops/operations/custom_ops.py +83 -19
- mindspore/ops/operations/debug_ops.py +42 -10
- mindspore/ops/operations/manually_defined/_inner.py +12 -0
- mindspore/ops/operations/manually_defined/ops_def.py +273 -20
- mindspore/ops/operations/math_ops.py +12 -223
- mindspore/ops/operations/nn_ops.py +20 -114
- mindspore/ops/operations/other_ops.py +7 -4
- mindspore/ops/operations/random_ops.py +46 -1
- mindspore/ops/primitive.py +18 -6
- mindspore/ops_generate/arg_dtype_cast.py +2 -0
- mindspore/ops_generate/gen_aclnn_implement.py +11 -11
- mindspore/ops_generate/gen_constants.py +36 -0
- mindspore/ops_generate/gen_ops.py +67 -52
- mindspore/ops_generate/gen_ops_inner_prim.py +1 -1
- mindspore/ops_generate/gen_pyboost_func.py +131 -47
- mindspore/ops_generate/op_proto.py +10 -3
- mindspore/ops_generate/pyboost_utils.py +14 -1
- mindspore/ops_generate/template.py +43 -21
- mindspore/parallel/__init__.py +3 -1
- mindspore/parallel/_auto_parallel_context.py +31 -9
- mindspore/parallel/_cell_wrapper.py +85 -0
- mindspore/parallel/_parallel_serialization.py +47 -19
- mindspore/parallel/_tensor.py +127 -13
- mindspore/parallel/_utils.py +53 -22
- mindspore/parallel/algo_parameter_config.py +5 -5
- mindspore/parallel/checkpoint_transform.py +46 -39
- mindspore/parallel/cluster/process_entity/__init__.py +1 -1
- mindspore/parallel/cluster/process_entity/_api.py +31 -23
- mindspore/parallel/cluster/process_entity/_utils.py +2 -27
- mindspore/parallel/parameter_broadcast.py +3 -4
- mindspore/parallel/shard.py +162 -31
- mindspore/parallel/transform_safetensors.py +1146 -0
- mindspore/profiler/__init__.py +2 -1
- mindspore/profiler/common/constant.py +29 -0
- mindspore/profiler/common/registry.py +47 -0
- mindspore/profiler/common/util.py +28 -0
- mindspore/profiler/dynamic_profiler.py +694 -0
- mindspore/profiler/envprofiling.py +17 -19
- mindspore/profiler/parser/ascend_analysis/constant.py +18 -0
- mindspore/profiler/parser/ascend_analysis/file_manager.py +25 -4
- mindspore/profiler/parser/ascend_analysis/function_event.py +43 -19
- mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +31 -26
- mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +56 -10
- mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +55 -8
- mindspore/profiler/parser/ascend_analysis/path_manager.py +313 -0
- mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +27 -20
- mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +9 -2
- mindspore/profiler/parser/ascend_msprof_exporter.py +5 -4
- mindspore/profiler/parser/ascend_timeline_generator.py +27 -25
- mindspore/profiler/parser/base_timeline_generator.py +19 -25
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +25 -12
- mindspore/profiler/parser/framework_parser.py +1 -391
- mindspore/profiler/parser/gpu_analysis/__init__.py +14 -0
- mindspore/profiler/parser/gpu_analysis/function_event.py +44 -0
- mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +89 -0
- mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +72 -0
- mindspore/profiler/parser/memory_usage_parser.py +0 -154
- mindspore/profiler/parser/profiler_info.py +78 -6
- mindspore/profiler/profiler.py +153 -0
- mindspore/profiler/profiling.py +285 -413
- mindspore/rewrite/__init__.py +1 -2
- mindspore/rewrite/common/namespace.py +4 -4
- mindspore/rewrite/symbol_tree/symbol_tree.py +3 -3
- mindspore/run_check/_check_version.py +39 -104
- mindspore/safeguard/rewrite_obfuscation.py +591 -247
- mindspore/train/__init__.py +4 -3
- mindspore/train/_utils.py +105 -19
- mindspore/train/amp.py +171 -53
- mindspore/train/callback/__init__.py +2 -2
- mindspore/train/callback/_callback.py +4 -4
- mindspore/train/callback/_checkpoint.py +97 -31
- mindspore/train/callback/_cluster_monitor.py +1 -1
- mindspore/train/callback/_flops_collector.py +1 -0
- mindspore/train/callback/_loss_monitor.py +3 -3
- mindspore/train/callback/_on_request_exit.py +145 -31
- mindspore/train/callback/_summary_collector.py +5 -5
- mindspore/train/callback/_tft_register.py +375 -0
- mindspore/train/dataset_helper.py +15 -3
- mindspore/train/metrics/metric.py +3 -3
- mindspore/train/metrics/roc.py +4 -4
- mindspore/train/mind_ir_pb2.py +44 -39
- mindspore/train/model.py +154 -58
- mindspore/train/serialization.py +342 -128
- mindspore/utils/__init__.py +21 -0
- mindspore/utils/utils.py +60 -0
- mindspore/version.py +1 -1
- {mindspore-2.3.0.dist-info → mindspore-2.4.1.dist-info}/METADATA +13 -7
- {mindspore-2.3.0.dist-info → mindspore-2.4.1.dist-info}/RECORD +248 -242
- mindspore/include/c_api/ms/abstract.h +0 -67
- mindspore/include/c_api/ms/attribute.h +0 -197
- mindspore/include/c_api/ms/base/handle_types.h +0 -43
- mindspore/include/c_api/ms/base/macros.h +0 -32
- mindspore/include/c_api/ms/base/status.h +0 -33
- mindspore/include/c_api/ms/base/types.h +0 -283
- mindspore/include/c_api/ms/context.h +0 -102
- mindspore/include/c_api/ms/graph.h +0 -160
- mindspore/include/c_api/ms/node.h +0 -606
- mindspore/include/c_api/ms/tensor.h +0 -161
- mindspore/include/c_api/ms/value.h +0 -84
- mindspore/mindspore_shared_lib.dll +0 -0
- mindspore/nn/extend/basic.py +0 -140
- mindspore/nn/extend/embedding.py +0 -143
- mindspore/nn/extend/layer/normalization.py +0 -109
- mindspore/nn/extend/pooling.py +0 -117
- mindspore/nn/layer/embedding_service.py +0 -531
- mindspore/ops/_op_impl/aicpu/strided_slice_v2.py +0 -93
- mindspore/ops/_op_impl/aicpu/strided_slice_v2_grad.py +0 -66
- mindspore/ops/extend/__init__.py +0 -53
- mindspore/ops/extend/array_func.py +0 -218
- mindspore/ops/extend/math_func.py +0 -76
- mindspore/ops/extend/nn_func.py +0 -308
- mindspore/ops/silent_check.py +0 -162
- mindspore/profiler/parser/msadvisor_analyzer.py +0 -82
- mindspore/profiler/parser/msadvisor_parser.py +0 -240
- mindspore/train/callback/_mindio_ttp.py +0 -443
- {mindspore-2.3.0.dist-info → mindspore-2.4.1.dist-info}/WHEEL +0 -0
- {mindspore-2.3.0.dist-info → mindspore-2.4.1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.3.0.dist-info → mindspore-2.4.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# Copyright 2023 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
|
+
"""Profiler path manager"""
|
|
16
|
+
import os
|
|
17
|
+
import re
|
|
18
|
+
import shutil
|
|
19
|
+
import warnings
|
|
20
|
+
|
|
21
|
+
from mindspore import log as logger
|
|
22
|
+
from mindspore.profiler.parser.ascend_analysis.constant import Constant
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__all__ = ['PathManager']
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class PathManager:
|
|
29
|
+
"""
|
|
30
|
+
Path common operations manager
|
|
31
|
+
"""
|
|
32
|
+
MAX_PATH_LENGTH = 4096
|
|
33
|
+
MAX_FILE_NAME_LENGTH = 255
|
|
34
|
+
DATA_FILE_AUTHORITY = 0o640
|
|
35
|
+
DATA_DIR_AUTHORITY = 0o750
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def check_input_directory_path(cls, path: str):
|
|
39
|
+
"""
|
|
40
|
+
Function Description:
|
|
41
|
+
check whether the path is valid, some businesses can accept a path that does not exist,
|
|
42
|
+
so the function do not verify whether the path exists
|
|
43
|
+
Parameter:
|
|
44
|
+
path: the path to check, whether the incoming path is absolute or relative depends on the business
|
|
45
|
+
Exception Description:
|
|
46
|
+
when invalid data throw exception
|
|
47
|
+
"""
|
|
48
|
+
cls._input_path_common_check(path)
|
|
49
|
+
|
|
50
|
+
if os.path.isfile(path):
|
|
51
|
+
msg = "Invalid input path is a file path: {path}"
|
|
52
|
+
raise RuntimeError(msg)
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def check_input_file_path(cls, path: str):
|
|
56
|
+
"""
|
|
57
|
+
Function Description:
|
|
58
|
+
check whether the file path is valid, some businesses can accept a path that does not exist,
|
|
59
|
+
so the function do not verify whether the path exists
|
|
60
|
+
Parameter:
|
|
61
|
+
path: the file path to check, whether the incoming path is absolute or relative depends on the business
|
|
62
|
+
Exception Description:
|
|
63
|
+
when invalid data throw exception
|
|
64
|
+
"""
|
|
65
|
+
cls._input_path_common_check(path)
|
|
66
|
+
|
|
67
|
+
if os.path.isdir(path):
|
|
68
|
+
msg = "Invalid input path is a directory path: {path}"
|
|
69
|
+
raise RuntimeError(msg)
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def copy_file(cls, src_path: str, dst_path: str):
|
|
73
|
+
"""
|
|
74
|
+
Function Description:
|
|
75
|
+
copy file safety
|
|
76
|
+
Parameter:
|
|
77
|
+
src_path: file source path
|
|
78
|
+
dst_path: file destination path
|
|
79
|
+
Exception Description:
|
|
80
|
+
when src_path is link throw exception
|
|
81
|
+
"""
|
|
82
|
+
if not os.path.exists(src_path):
|
|
83
|
+
logger.warning("The source file does not exist: %s", src_path)
|
|
84
|
+
return
|
|
85
|
+
|
|
86
|
+
cls.check_input_file_path(src_path)
|
|
87
|
+
dst_dir = os.path.dirname(dst_path)
|
|
88
|
+
cls.check_directory_path_writeable(dst_dir)
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
shutil.copy2(src_path, dst_path)
|
|
92
|
+
except Exception as err:
|
|
93
|
+
msg = f"Failed to copy path: {src_path}"
|
|
94
|
+
raise RuntimeError(msg) from err
|
|
95
|
+
|
|
96
|
+
@classmethod
|
|
97
|
+
def check_path_owner_consistent(cls, path: str):
|
|
98
|
+
"""
|
|
99
|
+
Function Description:
|
|
100
|
+
check whether the path belong to process owner
|
|
101
|
+
Parameter:
|
|
102
|
+
path: the path to check
|
|
103
|
+
Exception Description:
|
|
104
|
+
when invalid path, prompt the user
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
if not os.path.exists(path):
|
|
108
|
+
msg = f"The path does not exist: {path}"
|
|
109
|
+
raise RuntimeError(msg)
|
|
110
|
+
if os.stat(path).st_uid != os.getuid():
|
|
111
|
+
warnings.warn(f"Warning: The {path} owner does not match the current user.")
|
|
112
|
+
|
|
113
|
+
@classmethod
|
|
114
|
+
def check_directory_path_writeable(cls, path):
|
|
115
|
+
"""
|
|
116
|
+
Function Description:
|
|
117
|
+
check whether the path is writable
|
|
118
|
+
Parameter:
|
|
119
|
+
path: the path to check
|
|
120
|
+
Exception Description:
|
|
121
|
+
when invalid data throw exception
|
|
122
|
+
"""
|
|
123
|
+
cls.check_path_owner_consistent(path)
|
|
124
|
+
if os.path.islink(path):
|
|
125
|
+
msg = f"Invalid path is a soft chain: {path}"
|
|
126
|
+
raise RuntimeError(msg)
|
|
127
|
+
if not os.access(path, os.W_OK):
|
|
128
|
+
msg = f"The path permission check failed: {path}"
|
|
129
|
+
raise RuntimeError(msg)
|
|
130
|
+
|
|
131
|
+
@classmethod
|
|
132
|
+
def check_directory_path_readable(cls, path):
|
|
133
|
+
"""
|
|
134
|
+
Function Description:
|
|
135
|
+
check whether the path is writable
|
|
136
|
+
Parameter:
|
|
137
|
+
path: the path to check
|
|
138
|
+
Exception Description:
|
|
139
|
+
when invalid data throw exception
|
|
140
|
+
"""
|
|
141
|
+
cls.check_path_owner_consistent(path)
|
|
142
|
+
if os.path.islink(path):
|
|
143
|
+
msg = f"Invalid path is a soft chain: {path}"
|
|
144
|
+
raise RuntimeError(msg)
|
|
145
|
+
if not os.access(path, os.R_OK):
|
|
146
|
+
msg = f"The path permission check failed: {path}"
|
|
147
|
+
raise RuntimeError(msg)
|
|
148
|
+
|
|
149
|
+
@classmethod
|
|
150
|
+
def remove_path_safety(cls, path: str):
|
|
151
|
+
"""
|
|
152
|
+
Function Description:
|
|
153
|
+
remove path safety
|
|
154
|
+
Parameter:
|
|
155
|
+
path: the path to remove
|
|
156
|
+
Exception Description:
|
|
157
|
+
when invalid data throw exception
|
|
158
|
+
"""
|
|
159
|
+
msg = f"Failed to remove path: {path}"
|
|
160
|
+
if os.path.islink(path):
|
|
161
|
+
raise RuntimeError(msg)
|
|
162
|
+
if not os.path.exists(path):
|
|
163
|
+
return
|
|
164
|
+
try:
|
|
165
|
+
shutil.rmtree(path)
|
|
166
|
+
except FileNotFoundError:
|
|
167
|
+
return
|
|
168
|
+
except Exception as err:
|
|
169
|
+
raise RuntimeError(msg) from err
|
|
170
|
+
|
|
171
|
+
@classmethod
|
|
172
|
+
def remove_file_safety(cls, file: str):
|
|
173
|
+
"""
|
|
174
|
+
Function Description:
|
|
175
|
+
remove file safety
|
|
176
|
+
Parameter:
|
|
177
|
+
path: the file to remove
|
|
178
|
+
Exception Description:
|
|
179
|
+
when invalid data throw exception
|
|
180
|
+
"""
|
|
181
|
+
msg = f"Failed to remove file: {file}"
|
|
182
|
+
if os.path.islink(file):
|
|
183
|
+
raise RuntimeError(msg)
|
|
184
|
+
if not os.path.exists(file):
|
|
185
|
+
return
|
|
186
|
+
try:
|
|
187
|
+
os.remove(file)
|
|
188
|
+
except FileExistsError:
|
|
189
|
+
return
|
|
190
|
+
except Exception as err:
|
|
191
|
+
raise RuntimeError(msg) from err
|
|
192
|
+
|
|
193
|
+
@classmethod
|
|
194
|
+
def make_dir_safety(cls, path: str):
|
|
195
|
+
"""
|
|
196
|
+
Function Description:
|
|
197
|
+
make directory safety
|
|
198
|
+
Parameter:
|
|
199
|
+
path: the directory to remove
|
|
200
|
+
Exception Description:
|
|
201
|
+
when invalid data throw exception
|
|
202
|
+
"""
|
|
203
|
+
msg = f"Failed to make directory: {path}"
|
|
204
|
+
if os.path.islink(path):
|
|
205
|
+
raise RuntimeError(msg)
|
|
206
|
+
if os.path.exists(path):
|
|
207
|
+
return
|
|
208
|
+
try:
|
|
209
|
+
os.makedirs(path, mode=cls.DATA_DIR_AUTHORITY, exist_ok=True)
|
|
210
|
+
except Exception as err:
|
|
211
|
+
raise RuntimeError(msg) from err
|
|
212
|
+
|
|
213
|
+
@classmethod
|
|
214
|
+
def create_file_safety(cls, path: str):
|
|
215
|
+
"""
|
|
216
|
+
Function Description:
|
|
217
|
+
create file safety
|
|
218
|
+
Parameter:
|
|
219
|
+
path: the file to remove
|
|
220
|
+
Exception Description:
|
|
221
|
+
when invalid data throw exception
|
|
222
|
+
"""
|
|
223
|
+
msg = f"Failed to create file: {path}"
|
|
224
|
+
if os.path.islink(path):
|
|
225
|
+
raise RuntimeError(msg)
|
|
226
|
+
if os.path.exists(path):
|
|
227
|
+
return
|
|
228
|
+
try:
|
|
229
|
+
os.close(os.open(path, os.O_WRONLY | os.O_CREAT, cls.DATA_FILE_AUTHORITY))
|
|
230
|
+
except Exception as err:
|
|
231
|
+
raise RuntimeError(msg) from err
|
|
232
|
+
|
|
233
|
+
@classmethod
|
|
234
|
+
def _input_path_common_check(cls, path: str):
|
|
235
|
+
"""
|
|
236
|
+
Function Description:
|
|
237
|
+
input path check common function
|
|
238
|
+
Parameter:
|
|
239
|
+
path: the file path to check
|
|
240
|
+
Exception Description:
|
|
241
|
+
when invalid data throw exception
|
|
242
|
+
"""
|
|
243
|
+
if len(path) > cls.MAX_PATH_LENGTH:
|
|
244
|
+
raise RuntimeError("Length of input path exceeds the limit.")
|
|
245
|
+
|
|
246
|
+
if os.path.islink(path):
|
|
247
|
+
msg = f"Invalid input path is a soft chain: {path}"
|
|
248
|
+
raise RuntimeError(msg)
|
|
249
|
+
|
|
250
|
+
pattern = r'(\.|/|_|-|\s|[~0-9a-zA-Z])+'
|
|
251
|
+
if not re.fullmatch(pattern, path):
|
|
252
|
+
msg = f"Invalid input path: {path}"
|
|
253
|
+
raise RuntimeError(msg)
|
|
254
|
+
|
|
255
|
+
path_split_list = path.split("/")
|
|
256
|
+
for name in path_split_list:
|
|
257
|
+
if len(name) > cls.MAX_FILE_NAME_LENGTH:
|
|
258
|
+
raise RuntimeError("Length of input path exceeds the limit.")
|
|
259
|
+
|
|
260
|
+
@classmethod
|
|
261
|
+
def get_profiler_parent_path_list(cls, input_path: str):
|
|
262
|
+
"""
|
|
263
|
+
Function Description:
|
|
264
|
+
get valid profiler parent path list from input_path
|
|
265
|
+
Parameter:
|
|
266
|
+
input_path: The directory path from which to extract profiler parent paths.
|
|
267
|
+
Return:
|
|
268
|
+
A list containing the input path or its subdirectories that are valid profiler parents.
|
|
269
|
+
"""
|
|
270
|
+
profiler_path = os.path.join(input_path, Constant.PROFILER_DIR)
|
|
271
|
+
if os.path.isdir(profiler_path) and (cls.get_fwk_path(profiler_path) or cls.get_cann_path(profiler_path)):
|
|
272
|
+
return [input_path]
|
|
273
|
+
sub_dirs = os.listdir(os.path.realpath(input_path))
|
|
274
|
+
profiler_parent_path_list = []
|
|
275
|
+
for sub_dir in sub_dirs:
|
|
276
|
+
sub_path = os.path.join(input_path, sub_dir, Constant.PROFILER_DIR)
|
|
277
|
+
if not os.path.isdir(sub_path):
|
|
278
|
+
continue
|
|
279
|
+
if cls.get_fwk_path(sub_path) or cls.get_cann_path(sub_path):
|
|
280
|
+
profiler_parent_path_list.append(os.path.join(input_path, sub_dir))
|
|
281
|
+
return profiler_parent_path_list
|
|
282
|
+
|
|
283
|
+
@classmethod
|
|
284
|
+
def get_fwk_path(cls, input_path: str):
|
|
285
|
+
"""
|
|
286
|
+
Function Description:
|
|
287
|
+
get valid framework path from input_path
|
|
288
|
+
Parameter:
|
|
289
|
+
input_path: the directory path to check whether exist valid FRAMEWORK path
|
|
290
|
+
Return:
|
|
291
|
+
The path to the FRAMEWORK directory if found, otherwise an empty string.
|
|
292
|
+
"""
|
|
293
|
+
fwk_path = os.path.join(input_path, Constant.FRAMEWORK_DIR)
|
|
294
|
+
if os.path.isdir(fwk_path):
|
|
295
|
+
return fwk_path
|
|
296
|
+
return ""
|
|
297
|
+
|
|
298
|
+
@classmethod
|
|
299
|
+
def get_cann_path(cls, input_path: str):
|
|
300
|
+
"""
|
|
301
|
+
Function Description:
|
|
302
|
+
get valid PROF_XXX path from input_path
|
|
303
|
+
Parameter:
|
|
304
|
+
input_path: the directory path to check valid PROF_XXX path
|
|
305
|
+
Return:
|
|
306
|
+
The path to the PROF_XXX directory if it matches the pattern and exists, otherwise an empty string.
|
|
307
|
+
"""
|
|
308
|
+
sub_dirs = os.listdir(os.path.realpath(input_path))
|
|
309
|
+
for sub_dir in sub_dirs:
|
|
310
|
+
sub_path = os.path.join(input_path, sub_dir)
|
|
311
|
+
if os.path.isdir(sub_path) and re.match(r"^PROF_\d+_\d+_[0-9a-zA-Z]+", sub_dir):
|
|
312
|
+
return sub_path
|
|
313
|
+
return ""
|
|
@@ -18,25 +18,28 @@ import json
|
|
|
18
18
|
from decimal import Decimal
|
|
19
19
|
from subprocess import CalledProcessError, TimeoutExpired
|
|
20
20
|
from subprocess import Popen, PIPE
|
|
21
|
+
from configparser import ConfigParser
|
|
21
22
|
|
|
22
23
|
from mindspore import log as logger
|
|
23
24
|
from mindspore.profiler.common.validator.validate_path import validate_and_normalize_path
|
|
24
25
|
from mindspore.profiler.parser.ascend_analysis.constant import Constant
|
|
25
|
-
from mindspore.profiler.parser.profiler_info import ProfilerInfo
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
class ProfilerInfoParser:
|
|
29
29
|
"""Parse files that record information, such as profiler_info.json"""
|
|
30
30
|
|
|
31
31
|
_freq = 100.0
|
|
32
|
-
_time_offset = 0
|
|
33
|
-
_start_cnt = 0
|
|
34
32
|
_msprof_cmd = "msprof"
|
|
35
33
|
_time_out = 1
|
|
36
34
|
# profiler information related files
|
|
37
35
|
_source_prof_path = None
|
|
38
36
|
_loaded_frequency = False
|
|
39
37
|
_rank_id = 0
|
|
38
|
+
_clock_monotonic_raw = 0
|
|
39
|
+
_cntvct = 0
|
|
40
|
+
_collectionTimeBegin = 0
|
|
41
|
+
_clockMonotonicRaw = 0
|
|
42
|
+
_get_localtime_diff = 0
|
|
40
43
|
|
|
41
44
|
@classmethod
|
|
42
45
|
def init_source_path(cls, source_path: str):
|
|
@@ -73,31 +76,35 @@ class ProfilerInfoParser:
|
|
|
73
76
|
cls._freq = float(cpu_info.get("Frequency", cls._freq))
|
|
74
77
|
except ValueError:
|
|
75
78
|
pass
|
|
76
|
-
|
|
77
|
-
f"profiler_info_{cls._rank_id}.json")
|
|
78
|
-
if not os.path.isfile(profiler_info_path):
|
|
79
|
-
raise RuntimeError(f"Can`t find the file {profiler_info_path}, please check !")
|
|
80
|
-
with os.fdopen(os.open(profiler_info_path, os.O_RDONLY, 0o600),
|
|
81
|
-
'r') as fr:
|
|
82
|
-
profiler_info_data = json.load(fr)
|
|
83
|
-
cls._start_cnt = profiler_info_data.get('system_cnt')
|
|
84
|
-
cls._time_offset = profiler_info_data.get('system_time')
|
|
85
|
-
ProfilerInfo.set_system_time(cls._time_offset)
|
|
86
|
-
ProfilerInfo.set_system_cnt(cls._start_cnt)
|
|
79
|
+
cls._get_msprof_timestamp(cls._source_prof_path)
|
|
87
80
|
cls._loaded_frequency = True
|
|
88
81
|
start_ns = cls.__get_timestamp(syscnt)
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
return Decimal(start_ns).quantize(Decimal('0.000')) * Decimal(Constant.NS_TO_US).quantize(Decimal('0.000'))
|
|
83
|
+
|
|
84
|
+
@classmethod
|
|
85
|
+
def _get_msprof_timestamp(cls, source_path):
|
|
86
|
+
"""get msprof timestamp info"""
|
|
87
|
+
start_log = ConfigParser()
|
|
88
|
+
start_log.read(os.path.join(source_path, "host", "host_start.log"))
|
|
89
|
+
cls._clock_monotonic_raw = int(start_log.get("Host", "clock_monotonic_raw"))
|
|
90
|
+
cls._cntvct = int(start_log.get("Host", "cntvct"))
|
|
91
|
+
|
|
92
|
+
with open(os.path.join(source_path, "host", "start_info"), "r") as f:
|
|
93
|
+
info_dict = json.load(f)
|
|
94
|
+
cls._collectionTimeBegin = int(info_dict.get("collectionTimeBegin", 0)) # us
|
|
95
|
+
cls._clockMonotonicRaw = int(info_dict.get("clockMonotonicRaw", 0))
|
|
96
|
+
us_to_ns = 1000
|
|
97
|
+
cls._get_localtime_diff = cls._clock_monotonic_raw + (cls._collectionTimeBegin * us_to_ns -
|
|
98
|
+
cls._clockMonotonicRaw)
|
|
91
99
|
|
|
92
100
|
@classmethod
|
|
93
101
|
def __run_cmd(cls, cmd):
|
|
94
102
|
"""run shell command"""
|
|
95
103
|
try:
|
|
96
|
-
|
|
104
|
+
with Popen(cmd, stdout=PIPE, stderr=PIPE, text=True) as proc:
|
|
105
|
+
outs, errs = proc.communicate(timeout=cls._time_out)
|
|
97
106
|
except (FileNotFoundError, PermissionError, CalledProcessError) as exc:
|
|
98
107
|
raise RuntimeError(exc) from exc
|
|
99
|
-
try:
|
|
100
|
-
outs, errs = proc.communicate(timeout=cls._time_out)
|
|
101
108
|
except TimeoutExpired as err:
|
|
102
109
|
proc.kill()
|
|
103
110
|
msg = "The possible cause is that too much data is collected " \
|
|
@@ -112,5 +119,5 @@ class ProfilerInfoParser:
|
|
|
112
119
|
"""Convert syscnt to time stamp."""
|
|
113
120
|
ratio = time_fmt / cls._freq
|
|
114
121
|
# The unit of timestamp is ns
|
|
115
|
-
timestamp = round((syscnt - cls.
|
|
122
|
+
timestamp = round((syscnt - cls._cntvct) * ratio) + cls._get_localtime_diff
|
|
116
123
|
return timestamp
|
|
@@ -33,14 +33,21 @@ class TraceEventManager:
|
|
|
33
33
|
return x_event
|
|
34
34
|
|
|
35
35
|
@classmethod
|
|
36
|
-
def
|
|
36
|
+
def create_i_event(cls, event: BaseEvent) -> Dict:
|
|
37
|
+
"""Create a i event."""
|
|
38
|
+
event = {"name": event.name, "ph": "i", "ts": str(event.ts),
|
|
39
|
+
"pid": event.pid, "tid": event.tid, "args": event.args}
|
|
40
|
+
return event
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def create_m_event(cls, pid: int, tid_list: set, process_index: int) -> List:
|
|
37
44
|
"""Create some metadata event."""
|
|
38
45
|
# framework sidee trace information display format: MindSpore(pid pid_value): CPU
|
|
39
46
|
event_list = [
|
|
40
47
|
# process information
|
|
41
48
|
{"ph": "M", "name": Constant.PROCESS_NAME, "pid": pid, "tid": 0, "args": {"name": "MindSpore"}},
|
|
42
49
|
{"ph": "M", "name": Constant.PROCESS_LABEL, "pid": pid, "tid": 0, "args": {"labels": "CPU"}},
|
|
43
|
-
{"ph": "M", "name": Constant.PROCESS_SORT, "pid": pid, "tid": 0, "args": {"sort_index":
|
|
50
|
+
{"ph": "M", "name": Constant.PROCESS_SORT, "pid": pid, "tid": 0, "args": {"sort_index": process_index}},
|
|
44
51
|
]
|
|
45
52
|
for tid in tid_list:
|
|
46
53
|
sort_index = tid
|
|
@@ -24,6 +24,7 @@ from subprocess import Popen, PIPE
|
|
|
24
24
|
import csv
|
|
25
25
|
from mindspore import log as logger
|
|
26
26
|
from mindspore.profiler.common.util import get_newest_file
|
|
27
|
+
from mindspore.profiler.common.util import timeit
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
class AscendMsprofExporter:
|
|
@@ -54,7 +55,7 @@ class AscendMsprofExporter:
|
|
|
54
55
|
self._time_out = time_out
|
|
55
56
|
self.mindstudio_profiler_output = mindstudio_profiler_output # mindstudio_profiler_output dir
|
|
56
57
|
# PROF* dir
|
|
57
|
-
self.prof_root_dir = os.path.
|
|
58
|
+
self.prof_root_dir = os.path.realpath(os.path.join(self.mindstudio_profiler_output, os.path.pardir))
|
|
58
59
|
|
|
59
60
|
AscendMsprofExporter.check_msprof_env()
|
|
60
61
|
|
|
@@ -127,11 +128,10 @@ class AscendMsprofExporter:
|
|
|
127
128
|
def run_cmd(cls, cmd, timeout=300):
|
|
128
129
|
"""run shell command"""
|
|
129
130
|
try:
|
|
130
|
-
|
|
131
|
+
with Popen(cmd, stdout=PIPE, stderr=PIPE, text=True) as proc:
|
|
132
|
+
outs, errs = proc.communicate(timeout=timeout)
|
|
131
133
|
except (FileNotFoundError, PermissionError, CalledProcessError) as exc:
|
|
132
134
|
raise RuntimeError(exc) from exc
|
|
133
|
-
try:
|
|
134
|
-
outs, errs = proc.communicate(timeout=timeout)
|
|
135
135
|
except TimeoutExpired as err:
|
|
136
136
|
proc.kill()
|
|
137
137
|
msg = "The possible cause is that too much data is collected " \
|
|
@@ -168,6 +168,7 @@ class AscendMsprofExporter:
|
|
|
168
168
|
logger.warning('Get the drvVersion error, use single-export mode instead. detail : %s', err)
|
|
169
169
|
return False
|
|
170
170
|
|
|
171
|
+
@timeit("CANN export done")
|
|
171
172
|
def export(self, model_iteration_dict=None):
|
|
172
173
|
"""start_time is the time to collect PROF data"""
|
|
173
174
|
|
|
@@ -26,6 +26,7 @@ from mindspore.profiler.parser.base_timeline_generator import BaseTimelineGenera
|
|
|
26
26
|
from mindspore.profiler.parser.integrator import DeviceTarget
|
|
27
27
|
from mindspore.profiler.parser.ascend_analysis.fwk_cann_parser import FwkCANNParser
|
|
28
28
|
from mindspore.profiler.common.util import get_newest_file
|
|
29
|
+
from mindspore.profiler.parser.ascend_analysis.constant import Constant
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
class AscendTimelineGenerator(BaseTimelineGenerator):
|
|
@@ -33,9 +34,6 @@ class AscendTimelineGenerator(BaseTimelineGenerator):
|
|
|
33
34
|
_timeline_display_filename = 'ascend_timeline_display_{}.json'
|
|
34
35
|
_timeline_summary_filename = 'ascend_timeline_summary_{}.json'
|
|
35
36
|
_cluster_analyse_filename = 'ascend_cluster_analyse_{}_{}_{}_{}.csv'
|
|
36
|
-
top_scope_name = ('Default', 'Gradients', 'recompute_Default')
|
|
37
|
-
scope_index = 1
|
|
38
|
-
cpu_index = 2
|
|
39
37
|
|
|
40
38
|
def __init__(self, profiling_dir, source_path, mindstudio_profiler_output, rank_id, rank_size, mode,
|
|
41
39
|
step_list=None):
|
|
@@ -161,10 +159,6 @@ class AscendTimelineGenerator(BaseTimelineGenerator):
|
|
|
161
159
|
else:
|
|
162
160
|
msprof_timeline = self._parse_msprof_data(get_newest_file(file_list_msprof))
|
|
163
161
|
|
|
164
|
-
# get Ascend Hardware for scope
|
|
165
|
-
scope_data = self._parse_ascend_hardware_scope(msprof_timeline)
|
|
166
|
-
all_scope_data.extend(scope_data)
|
|
167
|
-
|
|
168
162
|
# get cpu op
|
|
169
163
|
cpu_op_file_name = fr'{self._profiling_dir}/cpu_op_execute_timestamp_{self._rank_id}.txt'
|
|
170
164
|
file_list = glob.glob(cpu_op_file_name)
|
|
@@ -175,20 +169,24 @@ class AscendTimelineGenerator(BaseTimelineGenerator):
|
|
|
175
169
|
timeline_data.extend(cpu_timeline)
|
|
176
170
|
all_scope_data.extend(scope_data)
|
|
177
171
|
|
|
178
|
-
# parse scope info
|
|
179
|
-
scope_timeline = self._parse_scope_info(all_scope_data)
|
|
180
|
-
timeline_data.extend(scope_timeline)
|
|
181
|
-
|
|
182
172
|
oprange_name = self._op_range_name.format(self._rank_id)
|
|
183
173
|
fwk_file_path = fr'{self._profiling_dir}/{self._framework_dir}/{oprange_name}'
|
|
184
174
|
if os.path.exists(fwk_file_path):
|
|
185
175
|
# It is faster not to submit to the pool
|
|
186
176
|
result = self._parse_fwk_device_data(msprof_timeline)
|
|
177
|
+
all_scope_data.extend(result.get('scope_data', []))
|
|
187
178
|
timeline_data.extend(result.get("trace_data", []))
|
|
188
179
|
self._kernel_events = result.get("kernels", [])
|
|
189
180
|
else:
|
|
181
|
+
# get Ascend Hardware for scope
|
|
182
|
+
scope_data = self._parse_ascend_hardware_scope(msprof_timeline)
|
|
183
|
+
all_scope_data.extend(scope_data)
|
|
190
184
|
timeline_data.extend(msprof_timeline)
|
|
191
185
|
|
|
186
|
+
# parse scope info
|
|
187
|
+
scope_timeline = self._parse_scope_info(all_scope_data)
|
|
188
|
+
timeline_data.extend(scope_timeline)
|
|
189
|
+
|
|
192
190
|
logger.info("All timeline data parse complete.")
|
|
193
191
|
self._timeline_data = timeline_data
|
|
194
192
|
return timeline_data
|
|
@@ -196,16 +194,16 @@ class AscendTimelineGenerator(BaseTimelineGenerator):
|
|
|
196
194
|
def parse_cpu_timeline(self, file_list):
|
|
197
195
|
"""Load cpu operator data from file"""
|
|
198
196
|
ms_to_us = 1e3
|
|
199
|
-
|
|
200
|
-
new_pid =
|
|
197
|
+
ns_to_us = 1e-3
|
|
198
|
+
new_pid = Constant.CPU_OP
|
|
201
199
|
process_list = [{"name": "process_name",
|
|
202
200
|
"pid": new_pid,
|
|
203
201
|
"args": {
|
|
204
|
-
"name": f"CPU OP
|
|
202
|
+
"name": f"CPU OP"
|
|
205
203
|
},
|
|
206
204
|
"ph": "M"
|
|
207
205
|
}, {"name": "process_sort_index", "pid": new_pid,
|
|
208
|
-
"args": {"sort_index":
|
|
206
|
+
"args": {"sort_index": new_pid}, "ph": "M"}
|
|
209
207
|
]
|
|
210
208
|
tid_set = set()
|
|
211
209
|
thread_list = []
|
|
@@ -221,11 +219,14 @@ class AscendTimelineGenerator(BaseTimelineGenerator):
|
|
|
221
219
|
time_arr = op_list[-1]
|
|
222
220
|
time_arr = time_arr.split(" ")
|
|
223
221
|
for time in time_arr:
|
|
224
|
-
ts, dur, tid = time.split(",")
|
|
225
|
-
ts = Decimal(ts).quantize(Decimal('0.000')) * Decimal(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
ts, dur, tid = time.split(",") # origin unit of ts is ns and dur is ms.
|
|
223
|
+
ts = Decimal(ts).quantize(Decimal('0.000')) * Decimal(ns_to_us).quantize(
|
|
224
|
+
Decimal('0.000')) # cast to us
|
|
225
|
+
dur = Decimal(dur).quantize(Decimal('0.000')) * Decimal(ms_to_us).quantize(
|
|
226
|
+
Decimal('0.000')) # cast to us
|
|
227
|
+
|
|
228
|
+
if op_full_name and op_full_name.startswith(Constant.TOP_SCOPE_NAMES):
|
|
229
|
+
te = ts + dur
|
|
229
230
|
scope_data.append((op_full_name.split('/')[:-1], ts, te))
|
|
230
231
|
|
|
231
232
|
if int(tid) not in tid_set:
|
|
@@ -261,7 +262,8 @@ class AscendTimelineGenerator(BaseTimelineGenerator):
|
|
|
261
262
|
fwkcann_parser = FwkCANNParser(self._source_path, cann_kernel_data, self._rank_id, self._step_list)
|
|
262
263
|
fwk_link_data = fwkcann_parser.generate_trace_data()
|
|
263
264
|
kernels = fwkcann_parser.kernels
|
|
264
|
-
|
|
265
|
+
scope_data = fwkcann_parser.scope_data_with_flow + fwkcann_parser.scope_data_without_flow
|
|
266
|
+
result = {"trace_data": fwk_link_data, "kernels": kernels, "scope_data": scope_data}
|
|
265
267
|
return result
|
|
266
268
|
|
|
267
269
|
def _parse_msprof_data(self, file_list):
|
|
@@ -298,7 +300,7 @@ class AscendTimelineGenerator(BaseTimelineGenerator):
|
|
|
298
300
|
continue
|
|
299
301
|
|
|
300
302
|
op_full_name = event.get('name')
|
|
301
|
-
if op_full_name and op_full_name.startswith(
|
|
303
|
+
if op_full_name and op_full_name.startswith(Constant.TOP_SCOPE_NAMES):
|
|
302
304
|
ts = Decimal(event.get('ts')).quantize(Decimal('0.000'))
|
|
303
305
|
te = ts + Decimal(event.get('dur')).quantize(Decimal('0.000'))
|
|
304
306
|
scope_data.append((op_full_name.split('/')[:-1], ts, te))
|
|
@@ -313,18 +315,18 @@ class AscendTimelineGenerator(BaseTimelineGenerator):
|
|
|
313
315
|
"""Parse scope info of op"""
|
|
314
316
|
if not scope_data:
|
|
315
317
|
return []
|
|
316
|
-
new_pid =
|
|
318
|
+
new_pid = Constant.SCOPE_LAYLER
|
|
317
319
|
scope_data.sort(key=lambda x: x[1])
|
|
318
320
|
process_list = [
|
|
319
321
|
{"name": "process_name",
|
|
320
322
|
"pid": new_pid,
|
|
321
323
|
"args": {
|
|
322
|
-
"name": f"Scope Layer
|
|
324
|
+
"name": f"Scope Layer"
|
|
323
325
|
},
|
|
324
326
|
"ph": "M"},
|
|
325
327
|
{"name": "process_sort_index",
|
|
326
328
|
"pid": new_pid,
|
|
327
|
-
"args": {"sort_index":
|
|
329
|
+
"args": {"sort_index": new_pid},
|
|
328
330
|
"ph": "M"}
|
|
329
331
|
]
|
|
330
332
|
|