mindspore 2.0.0rc1__cp38-none-any.whl → 2.2.0__cp38-none-any.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/Third_Party_Open_Source_Software_Notice +2 -2
- mindspore/__init__.py +5 -2
- mindspore/_akg/akg/build_module.py +5 -6
- mindspore/_akg/akg/composite/build_module.py +49 -16
- mindspore/_akg/akg/composite/split_stitch.py +10 -11
- mindspore/_akg/akg/config/repository.json +195 -0
- mindspore/_akg/akg/global_configs.py +5 -1
- mindspore/_akg/akg/ms/info_version_adapt.py +67 -1
- mindspore/_akg/akg/tvm/api.py +4 -3
- mindspore/_akg/akg/tvm/autotvm/__init__.py +1 -2
- mindspore/_akg/akg/tvm/autotvm/graph_tuner/base_graph_tuner.py +1 -5
- mindspore/_akg/akg/tvm/autotvm/measure/__init__.py +1 -1
- mindspore/_akg/akg/tvm/autotvm/measure/measure.py +1 -10
- mindspore/_akg/akg/tvm/autotvm/measure/measure_methods.py +1 -372
- mindspore/_akg/akg/tvm/build_module.py +16 -1
- mindspore/_akg/akg/tvm/contrib/graph_runtime.py +0 -53
- mindspore/_akg/akg/tvm/hybrid/parser.py +7 -6
- mindspore/_akg/akg/tvm/ir_builder.py +1 -1
- mindspore/_akg/akg/tvm/module.py +1 -2
- mindspore/_akg/akg/tvm/stmt.py +2 -2
- mindspore/_akg/akg/utils/composite_op_helper.py +9 -10
- mindspore/_akg/akg/utils/kernel_exec.py +58 -260
- mindspore/_akg/akg/utils/op_dsl.py +17 -1
- mindspore/_akg/akg/utils/result_analysis.py +4 -24
- mindspore/_akg/akg/utils/tbe_codegen_utils.py +198 -0
- mindspore/_c_dataengine.cpython-38-aarch64-linux-gnu.so +0 -0
- mindspore/_c_expression.cpython-38-aarch64-linux-gnu.so +0 -0
- mindspore/_c_mindrecord.cpython-38-aarch64-linux-gnu.so +0 -0
- mindspore/_check_jit_forbidden_api.py +5 -1
- mindspore/_checkparam.py +79 -62
- mindspore/_extends/graph_kernel/__init__.py +0 -1
- mindspore/_extends/graph_kernel/model/graph_split.py +2 -0
- mindspore/_extends/graph_kernel/model/model_builder.py +9 -50
- mindspore/_extends/graph_kernel/splitter.py +1 -9
- mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +128 -21
- mindspore/_extends/parallel_compile/akg_compiler/build_tbe_kernel.py +2 -2
- mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +4 -2
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +18 -13
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +13 -9
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_job.py +1 -1
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_job_manager.py +1 -1
- mindspore/_extends/parse/__init__.py +19 -17
- mindspore/_extends/parse/namespace.py +7 -36
- mindspore/_extends/parse/parser.py +375 -189
- mindspore/_extends/parse/resources.py +36 -41
- mindspore/_extends/parse/standard_method.py +350 -245
- mindspore/_extends/parse/trope.py +2 -12
- mindspore/_extends/remote/kernel_build_server.py +24 -7
- mindspore/_extends/remote/kernel_build_server_akg_v2.py +55 -0
- mindspore/_install_custom.py +43 -0
- mindspore/_mindspore_offline_debug.cpython-38-aarch64-linux-gnu.so +0 -0
- mindspore/amp.py +85 -19
- mindspore/bin/cache_admin +0 -0
- mindspore/bin/cache_server +0 -0
- mindspore/boost/base.py +2 -2
- mindspore/boost/boost.py +27 -32
- mindspore/boost/boost_cell_wrapper.py +37 -13
- mindspore/boost/grad_accumulation.py +1 -1
- mindspore/boost/grad_freeze.py +34 -6
- mindspore/boost/group_loss_scale_manager.py +15 -14
- mindspore/boost/less_batch_normalization.py +28 -3
- mindspore/common/__init__.py +15 -11
- mindspore/common/_auto_dynamic.py +68 -0
- mindspore/common/_jit_fallback_utils.py +111 -0
- mindspore/common/_register_for_adapter.py +17 -5
- mindspore/common/_register_for_tensor.py +2 -2
- mindspore/common/_stub_tensor.py +18 -15
- mindspore/common/_utils.py +31 -7
- mindspore/common/api.py +269 -101
- mindspore/common/auto_dynamic_shape.py +498 -0
- mindspore/common/dtype.py +61 -21
- mindspore/common/dump.py +9 -7
- mindspore/common/initializer.py +106 -76
- mindspore/common/jit_config.py +35 -14
- mindspore/common/lazy_inline.py +187 -0
- mindspore/common/mindir_util.py +101 -0
- mindspore/common/mutable.py +10 -13
- mindspore/common/parameter.py +246 -55
- mindspore/common/seed.py +13 -7
- mindspore/common/sparse_tensor.py +29 -33
- mindspore/common/tensor.py +907 -251
- mindspore/communication/__init__.py +7 -4
- mindspore/communication/_comm_helper.py +84 -4
- mindspore/communication/management.py +160 -88
- mindspore/config/op_info.config +99 -75
- mindspore/config/super_bar_config.json +36 -4
- mindspore/context.py +526 -219
- mindspore/dataset/__init__.py +9 -46
- mindspore/dataset/audio/__init__.py +4 -19
- mindspore/dataset/audio/transforms.py +545 -233
- mindspore/dataset/audio/utils.py +21 -18
- mindspore/dataset/callback/ds_callback.py +42 -13
- mindspore/dataset/core/config.py +158 -100
- mindspore/dataset/core/validator_helpers.py +1 -63
- mindspore/dataset/debug/debug_hook.py +45 -13
- mindspore/dataset/debug/pre_defined_hook.py +5 -5
- mindspore/dataset/engine/__init__.py +0 -5
- mindspore/dataset/engine/cache_client.py +38 -15
- mindspore/dataset/engine/datasets.py +615 -278
- mindspore/dataset/engine/datasets_audio.py +154 -283
- mindspore/dataset/engine/datasets_standard_format.py +104 -116
- mindspore/dataset/engine/datasets_text.py +443 -326
- mindspore/dataset/engine/datasets_user_defined.py +251 -164
- mindspore/dataset/engine/datasets_vision.py +839 -1443
- mindspore/dataset/engine/iterators.py +11 -4
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +7 -3
- mindspore/dataset/engine/obs/util.py +3 -0
- mindspore/dataset/engine/offload.py +6 -6
- mindspore/dataset/engine/queue.py +15 -14
- mindspore/dataset/engine/samplers.py +39 -23
- mindspore/dataset/engine/serializer_deserializer.py +22 -6
- mindspore/dataset/engine/validators.py +21 -331
- mindspore/dataset/text/__init__.py +5 -33
- mindspore/dataset/text/transforms.py +334 -165
- mindspore/dataset/text/utils.py +215 -145
- mindspore/dataset/transforms/__init__.py +1 -1
- mindspore/dataset/transforms/c_transforms.py +3 -2
- mindspore/dataset/transforms/py_transforms_util.py +40 -12
- mindspore/dataset/transforms/transforms.py +174 -71
- mindspore/dataset/utils/browse_dataset.py +25 -17
- mindspore/dataset/utils/line_reader.py +24 -21
- mindspore/dataset/vision/__init__.py +5 -26
- mindspore/dataset/vision/c_transforms.py +177 -165
- mindspore/dataset/vision/py_transforms.py +114 -119
- mindspore/dataset/vision/py_transforms_util.py +54 -51
- mindspore/dataset/vision/transforms.py +1127 -381
- mindspore/dataset/vision/utils.py +54 -38
- mindspore/dataset/vision/validators.py +12 -2
- mindspore/experimental/map_parameter.py +38 -4
- mindspore/{dataset/datapreprocess → experimental/optim}/__init__.py +14 -4
- mindspore/experimental/optim/adam.py +192 -0
- mindspore/experimental/optim/adamw.py +181 -0
- mindspore/experimental/optim/lr_scheduler.py +1427 -0
- mindspore/experimental/optim/optimizer.py +252 -0
- mindspore/experimental/optim/sgd.py +147 -0
- mindspore/gen_ops.py +273 -0
- mindspore/include/OWNERS +1 -2
- mindspore/include/api/context.h +21 -1
- mindspore/include/api/data_type.h +2 -1
- mindspore/include/api/graph.h +0 -15
- mindspore/include/api/kernel.h +2 -0
- mindspore/include/api/kernel_api.h +37 -12
- mindspore/include/api/model.h +29 -42
- mindspore/include/api/model_group.h +14 -3
- mindspore/include/api/model_parallel_runner.h +18 -2
- mindspore/include/api/serialization.h +26 -0
- mindspore/include/api/status.h +1 -0
- mindspore/include/api/types.h +38 -4
- mindspore/include/c_api/ms/abstract.h +67 -0
- mindspore/include/c_api/ms/attribute.h +197 -0
- mindspore/include/c_api/ms/base/handle_types.h +43 -0
- mindspore/include/c_api/ms/base/macros.h +32 -0
- mindspore/include/c_api/ms/base/status.h +33 -0
- mindspore/include/c_api/ms/base/types.h +282 -0
- mindspore/include/c_api/ms/context.h +102 -0
- mindspore/include/c_api/ms/graph.h +160 -0
- mindspore/include/c_api/ms/node.h +606 -0
- mindspore/include/c_api/ms/tensor.h +161 -0
- mindspore/include/c_api/ms/value.h +84 -0
- mindspore/include/c_api/status_c.h +3 -0
- mindspore/include/dataset/constants.h +6 -12
- mindspore/include/dataset/execute.h +23 -13
- mindspore/include/dataset/text.h +26 -26
- mindspore/include/dataset/transforms.h +25 -31
- mindspore/include/dataset/vision.h +60 -60
- mindspore/include/dataset/vision_ascend.h +5 -6
- mindspore/include/dataset/vision_lite.h +17 -17
- mindspore/include/mindapi/base/format.h +0 -1
- mindspore/include/mindapi/base/type_id.h +2 -1
- mindspore/include/mindapi/base/types.h +5 -1
- mindspore/lib/libdnnl.so.2 +0 -0
- mindspore/lib/libjemalloc.so.2 +0 -0
- mindspore/lib/libmindspore.so +0 -0
- mindspore/lib/libmindspore_backend.so +0 -0
- mindspore/lib/libmindspore_common.so +0 -0
- mindspore/lib/libmindspore_core.so +0 -0
- mindspore/lib/libmindspore_glog.so.0 +0 -0
- mindspore/lib/libmindspore_gpr.so.15 +0 -0
- mindspore/lib/libmindspore_grpc++.so.1 +0 -0
- mindspore/lib/libmindspore_grpc.so.15 +0 -0
- mindspore/lib/libmindspore_shared_lib.so +0 -0
- mindspore/lib/libmpi_adapter.so +0 -0
- mindspore/lib/libnnacl.so +0 -0
- mindspore/lib/libopencv_core.so.4.5 +0 -0
- mindspore/lib/libopencv_imgcodecs.so.4.5 +0 -0
- mindspore/lib/libopencv_imgproc.so.4.5 +0 -0
- mindspore/lib/libps_cache.so +0 -0
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_aicpu_kernels.so +0 -0
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_cpu_kernels.so +0 -0
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/config/cust_aicpu_kernel.json +9000 -0
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_proto/libcust_op_proto.so +0 -0
- mindspore/lib/plugin/ascend/libakg.so +0 -0
- mindspore/lib/plugin/ascend/libascend_collective.so +0 -0
- mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
- mindspore/lib/plugin/ascend/libhccl_plugin.so +0 -0
- mindspore/lib/plugin/ascend/libmindspore_aicpu_kernels.so +0 -0
- mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
- mindspore/lib/plugin/cpu/libakg.so +0 -0
- mindspore/lib/plugin/libmindspore_ascend.so.1 +0 -0
- mindspore/lib/plugin/libmindspore_ascend.so.2 +0 -0
- mindspore/log.py +9 -6
- mindspore/mindrecord/filereader.py +33 -4
- mindspore/mindrecord/filewriter.py +70 -35
- mindspore/mindrecord/mindpage.py +40 -34
- mindspore/mindrecord/shardreader.py +1 -1
- mindspore/mindrecord/shardsegment.py +1 -1
- mindspore/mindrecord/tools/cifar100_to_mr.py +25 -18
- mindspore/mindrecord/tools/cifar10_to_mr.py +25 -18
- mindspore/mindrecord/tools/csv_to_mr.py +29 -13
- mindspore/mindrecord/tools/imagenet_to_mr.py +24 -10
- mindspore/mindrecord/tools/mnist_to_mr.py +24 -11
- mindspore/mindrecord/tools/tfrecord_to_mr.py +31 -26
- mindspore/nn/cell.py +463 -169
- mindspore/nn/dynamic_lr.py +47 -43
- mindspore/nn/layer/activation.py +225 -82
- mindspore/nn/layer/basic.py +121 -79
- mindspore/nn/layer/channel_shuffle.py +21 -21
- mindspore/nn/layer/combined.py +33 -26
- mindspore/nn/layer/container.py +277 -22
- mindspore/nn/layer/conv.py +441 -304
- mindspore/nn/layer/dense.py +19 -13
- mindspore/nn/layer/embedding.py +62 -49
- mindspore/nn/layer/flash_attention.py +264 -0
- mindspore/nn/layer/image.py +50 -39
- mindspore/nn/layer/math.py +62 -51
- mindspore/nn/layer/normalization.py +219 -167
- mindspore/nn/layer/padding.py +58 -70
- mindspore/nn/layer/pooling.py +334 -287
- mindspore/nn/layer/rnn_cells.py +53 -38
- mindspore/nn/layer/rnns.py +59 -56
- mindspore/nn/layer/thor_layer.py +52 -44
- mindspore/nn/layer/timedistributed.py +6 -4
- mindspore/nn/layer/transformer.py +284 -164
- mindspore/nn/learning_rate_schedule.py +34 -25
- mindspore/nn/loss/__init__.py +3 -2
- mindspore/nn/loss/loss.py +554 -311
- mindspore/nn/optim/ada_grad.py +12 -9
- mindspore/nn/optim/adadelta.py +14 -11
- mindspore/nn/optim/adafactor.py +19 -16
- mindspore/nn/optim/adam.py +62 -47
- mindspore/nn/optim/adamax.py +13 -10
- mindspore/nn/optim/adasum.py +12 -8
- mindspore/nn/optim/asgd.py +10 -9
- mindspore/nn/optim/ftrl.py +20 -17
- mindspore/nn/optim/lamb.py +16 -12
- mindspore/nn/optim/lars.py +8 -6
- mindspore/nn/optim/lazyadam.py +25 -20
- mindspore/nn/optim/momentum.py +10 -7
- mindspore/nn/optim/optimizer.py +61 -9
- mindspore/nn/optim/proximal_ada_grad.py +14 -13
- mindspore/nn/optim/rmsprop.py +17 -13
- mindspore/nn/optim/rprop.py +30 -17
- mindspore/nn/optim/sgd.py +40 -23
- mindspore/nn/optim/thor.py +24 -26
- mindspore/nn/probability/bijector/bijector.py +11 -11
- mindspore/nn/probability/bijector/exp.py +1 -1
- mindspore/nn/probability/bijector/gumbel_cdf.py +3 -3
- mindspore/nn/probability/bijector/invert.py +1 -1
- mindspore/nn/probability/bijector/power_transform.py +29 -29
- mindspore/nn/probability/bijector/scalar_affine.py +3 -3
- mindspore/nn/probability/bijector/softplus.py +5 -5
- mindspore/nn/probability/bnn_layers/bnn_cell_wrapper.py +4 -2
- mindspore/nn/probability/bnn_layers/conv_variational.py +13 -13
- mindspore/nn/probability/bnn_layers/dense_variational.py +12 -12
- mindspore/nn/probability/bnn_layers/layer_distribution.py +9 -8
- mindspore/nn/probability/distribution/_utils/custom_ops.py +19 -3
- mindspore/nn/probability/distribution/_utils/utils.py +1 -1
- mindspore/nn/probability/distribution/bernoulli.py +9 -9
- mindspore/nn/probability/distribution/beta.py +8 -8
- mindspore/nn/probability/distribution/categorical.py +23 -15
- mindspore/nn/probability/distribution/cauchy.py +5 -6
- mindspore/nn/probability/distribution/distribution.py +3 -3
- mindspore/nn/probability/distribution/exponential.py +4 -4
- mindspore/nn/probability/distribution/gamma.py +10 -10
- mindspore/nn/probability/distribution/geometric.py +8 -8
- mindspore/nn/probability/distribution/gumbel.py +8 -9
- mindspore/nn/probability/distribution/half_normal.py +5 -5
- mindspore/nn/probability/distribution/laplace.py +5 -5
- mindspore/nn/probability/distribution/log_normal.py +12 -11
- mindspore/nn/probability/distribution/logistic.py +8 -8
- mindspore/nn/probability/distribution/normal.py +6 -5
- mindspore/nn/probability/distribution/poisson.py +10 -11
- mindspore/nn/probability/distribution/student_t.py +8 -9
- mindspore/nn/probability/distribution/transformed_distribution.py +5 -5
- mindspore/nn/probability/distribution/uniform.py +11 -11
- mindspore/nn/reinforcement/tensor_array.py +2 -2
- mindspore/nn/sparse/sparse.py +9 -9
- mindspore/nn/wrap/cell_wrapper.py +188 -63
- mindspore/nn/wrap/grad_reducer.py +21 -12
- mindspore/nn/wrap/loss_scale.py +136 -49
- mindspore/numpy/__init__.py +4 -4
- mindspore/numpy/array_creations.py +55 -56
- mindspore/numpy/array_ops.py +134 -35
- mindspore/numpy/logic_ops.py +66 -20
- mindspore/numpy/math_ops.py +142 -139
- mindspore/numpy/utils_const.py +2 -2
- mindspore/offline_debug/convert_async.py +2 -2
- mindspore/ops/_grad_experimental/__init__.py +7 -5
- mindspore/ops/_grad_experimental/grad_array_ops.py +231 -348
- mindspore/ops/{_grad → _grad_experimental}/grad_base.py +1 -33
- mindspore/ops/{_grad → _grad_experimental}/grad_comm_ops.py +25 -13
- mindspore/ops/{_grad/__init__.py → _grad_experimental/grad_debug_ops.py} +15 -7
- mindspore/ops/{_grad → _grad_experimental}/grad_implementations.py +17 -11
- mindspore/ops/_grad_experimental/grad_inner_ops.py +33 -52
- mindspore/ops/_grad_experimental/grad_math_ops.py +151 -1224
- mindspore/ops/_grad_experimental/grad_nn_ops.py +141 -414
- mindspore/ops/{_grad → _grad_experimental}/grad_quant_ops.py +10 -6
- mindspore/ops/_grad_experimental/grad_sparse.py +317 -2
- mindspore/ops/_grad_experimental/grad_sparse_ops.py +3 -13
- mindspore/ops/{_grad → _grad_experimental}/taylor_rule.py +1 -1
- mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/flash_attention/__init__.py +0 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/attention.py +406 -0
- mindspore/{_extends/graph_kernel/expanders/complex/__init__.py → ops/_op_impl/_custom_op/flash_attention/constants.py} +27 -8
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_bwd.py +467 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_fwd.py +563 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_impl.py +193 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/tik_ops_utils.py +435 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/__init__.py +0 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/sparse_tiling.py +45 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/strategy.py +67 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/wukong_tiling.py +62 -0
- mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_left_impl.py +2 -2
- mindspore/ops/_op_impl/aicpu/__init__.py +41 -1
- mindspore/ops/_op_impl/aicpu/adaptive_max_pool_2d.py +37 -0
- mindspore/ops/_op_impl/aicpu/bias_add_grad.py +0 -1
- mindspore/ops/_op_impl/aicpu/cast.py +52 -0
- mindspore/ops/_op_impl/aicpu/coalesce.py +2 -0
- mindspore/ops/_op_impl/aicpu/col2im.py +3 -1
- mindspore/ops/_op_impl/aicpu/count_nonzero.py +43 -0
- mindspore/ops/_op_impl/aicpu/dropout_genmask.py +6 -0
- mindspore/ops/_op_impl/aicpu/eps.py +32 -0
- mindspore/ops/_op_impl/aicpu/eye.py +4 -4
- mindspore/ops/_op_impl/aicpu/fft_with_size.py +6 -0
- mindspore/ops/_op_impl/aicpu/fill_diagonal.py +5 -0
- mindspore/ops/_op_impl/aicpu/gamma.py +2 -2
- mindspore/ops/_op_impl/aicpu/im2col.py +3 -5
- mindspore/ops/_op_impl/aicpu/lgamma.py +1 -0
- mindspore/ops/_op_impl/aicpu/log_uniform_candidate_sampler.py +6 -3
- mindspore/ops/_op_impl/aicpu/lu.py +39 -0
- mindspore/ops/_op_impl/aicpu/lu_unpack_grad.py +0 -1
- mindspore/ops/_op_impl/aicpu/masked_scatter.py +1 -0
- mindspore/ops/_op_impl/aicpu/masked_select_grad.py +3 -0
- mindspore/ops/_op_impl/aicpu/matrix_band_part.py +59 -0
- mindspore/ops/_op_impl/aicpu/matrix_power.py +6 -1
- mindspore/ops/_op_impl/aicpu/median.py +1 -0
- mindspore/ops/_op_impl/aicpu/multinomial.py +9 -9
- mindspore/ops/_op_impl/aicpu/not_equal.py +0 -5
- mindspore/ops/_op_impl/aicpu/pad_v3.py +3 -1
- mindspore/ops/_op_impl/aicpu/pad_v3_grad.py +2 -0
- mindspore/ops/_op_impl/aicpu/parameterized_truncated_normal.py +15 -7
- mindspore/ops/_op_impl/aicpu/random_categorical.py +39 -19
- mindspore/ops/_op_impl/aicpu/random_choice_with_mask.py +5 -2
- mindspore/ops/_op_impl/aicpu/random_poisson.py +103 -52
- mindspore/ops/_op_impl/aicpu/random_shuffle.py +17 -15
- mindspore/ops/_op_impl/aicpu/resize_bilinear_grad.py +0 -1
- mindspore/ops/_op_impl/aicpu/resize_nearest_neighbor_v2.py +0 -6
- mindspore/ops/_op_impl/aicpu/resize_nearest_neighbor_v2_grad.py +0 -7
- mindspore/ops/_op_impl/aicpu/scatter_nd.py +2 -0
- mindspore/ops/_op_impl/aicpu/sequence_concat.py +40 -0
- mindspore/ops/_op_impl/aicpu/sequence_stack.py +40 -0
- mindspore/ops/_op_impl/aicpu/{sparseaddmm.py → sparse_addmm.py} +2 -2
- mindspore/ops/_op_impl/aicpu/{sparsesparsemaximum.py → sparse_sparse_maximum.py} +4 -4
- mindspore/ops/_op_impl/aicpu/standard_laplace.py +5 -4
- mindspore/ops/_op_impl/aicpu/standard_normal.py +5 -4
- mindspore/ops/_op_impl/aicpu/truncated_normal.py +9 -7
- mindspore/ops/_op_impl/aicpu/uniform.py +5 -3
- mindspore/ops/_op_impl/aicpu/uniform_candidate_sampler.py +8 -4
- mindspore/ops/_op_impl/aicpu/uniform_int.py +5 -5
- mindspore/ops/_op_impl/aicpu/uniform_real.py +4 -4
- mindspore/ops/_op_impl/aicpu/upsample_nearest_3d.py +14 -6
- mindspore/ops/_op_impl/aicpu/upsample_nearest_3d_grad.py +22 -8
- mindspore/ops/_op_impl/aicpu/upsample_trilinear_3d.py +11 -6
- mindspore/ops/_op_impl/aicpu/upsample_trilinear_3d_grad.py +21 -10
- mindspore/ops/_op_impl/tbe/__init__.py +6 -4
- mindspore/ops/_op_impl/tbe/atomic_addr_clean.py +1 -1
- mindspore/ops/_op_impl/tbe/avg_pool.py +2 -2
- mindspore/ops/_op_impl/tbe/avg_pool_3d.py +3 -3
- mindspore/ops/_op_impl/tbe/avg_pool_3d_grad.py +4 -4
- mindspore/ops/_op_impl/tbe/avg_pool_ds.py +2 -2
- mindspore/ops/_op_impl/tbe/avg_pool_grad.py +3 -3
- mindspore/ops/_op_impl/tbe/avg_pool_grad_vm.py +3 -3
- mindspore/ops/_op_impl/tbe/batch_to_space.py +1 -1
- mindspore/ops/_op_impl/tbe/batch_to_space_nd.py +2 -2
- mindspore/ops/_op_impl/tbe/bn_infer.py +2 -2
- mindspore/ops/_op_impl/tbe/bn_infer_ds.py +3 -2
- mindspore/ops/_op_impl/tbe/broadcast_to.py +1 -1
- mindspore/ops/_op_impl/tbe/depthwise_conv2d.py +3 -3
- mindspore/ops/_op_impl/tbe/expand_dims.py +1 -1
- mindspore/ops/_op_impl/tbe/gather_v2.py +56 -0
- mindspore/ops/_op_impl/tbe/im2col.py +4 -4
- mindspore/ops/_op_impl/tbe/inplace_index_add.py +7 -3
- mindspore/ops/_op_impl/tbe/mem_set.py +38 -0
- mindspore/ops/_op_impl/tbe/scatter_nd_add.py +3 -0
- mindspore/ops/_op_impl/tbe/scatter_nd_d.py +1 -1
- mindspore/ops/_op_impl/tbe/space_to_batch.py +1 -1
- mindspore/ops/_op_impl/tbe/space_to_batch_nd.py +2 -2
- mindspore/ops/_op_impl/tbe/trans_data_ds.py +2 -0
- mindspore/ops/_primitive_cache.py +1 -1
- mindspore/ops/_tracefunc.py +241 -0
- mindspore/ops/_utils/utils.py +10 -2
- mindspore/ops/_vmap/vmap_array_ops.py +5 -3
- mindspore/ops/_vmap/vmap_base.py +5 -4
- mindspore/ops/_vmap/vmap_convolution_ops.py +1 -1
- mindspore/ops/_vmap/vmap_grad_math_ops.py +6 -4
- mindspore/ops/_vmap/vmap_grad_nn_ops.py +11 -6
- mindspore/ops/_vmap/vmap_math_ops.py +5 -2
- mindspore/ops/_vmap/vmap_nn_ops.py +135 -11
- mindspore/ops/arg_dtype_cast.py +54 -0
- mindspore/ops/composite/__init__.py +7 -5
- mindspore/ops/composite/base.py +78 -34
- mindspore/ops/composite/math_ops.py +5 -695
- mindspore/ops/composite/multitype_ops/_compile_utils.py +403 -97
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +28 -22
- mindspore/ops/composite/multitype_ops/add_impl.py +69 -7
- mindspore/ops/composite/multitype_ops/bitwise_and_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/bitwise_or_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/bitwise_xor_impl.py +2 -0
- mindspore/ops/composite/multitype_ops/div_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/floordiv_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/getitem_impl.py +48 -10
- mindspore/ops/composite/multitype_ops/greater_equal_impl.py +2 -0
- mindspore/ops/composite/multitype_ops/greater_impl.py +2 -0
- mindspore/ops/composite/multitype_ops/left_shift_impl.py +2 -0
- mindspore/ops/composite/multitype_ops/less_equal_impl.py +2 -0
- mindspore/ops/composite/multitype_ops/less_impl.py +2 -0
- mindspore/ops/composite/multitype_ops/logic_not_impl.py +2 -2
- mindspore/ops/composite/multitype_ops/mod_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/mul_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/negative_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/not_in_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/ones_like_impl.py +6 -0
- mindspore/ops/composite/multitype_ops/pow_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/right_shift_impl.py +2 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +10 -7
- mindspore/ops/composite/multitype_ops/sub_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/uadd_impl.py +2 -0
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +9 -0
- mindspore/ops/deprecated.py +304 -0
- mindspore/ops/function/__init__.py +41 -4
- mindspore/ops/function/array_func.py +1108 -467
- mindspore/ops/function/clip_func.py +94 -27
- mindspore/ops/function/debug_func.py +3 -1
- mindspore/ops/function/grad/grad_func.py +82 -73
- mindspore/ops/function/image_func.py +28 -12
- mindspore/ops/function/linalg_func.py +135 -39
- mindspore/ops/function/math_func.py +3779 -894
- mindspore/ops/function/nn_func.py +1584 -657
- mindspore/ops/function/parameter_func.py +13 -3
- mindspore/ops/function/random_func.py +247 -153
- mindspore/ops/function/sparse_func.py +14 -11
- mindspore/ops/function/sparse_unary_func.py +173 -47
- mindspore/ops/function/spectral_func.py +8 -4
- mindspore/ops/function/vmap_func.py +8 -7
- mindspore/ops/functional.py +47 -16
- mindspore/ops/op_info_register.py +346 -86
- mindspore/ops/operations/__init__.py +38 -22
- mindspore/ops/operations/_grad_ops.py +145 -149
- mindspore/ops/operations/_inner_ops.py +298 -56
- mindspore/ops/operations/_ms_kernel.py +3 -3
- mindspore/ops/operations/_quant_ops.py +24 -28
- mindspore/ops/operations/_rl_inner_ops.py +9 -7
- mindspore/ops/operations/_scalar_ops.py +115 -0
- mindspore/ops/operations/_sequence_ops.py +148 -10
- mindspore/ops/operations/_tensor_array.py +1 -1
- mindspore/ops/operations/_thor_ops.py +2 -2
- mindspore/ops/operations/array_ops.py +1239 -561
- mindspore/ops/operations/comm_ops.py +166 -90
- mindspore/ops/operations/control_ops.py +3 -3
- mindspore/ops/operations/custom_ops.py +124 -102
- mindspore/ops/operations/debug_ops.py +24 -11
- mindspore/ops/operations/image_ops.py +86 -71
- mindspore/ops/operations/inner_ops.py +18 -13
- mindspore/ops/operations/linalg_ops.py +30 -11
- mindspore/ops/operations/math_ops.py +1730 -435
- mindspore/ops/operations/nn_ops.py +1953 -943
- mindspore/ops/operations/other_ops.py +65 -43
- mindspore/ops/operations/random_ops.py +258 -98
- mindspore/ops/operations/rl_ops.py +4 -36
- mindspore/ops/operations/sparse_ops.py +38 -33
- mindspore/ops/operations/spectral_ops.py +8 -4
- mindspore/ops/primitive.py +66 -44
- mindspore/ops/signature.py +5 -5
- mindspore/parallel/_auto_parallel_context.py +80 -19
- mindspore/parallel/_cost_model_context.py +42 -0
- mindspore/parallel/_offload_context.py +162 -72
- mindspore/parallel/_parallel_serialization.py +2 -2
- mindspore/parallel/_ps_context.py +16 -4
- mindspore/parallel/_recovery_context.py +2 -1
- mindspore/parallel/_tensor.py +15 -13
- mindspore/parallel/_transformer/layers.py +8 -6
- mindspore/parallel/_transformer/loss.py +1 -0
- mindspore/parallel/_transformer/moe.py +7 -7
- mindspore/parallel/_transformer/op_parallel_config.py +12 -1
- mindspore/parallel/_transformer/transformer.py +34 -14
- mindspore/parallel/_utils.py +36 -14
- mindspore/parallel/algo_parameter_config.py +114 -20
- mindspore/parallel/checkpoint_transform.py +16 -18
- mindspore/parallel/shard.py +16 -13
- mindspore/profiler/__init__.py +1 -1
- mindspore/profiler/common/struct_type.py +3 -3
- mindspore/profiler/common/util.py +3 -2
- mindspore/profiler/envprofiling.py +11 -4
- mindspore/profiler/parser/aicpu_data_parser.py +5 -3
- mindspore/profiler/parser/ascend_flops_generator.py +94 -0
- mindspore/profiler/parser/ascend_fpbp_generator.py +76 -0
- mindspore/profiler/parser/ascend_hccl_generator.py +288 -0
- mindspore/profiler/parser/ascend_msprof_exporter.py +213 -0
- mindspore/profiler/parser/ascend_msprof_generator.py +199 -0
- mindspore/profiler/parser/ascend_op_generator.py +276 -0
- mindspore/profiler/parser/ascend_steptrace_generator.py +94 -0
- mindspore/profiler/parser/ascend_timeline_generator.py +110 -54
- mindspore/profiler/parser/base_timeline_generator.py +11 -7
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +45 -46
- mindspore/profiler/parser/flops_parser.py +15 -11
- mindspore/profiler/parser/framework_parser.py +92 -73
- mindspore/profiler/parser/hccl_parser.py +16 -12
- mindspore/profiler/parser/integrator.py +22 -11
- mindspore/profiler/parser/memory_usage_parser.py +36 -11
- mindspore/profiler/parser/minddata_analyzer.py +12 -14
- mindspore/profiler/parser/minddata_pipeline_parser.py +1 -1
- mindspore/profiler/parser/msadvisor_parser.py +8 -4
- mindspore/profiler/parser/op_intermediate_parser.py +5 -2
- mindspore/profiler/parser/optime_parser.py +1 -1
- mindspore/profiler/parser/profiler_info.py +4 -5
- mindspore/profiler/parser/step_trace_parser.py +11 -14
- mindspore/profiler/profiling.py +678 -377
- mindspore/rewrite/api/node.py +211 -54
- mindspore/rewrite/api/node_type.py +5 -0
- mindspore/rewrite/api/pattern_engine.py +22 -23
- mindspore/rewrite/api/scoped_value.py +20 -17
- mindspore/rewrite/api/symbol_tree.py +252 -106
- mindspore/rewrite/api/tree_node_helper.py +3 -0
- mindspore/rewrite/ast_helpers/__init__.py +2 -1
- mindspore/rewrite/ast_helpers/ast_finder.py +129 -0
- mindspore/rewrite/ast_helpers/ast_modifier.py +116 -104
- mindspore/rewrite/ast_transformers/flatten_recursive_stmt.py +97 -46
- mindspore/rewrite/common/rewrite_elog.py +5 -1
- mindspore/rewrite/namer.py +51 -51
- mindspore/rewrite/namespace.py +14 -5
- mindspore/{ops/bprop_mindir → rewrite/node}/__init__.py +9 -4
- mindspore/rewrite/node/call_function.py +79 -0
- mindspore/rewrite/node/cell_container.py +135 -0
- mindspore/rewrite/node/control_flow.py +88 -0
- mindspore/rewrite/{node.py → node/node.py} +313 -247
- mindspore/rewrite/node/node_manager.py +254 -0
- mindspore/rewrite/node/node_topological_manager.py +243 -0
- mindspore/rewrite/parsers/arguments_parser.py +22 -21
- mindspore/rewrite/parsers/assign_parser.py +225 -239
- mindspore/rewrite/parsers/attribute_parser.py +9 -7
- mindspore/rewrite/parsers/class_def_parser.py +179 -218
- mindspore/rewrite/parsers/constant_parser.py +9 -6
- mindspore/rewrite/parsers/container_parser.py +9 -7
- mindspore/rewrite/parsers/for_parser.py +36 -15
- mindspore/rewrite/parsers/function_def_parser.py +23 -20
- mindspore/rewrite/parsers/if_parser.py +28 -24
- mindspore/rewrite/parsers/module_parser.py +202 -25
- mindspore/rewrite/{parser.py → parsers/parser.py} +4 -2
- mindspore/rewrite/{parser_register.py → parsers/parser_register.py} +1 -1
- mindspore/rewrite/parsers/return_parser.py +6 -6
- mindspore/rewrite/sparsify/sparse_transformer.py +12 -3
- mindspore/rewrite/sparsify/sparsify.py +4 -1
- mindspore/rewrite/sparsify/utils.py +11 -5
- mindspore/rewrite/symbol_tree.py +577 -732
- mindspore/rewrite/symbol_tree_builder.py +9 -175
- mindspore/rewrite/symbol_tree_dumper.py +2 -2
- mindspore/run_check/_check_version.py +46 -39
- mindspore/run_check/run_check.py +3 -2
- mindspore/{scipy/sparse → safeguard}/__init__.py +4 -5
- mindspore/safeguard/rewrite_obfuscation.py +517 -0
- mindspore/scipy/__init__.py +1 -1
- mindspore/scipy/linalg.py +67 -61
- mindspore/scipy/ops.py +5 -41
- mindspore/scipy/ops_grad.py +3 -2
- mindspore/scipy/ops_wrapper.py +5 -5
- mindspore/scipy/optimize/line_search.py +8 -8
- mindspore/scipy/optimize/linear_sum_assignment.py +4 -4
- mindspore/scipy/optimize/minimize.py +16 -12
- mindspore/scipy/utils.py +1 -52
- mindspore/scipy/utils_const.py +4 -4
- mindspore/train/__init__.py +4 -4
- mindspore/train/_utils.py +13 -5
- mindspore/train/amp.py +410 -148
- mindspore/train/anf_ir_pb2.py +16 -4
- mindspore/train/callback/_backup_and_restore.py +8 -11
- mindspore/train/callback/_callback.py +80 -3
- mindspore/train/callback/_checkpoint.py +82 -51
- mindspore/train/callback/_early_stop.py +12 -15
- mindspore/train/callback/_history.py +1 -1
- mindspore/train/callback/_lambda_callback.py +13 -13
- mindspore/train/callback/_landscape.py +21 -17
- mindspore/train/callback/_loss_monitor.py +9 -10
- mindspore/train/callback/_on_request_exit.py +16 -33
- mindspore/train/callback/_reduce_lr_on_plateau.py +21 -24
- mindspore/train/callback/_summary_collector.py +44 -30
- mindspore/train/callback/_time_monitor.py +62 -12
- mindspore/train/data_sink.py +10 -16
- mindspore/train/dataset_helper.py +154 -86
- mindspore/train/loss_scale_manager.py +14 -9
- mindspore/train/metrics/__init__.py +10 -2
- mindspore/train/metrics/accuracy.py +1 -1
- mindspore/train/metrics/auc.py +1 -1
- mindspore/train/metrics/bleu_score.py +2 -2
- mindspore/train/metrics/confusion_matrix.py +14 -14
- mindspore/train/metrics/cosine_similarity.py +3 -3
- mindspore/train/metrics/dice.py +1 -1
- mindspore/train/metrics/fbeta.py +1 -1
- mindspore/train/metrics/hausdorff_distance.py +8 -6
- mindspore/train/metrics/mean_surface_distance.py +5 -4
- mindspore/train/metrics/metric.py +49 -17
- mindspore/train/metrics/occlusion_sensitivity.py +4 -4
- mindspore/train/metrics/perplexity.py +1 -1
- mindspore/train/metrics/precision.py +2 -2
- mindspore/train/metrics/recall.py +2 -3
- mindspore/train/metrics/roc.py +7 -7
- mindspore/train/metrics/root_mean_square_surface_distance.py +5 -4
- mindspore/train/metrics/topk.py +7 -4
- mindspore/train/mind_ir_pb2.py +193 -48
- mindspore/train/model.py +377 -133
- mindspore/train/serialization.py +697 -245
- mindspore/train/summary/_summary_adapter.py +5 -2
- mindspore/train/summary/_writer_pool.py +4 -3
- mindspore/train/summary/summary_record.py +25 -23
- mindspore/train/train_thor/convert_utils.py +39 -23
- mindspore/train/train_thor/dataset_helper.py +4 -3
- mindspore/train/train_thor/model_thor.py +8 -8
- mindspore/version.py +1 -1
- {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/METADATA +7 -8
- {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/RECORD +633 -804
- {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/entry_points.txt +0 -1
- mindspore/_akg/akg/tvm/contrib/debugger/__init__.py +0 -16
- mindspore/_akg/akg/tvm/contrib/debugger/debug_result.py +0 -274
- mindspore/_akg/akg/tvm/contrib/debugger/debug_runtime.py +0 -259
- mindspore/_akg/akg/tvm/contrib/peak.py +0 -341
- mindspore/_akg/akg/tvm/contrib/rpc.py +0 -25
- mindspore/_akg/akg/tvm/contrib/xcode.py +0 -257
- mindspore/_akg/akg/tvm/exec/__init__.py +0 -17
- mindspore/_akg/akg/tvm/exec/autotvm_log_editor.py +0 -60
- mindspore/_akg/akg/tvm/exec/measure_peak.py +0 -48
- mindspore/_akg/akg/tvm/exec/query_rpc_tracker.py +0 -48
- mindspore/_akg/akg/tvm/exec/rpc_proxy.py +0 -98
- mindspore/_akg/akg/tvm/exec/rpc_server.py +0 -88
- mindspore/_akg/akg/tvm/exec/rpc_tracker.py +0 -62
- mindspore/_akg/akg/tvm/rpc/__init__.py +0 -29
- mindspore/_akg/akg/tvm/rpc/base.py +0 -182
- mindspore/_akg/akg/tvm/rpc/client.py +0 -436
- mindspore/_akg/akg/tvm/rpc/proxy.py +0 -595
- mindspore/_akg/akg/tvm/rpc/server.py +0 -413
- mindspore/_akg/akg/tvm/rpc/tornado_util.py +0 -121
- mindspore/_akg/akg/tvm/rpc/tracker.py +0 -431
- mindspore/_extends/graph_kernel/expander.py +0 -80
- mindspore/_extends/graph_kernel/expanders/__init__.py +0 -57
- mindspore/_extends/graph_kernel/expanders/_utils.py +0 -269
- mindspore/_extends/graph_kernel/expanders/addn.py +0 -33
- mindspore/_extends/graph_kernel/expanders/batchnorm.py +0 -152
- mindspore/_extends/graph_kernel/expanders/batchnorm_grad.py +0 -105
- mindspore/_extends/graph_kernel/expanders/bias_add_grad.py +0 -49
- mindspore/_extends/graph_kernel/expanders/clip_by_norm_no_div_sum.py +0 -33
- mindspore/_extends/graph_kernel/expanders/complex/abs.py +0 -30
- mindspore/_extends/graph_kernel/expanders/complex/add.py +0 -44
- mindspore/_extends/graph_kernel/expanders/complex/div.py +0 -62
- mindspore/_extends/graph_kernel/expanders/complex/mul.py +0 -52
- mindspore/_extends/graph_kernel/expanders/complex/real_div.py +0 -62
- mindspore/_extends/graph_kernel/expanders/complex/sub.py +0 -45
- mindspore/_extends/graph_kernel/expanders/conv2d.py +0 -200
- mindspore/_extends/graph_kernel/expanders/dropout_grad.py +0 -30
- mindspore/_extends/graph_kernel/expanders/equal_count.py +0 -50
- mindspore/_extends/graph_kernel/expanders/erfc.py +0 -35
- mindspore/_extends/graph_kernel/expanders/expand_dims.py +0 -50
- mindspore/_extends/graph_kernel/expanders/fused_adam.py +0 -44
- mindspore/_extends/graph_kernel/expanders/fused_adam_weight_decay.py +0 -47
- mindspore/_extends/graph_kernel/expanders/fused_mul_add.py +0 -28
- mindspore/_extends/graph_kernel/expanders/gather.py +0 -43
- mindspore/_extends/graph_kernel/expanders/gelu_grad.py +0 -70
- mindspore/_extends/graph_kernel/expanders/gkdropout.py +0 -40
- mindspore/_extends/graph_kernel/expanders/identity.py +0 -25
- mindspore/_extends/graph_kernel/expanders/layernorm.py +0 -93
- mindspore/_extends/graph_kernel/expanders/layernorm_grad.py +0 -113
- mindspore/_extends/graph_kernel/expanders/logsoftmax.py +0 -46
- mindspore/_extends/graph_kernel/expanders/logsoftmax_grad.py +0 -36
- mindspore/_extends/graph_kernel/expanders/matmul.py +0 -80
- mindspore/_extends/graph_kernel/expanders/maximum_grad.py +0 -59
- mindspore/_extends/graph_kernel/expanders/minimum_grad.py +0 -80
- mindspore/_extends/graph_kernel/expanders/oneslike.py +0 -26
- mindspore/_extends/graph_kernel/expanders/reduce_mean.py +0 -43
- mindspore/_extends/graph_kernel/expanders/relu_grad.py +0 -32
- mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits.py +0 -41
- mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits_grad.py +0 -35
- mindspore/_extends/graph_kernel/expanders/sigmoid_grad.py +0 -31
- mindspore/_extends/graph_kernel/expanders/slice.py +0 -35
- mindspore/_extends/graph_kernel/expanders/softmax_cross_entropy_with_logits.py +0 -42
- mindspore/_extends/graph_kernel/expanders/softmax_grad_ext.py +0 -41
- mindspore/_extends/graph_kernel/expanders/softsign.py +0 -28
- mindspore/_extends/graph_kernel/expanders/sqrt_grad.py +0 -29
- mindspore/_extends/graph_kernel/expanders/square_sum_all.py +0 -44
- mindspore/_extends/graph_kernel/expanders/square_sum_v1.py +0 -37
- mindspore/_extends/graph_kernel/expanders/squared_difference.py +0 -43
- mindspore/_extends/graph_kernel/expanders/tanh_grad.py +0 -31
- mindspore/_extends/graph_kernel/expanders/tile.py +0 -54
- mindspore/_extends/graph_kernel/model/op_infer.py +0 -506
- mindspore/_extends/parse/jit_fallback_modules.py +0 -51
- mindspore/dataset/datapreprocess/preprocess_imagenet_validate_dataset.py +0 -54
- mindspore/dataset/engine/graphdata.py +0 -1586
- mindspore/include/api/net.h +0 -142
- mindspore/ops/_grad/grad_array_ops.py +0 -1347
- mindspore/ops/_grad/grad_clip_ops.py +0 -84
- mindspore/ops/_grad/grad_debug_ops.py +0 -68
- mindspore/ops/_grad/grad_inner_ops.py +0 -235
- mindspore/ops/_grad/grad_math_ops.py +0 -1684
- mindspore/ops/_grad/grad_nn_ops.py +0 -1529
- mindspore/ops/_grad/grad_other_ops.py +0 -89
- mindspore/ops/_grad/grad_sequence_ops.py +0 -296
- mindspore/ops/_grad/grad_sparse.py +0 -323
- mindspore/ops/_grad_experimental/grad_image_ops.py +0 -249
- mindspore/ops/_grad_experimental/grad_linalg_ops.py +0 -195
- mindspore/ops/_grad_experimental/grad_scalar_ops.py +0 -112
- mindspore/ops/bprop_mindir/AdaptiveAvgPool2D_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/AdaptiveMaxPool2D_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ApproximateEqual_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/Argmax_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/Argmin_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/AssignSub_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/Assign_bprop.mindir +0 -17
- mindspore/ops/bprop_mindir/AvgPool3D_bprop.mindir +0 -150
- mindspore/ops/bprop_mindir/AvgPool_bprop.mindir +0 -66
- mindspore/ops/bprop_mindir/BCEWithLogitsLoss_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/BatchNormGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/BatchToSpaceND_bprop.mindir +0 -28
- mindspore/ops/bprop_mindir/BiasAddGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/BinaryCrossEntropy_bprop.mindir +0 -33
- mindspore/ops/bprop_mindir/BroadcastTo_bprop.mindir +0 -306
- mindspore/ops/bprop_mindir/Broadcast_bprop.mindir +0 -13
- mindspore/ops/bprop_mindir/CTCLoss_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Concat_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Conv2DBackpropFilter_bprop.mindir +0 -240
- mindspore/ops/bprop_mindir/Conv2DBackpropInput_bprop.mindir +0 -247
- mindspore/ops/bprop_mindir/Conv2DTranspose_bprop.mindir +0 -247
- mindspore/ops/bprop_mindir/Conv3DTranspose_bprop.mindir +0 -315
- mindspore/ops/bprop_mindir/Conv3D_bprop.mindir +0 -278
- mindspore/ops/bprop_mindir/DType_bprop.mindir +0 -14
- mindspore/ops/bprop_mindir/DeformableOffsets_bprop.mindir +0 -58
- mindspore/ops/bprop_mindir/Depend_bprop.mindir +0 -13
- mindspore/ops/bprop_mindir/DepthToSpace_bprop.mindir +0 -23
- mindspore/ops/bprop_mindir/DepthwiseConv2dNative_bprop.mindir +0 -138
- mindspore/ops/bprop_mindir/DiagPart_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/Dropout2D_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Dropout3D_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DropoutDoMask_bprop.mindir +0 -25
- mindspore/ops/bprop_mindir/DropoutGenMask_bprop.mindir +0 -18
- mindspore/ops/bprop_mindir/DropoutGrad_bprop.mindir +0 -27
- mindspore/ops/bprop_mindir/Dropout_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DynamicGRUV2_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DynamicRNN_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DynamicShape_bprop.mindir +0 -14
- mindspore/ops/bprop_mindir/Elu_bprop.mindir +0 -16
- mindspore/ops/bprop_mindir/EmbeddingLookup_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Equal_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/ExpandDims_bprop.mindir +0 -58
- mindspore/ops/bprop_mindir/FastGeLU_bprop.mindir +0 -16
- mindspore/ops/bprop_mindir/Flatten_bprop.mindir +0 -54
- mindspore/ops/bprop_mindir/FloorDiv_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/GatherD_bprop.mindir +0 -26
- mindspore/ops/bprop_mindir/GatherNd_bprop.mindir +0 -57
- mindspore/ops/bprop_mindir/Gather_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/GreaterEqual_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/Greater_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/HSigmoid_bprop.mindir +0 -16
- mindspore/ops/bprop_mindir/HSwish_bprop.mindir +0 -16
- mindspore/ops/bprop_mindir/IOU_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/InstanceNorm_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/IsFinite_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/IsInf_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/IsNan_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/KLDivLoss_bprop.mindir +0 -126
- mindspore/ops/bprop_mindir/L2Loss_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/L2Normalize_bprop.mindir +0 -30
- mindspore/ops/bprop_mindir/LRN_bprop.mindir +0 -43
- mindspore/ops/bprop_mindir/LayerNormGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/LessEqual_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/Less_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/LinSpace_bprop.mindir +0 -23
- mindspore/ops/bprop_mindir/Load_bprop.mindir +0 -13
- mindspore/ops/bprop_mindir/LogSoftmax_bprop.mindir +0 -23
- mindspore/ops/bprop_mindir/LogicalAnd_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/LogicalNot_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/MaskedSelect_bprop.mindir +0 -21
- mindspore/ops/bprop_mindir/MaxPool3DGradGrad_bprop.mindir +0 -74
- mindspore/ops/bprop_mindir/MaxPool3DGrad_bprop.mindir +0 -74
- mindspore/ops/bprop_mindir/MaxPool3D_bprop.mindir +0 -75
- mindspore/ops/bprop_mindir/MaxPoolGradGrad_bprop.mindir +0 -65
- mindspore/ops/bprop_mindir/MaxPoolWithArgmax_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Maximum_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Minimum_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/MirrorPad_bprop.mindir +0 -27
- mindspore/ops/bprop_mindir/Mish_bprop.mindir +0 -35
- mindspore/ops/bprop_mindir/MulNoNan_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/NLLLoss_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/NonZero_bprop.mindir +0 -14
- mindspore/ops/bprop_mindir/NotEqual_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/OneHot_bprop.mindir +0 -26
- mindspore/ops/bprop_mindir/OnesLike_bprop.mindir +0 -14
- mindspore/ops/bprop_mindir/PReLU_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Pad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Padding_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/RNNTLoss_bprop.mindir +0 -29
- mindspore/ops/bprop_mindir/ROIAlign_bprop.mindir +0 -82
- mindspore/ops/bprop_mindir/Range_bprop.mindir +0 -22
- mindspore/ops/bprop_mindir/Rank_bprop.mindir +0 -14
- mindspore/ops/bprop_mindir/ReLU6_bprop.mindir +0 -16
- mindspore/ops/bprop_mindir/ReLUV2_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ReduceAll_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/ReduceAny_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/ReluGrad_bprop.mindir +0 -20
- mindspore/ops/bprop_mindir/Reshape_bprop.mindir +0 -60
- mindspore/ops/bprop_mindir/ResizeBilinear_bprop.mindir +0 -29
- mindspore/ops/bprop_mindir/ResizeNearestNeighbor_bprop.mindir +0 -89
- mindspore/ops/bprop_mindir/ReverseSequence_bprop.mindir +0 -52
- mindspore/ops/bprop_mindir/ReverseV2_bprop.mindir +0 -22
- mindspore/ops/bprop_mindir/Round_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/ScatterMax_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ScatterMin_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ScatterNdUpdate_bprop.mindir +0 -22
- mindspore/ops/bprop_mindir/ScatterNd_bprop.mindir +0 -24
- mindspore/ops/bprop_mindir/ScatterNonAliasingAdd_bprop.mindir +0 -22
- mindspore/ops/bprop_mindir/ScatterUpdate_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SeLU_bprop.mindir +0 -21
- mindspore/ops/bprop_mindir/Select_bprop.mindir +0 -31
- mindspore/ops/bprop_mindir/Shape_bprop.mindir +0 -14
- mindspore/ops/bprop_mindir/SigmoidCrossEntropyWithLogits_bprop.mindir +0 -21
- mindspore/ops/bprop_mindir/SigmoidGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Sigmoid_bprop.mindir +0 -16
- mindspore/ops/bprop_mindir/Sign_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/Slice_bprop.mindir +0 -26
- mindspore/ops/bprop_mindir/SmoothL1Loss_bprop.mindir +0 -36
- mindspore/ops/bprop_mindir/SoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Softplus_bprop.mindir +0 -16
- mindspore/ops/bprop_mindir/Softsign_bprop.mindir +0 -33
- mindspore/ops/bprop_mindir/Sort_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SpaceToBatchND_bprop.mindir +0 -28
- mindspore/ops/bprop_mindir/SpaceToDepth_bprop.mindir +0 -23
- mindspore/ops/bprop_mindir/SparseGatherV2_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SparseSoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Split_bprop.mindir +0 -22
- mindspore/ops/bprop_mindir/Squeeze_bprop.mindir +0 -54
- mindspore/ops/bprop_mindir/StridedSliceGrad_bprop.mindir +0 -95
- mindspore/ops/bprop_mindir/StridedSlice_bprop.mindir +0 -98
- mindspore/ops/bprop_mindir/Switch_bprop.mindir +0 -29
- mindspore/ops/bprop_mindir/TanhGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Tanh_bprop.mindir +0 -66
- mindspore/ops/bprop_mindir/TensorScatterAdd_bprop.mindir +0 -22
- mindspore/ops/bprop_mindir/TensorScatterUpdate_bprop.mindir +0 -29
- mindspore/ops/bprop_mindir/TensorShape_bprop.mindir +0 -14
- mindspore/ops/bprop_mindir/Tile_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TopK_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TransShape_bprop.mindir +0 -23
- mindspore/ops/bprop_mindir/TruncateDiv_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir +0 -20
- mindspore/ops/bprop_mindir/Unique_bprop.mindir +0 -16
- mindspore/ops/bprop_mindir/Unstack_bprop.mindir +0 -22
- mindspore/ops/bprop_mindir/UpsampleNearest3D_bprop.mindir +0 -32
- mindspore/ops/bprop_mindir/UpsampleTrilinear3D_bprop.mindir +0 -38
- mindspore/ops/bprop_mindir/ZerosLike_bprop.mindir +0 -15
- mindspore/ops/bprop_mindir/generate_mindir.py +0 -114
- mindspore/rewrite/node_visitor.py +0 -44
- mindspore/rewrite/topological_manager.py +0 -203
- mindspore/scipy/sparse/linalg.py +0 -192
- {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/WHEEL +0 -0
- {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/top_level.txt +0 -0
mindspore/context.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2020-
|
|
1
|
+
# Copyright 2020-2023 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.
|
|
@@ -35,16 +35,21 @@ from mindspore.parallel._ps_context import _set_ps_context, _get_ps_context, _re
|
|
|
35
35
|
_need_reset_device_target_for_ps
|
|
36
36
|
from mindspore.parallel._offload_context import _set_offload_context, _get_offload_context
|
|
37
37
|
|
|
38
|
-
__all__ = ['GRAPH_MODE', 'PYNATIVE_MODE', '
|
|
39
|
-
'
|
|
40
|
-
'get_ps_context', 'reset_ps_context', 'set_offload_context', 'get_offload_context']
|
|
38
|
+
__all__ = ['GRAPH_MODE', 'PYNATIVE_MODE', 'STRICT', 'COMPATIBLE', 'LAX', 'set_context', 'get_context',
|
|
39
|
+
'set_auto_parallel_context', 'get_auto_parallel_context', 'reset_auto_parallel_context', 'ParallelMode',
|
|
40
|
+
'set_ps_context', 'get_ps_context', 'reset_ps_context', 'set_offload_context', 'get_offload_context']
|
|
41
41
|
|
|
42
42
|
GRAPH_MODE = 0
|
|
43
43
|
PYNATIVE_MODE = 1
|
|
44
44
|
_DEVICE_APP_MEMORY_SIZE = 31 # The max memory size of graph plus variable.
|
|
45
|
-
|
|
45
|
+
_RE_PATTERN = r'[1-9][0-9]*(\.)?[0-9]*GB|0\.[0-9]*GB'
|
|
46
46
|
K_CONTEXT = None
|
|
47
47
|
|
|
48
|
+
# Enumerate for the property 'jit_syntax_level'.
|
|
49
|
+
STRICT = 0
|
|
50
|
+
COMPATIBLE = 1
|
|
51
|
+
LAX = 2
|
|
52
|
+
|
|
48
53
|
|
|
49
54
|
def _make_directory(path):
|
|
50
55
|
"""Make directory."""
|
|
@@ -156,7 +161,6 @@ class _Context:
|
|
|
156
161
|
self._context_switches = _ContextSwitchInfo(False)
|
|
157
162
|
self._context_handle = MSContext.get_instance()
|
|
158
163
|
self._support_binary = False
|
|
159
|
-
self.enable_compile_cache = None
|
|
160
164
|
|
|
161
165
|
def __getattribute__(self, attr):
|
|
162
166
|
value = object.__getattribute__(self, attr)
|
|
@@ -201,6 +205,13 @@ class _Context:
|
|
|
201
205
|
f"or context.PYNATIVE_MODE (1), but got {mode}.")
|
|
202
206
|
self.set_param(ms_ctx_param.mode, mode)
|
|
203
207
|
|
|
208
|
+
def set_jit_syntax_level(self, level):
|
|
209
|
+
""""Set the JIT syntax level for graph compiling"""
|
|
210
|
+
if level != STRICT and level != COMPATIBLE and level != LAX:
|
|
211
|
+
raise ValueError(f"For 'context.set_jit_syntax_level', the argument 'level' should be context.STRICT "
|
|
212
|
+
f"or context.LAX, but got {level}.")
|
|
213
|
+
self.set_param(ms_ctx_param.jit_syntax_level, level)
|
|
214
|
+
|
|
204
215
|
def set_memory_optimize_level(self, memory_optimize_level):
|
|
205
216
|
"""
|
|
206
217
|
The memory optimize level, support "O0", "O1".
|
|
@@ -251,32 +262,91 @@ class _Context:
|
|
|
251
262
|
Enable ascend config.
|
|
252
263
|
|
|
253
264
|
Args:
|
|
254
|
-
ascend_config (dict):
|
|
265
|
+
ascend_config (dict):
|
|
255
266
|
- precision_mode (str): "force_fp16", "allow_fp32_to_fp16", "allow_mix_precision",
|
|
256
|
-
"must_keep_origin_dtype", "force_fp32", "
|
|
257
|
-
"
|
|
267
|
+
"must_keep_origin_dtype", "force_fp32", "allow_fp32_to_bf16",
|
|
268
|
+
"allow_mix_precision_fp16" and "allow_mix_precision_bf16".
|
|
269
|
+
- jit_compile (bool): ``False`` and ``True``.
|
|
270
|
+
- atomic_clean_policy (int): ``0`` and ``1``. Default: ``1`` .
|
|
271
|
+
- op_precision_mode (str): config file path.
|
|
272
|
+
- parallel_speed_up_json_path(Union[str, None]): The path to the parallel speed up json file.
|
|
273
|
+
If its value is None or '', it does not take effect. Default None.
|
|
258
274
|
"""
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
275
|
+
ascend_cfg_modes = {
|
|
276
|
+
'precision_mode': ["force_fp16", "allow_fp32_to_fp16", "allow_mix_precision", "must_keep_origin_dtype",
|
|
277
|
+
"force_fp32", "allow_fp32_to_bf16", "allow_mix_precision_fp16",
|
|
278
|
+
"allow_mix_precision_bf16"],
|
|
279
|
+
'jit_compile': [True, False],
|
|
280
|
+
'atomic_clean_policy': [0, 1],
|
|
281
|
+
'matmul_allow_hf32': [True, False],
|
|
282
|
+
'conv_allow_hf32': [True, False],
|
|
283
|
+
'op_precision_mode': (str,),
|
|
284
|
+
'parallel_speed_up_json_path': (str, None)
|
|
285
|
+
}
|
|
286
|
+
ascend_cfg_setters = {
|
|
287
|
+
'precision_mode': self._get_ascend_config_setter('precision_mode'),
|
|
288
|
+
'jit_compile': self._get_ascend_config_setter('jit_compile', lambda v: "1" if v else "0"),
|
|
289
|
+
'atomic_clean_policy': self._get_ascend_config_setter('atomic_clean_policy', str),
|
|
290
|
+
'matmul_allow_hf32': self._get_ascend_config_setter('matmul_allow_hf32', lambda v: "1" if v else "0"),
|
|
291
|
+
'conv_allow_hf32': self._get_ascend_config_setter('conv_allow_hf32', lambda v: "1" if v else "0"),
|
|
292
|
+
'op_precision_mode': self._set_op_precision_mode,
|
|
293
|
+
'parallel_speed_up_json_path': self._set_speedup_config_path
|
|
294
|
+
}
|
|
295
|
+
ascend_cfg_set = tuple(ascend_cfg_modes.keys())
|
|
296
|
+
for ascend_key, ascend_value in ascend_config.items():
|
|
297
|
+
if ascend_key not in ascend_cfg_set:
|
|
267
298
|
raise ValueError(f"For 'context.set_context', the key of argument 'ascend_config' must be one of "
|
|
268
|
-
f"{
|
|
269
|
-
supported_modes =
|
|
270
|
-
if
|
|
299
|
+
f"{ascend_cfg_set}, but got {ascend_key}.")
|
|
300
|
+
supported_modes = ascend_cfg_modes.get(ascend_key)
|
|
301
|
+
if isinstance(supported_modes, list) and ascend_value not in supported_modes:
|
|
271
302
|
raise ValueError(f"For 'ascend_config', the value of argument {ascend_key} must be one of "
|
|
272
|
-
f"{supported_modes}, but got {
|
|
273
|
-
if
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
303
|
+
f"{supported_modes}, but got {ascend_value}.")
|
|
304
|
+
if isinstance(supported_modes, tuple) and not isinstance(ascend_value, supported_modes):
|
|
305
|
+
raise TypeError(f"For 'ascend_config', the type of argument {ascend_key} must be one of "
|
|
306
|
+
f"{supported_modes}, but got {type(ascend_value)}.")
|
|
307
|
+
cfg_setter = ascend_cfg_setters.get(ascend_key)
|
|
308
|
+
cfg_setter(ascend_value)
|
|
309
|
+
|
|
310
|
+
def set_gpu_config(self, gpu_config):
|
|
311
|
+
"""
|
|
312
|
+
Enable gpu config.
|
|
313
|
+
|
|
314
|
+
Args:
|
|
315
|
+
gpu_config (dict):
|
|
316
|
+
|
|
317
|
+
- conv_fprop_algo (str): "normal", "performance" or user specifies conv forward algorithm directly.
|
|
318
|
+
- conv_dgrad_algo (str): "normal", "performance" or user specifies conv data grad algorithm directly.
|
|
319
|
+
- conv_wgrad_algo (str): "normal", "performance" or user specifies conv weight grad algorithm directly.
|
|
320
|
+
- conv_allow_tf32 (bool): ``False`` and ``True``.
|
|
321
|
+
- matmul_allow_tf32 (bool): ``False`` and ``True``.
|
|
322
|
+
"""
|
|
323
|
+
|
|
324
|
+
gpu_cfgs = {'conv_fprop_algo': ["normal", "performance", "implicit_gemm", "precomp_gemm", "gemm", "direct",
|
|
325
|
+
"fft", "fft_tiling", "winograd", "winograd_nonfused"],
|
|
326
|
+
'conv_dgrad_algo': ["normal", "performance", "algo_0", "algo_1", "fft", "fft_tiling", "winograd",
|
|
327
|
+
"winograd_nonfused"],
|
|
328
|
+
'conv_wgrad_algo': ["normal", "performance", "algo_0", "algo_1", "fft", "algo_3", "fft_tiling",
|
|
329
|
+
"winograd_nonfused"],
|
|
330
|
+
'conv_allow_tf32': [True, False],
|
|
331
|
+
'matmul_allow_tf32': [True, False]}
|
|
332
|
+
for gpu_key in gpu_config:
|
|
333
|
+
if gpu_key not in gpu_cfgs:
|
|
334
|
+
raise ValueError(f"For 'context.set_context', the key of argument 'gpu_config' must be one of "
|
|
335
|
+
f"{gpu_cfgs}, but got {gpu_key}.")
|
|
336
|
+
supported_value = gpu_cfgs.get(gpu_key)
|
|
337
|
+
if gpu_config[gpu_key] not in supported_value:
|
|
338
|
+
raise ValueError(f"For 'gpu_config', the value of argument {gpu_key} must be one of "
|
|
339
|
+
f"{supported_value}, but got {gpu_config[gpu_key]}.")
|
|
340
|
+
if gpu_key == 'conv_fprop_algo':
|
|
341
|
+
self.set_param(ms_ctx_param.conv_fprop_algo, gpu_config[gpu_key])
|
|
342
|
+
if gpu_key == 'conv_dgrad_algo':
|
|
343
|
+
self.set_param(ms_ctx_param.conv_dgrad_algo, gpu_config[gpu_key])
|
|
344
|
+
if gpu_key == 'conv_wgrad_algo':
|
|
345
|
+
self.set_param(ms_ctx_param.conv_wgrad_algo, gpu_config[gpu_key])
|
|
346
|
+
if gpu_key == 'conv_allow_tf32':
|
|
347
|
+
self.set_param(ms_ctx_param.conv_allow_tf32, gpu_config[gpu_key])
|
|
348
|
+
if gpu_key == 'matmul_allow_tf32':
|
|
349
|
+
self.set_param(ms_ctx_param.matmul_allow_tf32, gpu_config[gpu_key])
|
|
280
350
|
|
|
281
351
|
def set_backend_policy(self, policy):
|
|
282
352
|
success = self._context_handle.set_backend_policy(policy)
|
|
@@ -312,13 +382,42 @@ class _Context:
|
|
|
312
382
|
if self.enable_debug_runtime and target == "CPU":
|
|
313
383
|
self.set_backend_policy("vm")
|
|
314
384
|
|
|
315
|
-
def
|
|
316
|
-
|
|
385
|
+
def set_aoe_tune_mode(self, tune_mode):
|
|
386
|
+
"""
|
|
387
|
+
Set aoe tune mode, support "online" and "offline".
|
|
388
|
+
|
|
389
|
+
Args:
|
|
390
|
+
tune_mode (str): "online" and "offline".
|
|
391
|
+
"""
|
|
392
|
+
candidate = ["online", "offline"]
|
|
317
393
|
if tune_mode in candidate:
|
|
318
|
-
self.set_param(ms_ctx_param.
|
|
394
|
+
self.set_param(ms_ctx_param.aoe_tune_mode, tune_mode)
|
|
319
395
|
else:
|
|
320
|
-
raise ValueError(f"For 'context.set_context', the argument '
|
|
321
|
-
f"['
|
|
396
|
+
raise ValueError(f"For 'context.set_context', the argument 'aoe_tune_mode' must be in "
|
|
397
|
+
f"['online', 'offline'], but got {tune_mode}.")
|
|
398
|
+
|
|
399
|
+
def set_aoe_config(self, aoe_config):
|
|
400
|
+
"""
|
|
401
|
+
Enable aoe config.
|
|
402
|
+
|
|
403
|
+
Args:
|
|
404
|
+
aoe_config (dict):
|
|
405
|
+
- job_type (str): ``"1"``, ``"2"``. Default: ``"2"`` .
|
|
406
|
+
- ``"1"``: subgraph tuning.
|
|
407
|
+
- ``"2"``: operator tuning.
|
|
408
|
+
"""
|
|
409
|
+
|
|
410
|
+
aoe_cfgs = {'job_type': ["1", "2"]}
|
|
411
|
+
for aoe_config_key in aoe_config:
|
|
412
|
+
if aoe_config_key not in aoe_cfgs:
|
|
413
|
+
raise ValueError(f"For 'context.set_context', the key of argument 'aoe_config' must be one of "
|
|
414
|
+
f"{aoe_cfgs}, but got {aoe_config_key}.")
|
|
415
|
+
supported_value = aoe_cfgs.get(aoe_config_key)
|
|
416
|
+
if aoe_config[aoe_config_key] not in supported_value:
|
|
417
|
+
raise ValueError(f"For 'aoe_config', the value of argument {aoe_config_key} must be one of "
|
|
418
|
+
f"{supported_value}, but got {aoe_config[aoe_config_key]}.")
|
|
419
|
+
if aoe_config_key == 'job_type':
|
|
420
|
+
self.set_param(ms_ctx_param.aoe_job_type, aoe_config[aoe_config_key])
|
|
322
421
|
|
|
323
422
|
def set_device_id(self, device_id):
|
|
324
423
|
if device_id < 0 or device_id > 4095:
|
|
@@ -343,14 +442,14 @@ class _Context:
|
|
|
343
442
|
logger.warning("For 'context.set_context', the parameter 'variable_memory_max_size' is deprecated, "
|
|
344
443
|
"and will be removed in a future "
|
|
345
444
|
"version. Please use parameter 'max_device_memory' instead.")
|
|
346
|
-
if not Validator.check_str_by_regular(variable_memory_max_size,
|
|
445
|
+
if not Validator.check_str_by_regular(variable_memory_max_size, _RE_PATTERN):
|
|
347
446
|
raise ValueError("For 'context.set_context', the argument 'variable_memory_max_size' should be in correct"
|
|
348
447
|
" format! It must be a string ending with 'GB', in addition to that, it must contain "
|
|
349
|
-
"only numbers or decimal points, such as \"5GB\" or \"3.5GB\", but got {}."
|
|
448
|
+
"only numbers or decimal points, such as \"5GB\" or \"3.5GB\", but got {}GB."
|
|
350
449
|
.format(variable_memory_max_size))
|
|
351
450
|
if float(variable_memory_max_size[:-2]) > _DEVICE_APP_MEMORY_SIZE:
|
|
352
451
|
raise ValueError("For 'context.set_context', the argument 'variable_memory_max_size' should not be "
|
|
353
|
-
"greater than 31GB, but got {}.".format(variable_memory_max_size))
|
|
452
|
+
"greater than 31GB, but got {}GB.".format(variable_memory_max_size))
|
|
354
453
|
variable_memory_max_size_ = variable_memory_max_size[:-2] + " * 1024 * 1024 * 1024"
|
|
355
454
|
graph_memory_max_size = _DEVICE_APP_MEMORY_SIZE - int(variable_memory_max_size[:-2])
|
|
356
455
|
graph_memory_max_size_ = str(graph_memory_max_size) + " * 1024 * 1024 * 1024"
|
|
@@ -358,7 +457,7 @@ class _Context:
|
|
|
358
457
|
self.set_param(ms_ctx_param._graph_memory_max_size, graph_memory_max_size_)
|
|
359
458
|
|
|
360
459
|
def set_max_device_memory(self, max_device_memory):
|
|
361
|
-
if not Validator.check_str_by_regular(max_device_memory,
|
|
460
|
+
if not Validator.check_str_by_regular(max_device_memory, _RE_PATTERN):
|
|
362
461
|
raise ValueError("For 'context.set_context', the argument 'max_device_memory' should be in correct "
|
|
363
462
|
" format! It must be a string ending with 'GB', in addition to that, it must contain "
|
|
364
463
|
"only numbers or decimal points, such as \"5GB\" or \"3.5GB\", but got {}."
|
|
@@ -374,7 +473,7 @@ class _Context:
|
|
|
374
473
|
logger.warning("Graph mode doesn't support to set parameter 'mempool_block_size' of context currently, "
|
|
375
474
|
"you can use context.set_context to set pynative mode.")
|
|
376
475
|
return
|
|
377
|
-
if not Validator.check_str_by_regular(mempool_block_size,
|
|
476
|
+
if not Validator.check_str_by_regular(mempool_block_size, _RE_PATTERN):
|
|
378
477
|
raise ValueError("For 'context.set_context', the argument 'mempool_block_size' should be in "
|
|
379
478
|
"correct format! Such as \"10GB\", "
|
|
380
479
|
"but got {}".format(mempool_block_size))
|
|
@@ -416,7 +515,7 @@ class _Context:
|
|
|
416
515
|
except (TypeError, ValueError) as exo:
|
|
417
516
|
raise ValueError(str(exo) + "\nFor 'context.set_context', open or load the 'env_config_path' file {} "
|
|
418
517
|
"failed, please check whether 'env_config_path' is json file and correct, "
|
|
419
|
-
"or may not have permission to read it.".format(env_config_path))
|
|
518
|
+
"or may not have permission to read it.".format(env_config_path)) from exo
|
|
420
519
|
self.set_param(ms_ctx_param.env_config_path, env_config_path)
|
|
421
520
|
|
|
422
521
|
def set_runtime_num_threads(self, runtime_num_threads):
|
|
@@ -441,8 +540,8 @@ class _Context:
|
|
|
441
540
|
'mode': set_mode,
|
|
442
541
|
'save_graphs_path': set_save_graphs_path,
|
|
443
542
|
'device_target': set_device_target,
|
|
543
|
+
'aoe_tune_mode': set_aoe_tune_mode,
|
|
444
544
|
'device_id': set_device_id,
|
|
445
|
-
'auto_tune_mode': set_auto_tune_mode,
|
|
446
545
|
'max_call_depth': set_max_call_depth,
|
|
447
546
|
'profiling_options': set_profiling_options,
|
|
448
547
|
'variable_memory_max_size': set_variable_memory_max_size,
|
|
@@ -456,7 +555,10 @@ class _Context:
|
|
|
456
555
|
'op_timeout': set_op_timeout,
|
|
457
556
|
'memory_offload': set_memory_offload,
|
|
458
557
|
'deterministic': set_deterministic,
|
|
459
|
-
'ascend_config': set_ascend_config
|
|
558
|
+
'ascend_config': set_ascend_config,
|
|
559
|
+
'jit_syntax_level': set_jit_syntax_level,
|
|
560
|
+
'gpu_config': set_gpu_config,
|
|
561
|
+
'aoe_config': set_aoe_config,
|
|
460
562
|
}
|
|
461
563
|
|
|
462
564
|
@property
|
|
@@ -496,6 +598,55 @@ class _Context:
|
|
|
496
598
|
raise TypeError(f"The attribute 'support_binary' should be a bool, but got {type(support)}.")
|
|
497
599
|
self._support_binary = support
|
|
498
600
|
|
|
601
|
+
def _get_ascend_config_setter(self, ascend_key, trans_fn=None):
|
|
602
|
+
def _config_setter(ascend_value):
|
|
603
|
+
self.set_param(ms_ctx_param.__members__[ascend_key], trans_fn(ascend_value))
|
|
604
|
+
|
|
605
|
+
if trans_fn is None:
|
|
606
|
+
trans_fn = lambda x: x
|
|
607
|
+
return _config_setter
|
|
608
|
+
|
|
609
|
+
def _set_op_precision_mode(self, ascend_value):
|
|
610
|
+
op_precision_path = ascend_value
|
|
611
|
+
real_path = os.path.realpath(op_precision_path)
|
|
612
|
+
if not os.path.exists(real_path):
|
|
613
|
+
raise ValueError(f"For 'ascend_config', the 'op_precision_mode' is invalid path, "
|
|
614
|
+
f"got '{op_precision_path}'.")
|
|
615
|
+
self.set_param(ms_ctx_param.op_precision_mode, ascend_value)
|
|
616
|
+
|
|
617
|
+
def _set_speedup_config_path(self, speedup_config_path):
|
|
618
|
+
""""Check and set speedup config for auto parallel."""
|
|
619
|
+
if speedup_config_path is None or speedup_config_path == "":
|
|
620
|
+
return
|
|
621
|
+
speedup_config_real_path = os.path.abspath(speedup_config_path)
|
|
622
|
+
if not os.path.exists(speedup_config_real_path):
|
|
623
|
+
raise ValueError(f"For 'ascend_config', the path to parallel_speed_up_json: "
|
|
624
|
+
f"{speedup_config_real_path} does not exist, please check whether the "
|
|
625
|
+
f"'parallel_speed_up_json_path' is correct.")
|
|
626
|
+
try:
|
|
627
|
+
valid_option = {"recompute_comm_overlap": ms_ctx_param.recompute_comm_overlap,
|
|
628
|
+
"matmul_grad_comm_overlap": ms_ctx_param.matmul_grad_comm_overlap,
|
|
629
|
+
"enable_task_opt": ms_ctx_param.enable_task_opt,
|
|
630
|
+
"enable_grad_comm_opt": ms_ctx_param.enable_grad_comm_opt,
|
|
631
|
+
"interleaved_matmul_comm": ms_ctx_param.interleaved_matmul_comm,
|
|
632
|
+
"interleaved_layernorm_comm": ms_ctx_param.interleaved_layernorm_comm}
|
|
633
|
+
with open(speedup_config_real_path, 'r') as f:
|
|
634
|
+
speedup_config = json.load(f)
|
|
635
|
+
for k, v in speedup_config.items():
|
|
636
|
+
if not isinstance(k, str):
|
|
637
|
+
raise TypeError("key {} is not a str".format(k))
|
|
638
|
+
if k not in valid_option:
|
|
639
|
+
raise ValueError("key {} should be one of {}.".format(k, valid_option.keys()))
|
|
640
|
+
if not isinstance(v, bool):
|
|
641
|
+
raise TypeError("value {} is not a bool".format(v))
|
|
642
|
+
self.set_param(valid_option.get(k), v)
|
|
643
|
+
except (TypeError, ValueError) as exo:
|
|
644
|
+
raise ValueError(str(exo) + "\nFor 'context.set_context', "
|
|
645
|
+
"open or load the 'speedup_config_path' file {} "
|
|
646
|
+
"failed, please check whether 'speedup_config_path' is json file and correct, "
|
|
647
|
+
"or may not have permission to read it.".format(speedup_config_real_path)) \
|
|
648
|
+
from exo
|
|
649
|
+
|
|
499
650
|
|
|
500
651
|
def _context():
|
|
501
652
|
"""
|
|
@@ -524,8 +675,9 @@ def _context():
|
|
|
524
675
|
@args_type_check(device_num=int, global_rank=int, gradients_mean=bool, gradient_fp32_sync=bool, parallel_mode=str,
|
|
525
676
|
auto_parallel_search_mode=str, search_mode=str, parameter_broadcast=bool, strategy_ckpt_load_file=str,
|
|
526
677
|
strategy_ckpt_save_file=str, full_batch=bool, enable_parallel_optimizer=bool, enable_alltoall=bool,
|
|
527
|
-
all_reduce_fusion_config=list, pipeline_stages=int,
|
|
528
|
-
parallel_optimizer_config=dict,
|
|
678
|
+
all_reduce_fusion_config=list, pipeline_stages=int, pipeline_segments=int,
|
|
679
|
+
parallel_optimizer_config=dict,
|
|
680
|
+
comm_fusion=dict, strategy_ckpt_config=dict)
|
|
529
681
|
def set_auto_parallel_context(**kwargs):
|
|
530
682
|
r"""
|
|
531
683
|
Set auto parallel context, only data parallel supported on CPU.
|
|
@@ -546,26 +698,26 @@ def set_auto_parallel_context(**kwargs):
|
|
|
546
698
|
device_num gradient_fp32_sync
|
|
547
699
|
global_rank loss_repeated_mean
|
|
548
700
|
gradients_mean search_mode
|
|
549
|
-
parallel_mode
|
|
550
|
-
all_reduce_fusion_config
|
|
551
|
-
enable_parallel_optimizer
|
|
552
|
-
parallel_optimizer_config
|
|
553
|
-
enable_alltoall
|
|
701
|
+
parallel_mode parameter_broadcast
|
|
702
|
+
all_reduce_fusion_config strategy_ckpt_load_file
|
|
703
|
+
enable_parallel_optimizer strategy_ckpt_save_file
|
|
704
|
+
parallel_optimizer_config dataset_strategy
|
|
705
|
+
enable_alltoall pipeline_stages
|
|
554
706
|
\ auto_parallel_search_mode
|
|
555
707
|
\ comm_fusion
|
|
556
708
|
\ strategy_ckpt_config
|
|
557
709
|
=========================== ===========================
|
|
558
710
|
|
|
559
711
|
Args:
|
|
560
|
-
device_num (int): Available device number, the value must be in [1, 4096]. Default: 1.
|
|
561
|
-
global_rank (int): Global rank id, the value must be in [0, 4095]. Default: 0.
|
|
712
|
+
device_num (int): Available device number, the value must be in [1, 4096]. Default: ``1`` .
|
|
713
|
+
global_rank (int): Global rank id, the value must be in [0, 4095]. Default: ``0`` .
|
|
562
714
|
gradients_mean (bool): Whether to perform mean operator after allreduce of gradients.
|
|
563
|
-
"stand_alone" do not support gradients_mean. Default: False.
|
|
715
|
+
"stand_alone" do not support gradients_mean. Default: ``False`` .
|
|
564
716
|
gradient_fp32_sync (bool): Run allreduce of gradients in fp32. "stand_alone", "data_parallel"
|
|
565
|
-
and "hybrid_parallel" do not support gradient_fp32_sync. Default: True.
|
|
566
|
-
parallel_mode (str): There are five kinds of parallel modes, "stand_alone", "data_parallel",
|
|
567
|
-
"hybrid_parallel", "semi_auto_parallel" and "auto_parallel". Note the pynative mode
|
|
568
|
-
the "stand_alone" and "data_parallel" mode. Default: "stand_alone".
|
|
717
|
+
and "hybrid_parallel" do not support gradient_fp32_sync. Default: ``True`` .
|
|
718
|
+
parallel_mode (str): There are five kinds of parallel modes, ``"stand_alone"`` , ``"data_parallel"`` ,
|
|
719
|
+
``"hybrid_parallel"`` , ``"semi_auto_parallel"`` and ``"auto_parallel"`` . Note the pynative mode
|
|
720
|
+
only supports the ``"stand_alone"`` and ``"data_parallel"`` mode. Default: ``"stand_alone"`` .
|
|
569
721
|
|
|
570
722
|
- stand_alone: Only one processor is working.
|
|
571
723
|
|
|
@@ -576,10 +728,12 @@ def set_auto_parallel_context(**kwargs):
|
|
|
576
728
|
- semi_auto_parallel: Achieves data and model parallelism by setting parallel strategies.
|
|
577
729
|
|
|
578
730
|
- auto_parallel: Achieving parallelism automatically.
|
|
579
|
-
search_mode (str): There are three kinds of shard strategy search modes: "recursive_programming",
|
|
580
|
-
"dynamic_programming" and "sharding_propagation". Default: "
|
|
731
|
+
search_mode (str): There are three kinds of shard strategy search modes: ``"recursive_programming"`` ,
|
|
732
|
+
``"dynamic_programming"`` and ``"sharding_propagation"`` . Default: ``"recursive_programming"`` .
|
|
581
733
|
|
|
582
|
-
- recursive_programming: Recursive programming search mode.
|
|
734
|
+
- recursive_programming: Recursive programming search mode. In order to obtain optimal performance,
|
|
735
|
+
it is recommended that users set the batch size to be greater than or equal to the product of
|
|
736
|
+
the number of devices and the number of multi-copy parallelism.
|
|
583
737
|
|
|
584
738
|
- dynamic_programming: Dynamic programming search mode.
|
|
585
739
|
|
|
@@ -589,17 +743,18 @@ def set_auto_parallel_context(**kwargs):
|
|
|
589
743
|
parameter_broadcast (bool): Whether to broadcast parameters before training. Before training, in order to have
|
|
590
744
|
the same network initialization parameter values for all devices, broadcast the parameters
|
|
591
745
|
on device 0 to other devices. Parameter broadcasting in different parallel modes is different,
|
|
592
|
-
data_parallel mode, all parameters are broadcast except for the parameter whose attribute
|
|
593
|
-
layerwise_parallel is True. Hybrid_parallel, semi_auto_parallel
|
|
594
|
-
segmented parameters do not participate in broadcasting.
|
|
746
|
+
``data_parallel`` mode, all parameters are broadcast except for the parameter whose attribute
|
|
747
|
+
layerwise_parallel is ``True`` . ``Hybrid_parallel`` , ``semi_auto_parallel`` and
|
|
748
|
+
``auto_parallel mode`` , the segmented parameters do not participate in broadcasting.
|
|
749
|
+
Default: ``False`` .
|
|
595
750
|
strategy_ckpt_load_file (str): The path to load parallel strategy checkpoint. The parameter is not to be
|
|
596
|
-
recommended currently, it is better using 'strategy_ckpt_config' to replace it. Default: ''
|
|
751
|
+
recommended currently, it is better using 'strategy_ckpt_config' to replace it. Default: ``''``
|
|
597
752
|
strategy_ckpt_save_file (str): The path to save parallel strategy checkpoint. The parameter is not to be
|
|
598
|
-
recommended currently, it is better using 'strategy_ckpt_config' to replace it. Default: ''
|
|
599
|
-
full_batch (bool): If you load whole batch datasets in auto_parallel mode, this parameter
|
|
600
|
-
should be set as True. Default: False. The interface is not to be recommended
|
|
601
|
-
it is better using 'dataset_strategy' to replace it.
|
|
602
|
-
dataset_strategy (Union[str, tuple]): Dataset sharding strategy. Default: "data_parallel".
|
|
753
|
+
recommended currently, it is better using 'strategy_ckpt_config' to replace it. Default: ``''``
|
|
754
|
+
full_batch (bool): If you load whole batch datasets in ``auto_parallel`` mode, this parameter
|
|
755
|
+
should be set as ``True`` . Default: ``False`` . The interface is not to be recommended
|
|
756
|
+
currently, it is better using 'dataset_strategy' to replace it.
|
|
757
|
+
dataset_strategy (Union[str, tuple]): Dataset sharding strategy. Default: ``"data_parallel"`` .
|
|
603
758
|
dataset_strategy="data_parallel" is equal to full_batch=False, dataset_strategy="full_batch" is
|
|
604
759
|
equal to full_batch=True. For execution mode is 'GRAPH_MODE' and dataset load into net by model
|
|
605
760
|
parallel strategy likes ds_stra ((1, 8), (1, 8)), it requires using
|
|
@@ -607,45 +762,51 @@ def set_auto_parallel_context(**kwargs):
|
|
|
607
762
|
enable_parallel_optimizer (bool): This is a developing feature, which shards the weight update computation for
|
|
608
763
|
data parallel training in the benefit of time and memory saving. Currently, auto and semi auto
|
|
609
764
|
parallel mode support all optimizers in both Ascend and GPU. Data parallel mode only supports
|
|
610
|
-
`Lamb` and `AdamWeightDecay` in Ascend . Default: False.
|
|
765
|
+
`Lamb` and `AdamWeightDecay` in Ascend . Default: ``False`` .
|
|
611
766
|
enable_alltoall (bool): A switch that allows AllToAll operators to be generated during communication. If its
|
|
612
|
-
value is False, there will be a combination of operators such as AllGather, Split and
|
|
613
|
-
instead of AllToAll. Default: False.
|
|
767
|
+
value is ``False`` , there will be a combination of operators such as AllGather, Split and
|
|
768
|
+
Concat instead of AllToAll. Default: ``False`` .
|
|
614
769
|
all_reduce_fusion_config (list): Set allreduce fusion strategy by parameters indices. Only support ReduceOp.SUM
|
|
615
770
|
and HCCL_WORLD_GROUP/NCCL_WORLD_GROUP. No Default, if it is not set, the fusion is closed.
|
|
616
771
|
pipeline_stages (int): Set the stage information for pipeline parallel. This indicates how the devices are
|
|
617
772
|
distributed alone in the pipeline. The total devices will be divided into 'pipeline_stags'
|
|
618
|
-
stages.
|
|
619
|
-
Default: 1.
|
|
620
|
-
grad_accumulation_step (int): Set the accumulation steps of gradients in auto and semi auto parallel mode.
|
|
621
|
-
This should be a positive int. Default: 1.
|
|
773
|
+
stages.
|
|
774
|
+
Default: ``1`` .
|
|
622
775
|
parallel_optimizer_config (dict): A dict contains the keys and values for setting the parallel optimizer
|
|
623
776
|
configure. The configure provides more detailed behavior control about parallel training
|
|
624
|
-
when parallel optimizer is enabled.
|
|
625
|
-
The configure will be effective when we use
|
|
777
|
+
when parallel optimizer is enabled. The configure will be effective when we use
|
|
626
778
|
mindspore.set_auto_parallel_context(enable_parallel_optimizer=True).
|
|
627
779
|
It supports the following keys.
|
|
628
780
|
|
|
629
|
-
- gradient_accumulation_shard(bool): If true, the accumulation gradient parameters will be
|
|
781
|
+
- gradient_accumulation_shard(bool): If ``true`` , the accumulation gradient parameters will be
|
|
630
782
|
sharded across the data parallel devices. This will
|
|
631
783
|
introduce additional communication(ReduceScatter) at
|
|
632
784
|
each step when accumulate the gradients, but saves a
|
|
633
785
|
lot of device memories, thus can make model be trained
|
|
634
786
|
with larger batch size. This configure is effective only
|
|
635
787
|
when the model runs on pipeline training or gradient
|
|
636
|
-
accumulation with data parallel. Default
|
|
788
|
+
accumulation with data parallel. Default ``False`` .
|
|
637
789
|
|
|
638
790
|
- parallel_optimizer_threshold(int): Set the threshold of parallel optimizer. When parallel
|
|
639
791
|
optimizer is enabled, parameters with size smaller than this threshold will not be sharded
|
|
640
792
|
across the devices. Parameter size = shape[0] \* ... \* shape[n] \* size(dtype). Non-negative.
|
|
641
|
-
Unit: KB. Default: 64.
|
|
793
|
+
Unit: KB. Default: ``64`` .
|
|
794
|
+
|
|
795
|
+
- optimizer_weight_shard_size(int): Set the optimizer weight shard group size, if you want to
|
|
796
|
+
specific the maximum group size across devices when the parallel optimizer is enabled.
|
|
797
|
+
The numerical range can be (0, device_num]. If pipeline parallel is enabled, the numerical
|
|
798
|
+
range is (0, device_num/stage]. If the size of data parallel communication domain
|
|
799
|
+
of the parameter cannot be divided by `optimizer_weight_shard_size`, then the specified
|
|
800
|
+
communication group size will not take effect. Default value is ``-1`` , which means the
|
|
801
|
+
optimizer weight shard group size will be the size of data parallel group of each parameter.
|
|
642
802
|
|
|
643
803
|
comm_fusion (dict): A dict contains the types and configurations for setting the communication fusion. each
|
|
644
804
|
communication fusion config has two keys: "mode" and "config".
|
|
645
805
|
It supports following communication fusion types and configurations:
|
|
646
806
|
|
|
647
|
-
- openstate: Whether turn on the communication fusion or not. If `openstate` is
|
|
648
|
-
the communication fusion, otherwise, turn off the communication fusion.
|
|
807
|
+
- openstate: Whether turn on the communication fusion or not. If `openstate` is ``True`` ,
|
|
808
|
+
turn on the communication fusion, otherwise, turn off the communication fusion.
|
|
809
|
+
Default: ``True`` .
|
|
649
810
|
|
|
650
811
|
- allreduce: If communication fusion type is `allreduce`. The `mode` contains: `auto`, `size`
|
|
651
812
|
and `index`. In `auto` mode, AllReduce fusion is configured by gradients size and the default
|
|
@@ -677,7 +838,7 @@ def set_auto_parallel_context(**kwargs):
|
|
|
677
838
|
Default: ''
|
|
678
839
|
|
|
679
840
|
- only_trainable_params (bool): Only save/load the strategy information for trainable parameter.
|
|
680
|
-
Default: True.
|
|
841
|
+
Default: ``True`` .
|
|
681
842
|
|
|
682
843
|
Raises:
|
|
683
844
|
ValueError: If input key is not attribute in auto parallel context.
|
|
@@ -699,7 +860,8 @@ def set_auto_parallel_context(**kwargs):
|
|
|
699
860
|
>>> ms.set_auto_parallel_context(enable_alltoall=False)
|
|
700
861
|
>>> ms.set_auto_parallel_context(all_reduce_fusion_config=[8, 160])
|
|
701
862
|
>>> ms.set_auto_parallel_context(pipeline_stages=2)
|
|
702
|
-
>>> parallel_config = {"gradient_accumulation_shard": True, "parallel_optimizer_threshold": 24
|
|
863
|
+
>>> parallel_config = {"gradient_accumulation_shard": True, "parallel_optimizer_threshold": 24,
|
|
864
|
+
... "optimizer_weight_shard_size": 2}
|
|
703
865
|
>>> ms.set_auto_parallel_context(parallel_optimizer_config=parallel_config, enable_parallel_optimizer=True)
|
|
704
866
|
>>> config = {"allreduce": {"mode": "size", "config": 32}, "allgather": {"mode": "size", "config": 32}}
|
|
705
867
|
>>> ms.set_auto_parallel_context(comm_fusion=config)
|
|
@@ -739,8 +901,8 @@ def reset_auto_parallel_context():
|
|
|
739
901
|
- gradients_mean: False.
|
|
740
902
|
- gradient_fp32_sync: True.
|
|
741
903
|
- parallel_mode: 'stand_alone'.
|
|
742
|
-
- search_mode: '
|
|
743
|
-
- auto_parallel_search_mode: '
|
|
904
|
+
- search_mode: 'recursive_programming'.
|
|
905
|
+
- auto_parallel_search_mode: 'recursive_programming'.
|
|
744
906
|
- parameter_broadcast: False.
|
|
745
907
|
- strategy_ckpt_load_file: ''.
|
|
746
908
|
- strategy_ckpt_save_file: ''.
|
|
@@ -749,6 +911,10 @@ def reset_auto_parallel_context():
|
|
|
749
911
|
- enable_alltoall: False.
|
|
750
912
|
- pipeline_stages: 1.
|
|
751
913
|
- fusion_threshold: 64.
|
|
914
|
+
|
|
915
|
+
Examples:
|
|
916
|
+
>>> import mindspore as ms
|
|
917
|
+
>>> ms.reset_auto_parallel_context()
|
|
752
918
|
"""
|
|
753
919
|
_reset_auto_parallel_context()
|
|
754
920
|
|
|
@@ -756,36 +922,51 @@ def reset_auto_parallel_context():
|
|
|
756
922
|
@args_type_check(offload_config=dict)
|
|
757
923
|
def set_offload_context(offload_config):
|
|
758
924
|
r"""
|
|
759
|
-
|
|
760
|
-
|
|
925
|
+
Configure heterogeneous training detailed parameters to adjust the offload strategy.
|
|
926
|
+
|
|
927
|
+
Note:
|
|
928
|
+
The offload configuration is only used if the memory offload feature is enabled
|
|
929
|
+
via mindspore.set_context(memory_offload="ON").
|
|
761
930
|
|
|
762
931
|
Args:
|
|
763
932
|
offload_config (dict): A dict contains the keys and values for setting the offload context
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
933
|
+
configure.It supports the following keys.
|
|
934
|
+
|
|
935
|
+
- offload_path (str): The path of offload, relative paths are supported. Default: ``"./offload"``.
|
|
936
|
+
- offload_cpu_size (str): The cpu memory size for offload. The format is "xxGB".
|
|
937
|
+
- offload_disk_size (str): The disk size for offload. The format is "xxGB"
|
|
938
|
+
- hbm_ratio (float): The ratio that can be used based on the maximum device memory.
|
|
939
|
+
The range is (0,1], Default: ``1.0``.
|
|
940
|
+
- cpu_ratio (float): The ratio that can be used based on the maximum host memory.
|
|
941
|
+
The range is (0,1], Default: ``1.0``.
|
|
942
|
+
- enable_pinned_mem (bool): The flag of whether enabling Pinned Memory. Default: ``True``.
|
|
943
|
+
- enable_aio (bool): The flag of whether enabling aio. Default: ``True``.
|
|
944
|
+
- aio_block_size (str): The size of aio block. The format is "xxGB".
|
|
945
|
+
- aio_queue_depth (int): The depth of aio queue.
|
|
946
|
+
- offload_param (str): The param for offload destination, cpu or disk, Default: ``""``.
|
|
947
|
+
- offload_checkpoint (str): The checkpoint for offload destination, only valid if recompute is turned on,
|
|
948
|
+
cpu or disk, Default: ``""``.
|
|
949
|
+
- auto_offload (bool): The flag of whether auto offload. Default: ``True``.
|
|
950
|
+
- host_mem_block_size (str): The memory block size of host memory pool. The format is "xxGB"
|
|
775
951
|
|
|
776
952
|
Raises:
|
|
777
953
|
ValueError: If input key is not attribute in auto parallel context.
|
|
778
954
|
|
|
779
955
|
Examples:
|
|
780
956
|
>>> from mindspore import context
|
|
781
|
-
>>> context.set_offload_context(offload_config={"offload_param"
|
|
957
|
+
>>> context.set_offload_context(offload_config={"offload_param":"cpu"})
|
|
782
958
|
"""
|
|
783
959
|
_set_offload_context(offload_config)
|
|
784
960
|
|
|
785
961
|
|
|
786
962
|
def get_offload_context():
|
|
787
963
|
"""
|
|
788
|
-
|
|
964
|
+
Gets the offload configuration parameters. Configure through interface mindspore.set_offload_context().
|
|
965
|
+
If the user is not set, the default configuration is obtained.
|
|
966
|
+
|
|
967
|
+
Returns:
|
|
968
|
+
Dict, heterogeneous training offload detailed configuration parameters.
|
|
969
|
+
|
|
789
970
|
Examples:
|
|
790
971
|
>>> from mindspore import context
|
|
791
972
|
>>> offload_config = context.get_offload_context()
|
|
@@ -801,11 +982,11 @@ def _check_target_specific_cfgs(device, arg_key):
|
|
|
801
982
|
'enable_reduce_precision': ['Ascend'],
|
|
802
983
|
'print_file_path': ['Ascend'],
|
|
803
984
|
'variable_memory_max_size': ['Ascend'],
|
|
804
|
-
'auto_tune_mode': ['Ascend'],
|
|
805
985
|
'max_device_memory': ['Ascend', 'GPU'],
|
|
806
986
|
'mempool_block_size': ['GPU', 'Ascend'],
|
|
807
987
|
'disable_format_transform': ['GPU'],
|
|
808
|
-
'ascend_config': ['Ascend']
|
|
988
|
+
'ascend_config': ['Ascend'],
|
|
989
|
+
'gpu_config': ['GPU'],
|
|
809
990
|
}
|
|
810
991
|
# configs not in map device_cfgs are supposed to be suitable for all devices
|
|
811
992
|
if arg_key not in device_cfgs:
|
|
@@ -820,14 +1001,15 @@ def _check_target_specific_cfgs(device, arg_key):
|
|
|
820
1001
|
|
|
821
1002
|
|
|
822
1003
|
@args_type_check(mode=int, precompile_only=bool, device_target=str, device_id=int, save_graphs=(bool, int),
|
|
823
|
-
save_graphs_path=str, enable_dump=bool,
|
|
1004
|
+
save_graphs_path=str, enable_dump=bool, aoe_tune_mode=str, aoe_config=dict,
|
|
824
1005
|
save_dump_path=str, enable_reduce_precision=bool, variable_memory_max_size=str,
|
|
825
1006
|
enable_auto_mixed_precision=bool, inter_op_parallel_num=int,
|
|
826
1007
|
enable_graph_kernel=bool, reserve_class_name_in_scope=bool, check_bprop=bool,
|
|
827
1008
|
max_device_memory=str, print_file_path=str, max_call_depth=int, env_config_path=str,
|
|
828
1009
|
graph_kernel_flags=str, save_compile_cache=bool, runtime_num_threads=int, load_compile_cache=bool,
|
|
829
1010
|
grad_for_scalar=bool, pynative_synchronize=bool, mempool_block_size=str, disable_format_transform=bool,
|
|
830
|
-
op_timeout=int, deterministic=str, ascend_config=dict
|
|
1011
|
+
op_timeout=int, deterministic=str, ascend_config=dict, jit_syntax_level=int,
|
|
1012
|
+
jit_enable_inplace_ops=bool, gpu_config=dict)
|
|
831
1013
|
def set_context(**kwargs):
|
|
832
1014
|
"""
|
|
833
1015
|
Set context for running environment.
|
|
@@ -838,7 +1020,7 @@ def set_context(**kwargs):
|
|
|
838
1020
|
Note:
|
|
839
1021
|
Attribute name is required for setting attributes.
|
|
840
1022
|
The mode is not recommended to be changed after net was initialized because the implementations of some
|
|
841
|
-
operations are different in graph mode and pynative mode. Default: PYNATIVE_MODE.
|
|
1023
|
+
operations are different in graph mode and pynative mode. Default: ``PYNATIVE_MODE`` .
|
|
842
1024
|
|
|
843
1025
|
Some configurations are device specific, see the below table for details:
|
|
844
1026
|
|
|
@@ -875,7 +1057,7 @@ def set_context(**kwargs):
|
|
|
875
1057
|
| +------------------------------+----------------------------+
|
|
876
1058
|
| | reserve_class_name_in_scope | CPU/GPU/Ascend |
|
|
877
1059
|
| +------------------------------+----------------------------+
|
|
878
|
-
| | pynative_synchronize | GPU/Ascend
|
|
1060
|
+
| | pynative_synchronize | CPU/GPU/Ascend |
|
|
879
1061
|
+-------------------------+------------------------------+----------------------------+
|
|
880
1062
|
| Executive Control | mode | CPU/GPU/Ascend |
|
|
881
1063
|
| +------------------------------+----------------------------+
|
|
@@ -885,7 +1067,9 @@ def set_context(**kwargs):
|
|
|
885
1067
|
| +------------------------------+----------------------------+
|
|
886
1068
|
| | enable_reduce_precision | Ascend |
|
|
887
1069
|
| +------------------------------+----------------------------+
|
|
888
|
-
| |
|
|
1070
|
+
| | aoe_tune_mode | Ascend |
|
|
1071
|
+
| +------------------------------+----------------------------+
|
|
1072
|
+
| | aoe_config | Ascend |
|
|
889
1073
|
| +------------------------------+----------------------------+
|
|
890
1074
|
| | check_bprop | CPU/GPU/Ascend |
|
|
891
1075
|
| +------------------------------+----------------------------+
|
|
@@ -910,47 +1094,52 @@ def set_context(**kwargs):
|
|
|
910
1094
|
| | memory_offload | GPU/Ascend |
|
|
911
1095
|
| +------------------------------+----------------------------+
|
|
912
1096
|
| | ascend_config | Ascend |
|
|
1097
|
+
| +------------------------------+----------------------------+
|
|
1098
|
+
| | jit_syntax_level | CPU/GPU/Ascend |
|
|
1099
|
+
| +------------------------------+----------------------------+
|
|
1100
|
+
| | gpu_config | GPU |
|
|
913
1101
|
+-------------------------+------------------------------+----------------------------+
|
|
914
1102
|
|
|
915
1103
|
Args:
|
|
916
1104
|
device_id (int): ID of the target device, the value must be in [0, device_num_per_host-1],
|
|
917
|
-
while device_num_per_host should be no more than 4096. Default: 0.
|
|
1105
|
+
while device_num_per_host should be no more than 4096. Default: ``0`` .
|
|
918
1106
|
device_target (str): The target device to run, support "Ascend", "GPU", and "CPU".
|
|
919
1107
|
If device target is not set, the version of MindSpore package is used.
|
|
920
|
-
max_device_memory (str): Set the maximum memory available for devices. The format is "xxGB".
|
|
921
|
-
The actual used memory size is the minimum of the available memory of the device
|
|
1108
|
+
max_device_memory (str): Set the maximum memory available for devices. The format is "xxGB".
|
|
1109
|
+
Default: ``" 1024GB"`` . The actual used memory size is the minimum of the available memory of the device
|
|
1110
|
+
and max_device_memory. 'max_device_memory' should be set before the program runs.
|
|
922
1111
|
variable_memory_max_size (str): This parameter is deprecated, and will be removed in a future version.
|
|
923
1112
|
Please use parameter 'max_device_memory' instead.
|
|
924
1113
|
mempool_block_size (str): Set the size of the memory pool block in PyNative mode for devices.
|
|
925
|
-
The format is "xxGB". Default: "1GB". Minimum size is "1G". The actual used memory block size is the
|
|
926
|
-
of the available memory of the device and mempool_block_size.
|
|
1114
|
+
The format is "xxGB". Default: ``"1GB"`` . Minimum size is "1G". The actual used memory block size is the
|
|
1115
|
+
minimum of the available memory of the device and mempool_block_size.
|
|
927
1116
|
op_timeout (int): Set the maximum duration of executing an operator in seconds.
|
|
928
1117
|
If the execution time exceeds this value, system will terminate the task. 0 means endless wait.
|
|
929
|
-
Default: 1900.
|
|
930
|
-
save_graphs (bool or int): Whether to save intermediate compilation graphs. Default: 0.
|
|
1118
|
+
Default: ``1900`` .
|
|
1119
|
+
save_graphs (bool or int): Whether to save intermediate compilation graphs. Default: ``0`` .
|
|
931
1120
|
Available values are:
|
|
932
1121
|
|
|
933
1122
|
- False or 0: disable saving of intermediate compilation graphs.
|
|
934
|
-
- 1: some intermediate files will be generated during graph
|
|
1123
|
+
- 1: some intermediate files will be generated during graph compilation.
|
|
935
1124
|
- True or 2: Generate more ir files related to backend process.
|
|
936
1125
|
- 3: Generate visualization computing graphs and detailed frontend ir graphs.
|
|
937
1126
|
|
|
938
|
-
When the `save_graphs` attribute is set as True, 1, 2 or 3, attribute of
|
|
939
|
-
to set the intermediate compilation graph storage path. By default, the graphs
|
|
940
|
-
directory.
|
|
1127
|
+
When the `save_graphs` attribute is set as ``True`` , ``1`` , ``2`` or ``3`` , attribute of
|
|
1128
|
+
`save_graphs_path` is used to set the intermediate compilation graph storage path. By default, the graphs
|
|
1129
|
+
are saved in the current directory.
|
|
941
1130
|
save_graphs_path (str): Path to save graphs. Default: ".".
|
|
942
1131
|
If the specified directory does not exist, the system will automatically create the directory.
|
|
943
1132
|
During distributed training, graphs will be saved to the directory of
|
|
944
1133
|
`save_graphs_path/rank_${rank_id}/`. `rank_id` is the ID of the current device in the cluster.
|
|
945
1134
|
deterministic (str): Whether to enable op run in deterministic mode. The value must be in the
|
|
946
|
-
range of ['ON', 'OFF'], and the default value is 'OFF'.
|
|
1135
|
+
range of ['ON', 'OFF'], and the default value is ``'OFF'`` .
|
|
947
1136
|
|
|
948
1137
|
- "ON": Enable operator deterministic running mode.
|
|
949
1138
|
- "OFF": Disable operator deterministic running mode.
|
|
950
1139
|
|
|
951
|
-
When deterministic mode is on, model ops will be deterministic in Ascend. This means that if op run
|
|
952
|
-
times with the same inputs on the same hardware, it will have the exact same outputs each time.
|
|
953
|
-
useful for debugging models.
|
|
1140
|
+
When deterministic mode is on, model ops will be deterministic in Ascend. This means that if op run
|
|
1141
|
+
multiple times with the same inputs on the same hardware, it will have the exact same outputs each time.
|
|
1142
|
+
This is useful for debugging models.
|
|
954
1143
|
enable_dump (bool): This parameters is deprecated, and will be deleted in the next version.
|
|
955
1144
|
save_dump_path (str): This parameters is deprecated, and will be deleted in the next version.
|
|
956
1145
|
print_file_path (str): The path of saving print data. If this parameter is set, print data is saved to
|
|
@@ -964,23 +1153,23 @@ def set_context(**kwargs):
|
|
|
964
1153
|
configure RDR:
|
|
965
1154
|
|
|
966
1155
|
- enable: controls whether the RDR is enabled to collect the key data during training and
|
|
967
|
-
save key data in the fault scenario. When set to true, the RDR will be turned on.
|
|
968
|
-
When set to false, the RDR will be turned off.
|
|
969
|
-
- mode: sets the mode of RDR on exporting data. When set to 1, the RDR only exports data
|
|
970
|
-
in the fault scenario. When set to 2, the RDR exports data in the fault scenario and the
|
|
971
|
-
normal end scenario. Default: 1.
|
|
1156
|
+
save key data in the fault scenario. When set to ``true`` , the RDR will be turned on.
|
|
1157
|
+
When set to ``false`` , the RDR will be turned off.
|
|
1158
|
+
- mode: sets the mode of RDR on exporting data. When set to ``1`` , the RDR only exports data
|
|
1159
|
+
in the fault scenario. When set to ``2`` , the RDR exports data in the fault scenario and the
|
|
1160
|
+
normal end scenario. Default: ``1`` .
|
|
972
1161
|
- path: sets the path where RDR saves data. The current path must be absolute.
|
|
973
1162
|
|
|
974
1163
|
Memory reuse:
|
|
975
1164
|
|
|
976
|
-
- mem_Reuse: controls whether the memory reuse function is turned on. When set to True,
|
|
977
|
-
|
|
1165
|
+
- mem_Reuse: controls whether the memory reuse function is turned on. When set to ``True`` ,
|
|
1166
|
+
the memory reuse function is turned on. When set to ``False`` , the memory reuse function is turned off.
|
|
978
1167
|
|
|
979
|
-
precompile_only (bool): Whether to only precompile the network. Default: False.
|
|
980
|
-
If set to True, the network will only be compiled, not executed.
|
|
981
|
-
reserve_class_name_in_scope (bool) : Whether to save the network class name in the scope. Default: True.
|
|
1168
|
+
precompile_only (bool): Whether to only precompile the network. Default: ``False`` .
|
|
1169
|
+
If set to ``True`` , the network will only be compiled, not executed.
|
|
1170
|
+
reserve_class_name_in_scope (bool) : Whether to save the network class name in the scope. Default: ``True`` .
|
|
982
1171
|
Each node has a scope. A scope of a subnode is the name of its parent node. If reserve_class_name_in_scope
|
|
983
|
-
is set to True, the class name will be saved after keyword 'net-' in the scope.
|
|
1172
|
+
is set to ``True`` , the class name will be saved after keyword 'net-' in the scope.
|
|
984
1173
|
For example:
|
|
985
1174
|
|
|
986
1175
|
Default/net-Net1/net-Net2 (reserve_class_name_in_scope=True)
|
|
@@ -988,27 +1177,34 @@ def set_context(**kwargs):
|
|
|
988
1177
|
Default/net/net (reserve_class_name_in_scope=False)
|
|
989
1178
|
|
|
990
1179
|
pynative_synchronize (bool): Whether to enable synchronous execution of the device in PyNative mode.
|
|
991
|
-
Default: False. When the value is set to False, the operator is executed asynchronously on the
|
|
992
|
-
When an error occurs in the execution of the operator, the specific error script code location
|
|
993
|
-
be located, when the value is set to True, the operator is executed synchronously on the
|
|
994
|
-
reduce the execution performance of the program. At this time, when an error occurs in the
|
|
995
|
-
the operator, the location of the error script code can be located according to the call stack
|
|
1180
|
+
Default: ``False`` . When the value is set to ``False`` , the operator is executed asynchronously on the
|
|
1181
|
+
device. When an error occurs in the execution of the operator, the specific error script code location
|
|
1182
|
+
cannot be located, when the value is set to ``True`` , the operator is executed synchronously on the
|
|
1183
|
+
device. It will reduce the execution performance of the program. At this time, when an error occurs in the
|
|
1184
|
+
execution of the operator, the location of the error script code can be located according to the call stack
|
|
1185
|
+
of the error.
|
|
996
1186
|
mode (int): Running in GRAPH_MODE(0) or PYNATIVE_MODE(1).
|
|
997
|
-
Both modes support all backends. Default: PYNATIVE_MODE.
|
|
1187
|
+
Both modes support all backends. Default: ``PYNATIVE_MODE`` .
|
|
998
1188
|
enable_graph_kernel (bool): Whether to enable graph kernel fusion to optimize network execution performance.
|
|
999
|
-
Default: False.
|
|
1189
|
+
Default: ``False`` .
|
|
1000
1190
|
Indicates whether to enable image-computing convergence to optimize network execution performance.
|
|
1001
|
-
If enable_graph_kernel is set to True, acceleration can be enabled.
|
|
1191
|
+
If enable_graph_kernel is set to ``True`` , acceleration can be enabled.
|
|
1002
1192
|
For details of graph kernel fusion, please check
|
|
1003
1193
|
`Enabling Graph Kernel Fusion
|
|
1004
|
-
<https://www.mindspore.cn/tutorials/experts/en/r2.
|
|
1194
|
+
<https://www.mindspore.cn/tutorials/experts/en/r2.2/optimize/graph_fusion_engine.html>`_.
|
|
1005
1195
|
graph_kernel_flags (str):
|
|
1006
1196
|
Optimization options of graph kernel fusion, and the priority is higher when it conflicts
|
|
1007
1197
|
with enable_graph_kernel. Only for experienced users.
|
|
1008
|
-
For example,
|
|
1198
|
+
For example,
|
|
1199
|
+
|
|
1200
|
+
.. code-block::
|
|
1201
|
+
|
|
1202
|
+
mindspore.set_context(graph_kernel_flags="--opt_level=2 --dump_as_text")
|
|
1203
|
+
|
|
1204
|
+
Some general options:
|
|
1009
1205
|
|
|
1010
1206
|
- opt_level: Set the optimization level.
|
|
1011
|
-
Default: 2. Graph kernel fusion can be enabled equivalently by setting opt_level greater than 0.
|
|
1207
|
+
Default: ``2`` . Graph kernel fusion can be enabled equivalently by setting opt_level greater than 0.
|
|
1012
1208
|
Available values are:
|
|
1013
1209
|
|
|
1014
1210
|
- 0: disables graph kernel fusion;
|
|
@@ -1019,55 +1215,52 @@ def set_context(**kwargs):
|
|
|
1019
1215
|
ParallelFusion and so on. Optimizations of this level are radical and unstable in some scenarios.
|
|
1020
1216
|
Be caution when using this level.
|
|
1021
1217
|
|
|
1022
|
-
- dump_as_text: dumps detail info as text files. Default:
|
|
1218
|
+
- dump_as_text: dumps detail info as text files. Default: ``False`` .
|
|
1023
1219
|
|
|
1024
|
-
More options can refer to the implementation code.
|
|
1025
1220
|
enable_reduce_precision (bool): Whether to enable precision reduction.
|
|
1026
1221
|
If the operator does not support the user-specified precision, the precision will
|
|
1027
|
-
be changed automatically. Default: True.
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
`Enable the operator optimization tool
|
|
1039
|
-
<https://www.mindspore.cn/tutorials/experts/en/r2.0/debug/auto_tune.html>`_.
|
|
1222
|
+
be changed automatically. Default: ``True`` .
|
|
1223
|
+
aoe_tune_mode (str): AOE tuning mode setting, which is not set by default.
|
|
1224
|
+
When set to ``"online"`` , the tuning in online function is turned on.
|
|
1225
|
+
When set to ``"offline"`` , ge graph will be save for offline tuning.
|
|
1226
|
+
aoe_config (dict): Set the parameters specific to Ascend Optimization Engine. It is not set by default.
|
|
1227
|
+
|
|
1228
|
+
- job_type (str): Mode type setting, default value is ``"2"``.
|
|
1229
|
+
|
|
1230
|
+
- ``"1"``: subgraph tuning;
|
|
1231
|
+
- ``"2"``: operator tuning.
|
|
1232
|
+
|
|
1040
1233
|
check_bprop (bool): Whether to check back propagation nodes. The checking ensures that the shape and dtype
|
|
1041
|
-
of back propagation node outputs is the same as input parameters. Default: False.
|
|
1042
|
-
max_call_depth (int): Specify the maximum depth of function call. Must be positive integer. Default: 1000.
|
|
1234
|
+
of back propagation node outputs is the same as input parameters. Default: ``False`` .
|
|
1235
|
+
max_call_depth (int): Specify the maximum depth of function call. Must be positive integer. Default: ``1000`` .
|
|
1043
1236
|
The max_call_depth parameter needs to be set when the nested call is too deep or the number
|
|
1044
1237
|
of subgraphs is too large. If max_call_depth is set larger than before, the system max stack depth should be
|
|
1045
1238
|
set larger too, otherwise a `core dumped` exception may be raised because of system stack overflow.
|
|
1046
|
-
grad_for_scalar (bool): Whether to get gradient for scalar. Default: False.
|
|
1047
|
-
When grad_for_scalar is set to True, the function's scalar input can be derived.
|
|
1048
|
-
The default value is False. Because the back-end does not support scaling operations currently,
|
|
1239
|
+
grad_for_scalar (bool): Whether to get gradient for scalar. Default: ``False`` .
|
|
1240
|
+
When grad_for_scalar is set to ``True`` , the function's scalar input can be derived.
|
|
1241
|
+
The default value is ``False`` . Because the back-end does not support scaling operations currently,
|
|
1049
1242
|
this interface only supports simple operations that can be deduced by the front-end.
|
|
1050
1243
|
enable_compile_cache (bool): Whether to save or load the cache of the graph compiled by front-end.
|
|
1051
|
-
After enable_compile_cache is set to True, during the first execution, a hardware-independent
|
|
1244
|
+
After enable_compile_cache is set to ``True`` , during the first execution, a hardware-independent
|
|
1052
1245
|
compilation cache is generated and exported to a MINDIR file. When the network is executed again,
|
|
1053
|
-
if enable_compile_cache is still set to True and the network scripts are not changed,
|
|
1246
|
+
if enable_compile_cache is still set to ``True`` and the network scripts are not changed,
|
|
1054
1247
|
the compile cache is loaded. Note that only limited automatic detection for the changes of
|
|
1055
|
-
python scripts is supported by now, which means that there is a correctness risk. Default: False.
|
|
1248
|
+
python scripts is supported by now, which means that there is a correctness risk. Default: ``False`` .
|
|
1056
1249
|
This is an experimental prototype that is subject to change and/or deletion.
|
|
1057
1250
|
compile_cache_path (str): Path to save the compile cache. Default: ".".
|
|
1058
1251
|
If the specified directory does not exist, the system will automatically create the directory.
|
|
1059
1252
|
The cache will be saved to the directory of `compile_cache_path/rank_${rank_id}/`. The `rank_id` is
|
|
1060
1253
|
the ID of the current device in the cluster.
|
|
1061
|
-
inter_op_parallel_num(int): The thread number of op parallel at the same time. Default value is 0,
|
|
1254
|
+
inter_op_parallel_num(int): The thread number of op parallel at the same time. Default value is ``0`` ,
|
|
1062
1255
|
which means use the default num.
|
|
1063
1256
|
runtime_num_threads(int): The thread pool number of cpu kernel used in runtime,
|
|
1064
|
-
which must bigger than or equal to 0. Default value is 30, if you run many processes at
|
|
1257
|
+
which must bigger than or equal to 0. Default value is ``30`` , if you run many processes at
|
|
1065
1258
|
the same time, you should set the value smaller to avoid thread contention.
|
|
1066
1259
|
disable_format_transform (bool): Whether to disable the automatic format transform function from NCHW to NHWC.
|
|
1067
|
-
When the network training performance of fp16 is worse than fp32,
|
|
1068
|
-
|
|
1260
|
+
When the network training performance of fp16 is worse than fp32, `disable_format_transform` can be set to
|
|
1261
|
+
``True`` to try to improve training performance. Default: ``False`` .
|
|
1069
1262
|
support_binary (bool): Whether to support run .pyc or .so in graph mode. If want to support run .so or .pyc
|
|
1070
|
-
in graph mode, coulde set 'support_binary' to be True, and run once .py file. It would save the source
|
|
1263
|
+
in graph mode, coulde set 'support_binary' to be ``True`` , and run once .py file. It would save the source
|
|
1071
1264
|
of the interfaces would be compiled by MindSpore to the interfaces definition .py file that should be
|
|
1072
1265
|
guaranteed to be writable. Then compile the .py file to the .pyc or .so file, and could run in Graph mode.
|
|
1073
1266
|
memory_optimize_level (str): The memory optimize level.
|
|
@@ -1077,20 +1270,20 @@ def set_context(**kwargs):
|
|
|
1077
1270
|
- O1: priority memory option, enable SOMAS.
|
|
1078
1271
|
memory_offload (str): Whether to enable the memory offload function. When it is enabled, the idle data will be
|
|
1079
1272
|
temporarily copied to the host side in the case of insufficient device memory. The value must be in the
|
|
1080
|
-
range of ['ON', 'OFF'], and the default value is 'OFF'.
|
|
1273
|
+
range of ['ON', 'OFF'], and the default value is ``'OFF'`` .
|
|
1081
1274
|
|
|
1082
1275
|
- ON: Enable the memory Offload function. On Ascend hardware platform, this parameter does not take effect
|
|
1083
1276
|
when the environment variable "GRAPH_OP_RUN=1" is not set; This parameter does not take effect when
|
|
1084
1277
|
memory_optimize_level is set 'O1'.
|
|
1085
1278
|
- OFF: Turn off the memory Offload function.
|
|
1086
1279
|
ascend_config (dict): Set the parameters specific to Ascend hardware platform. It is not set by default.
|
|
1087
|
-
Currently,
|
|
1088
|
-
The default value of `precision_mode
|
|
1089
|
-
in the future.
|
|
1280
|
+
Currently, configurations except `parallel_speed_up_json_path` and `precision_mode.force_fp32` are only
|
|
1281
|
+
supported on Ascend910B hardware platform. The default value of `precision_mode`, `jit_compile` and
|
|
1282
|
+
`atomic_clean_policy` are experimental parameters, may change in the future.
|
|
1090
1283
|
|
|
1091
1284
|
- precision_mode (str): Mixed precision mode setting, on Ascend910B hardware platform, the default
|
|
1092
1285
|
value of training network is based on the value of CANN, and the default value of inference network
|
|
1093
|
-
is force_fp16. The value range is as follows:
|
|
1286
|
+
is ``force_fp16`` . The value range is as follows:
|
|
1094
1287
|
|
|
1095
1288
|
- force_fp16: When the operator supports both float16 and float32, select float16 directly.
|
|
1096
1289
|
- allow_fp32_to_fp16: When the operator does not support the float32 data type, directly reduce
|
|
@@ -1101,18 +1294,123 @@ def set_context(**kwargs):
|
|
|
1101
1294
|
- must_keep_origin_dtype: Keep the accuracy of the original drawing.
|
|
1102
1295
|
- force_fp32: When the input of the matrix calculation operator is float16 and the output supports
|
|
1103
1296
|
float16 and float32, output is forced to float32.
|
|
1104
|
-
- force_lowerprecision: When the operator supports both float16 or bfloat16 and float32, select
|
|
1105
|
-
float16 or bfloat16 directly.
|
|
1106
1297
|
- allow_fp32_to_bf16: When the operator does not support the float32 data type, directly reduce
|
|
1107
1298
|
the precision of bfloat16.
|
|
1108
|
-
- allow_fp32_to_lowprecision: When the operator does not support the float32 data type, directly
|
|
1109
|
-
reduce the precision of float16 or bfloat16.
|
|
1110
1299
|
- allow_mix_precision_fp16: Automatic mixing precision, facing the whole network operator, automatically
|
|
1111
1300
|
reduces the precision of some operators to float16 according to the built-in optimization strategy.
|
|
1112
1301
|
- allow_mix_precision_bf16: Automatic mixing precision, facing the whole network operator, according to
|
|
1113
1302
|
the built-in optimization strategy, automatically reduces the precision of some operators to bfloat16.
|
|
1114
1303
|
|
|
1115
1304
|
- jit_compile (bool): Whether to select online compilation. the default value is based on CANN.
|
|
1305
|
+
- atomic_clean_policy (int): The policy for cleaning memory occupied by atomic operators in the network.
|
|
1306
|
+
Default: ``1`` .
|
|
1307
|
+
|
|
1308
|
+
- 0: The memory occupied by all atomic operators in the network is cleaned centrally.
|
|
1309
|
+
- 1: Memory is not cleaned centrally and each atomic operator in the network is cleaned separately.
|
|
1310
|
+
When the memory of the network exceeds the limit, you may try this cleaning policy, but it may cause
|
|
1311
|
+
performance loss.
|
|
1312
|
+
- matmul_allow_hf32 (bool): Whether to convert FP32 to HF32 for Matmul operators. Default value: ``False``.
|
|
1313
|
+
This is an experimental prototype that is subject to change and/or deletion.
|
|
1314
|
+
For detailed information, please refer to `Ascend community <https://www.hiascend.com/>`_ .
|
|
1315
|
+
- conv_allow_hf32 (bool): Whether to convert FP32 to HF32 for Conv operators. Default value: ``True``.
|
|
1316
|
+
This is an experimental prototype that is subject to change and/or deletion.
|
|
1317
|
+
For detailed information, please refer to `Ascend community <https://www.hiascend.com/>`_ .
|
|
1318
|
+
- op_precision_mode (str): Path to config file of op precision mode. For detailed information, please refer
|
|
1319
|
+
to `Ascend community <https://www.hiascend.com/>`_ .
|
|
1320
|
+
- parallel_speed_up_json_path(Union[str, None]): The path to the parallel speed up json file, configuration
|
|
1321
|
+
can refer to `parallel_speed_up.json
|
|
1322
|
+
<https://gitee.com/mindspore/mindspore/blob/r2.2/config/parallel_speed_up.json>`_ .
|
|
1323
|
+
If its value is None or '', it does not take effect. Default None.
|
|
1324
|
+
|
|
1325
|
+
- recompute_comm_overlap (bool): Enable overlap between recompute ops and communication ops if True.
|
|
1326
|
+
Default: False.
|
|
1327
|
+
- matmul_grad_comm_overlap (bool): Enable overlap between grad ops and communication ops if True.
|
|
1328
|
+
Default: False.
|
|
1329
|
+
- enable_task_opt (bool): Enable the optimization of the number of tasks for each communication if True.
|
|
1330
|
+
Default: False.
|
|
1331
|
+
- interleaved_matmul_comm (bool): Enable interleaved optimization of Matmul-Comm if True. Default: False.
|
|
1332
|
+
- interleaved_layernorm_comm (bool): Enable interleaved optimization of LayerNorm-Comm if True.
|
|
1333
|
+
Default: False.
|
|
1334
|
+
|
|
1335
|
+
jit_syntax_level (int): Set JIT syntax level for graph compiling, triggered by GRAPH_MODE and @jit decorator.
|
|
1336
|
+
The value must be ``STRICT`` or ``LAX`` . Default: ``LAX`` . All levels support all backends.
|
|
1337
|
+
|
|
1338
|
+
- ``STRICT`` : Only basic syntax is supported, and execution performance is optimal. Can be used for MindIR
|
|
1339
|
+
load and export.
|
|
1340
|
+
- ``LAX`` : Compatible with all Python syntax as much as possible. However, execution performance may be
|
|
1341
|
+
affected and not optimal. Cannot be used for MindIR load and export due to some syntax that may not be
|
|
1342
|
+
able to be exported.
|
|
1343
|
+
|
|
1344
|
+
gpu_config (dict): Set the parameters specific to gpu hardware platform. It is not set by default.
|
|
1345
|
+
Currently, only setting `conv_fprop_algo` and `conv_dgrad_algo` and `conv_wgrad_algo` and `conv_allow_tf32`
|
|
1346
|
+
and `matmul_allow_tf32` are supported on GPU hardware platform.
|
|
1347
|
+
|
|
1348
|
+
- conv_fprop_algo (str): Specifies convolution forward algorithm and the default value is 'normal',
|
|
1349
|
+
The value range is as follows:
|
|
1350
|
+
|
|
1351
|
+
- normal: Use the heuristic search algorithm.
|
|
1352
|
+
- performance: Use the trial search algorithm.
|
|
1353
|
+
- implicit_gemm: This algorithm expresses the convolution as a matrix product without actually explicitly
|
|
1354
|
+
forming the matrix that holds the input tensor data.
|
|
1355
|
+
- implicit_precomp_gemm: This algorithm expresses convolution as a matrix product without actually
|
|
1356
|
+
explicitly forming the matrix that holds the input tensor data, but still needs some memory workspace to
|
|
1357
|
+
precompute some indices in order to facilitate the implicit construction of the matrix that holds the
|
|
1358
|
+
input tensor data.
|
|
1359
|
+
- gemm: This algorithm expresses the convolution as an explicit matrix product. A significant memory
|
|
1360
|
+
workspace is needed to store the matrix that holds the input tensor data.
|
|
1361
|
+
- direct: This algorithm expresses the convolution as a direct convolution (for example, without
|
|
1362
|
+
implicitly or explicitly doing a matrix multiplication).
|
|
1363
|
+
- fft: This algorithm uses the Fast-Fourier Transform approach to compute the convolution. A significant
|
|
1364
|
+
memory workspace is needed to store intermediate results.
|
|
1365
|
+
- fft_tiling: This algorithm uses the Fast-Fourier Transform approach but splits the inputs into tiles.
|
|
1366
|
+
A significant memory workspace is needed to store intermediate results but less than fft algorithm for
|
|
1367
|
+
large size images.
|
|
1368
|
+
- winograd: This algorithm uses the Winograd Transform approach to compute the convolution. A reasonably
|
|
1369
|
+
sized workspace is needed to store intermediate results.
|
|
1370
|
+
- winograd_nonfused: This algorithm uses the Winograd Transform approach to compute the convolution. A
|
|
1371
|
+
significant workspace may be needed to store intermediate results.
|
|
1372
|
+
- conv_dgrad_algo (str): Specifies convolution data grad algorithm and the default value is 'normal',
|
|
1373
|
+
The value range is as follows:
|
|
1374
|
+
|
|
1375
|
+
- normal: Use the heuristic search algorithm.
|
|
1376
|
+
- performance: Use the trial search algorithm.
|
|
1377
|
+
- algo_0: This algorithm expresses the convolution as a sum of matrix products without actually explicitly
|
|
1378
|
+
forming the matrix that holds the input tensor data. The sum is done using the atomic add operation,
|
|
1379
|
+
thus the results are non-deterministic.
|
|
1380
|
+
- algo_1: This algorithm expresses the convolution as a matrix product without actually explicitly forming
|
|
1381
|
+
the matrix that holds the input tensor data. The results are deterministic.
|
|
1382
|
+
- fft: This algorithm uses a Fast-Fourier Transform approach to compute the convolution. A significant
|
|
1383
|
+
memory workspace is needed to store intermediate results. The results are deterministic.
|
|
1384
|
+
- fft_tiling: This algorithm uses the Fast-Fourier Transform approach but splits the inputs into tiles.
|
|
1385
|
+
A significant memory workspace is needed to store intermediate results but less than fft for large size
|
|
1386
|
+
images. The results are deterministic.
|
|
1387
|
+
- winograd: This algorithm uses the Winograd Transform approach to compute the convolution. A reasonably
|
|
1388
|
+
sized workspace is needed to store intermediate results. The results are deterministic.
|
|
1389
|
+
- winograd_nonfused: This algorithm uses the Winograd Transform approach to compute the convolution.
|
|
1390
|
+
A significant workspace may be needed to store intermediate results. The results are deterministic.
|
|
1391
|
+
- conv_wgrad_algo (str): Specifies convolution filter grad algorithm and the default value is 'normal',
|
|
1392
|
+
The value range is as follows:
|
|
1393
|
+
|
|
1394
|
+
- normal: Use the heuristic search algorithm.
|
|
1395
|
+
- performance: Use the trial search algorithm.
|
|
1396
|
+
- algo_0: This algorithm expresses the convolution as a sum of matrix products without actually explicitly
|
|
1397
|
+
forming the matrix that holds the input tensor data. The sum is done using the atomic add operation,
|
|
1398
|
+
thus the results are non-deterministic.
|
|
1399
|
+
- algo_1: This algorithm expresses the convolution as a matrix product without actually explicitly forming
|
|
1400
|
+
the matrix that holds the input tensor data. The results are deterministic.
|
|
1401
|
+
- fft: This algorithm uses a Fast-Fourier Transform approach to compute the convolution. A significant
|
|
1402
|
+
memory workspace is needed to store intermediate results. The results are deterministic.
|
|
1403
|
+
- algo_3: This algorithm is similar to algo_0 but uses some small workspace to precompute some indices.
|
|
1404
|
+
The results are also non-deterministic.
|
|
1405
|
+
- winograd_nonfused: This algorithm uses the Winograd Transform approach to compute the convolution.
|
|
1406
|
+
A significant workspace may be needed to store intermediate results. The results are deterministic.
|
|
1407
|
+
- fft_tiling: This algorithm uses the Fast-Fourier Transform approach but splits the inputs into tiles.
|
|
1408
|
+
A significant memory workspace is needed to store intermediate results but less than fft for large size
|
|
1409
|
+
images. The results are deterministic.
|
|
1410
|
+
- conv_allow_tf32 (bool): The flag below controls to allow Tensor core TF32 computation on CUDNN and the
|
|
1411
|
+
default value is ``True``.
|
|
1412
|
+
- matmul_allow_tf32 (bool): The flag below controls to allow Tensor core TF32 computation on CUBLAS and the
|
|
1413
|
+
default value is ``False``.
|
|
1116
1414
|
|
|
1117
1415
|
Raises:
|
|
1118
1416
|
ValueError: If input key is not an attribute in context.
|
|
@@ -1129,13 +1427,14 @@ def set_context(**kwargs):
|
|
|
1129
1427
|
>>> ms.set_context(graph_kernel_flags="--opt_level=2 --dump_as_text")
|
|
1130
1428
|
>>> ms.set_context(reserve_class_name_in_scope=True)
|
|
1131
1429
|
>>> ms.set_context(variable_memory_max_size="6GB")
|
|
1430
|
+
>>> ms.set_context(aoe_tune_mode="online")
|
|
1431
|
+
>>> ms.set_context(aoe_config={"job_type": "2"})
|
|
1132
1432
|
>>> ms.set_context(check_bprop=True)
|
|
1133
1433
|
>>> ms.set_context(max_device_memory="3.5GB")
|
|
1134
1434
|
>>> ms.set_context(mempool_block_size="1GB")
|
|
1135
1435
|
>>> ms.set_context(print_file_path="print.pb")
|
|
1136
1436
|
>>> ms.set_context(max_call_depth=80)
|
|
1137
1437
|
>>> ms.set_context(env_config_path="./env_config.json")
|
|
1138
|
-
>>> ms.set_context(auto_tune_mode="GA,RL")
|
|
1139
1438
|
>>> ms.set_context(grad_for_scalar=True)
|
|
1140
1439
|
>>> ms.set_context(enable_compile_cache=True, compile_cache_path="./cache.ms")
|
|
1141
1440
|
>>> ms.set_context(pynative_synchronize=True)
|
|
@@ -1145,7 +1444,11 @@ def set_context(**kwargs):
|
|
|
1145
1444
|
>>> ms.set_context(memory_optimize_level='O0')
|
|
1146
1445
|
>>> ms.set_context(memory_offload='ON')
|
|
1147
1446
|
>>> ms.set_context(deterministic='ON')
|
|
1148
|
-
>>> ms.set_context(ascend_config={"precision_mode": "force_fp16", "jit_compile": True
|
|
1447
|
+
>>> ms.set_context(ascend_config={"precision_mode": "force_fp16", "jit_compile": True,
|
|
1448
|
+
... "atomic_clean_policy": 1, "op_precision_mode": "./op_precision_config_file"})
|
|
1449
|
+
>>> ms.set_context(jit_syntax_level=ms.STRICT)
|
|
1450
|
+
>>> ms.set_context(gpu_config={"conv_fprop_algo": "performance", "conv_allow_tf32": True,
|
|
1451
|
+
... "matmul_allow_tf32": True})
|
|
1149
1452
|
"""
|
|
1150
1453
|
ctx = _context()
|
|
1151
1454
|
# set device target first
|
|
@@ -1153,7 +1456,7 @@ def set_context(**kwargs):
|
|
|
1153
1456
|
ctx.set_device_target(kwargs['device_target'])
|
|
1154
1457
|
device = ctx.get_param(ms_ctx_param.device_target)
|
|
1155
1458
|
for key, value in kwargs.items():
|
|
1156
|
-
if key
|
|
1459
|
+
if key in ('enable_sparse', 'auto_tune_mode'):
|
|
1157
1460
|
logger.warning(f"For 'context.set_context', '{key}' parameter is deprecated, "
|
|
1158
1461
|
"and will be removed in the next version.")
|
|
1159
1462
|
continue
|
|
@@ -1161,7 +1464,8 @@ def set_context(**kwargs):
|
|
|
1161
1464
|
logger.warning(f"For 'context.set_context', '{key}' parameter is deprecated. "
|
|
1162
1465
|
"For details, please see the interface parameter API comments")
|
|
1163
1466
|
continue
|
|
1164
|
-
if key in ('precision_mode', 'jit_compile'
|
|
1467
|
+
if key in ('precision_mode', 'jit_compile', 'atomic_clean_policy', 'matmul_allow_hf32', 'conv_allow_hf32',
|
|
1468
|
+
'op_precision_mode'):
|
|
1165
1469
|
raise ValueError(f"Please set '{key}' through parameter ascend_config")
|
|
1166
1470
|
if key == 'save_graphs':
|
|
1167
1471
|
if value is True:
|
|
@@ -1170,6 +1474,9 @@ def set_context(**kwargs):
|
|
|
1170
1474
|
value = 0
|
|
1171
1475
|
if value > 3:
|
|
1172
1476
|
raise ValueError(f"value for save_graphs should be 0-3 but got '{value}'")
|
|
1477
|
+
if key == 'jit_syntax_level' and value not in (STRICT, COMPATIBLE, LAX):
|
|
1478
|
+
raise ValueError(f"For 'jit_syntax_level', the value should be context.STRICT"
|
|
1479
|
+
f" or context.LAX, but got {value}.")
|
|
1173
1480
|
if not _check_target_specific_cfgs(device, key):
|
|
1174
1481
|
continue
|
|
1175
1482
|
if hasattr(ctx, key):
|
|
@@ -1231,16 +1538,16 @@ class ParallelMode:
|
|
|
1231
1538
|
"""
|
|
1232
1539
|
Parallel mode options.
|
|
1233
1540
|
|
|
1234
|
-
There are five kinds of parallel modes,
|
|
1235
|
-
|
|
1541
|
+
There are five kinds of parallel modes, ``STAND_ALONE``, ``DATA_PARALLEL``,
|
|
1542
|
+
``HYBRID_PARALLEL``, ``SEMI_AUTO_PARALLEL`` and ``AUTO_PARALLEL``. Default: ``STAND_ALONE``.
|
|
1236
1543
|
|
|
1237
|
-
- STAND_ALONE
|
|
1238
|
-
- DATA_PARALLEL
|
|
1239
|
-
- HYBRID_PARALLEL
|
|
1240
|
-
- SEMI_AUTO_PARALLEL
|
|
1241
|
-
- AUTO_PARALLEL
|
|
1544
|
+
- ``STAND_ALONE``: Only one processor is working.
|
|
1545
|
+
- ``DATA_PARALLEL``: Distributes the data across different processors.
|
|
1546
|
+
- ``HYBRID_PARALLEL``: Achieves data parallelism and model parallelism manually.
|
|
1547
|
+
- ``SEMI_AUTO_PARALLEL``: Achieves data parallelism and model parallelism by setting parallel strategies.
|
|
1548
|
+
- ``AUTO_PARALLEL``: Achieves parallelism automatically.
|
|
1242
1549
|
|
|
1243
|
-
MODE_LIST
|
|
1550
|
+
``MODE_LIST``: The list of all supported parallel modes.
|
|
1244
1551
|
"""
|
|
1245
1552
|
|
|
1246
1553
|
STAND_ALONE = "stand_alone"
|
|
@@ -1261,32 +1568,26 @@ def set_ps_context(**kwargs):
|
|
|
1261
1568
|
Some other environment variables should also be set for parameter server training mode.
|
|
1262
1569
|
These environment variables are listed below:
|
|
1263
1570
|
|
|
1264
|
-
MS_SERVER_NUM: Server number
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
MS_SCHED_PORT: Scheduler port
|
|
1571
|
+
- MS_SERVER_NUM: Server number
|
|
1572
|
+
- MS_WORKER_NUM: Worker number
|
|
1573
|
+
- MS_SCHED_HOST: Scheduler IP address
|
|
1574
|
+
- MS_SCHED_PORT: Scheduler port
|
|
1575
|
+
- MS_ROLE: The role of this process:
|
|
1271
1576
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
MS_WORKER: represents the worker,
|
|
1277
|
-
|
|
1278
|
-
MS_PSERVER/MS_SERVER: represents the Server
|
|
1577
|
+
- MS_SCHED: represents the scheduler,
|
|
1578
|
+
- MS_WORKER: represents the worker,
|
|
1579
|
+
- MS_PSERVER/MS_SERVER: represents the Server
|
|
1279
1580
|
|
|
1280
1581
|
Args:
|
|
1281
1582
|
enable_ps (bool): Whether to enable parameter server training mode.
|
|
1282
1583
|
Only after enable_ps is set True, the environment variables will be effective.
|
|
1283
|
-
Default: False.
|
|
1584
|
+
Default: ``False`` .
|
|
1284
1585
|
config_file_path (string): Configuration file path used by recovery, parameter server training mode only
|
|
1285
|
-
supports Server disaster recovery currently. Default: ''.
|
|
1286
|
-
scheduler_manage_port (int): Scheduler manage port used to scale out/in. Default: 11202.
|
|
1287
|
-
enable_ssl (bool): Set PS SSL mode enabled or disabled. Default: False.
|
|
1288
|
-
client_password (str): Password to decrypt the secret key stored in the client certificate. Default: ''.
|
|
1289
|
-
server_password (str): Password to decrypt the secret key stored in the server certificate. Default: ''.
|
|
1586
|
+
supports Server disaster recovery currently. Default: ``''`` .
|
|
1587
|
+
scheduler_manage_port (int): Scheduler manage port used to scale out/in. Default: ``11202`` .
|
|
1588
|
+
enable_ssl (bool): Set PS SSL mode enabled or disabled. Default: ``False`` .
|
|
1589
|
+
client_password (str): Password to decrypt the secret key stored in the client certificate. Default: ``''`` .
|
|
1590
|
+
server_password (str): Password to decrypt the secret key stored in the server certificate. Default: ``''`` .
|
|
1290
1591
|
|
|
1291
1592
|
Raises:
|
|
1292
1593
|
ValueError: If input key is not the attribute in parameter server training mode context.
|
|
@@ -1305,13 +1606,15 @@ def get_ps_context(attr_key):
|
|
|
1305
1606
|
Args:
|
|
1306
1607
|
attr_key (str): The key of the attribute:
|
|
1307
1608
|
|
|
1308
|
-
- enable_ps (bool): Whether to enable parameter server training mode.
|
|
1609
|
+
- enable_ps (bool): Whether to enable parameter server training mode. Default: ``False`` .
|
|
1309
1610
|
- config_file_path (string): Configuration file path used by recovery, parameter server training mode only
|
|
1310
|
-
supports Server disaster recovery currently. Default: ''.
|
|
1311
|
-
- scheduler_manage_port (int): Scheduler manage port used to scale out/in. Default: 11202.
|
|
1312
|
-
- enable_ssl (bool): Set PS SSL mode enabled or disabled. Default: False.
|
|
1313
|
-
- client_password (str): Password to decrypt the secret key stored in the client certificate.
|
|
1314
|
-
|
|
1611
|
+
supports Server disaster recovery currently. Default: ``''`` .
|
|
1612
|
+
- scheduler_manage_port (int): Scheduler manage port used to scale out/in. Default: ``11202`` .
|
|
1613
|
+
- enable_ssl (bool): Set PS SSL mode enabled or disabled. Default: ``False`` .
|
|
1614
|
+
- client_password (str): Password to decrypt the secret key stored in the client certificate.
|
|
1615
|
+
Default: ``''`` .
|
|
1616
|
+
- server_password (str): Password to decrypt the secret key stored in the server certificate.
|
|
1617
|
+
Default: ``''`` .
|
|
1315
1618
|
|
|
1316
1619
|
Returns:
|
|
1317
1620
|
Returns attribute value according to the key.
|
|
@@ -1333,6 +1636,10 @@ def reset_ps_context():
|
|
|
1333
1636
|
- enable_ps: False.
|
|
1334
1637
|
|
|
1335
1638
|
Meaning of each field and its default value refer to :func:`mindspore.set_ps_context`.
|
|
1639
|
+
|
|
1640
|
+
Examples:
|
|
1641
|
+
>>> import mindspore as ms
|
|
1642
|
+
>>> ms.reset_ps_context()
|
|
1336
1643
|
"""
|
|
1337
1644
|
_reset_ps_context()
|
|
1338
1645
|
|