mindspore 2.3.0__cp310-cp310-win_amd64.whl → 2.4.0__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/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- 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/atlprov.dll +0 -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/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- 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/mindir_util.py +2 -2
- mindspore/common/parameter.py +46 -13
- mindspore/common/recompute.py +39 -9
- mindspore/common/sparse_tensor.py +7 -3
- mindspore/common/tensor.py +209 -29
- mindspore/communication/__init__.py +1 -1
- mindspore/communication/_comm_helper.py +38 -3
- mindspore/communication/comm_func.py +310 -55
- mindspore/communication/management.py +14 -14
- mindspore/context.py +123 -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/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- 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/jpeg62.dll +0 -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_glog.dll +0 -0
- mindspore/mindspore_np_dtype.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mint/__init__.py +495 -46
- mindspore/mint/distributed/__init__.py +31 -0
- mindspore/mint/distributed/distributed.py +254 -0
- mindspore/mint/nn/__init__.py +266 -21
- 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 +28 -7
- mindspore/mint/special/__init__.py +63 -0
- mindspore/msobj140.dll +0 -0
- mindspore/mspdb140.dll +0 -0
- mindspore/mspdbcore.dll +0 -0
- mindspore/mspdbst.dll +0 -0
- mindspore/mspft140.dll +0 -0
- mindspore/msvcdis140.dll +0 -0
- mindspore/msvcp140_1.dll +0 -0
- mindspore/msvcp140_2.dll +0 -0
- mindspore/msvcp140_atomic_wait.dll +0 -0
- mindspore/msvcp140_codecvt_ids.dll +0 -0
- mindspore/multiprocessing/__init__.py +2 -1
- mindspore/nn/__init__.py +0 -1
- mindspore/nn/cell.py +275 -93
- mindspore/nn/layer/activation.py +211 -44
- mindspore/nn/layer/basic.py +113 -3
- mindspore/nn/layer/embedding.py +120 -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 +127 -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_comm_ops.py +47 -3
- 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 +85 -7
- mindspore/ops/auto_generate/gen_arg_dtype_cast.py +2 -0
- mindspore/ops/auto_generate/gen_extend_func.py +734 -13
- mindspore/ops/auto_generate/gen_ops_def.py +2420 -381
- mindspore/ops/auto_generate/gen_ops_prim.py +5196 -1659
- 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 +490 -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 +558 -207
- mindspore/ops/function/nn_func.py +817 -383
- mindspore/ops/function/other_func.py +3 -2
- mindspore/ops/function/random_func.py +184 -8
- 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 +6 -1
- 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 +12 -146
- mindspore/ops/operations/comm_ops.py +42 -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 +265 -10
- 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 +28 -8
- mindspore/parallel/_cell_wrapper.py +83 -0
- mindspore/parallel/_parallel_serialization.py +47 -19
- mindspore/parallel/_tensor.py +81 -11
- mindspore/parallel/_utils.py +13 -1
- 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 +993 -0
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -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 +280 -412
- 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 +36 -103
- mindspore/safeguard/rewrite_obfuscation.py +591 -247
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/__init__.py +4 -3
- mindspore/train/_utils.py +28 -2
- 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 +85 -22
- 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 +134 -31
- mindspore/train/callback/_summary_collector.py +5 -5
- mindspore/train/callback/_tft_register.py +352 -0
- mindspore/train/dataset_helper.py +7 -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 +134 -58
- mindspore/train/serialization.py +336 -112
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +21 -0
- mindspore/utils/utils.py +60 -0
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/METADATA +6 -2
- {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/RECORD +281 -275
- 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.0.dist-info}/WHEEL +0 -0
- {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/entry_points.txt +0 -0
- {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/top_level.txt +0 -0
|
@@ -54,7 +54,7 @@ class ReduceOp:
|
|
|
54
54
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
55
55
|
without any third-party or configuration file dependencies.
|
|
56
56
|
Please see the `msrun start up
|
|
57
|
-
<https://www.mindspore.cn/
|
|
57
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
58
58
|
for more details.
|
|
59
59
|
|
|
60
60
|
This example should be run with multiple devices.
|
|
@@ -141,7 +141,7 @@ class AllReduce(Primitive):
|
|
|
141
141
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
142
142
|
without any third-party or configuration file dependencies.
|
|
143
143
|
Please see the `msrun start up
|
|
144
|
-
<https://www.mindspore.cn/
|
|
144
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
145
145
|
for more details.
|
|
146
146
|
|
|
147
147
|
This example should be run with 2 devices.
|
|
@@ -178,14 +178,15 @@ class AllReduce(Primitive):
|
|
|
178
178
|
@prim_attr_register
|
|
179
179
|
def __init__(self, op=ReduceOp.SUM, group=GlobalComm.WORLD_COMM_GROUP):
|
|
180
180
|
"""Initialize AllReduce."""
|
|
181
|
+
self.group = _get_group(group)
|
|
181
182
|
if not isinstance(op, type(ReduceOp.SUM)):
|
|
182
183
|
raise TypeError(f"For '{self.name}', the 'op' must be str, but got {type(op).__name__}.")
|
|
183
|
-
if not isinstance(
|
|
184
|
+
if not isinstance(self.group, str):
|
|
184
185
|
raise TypeError(f"For '{self.name}', the 'group' must be str, "
|
|
185
|
-
f"but got {type(
|
|
186
|
-
check_hcom_group_valid(group, prim_name=self.name)
|
|
186
|
+
f"but got {type(self.group).__name__}.")
|
|
187
|
+
check_hcom_group_valid(self.group, prim_name=self.name)
|
|
187
188
|
self.op = op
|
|
188
|
-
self.add_prim_attr('group',
|
|
189
|
+
self.add_prim_attr('group', self.group)
|
|
189
190
|
self.add_prim_attr('fusion', 0)
|
|
190
191
|
self.add_prim_attr('index', 0)
|
|
191
192
|
self.add_prim_attr('no_eliminate', True)
|
|
@@ -230,7 +231,7 @@ class Reduce(PrimitiveWithInfer):
|
|
|
230
231
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method without any third-party
|
|
231
232
|
or configuration file dependencies.
|
|
232
233
|
Please see the `msrun start up
|
|
233
|
-
<https://www.mindspore.cn/
|
|
234
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
234
235
|
for more details.
|
|
235
236
|
|
|
236
237
|
This example should be run with 4 devices.
|
|
@@ -314,7 +315,7 @@ class AllGather(PrimitiveWithInfer):
|
|
|
314
315
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
315
316
|
without any third-party or configuration file dependencies.
|
|
316
317
|
Please see the `msrun start up
|
|
317
|
-
<https://www.mindspore.cn/
|
|
318
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
318
319
|
for more details.
|
|
319
320
|
|
|
320
321
|
This example should be run with 2 devices.
|
|
@@ -354,12 +355,13 @@ class AllGather(PrimitiveWithInfer):
|
|
|
354
355
|
@prim_attr_register
|
|
355
356
|
def __init__(self, group=GlobalComm.WORLD_COMM_GROUP):
|
|
356
357
|
"""Initialize AllGather."""
|
|
357
|
-
|
|
358
|
-
self.
|
|
359
|
-
self.
|
|
358
|
+
self.group = _get_group(group)
|
|
359
|
+
validator.check_value_type('group', self.group, (str,), self.name)
|
|
360
|
+
self.rank = get_rank(self.group)
|
|
361
|
+
self.rank_size = get_group_size(self.group)
|
|
360
362
|
validator.check('rank', self.rank, 'rank_size', self.rank_size, validator.LT, self.name)
|
|
361
363
|
self.add_prim_attr('rank_size', self.rank_size)
|
|
362
|
-
self.add_prim_attr('group',
|
|
364
|
+
self.add_prim_attr('group', self.group)
|
|
363
365
|
self.add_prim_attr('fusion', 0)
|
|
364
366
|
self.add_prim_attr('mean_flag', False)
|
|
365
367
|
self.add_prim_attr('no_eliminate', True)
|
|
@@ -375,25 +377,6 @@ class AllGather(PrimitiveWithInfer):
|
|
|
375
377
|
return x_dtype
|
|
376
378
|
|
|
377
379
|
|
|
378
|
-
class AShardIdentity(PrimitiveWithInfer):
|
|
379
|
-
"""
|
|
380
|
-
Auto parallel virtual operator. Identity operator only for shard function.
|
|
381
|
-
Do nothing in terms of infer_shape, infer_dtype, and the tensor.
|
|
382
|
-
|
|
383
|
-
It is only for internal use of parallel modules and cannot be called by users.
|
|
384
|
-
"""
|
|
385
|
-
|
|
386
|
-
@prim_attr_register
|
|
387
|
-
def __init__(self):
|
|
388
|
-
pass
|
|
389
|
-
|
|
390
|
-
def infer_shape(self, x_shape):
|
|
391
|
-
return x_shape
|
|
392
|
-
|
|
393
|
-
def infer_dtype(self, x_dtype):
|
|
394
|
-
return x_dtype
|
|
395
|
-
|
|
396
|
-
|
|
397
380
|
class _MiniStepAllGather(PrimitiveWithInfer):
|
|
398
381
|
"""
|
|
399
382
|
Auto parallel virtual operator. Do nothing in forward, do reducescatter in backward in mini-step. It is only for
|
|
@@ -555,7 +538,7 @@ class ReduceScatter(Primitive):
|
|
|
555
538
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
556
539
|
without any third-party or configuration file dependencies.
|
|
557
540
|
Please see the `msrun start up
|
|
558
|
-
<https://www.mindspore.cn/
|
|
541
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
559
542
|
for more details.
|
|
560
543
|
|
|
561
544
|
This example should be run with 2 devices.
|
|
@@ -597,11 +580,12 @@ class ReduceScatter(Primitive):
|
|
|
597
580
|
def __init__(self, op=ReduceOp.SUM, group=GlobalComm.WORLD_COMM_GROUP):
|
|
598
581
|
"""Initialize ReduceScatter."""
|
|
599
582
|
validator.check_value_type('op', op, (type(ReduceOp.SUM),), self.name)
|
|
600
|
-
|
|
583
|
+
self.group = _get_group(group)
|
|
584
|
+
validator.check_value_type('group', self.group, (str,), self.name)
|
|
601
585
|
self.op = op
|
|
602
|
-
self.rank_size = get_group_size(
|
|
586
|
+
self.rank_size = get_group_size(self.group)
|
|
603
587
|
self.add_prim_attr('rank_size', self.rank_size)
|
|
604
|
-
self.add_prim_attr('group',
|
|
588
|
+
self.add_prim_attr('group', self.group)
|
|
605
589
|
self.add_prim_attr('fusion', 0)
|
|
606
590
|
self.add_prim_attr('no_eliminate', True)
|
|
607
591
|
|
|
@@ -692,7 +676,7 @@ class Broadcast(PrimitiveWithInfer):
|
|
|
692
676
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
693
677
|
without any third-party or configuration file dependencies.
|
|
694
678
|
Please see the `msrun start up
|
|
695
|
-
<https://www.mindspore.cn/
|
|
679
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
696
680
|
for more details.
|
|
697
681
|
|
|
698
682
|
This example should be run with 2 devices.
|
|
@@ -922,7 +906,7 @@ class AlltoAll(PrimitiveWithInfer):
|
|
|
922
906
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
923
907
|
without any third-party or configuration file dependencies.
|
|
924
908
|
Please see the `msrun start up
|
|
925
|
-
<https://www.mindspore.cn/
|
|
909
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
926
910
|
for more details.
|
|
927
911
|
|
|
928
912
|
This example should be run with 8 devices.
|
|
@@ -1041,7 +1025,7 @@ class NeighborExchangeV2(Primitive):
|
|
|
1041
1025
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1042
1026
|
without any third-party or configuration file dependencies.
|
|
1043
1027
|
Please see the `msrun start up
|
|
1044
|
-
<https://www.mindspore.cn/
|
|
1028
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
1045
1029
|
for more details.
|
|
1046
1030
|
|
|
1047
1031
|
This example should be run with 2 devices.
|
|
@@ -1158,7 +1142,7 @@ class CollectiveScatter(Primitive):
|
|
|
1158
1142
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1159
1143
|
without any third-party or configuration file dependencies.
|
|
1160
1144
|
Please see the `msrun start up
|
|
1161
|
-
<https://www.mindspore.cn/
|
|
1145
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
1162
1146
|
for more details.
|
|
1163
1147
|
|
|
1164
1148
|
This example should be run with 2 devices.
|
|
@@ -1243,7 +1227,7 @@ class CollectiveGather(Primitive):
|
|
|
1243
1227
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1244
1228
|
without any third-party or configuration file dependencies.
|
|
1245
1229
|
Please see the `msrun start up
|
|
1246
|
-
<https://www.mindspore.cn/
|
|
1230
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
1247
1231
|
for more details.
|
|
1248
1232
|
|
|
1249
1233
|
This example should be run with 4 devices.
|
|
@@ -1308,8 +1292,6 @@ class Barrier(PrimitiveWithInfer):
|
|
|
1308
1292
|
Raises:
|
|
1309
1293
|
TypeError: If `group` is not a str.
|
|
1310
1294
|
RuntimeError: If backend is invalid, or distributed initialization fails.
|
|
1311
|
-
ValueError: If the local rank id of the calling process in the group
|
|
1312
|
-
is larger than the group's rank size.
|
|
1313
1295
|
|
|
1314
1296
|
Supported Platforms:
|
|
1315
1297
|
``Ascend``
|
|
@@ -1321,7 +1303,7 @@ class Barrier(PrimitiveWithInfer):
|
|
|
1321
1303
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1322
1304
|
without any third-party or configuration file dependencies.
|
|
1323
1305
|
Please see the `msrun start up
|
|
1324
|
-
<https://www.mindspore.cn/
|
|
1306
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
1325
1307
|
for more details.
|
|
1326
1308
|
|
|
1327
1309
|
This example should be run with 2 devices.
|
|
@@ -1395,7 +1377,7 @@ class Send(PrimitiveWithInfer):
|
|
|
1395
1377
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1396
1378
|
without any third-party or configuration file dependencies.
|
|
1397
1379
|
Please see the `msrun start up
|
|
1398
|
-
<https://www.mindspore.cn/
|
|
1380
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
1399
1381
|
for more details.
|
|
1400
1382
|
|
|
1401
1383
|
This example should be run with 2 devices.
|
|
@@ -1431,7 +1413,7 @@ class Send(PrimitiveWithInfer):
|
|
|
1431
1413
|
def __init__(self, sr_tag, dest_rank, group=GlobalComm.WORLD_COMM_GROUP, group_back=GlobalComm.WORLD_COMM_GROUP):
|
|
1432
1414
|
self.rank = dest_rank
|
|
1433
1415
|
self.sr_tag = sr_tag
|
|
1434
|
-
self.group = group
|
|
1416
|
+
self.group = _get_group(group)
|
|
1435
1417
|
self.add_prim_attr("no_eliminate", True)
|
|
1436
1418
|
|
|
1437
1419
|
def infer_shape(self, x_shape):
|
|
@@ -1479,7 +1461,7 @@ class Receive(PrimitiveWithInfer):
|
|
|
1479
1461
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1480
1462
|
without any third-party or configuration file dependencies.
|
|
1481
1463
|
Please see the `msrun start up
|
|
1482
|
-
<https://www.mindspore.cn/
|
|
1464
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
1483
1465
|
for more details.
|
|
1484
1466
|
|
|
1485
1467
|
This example should be run with 2 devices.
|
|
@@ -1517,7 +1499,7 @@ class Receive(PrimitiveWithInfer):
|
|
|
1517
1499
|
self.tag = sr_tag
|
|
1518
1500
|
self.shape = shape
|
|
1519
1501
|
self.dtype = dtype
|
|
1520
|
-
self.group = group
|
|
1502
|
+
self.group = _get_group(group)
|
|
1521
1503
|
self.add_prim_attr("no_eliminate", True)
|
|
1522
1504
|
valid_type = [mstype.float16, mstype.float32, mstype.float64, mstype.bfloat16,
|
|
1523
1505
|
mstype.int8, mstype.int16, mstype.int32, mstype.int64,
|
|
@@ -1695,6 +1677,8 @@ class _VirtualAssignAdd(PrimitiveWithInfer):
|
|
|
1695
1677
|
|
|
1696
1678
|
def infer_dtype(self, x_dtype, y_dtype):
|
|
1697
1679
|
return x_dtype
|
|
1680
|
+
|
|
1681
|
+
|
|
1698
1682
|
virtual_assign_add = _VirtualAssignAdd()
|
|
1699
1683
|
|
|
1700
1684
|
|
|
@@ -1834,7 +1818,7 @@ class BatchISendIRecv(PrimitiveWithInfer):
|
|
|
1834
1818
|
without any third-party or configuration file dependencies.
|
|
1835
1819
|
|
|
1836
1820
|
Please see the `msrun start up
|
|
1837
|
-
<https://www.mindspore.cn/
|
|
1821
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
1838
1822
|
for more details.
|
|
1839
1823
|
|
|
1840
1824
|
This example should be run with 2 devices.
|
|
@@ -1924,6 +1908,7 @@ class AlltoAllV(PrimitiveWithInfer):
|
|
|
1924
1908
|
recv_numel_list(Union[tuple[int], list[int]]): split numel to gather from different remote rank.
|
|
1925
1909
|
group (str): The communication group to work on. Default: ``GlobalComm.WORLD_COMM_GROUP``, which
|
|
1926
1910
|
means ``"hccl_world_group"`` in Ascend, and ``"nccl_world_group"`` in GPU.
|
|
1911
|
+
TODO:
|
|
1927
1912
|
|
|
1928
1913
|
Inputs:
|
|
1929
1914
|
- **input_x** (Tensor) - flatten tensor to scatter. The shape of tensor is :math:`(x_1)`.
|
|
@@ -1946,7 +1931,7 @@ class AlltoAllV(PrimitiveWithInfer):
|
|
|
1946
1931
|
without any third-party or configuration file dependencies.
|
|
1947
1932
|
|
|
1948
1933
|
Please see the `msrun start up
|
|
1949
|
-
<https://www.mindspore.cn/
|
|
1934
|
+
<https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
|
|
1950
1935
|
for more details.
|
|
1951
1936
|
|
|
1952
1937
|
This example should be run with 2 devices.
|
|
@@ -1986,11 +1971,15 @@ class AlltoAllV(PrimitiveWithInfer):
|
|
|
1986
1971
|
"""
|
|
1987
1972
|
|
|
1988
1973
|
@prim_attr_register
|
|
1989
|
-
def __init__(self, send_numel_list, recv_numel_list, group=None):
|
|
1974
|
+
def __init__(self, send_numel_list, recv_numel_list, group=None, split_sizes_empty=False):
|
|
1990
1975
|
validator.check_value_type("send_numel_list", send_numel_list, [tuple, list], self.name)
|
|
1991
1976
|
validator.check_value_type("recv_numel_list", recv_numel_list, [tuple, list], self.name)
|
|
1992
|
-
if group is None
|
|
1993
|
-
|
|
1994
|
-
self.
|
|
1977
|
+
self.group = GlobalComm.WORLD_COMM_GROUP if group is None else _get_group(group)
|
|
1978
|
+
self.send_numel_list = send_numel_list
|
|
1979
|
+
self.recv_numel_list = recv_numel_list
|
|
1980
|
+
self.split_sizes_empty = split_sizes_empty
|
|
1981
|
+
self.rank_size = get_group_size(self.group)
|
|
1982
|
+
|
|
1983
|
+
self.add_prim_attr('group', self.group)
|
|
1995
1984
|
self.add_prim_attr('send_numel_list', send_numel_list)
|
|
1996
1985
|
self.add_prim_attr('recv_numel_list', recv_numel_list)
|
|
@@ -28,6 +28,8 @@ import subprocess
|
|
|
28
28
|
import numpy as np
|
|
29
29
|
import mindspore as ms
|
|
30
30
|
from mindspore._c_expression import Oplib, typing
|
|
31
|
+
from mindspore._c_expression import pyboost_custom_ext
|
|
32
|
+
from mindspore.common._stub_tensor import _convert_stub
|
|
31
33
|
from mindspore import context
|
|
32
34
|
from mindspore.common import Tensor
|
|
33
35
|
from mindspore.common import dtype as mstype
|
|
@@ -156,6 +158,55 @@ def _compile_aot(file):
|
|
|
156
158
|
return func_path
|
|
157
159
|
|
|
158
160
|
|
|
161
|
+
class _CustomExt(ops.PrimitiveWithInfer):
|
|
162
|
+
"""
|
|
163
|
+
`Custom` primitive is used for PyBoost.
|
|
164
|
+
"""
|
|
165
|
+
|
|
166
|
+
def __init__(self, func, out_shape=None, out_dtype=None, bprop=None):
|
|
167
|
+
super().__init__("CustomExt")
|
|
168
|
+
self.func = func
|
|
169
|
+
self.out_shape = out_shape
|
|
170
|
+
self.out_dtype = out_dtype
|
|
171
|
+
self.bprop = bprop
|
|
172
|
+
|
|
173
|
+
def __infer__(self, *args):
|
|
174
|
+
if callable(self.out_shape):
|
|
175
|
+
infer_shape = self.out_shape(*(x["shape"] for x in args))
|
|
176
|
+
else:
|
|
177
|
+
infer_shape = self.out_shape
|
|
178
|
+
|
|
179
|
+
if callable(self.out_dtype):
|
|
180
|
+
infer_dtype = self.out_dtype(*(x["dtype"] for x in args))
|
|
181
|
+
else:
|
|
182
|
+
infer_dtype = self.out_dtype
|
|
183
|
+
|
|
184
|
+
infer_value = None
|
|
185
|
+
if infer_shape is None:
|
|
186
|
+
logger.warning("'out_shape' is None. Add a placeholder instead. "
|
|
187
|
+
"A CPP version of infer shape function is required "
|
|
188
|
+
"in this case.")
|
|
189
|
+
infer_shape = (1,)
|
|
190
|
+
# after all automatic infer information fulfillment, throw error if infer_shape/infer_dtype is still None
|
|
191
|
+
if not isinstance(infer_shape, (tuple, list)):
|
|
192
|
+
raise TypeError("'out_shape' must be one of [tuple, list, function], but got {}".format(type(infer_shape)))
|
|
193
|
+
|
|
194
|
+
if not isinstance(infer_dtype, (typing.Type, tuple, list)):
|
|
195
|
+
raise TypeError("'out_dtype' must be one of [mindspore.dtype, tuple, list, function], but got {}"
|
|
196
|
+
.format(type(infer_dtype)))
|
|
197
|
+
|
|
198
|
+
out = {
|
|
199
|
+
"shape": infer_shape,
|
|
200
|
+
"dtype": infer_dtype,
|
|
201
|
+
"value": infer_value,
|
|
202
|
+
}
|
|
203
|
+
return out
|
|
204
|
+
|
|
205
|
+
def get_bprop(self):
|
|
206
|
+
"""return back propagation function"""
|
|
207
|
+
return self.bprop
|
|
208
|
+
|
|
209
|
+
|
|
159
210
|
class Custom(ops.PrimitiveWithInfer):
|
|
160
211
|
r"""
|
|
161
212
|
`Custom` primitive is used for user defined operators and is to enhance the expressive ability of built-in
|
|
@@ -164,7 +215,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
164
215
|
function if needed. Then these `Custom` objects can be directly used in neural networks.
|
|
165
216
|
Detailed description and introduction of user-defined operators, including correct writing of parameters,
|
|
166
217
|
please refer to `Custom Operators Tutorial
|
|
167
|
-
<https://www.mindspore.cn/
|
|
218
|
+
<https://www.mindspore.cn/docs/en/master/model_train/custom_program/op_custom.html>`_ .
|
|
168
219
|
|
|
169
220
|
.. warning::
|
|
170
221
|
- This is an experimental API that is subject to change.
|
|
@@ -174,7 +225,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
174
225
|
|
|
175
226
|
- "hybrid": supports ["GPU", "CPU"].
|
|
176
227
|
- "akg": supports ["GPU", "CPU"].
|
|
177
|
-
- "aot": supports ["GPU", "CPU", "
|
|
228
|
+
- "aot": supports ["GPU", "CPU", "Ascend"].
|
|
178
229
|
- "pyfunc": supports ["CPU"].
|
|
179
230
|
- "julia": supports ["CPU"].
|
|
180
231
|
|
|
@@ -249,20 +300,18 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
249
300
|
(ex. Custom(func="./reorganize.so:CustomReorganize", out_shape=[1], out_dtype=mstype.float32,
|
|
250
301
|
"aot"))
|
|
251
302
|
|
|
252
|
-
b)
|
|
253
|
-
Before using Custom operators on the
|
|
254
|
-
based on Ascend C and compile them.
|
|
255
|
-
`
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
- Inferring the shape of the operator through C++ derivation: func="infer_shape.cc:aclnnAddCustom",
|
|
265
|
-
where infer_shape.cc is the shape derivation implemented in C++.
|
|
303
|
+
b) Ascend platform.
|
|
304
|
+
Before using Custom operators on the Ascend platform, users must first develop custom operators
|
|
305
|
+
based on Ascend C and compile them. The complete development and usage process can refer to the
|
|
306
|
+
tutorial `AOT-Type Custom Operators(Ascend) <https://www.mindspore.cn/docs/en/master/model_train/custom_program/operation/op_custom_ascendc.html>`_.
|
|
307
|
+
By passing the name of the operator through the input parameter `func`, there are two usage methods
|
|
308
|
+
based on the implementation of the infer shape function:
|
|
309
|
+
|
|
310
|
+
- Python infer: If the operator's infer shape is implemented in Python, that is, the infer shape
|
|
311
|
+
function is passed through the `out_shape` parameter, specify `func="CustomName"` .
|
|
312
|
+
- C++ infer: If the operator's infer shape is implemented through C++, then pass the path of the
|
|
313
|
+
infer shape implementation file in `func` and separate the operator name with `:`,
|
|
314
|
+
for example: `func="add_custom_infer.cc:AddCustom"` .
|
|
266
315
|
|
|
267
316
|
2. for "julia":
|
|
268
317
|
|
|
@@ -338,7 +387,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
338
387
|
or the attributes of `func` differs in different targets.
|
|
339
388
|
|
|
340
389
|
Supported Platforms:
|
|
341
|
-
``
|
|
390
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
342
391
|
|
|
343
392
|
Examples:
|
|
344
393
|
>>> import numpy as np
|
|
@@ -457,6 +506,12 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
457
506
|
|
|
458
507
|
self.add_prim_attr("func_type", self.func_type)
|
|
459
508
|
self._update_attr()
|
|
509
|
+
self.enable_pyboost = False
|
|
510
|
+
self.custom_pyboost = _CustomExt(self.func, self.out_shape, self.out_dtype, self.bprop)
|
|
511
|
+
if context.get_context("device_target") == "Ascend" and self.func_type == "aot":
|
|
512
|
+
self.enable_pyboost = True
|
|
513
|
+
for key, value in super().get_attr_dict().items():
|
|
514
|
+
self.custom_pyboost.add_prim_attr(key, value)
|
|
460
515
|
|
|
461
516
|
def __infer__(self, *args):
|
|
462
517
|
if callable(self.out_shape):
|
|
@@ -559,7 +614,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
559
614
|
raise TypeError(
|
|
560
615
|
"{}, 'func' should be like 'file_name:func_name', but got {}".format(
|
|
561
616
|
self.log_prefix, self.func))
|
|
562
|
-
file_path = os.path.
|
|
617
|
+
file_path = os.path.realpath(file_name_list[0])
|
|
563
618
|
if os.environ.get('MS_CUSTOM_AOT_WHITE_LIST') is None:
|
|
564
619
|
if Custom.custom_aot_warning:
|
|
565
620
|
logger.info("{}, no white list is set and it might cause problems. "
|
|
@@ -567,7 +622,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
567
622
|
.format(self.log_prefix))
|
|
568
623
|
Custom.custom_aot_warning = False
|
|
569
624
|
else:
|
|
570
|
-
legal_path = os.path.
|
|
625
|
+
legal_path = os.path.realpath(os.environ.get('MS_CUSTOM_AOT_WHITE_LIST'))
|
|
571
626
|
if legal_path not in file_path:
|
|
572
627
|
raise TypeError(
|
|
573
628
|
"{}, the legal path for the file is {}, but the file is {}".format(
|
|
@@ -1063,3 +1118,12 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
1063
1118
|
infer_value = Tensor(fake_output) if enable_infer_value else None
|
|
1064
1119
|
|
|
1065
1120
|
return infer_shape, infer_dtype, infer_value
|
|
1121
|
+
|
|
1122
|
+
def __call__(self, *args):
|
|
1123
|
+
if self.enable_pyboost:
|
|
1124
|
+
return _convert_stub(pyboost_custom_ext(self.custom_pyboost, [args]))
|
|
1125
|
+
should_elim, output = self.check_elim(*args)
|
|
1126
|
+
if should_elim:
|
|
1127
|
+
return output
|
|
1128
|
+
# pylint: disable=protected-access
|
|
1129
|
+
return ops.primitive._run_op(self, self.name, args)
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"""debug_ops"""
|
|
16
16
|
import os
|
|
17
17
|
import stat
|
|
18
|
-
from types import FunctionType, MethodType
|
|
19
18
|
|
|
20
19
|
import numpy as np
|
|
21
20
|
from mindspore import log as logger
|
|
22
|
-
from mindspore._c_expression import security
|
|
21
|
+
from mindspore._c_expression import security, HookType
|
|
23
22
|
from mindspore._c_expression import Tensor as Tensor_
|
|
24
23
|
from mindspore import _checkparam as validator
|
|
25
24
|
from mindspore.common import dtype as mstype
|
|
26
25
|
from mindspore.common.parameter import Parameter
|
|
27
26
|
from mindspore.common.tensor import Tensor
|
|
28
27
|
from mindspore.ops.primitive import prim_attr_register, Primitive, PrimitiveWithInfer
|
|
28
|
+
from mindspore._checkparam import check_hook_fn
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
SUMMARY_TENSOR_CACHE = []
|
|
@@ -64,6 +64,8 @@ class ScalarSummary(Primitive):
|
|
|
64
64
|
which specify the directory of the summary file. The summary file can
|
|
65
65
|
be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
|
|
66
66
|
mindinsight/docs/en/master/index.html>`_ for details.
|
|
67
|
+
In Ascend platform with graph mode, can set environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
|
|
68
|
+
to solve operator execution failure when calling this operator intensively.
|
|
67
69
|
|
|
68
70
|
Inputs:
|
|
69
71
|
- **name** (str) - The name of the input variable, it must not be an empty string.
|
|
@@ -122,6 +124,8 @@ class ImageSummary(Primitive):
|
|
|
122
124
|
SummaryRecord or SummaryCollector, which specify the directory of the summary file. The summary file can
|
|
123
125
|
be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
|
|
124
126
|
mindinsight/docs/en/master/index.html>`_ for details.
|
|
127
|
+
In Ascend platform with graph mode, can set environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
|
|
128
|
+
to solve operator execution failure when calling this operator intensively.
|
|
125
129
|
|
|
126
130
|
Inputs:
|
|
127
131
|
- **name** (str) - The name of the input variable, it must not be an empty string.
|
|
@@ -173,6 +177,8 @@ class TensorSummary(Primitive):
|
|
|
173
177
|
or SummaryCollector, which specify the directory of the summary file. The summary file can
|
|
174
178
|
be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
|
|
175
179
|
mindinsight/docs/en/master/index.html>`_ for details.
|
|
180
|
+
In Ascend platform with graph mode, can set environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
|
|
181
|
+
to solve operator execution failure when calling this operator intensively.
|
|
176
182
|
|
|
177
183
|
Inputs:
|
|
178
184
|
- **name** (str) - The name of the input variable.
|
|
@@ -228,9 +234,6 @@ class TensorDump(Primitive):
|
|
|
228
234
|
"""
|
|
229
235
|
Save the Tensor as an npy file in numpy format.
|
|
230
236
|
|
|
231
|
-
The file name will automatically have a prefix added based on the execution order. For example, if `file` is `a`,
|
|
232
|
-
the first saved file will be named `0_a.npy`, and the second one will be named `1_a.npy`, and so on.
|
|
233
|
-
|
|
234
237
|
.. warning::
|
|
235
238
|
- If a large amount of data is stored within a short period, it may lead to memory overflow on the device side.
|
|
236
239
|
Consider slicing the data to reduce the data scale.
|
|
@@ -238,6 +241,34 @@ class TensorDump(Primitive):
|
|
|
238
241
|
too quickly, data loss may occur. You need to actively control the destruction time of the main process,
|
|
239
242
|
such as using sleep.
|
|
240
243
|
|
|
244
|
+
Args:
|
|
245
|
+
input_output (str, optional): Used to control Tensordump behavior.
|
|
246
|
+
Available value is one of ['in', 'out', 'all']. Default value is ``out``.
|
|
247
|
+
|
|
248
|
+
In case of OpA --> RedistributionOps --> OpB,
|
|
249
|
+
The dump data of OpA's output is not equal to OpB's input (Due to the redistribution operators).
|
|
250
|
+
So the parameter input_output is to handle this situation.
|
|
251
|
+
|
|
252
|
+
Assuming OpA's output is used as both Tensordump's input parameter and OpB's input parameter.
|
|
253
|
+
Different requirements of saving dump data can be achieved by configuring parameter input_output:
|
|
254
|
+
|
|
255
|
+
- If the input_output is 'out', the dump data contains only OpA's output slice.
|
|
256
|
+
- If the input_output is 'all', the dump data contains both OpA's output slice and OpB's input slice.
|
|
257
|
+
- If the input_output is 'in', the dump data contains only OpB's input slice.
|
|
258
|
+
|
|
259
|
+
For input_output is 'all' or 'in', the input slice npy file format is:
|
|
260
|
+
id_fileName_cNodeID_dumpMode_rankID.npy.
|
|
261
|
+
|
|
262
|
+
For input_output is 'out' or 'all' the output slice npy file format is:
|
|
263
|
+
id_fileName.npy.
|
|
264
|
+
|
|
265
|
+
- id: An auto increment ID.
|
|
266
|
+
- fileName: Value of the parameter file
|
|
267
|
+
(if parameter file_name is a user-specified path, the value of fileName is the last level of the path).
|
|
268
|
+
- cNodeID: The node ID of the Tensordump node in the step_parallel_end.ir file.
|
|
269
|
+
- dumpMode: Value of the parameter input_output.
|
|
270
|
+
- rankID: Logical device id.
|
|
271
|
+
|
|
241
272
|
Inputs:
|
|
242
273
|
- **file** (str) - The path of the file to be saved.
|
|
243
274
|
- **input_x** (Tensor) - Input Tensor of any dimension.
|
|
@@ -280,7 +311,7 @@ class TensorDump(Primitive):
|
|
|
280
311
|
[6. 7. 8. 9.]]
|
|
281
312
|
"""
|
|
282
313
|
@prim_attr_register
|
|
283
|
-
def __init__(self):
|
|
314
|
+
def __init__(self, input_output='out'):
|
|
284
315
|
"""Initialize TensorDump."""
|
|
285
316
|
if security.enable_security():
|
|
286
317
|
raise ValueError('The TensorDump is not supported, please without `-s on` and recompile source.')
|
|
@@ -314,6 +345,8 @@ class HistogramSummary(Primitive):
|
|
|
314
345
|
It must be used with SummaryRecord or SummaryCollector, which specify the directory of the summary file.
|
|
315
346
|
The summary file can be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
|
|
316
347
|
mindinsight/docs/en/master/index.html>`_ for details.
|
|
348
|
+
In Ascend platform with graph mode, can set environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
|
|
349
|
+
to solve operator execution failure when calling this operator intensively.
|
|
317
350
|
|
|
318
351
|
Inputs:
|
|
319
352
|
- **name** (str) - The name of the input variable.
|
|
@@ -499,16 +532,15 @@ class HookBackward(PrimitiveWithInfer):
|
|
|
499
532
|
def __init__(self, hook_fn, cell_id=""):
|
|
500
533
|
"""Initialize HookBackward."""
|
|
501
534
|
super(HookBackward, self).__init__(self.__class__.__name__)
|
|
502
|
-
if not
|
|
503
|
-
|
|
504
|
-
f"but got {type(hook_fn)}.")
|
|
535
|
+
if not check_hook_fn("HookBackward", hook_fn):
|
|
536
|
+
return
|
|
505
537
|
if cell_id != "":
|
|
506
538
|
logger.warning(f"The args 'cell_id' of HookBackward will be removed in a future version. If the value of "
|
|
507
539
|
f"'cell_id' is set, the hook function will not work.")
|
|
508
540
|
self.add_prim_attr("cell_id", cell_id)
|
|
509
541
|
self.init_attrs["cell_id"] = cell_id
|
|
510
542
|
self.cell_id = cell_id
|
|
511
|
-
self.
|
|
543
|
+
self.set_hook_fn(hook_fn, HookType.HookBackward)
|
|
512
544
|
|
|
513
545
|
def infer_shape(self, *inputs_shape):
|
|
514
546
|
if len(inputs_shape) == 1:
|
|
@@ -23,6 +23,7 @@ from mindspore.common import dtype as mstype
|
|
|
23
23
|
from mindspore import _checkparam as validator
|
|
24
24
|
from mindspore.common._decorator import deprecated
|
|
25
25
|
from mindspore.ops.primitive import prim_attr_register, Primitive
|
|
26
|
+
from mindspore import log as logger
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
class ScalarCast(Primitive):
|
|
@@ -59,3 +60,14 @@ class ScalarCast(Primitive):
|
|
|
59
60
|
value = np.cast[np_dtype.lower()](input_x)
|
|
60
61
|
value = value.item()
|
|
61
62
|
return value
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class TensorReport(Primitive):
|
|
66
|
+
@prim_attr_register
|
|
67
|
+
def __init__(self):
|
|
68
|
+
"""Initialize TensorReport"""
|
|
69
|
+
self.add_prim_attr("side_effect_io", True)
|
|
70
|
+
self.add_prim_attr("channel_name", "ms_tensor_report")
|
|
71
|
+
|
|
72
|
+
def __call__(self, file, input_x):
|
|
73
|
+
logger.warning("TensorReport doesn't support pynative mode.")
|