mindspore 2.1.0__cp38-cp38-win_amd64.whl → 2.2.11__cp38-cp38-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +4 -1
- mindspore/_c_dataengine.cp38-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp38-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp38-win_amd64.pyd +0 -0
- mindspore/_check_jit_forbidden_api.py +3 -1
- mindspore/_checkparam.py +23 -29
- mindspore/_extends/graph_kernel/__init__.py +0 -1
- mindspore/_extends/graph_kernel/model/graph_split.py +84 -76
- mindspore/_extends/graph_kernel/model/model_builder.py +9 -50
- mindspore/_extends/graph_kernel/splitter.py +4 -11
- mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +122 -15
- mindspore/_extends/parallel_compile/akg_compiler/build_tbe_kernel.py +84 -67
- mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +4 -2
- mindspore/_extends/parallel_compile/akg_compiler/util.py +10 -7
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +2 -2
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +6 -5
- 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 +13 -15
- mindspore/_extends/parse/namespace.py +7 -33
- mindspore/_extends/parse/parser.py +67 -72
- mindspore/_extends/parse/resources.py +1 -1
- mindspore/_extends/parse/standard_method.py +86 -106
- mindspore/_extends/parse/trope.py +1 -1
- mindspore/_extends/remote/kernel_build_server.py +25 -7
- mindspore/_extends/remote/kernel_build_server_akg_v2.py +55 -0
- mindspore/_install_custom.py +43 -0
- mindspore/amp.py +47 -11
- mindspore/atlprov.dll +0 -0
- mindspore/boost/boost.py +1 -8
- mindspore/boost/boost_cell_wrapper.py +3 -2
- mindspore/boost/grad_accumulation.py +1 -1
- mindspore/boost/group_loss_scale_manager.py +8 -7
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/common/__init__.py +5 -3
- mindspore/common/_jit_fallback_utils.py +6 -0
- mindspore/common/_register_for_adapter.py +2 -0
- mindspore/common/_register_for_tensor.py +2 -2
- mindspore/common/_stub_tensor.py +13 -0
- mindspore/common/_utils.py +29 -0
- mindspore/common/api.py +174 -259
- mindspore/common/auto_dynamic_shape.py +494 -0
- mindspore/common/dtype.py +18 -11
- mindspore/common/dump.py +6 -4
- mindspore/common/initializer.py +14 -14
- mindspore/common/jit_config.py +33 -15
- mindspore/common/lazy_inline.py +126 -7
- mindspore/common/mindir_util.py +101 -0
- mindspore/common/parameter.py +51 -41
- mindspore/common/seed.py +4 -4
- mindspore/common/sparse_tensor.py +13 -14
- mindspore/common/tensor.py +243 -165
- mindspore/communication/__init__.py +7 -4
- mindspore/communication/_comm_helper.py +83 -4
- mindspore/communication/management.py +152 -84
- mindspore/config/op_info.config +14 -3
- mindspore/context.py +152 -61
- mindspore/dataset/__init__.py +5 -5
- mindspore/dataset/audio/__init__.py +2 -2
- mindspore/dataset/audio/transforms.py +52 -52
- mindspore/dataset/callback/ds_callback.py +16 -2
- mindspore/dataset/core/config.py +68 -51
- mindspore/dataset/engine/cache_client.py +33 -7
- mindspore/dataset/engine/datasets.py +250 -112
- mindspore/dataset/engine/datasets_audio.py +43 -211
- mindspore/dataset/engine/datasets_standard_format.py +16 -35
- mindspore/dataset/engine/datasets_text.py +43 -67
- mindspore/dataset/engine/datasets_user_defined.py +86 -100
- mindspore/dataset/engine/datasets_vision.py +219 -1029
- mindspore/dataset/engine/iterators.py +11 -4
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +4 -0
- mindspore/dataset/engine/obs/util.py +3 -0
- mindspore/dataset/engine/samplers.py +1 -1
- mindspore/dataset/engine/validators.py +19 -5
- mindspore/dataset/text/__init__.py +3 -3
- mindspore/dataset/text/transforms.py +101 -127
- mindspore/dataset/text/utils.py +205 -138
- mindspore/dataset/transforms/__init__.py +1 -1
- mindspore/dataset/transforms/py_transforms_util.py +40 -12
- mindspore/dataset/transforms/transforms.py +95 -40
- mindspore/dataset/utils/browse_dataset.py +8 -2
- mindspore/dataset/utils/line_reader.py +17 -19
- mindspore/dataset/vision/__init__.py +3 -3
- mindspore/dataset/vision/c_transforms.py +6 -3
- mindspore/dataset/vision/transforms.py +409 -287
- mindspore/dataset/vision/utils.py +13 -14
- mindspore/dataset/vision/validators.py +11 -1
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/map_parameter.py +14 -0
- mindspore/{nn/optim_ex → experimental/optim}/__init__.py +30 -29
- mindspore/{nn/optim_ex → experimental/optim}/adam.py +60 -67
- mindspore/{nn/optim_ex → experimental/optim}/adamw.py +181 -203
- mindspore/experimental/optim/lr_scheduler.py +1427 -0
- mindspore/{nn/optim_ex → experimental/optim}/optimizer.py +252 -259
- mindspore/{nn/optim_ex → experimental/optim}/sgd.py +147 -152
- mindspore/gen_ops.py +273 -0
- mindspore/include/OWNERS +0 -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 +17 -14
- mindspore/include/api/status.h +8 -3
- mindspore/include/api/types.h +37 -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/dataset/constants.h +6 -5
- mindspore/include/dataset/execute.h +23 -13
- mindspore/include/dataset/text.h +26 -26
- mindspore/include/dataset/transforms.h +13 -13
- mindspore/include/dataset/vision.h +60 -60
- mindspore/include/dataset/vision_ascend.h +5 -6
- mindspore/include/dataset/vision_lite.h +17 -17
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/imagenet_to_mr.py +1 -1
- mindspore/mindrecord/tools/mnist_to_mr.py +2 -2
- mindspore/mindspore_backend.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_shared_lib.dll +0 -0
- mindspore/msobj140.dll +0 -0
- mindspore/mspdb140.dll +0 -0
- mindspore/mspdbcore.dll +0 -0
- mindspore/mspdbst.dll +0 -0
- mindspore/mspft140.dll +0 -0
- mindspore/msvcdis140.dll +0 -0
- mindspore/msvcp140_1.dll +0 -0
- mindspore/msvcp140_2.dll +0 -0
- mindspore/msvcp140_atomic_wait.dll +0 -0
- mindspore/msvcp140_codecvt_ids.dll +0 -0
- mindspore/nn/__init__.py +0 -2
- mindspore/nn/cell.py +313 -74
- mindspore/nn/dynamic_lr.py +21 -21
- mindspore/nn/layer/activation.py +22 -30
- mindspore/nn/layer/basic.py +15 -13
- mindspore/nn/layer/channel_shuffle.py +1 -1
- mindspore/nn/layer/container.py +271 -9
- mindspore/nn/layer/conv.py +323 -204
- mindspore/nn/layer/dense.py +8 -5
- mindspore/nn/layer/embedding.py +33 -27
- mindspore/nn/layer/flash_attention.py +61 -95
- mindspore/nn/layer/image.py +8 -6
- mindspore/nn/layer/math.py +16 -25
- mindspore/nn/layer/normalization.py +107 -66
- mindspore/nn/layer/padding.py +1 -1
- mindspore/nn/layer/pooling.py +131 -109
- mindspore/nn/layer/rnn_cells.py +27 -22
- mindspore/nn/layer/rnns.py +13 -16
- mindspore/nn/layer/thor_layer.py +1 -1
- mindspore/nn/layer/transformer.py +221 -154
- mindspore/nn/learning_rate_schedule.py +9 -1
- mindspore/nn/loss/loss.py +235 -174
- mindspore/nn/optim/ada_grad.py +2 -1
- mindspore/nn/optim/adadelta.py +1 -0
- mindspore/nn/optim/adafactor.py +2 -1
- mindspore/nn/optim/adam.py +7 -4
- mindspore/nn/optim/adamax.py +3 -2
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/asgd.py +2 -3
- mindspore/nn/optim/ftrl.py +6 -5
- mindspore/nn/optim/lamb.py +7 -4
- mindspore/nn/optim/lars.py +1 -1
- mindspore/nn/optim/lazyadam.py +5 -3
- mindspore/nn/optim/momentum.py +2 -1
- mindspore/nn/optim/optimizer.py +53 -4
- mindspore/nn/optim/proximal_ada_grad.py +3 -4
- mindspore/nn/optim/rmsprop.py +4 -3
- mindspore/nn/optim/rprop.py +23 -12
- mindspore/nn/optim/sgd.py +26 -11
- mindspore/nn/optim/thor.py +9 -7
- mindspore/nn/probability/bijector/bijector.py +5 -5
- mindspore/nn/probability/bijector/power_transform.py +27 -27
- mindspore/nn/probability/bijector/softplus.py +3 -3
- mindspore/nn/probability/distribution/_utils/custom_ops.py +3 -3
- mindspore/nn/probability/distribution/bernoulli.py +5 -5
- mindspore/nn/probability/distribution/beta.py +3 -3
- mindspore/nn/probability/distribution/categorical.py +7 -7
- mindspore/nn/probability/distribution/cauchy.py +0 -1
- mindspore/nn/probability/distribution/distribution.py +3 -3
- mindspore/nn/probability/distribution/gamma.py +3 -3
- mindspore/nn/probability/distribution/geometric.py +4 -4
- mindspore/nn/probability/distribution/gumbel.py +4 -4
- mindspore/nn/probability/distribution/log_normal.py +2 -2
- mindspore/nn/probability/distribution/logistic.py +2 -2
- mindspore/nn/probability/distribution/poisson.py +4 -4
- mindspore/nn/probability/distribution/transformed_distribution.py +3 -3
- mindspore/nn/probability/distribution/uniform.py +6 -6
- mindspore/nn/wrap/__init__.py +4 -2
- mindspore/nn/wrap/cell_wrapper.py +87 -34
- mindspore/nn/wrap/grad_reducer.py +8 -5
- mindspore/nn/wrap/loss_scale.py +105 -42
- mindspore/numpy/array_creations.py +1 -2
- mindspore/numpy/array_ops.py +3 -2
- mindspore/numpy/utils_const.py +5 -5
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/__init__.py +0 -5
- mindspore/ops/_grad_experimental/grad_array_ops.py +2 -3
- mindspore/ops/_grad_experimental/grad_comm_ops.py +15 -2
- mindspore/ops/_grad_experimental/grad_debug_ops.py +0 -37
- mindspore/ops/_grad_experimental/grad_implementations.py +11 -1
- mindspore/ops/_grad_experimental/grad_inner_ops.py +2 -216
- mindspore/ops/_grad_experimental/grad_math_ops.py +19 -199
- mindspore/ops/_grad_experimental/grad_sparse.py +15 -0
- mindspore/ops/_grad_experimental/grad_sparse_ops.py +3 -3
- mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py +1 -1
- mindspore/ops/_op_impl/aicpu/__init__.py +14 -2
- mindspore/ops/_op_impl/aicpu/add.py +3 -3
- mindspore/ops/_op_impl/aicpu/bias_add_grad.py +0 -1
- mindspore/ops/_op_impl/aicpu/count_nonzero.py +43 -0
- mindspore/ops/_op_impl/{_custom_op/flash_attention/constants.py → aicpu/eps.py} +18 -27
- mindspore/ops/_op_impl/aicpu/gamma.py +2 -2
- mindspore/ops/_op_impl/aicpu/linear_sum_assignment.py +21 -2
- mindspore/ops/_op_impl/aicpu/log_uniform_candidate_sampler.py +6 -3
- mindspore/ops/_op_impl/aicpu/lu_unpack_grad.py +0 -1
- mindspore/ops/_op_impl/aicpu/multinomial.py +3 -3
- 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/{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 -5
- mindspore/ops/_op_impl/aicpu/standard_normal.py +5 -5
- 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/tbe/__init__.py +4 -4
- mindspore/ops/_op_impl/tbe/inplace_index_add.py +7 -3
- mindspore/ops/_op_impl/tbe/trans_data_ds.py +2 -0
- mindspore/ops/_primitive_cache.py +1 -1
- mindspore/ops/_tracefunc.py +45 -13
- mindspore/ops/_utils/utils.py +6 -1
- mindspore/ops/_vmap/vmap_array_ops.py +3 -3
- mindspore/ops/_vmap/vmap_base.py +3 -3
- mindspore/ops/_vmap/vmap_convolution_ops.py +1 -1
- mindspore/ops/_vmap/vmap_grad_math_ops.py +6 -4
- mindspore/ops/_vmap/vmap_math_ops.py +5 -2
- mindspore/ops/_vmap/vmap_nn_ops.py +61 -7
- mindspore/ops/arg_dtype_cast.py +54 -0
- mindspore/ops/composite/base.py +37 -10
- mindspore/ops/composite/math_ops.py +5 -4
- mindspore/ops/composite/multitype_ops/_compile_utils.py +275 -73
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +16 -9
- mindspore/ops/composite/multitype_ops/add_impl.py +43 -4
- mindspore/ops/composite/multitype_ops/getitem_impl.py +42 -4
- mindspore/ops/composite/multitype_ops/ones_like_impl.py +6 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +9 -0
- mindspore/ops/deprecated.py +304 -0
- mindspore/ops/function/__init__.py +4 -1
- mindspore/ops/function/array_func.py +174 -193
- mindspore/ops/function/clip_func.py +81 -13
- mindspore/ops/function/debug_func.py +1 -1
- mindspore/ops/function/grad/grad_func.py +18 -9
- mindspore/ops/function/image_func.py +10 -4
- mindspore/ops/function/linalg_func.py +5 -5
- mindspore/ops/function/math_func.py +575 -386
- mindspore/ops/function/nn_func.py +568 -260
- mindspore/ops/function/random_func.py +88 -57
- mindspore/ops/function/sparse_func.py +1 -1
- mindspore/ops/function/sparse_unary_func.py +14 -12
- mindspore/ops/function/vmap_func.py +6 -5
- mindspore/ops/functional.py +15 -10
- mindspore/ops/op_info_register.py +244 -25
- mindspore/ops/operations/__init__.py +31 -19
- mindspore/ops/operations/_grad_ops.py +71 -7
- mindspore/ops/operations/_inner_ops.py +350 -17
- mindspore/ops/operations/_quant_ops.py +4 -8
- mindspore/ops/operations/_sequence_ops.py +42 -0
- mindspore/ops/operations/array_ops.py +68 -282
- mindspore/ops/operations/comm_ops.py +107 -59
- mindspore/ops/operations/custom_ops.py +94 -70
- mindspore/ops/operations/debug_ops.py +8 -4
- mindspore/ops/operations/image_ops.py +18 -12
- mindspore/ops/operations/inner_ops.py +26 -3
- mindspore/ops/operations/math_ops.py +192 -144
- mindspore/ops/operations/nn_ops.py +857 -489
- mindspore/ops/operations/other_ops.py +0 -22
- mindspore/ops/operations/random_ops.py +53 -111
- mindspore/ops/operations/sparse_ops.py +3 -1
- mindspore/ops/primitive.py +24 -18
- mindspore/parallel/_auto_parallel_context.py +68 -8
- mindspore/parallel/_cost_model_context.py +2 -2
- mindspore/parallel/_offload_context.py +17 -3
- mindspore/parallel/_parallel_serialization.py +12 -5
- mindspore/parallel/_ps_context.py +12 -0
- mindspore/parallel/_tensor.py +18 -13
- mindspore/parallel/_transformer/layers.py +5 -3
- mindspore/parallel/_transformer/loss.py +1 -0
- mindspore/parallel/_transformer/moe.py +2 -2
- mindspore/parallel/_transformer/op_parallel_config.py +12 -1
- mindspore/parallel/_transformer/transformer.py +23 -3
- mindspore/parallel/_utils.py +11 -7
- mindspore/parallel/algo_parameter_config.py +85 -5
- mindspore/parallel/checkpoint_transform.py +19 -12
- mindspore/parallel/shard.py +21 -14
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/common/struct_type.py +3 -3
- mindspore/profiler/common/util.py +4 -2
- mindspore/profiler/envprofiling.py +1 -1
- mindspore/profiler/parser/aicpu_data_parser.py +5 -3
- mindspore/profiler/parser/ascend_flops_generator.py +2 -2
- mindspore/profiler/parser/ascend_fpbp_generator.py +1 -1
- mindspore/profiler/parser/ascend_hccl_generator.py +249 -12
- mindspore/profiler/parser/ascend_msprof_exporter.py +150 -255
- mindspore/profiler/parser/ascend_msprof_generator.py +204 -17
- mindspore/profiler/parser/ascend_op_generator.py +6 -6
- mindspore/profiler/parser/ascend_steptrace_generator.py +6 -4
- mindspore/profiler/parser/ascend_timeline_generator.py +14 -187
- mindspore/profiler/parser/base_timeline_generator.py +10 -8
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +16 -12
- mindspore/profiler/parser/flops_parser.py +15 -11
- mindspore/profiler/parser/framework_parser.py +38 -22
- mindspore/profiler/parser/hccl_parser.py +16 -12
- mindspore/profiler/parser/integrator.py +22 -11
- mindspore/profiler/parser/memory_usage_parser.py +2 -2
- 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 +21 -2
- mindspore/profiler/parser/step_trace_parser.py +11 -14
- mindspore/profiler/profiling.py +179 -89
- mindspore/rewrite/api/node.py +102 -19
- mindspore/rewrite/api/node_type.py +5 -1
- mindspore/rewrite/api/pattern_engine.py +1 -1
- mindspore/rewrite/api/scoped_value.py +9 -17
- mindspore/rewrite/api/symbol_tree.py +131 -47
- 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 +93 -46
- mindspore/rewrite/common/rewrite_elog.py +5 -1
- mindspore/rewrite/namer.py +33 -24
- mindspore/rewrite/namespace.py +14 -5
- mindspore/{_extends/graph_kernel/expanders/complex → rewrite/node}/__init__.py +9 -9
- 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} +273 -234
- mindspore/rewrite/node/node_manager.py +254 -0
- mindspore/rewrite/{topological_manager.py → node/node_topological_manager.py} +13 -46
- mindspore/rewrite/parsers/arguments_parser.py +22 -21
- mindspore/rewrite/parsers/assign_parser.py +216 -221
- mindspore/rewrite/parsers/attribute_parser.py +9 -7
- mindspore/rewrite/parsers/class_def_parser.py +174 -113
- mindspore/rewrite/parsers/constant_parser.py +9 -6
- mindspore/rewrite/parsers/container_parser.py +9 -7
- mindspore/rewrite/parsers/for_parser.py +42 -21
- mindspore/rewrite/parsers/function_def_parser.py +24 -16
- mindspore/rewrite/parsers/if_parser.py +28 -24
- mindspore/rewrite/parsers/module_parser.py +196 -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/utils.py +1 -1
- mindspore/rewrite/symbol_tree.py +523 -578
- mindspore/rewrite/symbol_tree_builder.py +9 -193
- mindspore/rewrite/symbol_tree_dumper.py +2 -2
- mindspore/run_check/_check_version.py +6 -4
- mindspore/{ops/bprop_mindir → safeguard}/__init__.py +4 -3
- mindspore/safeguard/rewrite_obfuscation.py +541 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +7 -3
- mindspore/train/amp.py +323 -123
- mindspore/train/anf_ir_pb2.py +14 -2
- mindspore/train/callback/_backup_and_restore.py +2 -12
- mindspore/train/callback/_callback.py +29 -4
- mindspore/train/callback/_checkpoint.py +23 -8
- mindspore/train/callback/_early_stop.py +2 -2
- mindspore/train/callback/_landscape.py +4 -4
- mindspore/train/callback/_loss_monitor.py +2 -2
- mindspore/train/callback/_on_request_exit.py +2 -2
- mindspore/train/callback/_reduce_lr_on_plateau.py +3 -4
- mindspore/train/callback/_summary_collector.py +15 -8
- mindspore/train/callback/_time_monitor.py +58 -5
- mindspore/train/data_sink.py +5 -11
- mindspore/train/dataset_helper.py +84 -57
- mindspore/train/loss_scale_manager.py +2 -2
- mindspore/train/metrics/__init__.py +3 -3
- mindspore/train/metrics/cosine_similarity.py +1 -1
- mindspore/train/metrics/hausdorff_distance.py +3 -2
- mindspore/train/metrics/mean_surface_distance.py +3 -2
- mindspore/train/metrics/metric.py +39 -19
- mindspore/train/metrics/roc.py +2 -2
- mindspore/train/metrics/root_mean_square_surface_distance.py +4 -3
- mindspore/train/mind_ir_pb2.py +85 -36
- mindspore/train/model.py +187 -47
- mindspore/train/serialization.py +487 -161
- mindspore/train/summary/_summary_adapter.py +1 -1
- mindspore/train/summary/_writer_pool.py +3 -2
- mindspore/train/summary/summary_record.py +37 -17
- mindspore/train/train_thor/convert_utils.py +3 -3
- mindspore/train/train_thor/dataset_helper.py +1 -1
- mindspore/turbojpeg.dll +0 -0
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/METADATA +7 -4
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/RECORD +429 -486
- mindspore/_extends/graph_kernel/expander.py +0 -80
- mindspore/_extends/graph_kernel/expanders/__init__.py +0 -54
- 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/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/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/model/op_infer.py +0 -506
- mindspore/dataset/datapreprocess/__init__.py +0 -20
- mindspore/dataset/datapreprocess/preprocess_imagenet_validate_dataset.py +0 -54
- mindspore/include/api/net.h +0 -142
- mindspore/nn/lr_scheduler.py +0 -262
- mindspore/ops/_grad_experimental/grad_image_ops.py +0 -248
- mindspore/ops/_grad_experimental/grad_linalg_ops.py +0 -181
- mindspore/ops/_grad_experimental/grad_other_ops.py +0 -72
- mindspore/ops/_grad_experimental/grad_scalar_ops.py +0 -112
- mindspore/ops/_grad_experimental/grad_sequence_ops.py +0 -351
- mindspore/ops/_op_impl/_custom_op/flash_attention/__init__.py +0 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/attention.py +0 -350
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_bwd.py +0 -409
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_fwd.py +0 -578
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_impl.py +0 -199
- mindspore/ops/_op_impl/_custom_op/flash_attention/tik_ops_utils.py +0 -446
- 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 +0 -45
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/strategy.py +0 -67
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/wukong_tiling.py +0 -62
- mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Broadcast_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Depend_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DepthwiseConv2dNative_bprop.mindir +0 -138
- mindspore/ops/bprop_mindir/EmbeddingLookup_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Load_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ScatterNonAliasingAdd_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SparseGatherV2_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SparseSoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Switch_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TransShape_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Unique_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Unstack_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/generate_mindir.py +0 -114
- mindspore/rewrite/node_visitor.py +0 -44
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/WHEEL +0 -0
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/entry_points.txt +0 -0
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/top_level.txt +0 -0
|
@@ -398,10 +398,16 @@ def slice2indices(input_slice, shape):
|
|
|
398
398
|
return False
|
|
399
399
|
ndim = len(shape)
|
|
400
400
|
mesh = list()
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
grids
|
|
404
|
-
|
|
401
|
+
range_op = P.Range()
|
|
402
|
+
cast_op = P.Cast()
|
|
403
|
+
grids = [
|
|
404
|
+
range_op(cast_op(start, mstype.int64), cast_op(stop, mstype.int64),
|
|
405
|
+
cast_op(step, mstype.int64))
|
|
406
|
+
]
|
|
407
|
+
grids += [
|
|
408
|
+
range_op(Tensor(0, mstype.int64), cast_op(dim_size, mstype.int64),
|
|
409
|
+
Tensor(1, mstype.int64)) for dim_size in shape[1:]
|
|
410
|
+
]
|
|
405
411
|
for j, grid in enumerate(grids):
|
|
406
412
|
mesh.append(P.Reshape()(grid, tuple(
|
|
407
413
|
[grid.size if j == t else 1 for t in range(ndim)])))
|
|
@@ -543,7 +549,7 @@ def convert_scalar_to_tensor(data_shape, data_dtype, indices_shape, value, op_ty
|
|
|
543
549
|
updates_shape = indices_shape + data_shape[1:]
|
|
544
550
|
else:
|
|
545
551
|
updates_shape = indices_shape[:-1] + data_shape[indices_shape[-1]:]
|
|
546
|
-
return P.
|
|
552
|
+
return P.FillV2()(updates_shape, P.Cast()(value, data_dtype))
|
|
547
553
|
|
|
548
554
|
|
|
549
555
|
def generate_updates_shape(data_shape, index_shape, op_type, is_dynamic):
|
|
@@ -844,7 +850,7 @@ def sequence_to_index(sequence, dim_size):
|
|
|
844
850
|
return False
|
|
845
851
|
if all(isinstance(i, bool) for i in sequence):
|
|
846
852
|
if dim_size is None:
|
|
847
|
-
|
|
853
|
+
return Tensor(sequence)
|
|
848
854
|
seq_size = len(sequence)
|
|
849
855
|
if seq_size != dim_size:
|
|
850
856
|
raise IndexError(f'dimension is {dim_size} but corresponding boolean dimension is {seq_size}')
|
|
@@ -865,11 +871,11 @@ def int_to_index(i, shape):
|
|
|
865
871
|
_check(i, dim_size)
|
|
866
872
|
i = (i + dim_size) % dim_size
|
|
867
873
|
if len(shape) == 1:
|
|
868
|
-
return P.
|
|
874
|
+
return P.FillV2()((1, 1), P.Cast()(i, mstype.int64))
|
|
869
875
|
mesh = list()
|
|
870
876
|
ndim = len(shape) - 1
|
|
871
877
|
for j, size in enumerate(shape[1:]):
|
|
872
|
-
grid = P.Range()(Tensor(0, mstype.int64), P.
|
|
878
|
+
grid = P.Range()(Tensor(0, mstype.int64), P.Cast()(size, mstype.int64), Tensor(1, mstype.int64))
|
|
873
879
|
mesh.append(P.Reshape()(grid, tuple([size if j == t else 1 for t in range(ndim)])))
|
|
874
880
|
shapes = map(P.Shape(), mesh)
|
|
875
881
|
out_shape = infer_out_shape(*shapes)
|
|
@@ -877,7 +883,8 @@ def int_to_index(i, shape):
|
|
|
877
883
|
for arr in mesh:
|
|
878
884
|
mesh_arrays.append(P.BroadcastTo(out_shape)(arr))
|
|
879
885
|
index = P.Stack(-1)(mesh_arrays)
|
|
880
|
-
return P.Concat(-1)((P.
|
|
886
|
+
return P.Concat(-1)((P.FillV2()(P.Shape()(index)[:-1] + (1,),
|
|
887
|
+
P.Cast()(i, mstype.int64)), index))
|
|
881
888
|
|
|
882
889
|
|
|
883
890
|
@constexpr
|
|
@@ -60,6 +60,26 @@ _tuple_add = _TupleAdd('tuple_add')
|
|
|
60
60
|
"""`_tuple_add` is an metafuncgraph object which will concatenate two tuples to form a tuple."""
|
|
61
61
|
|
|
62
62
|
|
|
63
|
+
class _DictUpdate(base.DictUpdate_):
|
|
64
|
+
"""
|
|
65
|
+
A metafuncgraph class that append another dict to the end of the dict.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
name (str): The name of the metafuncgraph object.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
def __init__(self, name):
|
|
72
|
+
"""Initialize _DictUpdate."""
|
|
73
|
+
base.DictUpdate_.__init__(self, name)
|
|
74
|
+
|
|
75
|
+
def __call__(self, *args):
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
_dict_update = _DictUpdate('dict_update')
|
|
80
|
+
"""`_dict_update` is an metafuncgraph object which will concatenate two dict to form a dict."""
|
|
81
|
+
|
|
82
|
+
|
|
63
83
|
class _ListAdd(base.ListAdd_):
|
|
64
84
|
"""
|
|
65
85
|
Adding two lists.
|
|
@@ -315,7 +335,8 @@ def _add_csrtensor(x, y):
|
|
|
315
335
|
Returns:
|
|
316
336
|
CSRTensor, consists of elements of x and elements of y.
|
|
317
337
|
"""
|
|
318
|
-
check_equal(x.shape, y.shape,
|
|
338
|
+
check_equal(x.shape, y.shape,
|
|
339
|
+
"input1 (shape={}) and input2(shape={}) should be the same shape.")
|
|
319
340
|
return F.csr_add(x, y, make_tensor(1, x.values.dtype), make_tensor(1, x.values.dtype))
|
|
320
341
|
|
|
321
342
|
|
|
@@ -331,7 +352,8 @@ def _add_cootensor(x, y):
|
|
|
331
352
|
Returns:
|
|
332
353
|
COOTensor, consists of elements of x and elements of y.
|
|
333
354
|
"""
|
|
334
|
-
check_equal(x.shape, y.shape,
|
|
355
|
+
check_equal(x.shape, y.shape,
|
|
356
|
+
"input1 (shape={}) and input2(shape={}) should be the same shape.")
|
|
335
357
|
return F.coo_add(x, y, make_tensor(0, x.values.dtype))
|
|
336
358
|
|
|
337
359
|
|
|
@@ -347,7 +369,8 @@ def _add_cootensor_tensor(x, y):
|
|
|
347
369
|
Returns:
|
|
348
370
|
Tensor, consists of elements of x and elements of y.
|
|
349
371
|
"""
|
|
350
|
-
check_equal(x.shape, y.shape,
|
|
372
|
+
check_equal(x.shape, y.shape,
|
|
373
|
+
"input1 (shape={}) and input2(shape={}) should be the same shape.")
|
|
351
374
|
return F.tensor_scatter_add(y, x.indices, x.values)
|
|
352
375
|
|
|
353
376
|
|
|
@@ -363,7 +386,8 @@ def _add_tensor_cootensor(x, y):
|
|
|
363
386
|
Returns:
|
|
364
387
|
Tensor, consists of elements of x and elements of y.
|
|
365
388
|
"""
|
|
366
|
-
check_equal(x.shape, y.shape,
|
|
389
|
+
check_equal(x.shape, y.shape,
|
|
390
|
+
"input1 (shape={}) and input2(shape={}) should be the same shape.")
|
|
367
391
|
return F.tensor_scatter_add(x, y.indices, y.values)
|
|
368
392
|
|
|
369
393
|
|
|
@@ -558,4 +582,19 @@ def _map_tensor_add_backward(x, y):
|
|
|
558
582
|
return x
|
|
559
583
|
|
|
560
584
|
|
|
585
|
+
@add.register("Dictionary", "Dictionary")
|
|
586
|
+
def _dict_add_dict(x, y):
|
|
587
|
+
"""
|
|
588
|
+
dictionary is added to dictionary.
|
|
589
|
+
|
|
590
|
+
Args:
|
|
591
|
+
x (dictionary): x
|
|
592
|
+
y (dictionary): y.
|
|
593
|
+
|
|
594
|
+
Returns:
|
|
595
|
+
dictionary, has the same dtype as x.
|
|
596
|
+
"""
|
|
597
|
+
return _dict_update(x, y)
|
|
598
|
+
|
|
599
|
+
|
|
561
600
|
hyper_add = base.HyperMap(_add_backward)
|
|
@@ -106,7 +106,26 @@ _tuple_get_item_tensor = _TupleGetItemTensor('tuple_get_item_tensor')
|
|
|
106
106
|
"""_tuple_get_item_tensor is an metafuncgraph object which will select indexed item."""
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
@getitem.register("Tuple", "
|
|
109
|
+
@getitem.register("Tuple", "Bool")
|
|
110
|
+
def _tuple_getitem_by_bool(data, number_index):
|
|
111
|
+
"""
|
|
112
|
+
Getting item of tuple by bool index.
|
|
113
|
+
|
|
114
|
+
Inputs:
|
|
115
|
+
data (tuple): A tuple to be sliced.
|
|
116
|
+
number_index (Number): Index in scalar.
|
|
117
|
+
|
|
118
|
+
Outputs:
|
|
119
|
+
Type, is the same as the element type of data.
|
|
120
|
+
"""
|
|
121
|
+
if number_index:
|
|
122
|
+
return F.tuple_getitem(data, 1)
|
|
123
|
+
return F.tuple_getitem(data, 0)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@getitem.register("Tuple", "Int")
|
|
127
|
+
@getitem.register("Tuple", "UInt")
|
|
128
|
+
@getitem.register("Tuple", "Float")
|
|
110
129
|
def _tuple_getitem_by_number(data, number_index):
|
|
111
130
|
"""
|
|
112
131
|
Getting item of tuple by number index.
|
|
@@ -142,7 +161,7 @@ def _tuple_getitem_by_slice(data, slice_index):
|
|
|
142
161
|
if start is None:
|
|
143
162
|
start = 0 if step >= 1 else -1
|
|
144
163
|
if stop is None:
|
|
145
|
-
stop = (2**31-1) if step >= 1 else -(2**31-1)
|
|
164
|
+
stop = (2**31 - 1) if step >= 1 else -(2**31 - 1)
|
|
146
165
|
return sequence_slice(data, start, stop, step)
|
|
147
166
|
return _tuple_slice(data, slice_index)
|
|
148
167
|
|
|
@@ -162,7 +181,26 @@ def _tuple_getitem_by_tensor(data, tensor_index):
|
|
|
162
181
|
return _tuple_get_item_tensor(data, tensor_index)
|
|
163
182
|
|
|
164
183
|
|
|
165
|
-
@getitem.register("List", "
|
|
184
|
+
@getitem.register("List", "Bool")
|
|
185
|
+
def _list_getitem_by_bool(data, number_index):
|
|
186
|
+
"""
|
|
187
|
+
Getting item of list by bool index.
|
|
188
|
+
|
|
189
|
+
Inputs:
|
|
190
|
+
data (tuple): A list to be sliced.
|
|
191
|
+
number_index (Bool): Index in scalar.
|
|
192
|
+
|
|
193
|
+
Outputs:
|
|
194
|
+
Type, is the same as the element type of data.
|
|
195
|
+
"""
|
|
196
|
+
if number_index:
|
|
197
|
+
return F.list_getitem(data, 1)
|
|
198
|
+
return F.list_getitem(data, 0)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@getitem.register("List", "Int")
|
|
202
|
+
@getitem.register("List", "UInt")
|
|
203
|
+
@getitem.register("List", "Float")
|
|
166
204
|
def _list_getitem_by_number(data, number_index):
|
|
167
205
|
"""
|
|
168
206
|
Getting item of list by number index.
|
|
@@ -198,7 +236,7 @@ def _list_getitem_by_slice(data, slice_index):
|
|
|
198
236
|
if start is None:
|
|
199
237
|
start = 0 if step >= 1 else -1
|
|
200
238
|
if stop is None:
|
|
201
|
-
stop = (2**31-1) if step >= 1 else -(2**31-1)
|
|
239
|
+
stop = (2**31 - 1) if step >= 1 else -(2**31 - 1)
|
|
202
240
|
return sequence_slice(data, start, stop, step)
|
|
203
241
|
return _list_slice(data, slice_index)
|
|
204
242
|
|
|
@@ -78,6 +78,12 @@ def _ones_like_func(x):
|
|
|
78
78
|
return F.environ_create()
|
|
79
79
|
|
|
80
80
|
|
|
81
|
+
@ones_like_leaf.register("None")
|
|
82
|
+
def _ones_like_none(x):
|
|
83
|
+
"""Returns none"""
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
|
|
81
87
|
ones_like = base.HyperMap(ones_like_leaf)
|
|
82
88
|
"""
|
|
83
89
|
`ones_like` is a function which can generate a graph of `ones_like` operation according to input tensor dtype.
|
|
@@ -22,6 +22,7 @@ from mindspore.ops.operations._inner_ops import SliceGetItem
|
|
|
22
22
|
from mindspore.ops.operations import _map_tensor_ops
|
|
23
23
|
from mindspore.ops.composite import base
|
|
24
24
|
from mindspore.common import Tensor
|
|
25
|
+
from mindspore.ops.composite.base import _dict_setitem
|
|
25
26
|
from ...operations._sequence_ops import SequenceSliceSetItem
|
|
26
27
|
|
|
27
28
|
DOC_URL = "https://mindspore.cn/search/en?inputValue=Index%20value%20assignment"
|
|
@@ -252,7 +253,7 @@ def _dict_setitem_with_tensor(data, key, value):
|
|
|
252
253
|
Outputs:
|
|
253
254
|
dict, type is as same as the element type of data.
|
|
254
255
|
"""
|
|
255
|
-
return
|
|
256
|
+
return _dict_setitem(data, key, value)
|
|
256
257
|
|
|
257
258
|
|
|
258
259
|
@setitem.register("Tensor", "Tensor", "Tensor")
|
|
@@ -41,6 +41,15 @@ def _zeros_like_bool(x):
|
|
|
41
41
|
"""Returns False if x is a bool."""
|
|
42
42
|
return False
|
|
43
43
|
|
|
44
|
+
@zeros_like_leaf.register("String")
|
|
45
|
+
def _zeros_like_string(x):
|
|
46
|
+
"""Returns False if x is a string."""
|
|
47
|
+
return 0
|
|
48
|
+
|
|
49
|
+
@zeros_like_leaf.register("Tuple")
|
|
50
|
+
def _zeros_like_tuple(x):
|
|
51
|
+
"""Returns False if x is a tuple."""
|
|
52
|
+
return 0
|
|
44
53
|
|
|
45
54
|
@zeros_like_leaf.register("Function")
|
|
46
55
|
def _zeros_like_func(x):
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# Copyright 2023 Huawei Technologies Co., Ltd
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ============================================================================
|
|
15
|
+
|
|
16
|
+
"""Defines deprecated operators."""
|
|
17
|
+
import itertools
|
|
18
|
+
import numpy as np
|
|
19
|
+
from mindspore.common._decorator import deprecated
|
|
20
|
+
from mindspore import context
|
|
21
|
+
from mindspore import _checkparam as validator
|
|
22
|
+
from mindspore.ops import signature as sig
|
|
23
|
+
from mindspore.ops.primitive import Primitive, prim_attr_register
|
|
24
|
+
from mindspore.ops.operations.math_ops import _MathBinaryOp
|
|
25
|
+
from mindspore.ops.operations.nn_ops import _check_positive_int_or_tuple
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class BNTrainingReduce(Primitive):
|
|
29
|
+
"""
|
|
30
|
+
Please use BatchNorm instead.
|
|
31
|
+
"""
|
|
32
|
+
@deprecated("1.5", "ops.BatchNorm", False)
|
|
33
|
+
@prim_attr_register
|
|
34
|
+
def __init__(self, data_format="NCHW"):
|
|
35
|
+
"""Initialize BNTrainingReduce."""
|
|
36
|
+
super().__init__(name="BNTrainingReduce")
|
|
37
|
+
self.init_prim_io_names(inputs=['x'], outputs=['sum', 'square_sum'])
|
|
38
|
+
self.format = validator.check_string(data_format, ['NCHW', 'NHWC'], 'format', self.name)
|
|
39
|
+
if context.get_context("device_target") != "GPU" and self.format == "NHWC":
|
|
40
|
+
raise ValueError(f"For '{self.name}', the 'NHWC' format is only supported in GPU target, "
|
|
41
|
+
f"but got the 'data_format' is {self.format} and "
|
|
42
|
+
f"the platform is {context.get_context('device_target')}.")
|
|
43
|
+
self.add_prim_attr('data_format', self.format)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class BNTrainingUpdate(Primitive):
|
|
47
|
+
"""
|
|
48
|
+
Please use BatchNorm instead.
|
|
49
|
+
"""
|
|
50
|
+
@deprecated("1.5", "ops.BatchNorm", False)
|
|
51
|
+
@prim_attr_register
|
|
52
|
+
def __init__(self, isRef=True, epsilon=1e-5, factor=0.1, data_format="NCHW"):
|
|
53
|
+
"""Initialize BNTrainingUpdate."""
|
|
54
|
+
super().__init__(name="BNTrainingUpdate")
|
|
55
|
+
self.init_prim_io_names(inputs=['x', 'sum', 'square_sum', 'scale', 'b', 'mean', 'variance'],
|
|
56
|
+
outputs=['y', 'running_mean', 'running_variance', 'save_mean', 'save_inv_variance'])
|
|
57
|
+
validator.check_value_type("isRef", isRef, [bool], self.name)
|
|
58
|
+
validator.check_value_type("epsilon", epsilon, [float], self.name)
|
|
59
|
+
validator.check_value_type("factor", factor, [float], self.name)
|
|
60
|
+
self.epsilon = validator.check_float_range(epsilon, 0, 1, validator.INC_RIGHT, 'epsilon', 'BNTrainingUpdate')
|
|
61
|
+
self.factor = validator.check_float_range(factor, 0, 1, validator.INC_BOTH, 'factor', 'BNTrainingUpdate')
|
|
62
|
+
self.format = validator.check_string(data_format, ['NCHW', 'NHWC'], 'format', self.name)
|
|
63
|
+
if context.get_context("device_target") != "GPU" and self.format == "NHWC":
|
|
64
|
+
raise ValueError(f"For '{self.name}', the 'NHWC' format is only supported in GPU target, "
|
|
65
|
+
f"but got the 'data_format' is {self.format} and "
|
|
66
|
+
f"the platform is {context.get_context('device_target')}.")
|
|
67
|
+
self.add_prim_attr('data_format', self.format)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class MaxPoolWithArgmax(Primitive):
|
|
71
|
+
"""
|
|
72
|
+
Please use MaxPoolWithArgmaxV2 instead.
|
|
73
|
+
"""
|
|
74
|
+
@deprecated("2.0", "ops.MaxPoolWithArgmaxV2", False)
|
|
75
|
+
@prim_attr_register
|
|
76
|
+
def __init__(self, kernel_size=1, strides=1, pad_mode="valid", data_format="NCHW"):
|
|
77
|
+
"""Initialize MaxPoolWithArgmax."""
|
|
78
|
+
super().__init__(name="MaxPoolWithArgmax")
|
|
79
|
+
self.init_prim_io_names(inputs=['x'], outputs=['output', 'mask'])
|
|
80
|
+
validator.check_value_type('kernel_size', kernel_size, [int, tuple], self.name)
|
|
81
|
+
validator.check_value_type('strides', strides, [int, tuple], self.name)
|
|
82
|
+
validator.check_value_type('pad_mode', pad_mode, [str], self.name)
|
|
83
|
+
self.pad_mode = validator.check_string(pad_mode.upper(), ['VALID', 'SAME'], 'pad_mode', self.name)
|
|
84
|
+
self.add_prim_attr("pad_mode", self.pad_mode)
|
|
85
|
+
self.format = validator.check_string(data_format, ['NCHW', 'NHWC'], 'format', self.name)
|
|
86
|
+
if context.get_context("device_target") != "GPU" and self.format == "NHWC":
|
|
87
|
+
raise ValueError(f"For '{self.name}', the 'NHWC' format is only supported in GPU target, "
|
|
88
|
+
f"but got the 'data_format' is {self.format} and "
|
|
89
|
+
f"the platform is {context.get_context('device_target')}.")
|
|
90
|
+
self.kernel_size = _check_positive_int_or_tuple(
|
|
91
|
+
"kernel_size", kernel_size, self.name, allow_four=False, ret_four=True)
|
|
92
|
+
self.kernel_size = (1, self.kernel_size[-2], self.kernel_size[-1], 1)
|
|
93
|
+
self.add_prim_attr("kernel_size", self.kernel_size)
|
|
94
|
+
|
|
95
|
+
self.strides = _check_positive_int_or_tuple("strides", strides, self.name, allow_four=False, ret_four=True)
|
|
96
|
+
self.strides = (1, self.strides[-2], self.strides[-1], 1)
|
|
97
|
+
self.add_prim_attr("strides", self.strides)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class DropoutGenMask(Primitive):
|
|
101
|
+
"""
|
|
102
|
+
Please use Dropout instead.
|
|
103
|
+
"""
|
|
104
|
+
@deprecated("1.5", "ops.Dropout", False)
|
|
105
|
+
@prim_attr_register
|
|
106
|
+
def __init__(self, Seed0=0, Seed1=0):
|
|
107
|
+
"""Initialize DropoutGenMask."""
|
|
108
|
+
super().__init__(name="DropoutGenMask")
|
|
109
|
+
self.init_prim_io_names(inputs=['shape', 'keep_prob'], outputs=['output'])
|
|
110
|
+
validator.check_value_type("Seed0", Seed0, [int], self.name)
|
|
111
|
+
validator.check_value_type("Seed1", Seed1, [int], self.name)
|
|
112
|
+
self.add_prim_attr("side_effect_hidden", True)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class DropoutDoMask(Primitive):
|
|
116
|
+
"""
|
|
117
|
+
Please use Dropout instead.
|
|
118
|
+
"""
|
|
119
|
+
@deprecated("1.5", "ops.Dropout", False)
|
|
120
|
+
@prim_attr_register
|
|
121
|
+
def __init__(self):
|
|
122
|
+
super().__init__(name="DropoutDoMask")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class Gelu(Primitive):
|
|
126
|
+
"""
|
|
127
|
+
Please use GeLU instead.
|
|
128
|
+
"""
|
|
129
|
+
@deprecated("1.1", "GeLU", True)
|
|
130
|
+
@prim_attr_register
|
|
131
|
+
def __init__(self):
|
|
132
|
+
"""Initialize Gelu"""
|
|
133
|
+
super().__init__(name="Gelu")
|
|
134
|
+
self.init_prim_io_names(inputs=['x'], outputs=['output'])
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class FastGelu(Primitive):
|
|
138
|
+
"""
|
|
139
|
+
Please use FastGeLU instead.
|
|
140
|
+
"""
|
|
141
|
+
@deprecated("1.1", "FastGeLU", True)
|
|
142
|
+
@prim_attr_register
|
|
143
|
+
def __init__(self):
|
|
144
|
+
"""Initialize FastGelu."""
|
|
145
|
+
super().__init__(name="FastGelu")
|
|
146
|
+
self.init_prim_io_names(inputs=['x'], outputs=['output'])
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class TensorAdd(_MathBinaryOp):
|
|
150
|
+
"""
|
|
151
|
+
Please use Add instead.
|
|
152
|
+
"""
|
|
153
|
+
@deprecated("1.1", "Add", True)
|
|
154
|
+
@prim_attr_register
|
|
155
|
+
def __init__(self):
|
|
156
|
+
"""Initialize TensorAdd."""
|
|
157
|
+
_MathBinaryOp.__init__(self)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class InplaceUpdate(Primitive):
|
|
161
|
+
"""
|
|
162
|
+
Please use InplaceUpdateV2 instead.
|
|
163
|
+
"""
|
|
164
|
+
@deprecated("2.0", "ops.InplaceUpdateV2", False)
|
|
165
|
+
@prim_attr_register
|
|
166
|
+
def __init__(self, indices):
|
|
167
|
+
"""Initialize InplaceUpdate"""
|
|
168
|
+
self.init_prim_io_names(inputs=['x', 'v'], outputs=['y'])
|
|
169
|
+
self.indices = indices
|
|
170
|
+
validator.check_value_type("indices", indices, [int, tuple], self.name)
|
|
171
|
+
if isinstance(indices, int):
|
|
172
|
+
self.indices = (indices,)
|
|
173
|
+
for item in self.indices:
|
|
174
|
+
validator.check_value_type("item of indices", item, [int], self.name)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class DynamicShape(Primitive):
|
|
178
|
+
"""
|
|
179
|
+
Please use TensorShape instead.
|
|
180
|
+
"""
|
|
181
|
+
@deprecated("1.7", "TensorShape", True)
|
|
182
|
+
@prim_attr_register
|
|
183
|
+
def __init__(self, dtype=9):
|
|
184
|
+
"""init Shape"""
|
|
185
|
+
super().__init__(name="DynamicShape")
|
|
186
|
+
self.init_prim_io_names(inputs=['tensor'], outputs=['output'])
|
|
187
|
+
self.add_prim_attr('is_dynamic_shape', True)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class GatherV2(Primitive):
|
|
191
|
+
"""
|
|
192
|
+
Please use Gather instead.
|
|
193
|
+
"""
|
|
194
|
+
@deprecated("1.1", "Gather", True)
|
|
195
|
+
@prim_attr_register
|
|
196
|
+
def __init__(self):
|
|
197
|
+
"""Initialize GatherV2"""
|
|
198
|
+
super().__init__(name="GatherV2")
|
|
199
|
+
self.add_prim_attr("batch_dims", 0)
|
|
200
|
+
self.init_prim_io_names(inputs=['params', 'indices', 'axis'], outputs=['output'])
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class ScalarToArray(Primitive):
|
|
204
|
+
"""
|
|
205
|
+
Please use scalar_to_tensor instead.
|
|
206
|
+
"""
|
|
207
|
+
@deprecated("2.0", "ops.scalar_to_tensor", False)
|
|
208
|
+
@prim_attr_register
|
|
209
|
+
def __init__(self):
|
|
210
|
+
super().__init__(name="ScalarToArray")
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class Pack(Primitive):
|
|
214
|
+
"""
|
|
215
|
+
Please use Stack instead.
|
|
216
|
+
"""
|
|
217
|
+
@deprecated("1.1", "Stack", True)
|
|
218
|
+
@prim_attr_register
|
|
219
|
+
def __init__(self, axis=0):
|
|
220
|
+
"""Initialize Pack"""
|
|
221
|
+
super().__init__(name="Pack")
|
|
222
|
+
validator.check_value_type("axis", axis, [int], self.name)
|
|
223
|
+
self.axis = axis
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class Unpack(Primitive):
|
|
227
|
+
"""
|
|
228
|
+
Please use Unstack instead.
|
|
229
|
+
"""
|
|
230
|
+
@deprecated("1.1", "Unstack", True)
|
|
231
|
+
@prim_attr_register
|
|
232
|
+
def __init__(self, axis=0):
|
|
233
|
+
"""Initialize Unpack"""
|
|
234
|
+
super().__init__(name="Unpack")
|
|
235
|
+
validator.check_value_type("axis", axis, [int], self.name)
|
|
236
|
+
self.axis = axis
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class ScatterNonAliasingAdd(Primitive):
|
|
240
|
+
"""
|
|
241
|
+
Please use TensorScatterAdd instead.
|
|
242
|
+
"""
|
|
243
|
+
__mindspore_signature__ = (
|
|
244
|
+
sig.make_sig('input_x', sig.sig_rw.RW_WRITE, dtype=sig.sig_dtype.T),
|
|
245
|
+
sig.make_sig('indices', dtype=sig.sig_dtype.T1),
|
|
246
|
+
sig.make_sig('updates', dtype=sig.sig_dtype.T)
|
|
247
|
+
)
|
|
248
|
+
@deprecated("2.1", "ops.ScatterNonAliasingAdd", False)
|
|
249
|
+
@prim_attr_register
|
|
250
|
+
def __init__(self):
|
|
251
|
+
"""Initialize ScatterNonAliasingAdd"""
|
|
252
|
+
super().__init__(name="ScatterNonAliasingAdd")
|
|
253
|
+
self.init_prim_io_names(inputs=['input_x', 'indices', 'updates'], outputs=['y'])
|
|
254
|
+
self.add_prim_attr('side_effect_mem', True)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
class BatchToSpaceND(Primitive):
|
|
258
|
+
"""
|
|
259
|
+
Please use batch_to_space_nd instead.
|
|
260
|
+
"""
|
|
261
|
+
@deprecated("2.0", "ops.batch_to_space_nd", False)
|
|
262
|
+
@prim_attr_register
|
|
263
|
+
def __init__(self, block_shape, crops):
|
|
264
|
+
"""Initialize BatchToSpaceND"""
|
|
265
|
+
super().__init__(name="BatchToSpaceND")
|
|
266
|
+
if isinstance(block_shape, int):
|
|
267
|
+
block_shape = (block_shape,) * np.array(crops).shape[0]
|
|
268
|
+
self.add_prim_attr("block_shape", block_shape)
|
|
269
|
+
validator.check_value_type('block_shape type', block_shape, [list, tuple], self.name)
|
|
270
|
+
validator.check('block_shape shape', len(np.array(block_shape).shape), '', 1, validator.EQ, self.name)
|
|
271
|
+
block_rank = len(block_shape)
|
|
272
|
+
if context.get_context("device_target") == "Ascend":
|
|
273
|
+
validator.check('block_shape length', block_rank, '', 2, validator.EQ, self.name)
|
|
274
|
+
for elem in block_shape:
|
|
275
|
+
validator.check('block_shape element', elem, '', 1, validator.GE, self.name)
|
|
276
|
+
validator.check_value_type('block_shape element', elem, [int], self.name)
|
|
277
|
+
self.block_shape = block_shape
|
|
278
|
+
|
|
279
|
+
validator.check_value_type('crops type', crops, [list, tuple], self.name)
|
|
280
|
+
validator.check('crops length', len(crops), '', 1, validator.GE, self.name)
|
|
281
|
+
validator.check('crops shape', np.array(crops).shape, '', (block_rank, 2), validator.EQ, self.name)
|
|
282
|
+
for elem in itertools.chain(*crops):
|
|
283
|
+
validator.check_non_negative_int(elem, 'crops element', self.name)
|
|
284
|
+
validator.check_value_type('crops element', elem, [int], self.name)
|
|
285
|
+
self.crops = crops
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
class identity(Primitive):
|
|
289
|
+
"""
|
|
290
|
+
Please use side_effect_propagate instead.
|
|
291
|
+
"""
|
|
292
|
+
|
|
293
|
+
# Side effect will propagated from the first argument to return value.
|
|
294
|
+
side_effect_propagate = 1
|
|
295
|
+
|
|
296
|
+
@prim_attr_register
|
|
297
|
+
def __init__(self):
|
|
298
|
+
"""Initialize identity."""
|
|
299
|
+
super().__init__(name="identity")
|
|
300
|
+
self.add_prim_attr('side_effect_propagate', 1)
|
|
301
|
+
|
|
302
|
+
@deprecated('2.0', 'nn.Identity', False)
|
|
303
|
+
def __call__(self, x):
|
|
304
|
+
return x
|
|
@@ -34,7 +34,6 @@ from .array_func import (
|
|
|
34
34
|
matrix_band_part,
|
|
35
35
|
padding,
|
|
36
36
|
fill,
|
|
37
|
-
fill_,
|
|
38
37
|
full,
|
|
39
38
|
full_like,
|
|
40
39
|
chunk,
|
|
@@ -243,6 +242,7 @@ from .math_func import (
|
|
|
243
242
|
exp,
|
|
244
243
|
tensor_expm1,
|
|
245
244
|
expm1,
|
|
245
|
+
eq,
|
|
246
246
|
equal,
|
|
247
247
|
not_equal,
|
|
248
248
|
ne,
|
|
@@ -445,6 +445,7 @@ from .math_func import (
|
|
|
445
445
|
vecdot,
|
|
446
446
|
dot,
|
|
447
447
|
batch_dot,
|
|
448
|
+
eps,
|
|
448
449
|
)
|
|
449
450
|
from .nn_func import (
|
|
450
451
|
adaptive_avg_pool1d,
|
|
@@ -502,6 +503,7 @@ from .nn_func import (
|
|
|
502
503
|
softmax,
|
|
503
504
|
softmin,
|
|
504
505
|
softshrink,
|
|
506
|
+
softplus,
|
|
505
507
|
pdist,
|
|
506
508
|
pad,
|
|
507
509
|
prelu,
|
|
@@ -709,6 +711,7 @@ from .sparse_unary_func import (
|
|
|
709
711
|
)
|
|
710
712
|
from .clip_func import (
|
|
711
713
|
clip_by_value,
|
|
714
|
+
clip_by_norm,
|
|
712
715
|
clamp,
|
|
713
716
|
clip,
|
|
714
717
|
clip_by_global_norm,
|