mindspore 1.10.0__cp38-cp38-win_amd64.whl → 2.0.0rc1__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/ConcurrencyCheck.dll +0 -0
- mindspore/CppBuildInsights.dll +0 -0
- mindspore/CppCoreCheck.dll +0 -0
- mindspore/EnumIndex.dll +0 -0
- mindspore/EspXEngine.dll +0 -0
- mindspore/HResultCheck.dll +0 -0
- mindspore/KernelTraceControl.dll +0 -0
- mindspore/LocalESPC.dll +0 -0
- mindspore/Microsoft.Diagnostics.Tracing.EventSource.dll +0 -0
- mindspore/Microsoft.VisualStudio.RemoteControl.dll +0 -0
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Microsoft.VisualStudio.Utilities.Internal.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- mindspore/VariantClear.dll +0 -0
- mindspore/__init__.py +9 -4
- 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 +102 -0
- mindspore/_checkparam.py +1066 -1001
- mindspore/_extends/builtin_operations.py +32 -4
- mindspore/_extends/graph_kernel/model/graph_split.py +66 -222
- mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +12 -9
- mindspore/_extends/parallel_compile/akg_compiler/build_tbe_kernel.py +119 -26
- mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +50 -50
- mindspore/_extends/parallel_compile/akg_compiler/util.py +9 -6
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +4 -25
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +9 -4
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_job_manager.py +1 -27
- mindspore/_extends/parse/__init__.py +5 -3
- mindspore/_extends/parse/namespace.py +17 -2
- mindspore/_extends/parse/parser.py +193 -34
- mindspore/_extends/parse/resources.py +7 -8
- mindspore/_extends/parse/standard_method.py +1780 -435
- mindspore/_extends/parse/trope.py +3 -1
- mindspore/amp.py +53 -58
- mindspore/atlprov.dll +0 -0
- mindspore/boost/adasum.py +3 -2
- mindspore/boost/boost.py +2 -2
- mindspore/boost/boost_cell_wrapper.py +46 -26
- mindspore/boost/dim_reduce.py +6 -5
- mindspore/boost/grad_accumulation.py +2 -1
- mindspore/boost/group_loss_scale_manager.py +1 -1
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/cfgpersist.dll +0 -0
- mindspore/clang_rt.asan_dbg_dynamic-x86_64.dll +0 -0
- mindspore/clang_rt.asan_dynamic-x86_64.dll +0 -0
- mindspore/common/__init__.py +11 -10
- mindspore/common/_decorator.py +2 -0
- mindspore/common/_register_for_adapter.py +55 -0
- mindspore/common/_stub_tensor.py +201 -0
- mindspore/common/_utils.py +57 -0
- mindspore/common/api.py +582 -297
- mindspore/common/dtype.py +66 -18
- mindspore/common/dump.py +2 -2
- mindspore/common/initializer.py +38 -1
- mindspore/common/jit_config.py +25 -13
- mindspore/common/mutable.py +53 -24
- mindspore/common/parameter.py +60 -37
- mindspore/common/seed.py +8 -24
- mindspore/common/sparse_tensor.py +927 -0
- mindspore/common/tensor.py +1627 -3900
- mindspore/communication/__init__.py +10 -5
- mindspore/communication/_comm_helper.py +78 -214
- mindspore/communication/_hccl_management.py +2 -1
- mindspore/communication/management.py +136 -47
- mindspore/config/op_info.config +501 -1008
- mindspore/context.py +291 -56
- mindspore/d3dcompiler_47.dll +0 -0
- mindspore/dataset/__init__.py +12 -8
- mindspore/dataset/audio/__init__.py +9 -9
- mindspore/dataset/audio/transforms.py +1090 -228
- mindspore/dataset/audio/utils.py +87 -39
- mindspore/dataset/audio/validators.py +223 -1
- mindspore/dataset/callback/ds_callback.py +17 -15
- mindspore/dataset/core/config.py +246 -17
- mindspore/dataset/core/py_util_helpers.py +4 -3
- mindspore/dataset/core/validator_helpers.py +10 -10
- mindspore/{parallel/nn/layers.py → dataset/debug/__init__.py} +7 -8
- mindspore/dataset/debug/debug_hook.py +65 -0
- mindspore/dataset/debug/pre_defined_hook.py +67 -0
- mindspore/dataset/engine/__init__.py +7 -3
- mindspore/dataset/engine/cache_client.py +9 -9
- mindspore/dataset/engine/datasets.py +648 -477
- mindspore/dataset/engine/datasets_audio.py +165 -167
- mindspore/dataset/engine/datasets_standard_format.py +93 -67
- mindspore/dataset/engine/datasets_text.py +492 -342
- mindspore/dataset/engine/datasets_user_defined.py +85 -50
- mindspore/dataset/engine/datasets_vision.py +1224 -699
- mindspore/dataset/engine/graphdata.py +134 -69
- mindspore/dataset/engine/iterators.py +50 -9
- mindspore/dataset/engine/offload.py +52 -31
- mindspore/dataset/engine/samplers.py +27 -24
- mindspore/dataset/engine/serializer_deserializer.py +14 -15
- mindspore/dataset/engine/validators.py +213 -52
- mindspore/dataset/text/__init__.py +10 -8
- mindspore/dataset/text/transforms.py +152 -57
- mindspore/dataset/text/utils.py +98 -49
- mindspore/dataset/text/validators.py +25 -0
- mindspore/dataset/transforms/__init__.py +4 -2
- mindspore/dataset/transforms/c_transforms.py +11 -13
- mindspore/dataset/transforms/py_transforms.py +2 -2
- mindspore/dataset/transforms/py_transforms_util.py +10 -0
- mindspore/dataset/transforms/transforms.py +13 -15
- mindspore/dataset/transforms/validators.py +7 -7
- mindspore/dataset/utils/__init__.py +2 -1
- mindspore/dataset/utils/browse_dataset.py +13 -13
- mindspore/dataset/utils/line_reader.py +121 -0
- mindspore/dataset/vision/__init__.py +8 -7
- mindspore/dataset/vision/c_transforms.py +125 -126
- mindspore/dataset/vision/py_transforms.py +37 -37
- mindspore/dataset/vision/py_transforms_util.py +23 -20
- mindspore/dataset/vision/transforms.py +316 -315
- mindspore/dataset/vision/utils.py +313 -17
- mindspore/dataset/vision/validators.py +6 -6
- mindspore/default_config.py +0 -1
- mindspore/dpcmi.dll +0 -0
- mindspore/{compression → experimental}/__init__.py +6 -5
- mindspore/experimental/map_parameter.py +275 -0
- mindspore/include/OWNERS +0 -1
- mindspore/include/api/callback/callback.h +9 -13
- mindspore/include/api/callback/ckpt_saver.h +2 -2
- mindspore/include/api/callback/loss_monitor.h +2 -2
- mindspore/include/api/callback/lr_scheduler.h +5 -5
- mindspore/include/api/callback/time_monitor.h +2 -2
- mindspore/include/api/callback/train_accuracy.h +4 -6
- mindspore/include/api/cfg.h +19 -6
- mindspore/include/api/context.h +70 -9
- mindspore/include/api/delegate.h +8 -1
- mindspore/include/api/dual_abi_helper.h +8 -24
- mindspore/include/api/metrics/accuracy.h +2 -2
- mindspore/include/api/metrics/metrics.h +4 -3
- mindspore/include/api/model.h +9 -4
- mindspore/include/api/model_group.h +68 -0
- mindspore/include/api/model_parallel_runner.h +17 -17
- mindspore/include/api/net.h +12 -11
- mindspore/include/api/serialization.h +20 -4
- mindspore/include/api/status.h +7 -1
- mindspore/include/api/types.h +25 -21
- mindspore/include/api/visible.h +4 -0
- mindspore/include/c_api/model_c.h +5 -0
- mindspore/include/c_api/status_c.h +1 -1
- mindspore/include/dataset/config.h +1 -1
- mindspore/include/dataset/constants.h +14 -0
- mindspore/include/dataset/text.h +59 -0
- mindspore/include/dataset/vision.h +56 -117
- mindspore/include/dataset/vision_lite.h +102 -0
- mindspore/jpeg62.dll +0 -0
- mindspore/log.py +28 -28
- mindspore/mindrecord/common/exceptions.py +2 -4
- mindspore/mindrecord/filereader.py +19 -1
- mindspore/mindrecord/filewriter.py +250 -88
- mindspore/mindrecord/mindpage.py +13 -13
- mindspore/mindrecord/shardheader.py +15 -15
- mindspore/mindrecord/shardreader.py +9 -0
- mindspore/mindrecord/shardwriter.py +29 -29
- mindspore/mindrecord/tools/cifar100_to_mr.py +9 -9
- mindspore/mindrecord/tools/cifar10_to_mr.py +9 -9
- mindspore/mindrecord/tools/csv_to_mr.py +4 -4
- mindspore/mindrecord/tools/imagenet_to_mr.py +70 -65
- mindspore/mindrecord/tools/mnist_to_mr.py +41 -41
- mindspore/mindrecord/tools/tfrecord_to_mr.py +6 -6
- mindspore/{libmindspore_backend.dll → 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 +1 -5
- mindspore/nn/cell.py +297 -234
- mindspore/nn/dynamic_lr.py +1 -1
- mindspore/nn/grad/cell_grad.py +17 -42
- mindspore/nn/layer/__init__.py +7 -4
- mindspore/nn/layer/activation.py +131 -88
- mindspore/nn/layer/basic.py +313 -613
- mindspore/nn/layer/channel_shuffle.py +103 -0
- mindspore/nn/layer/combined.py +1 -1
- mindspore/nn/layer/container.py +52 -6
- mindspore/nn/layer/conv.py +112 -43
- mindspore/nn/layer/dense.py +10 -9
- mindspore/nn/layer/embedding.py +36 -34
- mindspore/nn/layer/image.py +123 -27
- mindspore/nn/layer/math.py +108 -107
- mindspore/nn/layer/normalization.py +212 -366
- mindspore/nn/layer/padding.py +370 -42
- mindspore/nn/layer/pooling.py +1443 -219
- mindspore/nn/layer/rnn_cells.py +11 -16
- mindspore/nn/layer/rnns.py +38 -39
- mindspore/nn/layer/thor_layer.py +24 -25
- mindspore/nn/layer/timedistributed.py +5 -5
- mindspore/nn/layer/transformer.py +701 -0
- mindspore/nn/learning_rate_schedule.py +8 -8
- mindspore/nn/loss/__init__.py +9 -6
- mindspore/nn/loss/loss.py +678 -142
- mindspore/nn/metrics.py +53 -0
- mindspore/nn/optim/_dist_optimizer_registry.py +2 -2
- mindspore/nn/optim/ada_grad.py +8 -8
- mindspore/nn/optim/adadelta.py +2 -3
- mindspore/nn/optim/adafactor.py +18 -14
- mindspore/nn/optim/adam.py +429 -87
- mindspore/nn/optim/adamax.py +5 -6
- mindspore/nn/optim/adasum.py +10 -8
- mindspore/nn/optim/asgd.py +7 -7
- mindspore/nn/optim/ftrl.py +81 -11
- mindspore/nn/optim/lamb.py +7 -8
- mindspore/nn/optim/lars.py +4 -4
- mindspore/nn/optim/lazyadam.py +82 -7
- mindspore/nn/optim/momentum.py +8 -7
- mindspore/nn/optim/optimizer.py +19 -10
- mindspore/nn/optim/proximal_ada_grad.py +6 -5
- mindspore/nn/optim/rmsprop.py +3 -3
- mindspore/nn/optim/rprop.py +20 -16
- mindspore/nn/optim/sgd.py +21 -15
- mindspore/nn/optim/thor.py +23 -21
- mindspore/nn/probability/__init__.py +0 -2
- mindspore/nn/probability/bijector/bijector.py +7 -6
- mindspore/nn/probability/bijector/invert.py +4 -2
- mindspore/nn/probability/bijector/softplus.py +2 -2
- mindspore/nn/probability/bnn_layers/dense_variational.py +1 -1
- mindspore/nn/probability/bnn_layers/layer_distribution.py +2 -2
- mindspore/nn/probability/distribution/__init__.py +6 -0
- mindspore/nn/probability/distribution/_utils/custom_ops.py +3 -2
- mindspore/nn/probability/distribution/_utils/utils.py +11 -17
- mindspore/nn/probability/distribution/bernoulli.py +6 -6
- mindspore/nn/probability/distribution/beta.py +1 -1
- mindspore/nn/probability/distribution/categorical.py +9 -9
- mindspore/nn/probability/distribution/cauchy.py +8 -8
- mindspore/nn/probability/distribution/distribution.py +12 -6
- mindspore/nn/probability/distribution/exponential.py +5 -5
- mindspore/nn/probability/distribution/gamma.py +3 -3
- mindspore/nn/probability/distribution/geometric.py +6 -5
- mindspore/nn/probability/distribution/gumbel.py +5 -5
- mindspore/nn/probability/distribution/half_normal.py +133 -0
- mindspore/nn/probability/distribution/laplace.py +128 -0
- mindspore/nn/probability/distribution/log_normal.py +0 -1
- mindspore/nn/probability/distribution/logistic.py +4 -5
- mindspore/nn/probability/distribution/normal.py +11 -15
- mindspore/nn/probability/distribution/poisson.py +6 -2
- mindspore/nn/probability/distribution/student_t.py +150 -0
- mindspore/nn/probability/distribution/transformed_distribution.py +4 -4
- mindspore/nn/probability/distribution/uniform.py +5 -5
- mindspore/nn/reinforcement/_tensors_queue.py +3 -3
- mindspore/nn/reinforcement/tensor_array.py +2 -2
- mindspore/nn/sparse/sparse.py +8 -1
- mindspore/nn/wrap/cell_wrapper.py +55 -27
- mindspore/nn/wrap/grad_reducer.py +20 -11
- mindspore/nn/wrap/loss_scale.py +47 -30
- mindspore/numpy/array_creations.py +33 -22
- mindspore/numpy/array_ops.py +46 -42
- mindspore/numpy/logic_ops.py +6 -27
- mindspore/numpy/math_ops.py +26 -19
- mindspore/numpy/utils.py +1 -8
- mindspore/numpy/utils_const.py +112 -62
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/__init__.py +6 -3
- mindspore/ops/_constants.py +0 -6
- mindspore/ops/_grad/__init__.py +2 -1
- mindspore/ops/_grad/grad_array_ops.py +209 -152
- mindspore/ops/_grad/grad_base.py +55 -17
- mindspore/ops/_grad/grad_clip_ops.py +11 -3
- mindspore/ops/_grad/grad_comm_ops.py +58 -47
- mindspore/ops/_grad/grad_implementations.py +21 -61
- mindspore/ops/_grad/grad_inner_ops.py +48 -6
- mindspore/ops/_grad/grad_math_ops.py +306 -161
- mindspore/ops/_grad/grad_nn_ops.py +192 -181
- mindspore/ops/_grad/grad_other_ops.py +1 -1
- mindspore/ops/_grad/grad_quant_ops.py +5 -5
- mindspore/ops/_grad/grad_sequence_ops.py +296 -0
- mindspore/ops/_grad/grad_sparse.py +15 -9
- mindspore/ops/_grad_experimental/__init__.py +1 -0
- mindspore/ops/_grad_experimental/grad_array_ops.py +441 -55
- mindspore/ops/_grad_experimental/grad_image_ops.py +25 -7
- mindspore/ops/_grad_experimental/grad_inner_ops.py +3 -44
- mindspore/ops/_grad_experimental/grad_linalg_ops.py +16 -21
- mindspore/ops/_grad_experimental/grad_math_ops.py +979 -49
- mindspore/ops/_grad_experimental/grad_nn_ops.py +78 -8
- mindspore/ops/_grad_experimental/grad_scalar_ops.py +112 -0
- mindspore/ops/_grad_experimental/grad_sparse_ops.py +197 -13
- mindspore/ops/_op_impl/__init__.py +3 -3
- mindspore/ops/_op_impl/_custom_op/__init__.py +0 -1
- mindspore/ops/_op_impl/_custom_op/_basic.py +0 -1
- mindspore/ops/_op_impl/_custom_op/batch_matmul_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold.py +4 -2
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold2.py +2 -2
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold2_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold2_grad_reduce.py +5 -5
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold_grad.py +3 -3
- mindspore/ops/_op_impl/_custom_op/cholesky_trsm_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/correction_mul.py +3 -3
- mindspore/ops/_op_impl/_custom_op/correction_mul_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py +4 -8
- mindspore/ops/_op_impl/_custom_op/dsd_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perchannel.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perchannel_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perchannel_grad_reduce.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perlayer.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perlayer_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perlayer_grad_reduce.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_quant_perchannel.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_quant_perchannel_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_quant_perlayer.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_quant_perlayer_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fused_abs_max1_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/img2col_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_left_impl.py +2 -2
- mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_right_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_left_cast_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_right_mul_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/matmul_cube_impl.py +2 -2
- mindspore/ops/_op_impl/_custom_op/matmul_dds_grad_impl.py +0 -1
- mindspore/ops/_op_impl/_custom_op/matmul_dds_impl.py +0 -1
- mindspore/ops/_op_impl/_custom_op/matrix_combine_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/minmax_update_perchannel.py +2 -2
- mindspore/ops/_op_impl/_custom_op/minmax_update_perlayer.py +2 -2
- mindspore/ops/_op_impl/_custom_op/transpose02314_impl.py +1 -1
- mindspore/ops/_op_impl/aicpu/__init__.py +238 -3
- mindspore/ops/_op_impl/aicpu/abs.py +36 -0
- mindspore/ops/_op_impl/aicpu/adaptive_avg_pool_2d.py +34 -0
- mindspore/ops/_op_impl/aicpu/adaptive_avg_pool_2d_grad.py +34 -0
- mindspore/ops/_op_impl/aicpu/adaptive_avg_pool_3d.py +39 -0
- mindspore/ops/_op_impl/aicpu/adaptive_avg_pool_3d_grad.py +39 -0
- mindspore/ops/_op_impl/aicpu/adaptive_max_pool_2d_grad.py +37 -0
- mindspore/ops/_op_impl/aicpu/adaptive_max_pool_3d.py +42 -0
- mindspore/ops/_op_impl/aicpu/adaptive_max_pool_3d_grad.py +152 -0
- mindspore/ops/_op_impl/aicpu/add.py +43 -0
- mindspore/ops/_op_impl/aicpu/addcdiv.py +0 -32
- mindspore/ops/_op_impl/aicpu/addcmul.py +0 -84
- mindspore/ops/_op_impl/aicpu/affine_grid_grad.py +35 -0
- mindspore/ops/_op_impl/aicpu/arg_max.py +75 -0
- mindspore/ops/_op_impl/aicpu/arg_min.py +75 -0
- mindspore/ops/_op_impl/aicpu/argmin_with_value.py +43 -0
- mindspore/ops/_op_impl/aicpu/batch_matmul.py +43 -0
- mindspore/ops/_op_impl/aicpu/batch_norm_grad_grad.py +49 -0
- mindspore/ops/_op_impl/aicpu/bernoulli.py +48 -0
- mindspore/ops/_op_impl/aicpu/bessel_i0.py +31 -0
- mindspore/ops/_op_impl/aicpu/bias_add.py +44 -0
- mindspore/ops/_op_impl/aicpu/bias_add_grad.py +43 -0
- mindspore/ops/_op_impl/aicpu/bincount.py +33 -0
- mindspore/{nn/probability/infer/variational/__init__.py → ops/_op_impl/aicpu/cauchy.py} +17 -10
- mindspore/ops/_op_impl/aicpu/channel_shuffle.py +40 -0
- mindspore/ops/_op_impl/aicpu/cholesky.py +1 -1
- mindspore/ops/_op_impl/{cpu/bias_add.py → aicpu/choleskygrad.py} +9 -7
- mindspore/ops/_op_impl/aicpu/combined_non_max_suppression.py +42 -0
- mindspore/ops/_op_impl/aicpu/concat_offset.py +42 -0
- mindspore/ops/_op_impl/aicpu/concat_offset_v1.py +31 -0
- mindspore/ops/_op_impl/aicpu/conj.py +11 -0
- mindspore/ops/_op_impl/aicpu/crop_and_resize_grad_image.py +38 -0
- mindspore/ops/_op_impl/aicpu/cumulative_logsumexp.py +36 -0
- mindspore/ops/_op_impl/aicpu/deformable_offsets.py +38 -0
- mindspore/ops/_op_impl/aicpu/deformable_offsets_grad.py +2 -2
- mindspore/ops/_op_impl/aicpu/dense_to_sparse_set_operation.py +48 -0
- mindspore/ops/_op_impl/aicpu/diag.py +36 -0
- mindspore/ops/_op_impl/aicpu/diag_part.py +36 -0
- mindspore/ops/_op_impl/aicpu/diagonal.py +35 -0
- mindspore/ops/_op_impl/{cpu/bias_add_grad.py → aicpu/digamma.py} +9 -7
- mindspore/ops/_op_impl/aicpu/eig.py +35 -0
- mindspore/ops/_op_impl/aicpu/fft_with_size.py +41 -0
- mindspore/ops/_op_impl/aicpu/flatten.py +1 -0
- mindspore/ops/_op_impl/aicpu/fmax.py +36 -0
- mindspore/ops/_op_impl/aicpu/fmin.py +37 -0
- mindspore/ops/_op_impl/aicpu/fractional_max_pool3d_with_fixed_ksize.py +1 -1
- mindspore/ops/_op_impl/aicpu/fse_decode.py +43 -0
- mindspore/ops/_op_impl/aicpu/glu.py +33 -0
- mindspore/ops/_op_impl/aicpu/glu_grad.py +34 -0
- mindspore/ops/_op_impl/aicpu/greater.py +41 -0
- mindspore/ops/_op_impl/aicpu/greater_equal.py +41 -0
- mindspore/ops/_op_impl/aicpu/index_put.py +50 -0
- mindspore/ops/_op_impl/{tbe/scatter_add_ds.py → aicpu/inplace_index_add.py} +17 -21
- mindspore/ops/_op_impl/aicpu/instance_norm_v2.py +41 -0
- mindspore/ops/_op_impl/aicpu/instance_norm_v2_grad.py +44 -0
- mindspore/ops/_op_impl/aicpu/layer_norm_grad_grad.py +47 -0
- mindspore/ops/_op_impl/aicpu/less.py +41 -0
- mindspore/ops/_op_impl/aicpu/less_equal.py +41 -0
- mindspore/ops/_op_impl/aicpu/lgamma.py +32 -0
- mindspore/ops/_op_impl/aicpu/log_normal_reverse.py +33 -0
- mindspore/ops/_op_impl/aicpu/logit.py +33 -0
- mindspore/ops/_op_impl/aicpu/logit_grad.py +34 -0
- mindspore/ops/_op_impl/aicpu/masked_fill.py +42 -0
- mindspore/ops/_op_impl/aicpu/masked_scatter.py +39 -0
- mindspore/ops/_op_impl/aicpu/matmul.py +39 -0
- mindspore/ops/_op_impl/aicpu/matrix_logarithm.py +31 -0
- mindspore/ops/_op_impl/aicpu/matrix_power.py +32 -0
- mindspore/ops/_op_impl/aicpu/matrix_solve_ls.py +36 -0
- mindspore/ops/_op_impl/aicpu/matrix_triangular_solve.py +36 -0
- mindspore/ops/_op_impl/aicpu/mirror_pad.py +2 -0
- mindspore/ops/_op_impl/aicpu/mirror_pad_grad.py +0 -4
- mindspore/ops/_op_impl/aicpu/mul.py +3 -1
- mindspore/ops/_op_impl/aicpu/multinomial.py +14 -6
- mindspore/ops/_op_impl/aicpu/multinomial_with_replacement.py +35 -0
- mindspore/ops/_op_impl/aicpu/nan_to_num.py +34 -0
- mindspore/ops/_op_impl/aicpu/nllloss.py +38 -0
- mindspore/ops/_op_impl/aicpu/nllloss_grad.py +39 -0
- mindspore/ops/_op_impl/aicpu/ones_like.py +0 -2
- mindspore/ops/_op_impl/aicpu/polar.py +32 -0
- mindspore/ops/_op_impl/aicpu/polygamma.py +34 -0
- mindspore/ops/_op_impl/aicpu/qr.py +36 -0
- mindspore/ops/_op_impl/aicpu/quant_dtype_cast.py +40 -0
- mindspore/ops/_op_impl/aicpu/quantile.py +35 -0
- mindspore/ops/_op_impl/aicpu/ragged_tensor_to_sparse.py +73 -0
- mindspore/ops/_op_impl/aicpu/ragged_tensor_to_tensor.py +74 -0
- mindspore/ops/_op_impl/aicpu/random_shuffle.py +3 -0
- mindspore/ops/_op_impl/aicpu/randperm_v2.py +41 -0
- mindspore/ops/_op_impl/aicpu/range.py +36 -0
- mindspore/ops/_op_impl/aicpu/reciprocal.py +34 -0
- mindspore/ops/_op_impl/aicpu/reciprocal_grad.py +35 -0
- mindspore/ops/_op_impl/aicpu/reduce_sum.py +57 -0
- mindspore/ops/_op_impl/aicpu/resize_bicubic.py +2 -8
- mindspore/ops/_op_impl/aicpu/resize_bicubic_grad.py +1 -1
- mindspore/ops/_op_impl/aicpu/resize_v2.py +68 -0
- mindspore/ops/_op_impl/aicpu/resize_v2_grad.py +68 -0
- mindspore/ops/_op_impl/aicpu/scatter_elements.py +4 -0
- mindspore/ops/_op_impl/aicpu/scatter_nd_update.py +2 -0
- mindspore/ops/_op_impl/aicpu/search_sorted.py +12 -6
- mindspore/ops/_op_impl/aicpu/self_adjoint_eig.py +34 -0
- mindspore/ops/_op_impl/aicpu/sequence_add.py +34 -0
- mindspore/ops/_op_impl/aicpu/sequence_add_offset.py +34 -0
- mindspore/ops/_op_impl/aicpu/sequence_addn.py +38 -0
- mindspore/ops/_op_impl/aicpu/slice_grad.py +76 -0
- mindspore/ops/_op_impl/aicpu/smooth_l1_loss.py +35 -0
- mindspore/ops/_op_impl/aicpu/smooth_l1_loss_grad.py +37 -0
- mindspore/ops/_op_impl/aicpu/sort.py +39 -0
- mindspore/ops/_op_impl/aicpu/sparse_apply_adagrad_da.py +0 -24
- mindspore/ops/_op_impl/aicpu/sparse_cross.py +42 -0
- mindspore/ops/_op_impl/aicpu/sparse_fill_empty_rows.py +63 -0
- mindspore/ops/_op_impl/aicpu/sparse_fill_empty_rows_grad.py +45 -0
- mindspore/ops/_op_impl/aicpu/sparse_matrix_mat_mul.py +56 -0
- mindspore/ops/_op_impl/{tbe/slice_ds.py → aicpu/sparse_segment_sum.py} +16 -24
- mindspore/ops/_op_impl/aicpu/sparse_segment_sum_with_num_segments.py +68 -0
- mindspore/ops/_op_impl/aicpu/sparse_slice.py +63 -0
- mindspore/ops/_op_impl/aicpu/sparse_slice_grad.py +61 -0
- mindspore/ops/_op_impl/aicpu/squared_difference.py +2 -0
- mindspore/ops/_op_impl/aicpu/strided_slice_v2.py +93 -0
- mindspore/ops/_op_impl/aicpu/strided_slice_v2_grad.py +66 -0
- mindspore/ops/_op_impl/aicpu/tensor_scatter_update.py +59 -0
- mindspore/ops/_op_impl/{tbe/gather_v2.py → aicpu/tile.py} +24 -24
- mindspore/ops/_op_impl/aicpu/tridiagonal_solve.py +35 -0
- mindspore/ops/_op_impl/aicpu/tril_indices.py +34 -0
- mindspore/ops/_op_impl/aicpu/triu_indices.py +34 -0
- mindspore/ops/_op_impl/aicpu/uniform.py +34 -0
- mindspore/ops/_op_impl/aicpu/uniform_candidate_sampler.py +1 -0
- mindspore/ops/_op_impl/aicpu/unique_consecutive.py +10 -2
- mindspore/ops/_op_impl/cpu/__init__.py +1 -2
- mindspore/ops/_op_impl/cpu/dynamic_shape.py +5 -1
- mindspore/ops/_op_impl/cpu/maximum_grad.py +2 -0
- mindspore/{compression/common/__init__.py → ops/_op_impl/cpu/pyexecute.py} +13 -8
- mindspore/ops/_op_impl/cpu/reduce_sum.py +8 -0
- mindspore/ops/_op_impl/cpu/sparse_slice.py +62 -0
- mindspore/ops/_op_impl/cpu/sparse_slice_grad.py +60 -0
- mindspore/ops/_op_impl/cpu/tensor_shape.py +5 -1
- mindspore/ops/_op_impl/tbe/__init__.py +27 -608
- mindspore/ops/_op_impl/tbe/addcdiv_ds.py +42 -0
- mindspore/ops/_op_impl/tbe/addcmul_ds.py +44 -0
- mindspore/ops/_op_impl/tbe/assign_add_ds.py +1 -0
- mindspore/ops/_op_impl/tbe/atomic_addr_clean.py +1 -1
- mindspore/ops/_op_impl/tbe/avg_pool_3d_grad.py +1 -1
- mindspore/ops/_op_impl/tbe/basic_lstm_cell_c_state_grad_v2.py +0 -1
- mindspore/ops/_op_impl/tbe/batch_to_space.py +1 -1
- mindspore/ops/_op_impl/tbe/batch_to_space_nd.py +1 -1
- mindspore/ops/_op_impl/tbe/batch_to_space_nd_v2.py +41 -0
- mindspore/ops/_op_impl/tbe/bce_with_logits_loss.py +1 -0
- mindspore/ops/_op_impl/tbe/bias_add_grad.py +2 -0
- mindspore/ops/_op_impl/tbe/bn_infer_grad.py +4 -2
- mindspore/ops/_op_impl/tbe/bn_infer_grad_ds.py +40 -0
- mindspore/ops/_op_impl/tbe/bn_training_update.py +0 -1
- mindspore/ops/_op_impl/tbe/bn_training_update_ds.py +0 -1
- mindspore/ops/_op_impl/tbe/broadcast_to_ds.py +6 -4
- mindspore/ops/_op_impl/tbe/cast.py +0 -2
- mindspore/ops/_op_impl/tbe/cast_ds.py +3 -3
- mindspore/ops/_op_impl/tbe/ctc_loss_v2.py +0 -2
- mindspore/ops/_op_impl/tbe/ctc_loss_v2_grad.py +0 -2
- mindspore/ops/_op_impl/tbe/data_format_dim_map_ds.py +1 -0
- mindspore/ops/_op_impl/tbe/deformable_offsets.py +1 -0
- mindspore/ops/_op_impl/tbe/depthwise_conv2d.py +1 -1
- mindspore/ops/_op_impl/tbe/dynamic_atomic_addr_clean.py +1 -1
- mindspore/ops/_op_impl/tbe/gather_nd.py +1 -0
- mindspore/ops/_op_impl/tbe/greater.py +2 -0
- mindspore/ops/_op_impl/tbe/{index_add.py → inplace_index_add.py} +3 -6
- mindspore/ops/_op_impl/tbe/layer_norm_beta_gamma_backprop_v2.py +0 -1
- mindspore/ops/_op_impl/tbe/npu_clear_float_status_v2.py +35 -0
- mindspore/ops/_op_impl/tbe/npu_get_float_status_v2.py +35 -0
- mindspore/ops/_op_impl/tbe/one_hot_ds.py +0 -6
- mindspore/ops/_op_impl/tbe/{greater_ds.py → reduce_all_ds.py} +13 -16
- mindspore/ops/_op_impl/tbe/reduce_any_ds.py +39 -0
- mindspore/ops/_op_impl/tbe/roi_align_ds.py +44 -0
- mindspore/ops/_op_impl/tbe/roi_align_grad_ds.py +44 -0
- mindspore/ops/_op_impl/tbe/scatter_add.py +2 -0
- mindspore/ops/_op_impl/tbe/scatter_nd_add.py +2 -2
- mindspore/ops/_op_impl/tbe/slice.py +26 -15
- mindspore/ops/_op_impl/tbe/space_to_batch.py +1 -1
- mindspore/ops/_op_impl/tbe/space_to_batch_nd.py +1 -1
- mindspore/ops/_op_impl/tbe/strided_slice_grad_d.py +1 -0
- mindspore/ops/_op_impl/tbe/trans_data_ds.py +15 -5
- mindspore/ops/_op_impl/tbe/unsorted_segment_sum.py +1 -1
- mindspore/ops/_op_impl/tbe/unsorted_segment_sum_ds.py +2 -0
- mindspore/ops/_primitive_cache.py +3 -2
- mindspore/ops/_register_for_op.py +11 -0
- mindspore/ops/_utils/__init__.py +1 -1
- mindspore/ops/_utils/utils.py +20 -41
- mindspore/ops/_vmap/__init__.py +2 -2
- mindspore/ops/_vmap/vmap_array_ops.py +170 -78
- mindspore/ops/_vmap/vmap_base.py +24 -10
- mindspore/ops/_vmap/vmap_convolution_ops.py +7 -10
- mindspore/ops/_vmap/vmap_grad_math_ops.py +4 -4
- mindspore/ops/_vmap/vmap_grad_nn_ops.py +41 -9
- mindspore/ops/_vmap/vmap_image_ops.py +52 -0
- mindspore/ops/_vmap/vmap_math_ops.py +77 -6
- mindspore/ops/_vmap/vmap_nn_ops.py +78 -29
- mindspore/ops/_vmap/vmap_other_ops.py +3 -1
- mindspore/ops/_vmap/vmap_random_ops.py +55 -3
- mindspore/ops/_vmap/vmap_sparse_ops.py +1 -0
- 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 +18 -19
- mindspore/ops/bprop_mindir/Argmax_bprop.mindir +13 -12
- mindspore/ops/bprop_mindir/Argmin_bprop.mindir +14 -13
- mindspore/ops/bprop_mindir/AssignSub_bprop.mindir +17 -18
- mindspore/ops/bprop_mindir/Assign_bprop.mindir +16 -16
- mindspore/ops/bprop_mindir/AvgPool3D_bprop.mindir +150 -0
- mindspore/ops/bprop_mindir/AvgPool_bprop.mindir +66 -0
- mindspore/ops/bprop_mindir/BCEWithLogitsLoss_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir +13 -12
- mindspore/ops/bprop_mindir/BatchNormGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/BatchToSpaceND_bprop.mindir +28 -0
- mindspore/ops/bprop_mindir/BiasAddGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/BinaryCrossEntropy_bprop.mindir +33 -0
- mindspore/ops/bprop_mindir/BroadcastTo_bprop.mindir +306 -0
- mindspore/ops/bprop_mindir/Broadcast_bprop.mindir +12 -8
- 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 +240 -0
- mindspore/ops/bprop_mindir/Conv2DBackpropInput_bprop.mindir +247 -0
- mindspore/ops/bprop_mindir/Conv2DTranspose_bprop.mindir +247 -0
- mindspore/ops/bprop_mindir/Conv3DTranspose_bprop.mindir +315 -0
- mindspore/ops/bprop_mindir/Conv3D_bprop.mindir +278 -0
- mindspore/ops/bprop_mindir/DType_bprop.mindir +12 -12
- mindspore/ops/bprop_mindir/DeformableOffsets_bprop.mindir +58 -0
- mindspore/ops/bprop_mindir/Depend_bprop.mindir +12 -13
- mindspore/ops/bprop_mindir/DepthToSpace_bprop.mindir +23 -0
- mindspore/ops/bprop_mindir/DepthwiseConv2dNative_bprop.mindir +138 -0
- mindspore/ops/bprop_mindir/DiagPart_bprop.mindir +15 -0
- 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 +22 -24
- mindspore/ops/bprop_mindir/DropoutGenMask_bprop.mindir +16 -14
- mindspore/ops/bprop_mindir/DropoutGrad_bprop.mindir +27 -0
- 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 +12 -12
- mindspore/ops/bprop_mindir/Elu_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/EmbeddingLookup_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Equal_bprop.mindir +18 -19
- mindspore/ops/bprop_mindir/ExpandDims_bprop.mindir +58 -0
- mindspore/ops/bprop_mindir/FastGeLU_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/Flatten_bprop.mindir +54 -0
- mindspore/ops/bprop_mindir/FloorDiv_bprop.mindir +18 -15
- mindspore/ops/bprop_mindir/GatherD_bprop.mindir +26 -0
- mindspore/ops/bprop_mindir/GatherNd_bprop.mindir +57 -0
- mindspore/ops/bprop_mindir/Gather_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/GreaterEqual_bprop.mindir +17 -18
- mindspore/ops/bprop_mindir/Greater_bprop.mindir +18 -19
- mindspore/ops/bprop_mindir/HSigmoid_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/HSwish_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/IOU_bprop.mindir +18 -19
- mindspore/ops/bprop_mindir/InstanceNorm_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/IsFinite_bprop.mindir +13 -12
- mindspore/ops/bprop_mindir/IsInf_bprop.mindir +13 -10
- mindspore/ops/bprop_mindir/IsNan_bprop.mindir +14 -11
- mindspore/ops/bprop_mindir/KLDivLoss_bprop.mindir +126 -0
- mindspore/ops/bprop_mindir/L2Loss_bprop.mindir +15 -0
- mindspore/ops/bprop_mindir/L2Normalize_bprop.mindir +30 -0
- mindspore/ops/bprop_mindir/LRN_bprop.mindir +43 -0
- mindspore/ops/bprop_mindir/LayerNormGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/LessEqual_bprop.mindir +18 -19
- mindspore/ops/bprop_mindir/Less_bprop.mindir +17 -18
- mindspore/ops/bprop_mindir/LinSpace_bprop.mindir +22 -19
- mindspore/ops/bprop_mindir/Load_bprop.mindir +12 -13
- mindspore/ops/bprop_mindir/LogSoftmax_bprop.mindir +23 -0
- mindspore/ops/bprop_mindir/LogicalAnd_bprop.mindir +17 -18
- mindspore/ops/bprop_mindir/LogicalNot_bprop.mindir +14 -13
- mindspore/ops/bprop_mindir/MaskedSelect_bprop.mindir +21 -0
- mindspore/ops/bprop_mindir/MaxPool3DGradGrad_bprop.mindir +74 -0
- mindspore/ops/bprop_mindir/MaxPool3DGrad_bprop.mindir +74 -0
- mindspore/ops/bprop_mindir/MaxPool3D_bprop.mindir +75 -0
- mindspore/ops/bprop_mindir/MaxPoolGradGrad_bprop.mindir +65 -0
- 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 +27 -0
- mindspore/ops/bprop_mindir/Mish_bprop.mindir +35 -0
- 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 +14 -0
- mindspore/ops/bprop_mindir/NotEqual_bprop.mindir +18 -19
- mindspore/ops/bprop_mindir/OneHot_bprop.mindir +25 -23
- mindspore/ops/bprop_mindir/OnesLike_bprop.mindir +13 -13
- 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 +29 -0
- mindspore/ops/bprop_mindir/ROIAlign_bprop.mindir +82 -0
- mindspore/ops/bprop_mindir/Range_bprop.mindir +21 -19
- mindspore/ops/bprop_mindir/Rank_bprop.mindir +11 -11
- mindspore/ops/bprop_mindir/ReLU6_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/ReLUV2_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ReduceAll_bprop.mindir +18 -17
- mindspore/ops/bprop_mindir/ReduceAny_bprop.mindir +18 -17
- mindspore/ops/bprop_mindir/ReluGrad_bprop.mindir +19 -23
- mindspore/ops/bprop_mindir/Reshape_bprop.mindir +60 -0
- mindspore/ops/bprop_mindir/ResizeBilinear_bprop.mindir +29 -0
- mindspore/ops/bprop_mindir/ResizeNearestNeighbor_bprop.mindir +89 -0
- mindspore/ops/bprop_mindir/ReverseSequence_bprop.mindir +52 -0
- mindspore/ops/bprop_mindir/ReverseV2_bprop.mindir +22 -0
- mindspore/ops/bprop_mindir/Round_bprop.mindir +14 -13
- 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 +22 -0
- mindspore/ops/bprop_mindir/ScatterNd_bprop.mindir +24 -0
- mindspore/ops/bprop_mindir/ScatterNonAliasingAdd_bprop.mindir +22 -0
- mindspore/ops/bprop_mindir/ScatterUpdate_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SeLU_bprop.mindir +21 -0
- mindspore/ops/bprop_mindir/Select_bprop.mindir +30 -34
- mindspore/ops/bprop_mindir/Shape_bprop.mindir +12 -12
- mindspore/ops/bprop_mindir/SigmoidCrossEntropyWithLogits_bprop.mindir +21 -0
- mindspore/ops/bprop_mindir/SigmoidGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Sigmoid_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/Sign_bprop.mindir +13 -12
- mindspore/ops/bprop_mindir/Slice_bprop.mindir +26 -0
- mindspore/ops/bprop_mindir/SmoothL1Loss_bprop.mindir +36 -0
- mindspore/ops/bprop_mindir/SoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Softplus_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/Softsign_bprop.mindir +33 -0
- mindspore/ops/bprop_mindir/Sort_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SpaceToBatchND_bprop.mindir +28 -0
- mindspore/ops/bprop_mindir/SpaceToDepth_bprop.mindir +23 -0
- 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 +22 -0
- mindspore/ops/bprop_mindir/Squeeze_bprop.mindir +54 -0
- mindspore/ops/bprop_mindir/StridedSliceGrad_bprop.mindir +95 -0
- mindspore/ops/bprop_mindir/StridedSlice_bprop.mindir +98 -0
- mindspore/ops/bprop_mindir/Switch_bprop.mindir +28 -32
- mindspore/ops/bprop_mindir/TanhGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Tanh_bprop.mindir +66 -0
- mindspore/ops/bprop_mindir/TensorScatterAdd_bprop.mindir +22 -0
- mindspore/ops/bprop_mindir/TensorScatterUpdate_bprop.mindir +29 -0
- mindspore/ops/bprop_mindir/TensorShape_bprop.mindir +14 -0
- 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 +23 -0
- mindspore/ops/bprop_mindir/TruncateDiv_bprop.mindir +18 -15
- mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir +11 -13
- mindspore/ops/bprop_mindir/Unique_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/Unstack_bprop.mindir +22 -0
- mindspore/ops/bprop_mindir/UpsampleNearest3D_bprop.mindir +32 -0
- mindspore/ops/bprop_mindir/UpsampleTrilinear3D_bprop.mindir +38 -0
- mindspore/ops/bprop_mindir/ZerosLike_bprop.mindir +13 -12
- mindspore/ops/bprop_mindir/__init__.py +1 -4
- mindspore/ops/bprop_mindir/generate_mindir.py +32 -20
- mindspore/ops/composite/__init__.py +12 -13
- mindspore/ops/composite/base.py +261 -254
- mindspore/ops/composite/env_ops.py +41 -0
- mindspore/ops/composite/math_ops.py +197 -156
- mindspore/ops/composite/multitype_ops/_compile_utils.py +428 -176
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +188 -87
- mindspore/ops/composite/multitype_ops/add_impl.py +23 -1
- mindspore/ops/composite/multitype_ops/div_impl.py +3 -3
- mindspore/ops/composite/multitype_ops/equal_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/floordiv_impl.py +1 -1
- mindspore/ops/composite/multitype_ops/getitem_impl.py +52 -5
- mindspore/ops/composite/multitype_ops/greater_equal_impl.py +31 -0
- mindspore/ops/composite/multitype_ops/greater_impl.py +31 -0
- mindspore/ops/composite/multitype_ops/in_impl.py +15 -3
- mindspore/ops/composite/multitype_ops/less_equal_impl.py +33 -2
- mindspore/ops/composite/multitype_ops/less_impl.py +33 -0
- mindspore/ops/composite/multitype_ops/logical_and_impl.py +2 -2
- mindspore/ops/composite/multitype_ops/logical_or_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/mod_impl.py +1 -1
- mindspore/ops/composite/multitype_ops/mul_impl.py +21 -7
- mindspore/ops/composite/multitype_ops/not_in_impl.py +15 -3
- mindspore/ops/composite/multitype_ops/ones_like_impl.py +2 -4
- mindspore/ops/composite/multitype_ops/pow_impl.py +1 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +62 -70
- mindspore/ops/composite/multitype_ops/sub_impl.py +3 -3
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +41 -4
- mindspore/ops/function/__init__.py +323 -8
- mindspore/ops/function/array_func.py +3511 -780
- mindspore/ops/function/clip_func.py +329 -0
- mindspore/ops/function/debug_func.py +6 -6
- mindspore/ops/function/grad/__init__.py +5 -1
- mindspore/ops/function/grad/grad_func.py +736 -65
- mindspore/ops/function/image_func.py +270 -0
- mindspore/ops/function/linalg_func.py +268 -8
- mindspore/ops/function/math_func.py +8032 -3164
- mindspore/ops/function/nn_func.py +5619 -1855
- mindspore/ops/function/other_func.py +115 -0
- mindspore/ops/function/parameter_func.py +11 -10
- mindspore/ops/function/random_func.py +939 -77
- mindspore/ops/function/sparse_func.py +249 -84
- mindspore/ops/function/sparse_unary_func.py +2303 -0
- mindspore/ops/function/spectral_func.py +146 -0
- mindspore/ops/function/vmap_func.py +114 -0
- mindspore/ops/functional.py +182 -254
- mindspore/ops/op_info_register.py +79 -34
- mindspore/ops/operations/__init__.py +210 -118
- mindspore/ops/operations/_csr_ops.py +7 -7
- mindspore/ops/operations/_embedding_cache_ops.py +25 -15
- mindspore/ops/operations/_grad_ops.py +447 -322
- mindspore/ops/operations/_inner_ops.py +547 -176
- mindspore/ops/operations/_map_tensor_ops.py +112 -0
- mindspore/ops/operations/_ms_kernel.py +29 -27
- mindspore/ops/operations/_ocr_ops.py +11 -11
- mindspore/ops/operations/_opaque_predicate_registry.py +41 -0
- mindspore/ops/operations/_quant_ops.py +186 -101
- mindspore/ops/operations/_rl_inner_ops.py +122 -61
- mindspore/ops/operations/_scalar_ops.py +466 -0
- mindspore/ops/operations/_sequence_ops.py +1047 -0
- mindspore/ops/operations/_tensor_array.py +10 -11
- mindspore/ops/operations/_thor_ops.py +4 -4
- mindspore/ops/operations/array_ops.py +1428 -1226
- mindspore/ops/operations/comm_ops.py +180 -117
- mindspore/ops/operations/control_ops.py +4 -2
- mindspore/ops/operations/custom_ops.py +185 -98
- mindspore/ops/operations/debug_ops.py +92 -54
- mindspore/ops/operations/image_ops.py +406 -211
- mindspore/ops/operations/inner_ops.py +42 -53
- mindspore/ops/operations/linalg_ops.py +32 -29
- mindspore/ops/operations/math_ops.py +2076 -897
- mindspore/ops/operations/nn_ops.py +1282 -1252
- mindspore/ops/operations/other_ops.py +124 -278
- mindspore/ops/operations/random_ops.py +345 -178
- mindspore/ops/operations/rl_ops.py +8 -9
- mindspore/ops/operations/sparse_ops.py +502 -157
- mindspore/ops/operations/spectral_ops.py +107 -0
- mindspore/ops/primitive.py +192 -15
- mindspore/ops/vm_impl_registry.py +23 -2
- mindspore/parallel/__init__.py +6 -1
- mindspore/parallel/_auto_parallel_context.py +199 -92
- mindspore/parallel/_cell_wrapper.py +4 -2
- mindspore/parallel/_cost_model_context.py +3 -0
- mindspore/parallel/_dp_allreduce_fusion.py +2 -1
- mindspore/parallel/_offload_context.py +185 -0
- mindspore/parallel/_parallel_serialization.py +167 -28
- mindspore/parallel/_ps_context.py +9 -5
- mindspore/parallel/_recovery_context.py +1 -1
- mindspore/parallel/_tensor.py +9 -1
- mindspore/{nn/transformer → parallel/_transformer}/__init__.py +6 -6
- mindspore/{nn/transformer → parallel/_transformer}/layers.py +59 -37
- mindspore/{nn/transformer → parallel/_transformer}/loss.py +4 -7
- mindspore/{nn/transformer → parallel/_transformer}/moe.py +160 -35
- mindspore/{nn/transformer → parallel/_transformer}/op_parallel_config.py +3 -3
- mindspore/{nn/transformer → parallel/_transformer}/transformer.py +235 -196
- mindspore/parallel/_utils.py +47 -7
- mindspore/parallel/algo_parameter_config.py +5 -1
- mindspore/parallel/checkpoint_transform.py +329 -0
- mindspore/parallel/shard.py +229 -0
- mindspore/perf_msvcbuildinsights.dll +0 -0
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/__init__.py +2 -1
- mindspore/profiler/common/util.py +4 -3
- mindspore/profiler/common/validator/validate_path.py +2 -2
- mindspore/profiler/envprofiling.py +249 -0
- mindspore/profiler/parser/aicpu_data_parser.py +38 -39
- mindspore/profiler/parser/ascend_timeline_generator.py +497 -0
- mindspore/profiler/parser/base_timeline_generator.py +471 -0
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +684 -0
- mindspore/profiler/parser/framework_parser.py +42 -16
- mindspore/profiler/parser/hccl_parser.py +158 -158
- mindspore/profiler/parser/hwts_log_parser.py +7 -6
- mindspore/profiler/parser/integrator.py +18 -1579
- mindspore/profiler/parser/minddata_analyzer.py +8 -8
- mindspore/profiler/parser/msadvisor_analyzer.py +14 -27
- mindspore/profiler/parser/msadvisor_parser.py +2 -4
- mindspore/profiler/parser/optime_parser.py +17 -18
- mindspore/profiler/parser/profiler_info.py +108 -0
- mindspore/profiler/parser/step_trace_parser.py +1 -1
- mindspore/profiler/profiling.py +396 -194
- mindspore/rewrite/__init__.py +6 -2
- mindspore/rewrite/api/node.py +51 -110
- mindspore/rewrite/api/node_type.py +10 -6
- mindspore/rewrite/api/pattern_engine.py +51 -7
- mindspore/rewrite/api/scoped_value.py +64 -53
- mindspore/rewrite/api/symbol_tree.py +108 -61
- mindspore/rewrite/api/tree_node_helper.py +2 -3
- mindspore/{compression/quant/__init__.py → rewrite/ast_creator_register.py} +20 -11
- mindspore/rewrite/ast_helpers/__init__.py +6 -3
- mindspore/rewrite/ast_helpers/ast_creator.py +115 -0
- mindspore/rewrite/ast_helpers/ast_finder.py +99 -1
- mindspore/rewrite/ast_helpers/ast_modifier.py +17 -4
- mindspore/rewrite/ast_helpers/ast_replacer.py +1 -1
- mindspore/rewrite/ast_transformers/__init__.py +0 -1
- mindspore/rewrite/ast_transformers/flatten_recursive_stmt.py +46 -5
- mindspore/rewrite/ast_transformers/remove_return_out_of_if.py +6 -3
- mindspore/rewrite/common/__init__.py +2 -0
- mindspore/rewrite/common/event.py +1 -1
- mindspore/rewrite/common/observable.py +1 -1
- mindspore/rewrite/common/observer.py +1 -1
- mindspore/rewrite/common/rewrite_elog.py +35 -0
- mindspore/rewrite/namer.py +2 -2
- mindspore/rewrite/namespace.py +14 -4
- mindspore/rewrite/node.py +161 -13
- mindspore/rewrite/parser.py +0 -1
- mindspore/rewrite/parser_register.py +0 -1
- mindspore/rewrite/parsers/arguments_parser.py +3 -2
- mindspore/rewrite/parsers/assign_parser.py +267 -67
- mindspore/rewrite/parsers/attribute_parser.py +56 -0
- mindspore/rewrite/parsers/class_def_parser.py +191 -108
- mindspore/rewrite/parsers/constant_parser.py +101 -0
- mindspore/rewrite/parsers/container_parser.py +88 -0
- mindspore/rewrite/parsers/for_parser.py +28 -15
- mindspore/rewrite/parsers/function_def_parser.py +21 -5
- mindspore/rewrite/parsers/if_parser.py +11 -28
- mindspore/rewrite/parsers/module_parser.py +9 -6
- mindspore/rewrite/parsers/return_parser.py +3 -2
- mindspore/rewrite/sparsify/__init__.py +0 -0
- mindspore/rewrite/sparsify/sparse_transformer.py +448 -0
- mindspore/rewrite/sparsify/sparsify.py +109 -0
- mindspore/rewrite/sparsify/utils.py +173 -0
- mindspore/rewrite/symbol_tree.py +322 -109
- mindspore/rewrite/symbol_tree_builder.py +45 -8
- mindspore/rewrite/symbol_tree_dumper.py +0 -1
- mindspore/rewrite/topological_manager.py +1 -2
- mindspore/run_check/_check_version.py +209 -112
- mindspore/run_check/run_check.py +2 -1
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/__init__.py +6 -4
- mindspore/train/_utils.py +28 -5
- mindspore/train/amp.py +321 -50
- mindspore/train/callback/__init__.py +3 -1
- mindspore/train/callback/_backup_and_restore.py +120 -0
- mindspore/train/callback/_callback.py +8 -8
- mindspore/train/callback/_checkpoint.py +12 -9
- mindspore/train/callback/_early_stop.py +13 -7
- mindspore/train/callback/_history.py +8 -8
- mindspore/train/callback/_lambda_callback.py +6 -6
- mindspore/train/callback/_landscape.py +36 -38
- mindspore/train/callback/_loss_monitor.py +12 -6
- mindspore/train/callback/_lr_scheduler_callback.py +2 -4
- mindspore/train/callback/_on_request_exit.py +212 -0
- mindspore/train/callback/_reduce_lr_on_plateau.py +13 -7
- mindspore/train/callback/_summary_collector.py +27 -19
- mindspore/train/callback/_time_monitor.py +13 -7
- mindspore/train/checkpoint_pb2.py +68 -8
- mindspore/train/data_sink.py +122 -33
- mindspore/train/dataset_helper.py +28 -87
- mindspore/train/loss_scale_manager.py +4 -7
- mindspore/{nn → train}/metrics/__init__.py +20 -20
- mindspore/{nn → train}/metrics/accuracy.py +12 -10
- mindspore/{nn → train}/metrics/auc.py +4 -4
- mindspore/{nn → train}/metrics/bleu_score.py +4 -4
- mindspore/{nn → train}/metrics/confusion_matrix.py +10 -8
- mindspore/{nn → train}/metrics/cosine_similarity.py +4 -4
- mindspore/{nn → train}/metrics/dice.py +6 -5
- mindspore/{nn → train}/metrics/error.py +7 -5
- mindspore/{nn → train}/metrics/fbeta.py +9 -7
- mindspore/{nn → train}/metrics/hausdorff_distance.py +8 -6
- mindspore/{nn → train}/metrics/loss.py +4 -3
- mindspore/{nn → train}/metrics/mean_surface_distance.py +6 -5
- mindspore/{nn → train}/metrics/metric.py +6 -5
- mindspore/{nn → train}/metrics/occlusion_sensitivity.py +4 -3
- mindspore/{nn → train}/metrics/perplexity.py +5 -4
- mindspore/{nn → train}/metrics/precision.py +5 -4
- mindspore/{nn → train}/metrics/recall.py +5 -4
- mindspore/{nn → train}/metrics/roc.py +7 -6
- mindspore/{nn → train}/metrics/root_mean_square_surface_distance.py +6 -5
- mindspore/{nn → train}/metrics/topk.py +7 -5
- mindspore/train/mind_ir_pb2.py +339 -32
- mindspore/train/model.py +113 -84
- mindspore/train/serialization.py +547 -167
- mindspore/train/summary/_summary_adapter.py +1 -1
- mindspore/train/summary/summary_record.py +43 -12
- mindspore/train/train_thor/convert_utils.py +7 -1
- mindspore/train/train_thor/dataset_helper.py +3 -3
- mindspore/train/train_thor/model_thor.py +0 -4
- 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-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/METADATA +4 -3
- {mindspore-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/RECORD +901 -660
- mindspore/compression/common/constant.py +0 -124
- mindspore/compression/export/__init__.py +0 -19
- mindspore/compression/export/quant_export.py +0 -514
- mindspore/compression/quant/qat.py +0 -636
- mindspore/compression/quant/quant_utils.py +0 -462
- mindspore/compression/quant/quantizer.py +0 -68
- mindspore/libatomic-1.dll +0 -0
- mindspore/libgcc_s_seh-1.dll +0 -0
- mindspore/libgfortran-4.dll +0 -0
- mindspore/libgomp-1.dll +0 -0
- mindspore/libjpeg-62.dll +0 -0
- mindspore/libmindspore.dll +0 -0
- mindspore/libmindspore_common.dll +0 -0
- mindspore/libmindspore_core.dll +0 -0
- mindspore/libmindspore_glog.dll +0 -0
- mindspore/libnnacl.dll +0 -0
- mindspore/libopencv_core452.dll +0 -0
- mindspore/libopencv_imgcodecs452.dll +0 -0
- mindspore/libopencv_imgproc452.dll +0 -0
- mindspore/libquadmath-0.dll +0 -0
- mindspore/libsqlite3.dll +0 -0
- mindspore/libssp-0.dll +0 -0
- mindspore/libstdc++-6.dll +0 -0
- mindspore/libtinyxml2.dll +0 -0
- mindspore/libturbojpeg.dll +0 -0
- mindspore/libwinpthread-1.dll +0 -0
- mindspore/nn/layer/quant.py +0 -1868
- mindspore/nn/layer/rnn_utils.py +0 -90
- mindspore/nn/probability/dpn/__init__.py +0 -22
- mindspore/nn/probability/dpn/vae/__init__.py +0 -25
- mindspore/nn/probability/dpn/vae/cvae.py +0 -138
- mindspore/nn/probability/dpn/vae/vae.py +0 -122
- mindspore/nn/probability/infer/__init__.py +0 -22
- mindspore/nn/probability/infer/variational/elbo.py +0 -70
- mindspore/nn/probability/infer/variational/svi.py +0 -84
- mindspore/nn/probability/toolbox/__init__.py +0 -22
- mindspore/nn/probability/toolbox/anomaly_detection.py +0 -99
- mindspore/nn/probability/toolbox/uncertainty_evaluation.py +0 -363
- mindspore/nn/probability/transforms/__init__.py +0 -22
- mindspore/nn/probability/transforms/transform_bnn.py +0 -262
- mindspore/nn/probability/zhusuan/__init__.py +0 -18
- mindspore/nn/probability/zhusuan/framework/__init__.py +0 -18
- mindspore/nn/probability/zhusuan/framework/bn.py +0 -95
- mindspore/nn/probability/zhusuan/variational/__init__.py +0 -18
- mindspore/nn/probability/zhusuan/variational/elbo.py +0 -46
- mindspore/ops/_op_impl/tbe/bias_add_grad_ds.py +0 -52
- mindspore/ops/_op_impl/tbe/scatter_nd_add_ds.py +0 -43
- mindspore/ops/bprop_mindir/AssignAdd_bprop.mindir +0 -20
- mindspore/ops/bprop_mindir/Identity_bprop.mindir +0 -9
- mindspore/ops/bprop_mindir/LogicalOr_bprop.mindir +0 -20
- mindspore/ops/bprop_mindir/ReLU_bprop.mindir +0 -16
- mindspore/ops/bprop_mindir/UpdateState_bprop.mindir +0 -17
- mindspore/ops/bprop_mindir/stop_gradient_bprop.mindir +0 -12
- mindspore/ops/composite/array_ops.py +0 -210
- mindspore/ops/composite/clip_ops.py +0 -238
- mindspore/ops/composite/random_ops.py +0 -426
- mindspore/ops/composite/vmap_ops.py +0 -38
- mindspore/ops/operations/sponge_ops.py +0 -3531
- mindspore/ops/operations/sponge_update_ops.py +0 -2546
- mindspore/parallel/nn/__init__.py +0 -42
- mindspore/parallel/nn/loss.py +0 -22
- mindspore/parallel/nn/moe.py +0 -21
- mindspore/parallel/nn/op_parallel_config.py +0 -22
- mindspore/parallel/nn/transformer.py +0 -31
- mindspore/run_check/_check_deps_version.py +0 -84
- {mindspore-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/top_level.txt +0 -0
|
@@ -20,22 +20,25 @@ import numpy as np
|
|
|
20
20
|
|
|
21
21
|
from mindspore.common import Tensor
|
|
22
22
|
from mindspore.ops import composite as C
|
|
23
|
-
from mindspore.communication.management import GlobalComm
|
|
24
23
|
from mindspore.ops.operations.array_ops import Cast
|
|
24
|
+
from mindspore.ops.operations._scalar_ops import bit_or, bit_and
|
|
25
25
|
from mindspore.ops import signature as sig
|
|
26
26
|
from mindspore.ops.operations.math_ops import _infer_shape_reduce
|
|
27
27
|
from mindspore.ops.primitive import PrimitiveWithCheck, PrimitiveWithInfer, prim_attr_register, Primitive, _run_op
|
|
28
28
|
from mindspore import context
|
|
29
|
-
from mindspore.
|
|
30
|
-
from mindspore.
|
|
29
|
+
from mindspore._c_expression import Tensor as Tensor_
|
|
30
|
+
from mindspore._c_expression import typing
|
|
31
|
+
from mindspore import _checkparam as validator
|
|
31
32
|
from mindspore.common import dtype as mstype
|
|
32
33
|
from mindspore.common.parameter import Parameter
|
|
33
|
-
from mindspore.
|
|
34
|
+
from mindspore.communication.management import GlobalComm
|
|
35
|
+
from mindspore.common.api import _pynative_executor
|
|
36
|
+
from mindspore.common._register_for_adapter import ms_adapter_registry
|
|
34
37
|
|
|
35
38
|
|
|
36
39
|
# Bit operation
|
|
37
|
-
bit_and =
|
|
38
|
-
bit_or =
|
|
40
|
+
bit_and = bit_and()
|
|
41
|
+
bit_or = bit_or()
|
|
39
42
|
bit_xor = Primitive("bit_xor")
|
|
40
43
|
bit_left_shift = Primitive("bit_left_shift")
|
|
41
44
|
bit_right_shift = Primitive("bit_right_shift")
|
|
@@ -50,54 +53,10 @@ string_mul = Primitive("string_mul")
|
|
|
50
53
|
string_getitem = Primitive("string_getitem")
|
|
51
54
|
|
|
52
55
|
|
|
53
|
-
class FillV2(Primitive):
|
|
54
|
-
"""
|
|
55
|
-
Creates a tensor filled with a scalar value.
|
|
56
|
-
|
|
57
|
-
Creates a tensor with shape described by the first argument and fills it with values in the second argument.
|
|
58
|
-
|
|
59
|
-
Inputs:
|
|
60
|
-
- **shape** (tensor) - The specified shape of output tensor. The shape of the input1 must be 1D and
|
|
61
|
-
the data type of the input1 must be int32 or int64.
|
|
62
|
-
- **value** (tensor) - Value to fill the returned tensor. The shape of the input2 must be 0D and
|
|
63
|
-
the data type of the input2 must be one of the following types:
|
|
64
|
-
bool, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64.
|
|
65
|
-
|
|
66
|
-
Outputs:
|
|
67
|
-
A tensor, has the same type and shape as input value.
|
|
68
|
-
|
|
69
|
-
Raises:
|
|
70
|
-
ValueError: If `shape` is not a 1D tensor.
|
|
71
|
-
TypeError: If the data type of `shape` is not int32 or int64.
|
|
72
|
-
ValueError: If `value` is not a 0D tensor.
|
|
73
|
-
ValueError: If the number of output elements is greater than 1000000.
|
|
74
|
-
|
|
75
|
-
Supported Platforms:
|
|
76
|
-
``CPU``
|
|
77
|
-
|
|
78
|
-
Examples:
|
|
79
|
-
>>> fillV2 = ops.FillV2()
|
|
80
|
-
>>> output = fillV2(Tensor([2, 3], mindspore.int32), Tensor(1, mindspore.float32))
|
|
81
|
-
>>> print(output)
|
|
82
|
-
[[1. 1. 1.]
|
|
83
|
-
[1. 1. 1.]]
|
|
84
|
-
>>> output = fillV2(Tensor([3, 3], mindspore.int64), Tensor(0, mindspore.int32))
|
|
85
|
-
>>> print(output)
|
|
86
|
-
[[0 0 0]
|
|
87
|
-
[0 0 0]
|
|
88
|
-
[0 0 0]]
|
|
89
|
-
"""
|
|
90
|
-
|
|
91
|
-
@prim_attr_register
|
|
92
|
-
def __init__(self):
|
|
93
|
-
"""Initialize FillV2"""
|
|
94
|
-
self.add_prim_attr("max_length", 1000000)
|
|
95
|
-
|
|
96
|
-
|
|
97
56
|
class ExtractImagePatches(Primitive):
|
|
98
|
-
"""
|
|
57
|
+
r"""
|
|
99
58
|
Extracts patches from images.
|
|
100
|
-
The input tensor must be a 4-D tensor and the data format is
|
|
59
|
+
The input tensor must be a 4-D tensor and the data format is NCHW.
|
|
101
60
|
|
|
102
61
|
Args:
|
|
103
62
|
ksizes (Union[tuple[int], list[int]]): The size of sliding window, must be a tuple or a list of integers,
|
|
@@ -114,12 +73,32 @@ class ExtractImagePatches(Primitive):
|
|
|
114
73
|
- valid: Means that the taken patch area must be completely covered in the original image.
|
|
115
74
|
|
|
116
75
|
Inputs:
|
|
117
|
-
- **input_x** (Tensor) - A 4-D tensor whose shape is [in_batch, in_row, in_col
|
|
76
|
+
- **input_x** (Tensor) - A 4-D tensor whose shape is [in_batch, in_depth, in_row, in_col] and
|
|
118
77
|
data type is number.
|
|
119
78
|
|
|
120
79
|
Outputs:
|
|
121
80
|
Tensor, a 4-D tensor whose data type is same as 'input_x',
|
|
122
|
-
and the shape is [out_batch, out_row, out_col
|
|
81
|
+
and the shape is [out_batch, out_depth, out_row, out_col], Where the out_batch is the same as the in_batch
|
|
82
|
+
and
|
|
83
|
+
|
|
84
|
+
.. math::
|
|
85
|
+
out_depth=ksize\_row * ksize\_col * in\_depth
|
|
86
|
+
|
|
87
|
+
and
|
|
88
|
+
if 'padding' is "valid":
|
|
89
|
+
|
|
90
|
+
.. math::
|
|
91
|
+
out\_row=floor((in\_row - (ksize\_row + (ksize\_row - 1) * (rate\_row - 1))) / stride\_row) + 1
|
|
92
|
+
out\_col=floor((in\_col - (ksize\_col + (ksize\_col - 1) * (rate\_col - 1))) / stride\_col) + 1
|
|
93
|
+
|
|
94
|
+
if 'padding' is "same":
|
|
95
|
+
|
|
96
|
+
.. math::
|
|
97
|
+
out\_row=floor((in\_row - 1) / stride\_row) + 1
|
|
98
|
+
out\_col=floor((in\_col - 1) / stride\_col) + 1
|
|
99
|
+
|
|
100
|
+
Supported Platforms:
|
|
101
|
+
``Ascend`` ``GPU``
|
|
123
102
|
"""
|
|
124
103
|
|
|
125
104
|
@prim_attr_register
|
|
@@ -223,12 +202,14 @@ class Lamb(PrimitiveWithInfer):
|
|
|
223
202
|
Default: 0.0.
|
|
224
203
|
- **global_step** (Tensor) - Tensor to record current global step.
|
|
225
204
|
- **gradient** (Tensor) - Gradient, has the same shape and data type as `var`.
|
|
205
|
+
|
|
226
206
|
Outputs:
|
|
227
207
|
Tensor, the updated parameters.
|
|
208
|
+
|
|
228
209
|
- **var** (Tensor) - The same shape and data type as `var`.
|
|
229
210
|
|
|
230
211
|
Supported Platforms:
|
|
231
|
-
``GPU``
|
|
212
|
+
``Ascend````GPU``
|
|
232
213
|
"""
|
|
233
214
|
|
|
234
215
|
@prim_attr_register
|
|
@@ -238,9 +219,9 @@ class Lamb(PrimitiveWithInfer):
|
|
|
238
219
|
|
|
239
220
|
def infer_shape(self, var_shape, m_shape, v_shape, lr_shape, beta1_shape, beta2_shape,
|
|
240
221
|
epsilon_shape, decay_shape, global_step_shape, gradient_shape):
|
|
241
|
-
validator.check("var_shape", var_shape, "m_shape", m_shape,
|
|
242
|
-
validator.check("var_shape", var_shape, "v_shape", v_shape,
|
|
243
|
-
validator.check("var_shape", var_shape, "gradient_shape", gradient_shape,
|
|
222
|
+
validator.check("var_shape", var_shape, "m_shape", m_shape, validator.EQ, self.name)
|
|
223
|
+
validator.check("var_shape", var_shape, "v_shape", v_shape, validator.EQ, self.name)
|
|
224
|
+
validator.check("var_shape", var_shape, "gradient_shape", gradient_shape, validator.EQ, self.name)
|
|
244
225
|
return var_shape
|
|
245
226
|
|
|
246
227
|
def infer_dtype(self, var_dtype, m_dtype, v_dtype, lr_dtype, beta1_dtype, beta2_dtype,
|
|
@@ -344,18 +325,18 @@ class MatrixDiag(PrimitiveWithInfer):
|
|
|
344
325
|
return x_dtype
|
|
345
326
|
|
|
346
327
|
def infer_shape(self, x_shape, assist_shape):
|
|
347
|
-
validator.check_int(len(assist_shape), 2,
|
|
328
|
+
validator.check_int(len(assist_shape), 2, validator.GE, "assist rank", self.name)
|
|
348
329
|
validator.check('rank of x', len(x_shape) + 1,
|
|
349
|
-
'rank of assist', len(assist_shape),
|
|
330
|
+
'rank of assist', len(assist_shape), validator.LE, self.name)
|
|
350
331
|
validator.check('assist\'s penultimate dimension', assist_shape[-2], 'assist\'s last dimension',
|
|
351
|
-
assist_shape[-1],
|
|
332
|
+
assist_shape[-1], validator.EQ, self.name)
|
|
352
333
|
|
|
353
334
|
r_end_dim = -len(x_shape)
|
|
354
335
|
r_idx = -1
|
|
355
336
|
while r_idx >= r_end_dim:
|
|
356
337
|
if x_shape[r_idx] != 1:
|
|
357
338
|
validator.check("reverse x dim %d" % r_idx, x_shape[r_idx], "reverse assist dim %d" %
|
|
358
|
-
assist_shape[r_idx - 1], assist_shape[r_idx - 1],
|
|
339
|
+
assist_shape[r_idx - 1], assist_shape[r_idx - 1], validator.EQ, self.name)
|
|
359
340
|
r_idx = r_idx - 1
|
|
360
341
|
|
|
361
342
|
return assist_shape
|
|
@@ -393,8 +374,8 @@ class MatrixDiagPart(PrimitiveWithInfer):
|
|
|
393
374
|
return x_dtype
|
|
394
375
|
|
|
395
376
|
def infer_shape(self, x_shape, assist_shape):
|
|
396
|
-
validator.check_int(len(x_shape), 2,
|
|
397
|
-
validator.check("x shape", x_shape, "assist shape", assist_shape,
|
|
377
|
+
validator.check_int(len(x_shape), 2, validator.GE, "x rank", self.name)
|
|
378
|
+
validator.check("x shape", x_shape, "assist shape", assist_shape, validator.EQ, self.name)
|
|
398
379
|
|
|
399
380
|
if assist_shape[-2] < assist_shape[-1]:
|
|
400
381
|
out_shape = assist_shape[:-1]
|
|
@@ -448,6 +429,7 @@ class Send(PrimitiveWithInfer):
|
|
|
448
429
|
self.rank = dest_rank
|
|
449
430
|
self.sr_tag = sr_tag
|
|
450
431
|
self.group = group
|
|
432
|
+
self.add_prim_attr("no_eliminate", True)
|
|
451
433
|
|
|
452
434
|
def infer_shape(self, x_shape):
|
|
453
435
|
self.add_prim_attr("shape", x_shape)
|
|
@@ -459,7 +441,7 @@ class Send(PrimitiveWithInfer):
|
|
|
459
441
|
|
|
460
442
|
class Receive(PrimitiveWithInfer):
|
|
461
443
|
"""
|
|
462
|
-
|
|
444
|
+
Receive tensors from src_rank.
|
|
463
445
|
|
|
464
446
|
Note:
|
|
465
447
|
Send and Receive must be used in combination and have same sr_tag.
|
|
@@ -472,7 +454,8 @@ class Receive(PrimitiveWithInfer):
|
|
|
472
454
|
shape (list[int]): A required list identifying the shape of the tensor to be received.
|
|
473
455
|
dtype (Type): A required Type identifying the type of the tensor to be received. The supported types:
|
|
474
456
|
int8, int16, int32, float16, float32.
|
|
475
|
-
group (str): The communication group to work on.
|
|
457
|
+
group (str, optional): The communication group to work on.
|
|
458
|
+
Default: "hccl_world_group" on Ascend, "nccl_world_group" on GPU.
|
|
476
459
|
|
|
477
460
|
Inputs:
|
|
478
461
|
- **input_x** (Tensor) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`.
|
|
@@ -507,6 +490,7 @@ class Receive(PrimitiveWithInfer):
|
|
|
507
490
|
self.shape = shape
|
|
508
491
|
self.dtype = dtype
|
|
509
492
|
self.group = group
|
|
493
|
+
self.add_prim_attr("no_eliminate", True)
|
|
510
494
|
valid_type = [mstype.float16, mstype.float32, mstype.int32, mstype.int8, mstype.uint8]
|
|
511
495
|
args = {"dtype": dtype}
|
|
512
496
|
validator.check_scalar_or_tensor_types_same(args, valid_type, self.name)
|
|
@@ -552,15 +536,15 @@ class MatrixSetDiag(PrimitiveWithInfer):
|
|
|
552
536
|
return x_dtype
|
|
553
537
|
|
|
554
538
|
def infer_shape(self, x_shape, diagonal_shape, assist_shape):
|
|
555
|
-
validator.check_int(len(x_shape), 2,
|
|
556
|
-
validator.check("x shape", x_shape, "assist shape", assist_shape,
|
|
539
|
+
validator.check_int(len(x_shape), 2, validator.GE, "x rank", self.name)
|
|
540
|
+
validator.check("x shape", x_shape, "assist shape", assist_shape, validator.EQ, self.name)
|
|
557
541
|
|
|
558
542
|
if x_shape[-2] < x_shape[-1]:
|
|
559
|
-
validator.check("
|
|
560
|
-
x_shape[:-1],
|
|
543
|
+
validator.check("diagonal shape", diagonal_shape, "x shape excluding the last dimension",
|
|
544
|
+
x_shape[:-1], validator.EQ, self.name)
|
|
561
545
|
else:
|
|
562
546
|
validator.check("diagonal shape", diagonal_shape, "x shape excluding the second last dimension",
|
|
563
|
-
x_shape[:-2] + x_shape[-1:],
|
|
547
|
+
x_shape[:-2] + x_shape[-1:], validator.EQ, self.name)
|
|
564
548
|
|
|
565
549
|
return assist_shape
|
|
566
550
|
|
|
@@ -677,7 +661,7 @@ class ConvertToDynamic(PrimitiveWithCheck):
|
|
|
677
661
|
self.init_prim_io_names(inputs=["input"], outputs=["output"])
|
|
678
662
|
|
|
679
663
|
def check_shape(self, input_shape):
|
|
680
|
-
validator.check("input_shape rank", len(input_shape), "", 0,
|
|
664
|
+
validator.check("input_shape rank", len(input_shape), "", 0, validator.GT, self.name)
|
|
681
665
|
|
|
682
666
|
def check_dtype(self, input_dtype):
|
|
683
667
|
validator.check_subclass("input_dtype", input_dtype, mstype.tensor, self.name)
|
|
@@ -727,7 +711,7 @@ class GpuConvertToDynamicShape(PrimitiveWithCheck):
|
|
|
727
711
|
self.init_prim_io_names(inputs=["input"], outputs=["output"])
|
|
728
712
|
|
|
729
713
|
def check_shape(self, input_shape):
|
|
730
|
-
validator.check("input_shape rank", len(input_shape), "", 0,
|
|
714
|
+
validator.check("input_shape rank", len(input_shape), "", 0, validator.GT, self.name)
|
|
731
715
|
|
|
732
716
|
def check_dtype(self, input_dtype):
|
|
733
717
|
validator.check_subclass("input_dtype", input_dtype, mstype.tensor, self.name)
|
|
@@ -808,7 +792,7 @@ class SequenceMask(PrimitiveWithCheck):
|
|
|
808
792
|
One mask tensor of shape lengths.shape + (maxlen,).
|
|
809
793
|
|
|
810
794
|
Supported Platforms:
|
|
811
|
-
``GPU``
|
|
795
|
+
``GPU`` ``CPU``
|
|
812
796
|
|
|
813
797
|
Examples:
|
|
814
798
|
>>> from mindspore import ops
|
|
@@ -828,8 +812,8 @@ class SequenceMask(PrimitiveWithCheck):
|
|
|
828
812
|
self.init_prim_io_names(inputs=["lengths", "maxlen"], outputs=["mask"])
|
|
829
813
|
|
|
830
814
|
def check_shape(self, lengths_shape, maxlen_shape):
|
|
831
|
-
validator.check("lengths_shape", len(lengths_shape), "", 0,
|
|
832
|
-
validator.check("maxlen_shape", len(maxlen_shape), "", 0,
|
|
815
|
+
validator.check("lengths_shape", len(lengths_shape), "", 0, validator.GT, self.name)
|
|
816
|
+
validator.check("maxlen_shape", len(maxlen_shape), "", 0, validator.EQ, self.name)
|
|
833
817
|
|
|
834
818
|
def check_dtype(self, lengths_dtype, maxlen_dtype):
|
|
835
819
|
validator.check_subclass("lengths_dtype", lengths_dtype, mstype.tensor, self.name)
|
|
@@ -901,10 +885,10 @@ class SyncBatchNorm(Primitive):
|
|
|
901
885
|
|
|
902
886
|
@prim_attr_register
|
|
903
887
|
def __init__(self, epsilon=1e-5, momentum=0.1, group="sync_bn_group0", device_num=2):
|
|
904
|
-
validator.check_float_range(epsilon, 0, 1,
|
|
905
|
-
validator.check_float_range(momentum, 0, 1,
|
|
888
|
+
validator.check_float_range(epsilon, 0, 1, validator.INC_RIGHT, 'epsilon', self.name)
|
|
889
|
+
validator.check_float_range(momentum, 0, 1, validator.INC_BOTH, 'momentum', self.name)
|
|
906
890
|
validator.check_isinstance("group", group, str)
|
|
907
|
-
validator.check_int(device_num, 2,
|
|
891
|
+
validator.check_int(device_num, 2, validator.GE, "device_num", self.name)
|
|
908
892
|
self.init_prim_io_names(inputs=['x', 'scale', 'offset', 'mean', 'variance'],
|
|
909
893
|
outputs=['y', 'batch_mean', 'batch_variance', 'reserve_space_1', 'reserve_space_2'])
|
|
910
894
|
self.add_prim_attr('side_effect_mem', True)
|
|
@@ -967,7 +951,7 @@ class Centralization(PrimitiveWithInfer):
|
|
|
967
951
|
validator.check_value_type('axis', axis_v, [int, list, tuple], self.name)
|
|
968
952
|
|
|
969
953
|
if isinstance(axis_v, int):
|
|
970
|
-
validator.check_int_range(axis_v, -rank, rank,
|
|
954
|
+
validator.check_int_range(axis_v, -rank, rank, validator.INC_LEFT, 'axis', self.name)
|
|
971
955
|
elif axis:
|
|
972
956
|
for index, one_axis in enumerate(axis_v):
|
|
973
957
|
validator.check_value_type('axis[%d]' % index, one_axis, [int], self.name)
|
|
@@ -1068,9 +1052,9 @@ class StackPop(PrimitiveWithInfer):
|
|
|
1068
1052
|
validator.check_value_type("index", index, [int], self.name)
|
|
1069
1053
|
|
|
1070
1054
|
validator.check_value_type('shape type', shape, [list, tuple], self.name)
|
|
1071
|
-
validator.check_int(len(np.array(shape).shape), 1,
|
|
1055
|
+
validator.check_int(len(np.array(shape).shape), 1, validator.EQ, "dim of shape", self.name)
|
|
1072
1056
|
for elem in shape:
|
|
1073
|
-
validator.check_int(elem, 1,
|
|
1057
|
+
validator.check_int(elem, 1, validator.GE, 'shape element', self.name)
|
|
1074
1058
|
validator.check_value_type('type of shape element', elem, [int], self.name)
|
|
1075
1059
|
|
|
1076
1060
|
validator.check_type_name("dtype", dtype, (mstype.bool_,) + mstype.number_type, self.name)
|
|
@@ -1151,22 +1135,22 @@ class DynamicStitch(PrimitiveWithCheck):
|
|
|
1151
1135
|
|
|
1152
1136
|
def check_shape(self, indices_shape, data_shape):
|
|
1153
1137
|
validator.check_value_type("shape of indices", indices_shape, [tuple, list], self.name)
|
|
1154
|
-
validator.check_int(len(indices_shape), 1,
|
|
1138
|
+
validator.check_int(len(indices_shape), 1, validator.GE, "len of indices_shape", self.name)
|
|
1155
1139
|
indices_dim0 = len(indices_shape[0])
|
|
1156
1140
|
indices_num = len(indices_shape)
|
|
1157
1141
|
|
|
1158
1142
|
validator.check_value_type("shape of data", data_shape, [tuple, list], self.name)
|
|
1159
|
-
validator.check_int(len(data_shape), 1,
|
|
1143
|
+
validator.check_int(len(data_shape), 1, validator.GE, "len of data_shape", self.name)
|
|
1160
1144
|
data_dim0 = len(data_shape[0])
|
|
1161
1145
|
data_num = len(indices_shape)
|
|
1162
1146
|
|
|
1163
|
-
validator.check("size of indices", indices_num, 'size of data', data_num,
|
|
1147
|
+
validator.check("size of indices", indices_num, 'size of data', data_num, validator.EQ, self.name)
|
|
1164
1148
|
|
|
1165
1149
|
# shape of `data` must start with shape of `indices`
|
|
1166
1150
|
for i in range(0, indices_num):
|
|
1167
1151
|
indices_dim = len(indices_shape[i])
|
|
1168
1152
|
data_dim = len(data_shape[i])
|
|
1169
|
-
validator.check(f"dim of indices[{i}]", indices_dim, f"dim of data[{i}]", data_dim,
|
|
1153
|
+
validator.check(f"dim of indices[{i}]", indices_dim, f"dim of data[{i}]", data_dim, validator.LE, self.name)
|
|
1170
1154
|
if data_shape[i][:indices_dim] != data_shape[i][:indices_dim]:
|
|
1171
1155
|
raise ValueError(f"data[{i}].shape: {data_shape} does not start with indices[{i}].shape: {data_shape}")
|
|
1172
1156
|
|
|
@@ -1177,10 +1161,10 @@ class DynamicStitch(PrimitiveWithCheck):
|
|
|
1177
1161
|
data_dim = len(data_shape[i])
|
|
1178
1162
|
extra = data_dim - indices_dim
|
|
1179
1163
|
validator.check(f"extra dim of data[{i}]", extra,
|
|
1180
|
-
f"extra dim of data[0]", base_extra,
|
|
1164
|
+
f"extra dim of data[0]", base_extra, validator.EQ, self.name)
|
|
1181
1165
|
validator.check(f"data[0].shape[{indices_dim0}:]", data_shape[0][indices_dim0:],
|
|
1182
1166
|
f"data[{i}].shape[{len(indices_shape[i])}:]",
|
|
1183
|
-
data_shape[i][indices_dim:],
|
|
1167
|
+
data_shape[i][indices_dim:], validator.EQ, self.name)
|
|
1184
1168
|
|
|
1185
1169
|
out_shape = [-1] + data_shape[0][indices_dim0:]
|
|
1186
1170
|
return out_shape
|
|
@@ -1193,7 +1177,8 @@ class DynamicStitch(PrimitiveWithCheck):
|
|
|
1193
1177
|
validator.check_tensor_dtype_valid(f'indices[{i}]', indices_type[i], mstype.int32, self.name)
|
|
1194
1178
|
validator.check_tensor_dtype_valid(f'data[{i}]', data_type[i],
|
|
1195
1179
|
mstype.number_type + (mstype.bool_,), self.name)
|
|
1196
|
-
validator.check(f"type of data[{i}]", data_type[i], f"type of data[0]",
|
|
1180
|
+
validator.check(f"type of data[{i}]", data_type[i], f"type of data[0]",
|
|
1181
|
+
data_type[0], validator.EQ, self.name)
|
|
1197
1182
|
return data_type[0]
|
|
1198
1183
|
|
|
1199
1184
|
|
|
@@ -1278,69 +1263,6 @@ class TensorCopySlices(Primitive):
|
|
|
1278
1263
|
self.init_prim_io_names(inputs=['x', 'value', 'begin', 'end', 'strides'], outputs=['y'])
|
|
1279
1264
|
|
|
1280
1265
|
|
|
1281
|
-
class Roll(Primitive):
|
|
1282
|
-
"""
|
|
1283
|
-
Rolls the elements of a tensor along an axis.
|
|
1284
|
-
|
|
1285
|
-
The elements are shifted positively (towards larger indices) by the offset of `shift` along the dimension of `axis`.
|
|
1286
|
-
Negative `shift` values will shift elements in the opposite direction. Elements that roll passed the last position
|
|
1287
|
-
will wrap around to the first and vice versa. Multiple shifts along multiple axes may be specified.
|
|
1288
|
-
|
|
1289
|
-
Note:
|
|
1290
|
-
This inner operation is valid only if the axis is equal to 0. If the shift and the axis are tuples or lists,
|
|
1291
|
-
this inner operation is valid only for the first pair of elements.
|
|
1292
|
-
|
|
1293
|
-
Args:
|
|
1294
|
-
shift (Union[list(int), tuple(int), int]): Specifies the number of places by which elements are shifted
|
|
1295
|
-
positively (towards larger indices) along the specified dimension. Negative shifts will roll the elements
|
|
1296
|
-
in the opposite direction.
|
|
1297
|
-
axis (Union[list(int), tuple(int), int]): Specifies the dimension indexes of shape to be rolled. The value is
|
|
1298
|
-
forced to be zero in this operation.
|
|
1299
|
-
|
|
1300
|
-
Inputs:
|
|
1301
|
-
- **input_x** (Tensor) - Input tensor.
|
|
1302
|
-
|
|
1303
|
-
Outputs:
|
|
1304
|
-
Tensor, has the same shape and type as `input_x`.
|
|
1305
|
-
|
|
1306
|
-
Raises:
|
|
1307
|
-
TypeError: If `shift` is not an int, a tuple or a list.
|
|
1308
|
-
TypeError: If `axis` is not an int, a tuple or a list.
|
|
1309
|
-
|
|
1310
|
-
Supported Platforms:
|
|
1311
|
-
``Ascend`` ``GPU``
|
|
1312
|
-
|
|
1313
|
-
Examples:
|
|
1314
|
-
>>> from mindspore.ops.operations import _inner_ops as inner
|
|
1315
|
-
>>> input_x = Tensor(np.array([0, 1, 2, 3, 4]).astype(np.float32))
|
|
1316
|
-
>>> op = inner.Roll(shift=2, axis=0)
|
|
1317
|
-
>>> output = op(input_x)
|
|
1318
|
-
>>> print(output)
|
|
1319
|
-
[3. 4. 0. 1. 2.]
|
|
1320
|
-
>>> input_x = Tensor(np.array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]).astype(np.float32))
|
|
1321
|
-
>>> op = inner.Roll(shift=-1, axis=0)
|
|
1322
|
-
>>> output = op(input_x)
|
|
1323
|
-
>>> print(output)
|
|
1324
|
-
[[5. 6. 7. 8. 9.]
|
|
1325
|
-
[0. 1. 2. 3. 4.]]
|
|
1326
|
-
"""
|
|
1327
|
-
|
|
1328
|
-
@prim_attr_register
|
|
1329
|
-
def __init__(self, shift, axis):
|
|
1330
|
-
"""Initialize Roll"""
|
|
1331
|
-
if context.get_context("device_target") == "GPU":
|
|
1332
|
-
validator.check_value_type("shift", shift, [int, tuple, list], self.name)
|
|
1333
|
-
validator.check_value_type("axis", axis, [int, tuple, list], self.name)
|
|
1334
|
-
else:
|
|
1335
|
-
if isinstance(shift, (tuple, list)) and isinstance(axis, (tuple, list)):
|
|
1336
|
-
validator.check_equal_int(len(shift), 1, "shift size", self.name)
|
|
1337
|
-
validator.check_equal_int(len(axis), 1, "shift size", self.name)
|
|
1338
|
-
validator.check_equal_int(axis[0], 0, "axis", self.name)
|
|
1339
|
-
elif isinstance(shift, int) and isinstance(axis, int):
|
|
1340
|
-
validator.check_equal_int(axis, 0, "axis", self.name)
|
|
1341
|
-
self.init_prim_io_names(inputs=['input_x'], outputs=['output'])
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
1266
|
class DSDMatmul(PrimitiveWithInfer):
|
|
1345
1267
|
"""
|
|
1346
1268
|
The definition of the CusSquare primitive.
|
|
@@ -1524,10 +1446,16 @@ class SliceGetItem(Primitive):
|
|
|
1524
1446
|
raise TypeError(
|
|
1525
1447
|
"Primitive[SliceGetItem] only support to get a slice type element but got {}".format(slice_value))
|
|
1526
1448
|
if value == "start":
|
|
1449
|
+
if hasattr(slice_value.start, "ndim") and slice_value.start.ndim == 1:
|
|
1450
|
+
return slice_value.start.item()
|
|
1527
1451
|
return slice_value.start
|
|
1528
1452
|
if value == "stop":
|
|
1453
|
+
if hasattr(slice_value.stop, "ndim") and slice_value.stop.ndim == 1:
|
|
1454
|
+
return slice_value.stop.item()
|
|
1529
1455
|
return slice_value.stop
|
|
1530
1456
|
if value == "step":
|
|
1457
|
+
if hasattr(slice_value.step, "ndim") and slice_value.step.ndim == 1:
|
|
1458
|
+
return slice_value.step.item()
|
|
1531
1459
|
return slice_value.step
|
|
1532
1460
|
raise AttributeError("\'slice\' object has no attribute {}".format(value))
|
|
1533
1461
|
|
|
@@ -1549,7 +1477,7 @@ class DynamicBroadcastTo(Primitive):
|
|
|
1549
1477
|
ValueError: if the target and input shapes are incompatible.
|
|
1550
1478
|
|
|
1551
1479
|
Supported Platforms:
|
|
1552
|
-
``Ascend``
|
|
1480
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1553
1481
|
"""
|
|
1554
1482
|
|
|
1555
1483
|
@prim_attr_register
|
|
@@ -1562,12 +1490,25 @@ class Cummin(Primitive):
|
|
|
1562
1490
|
r"""
|
|
1563
1491
|
Returns the cumulative minimum of elements and the index.
|
|
1564
1492
|
|
|
1493
|
+
.. warning::
|
|
1494
|
+
This is an experimental API that is subject to change or deletion.
|
|
1495
|
+
|
|
1565
1496
|
Refer to :func:`mindspore.ops.cummin` for more detail.
|
|
1566
1497
|
|
|
1567
1498
|
Supported Platforms:
|
|
1568
1499
|
``Ascend`` ``GPU`` ``CPU``
|
|
1569
|
-
"""
|
|
1570
1500
|
|
|
1501
|
+
Examples:
|
|
1502
|
+
>>> from mindspore import Tensor, ops
|
|
1503
|
+
>>> import mindspore
|
|
1504
|
+
>>> a = Tensor([-0.2284, -0.6628, 0.0975, 0.2680, -1.3298, -0.4220], mindspore.float32)
|
|
1505
|
+
>>> func = ops.Cummin(axis=0)
|
|
1506
|
+
>>> output = func(a)
|
|
1507
|
+
>>> print(output[0])
|
|
1508
|
+
[-0.2284 -0.6628 -0.6628 -0.6628 -1.3298 -1.3298]
|
|
1509
|
+
>>> print(output[1])
|
|
1510
|
+
[0 1 1 1 4 4]
|
|
1511
|
+
"""
|
|
1571
1512
|
@prim_attr_register
|
|
1572
1513
|
def __init__(self, axis):
|
|
1573
1514
|
"""Initialize Cummin"""
|
|
@@ -1684,7 +1625,7 @@ class ParallelResizeBilinear(PrimitiveWithInfer):
|
|
|
1684
1625
|
"""Initialize ParallelResizeBilinear."""
|
|
1685
1626
|
validator.check_value_type("ori_image_size", ori_image_size, [list, tuple], self.name)
|
|
1686
1627
|
validator.check_value_type("split_size", split_size, [list, tuple], self.name)
|
|
1687
|
-
validator.check_int(len(split_size), 2,
|
|
1628
|
+
validator.check_int(len(split_size), 2, validator.EQ, "len of split_size", self.name)
|
|
1688
1629
|
validator.check_value_type("src_start_w", src_start_w, [int], self.name)
|
|
1689
1630
|
validator.check_value_type("dst_start_w", dst_start_w, [int], self.name)
|
|
1690
1631
|
validator.check_value_type("align_corners", align_corners, [bool], self.name)
|
|
@@ -2002,21 +1943,23 @@ class KMeansCentroids(PrimitiveWithInfer):
|
|
|
2002
1943
|
def infer_shape(self, x_shape, y_shape, sum_square_y_shape, sum_square_x_shape):
|
|
2003
1944
|
"""infer shape of primitive"""
|
|
2004
1945
|
expected_shape_size = 2
|
|
2005
|
-
validator.check_int(len(x_shape), expected_shape_size,
|
|
2006
|
-
validator.check_int(len(y_shape), expected_shape_size,
|
|
2007
|
-
validator.check_int(len(sum_square_y_shape), expected_shape_size,
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
1946
|
+
validator.check_int(len(x_shape), expected_shape_size, validator.EQ, "dims of x", self.name)
|
|
1947
|
+
validator.check_int(len(y_shape), expected_shape_size, validator.EQ, "dims of y", self.name)
|
|
1948
|
+
validator.check_int(len(sum_square_y_shape), expected_shape_size, validator.EQ,
|
|
1949
|
+
"dims of sum_square_y", self.name)
|
|
1950
|
+
validator.check_int(len(sum_square_x_shape), expected_shape_size, validator.EQ,
|
|
1951
|
+
"dims of sum_square_x", self.name)
|
|
1952
|
+
|
|
1953
|
+
validator.check_int(x_shape[1], y_shape[1], validator.EQ,
|
|
2011
1954
|
"the second dim of x and the second dim of y", self.name)
|
|
2012
|
-
validator.check_int(y_shape[0], sum_square_y_shape[1],
|
|
1955
|
+
validator.check_int(y_shape[0], sum_square_y_shape[1], validator.EQ,
|
|
2013
1956
|
"the first dim of y and the second dim of sum_square_y", self.name)
|
|
2014
|
-
validator.check_int(x_shape[0], sum_square_x_shape[0],
|
|
1957
|
+
validator.check_int(x_shape[0], sum_square_x_shape[0], validator.EQ,
|
|
2015
1958
|
"the first dim of x and the first dim of sum_square_x", self.name)
|
|
2016
|
-
validator.check_int(sum_square_y_shape[0], sum_square_x_shape[1],
|
|
1959
|
+
validator.check_int(sum_square_y_shape[0], sum_square_x_shape[1], validator.EQ,
|
|
2017
1960
|
"the first dim of sum_square_y and the first dim of sum_square_x",
|
|
2018
1961
|
self.name)
|
|
2019
|
-
validator.check_int(sum_square_y_shape[0], 1,
|
|
1962
|
+
validator.check_int(sum_square_y_shape[0], 1, validator.EQ,
|
|
2020
1963
|
"the first dim of sum_square_y", self.name)
|
|
2021
1964
|
|
|
2022
1965
|
k = y_shape[0]
|
|
@@ -2087,7 +2030,7 @@ class ClipByNorm(PrimitiveWithInfer):
|
|
|
2087
2030
|
x_dim = len(x_shape)
|
|
2088
2031
|
axis = self.axis if isinstance(self.axis, Iterable) else (self.axis,)
|
|
2089
2032
|
for _, value in enumerate(axis):
|
|
2090
|
-
validator.check_int_range(value, -x_dim, x_dim,
|
|
2033
|
+
validator.check_int_range(value, -x_dim, x_dim, validator.INC_LEFT, 'axis', self.name)
|
|
2091
2034
|
return x_shape
|
|
2092
2035
|
|
|
2093
2036
|
def infer_dtype(self, x_type, clip_norm_type):
|
|
@@ -2114,23 +2057,24 @@ class TopTypeof(Primitive):
|
|
|
2114
2057
|
def __init__(self):
|
|
2115
2058
|
self.prim = Primitive('TopTypeof')
|
|
2116
2059
|
self.typeof_cache = {
|
|
2117
|
-
'slice':
|
|
2118
|
-
'list':
|
|
2119
|
-
'tuple':
|
|
2120
|
-
'Tensor':
|
|
2121
|
-
'NoneType':
|
|
2122
|
-
'int':
|
|
2123
|
-
'bool':
|
|
2124
|
-
'ellipsis':
|
|
2060
|
+
'slice': mstype.Slice(),
|
|
2061
|
+
'list': mstype.List(),
|
|
2062
|
+
'tuple': mstype.Tuple(),
|
|
2063
|
+
'Tensor': mstype.tensor,
|
|
2064
|
+
'NoneType': mstype.none_type(),
|
|
2065
|
+
'int': mstype.Int(),
|
|
2066
|
+
'bool': mstype.Bool(),
|
|
2067
|
+
'ellipsis': mstype.Ellipsis_(),
|
|
2068
|
+
'dict': mstype.Dict()
|
|
2125
2069
|
}
|
|
2126
2070
|
|
|
2127
2071
|
def __call__(self, x):
|
|
2128
2072
|
index_type = type(x).__name__
|
|
2129
2073
|
if 'Tensor' in index_type:
|
|
2130
2074
|
index_type = 'Tensor'
|
|
2131
|
-
if index_type in
|
|
2075
|
+
if index_type in self.typeof_cache:
|
|
2132
2076
|
return self.typeof_cache.get(index_type)
|
|
2133
|
-
return
|
|
2077
|
+
return _pynative_executor.constant_folding(self.prim, x)
|
|
2134
2078
|
|
|
2135
2079
|
|
|
2136
2080
|
class MixedPrecisionCast(Primitive):
|
|
@@ -2176,3 +2120,430 @@ class MixedPrecisionCast(Primitive):
|
|
|
2176
2120
|
return data
|
|
2177
2121
|
|
|
2178
2122
|
return self.hyper_map(cast_inner, x)
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
class CheckBprop(PrimitiveWithInfer):
|
|
2126
|
+
"""
|
|
2127
|
+
Checks whether the data type and the shape of corresponding elements from tuples x and y are the same.
|
|
2128
|
+
|
|
2129
|
+
Args:
|
|
2130
|
+
prim_to_check (str): The name of the primitive being checked. Default: ''.
|
|
2131
|
+
|
|
2132
|
+
Inputs:
|
|
2133
|
+
- **input_x** (tuple[Tensor]) - The `input_x` contains the outputs of bprop to be checked.
|
|
2134
|
+
- **input_y** (tuple[Tensor]) - The `input_y` contains the inputs of bprop to check against.
|
|
2135
|
+
|
|
2136
|
+
Outputs:
|
|
2137
|
+
Tuple[Tensor], the `input_x`,
|
|
2138
|
+
if data type and shape of corresponding elements from `input_x` and `input_y` are the same.
|
|
2139
|
+
|
|
2140
|
+
Raises:
|
|
2141
|
+
TypeError: If `input_x` or `input_y` is not a Tensor.
|
|
2142
|
+
|
|
2143
|
+
Supported Platforms:
|
|
2144
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
2145
|
+
|
|
2146
|
+
Examples:
|
|
2147
|
+
>>> class Net(nn.Cell):
|
|
2148
|
+
... def __init__(self):
|
|
2149
|
+
... super(Net, self).__init__()
|
|
2150
|
+
... self.op = ops.CheckBprop()
|
|
2151
|
+
... def construct(self, x, y):
|
|
2152
|
+
... return self.op(x, y)
|
|
2153
|
+
...
|
|
2154
|
+
>>> net = Net()
|
|
2155
|
+
>>> input_x = (Tensor(np.array([[2, 2], [2, 2]]), mindspore.float32),)
|
|
2156
|
+
>>> input_y = (Tensor(np.array([[2, 2], [2, 2]]), mindspore.float32),)
|
|
2157
|
+
>>> output = net(input_x, input_y)
|
|
2158
|
+
>>> print(output)
|
|
2159
|
+
(Tensor(shape=[2, 2], dtype=Float32, value=
|
|
2160
|
+
[[ 2.00000000e+00, 2.00000000e+00],
|
|
2161
|
+
[ 2.00000000e+00, 2.00000000e+00]]),)
|
|
2162
|
+
"""
|
|
2163
|
+
|
|
2164
|
+
@prim_attr_register
|
|
2165
|
+
def __init__(self, prim_to_check=""):
|
|
2166
|
+
"""Initialize CheckBprop"""
|
|
2167
|
+
self.prim_to_check = prim_to_check
|
|
2168
|
+
|
|
2169
|
+
def infer_shape(self, xshapes, yshapes):
|
|
2170
|
+
"""infer shape"""
|
|
2171
|
+
tips = f"user defined method 'bprop'"
|
|
2172
|
+
validator.check_value_type('grads', xshapes, (tuple,), tips)
|
|
2173
|
+
validator.check_value_type('params', yshapes, (tuple,), tips)
|
|
2174
|
+
if not len(xshapes) == len(yshapes):
|
|
2175
|
+
raise ValueError(f"For {tips} the number of return values(gradients) must be equal to "
|
|
2176
|
+
f"the number of input arguments except 'out' and 'dout', "
|
|
2177
|
+
f"which is:{len(yshapes)} but got {len(xshapes)}.")
|
|
2178
|
+
checking_range = len(yshapes)
|
|
2179
|
+
for i in range(checking_range):
|
|
2180
|
+
xshape = xshapes[i]
|
|
2181
|
+
yshape = yshapes[i]
|
|
2182
|
+
if not xshape or not yshape:
|
|
2183
|
+
continue
|
|
2184
|
+
if xshape != yshape:
|
|
2185
|
+
raise ValueError(f"For {tips}, the {i}th return value(gradient of the {i}th argument) "
|
|
2186
|
+
f"should have the same shape as the {i}th argument, "
|
|
2187
|
+
f"which is:{yshape}, but got: {xshape}.")
|
|
2188
|
+
return xshapes
|
|
2189
|
+
|
|
2190
|
+
def infer_dtype(self, xdtypes, ydtypes):
|
|
2191
|
+
"""infer dtype"""
|
|
2192
|
+
tips = f"user defined method 'bprop'"
|
|
2193
|
+
validator.check_value_type('grads', xdtypes, (tuple,), tips)
|
|
2194
|
+
validator.check_value_type('params', ydtypes, (tuple,), tips)
|
|
2195
|
+
if not len(xdtypes) == len(ydtypes):
|
|
2196
|
+
raise ValueError(f"For {tips}, the number of return values(gradients) must be equal to "
|
|
2197
|
+
f"the number of input arguments except 'out' and 'dout', "
|
|
2198
|
+
f"which is:{len(ydtypes)} but got {len(xdtypes)}.")
|
|
2199
|
+
checking_range = len(ydtypes)
|
|
2200
|
+
for i in range(checking_range):
|
|
2201
|
+
xdtype = xdtypes[i]
|
|
2202
|
+
ydtype = ydtypes[i]
|
|
2203
|
+
if isinstance(xdtype, mstype.anything_type) or isinstance(ydtype, mstype.anything_type):
|
|
2204
|
+
continue
|
|
2205
|
+
if isinstance(ydtype, mstype.function_type):
|
|
2206
|
+
if not isinstance(xdtype, mstype.env_type_type):
|
|
2207
|
+
raise TypeError(f"For {tips}, the {i}th return value(gradient of the {i}th argument) type "
|
|
2208
|
+
f"should be {mstype.env_type_type}, but got {xdtype}.")
|
|
2209
|
+
if xdtype != ydtype:
|
|
2210
|
+
raise TypeError(f"For {tips}, the {i}th return value(gradient of the {i}th argument) "
|
|
2211
|
+
f"should have the same dtype as the {i}th argument, "
|
|
2212
|
+
f"which is:{ydtype}, but got: {xdtype}.")
|
|
2213
|
+
return xdtypes
|
|
2214
|
+
|
|
2215
|
+
check_bprop = CheckBprop()
|
|
2216
|
+
|
|
2217
|
+
|
|
2218
|
+
class SameTypeShape(PrimitiveWithInfer):
|
|
2219
|
+
"""
|
|
2220
|
+
Checks whether the data type and shape of two tensors are the same.
|
|
2221
|
+
|
|
2222
|
+
Refer to :func:`mindspore.ops.same_type_shape` for more detail.
|
|
2223
|
+
|
|
2224
|
+
Supported Platforms:
|
|
2225
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
2226
|
+
|
|
2227
|
+
Examples:
|
|
2228
|
+
>>> input_x = Tensor(np.array([[2, 2], [2, 2]]), mindspore.float32)
|
|
2229
|
+
>>> input_y = Tensor(np.array([[2, 2], [2, 2]]), mindspore.float32)
|
|
2230
|
+
>>> output = ops.SameTypeShape()(input_x, input_y)
|
|
2231
|
+
>>> print(output)
|
|
2232
|
+
[[2. 2.]
|
|
2233
|
+
[2. 2.]]
|
|
2234
|
+
"""
|
|
2235
|
+
|
|
2236
|
+
@prim_attr_register
|
|
2237
|
+
def __init__(self):
|
|
2238
|
+
"""Initialize Same"""
|
|
2239
|
+
|
|
2240
|
+
def __call__(self, x, y):
|
|
2241
|
+
"""run in PyNative mode"""
|
|
2242
|
+
validator.check_value_type('x', x, Tensor, self.name)
|
|
2243
|
+
validator.check_value_type('y', y, Tensor, self.name)
|
|
2244
|
+
validator.check('x dtype', x.dtype, 'y dtype', y.dtype, validator.EQ, self.name, TypeError)
|
|
2245
|
+
validator.check('x shape', x.shape, 'y shape', y.shape, validator.EQ, self.name)
|
|
2246
|
+
return x
|
|
2247
|
+
|
|
2248
|
+
def __infer__(self, x, y):
|
|
2249
|
+
validator.check_subclass('x', x['dtype'], mstype.tensor, self.name)
|
|
2250
|
+
validator.check_subclass('y', y['dtype'], mstype.tensor, self.name)
|
|
2251
|
+
validator.check('x dtype', x['dtype'], 'y dtype', y['dtype'], validator.EQ, self.name, TypeError)
|
|
2252
|
+
validator.check('x shape', x['shape'], 'y shape', y['shape'], validator.EQ, self.name)
|
|
2253
|
+
return x
|
|
2254
|
+
|
|
2255
|
+
|
|
2256
|
+
same_type_shape_ = SameTypeShape()
|
|
2257
|
+
|
|
2258
|
+
|
|
2259
|
+
def _is_subclass_(type_, dtype):
|
|
2260
|
+
if not isinstance(type_, typing.Type):
|
|
2261
|
+
return False
|
|
2262
|
+
return typing.is_subclass(type_, dtype)
|
|
2263
|
+
|
|
2264
|
+
|
|
2265
|
+
class IsSubClass(PrimitiveWithInfer):
|
|
2266
|
+
"""
|
|
2267
|
+
Checks whether this type is a sub-class of another type.
|
|
2268
|
+
|
|
2269
|
+
Inputs:
|
|
2270
|
+
- **sub_type** (mindspore.dtype) - The type to be checked. Only constant value is allowed.
|
|
2271
|
+
- **type_** (mindspore.dtype) - The target type. Only constant value is allowed.
|
|
2272
|
+
|
|
2273
|
+
Outputs:
|
|
2274
|
+
bool, the check result.
|
|
2275
|
+
|
|
2276
|
+
Raises:
|
|
2277
|
+
TypeError: If `sub_type` or `type_` is not a Type.
|
|
2278
|
+
|
|
2279
|
+
Supported Platforms:
|
|
2280
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
2281
|
+
|
|
2282
|
+
Examples:
|
|
2283
|
+
>>> output = ops.IsSubClass()(mindspore.int32, mindspore.intc)
|
|
2284
|
+
>>> print(output)
|
|
2285
|
+
True
|
|
2286
|
+
"""
|
|
2287
|
+
|
|
2288
|
+
@prim_attr_register
|
|
2289
|
+
def __init__(self):
|
|
2290
|
+
pass
|
|
2291
|
+
|
|
2292
|
+
def __infer__(self, sub_type, type_):
|
|
2293
|
+
sub_type_t = sub_type['value']
|
|
2294
|
+
type_v = type_['value']
|
|
2295
|
+
|
|
2296
|
+
validator.check_value_type("sub_type", sub_type_t, [mstype.Type], self.name)
|
|
2297
|
+
validator.check_value_type("type_", type_v, [mstype.Type], self.name)
|
|
2298
|
+
|
|
2299
|
+
value = _is_subclass_(sub_type_t, type_v)
|
|
2300
|
+
|
|
2301
|
+
out = {'shape': (),
|
|
2302
|
+
'dtype': mstype.type_type,
|
|
2303
|
+
'value': value}
|
|
2304
|
+
return out
|
|
2305
|
+
|
|
2306
|
+
|
|
2307
|
+
issubclass_ = IsSubClass()
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
class IsInstance(PrimitiveWithInfer):
|
|
2311
|
+
"""
|
|
2312
|
+
Checks whether an object is an instance of a target type.
|
|
2313
|
+
|
|
2314
|
+
Inputs:
|
|
2315
|
+
- **inst** (Any Object) - The instance to be checked. Only constant value is allowed.
|
|
2316
|
+
- **type_** (mindspore.dtype) - The target type. Only constant value is allowed.
|
|
2317
|
+
|
|
2318
|
+
Outputs:
|
|
2319
|
+
bool, the check result.
|
|
2320
|
+
|
|
2321
|
+
Raises:
|
|
2322
|
+
TypeError: If `type_` is not a Type.
|
|
2323
|
+
|
|
2324
|
+
Supported Platforms:
|
|
2325
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
2326
|
+
|
|
2327
|
+
Examples:
|
|
2328
|
+
>>> inst = 1
|
|
2329
|
+
>>> output = ops.IsInstance()(inst, mindspore.int32)
|
|
2330
|
+
>>> print(output)
|
|
2331
|
+
False
|
|
2332
|
+
"""
|
|
2333
|
+
|
|
2334
|
+
@prim_attr_register
|
|
2335
|
+
def __init__(self):
|
|
2336
|
+
pass
|
|
2337
|
+
|
|
2338
|
+
def __infer__(self, inst, type_):
|
|
2339
|
+
sub_type_t = inst['dtype']
|
|
2340
|
+
type_v = type_['value']
|
|
2341
|
+
|
|
2342
|
+
validator.check_value_type("type_", type_v, [mstype.Type], self.name)
|
|
2343
|
+
|
|
2344
|
+
if type_v == mstype.list_:
|
|
2345
|
+
value = isinstance(sub_type_t, list)
|
|
2346
|
+
elif type_v == mstype.tuple_:
|
|
2347
|
+
value = isinstance(sub_type_t, tuple)
|
|
2348
|
+
else:
|
|
2349
|
+
value = _is_subclass_(sub_type_t, type_v)
|
|
2350
|
+
|
|
2351
|
+
out = {'shape': (),
|
|
2352
|
+
'dtype': mstype.type_type,
|
|
2353
|
+
'value': value}
|
|
2354
|
+
return out
|
|
2355
|
+
|
|
2356
|
+
|
|
2357
|
+
class ConvertToAdapterTensor(Primitive):
|
|
2358
|
+
"""
|
|
2359
|
+
Convert a tensor from MindSpore's Tensor type to MSAdapter's Tensor type,
|
|
2360
|
+
where MSAdapter's Tensor is a subclass of MindSpore's Tensor.
|
|
2361
|
+
|
|
2362
|
+
Inputs:
|
|
2363
|
+
- **x** (Tensor) - The input tensor.
|
|
2364
|
+
|
|
2365
|
+
Outputs:
|
|
2366
|
+
A tensor, whose type is MSAdapter's Tensor.
|
|
2367
|
+
|
|
2368
|
+
Supported Platforms:
|
|
2369
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
2370
|
+
|
|
2371
|
+
Examples:
|
|
2372
|
+
>>> x = Tensor([1, 2 ,3])
|
|
2373
|
+
>>> x = ops.ConvertToAdapterTensor()(x)
|
|
2374
|
+
>>> print(x)
|
|
2375
|
+
[1 2 3]
|
|
2376
|
+
"""
|
|
2377
|
+
@prim_attr_register
|
|
2378
|
+
def __init__(self):
|
|
2379
|
+
"""Initialize"""
|
|
2380
|
+
|
|
2381
|
+
def __call__(self, x):
|
|
2382
|
+
"""run in PyNative mode"""
|
|
2383
|
+
return ms_adapter_registry.tensor(x, inner=True)
|
|
2384
|
+
|
|
2385
|
+
convert_to_adapter_tensor = ConvertToAdapterTensor()
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
class ConvertToMsTensor(Primitive):
|
|
2389
|
+
"""
|
|
2390
|
+
Convert a tensor from MSAdapter's Tensor type to MindSpore's Tensor type,
|
|
2391
|
+
where MSAdapter's Tensor is a subclass of MindSpore's Tensor.
|
|
2392
|
+
|
|
2393
|
+
Inputs:
|
|
2394
|
+
- **x** (Tensor) - The input tensor.
|
|
2395
|
+
|
|
2396
|
+
Outputs:
|
|
2397
|
+
A tensor, whose type is MindSpore's Tensor.
|
|
2398
|
+
|
|
2399
|
+
Supported Platforms:
|
|
2400
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
2401
|
+
|
|
2402
|
+
Examples:
|
|
2403
|
+
>>> x = Tensor([1, 2 ,3])
|
|
2404
|
+
>>> x = ops.ConvertToMsTensor()(x)
|
|
2405
|
+
>>> print(x)
|
|
2406
|
+
[1 2 3]
|
|
2407
|
+
"""
|
|
2408
|
+
@prim_attr_register
|
|
2409
|
+
def __init__(self):
|
|
2410
|
+
"""Initialize"""
|
|
2411
|
+
|
|
2412
|
+
def __call__(self, x):
|
|
2413
|
+
"""run in PyNative mode"""
|
|
2414
|
+
return Tensor(x)
|
|
2415
|
+
|
|
2416
|
+
convert_to_ms_tensor = ConvertToMsTensor()
|
|
2417
|
+
|
|
2418
|
+
|
|
2419
|
+
class GetGrad(Primitive):
|
|
2420
|
+
"""
|
|
2421
|
+
Use the position id or Parameter object to get the gradient from the output
|
|
2422
|
+
which returned by the :func:`mindspore.ops.grad`.
|
|
2423
|
+
"""
|
|
2424
|
+
|
|
2425
|
+
@prim_attr_register
|
|
2426
|
+
def __init__(self):
|
|
2427
|
+
"""Initialize ScatterElements"""
|
|
2428
|
+
self.init_prim_io_names(
|
|
2429
|
+
inputs=['gradients', 'x'], outputs=['gradient'])
|
|
2430
|
+
|
|
2431
|
+
def __call__(self, gradients, x):
|
|
2432
|
+
if not isinstance(x, int) and not isinstance(x, Parameter):
|
|
2433
|
+
raise TypeError(
|
|
2434
|
+
f"For `get_grad`, the `x` should be an integer or a Parameter, but got {x}")
|
|
2435
|
+
hash_id = x
|
|
2436
|
+
if isinstance(x, Parameter):
|
|
2437
|
+
hash_id = x.name
|
|
2438
|
+
output = None
|
|
2439
|
+
|
|
2440
|
+
def _get_grad(grads, identifier):
|
|
2441
|
+
if isinstance(grads, tuple):
|
|
2442
|
+
if len(grads) != 2 or identifier != grads[0]:
|
|
2443
|
+
for gradient in grads:
|
|
2444
|
+
_get_grad(gradient, identifier)
|
|
2445
|
+
else:
|
|
2446
|
+
nonlocal output
|
|
2447
|
+
output = grads[1]
|
|
2448
|
+
return
|
|
2449
|
+
|
|
2450
|
+
_get_grad(gradients, hash_id)
|
|
2451
|
+
if output is None:
|
|
2452
|
+
raise RuntimeError(
|
|
2453
|
+
f"Can not find the gradient for position or Parameter {x}")
|
|
2454
|
+
return output
|
|
2455
|
+
|
|
2456
|
+
|
|
2457
|
+
class IsParameter(PrimitiveWithInfer):
|
|
2458
|
+
"""
|
|
2459
|
+
Check if input is `Parameter`
|
|
2460
|
+
"""
|
|
2461
|
+
@prim_attr_register
|
|
2462
|
+
def __init__(self):
|
|
2463
|
+
"""Initialize IsParameter"""
|
|
2464
|
+
|
|
2465
|
+
def __call__(self, x):
|
|
2466
|
+
return isinstance(x, Parameter)
|
|
2467
|
+
|
|
2468
|
+
def __infer__(self, x):
|
|
2469
|
+
return {'shape': [],
|
|
2470
|
+
'dtype': mstype.bool_,
|
|
2471
|
+
'value': isinstance(x['dtype'], mstype.ref_type)}
|
|
2472
|
+
|
|
2473
|
+
|
|
2474
|
+
class SiLU(Primitive):
|
|
2475
|
+
r"""
|
|
2476
|
+
Computes SiLU (Sigmoid Linear Unit activation function) of input tensors element-wise.
|
|
2477
|
+
|
|
2478
|
+
Refer to :func:`mindspore.ops.silu` for more details.
|
|
2479
|
+
|
|
2480
|
+
Supported Platforms:
|
|
2481
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
2482
|
+
|
|
2483
|
+
Examples:
|
|
2484
|
+
>>> x = Tensor(np.array([-1, 2, -3, 2, -1]), mindspore.float16)
|
|
2485
|
+
>>> output = ops.SiLU(x)
|
|
2486
|
+
>>> print(output)
|
|
2487
|
+
[-0.269 1.762 -0.1423 1.762 -0.269]
|
|
2488
|
+
"""
|
|
2489
|
+
|
|
2490
|
+
@prim_attr_register
|
|
2491
|
+
def __init__(self):
|
|
2492
|
+
"""Initialize SiLU"""
|
|
2493
|
+
self.init_prim_io_names(inputs=['x'], outputs=['output'])
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
class TileSize(Primitive):
|
|
2497
|
+
r"""
|
|
2498
|
+
Tile size for matmul
|
|
2499
|
+
"""
|
|
2500
|
+
|
|
2501
|
+
@prim_attr_register
|
|
2502
|
+
def __init__(self):
|
|
2503
|
+
"""Initialize TileSize"""
|
|
2504
|
+
self.init_prim_io_names(inputs=['shape', 'out_shape', 'ndim'], outputs=['output'])
|
|
2505
|
+
|
|
2506
|
+
def __call__(self, shape, out_shape, ndim):
|
|
2507
|
+
size = [1] * ndim
|
|
2508
|
+
for idx, (i, j) in enumerate(zip(shape, out_shape)):
|
|
2509
|
+
if i != j:
|
|
2510
|
+
size[idx] = j
|
|
2511
|
+
return tuple(size)
|
|
2512
|
+
|
|
2513
|
+
|
|
2514
|
+
class GetitemTensorIndexInfo(Primitive):
|
|
2515
|
+
r"""
|
|
2516
|
+
Get getitem tensor index info
|
|
2517
|
+
"""
|
|
2518
|
+
|
|
2519
|
+
@prim_attr_register
|
|
2520
|
+
def __init__(self, is_ascend):
|
|
2521
|
+
"""Initialize GetitemTensorIndexInfo"""
|
|
2522
|
+
self.init_prim_io_names(inputs=['data', 'index'],
|
|
2523
|
+
outputs=["new_index", "tensor_update_types", "tensor_update_args"])
|
|
2524
|
+
validator.check_value_type('is_ascend', is_ascend, [bool], self.name)
|
|
2525
|
+
self.is_ascend = is_ascend
|
|
2526
|
+
|
|
2527
|
+
def __call__(self, data, index):
|
|
2528
|
+
return Tensor_.getitem_index_info(data, index, self.is_ascend)
|
|
2529
|
+
|
|
2530
|
+
|
|
2531
|
+
class SetitemTensorIndexInfo(Primitive):
|
|
2532
|
+
r"""
|
|
2533
|
+
Get setitem tensor index info
|
|
2534
|
+
"""
|
|
2535
|
+
|
|
2536
|
+
@prim_attr_register
|
|
2537
|
+
def __init__(self, is_ascend):
|
|
2538
|
+
"""Initialize GetitemTensorIndexInfo"""
|
|
2539
|
+
self.init_prim_io_names(
|
|
2540
|
+
inputs=['data', 'index', 'value'], outputs=['new_index',
|
|
2541
|
+
'v_transfer_types',
|
|
2542
|
+
'v_transfer_args',
|
|
2543
|
+
'tensor_update_types',
|
|
2544
|
+
'tensor_update_args'])
|
|
2545
|
+
validator.check_value_type('is_ascend', is_ascend, [bool], self.name)
|
|
2546
|
+
self.is_ascend = is_ascend
|
|
2547
|
+
|
|
2548
|
+
def __call__(self, data, index, value):
|
|
2549
|
+
return Tensor_.setitem_index_info(data, index, value, self.is_ascend)
|