mindspore 2.3.0__cp39-none-any.whl → 2.3.0rc2__cp39-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/Third_Party_Open_Source_Software_Notice +0 -1512
- mindspore/__init__.py +1 -2
- mindspore/_c_dataengine.cpython-39-aarch64-linux-gnu.so +0 -0
- mindspore/_c_expression.cpython-39-aarch64-linux-gnu.so +0 -0
- mindspore/_c_mindrecord.cpython-39-aarch64-linux-gnu.so +0 -0
- mindspore/_checkparam.py +25 -5
- mindspore/_extends/graph_kernel/model/graph_parallel.py +1 -1
- mindspore/_extends/parse/__init__.py +2 -2
- mindspore/_extends/parse/compile_config.py +0 -29
- mindspore/_extends/parse/namespace.py +2 -2
- mindspore/_extends/parse/parser.py +5 -21
- mindspore/_extends/parse/resources.py +7 -5
- mindspore/_extends/parse/standard_method.py +59 -40
- mindspore/_mindspore_offline_debug.cpython-39-aarch64-linux-gnu.so +0 -0
- mindspore/amp.py +5 -26
- mindspore/bin/cache_admin +0 -0
- mindspore/bin/cache_server +0 -0
- mindspore/boost/adasum.py +1 -1
- mindspore/boost/base.py +1 -1
- mindspore/boost/boost_cell_wrapper.py +1 -1
- mindspore/boost/grad_freeze.py +2 -2
- mindspore/boost/less_batch_normalization.py +6 -9
- mindspore/common/__init__.py +1 -8
- mindspore/common/_register_for_tensor.py +9 -8
- mindspore/common/api.py +65 -275
- mindspore/common/dtype.py +4 -8
- mindspore/common/dump.py +5 -2
- mindspore/common/jit_config.py +1 -1
- mindspore/common/lazy_inline.py +2 -14
- mindspore/common/parameter.py +15 -14
- mindspore/common/recompute.py +5 -20
- mindspore/common/sparse_tensor.py +6 -21
- mindspore/common/tensor.py +52 -100
- mindspore/communication/__init__.py +11 -6
- mindspore/communication/management.py +94 -92
- mindspore/context.py +18 -180
- mindspore/dataset/engine/datasets.py +46 -69
- mindspore/dataset/engine/datasets_user_defined.py +53 -72
- mindspore/dataset/engine/datasets_vision.py +2 -2
- mindspore/dataset/engine/queue.py +38 -56
- mindspore/dataset/engine/validators.py +5 -11
- mindspore/dataset/vision/__init__.py +5 -5
- mindspore/dataset/vision/c_transforms.py +5 -5
- mindspore/dataset/vision/py_transforms_util.py +1 -1
- mindspore/dataset/vision/transforms.py +46 -591
- mindspore/dataset/vision/utils.py +1 -121
- mindspore/dataset/vision/validators.py +3 -9
- mindspore/hal/__init__.py +1 -7
- mindspore/hal/device.py +1 -1
- mindspore/include/api/model.h +0 -3
- mindspore/include/dataset/vision.h +2 -54
- mindspore/include/mindapi/base/types.h +0 -1
- mindspore/lib/libdnnl.so.2 +0 -0
- mindspore/lib/libmindspore.so +0 -0
- mindspore/lib/libmindspore_backend.so +0 -0
- mindspore/lib/libmindspore_common.so +0 -0
- mindspore/lib/libmindspore_core.so +0 -0
- mindspore/lib/libmindspore_glog.so.0 +0 -0
- mindspore/lib/libmindspore_gpr.so.15 +0 -0
- mindspore/lib/libmindspore_grpc++.so.1 +0 -0
- mindspore/lib/libmindspore_grpc.so.15 +0 -0
- mindspore/lib/libmindspore_shared_lib.so +0 -0
- mindspore/lib/libmpi_adapter.so +0 -0
- mindspore/lib/libmpi_collective.so +0 -0
- mindspore/lib/libnnacl.so +0 -0
- mindspore/lib/libopencv_core.so.4.5 +0 -0
- mindspore/lib/libps_cache.so +0 -0
- mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/config/ascend310p/aic-ascend310p-ops-info.json +0 -35
- mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/custom_aicore_ops_impl/kv_cache_mgr.py +0 -2
- mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/vector_core/tbe/custom_aicore_ops_impl/kv_cache_mgr.py +0 -2
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_cpu_kernels.so +0 -0
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/config/cust_aicpu_kernel.json +0 -72
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_proto/libcust_op_proto.so +0 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_api/include/{aclnn_all_finite.h → aclnn_add_custom.h} +11 -9
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_api/include/aclnn_decoder_kv_cache.h +1 -1
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_api/include/aclnn_prompt_kv_cache.h +1 -1
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_api/lib/libcust_opapi.so +0 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/config/ascend310p/aic-ascend310p-ops-info.json +12 -184
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/config/ascend910/aic-ascend910-ops-info.json +15 -7
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/config/ascend910b/aic-ascend910b-ops-info.json +15 -7
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/add_custom.cpp +81 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/add_custom.py +134 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/decoder_kv_cache.py +31 -77
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/prompt_kv_cache.py +31 -77
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/op_tiling/lib/linux/aarch64/libcust_opmaster_rt2.0.so +0 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/op_tiling/liboptiling.so +0 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_proto/inc/op_proto.h +5 -4
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_proto/lib/linux/aarch64/libcust_opsproto_rt2.0.so +0 -0
- mindspore/lib/plugin/ascend/libascend_collective.so +0 -0
- mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
- mindspore/lib/plugin/ascend/libhccl_plugin.so +0 -0
- mindspore/lib/plugin/ascend/liblowlatency_collective.so +0 -0
- mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/bin/DeviceBin +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/bin/PkgInspect +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/bin/op_man +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/device/ascend910b/bin/ascend910b.bin +286 -275
- mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/host/libasdops_cann_host.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/host/libasdops_host.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/lib/libasdops.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/lib/libasdops_static.a +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/add/add_impl.h +0 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/apply_rotary_pos_emb_impl.h +0 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/asdop/asd_op_impl.h +0 -3
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/backend_param.h +0 -5
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/cast/cast_tiling.h +45 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/compare/compare_impl.h +0 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/flash_attention_score/flash_attention_score_impl.h +4 -8
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/flash_attention_score/flash_attention_score_tiling.h +4 -11
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/flash_attention_score/kernel/flash_attention_score_mix_hwsync.h +0 -18
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/internal_kernel.h +0 -6
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/internal_rtbackend.h +75 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul/kernel/matmul.h +5 -5
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul/matmul_impl.h +3 -18
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul_common/pp_matmul_common_tiling.h +5 -5
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul_common/pp_matmul_info.h +2 -2
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul_common/tiling_data.h +3 -36
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul_stridedslice/kernel/matmul_stridedslice_fusion.h +2 -2
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul_stridedslice/matmul_stridedslice_fusion_impl.h +4 -22
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/op_param.h +2 -16
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/paged_attention/kernel/paged_attention_mix_hwsync.h +3 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/paged_attention/paged_attention_impl.h +4 -5
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/paged_attention/paged_attention_tiling.h +4 -9
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/attention_param.h +2 -5
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/matmul_ext_param.h +0 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/matmul_qkv_param.h +4 -10
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/sub_param.h +12 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/rms_norm/rms_norm_impl.h +0 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/sub/sub_impl.h +0 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/tune_repo/matmul_table.h +1 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/backend.h +2 -10
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/elewise_utils.h +1 -5
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log.h +0 -1
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log_tiling.h +0 -17
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/math.h +7 -2
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libAdd_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libSub_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libadd_layernorm_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libadd_rms_norm_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libapply_rotary_pos_emb_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libcast_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libgelu_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libmatmul_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libmatmul_stridedslice_fusion_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libms_kernels_internal.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libnot_equal_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libreshape_and_cache_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/librms_norm_impl.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_bf16_bnsd_full_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_bf16_bnsd_tri_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_bf16_bsh_full_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_bf16_bsh_tri_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_fp16_bnsd_full_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_fp16_bnsd_tri_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_fp16_bsh_full_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_fp16_bsh_tri_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/paged_attention_bf16_bnsd_full_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/paged_attention_bf16_bsh_full_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/paged_attention_fp16_bnsd_full_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/paged_attention_fp16_bsh_full_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/lib/liblcal.so +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/lib/liblccl_wrapper.so +0 -0
- mindspore/lib/plugin/libmindspore_ascend.so.2 +0 -0
- mindspore/mindrecord/filewriter.py +2 -2
- mindspore/mint/__init__.py +40 -720
- mindspore/mint/nn/__init__.py +7 -89
- mindspore/mint/nn/functional.py +16 -165
- mindspore/mint/optim/adamw.py +16 -15
- mindspore/nn/__init__.py +2 -0
- mindspore/nn/cell.py +98 -97
- mindspore/nn/extend/basic.py +2 -2
- mindspore/nn/extend/embedding.py +1 -1
- mindspore/nn/extend/layer/normalization.py +5 -7
- mindspore/nn/generator.py +297 -0
- mindspore/nn/layer/activation.py +3 -4
- mindspore/nn/layer/basic.py +16 -79
- mindspore/nn/layer/conv.py +8 -17
- mindspore/nn/layer/embedding.py +4 -1
- mindspore/nn/layer/math.py +1 -1
- mindspore/nn/layer/normalization.py +1 -1
- mindspore/nn/layer/pooling.py +0 -5
- mindspore/nn/layer/rnn_cells.py +2 -2
- mindspore/nn/loss/loss.py +19 -19
- mindspore/nn/optim/adasum.py +1 -1
- mindspore/nn/optim/sgd.py +2 -3
- mindspore/nn/probability/distribution/exponential.py +1 -1
- mindspore/nn/probability/distribution/geometric.py +1 -1
- mindspore/nn/probability/distribution/logistic.py +1 -1
- mindspore/nn/wrap/cell_wrapper.py +1 -25
- mindspore/nn/wrap/loss_scale.py +1 -24
- mindspore/numpy/array_ops.py +1 -5
- mindspore/numpy/dtypes.py +3 -3
- mindspore/numpy/math_ops.py +8 -8
- mindspore/ops/__init__.py +1 -1
- mindspore/ops/_grad_experimental/grad_comm_ops.py +16 -75
- mindspore/ops/_vmap/vmap_array_ops.py +0 -27
- mindspore/ops/_vmap/vmap_math_ops.py +1 -29
- mindspore/ops/_vmap/vmap_nn_ops.py +18 -19
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +8 -34
- mindspore/ops/auto_generate/gen_arg_dtype_cast.py +9 -2
- mindspore/ops/auto_generate/gen_arg_handler.py +0 -26
- mindspore/ops/auto_generate/gen_extend_func.py +27 -603
- mindspore/ops/auto_generate/gen_ops_def.py +203 -993
- mindspore/ops/auto_generate/gen_ops_prim.py +402 -1946
- mindspore/ops/auto_generate/pyboost_inner_prim.py +20 -90
- mindspore/ops/composite/base.py +6 -3
- mindspore/ops/composite/math_ops.py +1 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +17 -24
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
- mindspore/ops/extend/__init__.py +3 -2
- mindspore/ops/extend/array_func.py +51 -10
- mindspore/ops/extend/nn_func.py +78 -2
- mindspore/ops/function/__init__.py +13 -8
- mindspore/ops/function/array_func.py +179 -455
- mindspore/ops/function/clip_func.py +1 -1
- mindspore/ops/function/grad/grad_func.py +3 -3
- mindspore/ops/function/math_func.py +103 -117
- mindspore/ops/function/nn_func.py +163 -275
- mindspore/ops/function/other_func.py +2 -2
- mindspore/ops/function/random_func.py +69 -202
- mindspore/ops/function/sparse_func.py +4 -4
- mindspore/ops/functional.py +327 -332
- mindspore/ops/operations/__init__.py +3 -13
- mindspore/ops/operations/_grad_ops.py +27 -3
- mindspore/ops/operations/_inner_ops.py +356 -53
- mindspore/ops/operations/_rl_inner_ops.py +2 -2
- mindspore/ops/operations/_tensor_array.py +8 -8
- mindspore/ops/operations/array_ops.py +65 -82
- mindspore/ops/operations/comm_ops.py +93 -784
- mindspore/ops/operations/custom_ops.py +28 -51
- mindspore/ops/operations/debug_ops.py +4 -4
- mindspore/ops/operations/inner_ops.py +2 -2
- mindspore/ops/operations/manually_defined/ops_def.py +4 -304
- mindspore/ops/operations/math_ops.py +50 -3
- mindspore/ops/operations/nn_ops.py +247 -14
- mindspore/ops/operations/other_ops.py +3 -3
- mindspore/ops/operations/random_ops.py +1 -1
- mindspore/ops/operations/sparse_ops.py +1 -1
- mindspore/ops/primitive.py +8 -9
- mindspore/ops/silent_check.py +5 -5
- mindspore/ops_generate/arg_dtype_cast.py +9 -2
- mindspore/ops_generate/arg_handler.py +0 -26
- mindspore/ops_generate/gen_aclnn_implement.py +4 -1
- mindspore/ops_generate/gen_ops.py +4 -26
- mindspore/ops_generate/gen_pyboost_func.py +12 -41
- mindspore/ops_generate/gen_utils.py +0 -21
- mindspore/ops_generate/pyboost_utils.py +2 -7
- mindspore/ops_generate/template.py +0 -1
- mindspore/parallel/_auto_parallel_context.py +1 -21
- mindspore/parallel/_tensor.py +5 -0
- mindspore/parallel/_transformer/transformer.py +1 -1
- mindspore/parallel/_utils.py +1 -15
- mindspore/parallel/algo_parameter_config.py +3 -1
- mindspore/parallel/checkpoint_transform.py +9 -12
- mindspore/parallel/cluster/process_entity/_api.py +29 -28
- mindspore/parallel/cluster/process_entity/_utils.py +3 -13
- mindspore/parallel/cluster/run.py +16 -13
- mindspore/parallel/parameter_broadcast.py +2 -2
- mindspore/parallel/shard.py +17 -31
- mindspore/profiler/__init__.py +2 -3
- mindspore/profiler/common/util.py +2 -107
- mindspore/profiler/envprofiling.py +1 -1
- mindspore/profiler/parser/ascend_analysis/constant.py +21 -8
- mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -82
- mindspore/profiler/parser/ascend_analysis/function_event.py +28 -43
- mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +27 -49
- mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +10 -15
- mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +20 -25
- mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +5 -5
- mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +1 -10
- mindspore/profiler/parser/ascend_hccl_generator.py +1 -4
- mindspore/profiler/parser/ascend_msprof_exporter.py +22 -43
- mindspore/profiler/parser/ascend_timeline_generator.py +5 -7
- mindspore/profiler/parser/minddata_parser.py +3 -72
- mindspore/profiler/profiling.py +59 -176
- mindspore/rewrite/api/node.py +1 -1
- mindspore/rewrite/common/namespace.py +5 -5
- mindspore/rewrite/parsers/assign_parser.py +0 -2
- mindspore/rewrite/parsers/class_def_parser.py +4 -8
- mindspore/run_check/_check_version.py +1 -1
- mindspore/scipy/fft.py +3 -1
- mindspore/scipy/linalg.py +3 -2
- mindspore/scipy/ops.py +3 -5
- mindspore/scipy/optimize/__init__.py +2 -2
- mindspore/train/__init__.py +4 -4
- mindspore/train/anf_ir_pb2.py +2 -8
- mindspore/train/callback/__init__.py +2 -5
- mindspore/train/callback/_backup_and_restore.py +2 -2
- mindspore/train/callback/_checkpoint.py +16 -104
- mindspore/train/callback/_landscape.py +1 -1
- mindspore/train/callback/_time_monitor.py +1 -1
- mindspore/train/data_sink.py +4 -5
- mindspore/train/dataset_helper.py +20 -45
- mindspore/train/model.py +38 -266
- mindspore/train/serialization.py +105 -256
- mindspore/train/summary/_summary_adapter.py +1 -1
- mindspore/version.py +1 -1
- {mindspore-2.3.0.dist-info → mindspore-2.3.0rc2.dist-info}/METADATA +2 -2
- {mindspore-2.3.0.dist-info → mindspore-2.3.0rc2.dist-info}/RECORD +303 -420
- mindspore/_extends/pijit/__init__.py +0 -23
- mindspore/_extends/pijit/pijit_func_white_list.py +0 -343
- mindspore/common/file_system.py +0 -48
- mindspore/common/generator.py +0 -260
- mindspore/common/no_inline.py +0 -54
- mindspore/common/np_dtype.py +0 -25
- mindspore/communication/comm_func.py +0 -1140
- mindspore/hal/memory.py +0 -326
- mindspore/lib/libavcodec.so.59 +0 -0
- mindspore/lib/libavdevice.so.59 +0 -0
- mindspore/lib/libavfilter.so.8 +0 -0
- mindspore/lib/libavformat.so.59 +0 -0
- mindspore/lib/libavutil.so.57 +0 -0
- mindspore/lib/libmindspore_np_dtype.so +0 -0
- mindspore/lib/libswresample.so.4 +0 -0
- mindspore/lib/libswscale.so.6 +0 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/all_finite.cpp +0 -326
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/all_finite.py +0 -180
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel/ascend910b/all_finite/AllFinite_576ceaeef5870c451cab59af55ea46ad.json +0 -58
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel/ascend910b/all_finite/AllFinite_576ceaeef5870c451cab59af55ea46ad.o +0 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel/ascend910b/all_finite/AllFinite_86a73ff6e28d734c96bb8d3054f7dd18.json +0 -58
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel/ascend910b/all_finite/AllFinite_86a73ff6e28d734c96bb8d3054f7dd18.o +0 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel/ascend910b/all_finite/AllFinite_f55e0ebaad1f2f572e43677336992fa0.json +0 -58
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel/ascend910b/all_finite/AllFinite_f55e0ebaad1f2f572e43677336992fa0.o +0 -0
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel/config/ascend910b/all_finite.json +0 -109
- mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel/config/ascend910b/binary_info_config.json +0 -38
- mindspore/lib/plugin/ascend/custom_compiler/OWNERS +0 -12
- mindspore/lib/plugin/ascend/custom_compiler/setup.py +0 -255
- mindspore/lib/plugin/ascend/custom_compiler/start.sh +0 -26
- mindspore/lib/plugin/ascend/custom_compiler/template.json +0 -40
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/acme.h +0 -24
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/acme_op.h +0 -69
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/base_type.h +0 -133
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/op_creator.h +0 -32
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/op_param.h +0 -35
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/tiling_info.h +0 -60
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/core/kernel_register.h +0 -37
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/core/platform/platform_configs.h +0 -89
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/core/platform/rt_funcs.h +0 -135
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/add_op.h +0 -34
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/asd_backoff_base.h +0 -62
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/asd_elewise_op.h +0 -33
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/asd_ops.h +0 -88
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/asd_pa_op.h +0 -45
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/cast_op.h +0 -52
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/matmul_op.h +0 -95
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/utils/asd_utils.h +0 -84
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/utils/comm_utils.h +0 -61
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_fp32.h +0 -224
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/and_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/div_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/elewise_binary_impl.h +0 -48
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/elewise_binary_tiling.h +0 -25
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/and_kernel.h +0 -46
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/div_kernel.h +0 -46
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/elewise_binary_base.h +0 -260
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/elewise_binary_kernel.h +0 -35
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/max_kernel.h +0 -66
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/min_kernel.h +0 -66
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/mul_kernel.h +0 -66
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/or_kernel.h +0 -46
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/max_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/min_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/mul_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/or_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/abs_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/elewise_unary_impl.h +0 -47
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/elewise_unary_tiling.h +0 -24
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/exp_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/abs_kernel.h +0 -45
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/elewise_unary_base.h +0 -148
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/elewise_unary_kernel.h +0 -31
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/exp_kernel.h +0 -45
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/ln_kernel.h +0 -45
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/not_kernel.h +0 -45
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/reciprocal_kernel.h +0 -45
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/relu_kernel.h +0 -55
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/rsqrt_kernel.h +0 -45
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/sqrt_kernel.h +0 -45
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/ln_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/not_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/reciprocal_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/relu_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/rsqrt_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/sqrt_impl.h +0 -29
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/grouped_matmul/grouped_matmul_impl.h +0 -45
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/grouped_matmul/grouped_matmul_tiling.h +0 -187
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/grouped_matmul/kernel/grouped_matmul.h +0 -245
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/grouped_matmul/kernel/grouped_matmul_interface.h +0 -24
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/grouped_matmul/kernel/grouped_matmul_utils.h +0 -111
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/grouped_matmul/tiling_data.h +0 -54
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/compare_param.h +0 -31
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/elewise_param.h +0 -41
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/grouped_matmul_param.h +0 -40
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/profiling_util.h +0 -364
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log_utils.h +0 -69
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/register/kernel_creator.h +0 -39
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/register/kernel_registry.h +0 -114
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/utils.h +0 -98
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/MatMulPostFusionMixTactic/matmul_postfusion_mix.json +0 -19
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/MatMulPostFusionMixTactic/matmul_postfusion_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/MatMulPostFusionMixTactic/matmul_postfusion_mix_mix_aic_0.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/MatMulPostFusionMixTactic/matmul_postfusion_mix_mix_aiv_0.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/MultiMatMulPostFusionMixTactic/multi_matmul_postfusion_mix.json +0 -19
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/MultiMatMulPostFusionMixTactic/multi_matmul_postfusion_mix.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/MultiMatMulPostFusionMixTactic/multi_matmul_postfusion_mix_mix_aic_0.o +0 -0
- mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/MultiMatMulPostFusionMixTactic/multi_matmul_postfusion_mix_mix_aiv_0.o +0 -0
- mindspore/mint/linalg/__init__.py +0 -22
- mindspore/nn/layer/embedding_service.py +0 -531
- mindspore/nn/layer/embedding_service_layer.py +0 -393
- mindspore/ops/function/reshard_func.py +0 -102
- mindspore/ops/operations/_infer_ops.py +0 -19
- mindspore/ops/operations/reshard_ops.py +0 -53
- mindspore/profiler/common/process_pool.py +0 -41
- mindspore/profiler/common/singleton.py +0 -28
- mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
- mindspore/profiler/parser/ascend_memory_generator.py +0 -185
- mindspore/train/callback/_cluster_monitor.py +0 -201
- mindspore/train/callback/_flops_collector.py +0 -238
- mindspore/train/callback/_mindio_ttp.py +0 -443
- {mindspore-2.3.0.dist-info → mindspore-2.3.0rc2.dist-info}/WHEEL +0 -0
- {mindspore-2.3.0.dist-info → mindspore-2.3.0rc2.dist-info}/entry_points.txt +0 -0
- {mindspore-2.3.0.dist-info → mindspore-2.3.0rc2.dist-info}/top_level.txt +0 -0
|
@@ -43,7 +43,7 @@ def add(input, other, alpha=1):
|
|
|
43
43
|
alpha (number.Number): A scaling factor applied to `other`, default 1.
|
|
44
44
|
|
|
45
45
|
Returns:
|
|
46
|
-
Tensor
|
|
46
|
+
Tensor, the shape is the same as the one of the input `input`, `other` after broadcasting,
|
|
47
47
|
and the data type is the one with higher precision or higher digits among the two inputs and alpha.
|
|
48
48
|
|
|
49
49
|
Raises:
|
|
@@ -58,11 +58,11 @@ def add(input, other, alpha=1):
|
|
|
58
58
|
>>> import numpy as np
|
|
59
59
|
>>> import mindspore
|
|
60
60
|
>>> from mindspore import Tensor
|
|
61
|
-
>>> from mindspore import
|
|
61
|
+
>>> from mindspore.ops.extend import add
|
|
62
62
|
>>> x = Tensor(1, mindspore.int32)
|
|
63
63
|
>>> y = Tensor(np.array([4, 5, 6]).astype(np.float32))
|
|
64
64
|
>>> alpha = 0.5
|
|
65
|
-
>>> output =
|
|
65
|
+
>>> output = add(x, y, alpha)
|
|
66
66
|
>>> print(output)
|
|
67
67
|
[3. 3.5 4.]
|
|
68
68
|
>>> # the data type of x is int32, the data type of y is float32,
|
|
@@ -73,98 +73,24 @@ def add(input, other, alpha=1):
|
|
|
73
73
|
return add_impl(input, other, alpha)
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
def argmax(input, dim=None, keepdim=False):
|
|
77
|
-
r"""
|
|
78
|
-
Return the indices of the maximum values of a tensor across a dimension.
|
|
79
|
-
|
|
80
|
-
Args:
|
|
81
|
-
input (Tensor): Input tensor.
|
|
82
|
-
dim (Union[int, None], optional): The dimension to reduce. If `dim` is ``None`` , the indices of the maximum
|
|
83
|
-
value within the flattened input will be returned. Default: ``None`` .
|
|
84
|
-
keepdim (bool, optional): Whether the output tensor retains the specified
|
|
85
|
-
dimension. Ignored if `dim` is None. Default: ``False`` .
|
|
86
|
-
|
|
87
|
-
Returns:
|
|
88
|
-
Tensor, indices of the maximum values across a dimension.
|
|
89
|
-
|
|
90
|
-
Raises:
|
|
91
|
-
TypeError: If `keepdim` is not bool.
|
|
92
|
-
ValueError: If `dim` is out of range.
|
|
93
|
-
|
|
94
|
-
Supported Platforms:
|
|
95
|
-
``Ascend``
|
|
96
|
-
|
|
97
|
-
Examples:
|
|
98
|
-
>>> import numpy as np
|
|
99
|
-
>>> from mindspore import Tensor
|
|
100
|
-
>>> from mindspore import ops
|
|
101
|
-
>>> x = Tensor(np.array([[1, 20, 5], [67, 8, 9], [130, 24, 15]]).astype(np.float32))
|
|
102
|
-
>>> output = ops.auto_generate.argmax_ext(x, dim=-1)
|
|
103
|
-
>>> print(output)
|
|
104
|
-
[1 0 0]
|
|
105
|
-
"""
|
|
106
|
-
return argmax_impl(input, dim, keepdim)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def atan2(input, other):
|
|
110
|
-
r"""
|
|
111
|
-
Returns arctangent of input/other element-wise.
|
|
112
|
-
|
|
113
|
-
It returns :math:`\theta\ \in\ [-\pi, \pi]`
|
|
114
|
-
such that :math:`input = r*\sin(\theta), other = r*\cos(\theta)`, where :math:`r = \sqrt{input^2 + other^2}`.
|
|
115
|
-
|
|
116
|
-
Note:
|
|
117
|
-
- Arg `input` and `other` comply with the implicit type conversion rules to make the data types consistent.
|
|
118
|
-
If they have different data types, the lower precision data type will be converted to relatively the
|
|
119
|
-
highest precision data type.
|
|
120
|
-
|
|
121
|
-
Args:
|
|
122
|
-
input (Tensor, Number.number): The input tensor or scalar.
|
|
123
|
-
other (Tensor, Number.number): The input tensor or scalar. It has the same shape with `input` or
|
|
124
|
-
its shape is able to broadcast with `input`.
|
|
125
|
-
|
|
126
|
-
Returns:
|
|
127
|
-
Tensor, the shape is the same as the one after broadcasting, and the data type is same as `input`.
|
|
128
|
-
|
|
129
|
-
Raises:
|
|
130
|
-
TypeError: If `input` or `other` is not a Tensor or scalar.
|
|
131
|
-
RuntimeError: If the data type of `input` and `other` conversion of Parameter is required
|
|
132
|
-
when data type conversion of Parameter is not supported.
|
|
133
|
-
|
|
134
|
-
Supported Platforms:
|
|
135
|
-
``Ascend``
|
|
136
|
-
|
|
137
|
-
Examples:
|
|
138
|
-
>>> import mindspore
|
|
139
|
-
>>> import numpy as np
|
|
140
|
-
>>> from mindspore import Tensor, ops
|
|
141
|
-
>>> input = Tensor(np.array([0, 1]), mindspore.float32)
|
|
142
|
-
>>> other = Tensor(np.array([1, 1]), mindspore.float32)
|
|
143
|
-
>>> output = mint.atan2(input, other)
|
|
144
|
-
>>> print(output)
|
|
145
|
-
[0. 0.7853982]
|
|
146
|
-
"""
|
|
147
|
-
return atan2_impl(input, other)
|
|
148
|
-
|
|
149
|
-
|
|
150
76
|
def bmm(input, mat2):
|
|
151
77
|
r"""
|
|
152
78
|
Performs batch matrix-matrix multiplication of two three-dimensional tensors.
|
|
153
79
|
|
|
154
80
|
.. math::
|
|
155
|
-
\text{output}= \text{input} @ \text{mat2}
|
|
81
|
+
\text{output}[b, i, j] = \text{input}[b, i, k] @ \text{mat2}[b, k, j]
|
|
156
82
|
|
|
157
83
|
Args:
|
|
158
|
-
input (Tensor): The first batch of matrices to be multiplied. Must be a three-dimensional tensor
|
|
159
|
-
mat2 (Tensor): The second batch of matrices to be multiplied. Must be a three-dimensional tensor
|
|
84
|
+
input (Tensor): The first batch of matrices to be multiplied. Must be a three-dimensional tensor.
|
|
85
|
+
mat2 (Tensor): The second batch of matrices to be multiplied. Must be a three-dimensional tensor.
|
|
160
86
|
|
|
161
87
|
Returns:
|
|
162
88
|
Tensor, the output tensor of shape `(b, n, p)`, where each matrix is the product of the corresponding matrices in the input batches.
|
|
163
89
|
|
|
164
90
|
Raises:
|
|
165
|
-
|
|
91
|
+
TypeError: If `input` or `mat2` is not three-dimensional tensors.
|
|
166
92
|
ValueError: If the length of the third dimension of `input` is not equal to the length of the second dimension of `mat2`.
|
|
167
|
-
ValueError: If the batch size of the inputs
|
|
93
|
+
ValueError: If the batch size of the inputs do not match.
|
|
168
94
|
|
|
169
95
|
Supported Platforms:
|
|
170
96
|
``Ascend`` ``GPU`` ``CPU``
|
|
@@ -173,183 +99,14 @@ def bmm(input, mat2):
|
|
|
173
99
|
>>> import mindspore
|
|
174
100
|
>>> import numpy as np
|
|
175
101
|
>>> from mindspore import Tensor
|
|
176
|
-
>>> from mindspore import
|
|
102
|
+
>>> from mindspore.ops.extend import bmm
|
|
177
103
|
>>> a = Tensor(np.ones(shape=[2, 3, 4]), mindspore.float32)
|
|
178
104
|
>>> b = Tensor(np.ones(shape=[2, 4, 5]), mindspore.float32)
|
|
179
|
-
>>> output =
|
|
180
|
-
>>> print(output)
|
|
181
|
-
[[[4. 4. 4. 4. 4.]
|
|
182
|
-
[4. 4. 4. 4. 4.]
|
|
183
|
-
[4. 4. 4. 4. 4.]]
|
|
184
|
-
[[4. 4. 4. 4. 4.]
|
|
185
|
-
[4. 4. 4. 4. 4.]
|
|
186
|
-
[4. 4. 4. 4. 4.]]]
|
|
187
|
-
"""
|
|
188
|
-
return bmm_impl(input, mat2)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
def fold(input, output_size, kernel_size, dilation=1, padding=0, stride=1):
|
|
192
|
-
r"""
|
|
193
|
-
Combines an array of sliding local blocks into a large containing tensor.
|
|
194
|
-
|
|
195
|
-
Consider a batched input tensor of shape :math:`(N, C \times \prod(\text{kernel_size}), L)` ,
|
|
196
|
-
where :math:`N` is the batch dimension, :math:`C \times \prod(\text{kernel_size})` is the
|
|
197
|
-
total number of values within each block (a block has :math:`\prod(\text{kernel_size})` spatial
|
|
198
|
-
locations each containing a `C`-channeled vector), and :math:`L` is the total number of such blocks:
|
|
199
|
-
|
|
200
|
-
.. math::
|
|
201
|
-
L = \prod_d \left\lfloor\frac{\text{output_size}[d] + 2 \times \text{padding}[d] %
|
|
202
|
-
- \text{dilation}[d] \times (\text{kernel_size}[d] - 1) - 1}{\text{stride}[d]} + 1\right\rfloor,
|
|
203
|
-
|
|
204
|
-
where :math:`d` is over all spatial dimensions.
|
|
205
|
-
|
|
206
|
-
Therefore, `output_size` is the spatial shape of the large containing tensor of the sliding local blocks.
|
|
207
|
-
|
|
208
|
-
The `dilation`, `padding` and `stride` arguments specify how the sliding blocks are retrieved.
|
|
209
|
-
|
|
210
|
-
.. warning::
|
|
211
|
-
Currently, only unbatched(3D) or batched(4D) image-like output tensors are supported.
|
|
212
|
-
|
|
213
|
-
Args:
|
|
214
|
-
input (Tensor): 2-D or 3-D Tensor.
|
|
215
|
-
output_size (Union[int, tuple[int], list[int]]): The shape of the spatial dimensions of
|
|
216
|
-
the output(i.e., output.shape[2:]).
|
|
217
|
-
kernel_size (Union[int, tuple[int], list[int]]): The size of the kernel, should be two int
|
|
218
|
-
for height and width. If type is int, it means that height equal with width. Must be specified.
|
|
219
|
-
dilation (Union[int, tuple[int], list[int]], optional): The size of the dilation, should be two int
|
|
220
|
-
for height and width. If type is int, it means that height equal with width. Default: ``1`` .
|
|
221
|
-
padding (Union[int, tuple[int], list[int]], optional): The size of the padding, should be two int
|
|
222
|
-
for height and width. If type is int, it means that height equal with width. Default: ``0`` .
|
|
223
|
-
stride (Union[int, tuple[int], list[int]], optional): The size of the stride, should be two int
|
|
224
|
-
for height and width. If type is int, it means that height equal with width. Default: ``1`` .
|
|
225
|
-
|
|
226
|
-
Returns:
|
|
227
|
-
A Tensor, with same type as `input` .
|
|
228
|
-
|
|
229
|
-
Shape:
|
|
230
|
-
- Input: :math:`(N, C \times \prod(\text{kernel_size}), L)` or
|
|
231
|
-
:math:`(C \times \prod(\text{kernel_size}), L)`
|
|
232
|
-
- Output: :math:`(N, C, output\_size[0], output\_size[1], ...)` or
|
|
233
|
-
:math:`(C, output\_size[0], output\_size[1], ...)`
|
|
234
|
-
|
|
235
|
-
Raises:
|
|
236
|
-
TypeError: If `output_size`, `kernel_size`, `stride`, `dilation`, `padding` data type is not int, tuple or list.
|
|
237
|
-
ValueError: If `output_size`, `kernel_size`, `dilation`, `stride` value is not
|
|
238
|
-
greater than zero or elements number invalid.
|
|
239
|
-
ValueError: If `padding` value is less than zero or elements number invalid.
|
|
240
|
-
ValueError: If input.shape[-2] can't be divisible by the product of kernel_size.
|
|
241
|
-
ValueError: If `input.shape[-1]` is not equal to the calculated number of sliding blocks `L`.
|
|
242
|
-
|
|
243
|
-
Supported Platforms:
|
|
244
|
-
``Ascend``
|
|
245
|
-
|
|
246
|
-
Examples:
|
|
247
|
-
>>> import numpy as np
|
|
248
|
-
>>> from mindspore import Tensor, ops
|
|
249
|
-
>>> x = Tensor(np.random.rand(16, 64, 25).astype(np.float32))
|
|
250
|
-
>>> output = ops.auto_generate.fold_ext(x, (8, 8), [2, 2], [2, 2], [2, 2], [2, 2])
|
|
105
|
+
>>> output = bmm(a, b)
|
|
251
106
|
>>> print(output.shape)
|
|
252
|
-
(
|
|
253
|
-
"""
|
|
254
|
-
return fold_impl(input, converted_output_size, converted_kernel_size, converted_dilation, converted_padding, converted_stride)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
def cumsum(input, dim, dtype=None):
|
|
258
|
-
r"""
|
|
259
|
-
Computes the cumulative sum of input Tensor along `dim`.
|
|
260
|
-
|
|
261
|
-
.. math::
|
|
262
|
-
|
|
263
|
-
y_i = x_1 + x_2 + x_3 + ... + x_i
|
|
264
|
-
|
|
265
|
-
Args:
|
|
266
|
-
input (Tensor): The input Tensor.
|
|
267
|
-
dim (int): Dim along which the cumulative sum is computed.
|
|
268
|
-
dtype (:class:`mindspore.dtype`, optional): The desired dtype of returned Tensor. If specified,
|
|
269
|
-
the input Tensor will be cast to `dtype` before the computation. This is useful for preventing overflows.
|
|
270
|
-
If not specified, stay the same as original Tensor. Default: ``None`` .
|
|
271
|
-
|
|
272
|
-
Returns:
|
|
273
|
-
Tensor, the shape of the output Tensor is consistent with the input Tensor's.
|
|
274
|
-
|
|
275
|
-
Raises:
|
|
276
|
-
TypeError: If `input` is not a Tensor.
|
|
277
|
-
ValueError: If the `dim` is out of range.
|
|
278
|
-
|
|
279
|
-
Supported Platforms:
|
|
280
|
-
``Ascend``
|
|
281
|
-
|
|
282
|
-
Examples:
|
|
283
|
-
>>> import numpy as np
|
|
284
|
-
>>> from mindspore import Tensor
|
|
285
|
-
>>> import mindspore.ops as ops
|
|
286
|
-
>>> x = Tensor(np.array([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7], [1, 3, 7, 9]]).astype(np.float32))
|
|
287
|
-
>>> # case 1: along the dim 0
|
|
288
|
-
>>> y = ops.auto_generate.cumsum_ext(x, 0)
|
|
289
|
-
>>> print(y)
|
|
290
|
-
[[ 3. 4. 6. 10.]
|
|
291
|
-
[ 4. 10. 13. 19.]
|
|
292
|
-
[ 8. 13. 21. 26.]
|
|
293
|
-
[ 9. 16. 28. 35.]]
|
|
294
|
-
>>> # case 2: along the dim 1
|
|
295
|
-
>>> y = ops.auto_generate.cumsum_ext(x, 1)
|
|
296
|
-
>>> print(y)
|
|
297
|
-
[[ 3. 7. 13. 23.]
|
|
298
|
-
[ 1. 7. 14. 23.]
|
|
299
|
-
[ 4. 7. 15. 22.]
|
|
300
|
-
[ 1. 4. 11. 20.]]
|
|
301
|
-
"""
|
|
302
|
-
return cumsum_impl(input, dim, dtype)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
def elu(input, alpha=1.0):
|
|
306
|
-
r"""
|
|
307
|
-
Exponential Linear Unit activation function.
|
|
308
|
-
|
|
309
|
-
Applies the exponential linear unit function element-wise.
|
|
310
|
-
The activation function is defined as:
|
|
311
|
-
|
|
312
|
-
.. math::
|
|
313
|
-
|
|
314
|
-
\text{ELU}(x)= \left\{
|
|
315
|
-
\begin{array}{align}
|
|
316
|
-
\alpha(e^{x} - 1) & \text{if } x \le 0\\
|
|
317
|
-
x & \text{if } x \gt 0\\
|
|
318
|
-
\end{array}\right.
|
|
319
|
-
|
|
320
|
-
Where :math:`x` is the element of input Tensor `input`, :math:`\alpha` is param `alpha`,
|
|
321
|
-
it determines the smoothness of ELU.
|
|
322
|
-
|
|
323
|
-
ELU function graph:
|
|
324
|
-
|
|
325
|
-
.. image:: ../images/ELU.png
|
|
326
|
-
:align: center
|
|
327
|
-
|
|
328
|
-
Args:
|
|
329
|
-
input (Tensor): The input of ELU is a Tensor of any dimension.
|
|
330
|
-
alpha (float, optional): The alpha value of ELU, the data type is float.
|
|
331
|
-
Default: ``1.0`` .
|
|
332
|
-
|
|
333
|
-
Returns:
|
|
334
|
-
Tensor, has the same shape and data type as `input`.
|
|
335
|
-
|
|
336
|
-
Raises:
|
|
337
|
-
TypeError: If `alpha` is not a float.
|
|
338
|
-
|
|
339
|
-
Supported Platforms:
|
|
340
|
-
``Ascend``
|
|
341
|
-
|
|
342
|
-
Examples:
|
|
343
|
-
>>> import mindspore
|
|
344
|
-
>>> import numpy as np
|
|
345
|
-
>>> from mindspore import Tensor, ops
|
|
346
|
-
>>> x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
|
|
347
|
-
>>> output = ops.auto_generate.elu_ext(x)
|
|
348
|
-
>>> print(output)
|
|
349
|
-
[[-0.63212055 4. -0.99966455]
|
|
350
|
-
[ 2. -0.99326205 9. ]]
|
|
107
|
+
(2, 3, 5)
|
|
351
108
|
"""
|
|
352
|
-
return
|
|
109
|
+
return bmm_impl(input, mat2)
|
|
353
110
|
|
|
354
111
|
|
|
355
112
|
def ffn(x, weight1, weight2, expertTokens=None, bias1=None, bias2=None, scale=None, offset=None, deqScale1=None, deqScale2=None, antiquant_scale1=None, antiquant_scale2=None, antiquant_offset1=None, antiquant_offset2=None, activation='fastgelu', inner_precise=0):
|
|
@@ -395,124 +152,6 @@ def flatten(input, start_dim=0, end_dim=-1):
|
|
|
395
152
|
return flatten_impl(input, start_dim, end_dim)
|
|
396
153
|
|
|
397
154
|
|
|
398
|
-
def unfold(input, kernel_size, dilation=1, padding=0, stride=1):
|
|
399
|
-
r"""
|
|
400
|
-
Extracts sliding local blocks from a batched input tensor.
|
|
401
|
-
|
|
402
|
-
Consider a batched input tensor of shape :math:`(N, C, *)`,
|
|
403
|
-
where :math:`N` is the batch dimension, :math:`C` is the channel dimension,
|
|
404
|
-
and :math:`*` represent arbitrary spatial dimensions. This operation flattens
|
|
405
|
-
each sliding `Kernel_size`- sized block within the spatial dimensions
|
|
406
|
-
of `input` into a column (i.e., last dimension) of a 3-D output
|
|
407
|
-
tensor of shape :math:`(N, C \times \prod(\text{kernel_size}), L)`, where
|
|
408
|
-
:math:`C \times \prod(\text{kernel_size})` is the total number of values
|
|
409
|
-
within each block (a block has :math:`\prod(\text{kernel_size})` spatial
|
|
410
|
-
locations each containing a `C`-channeled vector), and :math:`L` is
|
|
411
|
-
the total number of such blocks:
|
|
412
|
-
|
|
413
|
-
.. math::
|
|
414
|
-
L = \prod_d \left\lfloor\frac{\text{spatial_size}[d] + 2 \times \text{padding}[d] %
|
|
415
|
-
- \text{dilation}[d] \times (\text{kernel_size}[d] - 1) - 1}{\text{stride}[d]} + 1\right\rfloor,
|
|
416
|
-
|
|
417
|
-
where :math:`\text{spatial_size}` is formed by the spatial dimensions
|
|
418
|
-
of `input` (:math:`*` above), and :math:`d` is over all spatial
|
|
419
|
-
dimensions.
|
|
420
|
-
|
|
421
|
-
Therefore, indexing `output` at the last dimension (column dimension)
|
|
422
|
-
gives all values within a certain block.
|
|
423
|
-
|
|
424
|
-
The `dilation`, `padding` and `stride` arguments specify
|
|
425
|
-
how the sliding blocks are retrieved.
|
|
426
|
-
|
|
427
|
-
.. warning::
|
|
428
|
-
- Currently, batched(4D) image-like tensors are supported.
|
|
429
|
-
- For Ascend, it is only supported on platforms above Atlas A2.
|
|
430
|
-
|
|
431
|
-
Args:
|
|
432
|
-
input (Tensor): 4-D Tensor.
|
|
433
|
-
kernel_size (Union[int, tuple[int], list[int]]): The size of the kernel, should be two int
|
|
434
|
-
for height and width. If type is int, it means that height equal with width. Must be specified.
|
|
435
|
-
dilation (Union[int, tuple[int], list[int]], optional): The dilation of the window, should be two int
|
|
436
|
-
for height and width. If type is int, it means that height equal with width. Default: ``1`` .
|
|
437
|
-
padding (Union[int, tuple[int], list[int]], optional): The pad of the window, should be two int
|
|
438
|
-
for height and width. If type is int, it means that height equal with width. Default: ``0`` .
|
|
439
|
-
stride (Union[int, tuple[int], list[int]], optional): The stride of the window, should be two int
|
|
440
|
-
for height and width. If type is int, it means that height equal with width. Default: ``1`` .
|
|
441
|
-
|
|
442
|
-
Returns:
|
|
443
|
-
A Tensor, with same type as `input` .
|
|
444
|
-
|
|
445
|
-
Shape:
|
|
446
|
-
- Input: :math:`(N, C, *)`
|
|
447
|
-
- Output: :math:`(N, C \times \prod(\text{kernel_size}), L)`
|
|
448
|
-
|
|
449
|
-
Raises:
|
|
450
|
-
TypeError: If any data type of `kernel_size`, `stride`, `dilation`, `padding` is not int, tuple or list.
|
|
451
|
-
ValueError: If `kernel_size`, `dilation`, `stride` value is not
|
|
452
|
-
greater than zero or elements number more than `2`.
|
|
453
|
-
ValueError: If `padding` value is less than zero.
|
|
454
|
-
|
|
455
|
-
Supported Platforms:
|
|
456
|
-
``Ascend``
|
|
457
|
-
|
|
458
|
-
Examples:
|
|
459
|
-
>>> import mindspore
|
|
460
|
-
>>> import numpy as np
|
|
461
|
-
>>> from mindspore import Tensor, ops
|
|
462
|
-
>>> x = Tensor(np.random.rand(4, 4, 32, 32), mindspore.float32)
|
|
463
|
-
>>> output = ops.auto_generate.unfold_ext(x, kernel_size=3, dilation=1, stride=1)
|
|
464
|
-
>>> print(output.shape)
|
|
465
|
-
(4, 36, 900)
|
|
466
|
-
"""
|
|
467
|
-
return unfold_impl(input, converted_kernel_size, converted_dilation, converted_padding, converted_stride)
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
def index_select(input, dim, index):
|
|
471
|
-
r"""
|
|
472
|
-
Generates a new Tensor that accesses the values of `input` along the specified `dim` dimension
|
|
473
|
-
using the indices specified in `index`. The new Tensor has the same number of dimensions as `input`,
|
|
474
|
-
with the size of the `dim` dimension being equal to the length of `index`, and the size of all other
|
|
475
|
-
dimensions will be unchanged from the original `input` Tensor.
|
|
476
|
-
|
|
477
|
-
.. note::
|
|
478
|
-
The value of index must be in the range of `[0, input.shape[dim])`, the result is undefined out of range.
|
|
479
|
-
|
|
480
|
-
Args:
|
|
481
|
-
input (Tensor): The input Tensor.
|
|
482
|
-
dim (int): The dimension to be indexed.
|
|
483
|
-
index (Tensor): A 1-D Tensor with the indices.
|
|
484
|
-
|
|
485
|
-
Returns:
|
|
486
|
-
Tensor, has the same dtype as input Tensor.
|
|
487
|
-
|
|
488
|
-
Raises:
|
|
489
|
-
TypeError: If `input` or `index` is not a Tensor.
|
|
490
|
-
TypeError: If `dim` is not int number.
|
|
491
|
-
ValueError: If the value of `dim` is out the range of `[-input.ndim, input.ndim - 1]`.
|
|
492
|
-
ValueError: If the dimension of `index` is not equal to 1.
|
|
493
|
-
|
|
494
|
-
Supported Platforms:
|
|
495
|
-
``Ascend``
|
|
496
|
-
|
|
497
|
-
Examples:
|
|
498
|
-
>>> import mindspore
|
|
499
|
-
>>> from mindspore import Tensor, ops
|
|
500
|
-
>>> import numpy as np
|
|
501
|
-
>>> input = Tensor(np.arange(16).astype(np.float32).reshape(2, 2, 4))
|
|
502
|
-
>>> print(input)
|
|
503
|
-
[[[ 0. 1. 2. 3.]
|
|
504
|
-
[ 4. 5. 6. 7.]]
|
|
505
|
-
[[ 8. 9. 10. 11.]
|
|
506
|
-
[12. 13. 14. 15.]]]
|
|
507
|
-
>>> index = Tensor([0,], mindspore.int32)
|
|
508
|
-
>>> y = ops.auto_generate.index_select_ext(input, 1, index)
|
|
509
|
-
>>> print(y)
|
|
510
|
-
[[[ 0. 1. 2. 3.]]
|
|
511
|
-
[[ 8. 9. 10. 11.]]]
|
|
512
|
-
"""
|
|
513
|
-
return index_select_impl(input, dim, index)
|
|
514
|
-
|
|
515
|
-
|
|
516
155
|
def leaky_relu(input, negative_slope=0.01):
|
|
517
156
|
r"""
|
|
518
157
|
leaky_relu activation function. The element of `input` less than 0 times `negative_slope` .
|
|
@@ -521,9 +160,9 @@ def leaky_relu(input, negative_slope=0.01):
|
|
|
521
160
|
|
|
522
161
|
.. math::
|
|
523
162
|
\text{leaky_relu}(input) = \begin{cases}input, &\text{if } input \geq 0; \cr
|
|
524
|
-
\
|
|
163
|
+
{\negative_slope} * input, &\text{otherwise.}\end{cases}
|
|
525
164
|
|
|
526
|
-
where :math
|
|
165
|
+
where :math:`\negative_slope` represents the `negative_slope` parameter.
|
|
527
166
|
|
|
528
167
|
For more details, see `Rectifier Nonlinearities Improve Neural Network Acoustic Models
|
|
529
168
|
<https://ai.stanford.edu/~amaas/papers/relu_hybrid_icml2013_final.pdf>`_.
|
|
@@ -546,14 +185,14 @@ def leaky_relu(input, negative_slope=0.01):
|
|
|
546
185
|
TypeError: If `negative_slope` is not a float or an int.
|
|
547
186
|
|
|
548
187
|
Supported Platforms:
|
|
549
|
-
``Ascend``
|
|
188
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
550
189
|
|
|
551
190
|
Examples:
|
|
552
191
|
>>> import mindspore
|
|
553
192
|
>>> import numpy as np
|
|
554
193
|
>>> from mindspore import Tensor, ops
|
|
555
194
|
>>> input = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
|
|
556
|
-
>>> print(
|
|
195
|
+
>>> print(mint.leaky_relu(input, negative_slope=0.2))
|
|
557
196
|
[[-0.2 4. -1.6]
|
|
558
197
|
[ 2. -1. 9. ]]
|
|
559
198
|
"""
|
|
@@ -567,36 +206,6 @@ def matmul(input, mat2):
|
|
|
567
206
|
return matmul_impl(input, mat2)
|
|
568
207
|
|
|
569
208
|
|
|
570
|
-
def matrix_inverse(input):
|
|
571
|
-
r"""
|
|
572
|
-
Compute the inverse of the input matrix.
|
|
573
|
-
|
|
574
|
-
Args:
|
|
575
|
-
input (Tensor): A matrix to be calculated. Input `input` must be at least two dimensions, and the size of
|
|
576
|
-
the last two dimensions must be the same size.
|
|
577
|
-
|
|
578
|
-
Returns:
|
|
579
|
-
Tensor, has the same type and shape as input`.
|
|
580
|
-
|
|
581
|
-
Raises:
|
|
582
|
-
TypeError: If `input` is not a Tensor.
|
|
583
|
-
ValueError: If the size of the last two dimensions of `input` is not the same.
|
|
584
|
-
ValueError: If the dimension of `input` is 1.
|
|
585
|
-
|
|
586
|
-
Supported Platforms:
|
|
587
|
-
``Ascend``
|
|
588
|
-
|
|
589
|
-
Examples:
|
|
590
|
-
>>> from mindspore import Tensor, ops
|
|
591
|
-
>>> from mindspore import dtype as mstype
|
|
592
|
-
>>> x = Tensor([[1., 2.], [3., 4.]], mstype.float32)
|
|
593
|
-
>>> print(ops.matrix_inverse_ext(x))
|
|
594
|
-
[[-2. 1. ]
|
|
595
|
-
[ 1.5 -0.5]]
|
|
596
|
-
"""
|
|
597
|
-
return matrix_inverse_impl(input)
|
|
598
|
-
|
|
599
|
-
|
|
600
209
|
def mean(input, axis=None, keep_dims=False, dtype=None):
|
|
601
210
|
r"""
|
|
602
211
|
Reduces all dimension of a tensor by averaging all elements in the dimension, by default.
|
|
@@ -684,131 +293,11 @@ def mean(input, axis=None, keep_dims=False, dtype=None):
|
|
|
684
293
|
return mean_impl(input, axis, keep_dims, dtype)
|
|
685
294
|
|
|
686
295
|
|
|
687
|
-
def prod(input, axis=None, keep_dims=False, dtype=None):
|
|
688
|
-
r"""
|
|
689
|
-
Reduces a dimension of a tensor by multiplying all elements in the dimension, by default. And also can
|
|
690
|
-
reduce a dimension of `input` along the `axis`. Determine whether the dimensions of the output and input are the
|
|
691
|
-
same by controlling `keep_dims`.
|
|
692
|
-
|
|
693
|
-
Args:
|
|
694
|
-
input (Tensor[Number]): The input tensor. The dtype of the tensor to be reduced is number.
|
|
695
|
-
:math:`(N, *)` where :math:`*` means, any number of additional dimensions.
|
|
696
|
-
axis (int): The dimensions to reduce. Default: ``None`` , reduce all dimensions.
|
|
697
|
-
Only constant value is allowed. Assume the rank of `input` is r, and the value range is [-r,r).
|
|
698
|
-
keep_dims (bool): If ``True`` , keep these reduced dimensions and the length is 1.
|
|
699
|
-
If ``False`` , don't keep these dimensions. Default: ``False`` .
|
|
700
|
-
dtype (:class:`mindspore.dtype`): The desired data type of returned Tensor. Default: ``None`` .
|
|
701
|
-
|
|
702
|
-
Returns:
|
|
703
|
-
Tensor, has the same data type as input tensor.
|
|
704
|
-
|
|
705
|
-
- If `axis` is ``None`` , and `keep_dims` is ``False`` ,
|
|
706
|
-
the output is a 0-D tensor representing the product of all elements in the input tensor.
|
|
707
|
-
- If `axis` is int, set as 1, and `keep_dims` is ``False`` ,
|
|
708
|
-
the shape of output is :math:`(input_0, input_2, ..., input_R)`.
|
|
709
|
-
|
|
710
|
-
Raises:
|
|
711
|
-
TypeError: If `input` is not a Tensor.
|
|
712
|
-
TypeError: If `axis` is not one of the following: int or None.
|
|
713
|
-
TypeError: If `keep_dims` is not a bool.
|
|
714
|
-
ValueError: If `axis` is out of range.
|
|
715
|
-
|
|
716
|
-
Supported Platforms:
|
|
717
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
718
|
-
|
|
719
|
-
Examples:
|
|
720
|
-
>>> import mindspore
|
|
721
|
-
>>> import numpy as np
|
|
722
|
-
>>> from mindspore import Tensor, ops
|
|
723
|
-
>>> x = Tensor(np.random.randn(3, 4, 5, 6).astype(np.float32))
|
|
724
|
-
>>> output = ops.ProdExt()(x, 1, keep_dims=True)
|
|
725
|
-
>>> result = output.shape
|
|
726
|
-
>>> print(result)
|
|
727
|
-
(3, 1, 5, 6)
|
|
728
|
-
>>> # case 1: Reduces a dimension by multiplying all elements in the dimension.
|
|
729
|
-
>>> x = Tensor(np.array([[[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3]],
|
|
730
|
-
... [[4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]],
|
|
731
|
-
... [[7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9]]]), mindspore.float32)
|
|
732
|
-
>>> output = ops.ProdExt()(x)
|
|
733
|
-
>>> print(output)
|
|
734
|
-
2.2833798e+33
|
|
735
|
-
>>> print(output.shape)
|
|
736
|
-
()
|
|
737
|
-
>>> # case 2: Reduces a dimension along axis 0.
|
|
738
|
-
>>> output = ops.ProdExt()(x, 0, True)
|
|
739
|
-
>>> print(output)
|
|
740
|
-
[[[ 28. 28. 28. 28. 28. 28.]
|
|
741
|
-
[ 80. 80. 80. 80. 80. 80.]
|
|
742
|
-
[162. 162. 162. 162. 162. 162.]]]
|
|
743
|
-
>>> # case 3: Reduces a dimension along axis 1.
|
|
744
|
-
>>> output = ops.ProdExt()(x, 1, True)
|
|
745
|
-
>>> print(output)
|
|
746
|
-
[[[ 6. 6. 6. 6. 6. 6.]]
|
|
747
|
-
[[120. 120. 120. 120. 120. 120.]]
|
|
748
|
-
[[504. 504. 504. 504. 504. 504.]]]
|
|
749
|
-
>>> # case 4: Reduces a dimension along axis 2.
|
|
750
|
-
>>> output = ops.ProdExt()(x, 2, True)
|
|
751
|
-
>>> print(output)
|
|
752
|
-
[[[1.00000e+00]
|
|
753
|
-
[6.40000e+01]
|
|
754
|
-
[7.29000e+02]]
|
|
755
|
-
[[4.09600e+03]
|
|
756
|
-
[1.56250e+04]
|
|
757
|
-
[4.66560e+04]]
|
|
758
|
-
[[1.17649e+05]
|
|
759
|
-
[2.62144e+05]
|
|
760
|
-
[5.31441e+05]]]
|
|
761
|
-
"""
|
|
762
|
-
return prod_impl(input, axis, keep_dims, dtype)
|
|
763
|
-
|
|
764
|
-
|
|
765
296
|
def softplus(input, beta=1, threshold=20):
|
|
766
|
-
r"""
|
|
767
|
-
Applies softplus function to `input` element-wise.
|
|
768
|
-
|
|
769
|
-
The softplus function is shown as follows, x is the element of `input` :
|
|
770
|
-
|
|
771
|
-
.. math::
|
|
772
|
-
|
|
773
|
-
\text{output} = \frac{1}{beta}\log(1 + \exp(\text{beta * x}))
|
|
774
|
-
|
|
775
|
-
where :math:`input * beta > threshold`, the implementation converts to the linear function to ensure numerical stability.
|
|
776
|
-
|
|
777
|
-
Args:
|
|
778
|
-
input (Tensor): Tensor of any dimension. Supported dtypes:
|
|
779
|
-
|
|
780
|
-
- Ascend: float16, float32, bfloat16.
|
|
781
|
-
beta (number.Number, optional): Scaling parameters in the softplus function. Default: ``1`` .
|
|
782
|
-
threshold (number.Number, optional): For numerical stability, the softplus function is converted
|
|
783
|
-
to a threshold parameter of a linear function. Default: ``20`` .
|
|
784
|
-
|
|
785
|
-
Returns:
|
|
786
|
-
Tensor, with the same type and shape as the input.
|
|
787
|
-
|
|
788
|
-
Raises:
|
|
789
|
-
TypeError: If `input` is not a Tensor.
|
|
790
|
-
TypeError: If dtype of `input` is not float16, float32, bfloat16.
|
|
791
|
-
|
|
792
|
-
Supported Platforms:
|
|
793
|
-
``Ascend``
|
|
794
|
-
|
|
795
|
-
Examples:
|
|
796
|
-
>>> import mindspore
|
|
797
|
-
>>> import numpy as np
|
|
798
|
-
>>> from mindspore import Tensor, ops
|
|
799
|
-
>>> input = Tensor(np.array([0.1, 0.2, 30, 25]), mindspore.float32)
|
|
800
|
-
>>> output = ops.auto_generate.softplus_ext(input)
|
|
801
|
-
>>> print(output)
|
|
802
|
-
[0.74439657 0.7981388 30. 25.]
|
|
803
|
-
"""
|
|
804
|
-
return softplus_impl(input, beta, threshold)
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
def sort(input, dim=-1, descending=False, stable=False):
|
|
808
297
|
r"""
|
|
809
298
|
None
|
|
810
299
|
"""
|
|
811
|
-
return
|
|
300
|
+
return softplus_impl(input, beta, threshold)
|
|
812
301
|
|
|
813
302
|
|
|
814
303
|
def stack(tensors, dim=0):
|
|
@@ -830,22 +319,23 @@ def stack(tensors, dim=0):
|
|
|
830
319
|
|
|
831
320
|
Raises:
|
|
832
321
|
TypeError: If the data types of elements in `tensors` are not the same.
|
|
833
|
-
ValueError: If `
|
|
322
|
+
ValueError: If the length of `tensors` is not greater than zero;
|
|
323
|
+
or if dim is out of the range [-(R+1), R+1);
|
|
834
324
|
or if the shapes of elements in tensors are not the same.
|
|
835
325
|
|
|
836
326
|
Supported Platforms:
|
|
837
|
-
``Ascend``
|
|
327
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
838
328
|
|
|
839
329
|
Examples:
|
|
840
330
|
>>> import mindspore
|
|
841
|
-
>>> from mindspore import Tensor,
|
|
331
|
+
>>> from mindspore import Tensor, mint
|
|
842
332
|
>>> import numpy as np
|
|
843
333
|
>>> data1 = Tensor(np.array([0, 1]).astype(np.float32))
|
|
844
334
|
>>> data2 = Tensor(np.array([2, 3]).astype(np.float32))
|
|
845
|
-
>>> output =
|
|
335
|
+
>>> output = mint.stack([data1, data2], 0)
|
|
846
336
|
>>> print(output)
|
|
847
337
|
[[0. 1.]
|
|
848
|
-
|
|
338
|
+
[2. 3.]]
|
|
849
339
|
"""
|
|
850
340
|
return stack_impl(tensors, dim)
|
|
851
341
|
|
|
@@ -876,7 +366,7 @@ def sub(input, other, alpha=1):
|
|
|
876
366
|
alpha (number.Number): A scaling factor applied to `other`, default 1.
|
|
877
367
|
|
|
878
368
|
Returns:
|
|
879
|
-
Tensor
|
|
369
|
+
Tensor, the shape is the same as the one of the input `input`, `other` after broadcasting,
|
|
880
370
|
and the data type is the one with higher precision or higher digits among the two inputs and alpha.
|
|
881
371
|
|
|
882
372
|
Raises:
|
|
@@ -891,11 +381,11 @@ def sub(input, other, alpha=1):
|
|
|
891
381
|
>>> import numpy as np
|
|
892
382
|
>>> import mindspore
|
|
893
383
|
>>> from mindspore import Tensor
|
|
894
|
-
>>> from mindspore import
|
|
384
|
+
>>> from mindspore.ops.extend import sub
|
|
895
385
|
>>> x = Tensor(np.array([4, 5, 6]).astype(np.float32))
|
|
896
386
|
>>> y = Tensor(1, mindspore.int32)
|
|
897
387
|
>>> alpha = 0.5
|
|
898
|
-
>>> output =
|
|
388
|
+
>>> output = sub(x, y, alpha)
|
|
899
389
|
>>> print(output)
|
|
900
390
|
[3.5 4.5 5.5]
|
|
901
391
|
>>> # the data type of x is float32, the data type of y is int32,
|
|
@@ -908,73 +398,7 @@ def sub(input, other, alpha=1):
|
|
|
908
398
|
|
|
909
399
|
def topk(input, k, dim=-1, largest=True, sorted=True):
|
|
910
400
|
r"""
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
.. warning::
|
|
914
|
-
- If sorted is set to False, due to different memory layout and traversal methods on different platforms,
|
|
915
|
-
the display order of calculation results may be inconsistent when `sorted` is False.
|
|
916
|
-
|
|
917
|
-
If the `input` is a one-dimensional Tensor, finds the `k` largest or smallest entries in the Tensor,
|
|
918
|
-
and outputs its value and index as a Tensor. values[`k`] is the `k` largest item in `input`,
|
|
919
|
-
and its index is indices [`k`].
|
|
920
|
-
|
|
921
|
-
For a multi-dimensional matrix,
|
|
922
|
-
calculates the first or last `k` entries in a given dimension, therefore:
|
|
923
|
-
|
|
924
|
-
.. math::
|
|
925
|
-
|
|
926
|
-
values.shape = indices.shape
|
|
927
|
-
|
|
928
|
-
If the two compared elements are the same, the one with the smaller index value is returned first.
|
|
929
|
-
|
|
930
|
-
Args:
|
|
931
|
-
input (Tensor): Input to be computed.
|
|
932
|
-
k (int): The number of top or bottom elements to be computed along the last dimension.
|
|
933
|
-
dim (int, optional): The dimension to sort along. Default: ``-1`` .
|
|
934
|
-
largest (bool, optional): If largest is ``False`` then the k smallest elements are returned.
|
|
935
|
-
Default: ``True`` .
|
|
936
|
-
sorted (bool, optional): If ``True`` , the obtained elements will be sorted by the values in descending
|
|
937
|
-
order or ascending order according to `largest`. If ``False`` , the obtained elements will not be
|
|
938
|
-
sorted. Default: ``True`` .
|
|
939
|
-
|
|
940
|
-
Returns:
|
|
941
|
-
A tuple consisting of `values` and `indices`.
|
|
942
|
-
|
|
943
|
-
- values (Tensor) - The `k` largest or smallest elements in each slice of the given dimension.
|
|
944
|
-
- indices (Tensor) - The indices of values within the last dimension of input.
|
|
945
|
-
|
|
946
|
-
Raises:
|
|
947
|
-
TypeError: If `sorted` is not a bool.
|
|
948
|
-
TypeError: If `input` is not a Tensor.
|
|
949
|
-
TypeError: If `k` is not an int.
|
|
950
|
-
|
|
951
|
-
Supported Platforms:
|
|
952
|
-
``Ascend``
|
|
953
|
-
|
|
954
|
-
Examples:
|
|
955
|
-
>>> import mindspore as ms
|
|
956
|
-
>>> from mindspore import ops
|
|
957
|
-
>>> x = ms.Tensor([[0.5368, 0.2447, 0.4302, 0.9673],
|
|
958
|
-
... [0.4388, 0.6525, 0.4685, 0.1868],
|
|
959
|
-
... [0.3563, 0.5152, 0.9675, 0.8230]], dtype=ms.float32)
|
|
960
|
-
>>> output = ops.topk_ext(x, 2, dim=1)
|
|
961
|
-
>>> print(output)
|
|
962
|
-
(Tensor(shape=[3, 2], dtype=Float32, value=
|
|
963
|
-
[[ 9.67299998e-01, 5.36800027e-01],
|
|
964
|
-
[ 6.52499974e-01, 4.68499988e-01],
|
|
965
|
-
[ 9.67499971e-01, 8.23000014e-01]]), Tensor(shape=[3, 2], dtype=Int32, value=
|
|
966
|
-
[[3, 0],
|
|
967
|
-
[1, 2],
|
|
968
|
-
[2, 3]]))
|
|
969
|
-
>>> output2 = ops.topk_ext(x, 2, dim=1, largest=False)
|
|
970
|
-
>>> print(output2)
|
|
971
|
-
(Tensor(shape=[3, 2], dtype=Float32, value=
|
|
972
|
-
[[ 2.44700000e-01, 4.30200011e-01],
|
|
973
|
-
[ 1.86800003e-01, 4.38800007e-01],
|
|
974
|
-
[ 3.56299996e-01, 5.15200019e-01]]), Tensor(shape=[3, 2], dtype=Int32, value=
|
|
975
|
-
[[1, 2],
|
|
976
|
-
[3, 0],
|
|
977
|
-
[0, 1]]))
|
|
401
|
+
None
|
|
978
402
|
"""
|
|
979
403
|
return topk_impl(input, k, dim, largest, sorted)
|
|
980
404
|
|