mindspore 1.10.0__cp37-cp37m-win_amd64.whl → 2.0.0rc1__cp37-cp37m-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.cp37-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp37-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp37-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
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
|
|
19
19
|
"""Operators for sparse operators."""
|
|
20
20
|
|
|
21
|
-
from mindspore
|
|
21
|
+
from mindspore import _checkparam as validator
|
|
22
22
|
from mindspore.common import dtype as mstype
|
|
23
23
|
from mindspore.ops import signature as sig
|
|
24
|
-
from mindspore.ops.primitive import
|
|
24
|
+
from mindspore.ops.primitive import prim_attr_register, Primitive
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class SparseDenseCwiseAdd(Primitive):
|
|
@@ -57,9 +57,12 @@ class SparseDenseCwiseAdd(Primitive):
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
Supported Platforms:
|
|
60
|
-
``Ascend`` ``CPU``
|
|
60
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
61
61
|
|
|
62
62
|
Examples:
|
|
63
|
+
>>> from mindspore.common.tensor import Tensor
|
|
64
|
+
>>> from mindspore.common import dtype as ms
|
|
65
|
+
>>> from mindspore.ops.operations import sparse_ops as ops
|
|
63
66
|
>>> x1_indices = Tensor([[0, 0], [2, 2]], dtype=ms.int64)
|
|
64
67
|
>>> x1_values = Tensor([1, 2], dtype=ms.int32)
|
|
65
68
|
>>> x1_shape = Tensor([3, 3], dtype=ms.int64)
|
|
@@ -109,9 +112,12 @@ class SparseDenseCwiseMul(Primitive):
|
|
|
109
112
|
ValueError: If `x1_indices` proceed to cross the border the interview.
|
|
110
113
|
|
|
111
114
|
Supported Platforms:
|
|
112
|
-
``Ascend`` ``CPU``
|
|
115
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
113
116
|
|
|
114
117
|
Examples:
|
|
118
|
+
>>> from mindspore.common.tensor import Tensor
|
|
119
|
+
>>> from mindspore.common import dtype as ms
|
|
120
|
+
>>> from mindspore.ops.operations import sparse_ops as ops
|
|
115
121
|
>>> x1_indices = Tensor([[0, 0], [2, 2]], dtype=ms.int64)
|
|
116
122
|
>>> x1_values = Tensor([1, 2], dtype=ms.int32)
|
|
117
123
|
>>> x1_shape = Tensor([3, 3], dtype=ms.int64)
|
|
@@ -161,9 +167,12 @@ class SparseDenseCwiseDiv(Primitive):
|
|
|
161
167
|
ValueError: If `x1_indices` proceed to cross the border the interview.
|
|
162
168
|
|
|
163
169
|
Supported Platforms:
|
|
164
|
-
``Ascend`` ``
|
|
170
|
+
``Ascend`` ``GPU``
|
|
165
171
|
|
|
166
172
|
Examples:
|
|
173
|
+
>>> from mindspore.common.tensor import Tensor
|
|
174
|
+
>>> from mindspore.common import dtype as ms
|
|
175
|
+
>>> from mindspore.ops.operations import sparse_ops as ops
|
|
167
176
|
>>> x1_indices = Tensor([[0, 0], [2, 2]], dtype=ms.int64)
|
|
168
177
|
>>> x1_values = Tensor([4, 2], dtype=ms.int32)
|
|
169
178
|
>>> x1_shape = Tensor([3, 3], dtype=ms.int64)
|
|
@@ -183,49 +192,56 @@ class SparseDenseCwiseDiv(Primitive):
|
|
|
183
192
|
|
|
184
193
|
class SparseSlice(Primitive):
|
|
185
194
|
r"""
|
|
186
|
-
Slices a SparseTensor based on the
|
|
195
|
+
Slices a SparseTensor based on the `start` and `size`.
|
|
187
196
|
|
|
188
197
|
Inputs:
|
|
189
|
-
- **indices** (Tensor) - A 2D Tensor of
|
|
190
|
-
Support int64, each element value should be a non-negative int number.
|
|
198
|
+
- **indices** (Tensor) - A 2D Tensor of shape :math:`(N, R)`, the indices of the SparseTensor.
|
|
199
|
+
Support int64, each element value should be a non-negative int number.
|
|
200
|
+
The shape is :math:`(N, R)`.
|
|
191
201
|
- **values** (Tensor) - A 1D Tensor, represents the value corresponding to the position in the `indices`.
|
|
192
|
-
The shape should be :math:`(
|
|
202
|
+
The shape should be :math:`(N,)`.
|
|
193
203
|
- **shape** (Tensor) - A 1D Tensor of type int64 which specifies the shape of sparsetensor,
|
|
194
|
-
|
|
204
|
+
represent sparse tensor shape. The shape should be :math:`(R,)`.
|
|
195
205
|
- **start** (Tensor) - A 1D Tensor of type int64, represents the start of the slice.
|
|
206
|
+
The shape should be :math:`(R,)`.
|
|
196
207
|
- **size** (Tensor) - A 1D Tensor of type int64, represents the size of the slice.
|
|
208
|
+
The shape should be :math:`(R,)`.
|
|
197
209
|
|
|
198
210
|
Outputs:
|
|
199
211
|
A `SparseTensor` objects resulting from splicing.
|
|
200
|
-
|
|
201
|
-
-
|
|
202
|
-
-
|
|
212
|
+
|
|
213
|
+
- \*y_indices: A Tensor of type int64.
|
|
214
|
+
- \*y_values: A Tensor. Has the same type as `values`.
|
|
215
|
+
- \*y_shape: A Tensor of type int64. Has the same size as `size`.
|
|
203
216
|
|
|
204
217
|
Raises:
|
|
205
218
|
TypeError: If the dtype of `indices`, `shape`, `start`, `size` are not int64.
|
|
206
219
|
ValueError: If `indices` is not 2-D tensor.
|
|
207
220
|
ValueError: If `values`, `start`, `shape` , `size` is not a 1-D tensor.
|
|
208
221
|
ValueError: If the number of `indices` is not corresponding to the number of `values`.
|
|
209
|
-
ValueError: If the
|
|
222
|
+
ValueError: If the shape of `indices[1]` is not corresponding to `shape`.
|
|
223
|
+
ValueError: If the shape of `shape` is not corresponding to `start`.
|
|
224
|
+
ValueError: If the shape of `shape` is not corresponding to `size`.
|
|
210
225
|
|
|
211
226
|
Supported Platforms:
|
|
212
227
|
|
|
228
|
+
|
|
213
229
|
Examples:
|
|
214
|
-
>>> indices = Tensor([[0, 1], [1, 2], [1, 3], [2, 2]]
|
|
215
|
-
>>> values = Tensor([1, 2, 3, 4])
|
|
216
|
-
>>> shape = Tensor([3, 4]
|
|
217
|
-
>>> start = Tensor([0, 1]
|
|
218
|
-
>>> size = Tensor([2, 3]
|
|
230
|
+
>>> indices = Tensor(np.array([[0, 1], [1, 2], [1, 3], [2, 2]]).astype(np.int64))
|
|
231
|
+
>>> values = Tensor(np.array([1, 2, 3, 4]).astype(np.int64))
|
|
232
|
+
>>> shape = Tensor(np.array([3, 4]).astype(np.int64))
|
|
233
|
+
>>> start = Tensor(np.array([0, 1]).astype(np.int64))
|
|
234
|
+
>>> size = Tensor(np.array([2, 3]).astype(np.int64))
|
|
219
235
|
>>> sparseslice = ops.SparseSlice()
|
|
220
236
|
>>> output = sparseslice(indices, values, shape, start, size)
|
|
221
237
|
>>> print(output[0])
|
|
222
|
-
[[0
|
|
223
|
-
[1
|
|
224
|
-
[1
|
|
238
|
+
[[0 0]
|
|
239
|
+
[1 1]
|
|
240
|
+
[1 2]]
|
|
225
241
|
>>> print(output[1])
|
|
226
|
-
[1
|
|
242
|
+
[1 2 3]
|
|
227
243
|
>>> print(output[2])
|
|
228
|
-
[2
|
|
244
|
+
[2 3]
|
|
229
245
|
"""
|
|
230
246
|
|
|
231
247
|
@prim_attr_register
|
|
@@ -271,7 +287,7 @@ class SparseSparseMaximum(Primitive):
|
|
|
271
287
|
ValueError: If the `x1_shape` and `x2_shape` mismatch with each other.
|
|
272
288
|
|
|
273
289
|
Supported Platforms:
|
|
274
|
-
``Ascend`` ``CPU``
|
|
290
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
275
291
|
|
|
276
292
|
Examples:
|
|
277
293
|
>>> x1_indices = Tensor([[0, 1], [1, 2]])
|
|
@@ -289,6 +305,7 @@ class SparseSparseMaximum(Primitive):
|
|
|
289
305
|
>>> print(y_values)
|
|
290
306
|
[3. 4. 2.]
|
|
291
307
|
"""
|
|
308
|
+
|
|
292
309
|
@prim_attr_register
|
|
293
310
|
def __init__(self):
|
|
294
311
|
"""Initialize SparseSparseMaximum."""
|
|
@@ -331,7 +348,7 @@ class SetSize(Primitive):
|
|
|
331
348
|
>>> set_indices = Tensor(np.array([[0, 1], [1, 2]]).astype(np.int64))
|
|
332
349
|
>>> set_values = Tensor(np.array([1, 2]).astype(np.int64))
|
|
333
350
|
>>> set_shape = Tensor(np.array([3, 4]).astype(np.int64))
|
|
334
|
-
>>> setsize =
|
|
351
|
+
>>> setsize = ops.SetSize()
|
|
335
352
|
>>> out = setsize(set_indices, set_values, set_shape)
|
|
336
353
|
>>> print(out)
|
|
337
354
|
[1 1 0]
|
|
@@ -366,16 +383,19 @@ class SparseReorder(Primitive):
|
|
|
366
383
|
Raises:
|
|
367
384
|
TypeError: If `indices` or `shape` is not tensor or its dtype is not int64.
|
|
368
385
|
TypeError: If `values` is not tensor or its dtype is incorrect.
|
|
369
|
-
ValueError: If the index exceeds the bounds.
|
|
386
|
+
ValueError: If the index exceeds the bounds. (Raise RuntimeError if on GPU Platform)
|
|
370
387
|
ValueError: If the size of `indices` tensor shape is not equal to 2.
|
|
371
388
|
ValueError: If the size of `values` or `shape` tensor shape is not equal to 1.
|
|
372
389
|
ValueError: If `values` the first dimension length is not equal the first dimension length of 'indices'.
|
|
373
390
|
ValueError: If `shape` the first dimension length is not equal the second dimension length of 'indices'.
|
|
374
391
|
|
|
375
392
|
Supported Platforms:
|
|
376
|
-
``
|
|
393
|
+
``GPU`` ``CPU``
|
|
377
394
|
|
|
378
395
|
Examples:
|
|
396
|
+
>>> import mindspore.common.dtype as ms
|
|
397
|
+
>>> from mindspore import Tensor
|
|
398
|
+
>>> import mindspore.ops.operations.sparse_ops as op
|
|
379
399
|
>>> indices = Tensor([[2, 1], [0, 1]], dtype=ms.int64)
|
|
380
400
|
>>> values = Tensor([1, 2], dtype=ms.int16)
|
|
381
401
|
>>> shape = Tensor([3,3], dtype=ms.int64)
|
|
@@ -394,7 +414,7 @@ class SparseReorder(Primitive):
|
|
|
394
414
|
self.init_prim_io_names(inputs=['indices', 'values', 'shape'], outputs=['y_indices', 'y_values'])
|
|
395
415
|
|
|
396
416
|
|
|
397
|
-
class SparseToDense(
|
|
417
|
+
class SparseToDense(Primitive):
|
|
398
418
|
"""
|
|
399
419
|
Converts a sparse representation into a dense tensor.
|
|
400
420
|
|
|
@@ -406,7 +426,7 @@ class SparseToDense(PrimitiveWithInfer):
|
|
|
406
426
|
- **sparse_shape** (tuple(int)) - A positive int tuple which specifies the shape of sparse tensor,
|
|
407
427
|
should have 2 elements, represent sparse tensor shape is :math:`(N, C)`.
|
|
408
428
|
|
|
409
|
-
|
|
429
|
+
Outputs:
|
|
410
430
|
Tensor, converted from sparse tensor. The dtype is same as `values`, and the shape is `sparse_shape`.
|
|
411
431
|
|
|
412
432
|
Raises:
|
|
@@ -434,34 +454,6 @@ class SparseToDense(PrimitiveWithInfer):
|
|
|
434
454
|
self.init_prim_io_names(
|
|
435
455
|
inputs=['indices', 'values', 'dense_shape'], outputs=['output'])
|
|
436
456
|
|
|
437
|
-
def __infer__(self, indices, values, sparse_shape):
|
|
438
|
-
validator.check_tensor_dtype_valid('indices', indices['dtype'], [
|
|
439
|
-
mstype.int32, mstype.int64], self.name)
|
|
440
|
-
validator.check_tensor_dtype_valid(
|
|
441
|
-
'values', values['dtype'], mstype.number_type + (mstype.bool_,), self.name)
|
|
442
|
-
indices_shape = indices['shape']
|
|
443
|
-
if len(indices_shape) != 2:
|
|
444
|
-
raise ValueError(f"For '{self.name}', the 'indices' must be a 2-D tensor, "
|
|
445
|
-
f"but got 'indices' shape: {indices_shape}.")
|
|
446
|
-
values_shape = values['shape']
|
|
447
|
-
if len(values_shape) != 1 or values_shape[0] != indices_shape[0]:
|
|
448
|
-
raise ValueError(f"For '{self.name}', the 'values' must be a 1-D tensor and the first dimension length "
|
|
449
|
-
f"must be equal to the first dimension length of 'indices', "
|
|
450
|
-
f"but got 'indices' shape: {indices_shape}, 'values' shape: {values_shape}.")
|
|
451
|
-
sparse_shape_v = sparse_shape['value']
|
|
452
|
-
for i in sparse_shape_v:
|
|
453
|
-
if isinstance(i, bool) or not isinstance(i, int) or i <= 0:
|
|
454
|
-
raise ValueError(f"For '{self.name}', all elements in 'sparse_shape' must be "
|
|
455
|
-
f"positive int number, but got 'sparse_shape': {sparse_shape_v}.")
|
|
456
|
-
if len(sparse_shape_v) != indices_shape[1]:
|
|
457
|
-
raise ValueError(f"For '{self.name}', the length of 'sparse_shape' must be equal to the second dimension "
|
|
458
|
-
f"length of 'indices', but got the second dimension length of 'indices': "
|
|
459
|
-
f"{indices_shape[1]}, length of 'sparse_shape': {len(sparse_shape_v)}.")
|
|
460
|
-
out = {'shape': sparse_shape['value'],
|
|
461
|
-
'dtype': values['dtype'],
|
|
462
|
-
'value': None}
|
|
463
|
-
return out
|
|
464
|
-
|
|
465
457
|
|
|
466
458
|
class SparseToDenseV2(Primitive):
|
|
467
459
|
"""
|
|
@@ -513,6 +505,7 @@ class SparseToDenseV2(Primitive):
|
|
|
513
505
|
"""Initialize SparseToDenseV2."""
|
|
514
506
|
self.add_prim_attr("max_length", 1000000)
|
|
515
507
|
self.validate_indices = validate_indices
|
|
508
|
+
validator.check_value_type('validate_indices', validate_indices, [bool], self.name)
|
|
516
509
|
self.add_prim_attr("validate_indices", self.validate_indices)
|
|
517
510
|
self.init_prim_io_names(
|
|
518
511
|
inputs=['indices', 'output_shape', 'values', 'default_value'], outputs=['output'])
|
|
@@ -544,7 +537,7 @@ class SparseSoftmax(Primitive):
|
|
|
544
537
|
ValueError: If the size of shape < 2.
|
|
545
538
|
|
|
546
539
|
Supported Platforms:
|
|
547
|
-
``Ascend`` ``CPU``
|
|
540
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
548
541
|
|
|
549
542
|
Examples:
|
|
550
543
|
>>> indices = Tensor([[0,0], [0,3], [1,2], [1,5], [2,0], [2,5]])
|
|
@@ -568,11 +561,11 @@ class SparseTensorDenseAdd(Primitive):
|
|
|
568
561
|
|
|
569
562
|
Inputs:
|
|
570
563
|
- **x1_indices** (Tensor) - A 2-D Tensor, represents the position of the element in the sparse tensor.
|
|
571
|
-
Support int32, int64, each element value should be a non-negative int number. The shape is :math:`(n,
|
|
564
|
+
Support int32, int64, each element value should be a non-negative int number. The shape is :math:`(n, ndim)`.
|
|
572
565
|
- **x1_values** (Tensor) - A 1-D Tensor, represents the value corresponding to the position in the `indices`.
|
|
573
566
|
The shape should be :math:`(n,)`.
|
|
574
567
|
- **x1_shape** (tuple(int)) - A positive int tuple which specifies the shape of sparse tensor,
|
|
575
|
-
should have
|
|
568
|
+
should have ndim elements, represent sparse tensor shape is :math:`(ndim,)`.
|
|
576
569
|
- **x2** (Tensor) - A dense Tensor, the dtype is same as `values`.
|
|
577
570
|
|
|
578
571
|
Outputs:
|
|
@@ -582,14 +575,14 @@ class SparseTensorDenseAdd(Primitive):
|
|
|
582
575
|
Raises:
|
|
583
576
|
TypeError: If the dtype of `x1_indices` and 'x1_shape' is neither int32 nor int64.
|
|
584
577
|
ValueError: If `x1_shape`, shape of `x1_indices`, shape of `x1_values` and shape
|
|
585
|
-
|
|
578
|
+
of 'x2' don't meet the parameter description.
|
|
586
579
|
|
|
587
580
|
Supported Platforms:
|
|
588
|
-
``CPU``
|
|
581
|
+
``GPU`` ``CPU``
|
|
589
582
|
|
|
590
583
|
Examples:
|
|
591
584
|
>>> from mindspore import Tensor
|
|
592
|
-
>>>
|
|
585
|
+
>>> import mindspore.ops as ops
|
|
593
586
|
>>> from mindspore.common import dtype as mstype
|
|
594
587
|
>>> x1_indices = Tensor([[0, 0], [0, 1]], dtype=mstype.int64)
|
|
595
588
|
>>> x1_values = Tensor([1, 1], dtype=mstype.float32)
|
|
@@ -645,9 +638,13 @@ class SparseTensorDenseMatmul(Primitive):
|
|
|
645
638
|
and shape of `dense` don't meet the parameter description.
|
|
646
639
|
|
|
647
640
|
Supported Platforms:
|
|
648
|
-
``CPU``
|
|
641
|
+
``GPU`` ``CPU``
|
|
649
642
|
|
|
650
643
|
Examples:
|
|
644
|
+
>>> import mindspore
|
|
645
|
+
>>> from mindspore import Tensor
|
|
646
|
+
>>> from mindspore.ops import operations as ops
|
|
647
|
+
>>> from mindspore.common import dtype as mstype
|
|
651
648
|
>>> indices = Tensor([[0, 1], [1, 2]], dtype=mindspore.int32)
|
|
652
649
|
>>> values = Tensor([1, 2], dtype=mindspore.float32)
|
|
653
650
|
>>> sparse_shape = (3, 4)
|
|
@@ -673,45 +670,6 @@ class SparseTensorDenseMatmul(Primitive):
|
|
|
673
670
|
validator.check_value_type("adjoint_dt", adjoint_dt, [bool], self.name)
|
|
674
671
|
self.set_const_input_indexes([2])
|
|
675
672
|
|
|
676
|
-
def __infer__(self, indices, values, sparse_shape, dense):
|
|
677
|
-
validator.check_tensor_dtype_valid('indices', indices['dtype'], [
|
|
678
|
-
mstype.int32, mstype.int64], self.name)
|
|
679
|
-
valid_types = (mstype.float16, mstype.float32,
|
|
680
|
-
mstype.float64, mstype.int32, mstype.int64)
|
|
681
|
-
args = {'values': values['dtype'], 'dense': dense['dtype']}
|
|
682
|
-
validator.check_tensors_dtypes_same_and_valid(
|
|
683
|
-
args, valid_types, self.name)
|
|
684
|
-
indices_shape = indices['shape']
|
|
685
|
-
if len(indices_shape) != 2 or indices_shape[1] != 2:
|
|
686
|
-
raise ValueError(f"For '{self.name}', the 'indices' must be a 2-D tensor and "
|
|
687
|
-
f"the second dimension length must be 2, but got 'indices' shape: {indices_shape}.")
|
|
688
|
-
values_shape = values['shape']
|
|
689
|
-
if len(values_shape) != 1 or values_shape[0] != indices_shape[0]:
|
|
690
|
-
raise ValueError(f"For '{self.name}', the 'values' must be a 1-D tensor and "
|
|
691
|
-
f"the first dimension length must be equal to the first dimension length of 'indices', "
|
|
692
|
-
f"but got 'indices' shape: {indices_shape}, 'values' shape: {values_shape}.")
|
|
693
|
-
a_shape = sparse_shape['value'][::-1] if self.adjoint_st else sparse_shape['value']
|
|
694
|
-
b_shape = dense['shape'][::-1] if self.adjoint_dt else dense['shape']
|
|
695
|
-
for i in a_shape:
|
|
696
|
-
if isinstance(i, bool) or not isinstance(i, int) or i <= 0:
|
|
697
|
-
raise ValueError(f"For '{self.name}', all elements in 'sparse_shape' must be "
|
|
698
|
-
f"positive int number, but got 'sparse_shape': {a_shape}.")
|
|
699
|
-
if len(a_shape) != 2 or len(b_shape) != 2:
|
|
700
|
-
raise ValueError(f"For '{self.name}', both the length of 'sparse_shape' and the tensor "
|
|
701
|
-
f"rank of 'dense' must be equal to 2, but got the length of "
|
|
702
|
-
f"'sparse_shape': {len(a_shape)}, "
|
|
703
|
-
f"the tensor rank of 'dense': {len(b_shape)}.")
|
|
704
|
-
if a_shape[1] != b_shape[0]:
|
|
705
|
-
raise ValueError(f"For '{self.name}', the second dimension length of 'sparse_shape' must be equal to the "
|
|
706
|
-
f"first dimension length of 'dense', but got "
|
|
707
|
-
f"the tensor shape of 'sparse': {a_shape} and the tensor shape of 'dense': {b_shape}. "
|
|
708
|
-
f"Don't meet the condition for matmul")
|
|
709
|
-
out_shape = [a_shape[0], b_shape[1]]
|
|
710
|
-
out = {'shape': tuple(out_shape),
|
|
711
|
-
'dtype': values['dtype'],
|
|
712
|
-
'value': None}
|
|
713
|
-
return out
|
|
714
|
-
|
|
715
673
|
|
|
716
674
|
class CSRSparseMatrixToSparseTensor(Primitive):
|
|
717
675
|
"""
|
|
@@ -788,7 +746,7 @@ class DenseToCSRSparseMatrix(Primitive):
|
|
|
788
746
|
Converts a dense matrix(maybe batched) to its CSR sparse form.
|
|
789
747
|
|
|
790
748
|
.. warning::
|
|
791
|
-
This is an experimental
|
|
749
|
+
This is an experimental API that is subject to change or deletion.
|
|
792
750
|
|
|
793
751
|
Inputs:
|
|
794
752
|
- **dense_input** (Tensor) - A 2-D or 3-D Tensor. It represents the input dense matrix.
|
|
@@ -818,7 +776,7 @@ class DenseToCSRSparseMatrix(Primitive):
|
|
|
818
776
|
ValueError: If shape[1] of `indices` and rank of `dense_input` is not the same.
|
|
819
777
|
|
|
820
778
|
Supported Platforms:
|
|
821
|
-
|
|
779
|
+
|
|
822
780
|
|
|
823
781
|
Examples:
|
|
824
782
|
>>> x = Tensor([[[1., 0.], [0., 2.]]], dtype=mindspore.float32)
|
|
@@ -917,7 +875,7 @@ class Sspaddmm(Primitive):
|
|
|
917
875
|
If `x1_shape` is :math:`(s0, s1)`, `x2_shpae` should be :math:`(s0, s2)`, the `x3_shape` should be :math:`(s2, s1)`.
|
|
918
876
|
|
|
919
877
|
.. warning::
|
|
920
|
-
This is an experimental
|
|
878
|
+
This is an experimental API that is subject to change or deletion.
|
|
921
879
|
|
|
922
880
|
.. math::
|
|
923
881
|
out =\beta * x1 + \alpha * (x2 @ x3),
|
|
@@ -980,7 +938,7 @@ class Sspaddmm(Primitive):
|
|
|
980
938
|
ValueError: If the shape of `alpha`, `beta` is not () or (1,).
|
|
981
939
|
|
|
982
940
|
Supported Platforms:
|
|
983
|
-
``Ascend`` ``CPU``
|
|
941
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
984
942
|
|
|
985
943
|
Examples:
|
|
986
944
|
>>> x1_indices = Tensor(np.array([[0, 1], [0, 1]]), mstype.int64)
|
|
@@ -1003,6 +961,17 @@ class Sspaddmm(Primitive):
|
|
|
1003
961
|
>>> print(out_shapes)
|
|
1004
962
|
[3 3]
|
|
1005
963
|
"""
|
|
964
|
+
__mindspore_signature__ = (
|
|
965
|
+
sig.make_sig('x1_indices', dtype=sig.sig_dtype.T1),
|
|
966
|
+
sig.make_sig('x1_values', dtype=sig.sig_dtype.T),
|
|
967
|
+
sig.make_sig('x1_shape', dtype=sig.sig_dtype.T2),
|
|
968
|
+
sig.make_sig('x2_indices', dtype=sig.sig_dtype.T3),
|
|
969
|
+
sig.make_sig('x2_values', dtype=sig.sig_dtype.T),
|
|
970
|
+
sig.make_sig('x2_shape', dtype=sig.sig_dtype.T4),
|
|
971
|
+
sig.make_sig('x3_dense', dtype=sig.sig_dtype.T),
|
|
972
|
+
sig.make_sig('alpha', dtype=sig.sig_dtype.T),
|
|
973
|
+
sig.make_sig('beta', dtype=sig.sig_dtype.T)
|
|
974
|
+
)
|
|
1006
975
|
|
|
1007
976
|
@prim_attr_register
|
|
1008
977
|
def __init__(self):
|
|
@@ -1041,7 +1010,7 @@ class SparseAddmm(Primitive):
|
|
|
1041
1010
|
RuntimeError: If `x1_shape`, shape of `x2`, shape of `x3` don't meet the parameter description.
|
|
1042
1011
|
|
|
1043
1012
|
Supported Platforms:
|
|
1044
|
-
``
|
|
1013
|
+
``GPU`` ``CPU``
|
|
1045
1014
|
|
|
1046
1015
|
Examples:
|
|
1047
1016
|
>>> indices = Tensor([[0, 1], [1, 2]], dtype=ms.int32)
|
|
@@ -1114,6 +1083,7 @@ class SparseConcat(Primitive):
|
|
|
1114
1083
|
[3, 0],
|
|
1115
1084
|
[4, 1]]), Tensor(shape=[4], dtype=Int32, value= [1, 2, 3, 4]), Tensor(shape=[2], dtype=Int64, value= [6, 4]))
|
|
1116
1085
|
"""
|
|
1086
|
+
|
|
1117
1087
|
@prim_attr_register
|
|
1118
1088
|
def __init__(self, concat_dim=0):
|
|
1119
1089
|
"""Initialize SparseConcat."""
|
|
@@ -1127,11 +1097,11 @@ class SparseSegmentSum(Primitive):
|
|
|
1127
1097
|
Computes the sum along sparse segments of a tensor.
|
|
1128
1098
|
|
|
1129
1099
|
Inputs:
|
|
1130
|
-
- **x** (Tensor) - A tensor.
|
|
1131
|
-
- **indices** (Tensor) -
|
|
1132
|
-
Has same rank as segment_ids
|
|
1133
|
-
- **segment_ids** (Tensor) -
|
|
1134
|
-
|
|
1100
|
+
- **x** (Tensor) - A tensor of the first input of SparseSegmentSum.
|
|
1101
|
+
- **indices** (Tensor) - 1-D Tensor of type int32 or int 64 with indices into `x`.
|
|
1102
|
+
Has same rank as `segment_ids`. The shape should be :math:`(N,)`.
|
|
1103
|
+
- **segment_ids** (Tensor) - 1-D Tensor of type int32 or int64 with indices into the output `y`. Values
|
|
1104
|
+
should be sorted and can be repeated. The shape should be :math:`(N,)`.
|
|
1135
1105
|
|
|
1136
1106
|
Outputs:
|
|
1137
1107
|
A Tensor. Has the same type as `x` .
|
|
@@ -1145,10 +1115,10 @@ class SparseSegmentSum(Primitive):
|
|
|
1145
1115
|
ValueError: If shape[0] of `indices` is not corresponding to shape[0] of `segment_ids`.
|
|
1146
1116
|
ValueError: If indices in `segment_ids` are not contiguous or do not start from 0.
|
|
1147
1117
|
ValueError: If `segment_ids` is not sorted.
|
|
1148
|
-
ValueError: If `indices` is out of range of x's first
|
|
1118
|
+
ValueError: If `indices` is out of range of x's first dimension.
|
|
1149
1119
|
|
|
1150
1120
|
Supported Platforms:
|
|
1151
|
-
``GPU``
|
|
1121
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1152
1122
|
|
|
1153
1123
|
Examples:
|
|
1154
1124
|
>>> x = Tensor([[0, 1, 2], [1, 2, 3], [3, 6, 7]], dtype=ms.float32)
|
|
@@ -1170,7 +1140,6 @@ class SparseSegmentSum(Primitive):
|
|
|
1170
1140
|
def __init__(self):
|
|
1171
1141
|
"""Initialize SparseSegmentSum"""
|
|
1172
1142
|
self.init_prim_io_names(inputs=['x', 'indices', 'segment_ids'], outputs=['y'])
|
|
1173
|
-
self.add_prim_attr("cust_aicpu", self.name)
|
|
1174
1143
|
|
|
1175
1144
|
|
|
1176
1145
|
class SparseSegmentSumWithNumSegments(Primitive):
|
|
@@ -1178,12 +1147,13 @@ class SparseSegmentSumWithNumSegments(Primitive):
|
|
|
1178
1147
|
Computes the sum along sparse segments of a tensor, but it is allowed to miss id in segment_ids.
|
|
1179
1148
|
|
|
1180
1149
|
Inputs:
|
|
1181
|
-
- **x** (Tensor) - A Tensor.
|
|
1182
|
-
- **indices** (Tensor) -
|
|
1183
|
-
Has same rank as segment_ids
|
|
1184
|
-
- **segment_ids** (Tensor) -
|
|
1185
|
-
Values should be sorted and can be repeated. The shape should be :math:`(N,)`.
|
|
1186
|
-
- **num_segments** (Tensor) - Num_segments
|
|
1150
|
+
- **x** (Tensor) - A Tensor of the first input of SparseSegmentSumWithNumSegments.
|
|
1151
|
+
- **indices** (Tensor) - 1-D Tensor with indices into `x`. Must be one of the following types: int32, int64.
|
|
1152
|
+
Has same rank as `segment_ids`. The shape should be :math:`(N,)`.
|
|
1153
|
+
- **segment_ids** (Tensor) - 1-D Tensor with indices into the output `y`. Must be one of the following types:
|
|
1154
|
+
int32, int64. Values should be sorted and can be repeated. The shape should be :math:`(N,)`.
|
|
1155
|
+
- **num_segments** (Tensor) - Num_segments indicates the size of the output.
|
|
1156
|
+
It should be bigger than the largest id of `segment_ids`.
|
|
1187
1157
|
|
|
1188
1158
|
Outputs:
|
|
1189
1159
|
A Tensor. Has the same type as `x` .
|
|
@@ -1199,10 +1169,10 @@ class SparseSegmentSumWithNumSegments(Primitive):
|
|
|
1199
1169
|
ValueError: If shape[0] of `indices` is not corresponding to shape[0] of `segment_ids`.
|
|
1200
1170
|
ValueError: If `segment_ids` is not sorted.
|
|
1201
1171
|
ValueError: If the last number of `segment_ids` is bigger than or equal to `num_segments`.
|
|
1202
|
-
ValueError: If `indices` is out of range of x's first
|
|
1172
|
+
ValueError: If `indices` is out of range of x's first dimension.
|
|
1203
1173
|
|
|
1204
1174
|
Supported Platforms:
|
|
1205
|
-
``GPU``
|
|
1175
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1206
1176
|
|
|
1207
1177
|
Examples:
|
|
1208
1178
|
>>> x = Tensor([[0, 1, 0, 0], [0, 1, 1, 0], [1, 0, 1, 0]], dtype=ms.float16)
|
|
@@ -1221,14 +1191,13 @@ class SparseSegmentSumWithNumSegments(Primitive):
|
|
|
1221
1191
|
sig.make_sig('x', dtype=sig.sig_dtype.T1),
|
|
1222
1192
|
sig.make_sig('indices', dtype=sig.sig_dtype.T),
|
|
1223
1193
|
sig.make_sig('segment_ids', dtype=sig.sig_dtype.T),
|
|
1224
|
-
sig.make_sig('
|
|
1194
|
+
sig.make_sig('num_segments', dtype=sig.sig_dtype.T)
|
|
1225
1195
|
)
|
|
1226
1196
|
|
|
1227
1197
|
@prim_attr_register
|
|
1228
1198
|
def __init__(self):
|
|
1229
1199
|
"""Initialize SparseSegmentSumWithNumSegments"""
|
|
1230
1200
|
self.init_prim_io_names(inputs=['x', 'indices', 'segment_ids', 'num_segments'], outputs=['y'])
|
|
1231
|
-
self.add_prim_attr("cust_aicpu", self.name)
|
|
1232
1201
|
|
|
1233
1202
|
|
|
1234
1203
|
class SparseSegmentSqrtN(Primitive):
|
|
@@ -1382,7 +1351,7 @@ class SparseMatrixNNZ(Primitive):
|
|
|
1382
1351
|
ValueError: If shape[0] of `x_dense_shape` is not 2 or 3.
|
|
1383
1352
|
|
|
1384
1353
|
Supported Platforms:
|
|
1385
|
-
``Ascend`` ``CPU``
|
|
1354
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1386
1355
|
|
|
1387
1356
|
Examples:
|
|
1388
1357
|
>>> dense_shape = Tensor([2,3], dtype=mstype.int32)
|
|
@@ -1403,6 +1372,65 @@ class SparseMatrixNNZ(Primitive):
|
|
|
1403
1372
|
inputs=['x_dense_shape', 'x_batch_pointers', 'x_row_pointers', 'x_col_indices', 'x_values'], outputs=['y'])
|
|
1404
1373
|
|
|
1405
1374
|
|
|
1375
|
+
class SparseFillEmptyRows(Primitive):
|
|
1376
|
+
r"""
|
|
1377
|
+
Fill the blank lines in the input 2D SparseTensor with default values.
|
|
1378
|
+
|
|
1379
|
+
Inputs:
|
|
1380
|
+
- **indices** (Tensor) - A 2-D Tensor, represents the position of the element in the sparse tensor.
|
|
1381
|
+
Support int64, each element value should be a non-negative int number. The shape is :math:`(n, 2)`.
|
|
1382
|
+
- **values** (Tensor) - A 1-D Tensor, represents the value corresponding to the position in the `indices`.
|
|
1383
|
+
The shape should be :math:`(n,)`.
|
|
1384
|
+
- **dense_shape** (Tensor) - A 1-D Tensor with only two elements, represents the shape of SparseTensor.
|
|
1385
|
+
Support int64.
|
|
1386
|
+
- **default_value** (Tensor) - A 0-D Tensor of the same type as `values`, scalar value to
|
|
1387
|
+
fill the blank lines in the input 2D SparseTensor.
|
|
1388
|
+
|
|
1389
|
+
Outputs:
|
|
1390
|
+
- **output_indices** (Tensor) - A 2-D Tensor, represents the position of the element in the sparse tensor
|
|
1391
|
+
after being filled. Support int64, each element value should be a non-negative int number.
|
|
1392
|
+
The shape is :math:`(m, 2)`, because of being filled, m>=n.
|
|
1393
|
+
- **output_values** (Tensor) - A 1-D Tensor. It represents the value corresponding to the position
|
|
1394
|
+
in the `output_indices`, the shape of which should be :math:`(m,)`, because of being filled, m>=n.
|
|
1395
|
+
- **empty_row_indicator** (Tensor) - A 1-D Tensor. It indicates whether each row is empty.
|
|
1396
|
+
Support bool. The shape is :math:`(dense\_shape[0],)`.
|
|
1397
|
+
- **reverse_index_map** (Tensor) - A 1-D Tensor. It is the index that means the value here is original
|
|
1398
|
+
rather than filled. Support bool. The shape is :math:`(n, 2)`.
|
|
1399
|
+
|
|
1400
|
+
Raises:
|
|
1401
|
+
TypeError: If the dtype of `indices` is not int64.
|
|
1402
|
+
TypeError: If the dtype of `dense_shape` is not int64.
|
|
1403
|
+
TypeError: If the dtype of `values` and the dtype of `default_value` are not same.
|
|
1404
|
+
ValueError: If `sparse_shape`, shape of `indices` and shape of `values` don't meet the parameter description.
|
|
1405
|
+
|
|
1406
|
+
Supported Platforms:
|
|
1407
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1408
|
+
|
|
1409
|
+
Examples:
|
|
1410
|
+
>>> indices = Tensor([[1, 0]], dtype=mstype.int64)
|
|
1411
|
+
>>> values = Tensor([4], dtype=mstype.float32)
|
|
1412
|
+
>>> dense_shape = Tensor([2, 3], dtype=mstype.int64)
|
|
1413
|
+
>>> default_value = Tensor(5, dtype=mstype.float32)
|
|
1414
|
+
>>> sparsefillemptyrows = ops.SparseFillEmptyRows()
|
|
1415
|
+
>>> out = sparsefillemptyrows(indices, values, dense_shape, default_value)
|
|
1416
|
+
>>> print(out[0])
|
|
1417
|
+
Tensor(shape=[2, 2], dtype=Int64, value=
|
|
1418
|
+
[[0, 0],
|
|
1419
|
+
[1, 0]])
|
|
1420
|
+
>>> print(out[1])
|
|
1421
|
+
Tensor(shape=[2], dtype=Float32, value= [ 5.00000000e+00, 4.00000000e+00])
|
|
1422
|
+
>>> print(out[2])
|
|
1423
|
+
Tensor(shape=[2], dtype=Bool, value= [ True, False])
|
|
1424
|
+
>>> print(out[3])
|
|
1425
|
+
Tensor(shape=[1], dtype=Int64, value= [1])
|
|
1426
|
+
"""
|
|
1427
|
+
@prim_attr_register
|
|
1428
|
+
def __init__(self):
|
|
1429
|
+
"""Initialize SparseFillEmptyRows."""
|
|
1430
|
+
self.init_prim_io_names(inputs=['indices', 'values', 'dense_shape', 'default_value'],
|
|
1431
|
+
outputs=['output_indices', 'output_values', 'empty_row_indicator', 'reverse_index_map'])
|
|
1432
|
+
|
|
1433
|
+
|
|
1406
1434
|
class SparseSegmentMeanWithNumSegments(Primitive):
|
|
1407
1435
|
"""
|
|
1408
1436
|
Compute the mean along sparse segments of a tensor. It is allowed to have missing id in segment_ids.
|
|
@@ -1437,9 +1465,12 @@ class SparseSegmentMeanWithNumSegments(Primitive):
|
|
|
1437
1465
|
ValueError: If `indices` is out of range of x's first dimension.
|
|
1438
1466
|
|
|
1439
1467
|
Supported Platforms:
|
|
1440
|
-
``
|
|
1468
|
+
``GPU`` ``CPU``
|
|
1441
1469
|
|
|
1442
1470
|
Examples:
|
|
1471
|
+
>>> from mindspore import Tensor
|
|
1472
|
+
>>> import mindspore as ms
|
|
1473
|
+
>>> import mindspore.ops.operations.sparse_ops as ops
|
|
1443
1474
|
>>> x = Tensor([[0, 2, 0, 0], [0, 1, 1, 0], [2, 0, 2, 0]], dtype=ms.float16)
|
|
1444
1475
|
>>> indices = Tensor([0, 2, 1], dtype=ms.int32)
|
|
1445
1476
|
>>> segment_ids = Tensor([0, 0, 2], dtype=ms.int32)
|
|
@@ -1470,8 +1501,9 @@ class SparseAdd(Primitive):
|
|
|
1470
1501
|
- **x2_indices** (Tensor) - represents the second COOTensor's indices.
|
|
1471
1502
|
- **x2_values** (Tensor) - represents the second COOTensor's values.
|
|
1472
1503
|
- **x2_shape** (Tensor) - represents the second COOTensor's dense shape.
|
|
1473
|
-
- **thresh** (Tensor) - represents the magnitude threshold that determines if an output
|
|
1474
|
-
value/index pair take space.
|
|
1504
|
+
- **thresh** (Tensor) - A 0-D Tensor, represents the magnitude threshold that determines if an output
|
|
1505
|
+
value/index pair take space. Its dtype should match that of the values if they are real.
|
|
1506
|
+
If output's value is less than the `thresh`, it will vanish.
|
|
1475
1507
|
|
|
1476
1508
|
Outputs:
|
|
1477
1509
|
- **sum_indices** (Tensor) - this is the indices of the sum.
|
|
@@ -1497,7 +1529,7 @@ class SparseAdd(Primitive):
|
|
|
1497
1529
|
TypeError: If (x1_values/x2_values)'s type is not matched with thresh's type.
|
|
1498
1530
|
|
|
1499
1531
|
Supported Platforms:
|
|
1500
|
-
``
|
|
1532
|
+
``GPU`` ``CPU``
|
|
1501
1533
|
|
|
1502
1534
|
Examples:
|
|
1503
1535
|
>>> from mindspore import Tensor
|
|
@@ -1517,6 +1549,7 @@ class SparseAdd(Primitive):
|
|
|
1517
1549
|
Tensor(shape=[4], dtype=Int32, value=[3, 1, 4, 2]),
|
|
1518
1550
|
Tensor(shape=[2], dtype=Int64, value=[3, 4]))
|
|
1519
1551
|
"""
|
|
1552
|
+
|
|
1520
1553
|
@prim_attr_register
|
|
1521
1554
|
def __init__(self):
|
|
1522
1555
|
self.init_prim_io_names(
|
|
@@ -1530,7 +1563,7 @@ class SparseMatrixSoftmax(Primitive):
|
|
|
1530
1563
|
Calculates the softmax of a CSRTensorMatrix.
|
|
1531
1564
|
|
|
1532
1565
|
.. warning::
|
|
1533
|
-
This is an experimental
|
|
1566
|
+
This is an experimental API that is subject to change or deletion.
|
|
1534
1567
|
|
|
1535
1568
|
Args:
|
|
1536
1569
|
dtype (dtype.Number) - The valid data type. Only constant value is allowed.
|
|
@@ -1725,6 +1758,7 @@ class SparseMatrixTranspose(Primitive):
|
|
|
1725
1758
|
>>> print(output[4])
|
|
1726
1759
|
[99.]
|
|
1727
1760
|
"""
|
|
1761
|
+
|
|
1728
1762
|
@prim_attr_register
|
|
1729
1763
|
def __init__(self, conjugate=False):
|
|
1730
1764
|
"""Initialize SparseMatrixTranspose"""
|
|
@@ -1776,7 +1810,7 @@ class SparseSparseMinimum(Primitive):
|
|
|
1776
1810
|
ValueError: If shape[0] of `x1_shape` is not corresponding to shape[0] of `x2_shape`.
|
|
1777
1811
|
|
|
1778
1812
|
Supported Platforms:
|
|
1779
|
-
``
|
|
1813
|
+
``GPU`` ``CPU``
|
|
1780
1814
|
|
|
1781
1815
|
Examples:
|
|
1782
1816
|
>>> from mindspore.ops.operations.sparse_ops import SparseSparseMinimum
|
|
@@ -1998,7 +2032,7 @@ class SparseMatrixMatMul(Primitive):
|
|
|
1998
2032
|
r"""
|
|
1999
2033
|
Performs a matrix multiplication of a sparse matrix x1 with dense matrix x2; return a dense matrix x1*x2.
|
|
2000
2034
|
Each matrix may be transposed or adjointed (conjugated and transposed)
|
|
2001
|
-
according to the Boolean parameters transpose_x1,adjoint_x1,transpose_x2 and adjoint_x2.
|
|
2035
|
+
according to the Boolean parameters transpose_x1, adjoint_x1, transpose_x2 and adjoint_x2.
|
|
2002
2036
|
At most one of transpose_x1 or adjoint_x1 may be True.
|
|
2003
2037
|
Similarly, at most one of transpose_x2 or adjoint_x2 may be True.
|
|
2004
2038
|
|
|
@@ -2025,35 +2059,34 @@ class SparseMatrixMatMul(Primitive):
|
|
|
2025
2059
|
nonzero values of the first `i - 1` rows in the corresponding batch.
|
|
2026
2060
|
- **x1_col_indices** (Tensor) - A 1-D Tensor. It represents column indices of the nonzero values
|
|
2027
2061
|
in the input CSR sparse matrix x1.
|
|
2028
|
-
- **x1_values** (Tensor) - A 1-D Tensor. It represents all the nonzero values
|
|
2029
|
-
input CSR sparse matrix x1.
|
|
2030
|
-
|
|
2062
|
+
- **x1_values** (Tensor) - A 1-D Tensor. It represents all the nonzero values
|
|
2063
|
+
in the input CSR sparse matrix x1. Support float32, float64, complex64, complex128.
|
|
2031
2064
|
- **x2_dense** (Tensor) - A 2-D or 3-D Tensor, represents the input dense matrix x2.
|
|
2032
|
-
|
|
2065
|
+
Its dtype is the same as `x1_values`.
|
|
2033
2066
|
|
|
2034
2067
|
Outputs:
|
|
2035
|
-
|
|
2036
|
-
|
|
2068
|
+
Tensor, which represents the output dense matrix y.
|
|
2069
|
+
Its dtype is the same as `x1_values`.
|
|
2037
2070
|
|
|
2038
2071
|
Raises:
|
|
2039
|
-
TypeError: If
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
ValueError: If shape[0]
|
|
2072
|
+
TypeError: If the dtype of `x1_dense_shape`, `x1_batch_pointers`, `x1_row_pointers` or `x1_col_indices`
|
|
2073
|
+
is not int32 or int64, or the dtypes of above inputs are not the same.
|
|
2074
|
+
TypeError: If the dtype of `x1_values`, `x2_dense` is not supported.
|
|
2075
|
+
ValueError: If shape[0] of `x1_dense_shape` or the dimension of `x2_dense` is not 2 or 3.
|
|
2076
|
+
ValueError: If shape[0]-1 of `x1_batch_pointers` and shape[0] of `x2_dense` are not the same.
|
|
2043
2077
|
|
|
2044
2078
|
Supported Platforms:
|
|
2045
|
-
|
|
2079
|
+
``CPU``
|
|
2046
2080
|
|
|
2047
2081
|
Examples:
|
|
2048
|
-
>>>
|
|
2049
|
-
>>>
|
|
2050
|
-
>>>
|
|
2051
|
-
>>>
|
|
2052
|
-
>>>
|
|
2053
|
-
>>> x1_values = Tensor([1.0, 5.0, -1.0, -2.0], dtype=mindspore.float32)
|
|
2082
|
+
>>> x1_dense_shape = Tensor([4, 5], dtype=ms.int32)
|
|
2083
|
+
>>> x1_batch_pointers = Tensor([0, 4], dtype=ms.int32)
|
|
2084
|
+
>>> x1_row_pointers = Tensor([0, 1, 1, 3, 4], dtype=ms.int32)
|
|
2085
|
+
>>> x1_col_indices = Tensor([0, 3, 4, 0], dtype=ms.int32)
|
|
2086
|
+
>>> x1_values = Tensor([1.0, 5.0, -1.0, -2.0], dtype=ms.float32)
|
|
2054
2087
|
>>> x2_dense = Tensor([[2.0, 0.8, 1.0],[ 2.9, 3.2, 0.0],[7.0, 4.6, 0.2],[3.5, 4.9, 1.4],[4.0, 3.7, 6.9]],
|
|
2055
|
-
... dtype=
|
|
2056
|
-
>>> sparse_matrix_mat_mul = SparseMatrixMatMul()
|
|
2088
|
+
... dtype=ms.float32)
|
|
2089
|
+
>>> sparse_matrix_mat_mul = ops.SparseMatrixMatMul()
|
|
2057
2090
|
>>> out = sparse_matrix_mat_mul(x1_dense_shape, x1_batch_pointers, x1_row_pointers, x1_col_indices,
|
|
2058
2091
|
... x1_values, x2_dense)
|
|
2059
2092
|
>>> print(out)
|
|
@@ -2149,6 +2182,7 @@ class SparseMatrixAdd(Primitive):
|
|
|
2149
2182
|
Tensor(shape=[2], dtype=Int32, values = [0, 1]),
|
|
2150
2183
|
Tensor(shape=[2], dtype=Float32, values = [2.0, 4.0]))
|
|
2151
2184
|
"""
|
|
2185
|
+
|
|
2152
2186
|
@prim_attr_register
|
|
2153
2187
|
def __init__(self):
|
|
2154
2188
|
'''Initialize for SparseMatrixAdd'''
|
|
@@ -2194,6 +2228,7 @@ class SparseSplit(Primitive):
|
|
|
2194
2228
|
Supported Platforms:
|
|
2195
2229
|
|
|
2196
2230
|
"""
|
|
2231
|
+
|
|
2197
2232
|
@prim_attr_register
|
|
2198
2233
|
def __init__(self, num_split=1):
|
|
2199
2234
|
"""Initialize SparseSplit."""
|
|
@@ -2307,7 +2342,7 @@ class SparseReshape(Primitive):
|
|
|
2307
2342
|
RuntimeError: If inferred-dim(-1) in `new_shape` cannot be correctly inferred.
|
|
2308
2343
|
|
|
2309
2344
|
Supported Platforms:
|
|
2310
|
-
``Ascend`` ``CPU``
|
|
2345
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
2311
2346
|
|
|
2312
2347
|
Examples:
|
|
2313
2348
|
>>> indices = Tensor([[0, 0, 0],
|
|
@@ -2329,6 +2364,7 @@ class SparseReshape(Primitive):
|
|
|
2329
2364
|
>>> print(y_shape)
|
|
2330
2365
|
[9 4]
|
|
2331
2366
|
"""
|
|
2367
|
+
|
|
2332
2368
|
@prim_attr_register
|
|
2333
2369
|
def __init__(self):
|
|
2334
2370
|
"""Initialize SparseReshape."""
|
|
@@ -2371,8 +2407,8 @@ class SparseCountSparseOutput(Primitive):
|
|
|
2371
2407
|
ValueError: If number of values does not match first dimension of indices
|
|
2372
2408
|
ValueError: If number of dense_shape dimensions does not match second dimension of indices
|
|
2373
2409
|
ValueError: If num dim of dense_shape is < 1
|
|
2374
|
-
|
|
2375
|
-
|
|
2410
|
+
RuntimeError: If number of weights is not equal to number of values
|
|
2411
|
+
RuntimeError: If indexes are not in bounds of the dense shape
|
|
2376
2412
|
|
|
2377
2413
|
Examples:
|
|
2378
2414
|
>>> from mindspore.ops.operations.sparse_ops import SparseCountSparseOutput
|
|
@@ -2393,6 +2429,7 @@ class SparseCountSparseOutput(Primitive):
|
|
|
2393
2429
|
``CPU``
|
|
2394
2430
|
|
|
2395
2431
|
"""
|
|
2432
|
+
|
|
2396
2433
|
@prim_attr_register
|
|
2397
2434
|
def __init__(self, binary_output=False, minlength=-1, maxlength=-1):
|
|
2398
2435
|
self.init_prim_io_names(
|
|
@@ -2401,3 +2438,311 @@ class SparseCountSparseOutput(Primitive):
|
|
|
2401
2438
|
validator.check_value_type("binary_output", binary_output, [bool], self.name)
|
|
2402
2439
|
validator.check_value_type("minlength", minlength, [int], self.name)
|
|
2403
2440
|
validator.check_value_type("maxlength", maxlength, [int], self.name)
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
class DenseToSparseSetOperation(Primitive):
|
|
2444
|
+
"""
|
|
2445
|
+
Applies set operation along last dimension of `x1` and `x2`.
|
|
2446
|
+
Input `x2` is a SparseTensor represented by `x2_indices`, `x2_values`, and `x2_shape`.
|
|
2447
|
+
For `x2` ranked `n`, 1st `n-1` dimensions must be the same as `x1`. Dimension `n` contains values in a set,
|
|
2448
|
+
duplicates are allowed but ignored.
|
|
2449
|
+
|
|
2450
|
+
Args:
|
|
2451
|
+
set_operation (str): The type of set operation, supports four kinds of inputs, case insensitive. Default: "".
|
|
2452
|
+
"a-b": Get the difference set of x1 to x2.
|
|
2453
|
+
"b-a": Get the difference set of x2 to x1.
|
|
2454
|
+
"intersection": Get the intersection set of x2 to x1.
|
|
2455
|
+
"union": Get the union set of x2 to x1.
|
|
2456
|
+
validate_indices (bool): Optional attributes for DenseToSparseSetOperation. Default: True.
|
|
2457
|
+
|
|
2458
|
+
Inputs:
|
|
2459
|
+
- **x1** (Tensor) - The input tensor `x1` with rank `n`. 1st `n-1` dimensions must be the same as `x2`.
|
|
2460
|
+
Dimension `n` contains values in a set, duplicates are allowed but ignored. Must be one of the
|
|
2461
|
+
following types: int8, int16, int32, int64, uint8, uint16.
|
|
2462
|
+
- **x2_indices** (Tensor) - A 2-D Tensor, type int64, indices of a SparseTensor.
|
|
2463
|
+
- **x2_values** (Tensor) - A 1-D Tensor, must have the same type as x1, values of a SparseTensor. Size
|
|
2464
|
+
must be the same as `x2_indices`
|
|
2465
|
+
- **x2_shape** (Tensor) - A 1-D Tensor, type int64, shape of a SparseTensor, must have the same size as
|
|
2466
|
+
the second dimensions of `x2_indices`
|
|
2467
|
+
|
|
2468
|
+
Outputs:
|
|
2469
|
+
y_indices: A Tensor of type int64.
|
|
2470
|
+
y_values: A Tensor. Has the same type as x1.
|
|
2471
|
+
y_shape: A Tensor of type int64 .
|
|
2472
|
+
|
|
2473
|
+
Raises:
|
|
2474
|
+
TypeError: If any input is not Tensor.
|
|
2475
|
+
TypeError:If the dtype of `x2_values` is not the same as 'x1'.
|
|
2476
|
+
TypeError:If the dtype of `x2_indices` or `x2_shape` is not int64.
|
|
2477
|
+
ValueError: If the group shape of `x1` or `x2` mismatch with each other.
|
|
2478
|
+
ValueError: If the rank of `x1` is less than 2.
|
|
2479
|
+
ValueError: If the rank of `x2_indices` is not equal 2.
|
|
2480
|
+
|
|
2481
|
+
Supported Platforms:
|
|
2482
|
+
``Ascend`` ``CPU``
|
|
2483
|
+
|
|
2484
|
+
Examples:
|
|
2485
|
+
>>> from mindspore.ops.operations.sparse_ops import DenseToSparseSetOperation
|
|
2486
|
+
>>> x1 = Tensor([[1, 2], [3, 0], [1, 5]], dtype=ms.int64)
|
|
2487
|
+
>>> x2_indices = Tensor([[0, 1], [0, 2], [1, 2]], dtype=ms.int64)
|
|
2488
|
+
>>> x2_values = Tensor([5, 1, 7],dtype=ms.int64)
|
|
2489
|
+
>>> x2_shape = Tensor([3, 3], dtype=ms.int64)
|
|
2490
|
+
>>> dense_to_sparse_set_operation = DenseToSparseSetOperation(set_operation='intersection')
|
|
2491
|
+
>>> out = dense_to_sparse_set_operation(x1, x2_indices, x2_values, x2_shape)
|
|
2492
|
+
>>> print(out)
|
|
2493
|
+
(Tensor(shape=[1, 2], dtype=Int64, value=
|
|
2494
|
+
[[0, 0]]), Tensor(shape=[1], dtype=Int64, value= [1]), Tensor(shape=[2], dtype=Int64, value= [3, 1]))
|
|
2495
|
+
"""
|
|
2496
|
+
|
|
2497
|
+
@prim_attr_register
|
|
2498
|
+
def __init__(self, set_operation="", validate_indices=True):
|
|
2499
|
+
"""Initialize DenseToSparseSetOperation."""
|
|
2500
|
+
self.init_prim_io_names(inputs=['x1', 'x2_indices', 'x2_values', 'x2_shape'],
|
|
2501
|
+
outputs=['y_indices', 'y_values', 'y_shape'])
|
|
2502
|
+
self.set_operation = set_operation
|
|
2503
|
+
self.validate_indices = validate_indices
|
|
2504
|
+
self.add_prim_attr('set_operation', self.set_operation)
|
|
2505
|
+
self.add_prim_attr('validate_indices', self.validate_indices)
|
|
2506
|
+
|
|
2507
|
+
validator.check_value_type("set_operation", set_operation, [str], self.name)
|
|
2508
|
+
validator.check_value_type("validate_indices", validate_indices, [bool], self.name)
|
|
2509
|
+
|
|
2510
|
+
|
|
2511
|
+
class RaggedTensorToTensor(Primitive):
|
|
2512
|
+
r"""
|
|
2513
|
+
Create a dense tensor from a ragged tensor, possibly altering its shape.
|
|
2514
|
+
|
|
2515
|
+
Args:
|
|
2516
|
+
row_partition_types(list(str)): A list of `strings`. The types of the row partition tensors.
|
|
2517
|
+
At present, these can be:
|
|
2518
|
+
"ROW_SPLITS": the row_splits tensor from the ragged tensor.
|
|
2519
|
+
"VALUE_ROWIDS": the value_rowids tensor from the ragged tensor.
|
|
2520
|
+
"FIRST_DIM_SIZE": if value_rowids is used for the first dimension, then it is preceded by "FIRST_DIM_SIZE".
|
|
2521
|
+
|
|
2522
|
+
Inputs:
|
|
2523
|
+
- **shape** (Tensor) - A 1-D `Tensor`. Must be one of the following types: `int64`, `int32`.
|
|
2524
|
+
The desired shape of the output tensor.
|
|
2525
|
+
- **values** (Tensor) - A 1-D or higher `Tensor` representing the values of the ragged tensor.
|
|
2526
|
+
- **default_value** (Tensor) - A `Tensor` representing the default value of the ragged tensor.
|
|
2527
|
+
Must have the same type as `values` and less dimension than `values`.
|
|
2528
|
+
- **row_partition_tensors** (list(Tensor)) - A list of at least 1 `Tensor` objects with the same
|
|
2529
|
+
type in: `int64`, `int32`. The row partition tensor is 0-D, 1-D, 1-D, when the row partition type is
|
|
2530
|
+
"FIRST_DIM_SIZE", "VALUE_ROWIDS", "ROW_SPLITS" respectively.
|
|
2531
|
+
|
|
2532
|
+
Outputs:
|
|
2533
|
+
A `Tensor`. Has the same type as `values` and the shape is `shape`.
|
|
2534
|
+
|
|
2535
|
+
Raises:
|
|
2536
|
+
TypeError: If the type of `shape`, `values` or `default_value` is not Tensor.
|
|
2537
|
+
ValueError: If the dimension of `shape` or `values` is not 1.
|
|
2538
|
+
ValueError: If the dimension of `default_value` is more than `values`.
|
|
2539
|
+
ValueError: If the order or value of `row_partition_types` is not support.
|
|
2540
|
+
RuntimeError: If the value of `row_partition_tensors` is not in ascending order
|
|
2541
|
+
when the `row_partition_types` is "ROW_SPLITS".
|
|
2542
|
+
RuntimeError: If value rowid is not less than first dim size
|
|
2543
|
+
when the `row_partition_types` is "FIRST_DIM_SIZE", "VALUE_ROWIDS".
|
|
2544
|
+
ValueError: If row partition size plus `values` rank is not equal to `shape` rank.
|
|
2545
|
+
|
|
2546
|
+
Supported Platforms:
|
|
2547
|
+
``CPU``
|
|
2548
|
+
|
|
2549
|
+
Examples:
|
|
2550
|
+
>>> from mindspore.ops.operations.sparse_ops import RaggedTensorToTensor
|
|
2551
|
+
>>> shape = Tensor([4, 4], mstype.int32)
|
|
2552
|
+
>>> values = Tensor([1, 2, 3, 4, 5, 6, 7, 8, 9], mstype.int64)
|
|
2553
|
+
>>> default_value = Tensor(0, dtype=mstype.int64)
|
|
2554
|
+
>>> row_partition_tensors_list = []
|
|
2555
|
+
>>> row_partition_tensors = Tensor([0, 3, 3, 7, 9], mstype.int32)
|
|
2556
|
+
>>> row_partition_tensors_list.append(row_partition_tensors)
|
|
2557
|
+
>>> row_partition_types = ["ROW_SPLITS"]
|
|
2558
|
+
>>> ragged_tensor_to_tensor = RaggedTensorToTensor(row_partition_types)
|
|
2559
|
+
>>> out = ragged_tensor_to_tensor(shape, values, default_value, row_partition_tensors_list)
|
|
2560
|
+
>>> print(out)
|
|
2561
|
+
[[1 2 3 0]
|
|
2562
|
+
[0 0 0 0]
|
|
2563
|
+
[4 5 6 7]
|
|
2564
|
+
[8 9 0 0]]
|
|
2565
|
+
"""
|
|
2566
|
+
|
|
2567
|
+
@prim_attr_register
|
|
2568
|
+
def __init__(self, row_partition_types):
|
|
2569
|
+
"""Initialize RaggedTensorToTensor"""
|
|
2570
|
+
self.init_prim_io_names(inputs=['shape', 'values', 'default_value', 'row_partition_tensors'],
|
|
2571
|
+
outputs=['result'])
|
|
2572
|
+
validator.check_value_type("row_partition_types", row_partition_types, [list], self.name)
|
|
2573
|
+
|
|
2574
|
+
if not row_partition_types:
|
|
2575
|
+
raise ValueError(f"For {self.name}, row_partition_types cannot be empty.")
|
|
2576
|
+
|
|
2577
|
+
for i, item in enumerate(row_partition_types):
|
|
2578
|
+
validator.check_value_type(f"row_partition_types[{i}]", item, [str], self.name)
|
|
2579
|
+
|
|
2580
|
+
valid_values = ("ROW_SPLITS", "FIRST_DIM_SIZE", "VALUE_ROWIDS")
|
|
2581
|
+
if not set(row_partition_types).issubset(valid_values):
|
|
2582
|
+
diff = tuple(set(row_partition_types).difference(valid_values))
|
|
2583
|
+
raise ValueError(
|
|
2584
|
+
f"For {self.name}, row_partition_types only support {valid_values}, "
|
|
2585
|
+
f"but got {diff if len(diff) > 1 else repr(diff[0])}.")
|
|
2586
|
+
|
|
2587
|
+
first_element = valid_values[:2]
|
|
2588
|
+
if row_partition_types[0] not in first_element:
|
|
2589
|
+
raise ValueError(
|
|
2590
|
+
f"For {self.name}, the first element of row_partition_types must be in {first_element}, "
|
|
2591
|
+
f"but got '{row_partition_types[0]}'.")
|
|
2592
|
+
|
|
2593
|
+
if row_partition_types[0] == "FIRST_DIM_SIZE":
|
|
2594
|
+
if set(row_partition_types[1:]) != {"VALUE_ROWIDS"}:
|
|
2595
|
+
raise ValueError(
|
|
2596
|
+
f"For {self.name}, 'VALUE_ROWIDS' must be preceded by 'FIRST_DIM_SIZE' in row_partition_types.")
|
|
2597
|
+
else:
|
|
2598
|
+
if set(row_partition_types) != {"ROW_SPLITS"}:
|
|
2599
|
+
raise ValueError(
|
|
2600
|
+
f"For {self.name}, the each element of row_partition_types must be 'ROW_SPLITS' "
|
|
2601
|
+
f"when row_splits tensor.")
|
|
2602
|
+
|
|
2603
|
+
|
|
2604
|
+
class SparseCross(Primitive):
|
|
2605
|
+
"""
|
|
2606
|
+
Generates sparse cross from a list of sparse and dense tensors.
|
|
2607
|
+
|
|
2608
|
+
Args:
|
|
2609
|
+
hashed_output (bool): If true, returns the hash of the cross instead of the string. This will allow us
|
|
2610
|
+
avoiding string manipulations.
|
|
2611
|
+
num_buckets (int): An int that is >= 0. It is used if "hashed_output" is true.output = hashed_value%num_buckets
|
|
2612
|
+
if num_buckets > 0 else "hashed_value".
|
|
2613
|
+
hash_key (int): Specify the hash_key that will be used by the "FingerprintCat64" function to combine the
|
|
2614
|
+
crosses fingerprints.
|
|
2615
|
+
out_type (mindspore.dtype): The output data type. Defaults to "int64".
|
|
2616
|
+
internal_type (mindspore.dtype): An type int64.
|
|
2617
|
+
|
|
2618
|
+
Inputs:
|
|
2619
|
+
- **indices** (list(Tensor)) - A list of Tensor objects with type int64. 2-D.
|
|
2620
|
+
Indices of each input SparseTensor.
|
|
2621
|
+
- **values** (list(Tensor)) - A list of Tensor objects with types from: int64.
|
|
2622
|
+
1-D. values of each SparseTensor.
|
|
2623
|
+
- **shapes** (list(Tensor)) - A list with the same length as indices of Tensor objects with type int64.
|
|
2624
|
+
1-D. Shapes of each SparseTensor.
|
|
2625
|
+
- **dense_inputs** (list(Tensor)) - A list of Tensor objects with types from: int64.
|
|
2626
|
+
2-D. Columns represented by dense Tensor.
|
|
2627
|
+
|
|
2628
|
+
Outputs:
|
|
2629
|
+
- **output_indices** (Tensor) - A Tensor of type int64. 2-D. Indices of the concatenated SparseTensor.
|
|
2630
|
+
- **output_values** (Tensor) - A Tensor of type "out_type". 1-D.
|
|
2631
|
+
Non-empty values of the concatenated or hashed SparseTensor.
|
|
2632
|
+
- **output_shape** (Tensor) - A Tensor of type int64. 1-D. Shape of the concatenated SparseTensor.
|
|
2633
|
+
|
|
2634
|
+
Raises:
|
|
2635
|
+
TypeError: The indices shape rank is not equal to the shape rank.
|
|
2636
|
+
TypeError: The indices element number is not equal to the value element number.
|
|
2637
|
+
TypeError: The indices shape rank should be 2.
|
|
2638
|
+
TypeError: The denses shape rank should be 2.
|
|
2639
|
+
TypeError: The shapes rank should be 2.
|
|
2640
|
+
|
|
2641
|
+
Supported Platforms:
|
|
2642
|
+
``CPU``
|
|
2643
|
+
|
|
2644
|
+
Examples:
|
|
2645
|
+
>>> from mindspore.ops.operations.sparse_ops import SparseCross
|
|
2646
|
+
>>> indice1 = Tensor([[0,0],[1,0],[1,1]], dtype=mstype.int64)
|
|
2647
|
+
>>> value1 = Tensor([1, 2, 3], dtype=mstype.int64)
|
|
2648
|
+
>>> shape1 = Tensor([2, 2], dtype=mstype.int64)
|
|
2649
|
+
>>> dense1 = Tensor([[1],[2]], dtype=mstype.int64)
|
|
2650
|
+
>>> indice2 = Tensor([[0,0],[1,0],[1,1]], dtype=mstype.int64)
|
|
2651
|
+
>>> value2 = Tensor([1, 2, 3], dtype=mstype.int64)
|
|
2652
|
+
>>> shape2 = Tensor([2, 2], dtype=mstype.int64)
|
|
2653
|
+
>>> dense2 = Tensor([[1],[2]], dtype=mstype.int64)
|
|
2654
|
+
>>> indices = [indice1, indice2]
|
|
2655
|
+
>>> values = [value1, value2]
|
|
2656
|
+
>>> shapes = [shape1, shape2]
|
|
2657
|
+
>>> dense_inputs = [dense1, dense2]
|
|
2658
|
+
>>> hashed_output=True
|
|
2659
|
+
>>> hash_key= 2
|
|
2660
|
+
>>> out_type= mstype.int64
|
|
2661
|
+
>>> internal_type = mstype.int64
|
|
2662
|
+
>>> num_buckets=0
|
|
2663
|
+
>>> sparse_cross = SparseCross(hashed_output, hash_key, out_type, internal_type, num_buckets)
|
|
2664
|
+
>>> out = sparse_cross(indices, values, shapes, dense_inputs)
|
|
2665
|
+
>>> print(out)
|
|
2666
|
+
(Tensor(shape=[5, 2], dtype=Int64, value=
|
|
2667
|
+
[[0, 0],
|
|
2668
|
+
[1, 0],
|
|
2669
|
+
[1, 1],
|
|
2670
|
+
[1, 2],
|
|
2671
|
+
[1, 3]]), Tensor(shape=[5], dtype=Int64, value= [1350190460805457680, 6319552725219729347,
|
|
2672
|
+
4652439303631496997, 7670687697825594049, 174086171018132662]), Tensor(shape=[2], dtype=Int64, value= [2, 4]))
|
|
2673
|
+
"""
|
|
2674
|
+
|
|
2675
|
+
@prim_attr_register
|
|
2676
|
+
def __init__(self, hashed_output, hash_key, out_type, internal_type, num_buckets=0):
|
|
2677
|
+
"""Initialize SparseCross."""
|
|
2678
|
+
self.init_prim_io_names(inputs=["indices", "values", "shapes", "dense_inputs"],
|
|
2679
|
+
outputs=["output_indices", "output_values", "output_shape"])
|
|
2680
|
+
validator.check_value_type("hashed_output", hashed_output, [bool], self.name)
|
|
2681
|
+
validator.check_value_type("hash_key", hash_key, [int], self.name)
|
|
2682
|
+
validator.check_value_type("out_type", out_type, [mstype.Type], self.name)
|
|
2683
|
+
validator.check_value_type("internal_type", internal_type, [mstype.Type], self.name)
|
|
2684
|
+
validator.check_value_type("num_buckets", num_buckets, [int], self.name)
|
|
2685
|
+
|
|
2686
|
+
|
|
2687
|
+
class RaggedTensorToSparse(Primitive):
|
|
2688
|
+
r"""
|
|
2689
|
+
Converts a RaggedTensor into a SparseTensor with the same values.
|
|
2690
|
+
|
|
2691
|
+
Args:
|
|
2692
|
+
Tsplits(mindspore.dtype): A required attribute, the type of the `rt_nested_splits`. Default: `int64`.
|
|
2693
|
+
|
|
2694
|
+
Inputs:
|
|
2695
|
+
- **rt_nested_splits** (list(Tensor)) - A list of at least 1 `Tensor` objects with the same
|
|
2696
|
+
type in: `int64`, `int32`. The row_splits for the RaggedTensor.
|
|
2697
|
+
Ragged splits is in ascending order, first value of splits must be 0 and final value of splits
|
|
2698
|
+
must equal with the length of `rt_dense_values`.
|
|
2699
|
+
- **rt_dense_values** (Tensor) - A `Tensor`. The flat_values for the RaggedTensor. The rank of values
|
|
2700
|
+
must more than 0.
|
|
2701
|
+
|
|
2702
|
+
Outputs:
|
|
2703
|
+
- **sparse_indices** (Tensor) - A `Tensor` of type int64. Contains the indices of the output
|
|
2704
|
+
sparse tensor.
|
|
2705
|
+
- **sparse_values** (Tensor) - A `Tensor`. Has the same type as rt_dense_values.
|
|
2706
|
+
Contains the values of the output sparse tensor.
|
|
2707
|
+
- **sparse_dense_shape** (Tensor) - A `Tensor` of type int64. Contains the dense shape of the
|
|
2708
|
+
output sparse tensor.
|
|
2709
|
+
|
|
2710
|
+
Raises:
|
|
2711
|
+
TypeError: If the type of `Tsplits`, `rt_nested_splits` or `rt_dense_values` is not support.
|
|
2712
|
+
RuntimeError: If the order of `rt_nested_splits` is not support.
|
|
2713
|
+
RuntimeError: If the first value of `rt_nested_splits` is not 0.
|
|
2714
|
+
RuntimeError: If the final value of `rt_nested_splits` is not equal with the length of
|
|
2715
|
+
`rt_dense_values`.
|
|
2716
|
+
ValueError: If the rank of `rt_dense_values` is not more than 0.
|
|
2717
|
+
|
|
2718
|
+
Supported Platforms:
|
|
2719
|
+
|
|
2720
|
+
|
|
2721
|
+
Examples:
|
|
2722
|
+
>>> from mindspore.ops.operations.sparse_ops import RaggedTensorToSparse
|
|
2723
|
+
>>> rt_nested_splits = Tensor([0, 3, 3, 5, 6], mstype.int64)
|
|
2724
|
+
>>> rt_dense_values = Tensor([1, 2, 3, 4, 5, 6], mstype.int32)
|
|
2725
|
+
>>> rt_nested_splits_list = []
|
|
2726
|
+
>>> rt_nested_splits_list.append(rt_nested_splits)
|
|
2727
|
+
>>> Tsplits = mstype.int64
|
|
2728
|
+
>>> ragged_tensor_to_sparse = RaggedTensorToSparse(Tsplits)
|
|
2729
|
+
>>> out = ragged_tensor_to_sparse(rt_nested_splits_list, rt_dense_values)
|
|
2730
|
+
>>> print(out)
|
|
2731
|
+
(Tensor(shape=[6, 2], dtype=Int64, value=
|
|
2732
|
+
[[0, 0],
|
|
2733
|
+
[0, 1],
|
|
2734
|
+
[0, 2],
|
|
2735
|
+
[2, 0],
|
|
2736
|
+
[2, 1],
|
|
2737
|
+
[3, 0]]),
|
|
2738
|
+
Tensor(shape=[6], dtype=Int32, value= [1, 2, 3, 4, 5, 6]),
|
|
2739
|
+
Tensor(shape=[2], dtype=Int64, value= [4, 3]))
|
|
2740
|
+
"""
|
|
2741
|
+
@prim_attr_register
|
|
2742
|
+
def __init__(self, Tsplits):
|
|
2743
|
+
"""Initialize RaggedTensorToSparse."""
|
|
2744
|
+
self.init_prim_io_names(inputs=['rt_nested_splits', 'rt_dense_values'],
|
|
2745
|
+
outputs=['sparse_indices', 'sparse_values', 'sparse_dense_shape'])
|
|
2746
|
+
validator.check_value_type("Tsplits", Tsplits, [mstype.Type], self.name)
|
|
2747
|
+
valid_values = {mstype.int64, mstype.int32}
|
|
2748
|
+
validator.check_type_name("Tsplits", Tsplits, valid_values, self.name)
|