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
|
@@ -150,7 +150,7 @@ def add_ext(input, other, alpha=1):
|
|
|
150
150
|
alpha (number.Number): A scaling factor applied to `other`, default 1.
|
|
151
151
|
|
|
152
152
|
Returns:
|
|
153
|
-
Tensor
|
|
153
|
+
Tensor, the shape is the same as the one of the input `input`, `other` after broadcasting,
|
|
154
154
|
and the data type is the one with higher precision or higher digits among the two inputs and alpha.
|
|
155
155
|
|
|
156
156
|
Raises:
|
|
@@ -165,11 +165,11 @@ def add_ext(input, other, alpha=1):
|
|
|
165
165
|
>>> import numpy as np
|
|
166
166
|
>>> import mindspore
|
|
167
167
|
>>> from mindspore import Tensor
|
|
168
|
-
>>> from mindspore import
|
|
168
|
+
>>> from mindspore.ops.extend import add
|
|
169
169
|
>>> x = Tensor(1, mindspore.int32)
|
|
170
170
|
>>> y = Tensor(np.array([4, 5, 6]).astype(np.float32))
|
|
171
171
|
>>> alpha = 0.5
|
|
172
|
-
>>> output =
|
|
172
|
+
>>> output = add(x, y, alpha)
|
|
173
173
|
>>> print(output)
|
|
174
174
|
[3. 3.5 4.]
|
|
175
175
|
>>> # the data type of x is int32, the data type of y is float32,
|
|
@@ -208,7 +208,7 @@ def add(input, other):
|
|
|
208
208
|
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
|
209
209
|
|
|
210
210
|
Returns:
|
|
211
|
-
Tensor
|
|
211
|
+
Tensor, the shape is the same as the one of the input `input` , `other` after broadcasting,
|
|
212
212
|
and the data type is the one with higher precision or higher digits among the two inputs.
|
|
213
213
|
|
|
214
214
|
Raises:
|
|
@@ -241,13 +241,6 @@ def add(input, other):
|
|
|
241
241
|
return add_op(input, other)
|
|
242
242
|
|
|
243
243
|
|
|
244
|
-
def addmm(input, mat1, mat2, beta, alpha):
|
|
245
|
-
r"""
|
|
246
|
-
|
|
247
|
-
"""
|
|
248
|
-
return addmm_op(input, mat1, mat2, beta, alpha)
|
|
249
|
-
|
|
250
|
-
|
|
251
244
|
def addn(x):
|
|
252
245
|
r"""
|
|
253
246
|
Computes addition of all input tensors element-wise.
|
|
@@ -320,7 +313,7 @@ def apply_rotary_pos_emb_(query, key, cos, sin, position_ids, cos_format=0):
|
|
|
320
313
|
return apply_rotary_pos_emb_op(query, key, cos, sin, position_ids)
|
|
321
314
|
|
|
322
315
|
|
|
323
|
-
def
|
|
316
|
+
def argmax(input, dim=None, keepdim=False):
|
|
324
317
|
r"""
|
|
325
318
|
Return the indices of the maximum values of a tensor across a dimension.
|
|
326
319
|
|
|
@@ -339,14 +332,13 @@ def argmax_ext(input, dim=None, keepdim=False):
|
|
|
339
332
|
ValueError: If `dim` is out of range.
|
|
340
333
|
|
|
341
334
|
Supported Platforms:
|
|
342
|
-
``Ascend``
|
|
335
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
343
336
|
|
|
344
337
|
Examples:
|
|
345
338
|
>>> import numpy as np
|
|
346
|
-
>>> from mindspore import Tensor
|
|
347
|
-
>>> from mindspore import ops
|
|
339
|
+
>>> from mindspore import Tensor, ops
|
|
348
340
|
>>> x = Tensor(np.array([[1, 20, 5], [67, 8, 9], [130, 24, 15]]).astype(np.float32))
|
|
349
|
-
>>> output = ops.
|
|
341
|
+
>>> output = ops.argmax(x, dim=-1)
|
|
350
342
|
>>> print(output)
|
|
351
343
|
[1 0 0]
|
|
352
344
|
"""
|
|
@@ -504,47 +496,6 @@ def assign(variable, value):
|
|
|
504
496
|
return assign_op(variable, value)
|
|
505
497
|
|
|
506
498
|
|
|
507
|
-
def atan2_ext(input, other):
|
|
508
|
-
r"""
|
|
509
|
-
Returns arctangent of input/other element-wise.
|
|
510
|
-
|
|
511
|
-
It returns :math:`\theta\ \in\ [-\pi, \pi]`
|
|
512
|
-
such that :math:`input = r*\sin(\theta), other = r*\cos(\theta)`, where :math:`r = \sqrt{input^2 + other^2}`.
|
|
513
|
-
|
|
514
|
-
Note:
|
|
515
|
-
- Arg `input` and `other` comply with the implicit type conversion rules to make the data types consistent.
|
|
516
|
-
If they have different data types, the lower precision data type will be converted to relatively the
|
|
517
|
-
highest precision data type.
|
|
518
|
-
|
|
519
|
-
Args:
|
|
520
|
-
input (Tensor, Number.number): The input tensor or scalar.
|
|
521
|
-
other (Tensor, Number.number): The input tensor or scalar. It has the same shape with `input` or
|
|
522
|
-
its shape is able to broadcast with `input`.
|
|
523
|
-
|
|
524
|
-
Returns:
|
|
525
|
-
Tensor, the shape is the same as the one after broadcasting, and the data type is same as `input`.
|
|
526
|
-
|
|
527
|
-
Raises:
|
|
528
|
-
TypeError: If `input` or `other` is not a Tensor or scalar.
|
|
529
|
-
RuntimeError: If the data type of `input` and `other` conversion of Parameter is required
|
|
530
|
-
when data type conversion of Parameter is not supported.
|
|
531
|
-
|
|
532
|
-
Supported Platforms:
|
|
533
|
-
``Ascend``
|
|
534
|
-
|
|
535
|
-
Examples:
|
|
536
|
-
>>> import mindspore
|
|
537
|
-
>>> import numpy as np
|
|
538
|
-
>>> from mindspore import Tensor, ops
|
|
539
|
-
>>> input = Tensor(np.array([0, 1]), mindspore.float32)
|
|
540
|
-
>>> other = Tensor(np.array([1, 1]), mindspore.float32)
|
|
541
|
-
>>> output = mint.atan2(input, other)
|
|
542
|
-
>>> print(output)
|
|
543
|
-
[0. 0.7853982]
|
|
544
|
-
"""
|
|
545
|
-
return atan2_ext_op(input, other)
|
|
546
|
-
|
|
547
|
-
|
|
548
499
|
def atan2(input, other):
|
|
549
500
|
r"""
|
|
550
501
|
Returns arctangent of input/other element-wise.
|
|
@@ -664,19 +615,19 @@ def bmm_ext(input, mat2):
|
|
|
664
615
|
Performs batch matrix-matrix multiplication of two three-dimensional tensors.
|
|
665
616
|
|
|
666
617
|
.. math::
|
|
667
|
-
\text{output}= \text{input} @ \text{mat2}
|
|
618
|
+
\text{output}[b, i, j] = \text{input}[b, i, k] @ \text{mat2}[b, k, j]
|
|
668
619
|
|
|
669
620
|
Args:
|
|
670
|
-
input (Tensor): The first batch of matrices to be multiplied. Must be a three-dimensional tensor
|
|
671
|
-
mat2 (Tensor): The second batch of matrices to be multiplied. Must be a three-dimensional tensor
|
|
621
|
+
input (Tensor): The first batch of matrices to be multiplied. Must be a three-dimensional tensor.
|
|
622
|
+
mat2 (Tensor): The second batch of matrices to be multiplied. Must be a three-dimensional tensor.
|
|
672
623
|
|
|
673
624
|
Returns:
|
|
674
625
|
Tensor, the output tensor of shape `(b, n, p)`, where each matrix is the product of the corresponding matrices in the input batches.
|
|
675
626
|
|
|
676
627
|
Raises:
|
|
677
|
-
|
|
628
|
+
TypeError: If `input` or `mat2` is not three-dimensional tensors.
|
|
678
629
|
ValueError: If the length of the third dimension of `input` is not equal to the length of the second dimension of `mat2`.
|
|
679
|
-
ValueError: If the batch size of the inputs
|
|
630
|
+
ValueError: If the batch size of the inputs do not match.
|
|
680
631
|
|
|
681
632
|
Supported Platforms:
|
|
682
633
|
``Ascend`` ``GPU`` ``CPU``
|
|
@@ -685,17 +636,12 @@ def bmm_ext(input, mat2):
|
|
|
685
636
|
>>> import mindspore
|
|
686
637
|
>>> import numpy as np
|
|
687
638
|
>>> from mindspore import Tensor
|
|
688
|
-
>>> from mindspore import
|
|
639
|
+
>>> from mindspore.ops.extend import bmm
|
|
689
640
|
>>> a = Tensor(np.ones(shape=[2, 3, 4]), mindspore.float32)
|
|
690
641
|
>>> b = Tensor(np.ones(shape=[2, 4, 5]), mindspore.float32)
|
|
691
|
-
>>> output =
|
|
692
|
-
>>> print(output)
|
|
693
|
-
|
|
694
|
-
[4. 4. 4. 4. 4.]
|
|
695
|
-
[4. 4. 4. 4. 4.]]
|
|
696
|
-
[[4. 4. 4. 4. 4.]
|
|
697
|
-
[4. 4. 4. 4. 4.]
|
|
698
|
-
[4. 4. 4. 4. 4.]]]
|
|
642
|
+
>>> output = bmm(a, b)
|
|
643
|
+
>>> print(output.shape)
|
|
644
|
+
(2, 3, 5)
|
|
699
645
|
"""
|
|
700
646
|
return bmm_ext_op(input, mat2)
|
|
701
647
|
|
|
@@ -766,13 +712,13 @@ def broadcast_to(input, shape):
|
|
|
766
712
|
>>> output = ops.broadcast_to(x, shape)
|
|
767
713
|
>>> print(output)
|
|
768
714
|
[[1. 2. 3.]
|
|
769
|
-
|
|
715
|
+
[1. 2. 3.]]
|
|
770
716
|
>>> shape = (-1, 2)
|
|
771
717
|
>>> x = Tensor(np.array([[1], [2]]).astype(np.float32))
|
|
772
718
|
>>> output = ops.broadcast_to(x, shape)
|
|
773
719
|
>>> print(output)
|
|
774
720
|
[[1. 1.]
|
|
775
|
-
|
|
721
|
+
[2. 2.]]
|
|
776
722
|
"""
|
|
777
723
|
return broadcast_to_impl(input, shape)
|
|
778
724
|
|
|
@@ -1020,72 +966,6 @@ def clamp_tensor(input, min=None, max=None):
|
|
|
1020
966
|
return clamp_tensor_op(input, min, max)
|
|
1021
967
|
|
|
1022
968
|
|
|
1023
|
-
def fold_ext(input, output_size, kernel_size, dilation=1, padding=0, stride=1):
|
|
1024
|
-
r"""
|
|
1025
|
-
Combines an array of sliding local blocks into a large containing tensor.
|
|
1026
|
-
|
|
1027
|
-
Consider a batched input tensor of shape :math:`(N, C \times \prod(\text{kernel_size}), L)` ,
|
|
1028
|
-
where :math:`N` is the batch dimension, :math:`C \times \prod(\text{kernel_size})` is the
|
|
1029
|
-
total number of values within each block (a block has :math:`\prod(\text{kernel_size})` spatial
|
|
1030
|
-
locations each containing a `C`-channeled vector), and :math:`L` is the total number of such blocks:
|
|
1031
|
-
|
|
1032
|
-
.. math::
|
|
1033
|
-
L = \prod_d \left\lfloor\frac{\text{output_size}[d] + 2 \times \text{padding}[d] %
|
|
1034
|
-
- \text{dilation}[d] \times (\text{kernel_size}[d] - 1) - 1}{\text{stride}[d]} + 1\right\rfloor,
|
|
1035
|
-
|
|
1036
|
-
where :math:`d` is over all spatial dimensions.
|
|
1037
|
-
|
|
1038
|
-
Therefore, `output_size` is the spatial shape of the large containing tensor of the sliding local blocks.
|
|
1039
|
-
|
|
1040
|
-
The `dilation`, `padding` and `stride` arguments specify how the sliding blocks are retrieved.
|
|
1041
|
-
|
|
1042
|
-
.. warning::
|
|
1043
|
-
Currently, only unbatched(3D) or batched(4D) image-like output tensors are supported.
|
|
1044
|
-
|
|
1045
|
-
Args:
|
|
1046
|
-
input (Tensor): 2-D or 3-D Tensor.
|
|
1047
|
-
output_size (Union[int, tuple[int], list[int]]): The shape of the spatial dimensions of
|
|
1048
|
-
the output(i.e., output.shape[2:]).
|
|
1049
|
-
kernel_size (Union[int, tuple[int], list[int]]): The size of the kernel, should be two int
|
|
1050
|
-
for height and width. If type is int, it means that height equal with width. Must be specified.
|
|
1051
|
-
dilation (Union[int, tuple[int], list[int]], optional): The size of the dilation, should be two int
|
|
1052
|
-
for height and width. If type is int, it means that height equal with width. Default: ``1`` .
|
|
1053
|
-
padding (Union[int, tuple[int], list[int]], optional): The size of the padding, should be two int
|
|
1054
|
-
for height and width. If type is int, it means that height equal with width. Default: ``0`` .
|
|
1055
|
-
stride (Union[int, tuple[int], list[int]], optional): The size of the stride, should be two int
|
|
1056
|
-
for height and width. If type is int, it means that height equal with width. Default: ``1`` .
|
|
1057
|
-
|
|
1058
|
-
Returns:
|
|
1059
|
-
A Tensor, with same type as `input` .
|
|
1060
|
-
|
|
1061
|
-
Shape:
|
|
1062
|
-
- Input: :math:`(N, C \times \prod(\text{kernel_size}), L)` or
|
|
1063
|
-
:math:`(C \times \prod(\text{kernel_size}), L)`
|
|
1064
|
-
- Output: :math:`(N, C, output\_size[0], output\_size[1], ...)` or
|
|
1065
|
-
:math:`(C, output\_size[0], output\_size[1], ...)`
|
|
1066
|
-
|
|
1067
|
-
Raises:
|
|
1068
|
-
TypeError: If `output_size`, `kernel_size`, `stride`, `dilation`, `padding` data type is not int, tuple or list.
|
|
1069
|
-
ValueError: If `output_size`, `kernel_size`, `dilation`, `stride` value is not
|
|
1070
|
-
greater than zero or elements number invalid.
|
|
1071
|
-
ValueError: If `padding` value is less than zero or elements number invalid.
|
|
1072
|
-
ValueError: If input.shape[-2] can't be divisible by the product of kernel_size.
|
|
1073
|
-
ValueError: If `input.shape[-1]` is not equal to the calculated number of sliding blocks `L`.
|
|
1074
|
-
|
|
1075
|
-
Supported Platforms:
|
|
1076
|
-
``Ascend``
|
|
1077
|
-
|
|
1078
|
-
Examples:
|
|
1079
|
-
>>> import numpy as np
|
|
1080
|
-
>>> from mindspore import Tensor, ops
|
|
1081
|
-
>>> x = Tensor(np.random.rand(16, 64, 25).astype(np.float32))
|
|
1082
|
-
>>> output = ops.auto_generate.fold_ext(x, (8, 8), [2, 2], [2, 2], [2, 2], [2, 2])
|
|
1083
|
-
>>> print(output.shape)
|
|
1084
|
-
(16, 16, 8, 8)
|
|
1085
|
-
"""
|
|
1086
|
-
return col2im_ext_op(input, output_size, kernel_size, dilation, padding, stride)
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
969
|
def cat(tensors, axis=0):
|
|
1090
970
|
r"""
|
|
1091
971
|
Connect input tensors along with the given axis.
|
|
@@ -1392,54 +1272,6 @@ def cummax(input, axis):
|
|
|
1392
1272
|
return cummax_op(input)
|
|
1393
1273
|
|
|
1394
1274
|
|
|
1395
|
-
def cumsum_ext(input, dim, dtype=None):
|
|
1396
|
-
r"""
|
|
1397
|
-
Computes the cumulative sum of input Tensor along `dim`.
|
|
1398
|
-
|
|
1399
|
-
.. math::
|
|
1400
|
-
|
|
1401
|
-
y_i = x_1 + x_2 + x_3 + ... + x_i
|
|
1402
|
-
|
|
1403
|
-
Args:
|
|
1404
|
-
input (Tensor): The input Tensor.
|
|
1405
|
-
dim (int): Dim along which the cumulative sum is computed.
|
|
1406
|
-
dtype (:class:`mindspore.dtype`, optional): The desired dtype of returned Tensor. If specified,
|
|
1407
|
-
the input Tensor will be cast to `dtype` before the computation. This is useful for preventing overflows.
|
|
1408
|
-
If not specified, stay the same as original Tensor. Default: ``None`` .
|
|
1409
|
-
|
|
1410
|
-
Returns:
|
|
1411
|
-
Tensor, the shape of the output Tensor is consistent with the input Tensor's.
|
|
1412
|
-
|
|
1413
|
-
Raises:
|
|
1414
|
-
TypeError: If `input` is not a Tensor.
|
|
1415
|
-
ValueError: If the `dim` is out of range.
|
|
1416
|
-
|
|
1417
|
-
Supported Platforms:
|
|
1418
|
-
``Ascend``
|
|
1419
|
-
|
|
1420
|
-
Examples:
|
|
1421
|
-
>>> import numpy as np
|
|
1422
|
-
>>> from mindspore import Tensor
|
|
1423
|
-
>>> import mindspore.ops as ops
|
|
1424
|
-
>>> x = Tensor(np.array([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7], [1, 3, 7, 9]]).astype(np.float32))
|
|
1425
|
-
>>> # case 1: along the dim 0
|
|
1426
|
-
>>> y = ops.auto_generate.cumsum_ext(x, 0)
|
|
1427
|
-
>>> print(y)
|
|
1428
|
-
[[ 3. 4. 6. 10.]
|
|
1429
|
-
[ 4. 10. 13. 19.]
|
|
1430
|
-
[ 8. 13. 21. 26.]
|
|
1431
|
-
[ 9. 16. 28. 35.]]
|
|
1432
|
-
>>> # case 2: along the dim 1
|
|
1433
|
-
>>> y = ops.auto_generate.cumsum_ext(x, 1)
|
|
1434
|
-
>>> print(y)
|
|
1435
|
-
[[ 3. 7. 13. 23.]
|
|
1436
|
-
[ 1. 7. 14. 23.]
|
|
1437
|
-
[ 4. 7. 15. 22.]
|
|
1438
|
-
[ 1. 4. 11. 20.]]
|
|
1439
|
-
"""
|
|
1440
|
-
return cumsum_ext_op(input, dim, dtype)
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
1275
|
def decoder_k_v_cache(cache, update, valid_seq_len, batch_index, seq_len_axis, new_max_seq_len, cur_max_seq_len):
|
|
1444
1276
|
r"""
|
|
1445
1277
|
The DecoderKVCache is used for decoding the KVCache of transformer network.
|
|
@@ -1628,56 +1460,6 @@ def dot(input, other):
|
|
|
1628
1460
|
return dot_op(input, other)
|
|
1629
1461
|
|
|
1630
1462
|
|
|
1631
|
-
def elu_ext(input, alpha=1.0):
|
|
1632
|
-
r"""
|
|
1633
|
-
Exponential Linear Unit activation function.
|
|
1634
|
-
|
|
1635
|
-
Applies the exponential linear unit function element-wise.
|
|
1636
|
-
The activation function is defined as:
|
|
1637
|
-
|
|
1638
|
-
.. math::
|
|
1639
|
-
|
|
1640
|
-
\text{ELU}(x)= \left\{
|
|
1641
|
-
\begin{array}{align}
|
|
1642
|
-
\alpha(e^{x} - 1) & \text{if } x \le 0\\
|
|
1643
|
-
x & \text{if } x \gt 0\\
|
|
1644
|
-
\end{array}\right.
|
|
1645
|
-
|
|
1646
|
-
Where :math:`x` is the element of input Tensor `input`, :math:`\alpha` is param `alpha`,
|
|
1647
|
-
it determines the smoothness of ELU.
|
|
1648
|
-
|
|
1649
|
-
ELU function graph:
|
|
1650
|
-
|
|
1651
|
-
.. image:: ../images/ELU.png
|
|
1652
|
-
:align: center
|
|
1653
|
-
|
|
1654
|
-
Args:
|
|
1655
|
-
input (Tensor): The input of ELU is a Tensor of any dimension.
|
|
1656
|
-
alpha (float, optional): The alpha value of ELU, the data type is float.
|
|
1657
|
-
Default: ``1.0`` .
|
|
1658
|
-
|
|
1659
|
-
Returns:
|
|
1660
|
-
Tensor, has the same shape and data type as `input`.
|
|
1661
|
-
|
|
1662
|
-
Raises:
|
|
1663
|
-
TypeError: If `alpha` is not a float.
|
|
1664
|
-
|
|
1665
|
-
Supported Platforms:
|
|
1666
|
-
``Ascend``
|
|
1667
|
-
|
|
1668
|
-
Examples:
|
|
1669
|
-
>>> import mindspore
|
|
1670
|
-
>>> import numpy as np
|
|
1671
|
-
>>> from mindspore import Tensor, ops
|
|
1672
|
-
>>> x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
|
|
1673
|
-
>>> output = ops.auto_generate.elu_ext(x)
|
|
1674
|
-
>>> print(output)
|
|
1675
|
-
[[-0.63212055 4. -0.99966455]
|
|
1676
|
-
[ 2. -0.99326205 9. ]]
|
|
1677
|
-
"""
|
|
1678
|
-
return elu_ext_impl(input, alpha)
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
1463
|
def elu(input_x, alpha=1.0):
|
|
1682
1464
|
r"""
|
|
1683
1465
|
Exponential Linear Unit activation function.
|
|
@@ -1695,6 +1477,8 @@ def elu(input_x, alpha=1.0):
|
|
|
1695
1477
|
|
|
1696
1478
|
Where :math:`x` is the element of input Tensor `input_x`, :math:`\alpha` is param `alpha`,
|
|
1697
1479
|
it determines the smoothness of ELU.
|
|
1480
|
+
The picture about ELU looks like this `ELU <https://en.wikipedia.org/wiki/
|
|
1481
|
+
Activation_function#/media/File:Activation_elu.svg>`_ .
|
|
1698
1482
|
|
|
1699
1483
|
ELU function graph:
|
|
1700
1484
|
|
|
@@ -1746,7 +1530,6 @@ def equal(input, other):
|
|
|
1746
1530
|
|
|
1747
1531
|
Note:
|
|
1748
1532
|
- `input` and `other` comply with the implicit type conversion rules to make the data types consistent.
|
|
1749
|
-
- The input must be two Tensors, or a Tensor and a Scalar.
|
|
1750
1533
|
- The shapes of the inputs can be broadcasted to each other.
|
|
1751
1534
|
|
|
1752
1535
|
Args:
|
|
@@ -1794,18 +1577,20 @@ def erf(input):
|
|
|
1794
1577
|
input (Tensor): The input tensor of Gaussian error function. :math:`x` in the following formula.
|
|
1795
1578
|
Supported dtypes:
|
|
1796
1579
|
|
|
1580
|
+
- Ascend: float16, float32, int64, bool.
|
|
1797
1581
|
- GPU/CPU: float16, float32, float64.
|
|
1798
|
-
- Ascend: float16, float32, float64, int64, bool.
|
|
1799
1582
|
|
|
1800
1583
|
Returns:
|
|
1801
|
-
Tensor
|
|
1802
|
-
|
|
1803
|
-
[bool, int64]. Otherwise output has the same dtype as the `input`.
|
|
1584
|
+
Tensor. If the input is int64 or bool, the return value type is float32.
|
|
1585
|
+
Otherwise, the return value type is the same as the input type.
|
|
1804
1586
|
|
|
1805
|
-
|
|
1806
|
-
:
|
|
1807
|
-
|
|
1808
|
-
|
|
1587
|
+
|
|
1588
|
+
Raises:
|
|
1589
|
+
TypeError: If `input` is not a Tensor.
|
|
1590
|
+
TypeError: If dtype of `input` is not as follows
|
|
1591
|
+
|
|
1592
|
+
- Ascend: float16, float32, int64, bool.
|
|
1593
|
+
- GPU/CPU: float16, float32, float64.
|
|
1809
1594
|
|
|
1810
1595
|
Supported Platforms:
|
|
1811
1596
|
``Ascend`` ``GPU`` ``CPU``
|
|
@@ -1877,8 +1662,7 @@ def erfinv(input):
|
|
|
1877
1662
|
- GPU/CPU: float16, float32 or float64.
|
|
1878
1663
|
|
|
1879
1664
|
Returns:
|
|
1880
|
-
Tensor
|
|
1881
|
-
Otherwise, the return value type is the same as the input type.
|
|
1665
|
+
Tensor, has the same shape and dtype as `input`.
|
|
1882
1666
|
|
|
1883
1667
|
:raise TypeError: If dtype of `input` is not as follows
|
|
1884
1668
|
|
|
@@ -1895,7 +1679,7 @@ def erfinv(input):
|
|
|
1895
1679
|
>>> input = Tensor(np.array([0, 0.5, -0.9]), mindspore.float32)
|
|
1896
1680
|
>>> output = ops.erfinv(input)
|
|
1897
1681
|
>>> print(output)
|
|
1898
|
-
[ 0. 0.
|
|
1682
|
+
[ 0. 0.47695306 -1.1630805 ]
|
|
1899
1683
|
"""
|
|
1900
1684
|
return erfinv_op(input)
|
|
1901
1685
|
|
|
@@ -1926,7 +1710,7 @@ def exp(input):
|
|
|
1926
1710
|
>>> input = Tensor(np.array([0.0, 1.0, 3.0]), mindspore.float32)
|
|
1927
1711
|
>>> output = ops.exp(input)
|
|
1928
1712
|
>>> print(output)
|
|
1929
|
-
[ 1. 2.
|
|
1713
|
+
[ 1. 2.718282 20.085537]
|
|
1930
1714
|
"""
|
|
1931
1715
|
return exp_op(input)
|
|
1932
1716
|
|
|
@@ -2456,20 +2240,18 @@ def floor(input):
|
|
|
2456
2240
|
|
|
2457
2241
|
.. math::
|
|
2458
2242
|
|
|
2459
|
-
out_i = \lfloor
|
|
2243
|
+
out_i = \lfloor x_i \rfloor
|
|
2460
2244
|
|
|
2461
2245
|
Args:
|
|
2462
|
-
input (Tensor): The input tensor. Its
|
|
2463
|
-
|
|
2464
|
-
- Ascend: float16, float32, float64, bfloat16, int8, int16, int32, int64, uint8, uint16, uint32, uint64.
|
|
2465
|
-
- GPU/CPU: float16, float32, float64.
|
|
2246
|
+
input (Tensor): The input tensor, :math:`x` in the above formula. Its data type must be float16,
|
|
2247
|
+
float32 or float64.
|
|
2466
2248
|
|
|
2467
2249
|
Returns:
|
|
2468
2250
|
Tensor, has the same shape as `input`.
|
|
2469
2251
|
|
|
2470
2252
|
Raises:
|
|
2471
2253
|
TypeError: If `input` is not a Tensor.
|
|
2472
|
-
TypeError: If dtype of `input` is not
|
|
2254
|
+
TypeError: If dtype of `input` is not in [float16, float32, float64].
|
|
2473
2255
|
|
|
2474
2256
|
Supported Platforms:
|
|
2475
2257
|
``Ascend`` ``GPU`` ``CPU``
|
|
@@ -2728,8 +2510,8 @@ def greater_equal(input, other):
|
|
|
2728
2510
|
Args:
|
|
2729
2511
|
input (Union[Tensor, Number]): The first input is a number or
|
|
2730
2512
|
a bool or a tensor whose data type is number or bool.
|
|
2731
|
-
other (Union[Tensor, Number]):
|
|
2732
|
-
|
|
2513
|
+
other (Union[Tensor, Number]): The second input is a number
|
|
2514
|
+
or a tensor whose data type is number or bool.
|
|
2733
2515
|
|
|
2734
2516
|
Returns:
|
|
2735
2517
|
Tensor, the shape is the same as the one after broadcasting, and the data type is bool.
|
|
@@ -3017,124 +2799,6 @@ def ifftshift(input, dim=None):
|
|
|
3017
2799
|
return ifftshift_op(input, dim)
|
|
3018
2800
|
|
|
3019
2801
|
|
|
3020
|
-
def unfold_ext(input, kernel_size, dilation=1, padding=0, stride=1):
|
|
3021
|
-
r"""
|
|
3022
|
-
Extracts sliding local blocks from a batched input tensor.
|
|
3023
|
-
|
|
3024
|
-
Consider a batched input tensor of shape :math:`(N, C, *)`,
|
|
3025
|
-
where :math:`N` is the batch dimension, :math:`C` is the channel dimension,
|
|
3026
|
-
and :math:`*` represent arbitrary spatial dimensions. This operation flattens
|
|
3027
|
-
each sliding `Kernel_size`- sized block within the spatial dimensions
|
|
3028
|
-
of `input` into a column (i.e., last dimension) of a 3-D output
|
|
3029
|
-
tensor of shape :math:`(N, C \times \prod(\text{kernel_size}), L)`, where
|
|
3030
|
-
:math:`C \times \prod(\text{kernel_size})` is the total number of values
|
|
3031
|
-
within each block (a block has :math:`\prod(\text{kernel_size})` spatial
|
|
3032
|
-
locations each containing a `C`-channeled vector), and :math:`L` is
|
|
3033
|
-
the total number of such blocks:
|
|
3034
|
-
|
|
3035
|
-
.. math::
|
|
3036
|
-
L = \prod_d \left\lfloor\frac{\text{spatial_size}[d] + 2 \times \text{padding}[d] %
|
|
3037
|
-
- \text{dilation}[d] \times (\text{kernel_size}[d] - 1) - 1}{\text{stride}[d]} + 1\right\rfloor,
|
|
3038
|
-
|
|
3039
|
-
where :math:`\text{spatial_size}` is formed by the spatial dimensions
|
|
3040
|
-
of `input` (:math:`*` above), and :math:`d` is over all spatial
|
|
3041
|
-
dimensions.
|
|
3042
|
-
|
|
3043
|
-
Therefore, indexing `output` at the last dimension (column dimension)
|
|
3044
|
-
gives all values within a certain block.
|
|
3045
|
-
|
|
3046
|
-
The `dilation`, `padding` and `stride` arguments specify
|
|
3047
|
-
how the sliding blocks are retrieved.
|
|
3048
|
-
|
|
3049
|
-
.. warning::
|
|
3050
|
-
- Currently, batched(4D) image-like tensors are supported.
|
|
3051
|
-
- For Ascend, it is only supported on platforms above Atlas A2.
|
|
3052
|
-
|
|
3053
|
-
Args:
|
|
3054
|
-
input (Tensor): 4-D Tensor.
|
|
3055
|
-
kernel_size (Union[int, tuple[int], list[int]]): The size of the kernel, should be two int
|
|
3056
|
-
for height and width. If type is int, it means that height equal with width. Must be specified.
|
|
3057
|
-
dilation (Union[int, tuple[int], list[int]], optional): The dilation of the window, should be two int
|
|
3058
|
-
for height and width. If type is int, it means that height equal with width. Default: ``1`` .
|
|
3059
|
-
padding (Union[int, tuple[int], list[int]], optional): The pad of the window, should be two int
|
|
3060
|
-
for height and width. If type is int, it means that height equal with width. Default: ``0`` .
|
|
3061
|
-
stride (Union[int, tuple[int], list[int]], optional): The stride of the window, should be two int
|
|
3062
|
-
for height and width. If type is int, it means that height equal with width. Default: ``1`` .
|
|
3063
|
-
|
|
3064
|
-
Returns:
|
|
3065
|
-
A Tensor, with same type as `input` .
|
|
3066
|
-
|
|
3067
|
-
Shape:
|
|
3068
|
-
- Input: :math:`(N, C, *)`
|
|
3069
|
-
- Output: :math:`(N, C \times \prod(\text{kernel_size}), L)`
|
|
3070
|
-
|
|
3071
|
-
Raises:
|
|
3072
|
-
TypeError: If any data type of `kernel_size`, `stride`, `dilation`, `padding` is not int, tuple or list.
|
|
3073
|
-
ValueError: If `kernel_size`, `dilation`, `stride` value is not
|
|
3074
|
-
greater than zero or elements number more than `2`.
|
|
3075
|
-
ValueError: If `padding` value is less than zero.
|
|
3076
|
-
|
|
3077
|
-
Supported Platforms:
|
|
3078
|
-
``Ascend``
|
|
3079
|
-
|
|
3080
|
-
Examples:
|
|
3081
|
-
>>> import mindspore
|
|
3082
|
-
>>> import numpy as np
|
|
3083
|
-
>>> from mindspore import Tensor, ops
|
|
3084
|
-
>>> x = Tensor(np.random.rand(4, 4, 32, 32), mindspore.float32)
|
|
3085
|
-
>>> output = ops.auto_generate.unfold_ext(x, kernel_size=3, dilation=1, stride=1)
|
|
3086
|
-
>>> print(output.shape)
|
|
3087
|
-
(4, 36, 900)
|
|
3088
|
-
"""
|
|
3089
|
-
return im2col_ext_op(input, kernel_size, dilation, padding, stride)
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
def index_select_ext(input, dim, index):
|
|
3093
|
-
r"""
|
|
3094
|
-
Generates a new Tensor that accesses the values of `input` along the specified `dim` dimension
|
|
3095
|
-
using the indices specified in `index`. The new Tensor has the same number of dimensions as `input`,
|
|
3096
|
-
with the size of the `dim` dimension being equal to the length of `index`, and the size of all other
|
|
3097
|
-
dimensions will be unchanged from the original `input` Tensor.
|
|
3098
|
-
|
|
3099
|
-
.. note::
|
|
3100
|
-
The value of index must be in the range of `[0, input.shape[dim])`, the result is undefined out of range.
|
|
3101
|
-
|
|
3102
|
-
Args:
|
|
3103
|
-
input (Tensor): The input Tensor.
|
|
3104
|
-
dim (int): The dimension to be indexed.
|
|
3105
|
-
index (Tensor): A 1-D Tensor with the indices.
|
|
3106
|
-
|
|
3107
|
-
Returns:
|
|
3108
|
-
Tensor, has the same dtype as input Tensor.
|
|
3109
|
-
|
|
3110
|
-
Raises:
|
|
3111
|
-
TypeError: If `input` or `index` is not a Tensor.
|
|
3112
|
-
TypeError: If `dim` is not int number.
|
|
3113
|
-
ValueError: If the value of `dim` is out the range of `[-input.ndim, input.ndim - 1]`.
|
|
3114
|
-
ValueError: If the dimension of `index` is not equal to 1.
|
|
3115
|
-
|
|
3116
|
-
Supported Platforms:
|
|
3117
|
-
``Ascend``
|
|
3118
|
-
|
|
3119
|
-
Examples:
|
|
3120
|
-
>>> import mindspore
|
|
3121
|
-
>>> from mindspore import Tensor, ops
|
|
3122
|
-
>>> import numpy as np
|
|
3123
|
-
>>> input = Tensor(np.arange(16).astype(np.float32).reshape(2, 2, 4))
|
|
3124
|
-
>>> print(input)
|
|
3125
|
-
[[[ 0. 1. 2. 3.]
|
|
3126
|
-
[ 4. 5. 6. 7.]]
|
|
3127
|
-
[[ 8. 9. 10. 11.]
|
|
3128
|
-
[12. 13. 14. 15.]]]
|
|
3129
|
-
>>> index = Tensor([0,], mindspore.int32)
|
|
3130
|
-
>>> y = ops.auto_generate.index_select_ext(input, 1, index)
|
|
3131
|
-
>>> print(y)
|
|
3132
|
-
[[[ 0. 1. 2. 3.]]
|
|
3133
|
-
[[ 8. 9. 10. 11.]]]
|
|
3134
|
-
"""
|
|
3135
|
-
return index_select_op(input, dim, index)
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
2802
|
def irfft(input, n=None, dim=-1, norm=None):
|
|
3139
2803
|
r"""
|
|
3140
2804
|
Calculates the inverse of `rfft()`.
|
|
@@ -3233,9 +2897,9 @@ def leaky_relu_ext(input, negative_slope=0.01):
|
|
|
3233
2897
|
|
|
3234
2898
|
.. math::
|
|
3235
2899
|
\text{leaky_relu}(input) = \begin{cases}input, &\text{if } input \geq 0; \cr
|
|
3236
|
-
\
|
|
2900
|
+
{\negative_slope} * input, &\text{otherwise.}\end{cases}
|
|
3237
2901
|
|
|
3238
|
-
where :math
|
|
2902
|
+
where :math:`\negative_slope` represents the `negative_slope` parameter.
|
|
3239
2903
|
|
|
3240
2904
|
For more details, see `Rectifier Nonlinearities Improve Neural Network Acoustic Models
|
|
3241
2905
|
<https://ai.stanford.edu/~amaas/papers/relu_hybrid_icml2013_final.pdf>`_.
|
|
@@ -3258,14 +2922,14 @@ def leaky_relu_ext(input, negative_slope=0.01):
|
|
|
3258
2922
|
TypeError: If `negative_slope` is not a float or an int.
|
|
3259
2923
|
|
|
3260
2924
|
Supported Platforms:
|
|
3261
|
-
``Ascend``
|
|
2925
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
3262
2926
|
|
|
3263
2927
|
Examples:
|
|
3264
2928
|
>>> import mindspore
|
|
3265
2929
|
>>> import numpy as np
|
|
3266
2930
|
>>> from mindspore import Tensor, ops
|
|
3267
2931
|
>>> input = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
|
|
3268
|
-
>>> print(
|
|
2932
|
+
>>> print(mint.leaky_relu(input, negative_slope=0.2))
|
|
3269
2933
|
[[-0.2 4. -1.6]
|
|
3270
2934
|
[ 2. -1. 9. ]]
|
|
3271
2935
|
"""
|
|
@@ -3297,7 +2961,7 @@ def less_equal(input, other):
|
|
|
3297
2961
|
Tensor, the shape is the same as the one after broadcasting, and the data type is bool.
|
|
3298
2962
|
|
|
3299
2963
|
Raises:
|
|
3300
|
-
TypeError: If neither `input` nor `other` is a Tensor
|
|
2964
|
+
TypeError: If neither `input` nor `other` is a Tensor or number.Number.
|
|
3301
2965
|
|
|
3302
2966
|
Supported Platforms:
|
|
3303
2967
|
``Ascend`` ``GPU`` ``CPU``
|
|
@@ -3549,36 +3213,6 @@ def matrix_exp(input):
|
|
|
3549
3213
|
return matrix_exp_op(input)
|
|
3550
3214
|
|
|
3551
3215
|
|
|
3552
|
-
def matrix_inverse_ext(input):
|
|
3553
|
-
r"""
|
|
3554
|
-
Compute the inverse of the input matrix.
|
|
3555
|
-
|
|
3556
|
-
Args:
|
|
3557
|
-
input (Tensor): A matrix to be calculated. Input `input` must be at least two dimensions, and the size of
|
|
3558
|
-
the last two dimensions must be the same size.
|
|
3559
|
-
|
|
3560
|
-
Returns:
|
|
3561
|
-
Tensor, has the same type and shape as input`.
|
|
3562
|
-
|
|
3563
|
-
Raises:
|
|
3564
|
-
TypeError: If `input` is not a Tensor.
|
|
3565
|
-
ValueError: If the size of the last two dimensions of `input` is not the same.
|
|
3566
|
-
ValueError: If the dimension of `input` is 1.
|
|
3567
|
-
|
|
3568
|
-
Supported Platforms:
|
|
3569
|
-
``Ascend``
|
|
3570
|
-
|
|
3571
|
-
Examples:
|
|
3572
|
-
>>> from mindspore import Tensor, ops
|
|
3573
|
-
>>> from mindspore import dtype as mstype
|
|
3574
|
-
>>> x = Tensor([[1., 2.], [3., 4.]], mstype.float32)
|
|
3575
|
-
>>> print(ops.matrix_inverse_ext(x))
|
|
3576
|
-
[[-2. 1. ]
|
|
3577
|
-
[ 1.5 -0.5]]
|
|
3578
|
-
"""
|
|
3579
|
-
return matrix_inverse_ext_op(input)
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
3216
|
def max_(input):
|
|
3583
3217
|
r"""
|
|
3584
3218
|
Calculates the maximum value of the input tensor.
|
|
@@ -3595,7 +3229,6 @@ def maximum(input, other):
|
|
|
3595
3229
|
Note:
|
|
3596
3230
|
- Inputs of `input` and `other` comply with the implicit type conversion rules to make the data types
|
|
3597
3231
|
consistent.
|
|
3598
|
-
- The input must be two Tensors, or a Tensor and a Scalar.
|
|
3599
3232
|
- When the inputs are two tensors,
|
|
3600
3233
|
dtypes of them cannot be bool at the same time, and the shapes of them could be broadcast.
|
|
3601
3234
|
- When the inputs are one tensor and one scalar,
|
|
@@ -3791,6 +3424,13 @@ def minimum(input, other):
|
|
|
3791
3424
|
return minimum_op(input, other)
|
|
3792
3425
|
|
|
3793
3426
|
|
|
3427
|
+
def moe_finalize_routing(expanded_x, x1, x2=None, bias=None, scales=None, expanded_row_idx=None, expanded_expert_idx=None):
|
|
3428
|
+
r"""
|
|
3429
|
+
|
|
3430
|
+
"""
|
|
3431
|
+
return moe_finalize_routing_op(expanded_x, x1, x2, bias, scales, expanded_row_idx, expanded_expert_idx)
|
|
3432
|
+
|
|
3433
|
+
|
|
3794
3434
|
def mul(input, other):
|
|
3795
3435
|
r"""
|
|
3796
3436
|
Multiplies two tensors element-wise.
|
|
@@ -3926,22 +3566,62 @@ def nextafter(input, other):
|
|
|
3926
3566
|
return next_after_op(input, other)
|
|
3927
3567
|
|
|
3928
3568
|
|
|
3929
|
-
def
|
|
3569
|
+
def nonzero(input):
|
|
3930
3570
|
r"""
|
|
3931
|
-
|
|
3571
|
+
Return a Tensor of the positions of all non-zero values.
|
|
3932
3572
|
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
"""
|
|
3936
|
-
return not_equal_op(input, other)
|
|
3573
|
+
Args:
|
|
3574
|
+
input (Tensor): The input Tensor, its rank should be greater than or eaqual to 1.
|
|
3937
3575
|
|
|
3938
|
-
|
|
3576
|
+
Returns:
|
|
3577
|
+
Tensor, a 2-D Tensor whose data type is int64, containing the positions of all non-zero values of the input.
|
|
3939
3578
|
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3579
|
+
Raises:
|
|
3580
|
+
TypeError: If `input` is not Tensor.
|
|
3581
|
+
ValueError: If dim of `input` equals to 0.
|
|
3943
3582
|
|
|
3944
|
-
|
|
3583
|
+
Supported Platforms:
|
|
3584
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
3585
|
+
|
|
3586
|
+
Examples:
|
|
3587
|
+
>>> import mindspore
|
|
3588
|
+
>>> import numpy as np
|
|
3589
|
+
>>> from mindspore import Tensor
|
|
3590
|
+
>>> import mindspore.ops as ops
|
|
3591
|
+
>>> x = Tensor(np.array([[[1, 0], [-5, 0]]]), mindspore.int32)
|
|
3592
|
+
>>> output = ops.nonzero(x)
|
|
3593
|
+
>>> print(output)
|
|
3594
|
+
[[0 0 0]
|
|
3595
|
+
[0 1 0]]
|
|
3596
|
+
>>> x = Tensor(np.array([1, 0, 2, 0, 3]), mindspore.int32)
|
|
3597
|
+
>>> output = ops.nonzero(x)
|
|
3598
|
+
>>> print(output)
|
|
3599
|
+
[[0]
|
|
3600
|
+
[2]
|
|
3601
|
+
[4]]
|
|
3602
|
+
"""
|
|
3603
|
+
return non_zero_op(input)
|
|
3604
|
+
|
|
3605
|
+
|
|
3606
|
+
def not_equal(input, other):
|
|
3607
|
+
r"""
|
|
3608
|
+
Alias for :func:`mindspore.ops.ne` .
|
|
3609
|
+
|
|
3610
|
+
Supported Platforms:
|
|
3611
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
3612
|
+
"""
|
|
3613
|
+
return not_equal_op(input, other)
|
|
3614
|
+
|
|
3615
|
+
ones_op=Ones()
|
|
3616
|
+
|
|
3617
|
+
def ones(shape, dtype=None):
|
|
3618
|
+
r"""
|
|
3619
|
+
Creates a tensor filled with value ones.
|
|
3620
|
+
|
|
3621
|
+
Creates a tensor with shape described by the first argument and fills it with value ones in type of the second
|
|
3622
|
+
argument.
|
|
3623
|
+
|
|
3624
|
+
.. warning::
|
|
3945
3625
|
For argument `shape`, Tensor type input will be deprecated in the future version.
|
|
3946
3626
|
|
|
3947
3627
|
Args:
|
|
@@ -4170,84 +3850,6 @@ def prelu(x, weight):
|
|
|
4170
3850
|
return prelu_op(x, weight)
|
|
4171
3851
|
|
|
4172
3852
|
|
|
4173
|
-
def prod_ext(input, axis=None, keep_dims=False, dtype=None):
|
|
4174
|
-
r"""
|
|
4175
|
-
Reduces a dimension of a tensor by multiplying all elements in the dimension, by default. And also can
|
|
4176
|
-
reduce a dimension of `input` along the `axis`. Determine whether the dimensions of the output and input are the
|
|
4177
|
-
same by controlling `keep_dims`.
|
|
4178
|
-
|
|
4179
|
-
Args:
|
|
4180
|
-
input (Tensor[Number]): The input tensor. The dtype of the tensor to be reduced is number.
|
|
4181
|
-
:math:`(N, *)` where :math:`*` means, any number of additional dimensions.
|
|
4182
|
-
axis (int): The dimensions to reduce. Default: ``None`` , reduce all dimensions.
|
|
4183
|
-
Only constant value is allowed. Assume the rank of `input` is r, and the value range is [-r,r).
|
|
4184
|
-
keep_dims (bool): If ``True`` , keep these reduced dimensions and the length is 1.
|
|
4185
|
-
If ``False`` , don't keep these dimensions. Default: ``False`` .
|
|
4186
|
-
dtype (:class:`mindspore.dtype`): The desired data type of returned Tensor. Default: ``None`` .
|
|
4187
|
-
|
|
4188
|
-
Returns:
|
|
4189
|
-
Tensor, has the same data type as input tensor.
|
|
4190
|
-
|
|
4191
|
-
- If `axis` is ``None`` , and `keep_dims` is ``False`` ,
|
|
4192
|
-
the output is a 0-D tensor representing the product of all elements in the input tensor.
|
|
4193
|
-
- If `axis` is int, set as 1, and `keep_dims` is ``False`` ,
|
|
4194
|
-
the shape of output is :math:`(input_0, input_2, ..., input_R)`.
|
|
4195
|
-
|
|
4196
|
-
Raises:
|
|
4197
|
-
TypeError: If `input` is not a Tensor.
|
|
4198
|
-
TypeError: If `axis` is not one of the following: int or None.
|
|
4199
|
-
TypeError: If `keep_dims` is not a bool.
|
|
4200
|
-
ValueError: If `axis` is out of range.
|
|
4201
|
-
|
|
4202
|
-
Supported Platforms:
|
|
4203
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
4204
|
-
|
|
4205
|
-
Examples:
|
|
4206
|
-
>>> import mindspore
|
|
4207
|
-
>>> import numpy as np
|
|
4208
|
-
>>> from mindspore import Tensor, ops
|
|
4209
|
-
>>> x = Tensor(np.random.randn(3, 4, 5, 6).astype(np.float32))
|
|
4210
|
-
>>> output = ops.ProdExt()(x, 1, keep_dims=True)
|
|
4211
|
-
>>> result = output.shape
|
|
4212
|
-
>>> print(result)
|
|
4213
|
-
(3, 1, 5, 6)
|
|
4214
|
-
>>> # case 1: Reduces a dimension by multiplying all elements in the dimension.
|
|
4215
|
-
>>> x = Tensor(np.array([[[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3]],
|
|
4216
|
-
... [[4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]],
|
|
4217
|
-
... [[7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9]]]), mindspore.float32)
|
|
4218
|
-
>>> output = ops.ProdExt()(x)
|
|
4219
|
-
>>> print(output)
|
|
4220
|
-
2.2833798e+33
|
|
4221
|
-
>>> print(output.shape)
|
|
4222
|
-
()
|
|
4223
|
-
>>> # case 2: Reduces a dimension along axis 0.
|
|
4224
|
-
>>> output = ops.ProdExt()(x, 0, True)
|
|
4225
|
-
>>> print(output)
|
|
4226
|
-
[[[ 28. 28. 28. 28. 28. 28.]
|
|
4227
|
-
[ 80. 80. 80. 80. 80. 80.]
|
|
4228
|
-
[162. 162. 162. 162. 162. 162.]]]
|
|
4229
|
-
>>> # case 3: Reduces a dimension along axis 1.
|
|
4230
|
-
>>> output = ops.ProdExt()(x, 1, True)
|
|
4231
|
-
>>> print(output)
|
|
4232
|
-
[[[ 6. 6. 6. 6. 6. 6.]]
|
|
4233
|
-
[[120. 120. 120. 120. 120. 120.]]
|
|
4234
|
-
[[504. 504. 504. 504. 504. 504.]]]
|
|
4235
|
-
>>> # case 4: Reduces a dimension along axis 2.
|
|
4236
|
-
>>> output = ops.ProdExt()(x, 2, True)
|
|
4237
|
-
>>> print(output)
|
|
4238
|
-
[[[1.00000e+00]
|
|
4239
|
-
[6.40000e+01]
|
|
4240
|
-
[7.29000e+02]]
|
|
4241
|
-
[[4.09600e+03]
|
|
4242
|
-
[1.56250e+04]
|
|
4243
|
-
[4.66560e+04]]
|
|
4244
|
-
[[1.17649e+05]
|
|
4245
|
-
[2.62144e+05]
|
|
4246
|
-
[5.31441e+05]]]
|
|
4247
|
-
"""
|
|
4248
|
-
return prod_ext_op(input, axis, keep_dims, dtype)
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
3853
|
def prompt_k_v_cache(cache, update, valid_seq_len, batch_index, seq_len_axis, new_max_seq_len, cur_max_seq_len, align_mode='LEFT'):
|
|
4252
3854
|
r"""
|
|
4253
3855
|
The PromptKVCache is used for prefill the KVCache of transformer network.
|
|
@@ -4307,6 +3909,13 @@ def prompt_k_v_cache(cache, update, valid_seq_len, batch_index, seq_len_axis, ne
|
|
|
4307
3909
|
return prompt_k_v_cache_op(cache, update, valid_seq_len, batch_index, seq_len_axis, new_max_seq_len, cur_max_seq_len)
|
|
4308
3910
|
|
|
4309
3911
|
|
|
3912
|
+
def quant_batch_matmul(x1, x2, scale, offset=None, bias=None, transpose_x1=False, transpose_x2=False, dtype=mstype.float16):
|
|
3913
|
+
r"""
|
|
3914
|
+
|
|
3915
|
+
"""
|
|
3916
|
+
return quant_batch_matmul_impl(x1, x2, scale, offset, bias, transpose_x1, transpose_x2, dtype)
|
|
3917
|
+
|
|
3918
|
+
|
|
4310
3919
|
def randperm(n, seed=0, offset=0, dtype=mstype.int64):
|
|
4311
3920
|
r"""
|
|
4312
3921
|
Generates random permutation of integers from 0 to n-1.
|
|
@@ -4572,6 +4181,13 @@ def relu(input):
|
|
|
4572
4181
|
return relu_op(input)
|
|
4573
4182
|
|
|
4574
4183
|
|
|
4184
|
+
def repeat_interleave(input, repeats, axis=None, output_size=None):
|
|
4185
|
+
r"""
|
|
4186
|
+
|
|
4187
|
+
"""
|
|
4188
|
+
return repeat_interleave_op(input, repeats, axis, output_size)
|
|
4189
|
+
|
|
4190
|
+
|
|
4575
4191
|
def reshape_and_cache(key, value, key_cache, value_cache, slot_mapping):
|
|
4576
4192
|
r"""
|
|
4577
4193
|
The ReshapeAndCache is used for updating the block-wise KVCache of transformer network.
|
|
@@ -4746,55 +4362,6 @@ def rfft(input, n=None, dim=-1, norm=None):
|
|
|
4746
4362
|
return rfft_op(input, n, dim, norm)
|
|
4747
4363
|
|
|
4748
4364
|
|
|
4749
|
-
def rms_norm(x, gamma, epsilon=1e-6):
|
|
4750
|
-
r"""
|
|
4751
|
-
The RmsNorm(Root Mean Square Layer Normalization) operator is a normalization operation. Compared to
|
|
4752
|
-
LayerNorm, it retains scaling invariance and removes translation invariance. Its formula is:
|
|
4753
|
-
|
|
4754
|
-
.. math::
|
|
4755
|
-
y=\frac{x_i}{\sqrt{\frac{1}{n}}\sum_{i=1}^{n}{ x_i^2}+\varepsilon }\gamma_i
|
|
4756
|
-
|
|
4757
|
-
.. warning::
|
|
4758
|
-
This is an experimental API that is subject to change or deletion. This API is only supported in Atlas A2
|
|
4759
|
-
training series for now.
|
|
4760
|
-
|
|
4761
|
-
Args:
|
|
4762
|
-
x (Tensor): Input data of RmsNorm. Support data type: float16, float32, bfloat16.
|
|
4763
|
-
gamma (Tensor): Learnable parameter :math:`\gamma` . Support data type: float16, float32, bfloat16.
|
|
4764
|
-
epsilon (float, optional): A float number ranged in (0, 1] to prevent division by 0. Default value is `1e-6`.
|
|
4765
|
-
|
|
4766
|
-
Returns:
|
|
4767
|
-
- Tensor, denotes the normalized result, has the same type and shape as `x`.
|
|
4768
|
-
- Tensor, with the float data type, denotes the reciprocal of the input standard deviation, used by gradient
|
|
4769
|
-
calculation.
|
|
4770
|
-
|
|
4771
|
-
Raises:
|
|
4772
|
-
TypeError: If data type of `x` is not one of the following: float16, float32, bfloat16.
|
|
4773
|
-
TypeError: If data type of `gamma` is not one of the following: float16, float32, bfloat16.
|
|
4774
|
-
TypeError: If data type of `x` is not the same with the data type of `gamma`.
|
|
4775
|
-
ValueError: If `epsilon` is not a float between 0 and 1.
|
|
4776
|
-
ValueError: If the rank of `gamma` is lagger than the rank of `x`.
|
|
4777
|
-
|
|
4778
|
-
Supported Platforms:
|
|
4779
|
-
``Ascend``
|
|
4780
|
-
|
|
4781
|
-
Examples:
|
|
4782
|
-
>>> import mindspore
|
|
4783
|
-
>>> import numpy as np
|
|
4784
|
-
>>> from mindspore import Tensor, ops
|
|
4785
|
-
>>> x = Tensor(np.array([[1, 2, 3], [1, 2, 3]]), mindspore.float32)
|
|
4786
|
-
>>> gamma = Tensor(np.ones([3]), mindspore.float32)
|
|
4787
|
-
>>> y, rstd = ops.rms_norm(x, gamma)
|
|
4788
|
-
>>> print(y)
|
|
4789
|
-
[[0.46290997 0.92581993 1.3887299]
|
|
4790
|
-
[0.46290997 0.92581993 1.3887299]]
|
|
4791
|
-
>>> print(rstd)
|
|
4792
|
-
[[0.46290997]
|
|
4793
|
-
[0.46290997]]
|
|
4794
|
-
"""
|
|
4795
|
-
return rms_norm_impl(x, gamma, epsilon)
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
4365
|
def round(input):
|
|
4799
4366
|
r"""
|
|
4800
4367
|
Returns half to even of a tensor element-wise.
|
|
@@ -4854,7 +4421,7 @@ def rsqrt(input):
|
|
|
4854
4421
|
>>> input = ms.Tensor([-0.0370, 0.2970, 1.5420, -0.9105])
|
|
4855
4422
|
>>> output = ops.rsqrt(input)
|
|
4856
4423
|
>>> print(output)
|
|
4857
|
-
[ nan 1.8349396 0.
|
|
4424
|
+
[ nan 1.8349396 0.80530024 nan]
|
|
4858
4425
|
"""
|
|
4859
4426
|
return rsqrt_op(input)
|
|
4860
4427
|
|
|
@@ -5120,47 +4687,6 @@ def sigmoid(input):
|
|
|
5120
4687
|
return sigmoid_op(input)
|
|
5121
4688
|
|
|
5122
4689
|
|
|
5123
|
-
def sign(input):
|
|
5124
|
-
r"""
|
|
5125
|
-
Returns an element-wise indication of the sign of a number. Notice: When the input dtype is float64, the gradient of this operator is NaN.
|
|
5126
|
-
|
|
5127
|
-
.. math::
|
|
5128
|
-
\text{out}_{i} = \begin{cases}
|
|
5129
|
-
-1 & \text{input}_{i} < 0 \\
|
|
5130
|
-
0 & \text{input}_{i} = 0 \\
|
|
5131
|
-
1 & \text{input}_{i} > 0
|
|
5132
|
-
\end{cases}
|
|
5133
|
-
|
|
5134
|
-
Args:
|
|
5135
|
-
input (Tensor): Input Tensor.
|
|
5136
|
-
|
|
5137
|
-
Returns:
|
|
5138
|
-
Tensor, the sign of input.
|
|
5139
|
-
|
|
5140
|
-
Raises:
|
|
5141
|
-
TypeError: If `input` is not a Tensor.
|
|
5142
|
-
|
|
5143
|
-
Supported Platforms:
|
|
5144
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
5145
|
-
|
|
5146
|
-
Examples:
|
|
5147
|
-
>>> import mindspore as ms
|
|
5148
|
-
>>> import mindspore.ops as ops
|
|
5149
|
-
>>> input = ms.Tensor([[-1, 0, 2, 4, 6], [2, 3, 5, -6, 0]])
|
|
5150
|
-
>>> output = ops.sign(input)
|
|
5151
|
-
>>> print(output)
|
|
5152
|
-
[[-1 0 1 1 1]
|
|
5153
|
-
[ 1 1 1 -1 0]]
|
|
5154
|
-
>>> ms.set_context(device_target="CPU")
|
|
5155
|
-
>>> x = ms.Tensor([[-1, 0, float('inf'), 4, float('nan')], [2, 3, float('-inf'), -6, 0]])
|
|
5156
|
-
>>> output = ops.sign(x)
|
|
5157
|
-
>>> print(output)
|
|
5158
|
-
[[-1. 0. 1. 1. 0.]
|
|
5159
|
-
[ 1. 1. -1. -1. 0.]]
|
|
5160
|
-
"""
|
|
5161
|
-
return sign_op(input)
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
4690
|
def silu(input):
|
|
5165
4691
|
r"""
|
|
5166
4692
|
Computes Sigmoid Linear Unit of input element-wise. The SiLU function is defined as:
|
|
@@ -5222,10 +4748,10 @@ def sin(input):
|
|
|
5222
4748
|
The dtype of output is float32 when dtype of `input` is in
|
|
5223
4749
|
[bool, int8, uint8, int16, int32, int64]. Otherwise output has the same dtype as the `input`.
|
|
5224
4750
|
|
|
5225
|
-
:
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
4751
|
+
Raises:
|
|
4752
|
+
TypeError: If `input` is not a Tensor.
|
|
4753
|
+
TypeError: On CPU or GPU: If dtype of `input` is not float16, float32 or float64, complex64, complex128.
|
|
4754
|
+
On Ascend: If type of `input` is not bool, int8, uint8, int16, int32, int64, float16, float32 or float64, complex64, complex128.
|
|
5229
4755
|
|
|
5230
4756
|
Supported Platforms:
|
|
5231
4757
|
``Ascend`` ``GPU`` ``CPU``
|
|
@@ -5237,7 +4763,7 @@ def sin(input):
|
|
|
5237
4763
|
>>> input = Tensor(np.array([0.62, 0.28, 0.43, 0.62]), mindspore.float32)
|
|
5238
4764
|
>>> output = ops.sin(input)
|
|
5239
4765
|
>>> print(output)
|
|
5240
|
-
[0.
|
|
4766
|
+
[0.5810352 0.27635565 0.41687083 0.5810352]
|
|
5241
4767
|
"""
|
|
5242
4768
|
return sin_op(input)
|
|
5243
4769
|
|
|
@@ -5309,42 +4835,7 @@ def sinh(input):
|
|
|
5309
4835
|
|
|
5310
4836
|
def softplus_ext(input, beta=1, threshold=20):
|
|
5311
4837
|
r"""
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
The softplus function is shown as follows, x is the element of `input` :
|
|
5315
|
-
|
|
5316
|
-
.. math::
|
|
5317
|
-
|
|
5318
|
-
\text{output} = \frac{1}{beta}\log(1 + \exp(\text{beta * x}))
|
|
5319
|
-
|
|
5320
|
-
where :math:`input * beta > threshold`, the implementation converts to the linear function to ensure numerical stability.
|
|
5321
|
-
|
|
5322
|
-
Args:
|
|
5323
|
-
input (Tensor): Tensor of any dimension. Supported dtypes:
|
|
5324
|
-
|
|
5325
|
-
- Ascend: float16, float32, bfloat16.
|
|
5326
|
-
beta (number.Number, optional): Scaling parameters in the softplus function. Default: ``1`` .
|
|
5327
|
-
threshold (number.Number, optional): For numerical stability, the softplus function is converted
|
|
5328
|
-
to a threshold parameter of a linear function. Default: ``20`` .
|
|
5329
|
-
|
|
5330
|
-
Returns:
|
|
5331
|
-
Tensor, with the same type and shape as the input.
|
|
5332
|
-
|
|
5333
|
-
Raises:
|
|
5334
|
-
TypeError: If `input` is not a Tensor.
|
|
5335
|
-
TypeError: If dtype of `input` is not float16, float32, bfloat16.
|
|
5336
|
-
|
|
5337
|
-
Supported Platforms:
|
|
5338
|
-
``Ascend``
|
|
5339
|
-
|
|
5340
|
-
Examples:
|
|
5341
|
-
>>> import mindspore
|
|
5342
|
-
>>> import numpy as np
|
|
5343
|
-
>>> from mindspore import Tensor, ops
|
|
5344
|
-
>>> input = Tensor(np.array([0.1, 0.2, 30, 25]), mindspore.float32)
|
|
5345
|
-
>>> output = ops.auto_generate.softplus_ext(input)
|
|
5346
|
-
>>> print(output)
|
|
5347
|
-
[0.74439657 0.7981388 30. 25.]
|
|
4838
|
+
|
|
5348
4839
|
"""
|
|
5349
4840
|
return softplus_ext_op(input, beta, threshold)
|
|
5350
4841
|
|
|
@@ -5406,13 +4897,6 @@ def solve_triangular(a, b, trans=0, lower=False, unit_diagonal=False):
|
|
|
5406
4897
|
return solve_triangular_op(a, b, trans, lower, unit_diagonal)
|
|
5407
4898
|
|
|
5408
4899
|
|
|
5409
|
-
def sort_ext(input, dim=-1, descending=False, stable=False):
|
|
5410
|
-
r"""
|
|
5411
|
-
|
|
5412
|
-
"""
|
|
5413
|
-
return sort_ext_op(input, dim, descending, stable)
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
4900
|
def sqrt(x):
|
|
5417
4901
|
r"""
|
|
5418
4902
|
Returns sqrt of a tensor element-wise.
|
|
@@ -5496,22 +4980,23 @@ def stack_ext(tensors, dim=0):
|
|
|
5496
4980
|
|
|
5497
4981
|
Raises:
|
|
5498
4982
|
TypeError: If the data types of elements in `tensors` are not the same.
|
|
5499
|
-
ValueError: If `
|
|
4983
|
+
ValueError: If the length of `tensors` is not greater than zero;
|
|
4984
|
+
or if dim is out of the range [-(R+1), R+1);
|
|
5500
4985
|
or if the shapes of elements in tensors are not the same.
|
|
5501
4986
|
|
|
5502
4987
|
Supported Platforms:
|
|
5503
|
-
``Ascend``
|
|
4988
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
5504
4989
|
|
|
5505
4990
|
Examples:
|
|
5506
4991
|
>>> import mindspore
|
|
5507
|
-
>>> from mindspore import Tensor,
|
|
4992
|
+
>>> from mindspore import Tensor, mint
|
|
5508
4993
|
>>> import numpy as np
|
|
5509
4994
|
>>> data1 = Tensor(np.array([0, 1]).astype(np.float32))
|
|
5510
4995
|
>>> data2 = Tensor(np.array([2, 3]).astype(np.float32))
|
|
5511
|
-
>>> output =
|
|
4996
|
+
>>> output = mint.stack([data1, data2], 0)
|
|
5512
4997
|
>>> print(output)
|
|
5513
4998
|
[[0. 1.]
|
|
5514
|
-
|
|
4999
|
+
[2. 3.]]
|
|
5515
5000
|
"""
|
|
5516
5001
|
return stack_ext_impl(tensors, dim)
|
|
5517
5002
|
|
|
@@ -5703,7 +5188,7 @@ def sub_ext(input, other, alpha=1):
|
|
|
5703
5188
|
alpha (number.Number): A scaling factor applied to `other`, default 1.
|
|
5704
5189
|
|
|
5705
5190
|
Returns:
|
|
5706
|
-
Tensor
|
|
5191
|
+
Tensor, the shape is the same as the one of the input `input`, `other` after broadcasting,
|
|
5707
5192
|
and the data type is the one with higher precision or higher digits among the two inputs and alpha.
|
|
5708
5193
|
|
|
5709
5194
|
Raises:
|
|
@@ -5718,11 +5203,11 @@ def sub_ext(input, other, alpha=1):
|
|
|
5718
5203
|
>>> import numpy as np
|
|
5719
5204
|
>>> import mindspore
|
|
5720
5205
|
>>> from mindspore import Tensor
|
|
5721
|
-
>>> from mindspore import
|
|
5206
|
+
>>> from mindspore.ops.extend import sub
|
|
5722
5207
|
>>> x = Tensor(np.array([4, 5, 6]).astype(np.float32))
|
|
5723
5208
|
>>> y = Tensor(1, mindspore.int32)
|
|
5724
5209
|
>>> alpha = 0.5
|
|
5725
|
-
>>> output =
|
|
5210
|
+
>>> output = sub(x, y, alpha)
|
|
5726
5211
|
>>> print(output)
|
|
5727
5212
|
[3.5 4.5 5.5]
|
|
5728
5213
|
>>> # the data type of x is float32, the data type of y is int32,
|
|
@@ -5757,7 +5242,7 @@ def sub(input, other):
|
|
|
5757
5242
|
the second input should be a number.Number or bool value, or a Tensor whose data type is number or bool.
|
|
5758
5243
|
|
|
5759
5244
|
Returns:
|
|
5760
|
-
Tensor
|
|
5245
|
+
Tensor, the shape is the same as the one after broadcasting,
|
|
5761
5246
|
and the data type is the one with higher precision or higher digits among the two inputs.
|
|
5762
5247
|
|
|
5763
5248
|
Raises:
|
|
@@ -5820,97 +5305,11 @@ def tanh(input):
|
|
|
5820
5305
|
|
|
5821
5306
|
def topk_ext(input, k, dim=-1, largest=True, sorted=True):
|
|
5822
5307
|
r"""
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
.. warning::
|
|
5826
|
-
- If sorted is set to False, due to different memory layout and traversal methods on different platforms,
|
|
5827
|
-
the display order of calculation results may be inconsistent when `sorted` is False.
|
|
5828
|
-
|
|
5829
|
-
If the `input` is a one-dimensional Tensor, finds the `k` largest or smallest entries in the Tensor,
|
|
5830
|
-
and outputs its value and index as a Tensor. values[`k`] is the `k` largest item in `input`,
|
|
5831
|
-
and its index is indices [`k`].
|
|
5832
|
-
|
|
5833
|
-
For a multi-dimensional matrix,
|
|
5834
|
-
calculates the first or last `k` entries in a given dimension, therefore:
|
|
5835
|
-
|
|
5836
|
-
.. math::
|
|
5837
|
-
|
|
5838
|
-
values.shape = indices.shape
|
|
5839
|
-
|
|
5840
|
-
If the two compared elements are the same, the one with the smaller index value is returned first.
|
|
5841
|
-
|
|
5842
|
-
Args:
|
|
5843
|
-
input (Tensor): Input to be computed.
|
|
5844
|
-
k (int): The number of top or bottom elements to be computed along the last dimension.
|
|
5845
|
-
dim (int, optional): The dimension to sort along. Default: ``-1`` .
|
|
5846
|
-
largest (bool, optional): If largest is ``False`` then the k smallest elements are returned.
|
|
5847
|
-
Default: ``True`` .
|
|
5848
|
-
sorted (bool, optional): If ``True`` , the obtained elements will be sorted by the values in descending
|
|
5849
|
-
order or ascending order according to `largest`. If ``False`` , the obtained elements will not be
|
|
5850
|
-
sorted. Default: ``True`` .
|
|
5851
|
-
|
|
5852
|
-
Returns:
|
|
5853
|
-
A tuple consisting of `values` and `indices`.
|
|
5854
|
-
|
|
5855
|
-
- values (Tensor) - The `k` largest or smallest elements in each slice of the given dimension.
|
|
5856
|
-
- indices (Tensor) - The indices of values within the last dimension of input.
|
|
5857
|
-
|
|
5858
|
-
Raises:
|
|
5859
|
-
TypeError: If `sorted` is not a bool.
|
|
5860
|
-
TypeError: If `input` is not a Tensor.
|
|
5861
|
-
TypeError: If `k` is not an int.
|
|
5862
|
-
|
|
5863
|
-
Supported Platforms:
|
|
5864
|
-
``Ascend``
|
|
5865
|
-
|
|
5866
|
-
Examples:
|
|
5867
|
-
>>> import mindspore as ms
|
|
5868
|
-
>>> from mindspore import ops
|
|
5869
|
-
>>> x = ms.Tensor([[0.5368, 0.2447, 0.4302, 0.9673],
|
|
5870
|
-
... [0.4388, 0.6525, 0.4685, 0.1868],
|
|
5871
|
-
... [0.3563, 0.5152, 0.9675, 0.8230]], dtype=ms.float32)
|
|
5872
|
-
>>> output = ops.topk_ext(x, 2, dim=1)
|
|
5873
|
-
>>> print(output)
|
|
5874
|
-
(Tensor(shape=[3, 2], dtype=Float32, value=
|
|
5875
|
-
[[ 9.67299998e-01, 5.36800027e-01],
|
|
5876
|
-
[ 6.52499974e-01, 4.68499988e-01],
|
|
5877
|
-
[ 9.67499971e-01, 8.23000014e-01]]), Tensor(shape=[3, 2], dtype=Int32, value=
|
|
5878
|
-
[[3, 0],
|
|
5879
|
-
[1, 2],
|
|
5880
|
-
[2, 3]]))
|
|
5881
|
-
>>> output2 = ops.topk_ext(x, 2, dim=1, largest=False)
|
|
5882
|
-
>>> print(output2)
|
|
5883
|
-
(Tensor(shape=[3, 2], dtype=Float32, value=
|
|
5884
|
-
[[ 2.44700000e-01, 4.30200011e-01],
|
|
5885
|
-
[ 1.86800003e-01, 4.38800007e-01],
|
|
5886
|
-
[ 3.56299996e-01, 5.15200019e-01]]), Tensor(shape=[3, 2], dtype=Int32, value=
|
|
5887
|
-
[[1, 2],
|
|
5888
|
-
[3, 0],
|
|
5889
|
-
[0, 1]]))
|
|
5308
|
+
|
|
5890
5309
|
"""
|
|
5891
5310
|
return topk_ext_op(input, k, dim, largest, sorted)
|
|
5892
5311
|
|
|
5893
5312
|
|
|
5894
|
-
def topkrouter(input, capacity, expert_num):
|
|
5895
|
-
r"""
|
|
5896
|
-
TopkRouter implementation in MOE.
|
|
5897
|
-
|
|
5898
|
-
Inputs:
|
|
5899
|
-
- **x** (Tensor) - Input Tensor of 3D, Supporting types:[int32, int64]
|
|
5900
|
-
- **capacity** (Int64) - The maximum number of tokens each expert can handle
|
|
5901
|
-
- **expert_num** (Int64) - The number of expert.
|
|
5902
|
-
|
|
5903
|
-
Outputs:
|
|
5904
|
-
tuple(Tensor), tuple of 2 tensors, `dispatch_index` and `combine_inex`.
|
|
5905
|
-
- dispatch_index (Tensor) - Token ID processed by each expert.
|
|
5906
|
-
- combine_index (Tensor) - The combine index of each token.
|
|
5907
|
-
|
|
5908
|
-
Supported Platforms:
|
|
5909
|
-
``Ascend``
|
|
5910
|
-
"""
|
|
5911
|
-
return topkrouter_op(input, capacity, expert_num)
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
5313
|
def trace(input):
|
|
5915
5314
|
r"""
|
|
5916
5315
|
Returns a new tensor that is the sum of the `input` main trace.
|
|
@@ -6002,6 +5401,66 @@ def transpose(input, input_perm):
|
|
|
6002
5401
|
return transpose_op(input, input_perm)
|
|
6003
5402
|
|
|
6004
5403
|
|
|
5404
|
+
def tril(input, diagonal=0):
|
|
5405
|
+
r"""
|
|
5406
|
+
Returns the lower triangle part of 'input' (elements that contain the diagonal and below),
|
|
5407
|
+
and set the other elements to zeros.
|
|
5408
|
+
|
|
5409
|
+
Args:
|
|
5410
|
+
input (Tensor): A Tensor with shape :math:`(x_1, x_2, ..., x_R)`. The rank must be at least 2.
|
|
5411
|
+
Supporting all number types including bool.
|
|
5412
|
+
diagonal (int, optional): An optional attribute indicates the diagonal to consider, default: 0,
|
|
5413
|
+
indicating the main diagonal.
|
|
5414
|
+
|
|
5415
|
+
Returns:
|
|
5416
|
+
Tensor, the same shape and data type as the input `x`.
|
|
5417
|
+
|
|
5418
|
+
Raises:
|
|
5419
|
+
TypeError: If `x` is not a Tensor.
|
|
5420
|
+
TypeError: If `diagonal` is not an int.
|
|
5421
|
+
TypeError: If the type of `x` is neither number nor bool.
|
|
5422
|
+
ValueError: If the rank of `x` is less than 2.
|
|
5423
|
+
|
|
5424
|
+
Supported Platforms:
|
|
5425
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
5426
|
+
|
|
5427
|
+
Examples:
|
|
5428
|
+
>>> import numpy as np
|
|
5429
|
+
>>> from mindspore import Tensor, ops
|
|
5430
|
+
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
|
5431
|
+
... [ 5, 6, 7, 8],
|
|
5432
|
+
... [10, 11, 12, 13],
|
|
5433
|
+
... [14, 15, 16, 17]]))
|
|
5434
|
+
>>> result = ops.tril(x)
|
|
5435
|
+
>>> print(result)
|
|
5436
|
+
[[ 1 0 0 0]
|
|
5437
|
+
[ 5 6 0 0]
|
|
5438
|
+
[10 11 12 0]
|
|
5439
|
+
[14 15 16 17]]
|
|
5440
|
+
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
|
5441
|
+
... [ 5, 6, 7, 8],
|
|
5442
|
+
... [10, 11, 12, 13],
|
|
5443
|
+
... [14, 15, 16, 17]]))
|
|
5444
|
+
>>> result = ops.tril(x, diagonal=1)
|
|
5445
|
+
>>> print(result)
|
|
5446
|
+
[[ 1 2 0 0]
|
|
5447
|
+
[ 5 6 7 0]
|
|
5448
|
+
[10 11 12 13]
|
|
5449
|
+
[14 15 16 17]]
|
|
5450
|
+
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
|
5451
|
+
... [ 5, 6, 7, 8],
|
|
5452
|
+
... [10, 11, 12, 13],
|
|
5453
|
+
... [14, 15, 16, 17]]))
|
|
5454
|
+
>>> result = ops.tril(x, diagonal=-1)
|
|
5455
|
+
>>> print(result)
|
|
5456
|
+
[[ 0 0 0 0]
|
|
5457
|
+
[ 5 0 0 0]
|
|
5458
|
+
[10 11 0 0]
|
|
5459
|
+
[14 15 16 0]]
|
|
5460
|
+
"""
|
|
5461
|
+
return tril_impl(input, diagonal)
|
|
5462
|
+
|
|
5463
|
+
|
|
6005
5464
|
def triu(input, diagonal=0):
|
|
6006
5465
|
r"""
|
|
6007
5466
|
Returns the upper triangle part of 'input' (elements that contain the diagonal and below),
|
|
@@ -6151,11 +5610,18 @@ def view(input, shape):
|
|
|
6151
5610
|
"""
|
|
6152
5611
|
return view_op(input, shape)
|
|
6153
5612
|
|
|
5613
|
+
|
|
5614
|
+
def weight_quant_batch_matmul(x, weight, antiquant_scale, antiquant_offset=None, quant_scale=None, quant_offset=None, bias=None, transpose_x=False, transpose_weight=False, antiquant_group_size=0):
|
|
5615
|
+
r"""
|
|
5616
|
+
|
|
5617
|
+
"""
|
|
5618
|
+
return weight_quant_batch_matmul_impl(x, weight, antiquant_scale, antiquant_offset, quant_scale, quant_offset, bias, transpose_x, transpose_weight, antiquant_group_size)
|
|
5619
|
+
|
|
6154
5620
|
zeros_op=Zeros()
|
|
6155
5621
|
|
|
6156
5622
|
def zeros(size, dtype=None):
|
|
6157
5623
|
r"""
|
|
6158
|
-
Creates a tensor filled with
|
|
5624
|
+
Creates a tensor filled with 0 with shape described by `size` and fills it with value 0 in type of `dtype`.
|
|
6159
5625
|
|
|
6160
5626
|
.. warning::
|
|
6161
5627
|
For argument `size`, Tensor type input will be deprecated in the future version.
|
|
@@ -6185,259 +5651,3 @@ def zeros(size, dtype=None):
|
|
|
6185
5651
|
[0. 0.]]
|
|
6186
5652
|
"""
|
|
6187
5653
|
return zeros_op(size, dtype)
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
def grouped_matmul(x, weight, bias=None, scale=None, offset=None, antiquant_scale=None, antiquant_offset=None, group_list=None, split_item=0, group_type=-1):
|
|
6191
|
-
r"""
|
|
6192
|
-
Group calculation matmul.
|
|
6193
|
-
|
|
6194
|
-
** Non-Quant: **
|
|
6195
|
-
|
|
6196
|
-
.. math::
|
|
6197
|
-
y_i = x_i\times weight_i + bias_i
|
|
6198
|
-
|
|
6199
|
-
** Antiquant-Quant: **
|
|
6200
|
-
|
|
6201
|
-
.. math::
|
|
6202
|
-
y_i = x_i\times (weight_i + antiquant\_offset_i) * antiquant\_scale_i + bias_i
|
|
6203
|
-
|
|
6204
|
-
Args:
|
|
6205
|
-
split_item (int): Splitting input mode. Only support 0 and 3. 0 represents multiple Tensors, and 3 represents a single Tensor.
|
|
6206
|
-
group_type (int): The axis to be split. Only support -1 and 0. If the matrix is multiplied by A[m,k]xB[k,n]=C[m,n].
|
|
6207
|
-
-1: No grouping, 0: Group on the m-axis
|
|
6208
|
-
|
|
6209
|
-
Inputs:
|
|
6210
|
-
x (TensorList): TensorList, including 2D-6D Tensors. Supported dtypes: Float16, Float32.
|
|
6211
|
-
The shape of the tensor in tensorlist is :math:`(M, N)` or :math:`(..., M, N)`.
|
|
6212
|
-
weight (TensorList): TensorList, include 2D-3D Tensors. Supported dtypes: Float16, Float32, int8.
|
|
6213
|
-
The shape of the tensor in tensorlist is :math:`(N, K)` or :math:`(E, N, K)`.
|
|
6214
|
-
bias (TensorList, optional): TensorList, include 1D-2D Tensors. Supported dtypes: Float16, Float32. If not used, None.
|
|
6215
|
-
Length is the same as the weight length. The shape of the tensor is :math:`(N)` or :math:`(E, N)`.
|
|
6216
|
-
scale (TensorList, optional): TensorList, scale factor of quant(A8W8) parameters. Supported dtypes: Unit64.
|
|
6217
|
-
Length is the same as the weight length. Currently not supported, use None.
|
|
6218
|
-
offset (TensorList, optional): TensorList, offset of quant(A8W8) parameters. Supported dtypes: Float32.
|
|
6219
|
-
Length is the same as the weight length. Currently not supported, use None.
|
|
6220
|
-
antiquant_scale (TensorList, optional): TensorList, scale factor of antiquant(A16W8) parameters. Supported dtypes: Float16.
|
|
6221
|
-
Length is the same as the weight length. Only use in antiquant. If not used, None.
|
|
6222
|
-
antiquant_offset (TensorList, optional): TensorList, offset factor of antiquant(A16W8) parameters. Supported dtypes: Float16.
|
|
6223
|
-
Length is the same as the weight length. Only use in antiquant. If not used, None.
|
|
6224
|
-
group_list (Tensor, optional): Grouping positions for the M-axis of input x. Supported dtypes: Int64
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
Parameter limitations 1
|
|
6228
|
-
=========== ============ =========== ====================================================================================================
|
|
6229
|
-
split_item group_type group_list notes
|
|
6230
|
-
=========== ============ =========== ====================================================================================================
|
|
6231
|
-
0 -1 None The length of x is n, tensor in x must be 2D-6D. The length of weight is n, tensor in weight must be 2D.
|
|
6232
|
-
3 0 1D Tensor The length of x is 1, tensor in x must be 2D. The length of weight is 1, tensor in weight must be 3D.
|
|
6233
|
-
(group_list.shape)[0] must be equal to (weight.shape)[0]
|
|
6234
|
-
The last number in group_list needs to be equal to the 0th dimension of the shape with weight
|
|
6235
|
-
=========== ============ =========== ====================================================================================================
|
|
6236
|
-
|
|
6237
|
-
Parameter limitations 2
|
|
6238
|
-
Non-quant tyep table
|
|
6239
|
-
========= ========= ========= ========= ========= ================ ================= =========
|
|
6240
|
-
x weight bias scale offset antiquant_scale antiquant_offset y
|
|
6241
|
-
========= ========= ========= ========= ========= ================ ================= =========
|
|
6242
|
-
Float16 Float16 Float16 None None None None Float16
|
|
6243
|
-
========= ========= ========= ========= ========= ================ ================= =========
|
|
6244
|
-
|
|
6245
|
-
Parameter limitations 3
|
|
6246
|
-
Only in split_item=3, group_type=0
|
|
6247
|
-
========= ========= ========= ========= ========= ================ ================= =========
|
|
6248
|
-
x weight bias scale offset antiquant_scale antiquant_offset y
|
|
6249
|
-
========= ========= ========= ========= ========= ================ ================= =========
|
|
6250
|
-
Float32 Float32 Float32 None None None None Float32
|
|
6251
|
-
========= ========= ========= ========= ========= ================ ================= =========
|
|
6252
|
-
|
|
6253
|
-
Outputs:
|
|
6254
|
-
y (TensorList): TensorList, include 2D Tensors. The shape of the tensor is :math:`(M, K)`.
|
|
6255
|
-
|
|
6256
|
-
Raises:
|
|
6257
|
-
TypeError: If `split_item` is not 0 or 3.
|
|
6258
|
-
TypeError: If `group_type` is not -1 or 0.
|
|
6259
|
-
TypeError: when `split_item` is 0, `group_type` is not -1.
|
|
6260
|
-
TypeError: when `split_item` is 3, `group_type` is not 0.
|
|
6261
|
-
TypeError: when `split_item` is 3, `group_list` is None.
|
|
6262
|
-
|
|
6263
|
-
Supported Platforms:
|
|
6264
|
-
``Ascend``
|
|
6265
|
-
|
|
6266
|
-
Examples:
|
|
6267
|
-
>>> import mindspore as ms
|
|
6268
|
-
>>> import numpy as np
|
|
6269
|
-
>>> from mindspore import nn, context
|
|
6270
|
-
>>> from mindspore.ops.auto_generate import GroupedMatmul
|
|
6271
|
-
>>> class Net(nn.Cell):
|
|
6272
|
-
... def __init__(self, split_item=3, group_type=0):
|
|
6273
|
-
... super(Net, self).__init__()
|
|
6274
|
-
... self.gmm = GroupedMatmul(split_item, group_type)
|
|
6275
|
-
...
|
|
6276
|
-
... def construct(self, x, weight, bias, scale, offset, antiquant_scale, antiquant_offset, group_list):
|
|
6277
|
-
... result = self.gmm(x, weight, bias, scale, offset, antiquant_scale, antiquant_offset, group_list)
|
|
6278
|
-
... return result
|
|
6279
|
-
...
|
|
6280
|
-
>>> context.set_context(device_target="Ascend", mode=ms.GRAPH_MODE)
|
|
6281
|
-
>>> x = [ms.Tensor(np.array([[0, 0, 0, 0],
|
|
6282
|
-
... [1, 1, 1, 1],
|
|
6283
|
-
... [2, 2, 2, 2],
|
|
6284
|
-
... [2, 2, 2, 2],
|
|
6285
|
-
... [1, 1, 1, 1],
|
|
6286
|
-
... [1, 1, 1, 1]]), ms.float16)]
|
|
6287
|
-
>>> weight = [ms.Tensor(np.arange(32).reshape((4, 4, 2)), ms.float16)]
|
|
6288
|
-
>>> bias = None
|
|
6289
|
-
>>> scale = None
|
|
6290
|
-
>>> offset = None
|
|
6291
|
-
>>> antiquant_scale = None
|
|
6292
|
-
>>> antiquant_offset = None
|
|
6293
|
-
>>> group_list = ms.Tensor([1, 3, 4, 6], ms.int64)
|
|
6294
|
-
>>> net = Net()
|
|
6295
|
-
>>> output = net(x, weight, bias, scale, offset, antiquant_scale, antiquant_offset, group_list)
|
|
6296
|
-
>>> print(output[0])
|
|
6297
|
-
[[0 0 ]
|
|
6298
|
-
[44 48 ]
|
|
6299
|
-
[88 96 ]
|
|
6300
|
-
[152 160]
|
|
6301
|
-
[108 112]
|
|
6302
|
-
[108 112]]
|
|
6303
|
-
"""
|
|
6304
|
-
return grouped_matmul_impl(x, weight, bias, scale, offset, antiquant_scale, antiquant_offset, group_list, split_item, group_type)
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
def kv_cache_scatter_update(var, indices, updates, axis, reduce='none'):
|
|
6308
|
-
r"""
|
|
6309
|
-
Update var with updates and indices along sequence axis.
|
|
6310
|
-
|
|
6311
|
-
Args:
|
|
6312
|
-
var (Tensor): 4-D tensor, the target tensor.
|
|
6313
|
-
indices (Tensor): 1-D tensor, the index tensor.
|
|
6314
|
-
updates (Tensor): 4-D tensor, the tensor doing the update operation.
|
|
6315
|
-
axis (Int): Which axis to scatter, can be '-1' and '-2'.
|
|
6316
|
-
reduce (String): Scatter mode, default to string "none" and can be "update".
|
|
6317
|
-
|
|
6318
|
-
Returns:
|
|
6319
|
-
Tensor, has the same data type and shape as original `var`.
|
|
6320
|
-
|
|
6321
|
-
Supported Platforms:
|
|
6322
|
-
``Ascend``
|
|
6323
|
-
|
|
6324
|
-
Examples:
|
|
6325
|
-
>>> import mindspore
|
|
6326
|
-
>>> import numpy as np
|
|
6327
|
-
>>> from mindspore import Tensor, ops
|
|
6328
|
-
>>> from mindspore.ops.operations._infer_ops import KVCacheScatterUpdate
|
|
6329
|
-
>>> kv_cache_scatter_update_op = KVCacheScatterUpdate()
|
|
6330
|
-
>>> var_shape = [1, 5, 128, 4096]
|
|
6331
|
-
>>> var = np.random.uniform(low=1, high=10, size=var_shape).astype(np.float32)
|
|
6332
|
-
>>> indices_shape = [1]
|
|
6333
|
-
>>> indices = np.random.randint(low=1, high=10, size=indices_shape).astype(np.int64)
|
|
6334
|
-
>>> updates_shape = [1, 5, 128, 1]
|
|
6335
|
-
>>> updates = np.random.uniform(low=1, high=10, size=updates_shape).astype(np.float32)
|
|
6336
|
-
>>> output = kv_cache_scatter_update_op(Tensor(var), Tensor(indices), Tensor(updates), -1, 'update')
|
|
6337
|
-
>>> print(output.shape)
|
|
6338
|
-
"""
|
|
6339
|
-
return kv_cache_scatter_update_op(var, indices, updates, axis, reduce)
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
def moe_finalize_routing(expanded_x, x1, x2=None, bias=None, scales=None, expanded_row_idx=None, expanded_expert_idx=None):
|
|
6343
|
-
r"""
|
|
6344
|
-
In MoE calculation, merge the results output by FFN and rearrange the output in time order by experts.
|
|
6345
|
-
|
|
6346
|
-
Notes:
|
|
6347
|
-
- E: The number of experts, such as 8.
|
|
6348
|
-
- K: The number of experts selected by a token, such as 1 or 2.
|
|
6349
|
-
- N: The number of rows in x1, which is the number of original tokens.
|
|
6350
|
-
- H: The number of cols in x1, which is the hiddens of tokens.
|
|
6351
|
-
|
|
6352
|
-
.. math::
|
|
6353
|
-
|
|
6354
|
-
expertid = expanded_expert_idx[i,k]
|
|
6355
|
-
out(i,j) = x1_{i,j} + x2_{i,j} + \sum_{k=0}^{K}(scales_{i,k}*(expanded\_x_{expanded\_row\_idx_{i+k*N},j} + bias_{expertid,j}))
|
|
6356
|
-
|
|
6357
|
-
Inputs:
|
|
6358
|
-
expanded_x (Tensor): The output of MoE FFN. The tensor must be 2D tensor. The shape of the tensor must be :math:`(K*N, H)`.
|
|
6359
|
-
Supported dtypes: Float16, Float32.
|
|
6360
|
-
x1 (Tensor): The output of attention. The tensor must be 2D tensor. The shape of the tensor must be :math:`(N, H)`.
|
|
6361
|
-
Data type requirements should be consistent with expanded_x.
|
|
6362
|
-
If not used, the required values to be passed are all 0, The shape of the Tensor meets the requirements
|
|
6363
|
-
x2 (Tensor, optional): The output of attention. The tensor must be 2D tensor. The shape of the tensor must be :math:`(N, H)`. If not used, None.
|
|
6364
|
-
Data type requirements should be consistent with expanded_x.
|
|
6365
|
-
bias (Tensor): The bias of the last matmul in MoE FFN. The tensor must be 2D tensor. The shape of the tensor must be :math:`(E, H)`.
|
|
6366
|
-
Data type requirements should be consistent with expanded_x.
|
|
6367
|
-
scales (Tensor): Weighted expanded when each token corresponds to multiple experts. The tensor must be 2D tensor.
|
|
6368
|
-
The shape of the tensor must be :math:`(N, K)`. Data type requirements should be consistent with expanded_x.
|
|
6369
|
-
If not used, the required values to be passed are all 1. The shape of the Tensor meets the requirements
|
|
6370
|
-
expanded_row_idx (Tensor): The index in time order. The tensor must be 1D tensor. The shape of the tensor must be :math:`(K*N)`. Supported dtypes: Int32.
|
|
6371
|
-
The value in Tensor must be between 0 and K*N, and the value cannot be repeated.
|
|
6372
|
-
expanded_expert_idx (Tensor): The experts selected for each token are used to find the bias of which experts need to be accumulated.
|
|
6373
|
-
The tensor must be 2D tensor. The shape of the tensor must be :math:`(N, K)`. Supported dtypes: Int32.
|
|
6374
|
-
|
|
6375
|
-
Outputs:
|
|
6376
|
-
Tensor, the merged and sorted results. The tensor is 2D tensor. The shape of the tensor is :math:`(N, H)`. Data type consistent with expanded_x.
|
|
6377
|
-
|
|
6378
|
-
Raises:
|
|
6379
|
-
TypeError: If the data type of input Tensor does not match the description in args.
|
|
6380
|
-
ShapeError: If the shape of input Tensor does not match the description in args.
|
|
6381
|
-
|
|
6382
|
-
Supported Platforms:
|
|
6383
|
-
``Ascend``
|
|
6384
|
-
|
|
6385
|
-
Examples:
|
|
6386
|
-
>>> import mindspore as ms
|
|
6387
|
-
>>> import numpy as np
|
|
6388
|
-
>>> from mindspore import Tensor, nn, context
|
|
6389
|
-
>>> from mindspore.ops.auto_generate import MoeFinalizeRouting
|
|
6390
|
-
>>> class Net(nn.Cell):
|
|
6391
|
-
... def __init__(self):
|
|
6392
|
-
... super(Net, self).__init__()
|
|
6393
|
-
... self.moe_finalize_routing = MoeFinalizeRouting()
|
|
6394
|
-
...
|
|
6395
|
-
... def construct(self, expanded_x, x1, x2, bias, scales, expanded_row_idx, expanded_expert_idx):
|
|
6396
|
-
... result = self.moe_finalize_routing(expanded_x, x1, x2, bias, scales, expanded_row_idx, expanded_expert_idx)
|
|
6397
|
-
... return result
|
|
6398
|
-
...
|
|
6399
|
-
>>> context.set_context(device_target="Ascend", mode=ms.GRAPH_MODE)
|
|
6400
|
-
>>> # E = 4, K = 2, N = 3, H = 4
|
|
6401
|
-
>>> expanded_x = ms.Tensor(np.array([[0.1, 0.1, 0.1, 0.1],
|
|
6402
|
-
... [0.2, 0.2, 0.2, 0.2],
|
|
6403
|
-
... [0.3, 0.3, 0.3, 0.3],
|
|
6404
|
-
... [0.1, 0.1, 0.1, 0.1],
|
|
6405
|
-
... [0.2, 0.2, 0.2, 0.2],
|
|
6406
|
-
... [0.3, 0.3, 0.3, 0.3]]), ms.float16)
|
|
6407
|
-
>>> x1 = ms.Tensor(np.array([[1, 1, 1, 1],
|
|
6408
|
-
... [0.2, 0.2, 0.2, 0.2],
|
|
6409
|
-
... [0.3, 0.3, 0.3, 0.3]]), ms.float16)
|
|
6410
|
-
>>> x2 = None
|
|
6411
|
-
>>> bias = ms.Tensor(np.array([[0.1, 0.1, 0.1, 0.1],
|
|
6412
|
-
... [0.2, 0.2, 0.2, 0.2],
|
|
6413
|
-
... [0.3, 0.3, 0.3, 0.3],
|
|
6414
|
-
... [0.4, 0.4, 0.4, 0.4]]), ms.float16)
|
|
6415
|
-
>>> scales = ms.Tensor(np.array([[0.7, 0.3],
|
|
6416
|
-
... [0.8, 0.2],
|
|
6417
|
-
... [0.8, 0.2]]), ms.float16)
|
|
6418
|
-
>>> expanded_row_idx = ms.Tensor(np.array([2, 3, 1, 0, 5, 4]), ms.int32)
|
|
6419
|
-
>>> expanded_expert_idx = ms.Tensor(np.array([[0, 1],
|
|
6420
|
-
... [0, 2],
|
|
6421
|
-
... [1, 3]]), ms.int32)
|
|
6422
|
-
>>> net = Net()
|
|
6423
|
-
>>> output = net(expanded_x, x1, x2, bias, scales, expanded_row_idx, expanded_expert_idx)
|
|
6424
|
-
>>> print(output)
|
|
6425
|
-
[[1.37 1.37 1.37 1.37]
|
|
6426
|
-
[0.48 0.48 0.48 0.48]
|
|
6427
|
-
[0.74 0.74 0.74 0.74]]
|
|
6428
|
-
"""
|
|
6429
|
-
return moe_finalize_routing_op(expanded_x, x1, x2, bias, scales, expanded_row_idx, expanded_expert_idx)
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
def quant_batch_matmul(x1, x2, scale, offset=None, bias=None, transpose_x1=False, transpose_x2=False, dtype=mstype.float16):
|
|
6433
|
-
r"""
|
|
6434
|
-
|
|
6435
|
-
"""
|
|
6436
|
-
return quant_batch_matmul_impl(x1, x2, scale, offset, bias, transpose_x1, transpose_x2, dtype)
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
def weight_quant_batch_matmul(x, weight, antiquant_scale, antiquant_offset=None, quant_scale=None, quant_offset=None, bias=None, transpose_x=False, transpose_weight=False, antiquant_group_size=0):
|
|
6440
|
-
r"""
|
|
6441
|
-
|
|
6442
|
-
"""
|
|
6443
|
-
return weight_quant_batch_matmul_impl(x, weight, antiquant_scale, antiquant_offset, quant_scale, quant_offset, bias, transpose_x, transpose_weight, antiquant_group_size)
|