mindspore 2.7.0__cp310-cp310-win_amd64.whl → 2.7.1__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/__init__.py +4 -1
- mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
- mindspore/_extends/parse/compile_config.py +24 -1
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +6 -2
- mindspore/_extends/parse/resources.py +1 -1
- mindspore/_extends/parse/standard_method.py +8 -1
- mindspore/_extends/parse/trope.py +2 -1
- mindspore/_extends/pijit/pijit_func_white_list.py +7 -22
- mindspore/avcodec-59.dll +0 -0
- mindspore/avdevice-59.dll +0 -0
- mindspore/avfilter-8.dll +0 -0
- mindspore/avformat-59.dll +0 -0
- mindspore/avutil-57.dll +0 -0
- mindspore/boost/base.py +29 -2
- mindspore/common/_decorator.py +3 -2
- mindspore/common/_grad_function.py +3 -1
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +275 -64
- mindspore/common/_utils.py +0 -44
- mindspore/common/api.py +285 -35
- mindspore/common/dump.py +7 -108
- mindspore/common/dynamic_shape/auto_dynamic_shape.py +1 -3
- mindspore/common/hook_handle.py +60 -0
- mindspore/common/jit_config.py +5 -1
- mindspore/common/jit_trace.py +27 -12
- mindspore/common/lazy_inline.py +5 -3
- mindspore/common/parameter.py +13 -107
- mindspore/common/recompute.py +4 -11
- mindspore/common/tensor.py +16 -169
- mindspore/communication/_comm_helper.py +11 -1
- mindspore/communication/comm_func.py +138 -4
- mindspore/communication/management.py +85 -1
- mindspore/config/op_info.config +0 -15
- mindspore/context.py +5 -85
- mindspore/dataset/engine/datasets.py +8 -4
- mindspore/dataset/engine/datasets_vision.py +1 -1
- mindspore/dataset/engine/validators.py +1 -15
- mindspore/dnnl.dll +0 -0
- mindspore/{experimental/llm_boost/ascend_native → graph}/__init__.py +7 -7
- mindspore/graph/custom_pass.py +55 -0
- mindspore/include/dataset/execute.h +2 -2
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/__init__.py +3 -3
- mindspore/mindrecord/common/exceptions.py +1 -0
- mindspore/mindrecord/config.py +1 -1
- mindspore/{parallel/mpi → mindrecord/core}/__init__.py +4 -1
- mindspore/mindrecord/{shardheader.py → core/shardheader.py} +2 -1
- mindspore/mindrecord/{shardindexgenerator.py → core/shardindexgenerator.py} +1 -1
- mindspore/mindrecord/{shardreader.py → core/shardreader.py} +2 -1
- mindspore/mindrecord/{shardsegment.py → core/shardsegment.py} +2 -2
- mindspore/mindrecord/{shardutils.py → core/shardutils.py} +1 -1
- mindspore/mindrecord/{shardwriter.py → core/shardwriter.py} +1 -1
- mindspore/mindrecord/filereader.py +4 -4
- mindspore/mindrecord/filewriter.py +5 -5
- mindspore/mindrecord/mindpage.py +2 -2
- mindspore/mindrecord/tools/cifar10.py +1 -1
- mindspore/mindrecord/tools/cifar100.py +1 -1
- mindspore/mindrecord/tools/cifar100_to_mr.py +1 -1
- mindspore/mindrecord/tools/cifar10_to_mr.py +1 -1
- mindspore/mindrecord/tools/csv_to_mr.py +1 -1
- mindspore/mindrecord/tools/imagenet_to_mr.py +1 -1
- mindspore/mindrecord/tools/mnist_to_mr.py +1 -1
- mindspore/mindrecord/tools/tfrecord_to_mr.py +1 -1
- mindspore/mindspore_backend_common.dll +0 -0
- mindspore/mindspore_backend_manager.dll +0 -0
- mindspore/mindspore_cluster.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_cpu.dll +0 -0
- mindspore/mindspore_dump.dll +0 -0
- mindspore/mindspore_frontend.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_hardware_abstract.dll +0 -0
- mindspore/mindspore_memory_pool.dll +0 -0
- mindspore/mindspore_ms_backend.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/{mindspore_ops_host.dll → mindspore_ops_cpu.dll} +0 -0
- mindspore/mindspore_profiler.dll +0 -0
- mindspore/mindspore_pyboost.dll +0 -0
- mindspore/mindspore_pynative.dll +0 -0
- mindspore/mindspore_runtime_pipeline.dll +0 -0
- mindspore/mindspore_runtime_utils.dll +0 -0
- mindspore/mindspore_tools.dll +0 -0
- mindspore/mint/__init__.py +15 -10
- mindspore/mint/distributed/distributed.py +182 -62
- mindspore/mint/nn/__init__.py +2 -16
- mindspore/mint/nn/functional.py +4 -110
- mindspore/mint/nn/layer/__init__.py +0 -2
- mindspore/mint/nn/layer/activation.py +0 -6
- mindspore/mint/nn/layer/basic.py +0 -47
- mindspore/mint/nn/layer/conv.py +4 -4
- mindspore/mint/nn/layer/normalization.py +8 -13
- mindspore/mint/nn/layer/pooling.py +0 -4
- mindspore/nn/__init__.py +1 -3
- mindspore/nn/cell.py +16 -66
- mindspore/nn/layer/basic.py +49 -1
- mindspore/nn/layer/container.py +16 -0
- mindspore/nn/layer/embedding.py +4 -169
- mindspore/nn/layer/normalization.py +2 -1
- mindspore/nn/layer/thor_layer.py +4 -85
- mindspore/nn/optim/ada_grad.py +0 -1
- mindspore/nn/optim/adafactor.py +0 -1
- mindspore/nn/optim/adam.py +31 -124
- mindspore/nn/optim/adamax.py +0 -1
- mindspore/nn/optim/asgd.py +0 -1
- mindspore/nn/optim/ftrl.py +8 -102
- mindspore/nn/optim/lamb.py +0 -1
- mindspore/nn/optim/lars.py +0 -3
- mindspore/nn/optim/lazyadam.py +25 -218
- mindspore/nn/optim/momentum.py +5 -43
- mindspore/nn/optim/optimizer.py +6 -55
- mindspore/nn/optim/proximal_ada_grad.py +0 -1
- mindspore/nn/optim/rmsprop.py +0 -1
- mindspore/nn/optim/rprop.py +0 -1
- mindspore/nn/optim/sgd.py +0 -1
- mindspore/nn/optim/tft_wrapper.py +0 -1
- mindspore/nn/optim/thor.py +0 -2
- mindspore/nn/probability/bijector/bijector.py +7 -8
- mindspore/nn/probability/bijector/gumbel_cdf.py +2 -2
- mindspore/nn/probability/bijector/power_transform.py +20 -21
- mindspore/nn/probability/bijector/scalar_affine.py +5 -5
- mindspore/nn/probability/bijector/softplus.py +13 -14
- mindspore/nn/wrap/grad_reducer.py +4 -74
- mindspore/numpy/array_creations.py +2 -2
- mindspore/numpy/fft.py +9 -9
- mindspore/{nn/reinforcement → onnx}/__init__.py +5 -8
- mindspore/onnx/onnx_export.py +137 -0
- mindspore/opencv_core4110.dll +0 -0
- mindspore/opencv_imgcodecs4110.dll +0 -0
- mindspore/{opencv_imgproc452.dll → opencv_imgproc4110.dll} +0 -0
- mindspore/ops/__init__.py +2 -0
- mindspore/ops/_grad_experimental/grad_comm_ops.py +38 -2
- mindspore/ops/_op_impl/aicpu/__init__.py +0 -10
- mindspore/ops/_op_impl/cpu/__init__.py +0 -5
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +16 -22
- mindspore/ops/auto_generate/gen_extend_func.py +2 -7
- mindspore/ops/auto_generate/gen_ops_def.py +98 -141
- mindspore/ops/auto_generate/gen_ops_prim.py +12708 -12686
- mindspore/ops/communication.py +97 -0
- mindspore/ops/composite/__init__.py +5 -2
- mindspore/ops/composite/base.py +15 -1
- mindspore/ops/composite/multitype_ops/__init__.py +3 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +150 -8
- mindspore/ops/composite/multitype_ops/add_impl.py +7 -0
- mindspore/ops/composite/multitype_ops/mod_impl.py +27 -0
- mindspore/ops/function/__init__.py +1 -0
- mindspore/ops/function/array_func.py +14 -12
- mindspore/ops/function/comm_func.py +3883 -0
- mindspore/ops/function/debug_func.py +3 -4
- mindspore/ops/function/math_func.py +45 -54
- mindspore/ops/function/nn_func.py +75 -294
- mindspore/ops/function/random_func.py +9 -18
- mindspore/ops/functional.py +2 -0
- mindspore/ops/functional_overload.py +354 -18
- mindspore/ops/operations/__init__.py +2 -5
- mindspore/ops/operations/_custom_ops_utils.py +7 -9
- mindspore/ops/operations/_inner_ops.py +1 -38
- mindspore/ops/operations/_rl_inner_ops.py +0 -933
- mindspore/ops/operations/array_ops.py +1 -0
- mindspore/ops/operations/comm_ops.py +94 -2
- mindspore/ops/operations/custom_ops.py +228 -19
- mindspore/ops/operations/debug_ops.py +27 -29
- mindspore/ops/operations/manually_defined/ops_def.py +27 -306
- mindspore/ops/operations/nn_ops.py +2 -2
- mindspore/ops/operations/sparse_ops.py +0 -83
- mindspore/ops/primitive.py +1 -17
- mindspore/ops/tensor_method.py +72 -3
- mindspore/ops_generate/aclnn/aclnn_kernel_register_auto_cc_generator.py +5 -5
- mindspore/ops_generate/aclnn/gen_aclnn_implement.py +8 -8
- mindspore/ops_generate/api/functions_cc_generator.py +53 -4
- mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +25 -11
- mindspore/ops_generate/common/gen_constants.py +11 -10
- mindspore/ops_generate/common/op_proto.py +18 -1
- mindspore/ops_generate/common/template.py +102 -245
- mindspore/ops_generate/common/template_utils.py +212 -0
- mindspore/ops_generate/gen_custom_ops.py +69 -0
- mindspore/ops_generate/op_def/ops_def_cc_generator.py +78 -7
- mindspore/ops_generate/op_def_py/base_op_prim_py_generator.py +360 -0
- mindspore/ops_generate/op_def_py/custom_op_prim_py_generator.py +140 -0
- mindspore/ops_generate/op_def_py/op_def_py_generator.py +54 -7
- mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -312
- mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +74 -17
- mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +22 -5
- mindspore/ops_generate/pyboost/op_template_parser.py +3 -2
- mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +21 -5
- mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +2 -2
- mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +30 -10
- mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +10 -3
- mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +19 -9
- mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +71 -28
- mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +10 -9
- mindspore/ops_generate/pyboost/pyboost_utils.py +27 -16
- mindspore/ops_generate/resources/yaml_loader.py +13 -0
- mindspore/ops_generate/tensor_py_cc_generator.py +2 -2
- mindspore/parallel/_cell_wrapper.py +1 -1
- mindspore/parallel/_parallel_serialization.py +1 -4
- mindspore/parallel/_utils.py +29 -6
- mindspore/parallel/checkpoint_transform.py +18 -2
- mindspore/parallel/cluster/process_entity/_api.py +24 -32
- mindspore/parallel/cluster/process_entity/_utils.py +9 -5
- mindspore/{experimental/llm_boost/atb → parallel/distributed}/__init__.py +21 -23
- mindspore/parallel/distributed/distributed_data_parallel.py +393 -0
- mindspore/parallel/distributed/flatten_grad_buffer.py +295 -0
- mindspore/parallel/strategy.py +336 -0
- mindspore/parallel/transform_safetensors.py +117 -16
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +3 -0
- mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +1 -1
- mindspore/profiler/common/constant.py +5 -0
- mindspore/profiler/common/file_manager.py +9 -0
- mindspore/profiler/common/msprof_cmd_tool.py +38 -2
- mindspore/profiler/common/path_manager.py +56 -24
- mindspore/profiler/common/profiler_context.py +2 -12
- mindspore/profiler/common/profiler_info.py +3 -3
- mindspore/profiler/common/profiler_path_manager.py +13 -0
- mindspore/profiler/common/util.py +30 -3
- mindspore/profiler/experimental_config.py +2 -1
- mindspore/profiler/platform/npu_profiler.py +33 -6
- mindspore/run_check/_check_version.py +108 -24
- mindspore/runtime/__init__.py +3 -2
- mindspore/runtime/executor.py +11 -3
- mindspore/runtime/memory.py +112 -0
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/{experimental/llm_boost → tools}/__init__.py +5 -5
- mindspore/tools/data_dump.py +130 -0
- mindspore/tools/sdc_detect.py +91 -0
- mindspore/tools/stress_detect.py +63 -0
- mindspore/train/__init__.py +6 -6
- mindspore/train/_utils.py +5 -18
- mindspore/train/amp.py +6 -4
- mindspore/train/callback/_checkpoint.py +0 -9
- mindspore/train/callback/_train_fault_tolerance.py +69 -18
- mindspore/train/data_sink.py +1 -5
- mindspore/train/model.py +38 -211
- mindspore/train/serialization.py +126 -387
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +6 -3
- mindspore/utils/dlpack.py +92 -0
- mindspore/utils/dryrun.py +1 -1
- mindspore/utils/runtime_execution_order_check.py +10 -0
- mindspore/utils/sdc_detect.py +14 -12
- mindspore/utils/stress_detect.py +43 -0
- mindspore/utils/utils.py +144 -8
- mindspore/version.py +1 -1
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/METADATA +3 -2
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/RECORD +254 -267
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +0 -210
- mindspore/experimental/llm_boost/ascend_native/llm_boost.py +0 -52
- mindspore/experimental/llm_boost/atb/boost_base.py +0 -385
- mindspore/experimental/llm_boost/atb/llama_boost.py +0 -137
- mindspore/experimental/llm_boost/atb/qwen_boost.py +0 -124
- mindspore/experimental/llm_boost/register.py +0 -130
- mindspore/experimental/llm_boost/utils.py +0 -31
- mindspore/include/OWNERS +0 -7
- mindspore/mindspore_cpu_res_manager.dll +0 -0
- mindspore/mindspore_ops_kernel_common.dll +0 -0
- mindspore/mindspore_res_manager.dll +0 -0
- mindspore/nn/optim/_dist_optimizer_registry.py +0 -111
- mindspore/nn/reinforcement/_batch_read_write.py +0 -142
- mindspore/nn/reinforcement/_tensors_queue.py +0 -152
- mindspore/nn/reinforcement/tensor_array.py +0 -145
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/ops/_op_impl/aicpu/priority_replay_buffer.py +0 -113
- mindspore/ops/_op_impl/aicpu/reservoir_replay_buffer.py +0 -96
- mindspore/ops/_op_impl/aicpu/sparse_cross.py +0 -42
- mindspore/ops/_op_impl/cpu/buffer_append.py +0 -28
- mindspore/ops/_op_impl/cpu/buffer_get.py +0 -28
- mindspore/ops/_op_impl/cpu/buffer_sample.py +0 -28
- mindspore/ops/_op_impl/cpu/priority_replay_buffer.py +0 -42
- mindspore/ops/operations/_tensor_array.py +0 -359
- mindspore/ops/operations/rl_ops.py +0 -288
- mindspore/parallel/_offload_context.py +0 -275
- mindspore/parallel/_recovery_context.py +0 -115
- mindspore/parallel/_transformer/__init__.py +0 -35
- mindspore/parallel/_transformer/layers.py +0 -765
- mindspore/parallel/_transformer/loss.py +0 -251
- mindspore/parallel/_transformer/moe.py +0 -693
- mindspore/parallel/_transformer/op_parallel_config.py +0 -222
- mindspore/parallel/_transformer/transformer.py +0 -3124
- mindspore/parallel/mpi/_mpi_config.py +0 -116
- mindspore/train/memory_profiling_pb2.py +0 -298
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/WHEEL +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/top_level.txt +0 -0
mindspore/common/_tensor_docs.py
CHANGED
|
@@ -28,7 +28,7 @@ def attach_docstr(method, docstr):
|
|
|
28
28
|
|
|
29
29
|
attach_docstr("absolute", r"""absolute() -> Tensor
|
|
30
30
|
|
|
31
|
-
Alias for :func:`Tensor.abs`.
|
|
31
|
+
Alias for :func:`mindspore.Tensor.abs`.
|
|
32
32
|
""")
|
|
33
33
|
attach_docstr("abs", r"""abs() -> Tensor
|
|
34
34
|
|
|
@@ -339,7 +339,7 @@ Alias for :func:`mindspore.Tensor.asin`.
|
|
|
339
339
|
""")
|
|
340
340
|
attach_docstr("arctan2", r"""arctan2(other) -> Tensor
|
|
341
341
|
|
|
342
|
-
Alias for :func:`Tensor.atan2`.
|
|
342
|
+
Alias for :func:`mindspore.Tensor.atan2`.
|
|
343
343
|
""")
|
|
344
344
|
attach_docstr("arctanh", r"""arctanh() -> Tensor
|
|
345
345
|
|
|
@@ -683,6 +683,9 @@ Examples:
|
|
|
683
683
|
>>> print(output)
|
|
684
684
|
[ 0 1 0 0 -2 3 2]
|
|
685
685
|
""")
|
|
686
|
+
attach_docstr("broadcast_to", r"""broadcast_to(*shape) -> Tensor
|
|
687
|
+
|
|
688
|
+
For details, please refer to :func:`mindspore.ops.broadcast_to`.""")
|
|
686
689
|
attach_docstr("ceil", r"""ceil() -> Tensor
|
|
687
690
|
|
|
688
691
|
For details, please refer to :func:`mindspore.ops.ceil`.""")
|
|
@@ -768,9 +771,6 @@ attach_docstr("clone", r"""clone() -> Tensor
|
|
|
768
771
|
|
|
769
772
|
Returns a copy of self.
|
|
770
773
|
|
|
771
|
-
.. warning::
|
|
772
|
-
This is an experimental API that is subject to change or deletion.
|
|
773
|
-
|
|
774
774
|
Note:
|
|
775
775
|
This function is differentiable, and gradients will flow back directly from the calculation
|
|
776
776
|
result of the function to the `self`.
|
|
@@ -796,8 +796,6 @@ attach_docstr("copy_", r"""copy_(src, non_blocking=False) -> Tensor
|
|
|
796
796
|
Copies the elements from `src` into `self` tensor and returns `self`.
|
|
797
797
|
|
|
798
798
|
.. warning::
|
|
799
|
-
This is an experimental API that is subject to change or deletion.
|
|
800
|
-
|
|
801
799
|
If Copying is performed between Ascend and Ascend, the `src` tensor must be broadcastable with the `self` tensor,
|
|
802
800
|
and they can be of different data types.
|
|
803
801
|
Copying is performed between CPU and Ascend or CPU and CPU are only supported if `self` and `src` have
|
|
@@ -836,9 +834,6 @@ attach_docstr("count_nonzero", r"""count_nonzero(dim=None) -> Tensor
|
|
|
836
834
|
|
|
837
835
|
Counts the number of non-zero values in the tensor input along the given dim. If no dim is specified then all non-zeros in the tensor are counted.
|
|
838
836
|
|
|
839
|
-
.. warning::
|
|
840
|
-
This is an experimental API that is subject to change or deletion.
|
|
841
|
-
|
|
842
837
|
Args:
|
|
843
838
|
dim (Union[None, int, tuple(int), list(int)], optional): The dimension to reduce. Default value: ``None``, which indicates that the number of non-zero elements is calculated. If `dim` is ``None``, all elements in the tensor are summed up.
|
|
844
839
|
|
|
@@ -1341,9 +1336,6 @@ the scalar could only be a constant.
|
|
|
1341
1336
|
where the :math:`floor` indicates the Floor operator. For more details,
|
|
1342
1337
|
please refer to the :class:`mindspore.mint.floor` operator.
|
|
1343
1338
|
|
|
1344
|
-
.. warning::
|
|
1345
|
-
This is an experimental API that is subject to change or deletion.
|
|
1346
|
-
|
|
1347
1339
|
Args:
|
|
1348
1340
|
other (Union[Tensor, Number, bool]): The other input is a number or
|
|
1349
1341
|
a bool or a tensor whose data type is number or bool.
|
|
@@ -1482,7 +1474,7 @@ The following figure shows the calculation process of Gather commonly:
|
|
|
1482
1474
|
where params represents the input `input_params`, and indices represents the index to be sliced `input_indices`.
|
|
1483
1475
|
|
|
1484
1476
|
.. note::
|
|
1485
|
-
- The value of input_indices must be in the range of
|
|
1477
|
+
- The value of input_indices must be in the range of :math:`[0, input\_param.shape[axis])`.
|
|
1486
1478
|
On CPU and GPU, an error is raised if an out of bound indice is found. On Ascend, the results may be
|
|
1487
1479
|
undefined.
|
|
1488
1480
|
- The data type of self cannot be
|
|
@@ -1507,7 +1499,7 @@ Raises:
|
|
|
1507
1499
|
ValueError: If `axis` is a Tensor and its size is not 1.
|
|
1508
1500
|
TypeError: If `self` is not a tensor.
|
|
1509
1501
|
TypeError: If `input_indices` is not a tensor of type int.
|
|
1510
|
-
RuntimeError: If `input_indices` is out of range :math:`[0,
|
|
1502
|
+
RuntimeError: If `input_indices` is out of range :math:`[0, input\_param.shape[axis])` on CPU or GPU.
|
|
1511
1503
|
|
|
1512
1504
|
Supported Platforms:
|
|
1513
1505
|
``Ascend`` ``GPU`` ``CPU``
|
|
@@ -1566,7 +1558,7 @@ For details, please refer to :func:`mindspore.ops.greater_equal`.
|
|
|
1566
1558
|
""")
|
|
1567
1559
|
attach_docstr("gt", r"""gt(other) -> Tensor
|
|
1568
1560
|
|
|
1569
|
-
For details, please refer to :func
|
|
1561
|
+
For details, please refer to :func:`mindspore.Tensor.greater`.""")
|
|
1570
1562
|
attach_docstr("hardshrink", r"""hardshrink(lambd=0.5) -> Tensor
|
|
1571
1563
|
|
|
1572
1564
|
For details, please refer to :func:`mindspore.ops.hardshrink`.""")
|
|
@@ -1576,6 +1568,10 @@ For details, please refer to :func:`mindspore.ops.histc`.
|
|
|
1576
1568
|
|
|
1577
1569
|
Supported Platforms:
|
|
1578
1570
|
``Ascend`` ``GPU`` ``CPU``""")
|
|
1571
|
+
attach_docstr("imag", r"""imag() -> Tensor
|
|
1572
|
+
|
|
1573
|
+
For details, please refer to :func:`mindspore.ops.imag`.
|
|
1574
|
+
""")
|
|
1579
1575
|
attach_docstr("index_add", r"""index_add(indices, y, axis, use_lock=True, check_index_bound=True) -> Tensor
|
|
1580
1576
|
|
|
1581
1577
|
Adds tensor `y` to specified axis and indices of tensor `self`. The axis should be in [-len(self.dim), len(self.dim) - 1], and indices should be in [0, the size of `self` - 1] at the axis dimension.
|
|
@@ -1620,6 +1616,87 @@ For details, please refer to :func:`mindspore.ops.index_add`.
|
|
|
1620
1616
|
The corresponding relationships between the parameters of `Tensor.index_add` and :func:`mindspore.ops.index_add`
|
|
1621
1617
|
are as follows: `dim` -> `axis`, `index` -> `indices`, `source * alpha` -> `y`.
|
|
1622
1618
|
""")
|
|
1619
|
+
attach_docstr("index_copy_", r"""index_copy_(dim, index, tensor) -> Tensor
|
|
1620
|
+
|
|
1621
|
+
Copies the elements of `tensor` into the `self` by selecting the indices in the order given in `index` .
|
|
1622
|
+
|
|
1623
|
+
.. note::
|
|
1624
|
+
The value of `index` must be in the range `[0, self.shape[dim])` , if it is out of range, the result is undefined.
|
|
1625
|
+
|
|
1626
|
+
If value of `index` contains duplicate entries, the result is nondeterministic since it depends on the last copy operation that occurred.
|
|
1627
|
+
|
|
1628
|
+
Args:
|
|
1629
|
+
dim (int): The dimension along which to `index` .
|
|
1630
|
+
index (Tensor): A 1-D Tensor with the indices to access in `self` along the specified `dim` .
|
|
1631
|
+
tensor (Tensor): The tensor containing values to copy.
|
|
1632
|
+
|
|
1633
|
+
Returns:
|
|
1634
|
+
Return `self` Tensor.
|
|
1635
|
+
|
|
1636
|
+
Supported Platforms:
|
|
1637
|
+
``Ascend``
|
|
1638
|
+
|
|
1639
|
+
Examples:
|
|
1640
|
+
>>> import mindspore
|
|
1641
|
+
>>> from mindspore import Tensor, mint
|
|
1642
|
+
>>> x = mint.ones((5, 3), dtype=mindspore.int64)
|
|
1643
|
+
>>> index = Tensor([4, 0, 2])
|
|
1644
|
+
>>> tensor = Tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=mindspore.int64)
|
|
1645
|
+
>>> x.index_copy_(0, index, tensor)
|
|
1646
|
+
Tensor(shape=[5, 3], dtype=Int64, value=
|
|
1647
|
+
[[4 5 6]
|
|
1648
|
+
[1 1 1]
|
|
1649
|
+
[7 8 9]
|
|
1650
|
+
[1 1 1]
|
|
1651
|
+
[1 2 3]])
|
|
1652
|
+
""")
|
|
1653
|
+
attach_docstr("index_fill_", r"""index_fill_(dim, index, value) -> Tensor
|
|
1654
|
+
|
|
1655
|
+
Fills the elements under the `dim` dimension of the `self` Tensor with the input `value`
|
|
1656
|
+
by selecting the indices in the order given in `index`.
|
|
1657
|
+
|
|
1658
|
+
.. warning::
|
|
1659
|
+
This is an experimental API that is subject to change or deletion.
|
|
1660
|
+
|
|
1661
|
+
.. note::
|
|
1662
|
+
While calculating the gradient of `value` , the value of `index` must be in the range `[0, self.shape[dim])` ,
|
|
1663
|
+
if it is out of range, the result is undefined.
|
|
1664
|
+
|
|
1665
|
+
Args:
|
|
1666
|
+
dim (int): Dimension along which to fill the `self` Tensor.
|
|
1667
|
+
index (Tensor): Indices of the `self` Tensor to fill in. The `index` must be a 0D or 1D Tensor with dtype int32
|
|
1668
|
+
or int64.
|
|
1669
|
+
value (Union[Tensor, Number, bool]): Value to fill the `self` Tensor. The `value` is a number or a bool or a
|
|
1670
|
+
tensor whose data type is number or bool. If `value` is a Tensor, it must be a 0D Tensor.
|
|
1671
|
+
|
|
1672
|
+
Returns:
|
|
1673
|
+
Tensor, the shape and the data type are the same as those of `self` .
|
|
1674
|
+
|
|
1675
|
+
Raises:
|
|
1676
|
+
TypeError: If the data type of `index` is not int32 or int64.
|
|
1677
|
+
RuntimeError: If `dim` is out of range :math:`[-self.ndim, self.ndim)`.
|
|
1678
|
+
RuntimeError: If the rank of `index` is greater than 1.
|
|
1679
|
+
RuntimeError: If `value` is a Tensor and its rank is not equal to 0.
|
|
1680
|
+
|
|
1681
|
+
Supported Platforms:
|
|
1682
|
+
``Ascend``
|
|
1683
|
+
|
|
1684
|
+
Examples:
|
|
1685
|
+
>>> import mindspore
|
|
1686
|
+
>>> from mindspore import Tensor
|
|
1687
|
+
>>> import numpy as np
|
|
1688
|
+
>>> x = Tensor(np.array([[1, 2, 3], [4, 5, 6]]), mindspore.int32)
|
|
1689
|
+
>>> dim = 1
|
|
1690
|
+
>>> index = Tensor(np.array([0, 2]), mindspore.int32)
|
|
1691
|
+
>>> value = Tensor(0, mindspore.int32)
|
|
1692
|
+
>>> output = x.index_fill_(dim, index, value)
|
|
1693
|
+
>>> print(output)
|
|
1694
|
+
[[ 0 2 0]
|
|
1695
|
+
[ 0 5 0]]
|
|
1696
|
+
>>> print(x)
|
|
1697
|
+
[[ 0 2 0]
|
|
1698
|
+
[ 0 5 0]]
|
|
1699
|
+
""")
|
|
1623
1700
|
attach_docstr("index_select", r"""index_select(axis, index) -> Tensor
|
|
1624
1701
|
|
|
1625
1702
|
Generates a new Tensor that accesses the values of `self` along the specified `axis` dimension
|
|
@@ -1952,9 +2029,6 @@ attach_docstr("masked_scatter", r"""masked_scatter(mask, source) -> Tensor
|
|
|
1952
2029
|
Returns a Tensor. Updates the value in the "self Tensor" with the `tensor` value according to the mask.
|
|
1953
2030
|
The shape of `mask` and the shape of the "self Tensor" must be the same or `mask` is broadcastable.
|
|
1954
2031
|
|
|
1955
|
-
.. warning::
|
|
1956
|
-
This is an experimental API that is subject to change or deletion.
|
|
1957
|
-
|
|
1958
2032
|
Args:
|
|
1959
2033
|
mask (Tensor[bool]): A bool tensor with a shape broadcastable to the "self Tensor".
|
|
1960
2034
|
source (Tensor): A tensor with the same data type as the "self Tensor". The number
|
|
@@ -1978,11 +2052,52 @@ Examples:
|
|
|
1978
2052
|
>>> import numpy as np
|
|
1979
2053
|
>>> import mindspore
|
|
1980
2054
|
>>> from mindspore import Tensor
|
|
1981
|
-
>>>
|
|
2055
|
+
>>> x = Tensor(np.array([1., 2., 3., 4.]), mindspore.float32)
|
|
2056
|
+
>>> mask = Tensor(np.array([True, True, False, True]), mindspore.bool_)
|
|
2057
|
+
>>> source = Tensor(np.array([5., 6., 7.]), mindspore.float32)
|
|
2058
|
+
>>> output = x.masked_scatter(mask, source)
|
|
2059
|
+
>>> print(output)
|
|
2060
|
+
[5. 6. 3. 7.]""")
|
|
2061
|
+
attach_docstr("masked_scatter_", r"""masked_scatter_(mask, source) -> Tensor
|
|
2062
|
+
|
|
2063
|
+
Updates the value in the `self` with the `source` value according to the `mask`, and returns a Tensor.
|
|
2064
|
+
The shape of `mask` and the `self` must be the same or `mask` is broadcastable.
|
|
2065
|
+
|
|
2066
|
+
Note:
|
|
2067
|
+
When the total number of elements in `source` is less than the number of True elements in `mask`,
|
|
2068
|
+
the NPU may not be able to detect this invalid input; therefore,
|
|
2069
|
+
the correctness of the output cannot be guaranteed.
|
|
2070
|
+
|
|
2071
|
+
Args:
|
|
2072
|
+
mask (Tensor[bool]): A bool tensor with a shape broadcastable to the `self`.
|
|
2073
|
+
source (Tensor): A tensor with the same data type as the `self`. The number
|
|
2074
|
+
of elements must be greater than or equal to the number of True elements in `mask`.
|
|
2075
|
+
|
|
2076
|
+
Returns:
|
|
2077
|
+
Tensor, with the same type and shape as the `self`.
|
|
2078
|
+
|
|
2079
|
+
Raises:
|
|
2080
|
+
TypeError: If `mask` or `source` is not a Tensor.
|
|
2081
|
+
TypeError: If data type of the "self Tensor" is not be supported.
|
|
2082
|
+
TypeError: If dtype of `mask` is not bool.
|
|
2083
|
+
TypeError: If the dim of the "self Tensor" is less than the dim of `mask`.
|
|
2084
|
+
ValueError: If `mask` can not be broadcastable to the "self Tensor".
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
Supported Platforms:
|
|
2088
|
+
``Ascend``
|
|
2089
|
+
|
|
2090
|
+
Examples:
|
|
2091
|
+
>>> import numpy as np
|
|
2092
|
+
>>> import mindspore
|
|
2093
|
+
>>> from mindspore import Tensor
|
|
2094
|
+
>>> x = Tensor(np.array([1., 2., 3., 4.]), mindspore.float32)
|
|
1982
2095
|
>>> mask = Tensor(np.array([True, True, False, True]), mindspore.bool_)
|
|
1983
2096
|
>>> tensor = Tensor(np.array([5., 6., 7.]), mindspore.float32)
|
|
1984
|
-
>>> output =
|
|
2097
|
+
>>> output = x.masked_scatter_(mask, tensor)
|
|
1985
2098
|
>>> print(output)
|
|
2099
|
+
[5. 6. 3. 7.]
|
|
2100
|
+
>>> print(x)
|
|
1986
2101
|
[5. 6. 3. 7.]""")
|
|
1987
2102
|
attach_docstr("masked_select", r"""masked_select(mask) -> Tensor
|
|
1988
2103
|
|
|
@@ -2680,9 +2795,6 @@ attach_docstr("new_empty", r"""new_empty(size, *, dtype=None, device=None) -> Te
|
|
|
2680
2795
|
Returns an uninitialized Tensor. Its shape is specified by `size`, its dtype is specified by `dtype` and its
|
|
2681
2796
|
device is specified by `device`.
|
|
2682
2797
|
|
|
2683
|
-
.. warning::
|
|
2684
|
-
This is an experimental API that is subject to change or deletion.
|
|
2685
|
-
|
|
2686
2798
|
Args:
|
|
2687
2799
|
size (Union[tuple[int], list[int], int]): The specified shape of output tensor. Only positive integer or
|
|
2688
2800
|
tuple or list containing positive integers are allowed.
|
|
@@ -2690,7 +2802,7 @@ Args:
|
|
|
2690
2802
|
Keyword Args:
|
|
2691
2803
|
dtype (:class:`mindspore.dtype`, optional): The specified dtype of the output tensor. If `dtype = None`,
|
|
2692
2804
|
the tensor will have the same dtype as `self`. Default ``None``.
|
|
2693
|
-
device (
|
|
2805
|
+
device (str, optional): The specified device of the output tensor. In PyNative mode, ``"Ascend"``, ``"npu"``,
|
|
2694
2806
|
``"cpu"`` and ``"CPU"`` are supported. In graph mode O0, ``"Ascend"`` and ``"npu"`` are supported. If `device = None`,
|
|
2695
2807
|
the value set by :func:`mindspore.set_device` will be used. Default ``None``.
|
|
2696
2808
|
|
|
@@ -2816,6 +2928,15 @@ attach_docstr("outer", r"""outer(vec2) -> Tensor
|
|
|
2816
2928
|
|
|
2817
2929
|
For details, please refer to :func:`mindspore.ops.outer`.
|
|
2818
2930
|
""")
|
|
2931
|
+
attach_docstr("permute", r"""permute(*dims) -> Tensor
|
|
2932
|
+
|
|
2933
|
+
For details, please refer to :func:`mindspore.mint.permute`.
|
|
2934
|
+
|
|
2935
|
+
.. method:: Tensor.permute(*axis) -> Tensor
|
|
2936
|
+
:noindex:
|
|
2937
|
+
|
|
2938
|
+
For details, please refer to :func:`mindspore.ops.permute`.
|
|
2939
|
+
""")
|
|
2819
2940
|
attach_docstr("pow", r"""pow(exponent) -> Tensor
|
|
2820
2941
|
|
|
2821
2942
|
For details, please refer to :func:`mindspore.ops.pow`.
|
|
@@ -2936,6 +3057,10 @@ Examples:
|
|
|
2936
3057
|
[[4. 9. 5.]
|
|
2937
3058
|
[10. 7. 8.]]
|
|
2938
3059
|
""")
|
|
3060
|
+
attach_docstr("real", r"""real() -> Tensor
|
|
3061
|
+
|
|
3062
|
+
For details, please refer to :func:`mindspore.ops.real`.
|
|
3063
|
+
""")
|
|
2939
3064
|
attach_docstr("reciprocal", r"""reciprocal() -> Tensor
|
|
2940
3065
|
|
|
2941
3066
|
For details, please refer to :func:`mindspore.ops.reciprocal`.
|
|
@@ -3087,9 +3212,6 @@ elements in `repeats`.
|
|
|
3087
3212
|
repeats_{i} & \text{if } input.{rank} \le i < n \\
|
|
3088
3213
|
\end{cases}
|
|
3089
3214
|
|
|
3090
|
-
.. warning::
|
|
3091
|
-
This is an experimental API that is subject to change or deletion.
|
|
3092
|
-
|
|
3093
3215
|
.. note::
|
|
3094
3216
|
If need to specify the number of repetition times for each element of a single dimension, please
|
|
3095
3217
|
refer to :func:`mindspore.Tensor.repeat_interleave`.
|
|
@@ -3906,6 +4028,12 @@ Examples:
|
|
|
3906
4028
|
attach_docstr("sigmoid", r"""sigmoid() -> Tensor
|
|
3907
4029
|
|
|
3908
4030
|
For details, please refer to :func:`mindspore.ops.sigmoid`.""")
|
|
4031
|
+
attach_docstr("sigmoid_", r"""sigmoid_() -> Tensor
|
|
4032
|
+
|
|
4033
|
+
In-place version of :func:`mindspore.Tensor.sigmoid`.
|
|
4034
|
+
|
|
4035
|
+
.. warning::
|
|
4036
|
+
Only supports Ascend.""")
|
|
3909
4037
|
attach_docstr("sinc", r"""sinc() -> Tensor
|
|
3910
4038
|
|
|
3911
4039
|
For details, please refer to :func:`mindspore.ops.sinc`.
|
|
@@ -4086,6 +4214,9 @@ For details, please refer to :func:`mindspore.ops.sqrt`.
|
|
|
4086
4214
|
attach_docstr("square", r"""square() -> Tensor
|
|
4087
4215
|
|
|
4088
4216
|
For details, please refer to :func:`mindspore.ops.square`.""")
|
|
4217
|
+
attach_docstr("squeeze", r"""squeeze(*axis) -> Tensor
|
|
4218
|
+
|
|
4219
|
+
For details, please refer to :func:`mindspore.ops.squeeze`.""")
|
|
4089
4220
|
attach_docstr("std", r"""std(axis=None, ddof=0, keepdims=False) -> Tensor
|
|
4090
4221
|
|
|
4091
4222
|
For details, please refer to :func:`mindspore.ops.std`.
|
|
@@ -4531,13 +4662,106 @@ Examples:
|
|
|
4531
4662
|
|
|
4532
4663
|
For more details, please refer to :func:`mindspore.ops.topk`.
|
|
4533
4664
|
""")
|
|
4665
|
+
attach_docstr("to", r"""to(dtype=None, non_blocking=False, copy=False) -> Tensor
|
|
4666
|
+
|
|
4667
|
+
Returns a tensor with the new specified data type.
|
|
4668
|
+
|
|
4669
|
+
Note:
|
|
4670
|
+
- When converting complex numbers to boolean type, the imaginary part of the complex number is not
|
|
4671
|
+
taken into account. As long as the real part is non-zero, it returns True; otherwise, it returns False.
|
|
4672
|
+
- `non_blocking` and `copy` do not take effect in GRAPH_MODE or within jit.
|
|
4673
|
+
|
|
4674
|
+
Args:
|
|
4675
|
+
dtype (dtype.Number, optional): The valid data type of the output tensor. Default: ``None``.
|
|
4676
|
+
non_blocking(bool, optional): Data type conversion asynchronously. If ``True`` , convert data type asynchronously. If ``False`` , convert data type synchronously. Default: ``False`` .
|
|
4677
|
+
copy(bool, optional): When copy is set ``True`` , a new Tensor is created even when then Tensor already matches the desired conversion. Default: ``False`` .
|
|
4678
|
+
|
|
4679
|
+
Returns:
|
|
4680
|
+
Tensor, the data type of the tensor is `dtype` .
|
|
4681
|
+
|
|
4682
|
+
Supported Platforms:
|
|
4683
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
4684
|
+
|
|
4685
|
+
Examples:
|
|
4686
|
+
>>> import mindspore
|
|
4687
|
+
>>> import numpy as np
|
|
4688
|
+
>>> from mindspore import Tensor
|
|
4689
|
+
>>> input_np = np.random.randn(2, 3, 4, 5).astype(np.float32)
|
|
4690
|
+
>>> input = Tensor(input_np)
|
|
4691
|
+
>>> dtype = mindspore.int32
|
|
4692
|
+
>>> output = input.to(dtype)
|
|
4693
|
+
>>> print(output.dtype)
|
|
4694
|
+
Int32
|
|
4695
|
+
>>> print(output.shape)
|
|
4696
|
+
(2, 3, 4, 5)
|
|
4697
|
+
|
|
4698
|
+
.. method:: Tensor.to(device=None, dtype=None, non_blocking=False, copy=False) -> Tensor
|
|
4699
|
+
:noindex:
|
|
4700
|
+
|
|
4701
|
+
Returns a tensor with the new specified data type and device type.
|
|
4702
|
+
|
|
4703
|
+
Note:
|
|
4704
|
+
`device` , `non_blocking` and `copy` do not take effect in GRAPH_MODE or within jit.
|
|
4705
|
+
|
|
4706
|
+
Args:
|
|
4707
|
+
device(str, optional): The device type of the output tensor. Default: ``None`` .
|
|
4708
|
+
dtype (dtype.Number, optional): The valid data type of the output tensor. Default: ``None`` .
|
|
4709
|
+
non_blocking(bool, optional): Data type conversion asynchronously. If ``True`` , convert data type asynchronously. If ``False`` , convert data type synchronously. Default: ``False`` .
|
|
4710
|
+
copy(bool, optional): When copy is set ``True`` , a new Tensor is created even when then Tensor already matches the desired conversion. Default: ``False`` .
|
|
4711
|
+
|
|
4712
|
+
Returns:
|
|
4713
|
+
Tensor, the specified device type and data type of the tensor.
|
|
4714
|
+
|
|
4715
|
+
Supported Platforms:
|
|
4716
|
+
``Ascend`` ``CPU``
|
|
4717
|
+
|
|
4718
|
+
Examples:
|
|
4719
|
+
>>> import mindspore
|
|
4720
|
+
>>> import numpy as np
|
|
4721
|
+
>>> from mindspore import Tensor
|
|
4722
|
+
>>> input_np = np.random.randn(2, 3, 4, 5).astype(np.float32)
|
|
4723
|
+
>>> input = Tensor(input_np)
|
|
4724
|
+
>>> dtype = mindspore.int32
|
|
4725
|
+
>>> output = input.to("Ascend")
|
|
4726
|
+
>>> print(output.device)
|
|
4727
|
+
"Ascend:0"
|
|
4728
|
+
|
|
4729
|
+
.. method:: Tensor.to(other, non_blocking=False, copy=False) -> Tensor
|
|
4730
|
+
:noindex:
|
|
4731
|
+
|
|
4732
|
+
Returns a tensor with same device and dtype as the Tensor `other` .
|
|
4733
|
+
|
|
4734
|
+
Note:
|
|
4735
|
+
`non_blocking` and `copy` do not take effect in GRAPH_MODE or within jit.
|
|
4736
|
+
|
|
4737
|
+
Args:
|
|
4738
|
+
other(Tensor): The returned Tensor has the same device and dtype as `other` .
|
|
4739
|
+
non_blocking(bool, optional): Data type conversion asynchronously. If ``True`` , convert data type asynchronously. If ``False`` , convert data type synchronously. Default: ``False`` .
|
|
4740
|
+
copy(bool, optional): When copy is set ``True`` , a new Tensor is created even when then Tensor already matches the desired conversion. Default: ``False`` .
|
|
4741
|
+
|
|
4742
|
+
Returns:
|
|
4743
|
+
Tensor, same device and dtype as the Tensor `other` .
|
|
4744
|
+
|
|
4745
|
+
Supported Platforms:
|
|
4746
|
+
``Ascend`` ``CPU``
|
|
4747
|
+
|
|
4748
|
+
Examples:
|
|
4749
|
+
>>> import mindspore
|
|
4750
|
+
>>> import numpy as np
|
|
4751
|
+
>>> from mindspore import Tensor
|
|
4752
|
+
>>> input_np = np.random.randn(2, 3, 4, 5).astype(np.float32)
|
|
4753
|
+
>>> input = Tensor(input_np)
|
|
4754
|
+
>>> other = input.to("Ascend", dtype=mindspore.float16)
|
|
4755
|
+
>> output = input.to(other)
|
|
4756
|
+
>>> print(output.device)
|
|
4757
|
+
"Ascend:0"
|
|
4758
|
+
>>> print(output.dtype)
|
|
4759
|
+
float16
|
|
4760
|
+
""")
|
|
4534
4761
|
attach_docstr("transpose", r"""transpose(dim0, dim1) -> Tensor
|
|
4535
4762
|
|
|
4536
4763
|
Interchange two axes of a tensor.
|
|
4537
4764
|
|
|
4538
|
-
.. warning::
|
|
4539
|
-
This is an experimental API that is subject to change or deletion.
|
|
4540
|
-
|
|
4541
4765
|
Args:
|
|
4542
4766
|
dim0 (int): Specifies the first dimension to be transposed.
|
|
4543
4767
|
dim1 (int): Specifies the second dimension to be transposed.
|
|
@@ -4807,6 +5031,26 @@ Examples:
|
|
|
4807
5031
|
>>> print(output)
|
|
4808
5032
|
[1. 2. 3. 2. 3. 4.]
|
|
4809
5033
|
""")
|
|
5034
|
+
attach_docstr("view", r"""view(*shape) -> Tensor
|
|
5035
|
+
|
|
5036
|
+
Reshape the tensor according to the input `shape` .
|
|
5037
|
+
|
|
5038
|
+
Args:
|
|
5039
|
+
shape (Union[tuple(int), int]): Dimension of the output tensor.
|
|
5040
|
+
|
|
5041
|
+
Returns:
|
|
5042
|
+
Tensor, which dimension is the input shape's value.
|
|
5043
|
+
|
|
5044
|
+
Examples:
|
|
5045
|
+
>>> from mindspore import Tensor
|
|
5046
|
+
>>> import numpy as np
|
|
5047
|
+
>>> a = Tensor(np.array([[1, 2, 3], [2, 3, 4]], dtype=np.float32))
|
|
5048
|
+
>>> output = a.view((3, 2))
|
|
5049
|
+
>>> print(output)
|
|
5050
|
+
[[1. 2.]
|
|
5051
|
+
[3. 2.]
|
|
5052
|
+
[3. 4.]]
|
|
5053
|
+
""")
|
|
4810
5054
|
attach_docstr("where", r"""where(condition, y) -> Tensor
|
|
4811
5055
|
|
|
4812
5056
|
For details, please refer to :func:`mindspore.ops.where`.
|
|
@@ -4815,39 +5059,6 @@ attach_docstr("xlogy", r"""xlogy(other) -> Tensor
|
|
|
4815
5059
|
|
|
4816
5060
|
For details, please refer to :func:`mindspore.ops.xlogy`.
|
|
4817
5061
|
""")
|
|
4818
|
-
attach_docstr("_to", r"""_to(dtype) -> Tensor
|
|
4819
|
-
|
|
4820
|
-
Returns a tensor with the new specified data type.
|
|
4821
|
-
|
|
4822
|
-
Note:
|
|
4823
|
-
When converting complex numbers to boolean type, the imaginary part of the complex number is not
|
|
4824
|
-
taken into account. As long as the real part is non-zero, it returns True; otherwise, it returns False.
|
|
4825
|
-
|
|
4826
|
-
Args:
|
|
4827
|
-
dtype (dtype.Number): The valid data type of the output tensor. Only constant value is allowed.
|
|
4828
|
-
|
|
4829
|
-
Returns:
|
|
4830
|
-
Tensor, the data type of the tensor is `dtype`.
|
|
4831
|
-
|
|
4832
|
-
Raises:
|
|
4833
|
-
TypeError: If `dtype` is not a Number.
|
|
4834
|
-
|
|
4835
|
-
Supported Platforms:
|
|
4836
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
4837
|
-
|
|
4838
|
-
Examples:
|
|
4839
|
-
>>> import mindspore
|
|
4840
|
-
>>> import numpy as np
|
|
4841
|
-
>>> from mindspore import Tensor
|
|
4842
|
-
>>> input_np = np.random.randn(2, 3, 4, 5).astype(np.float32)
|
|
4843
|
-
>>> input = Tensor(input_np)
|
|
4844
|
-
>>> dtype = mindspore.int32
|
|
4845
|
-
>>> output = input._to(dtype)
|
|
4846
|
-
>>> print(output.dtype)
|
|
4847
|
-
Int32
|
|
4848
|
-
>>> print(output.shape)
|
|
4849
|
-
(2, 3, 4, 5)
|
|
4850
|
-
""")
|
|
4851
5062
|
attach_docstr("__abs__", r"""__abs__() -> Tensor
|
|
4852
5063
|
|
|
4853
5064
|
Alias for :func:`Tensor.abs`.
|
mindspore/common/_utils.py
CHANGED
|
@@ -16,15 +16,10 @@
|
|
|
16
16
|
# ============================================================================
|
|
17
17
|
"""common utils."""
|
|
18
18
|
|
|
19
|
-
import os
|
|
20
|
-
import math
|
|
21
19
|
import types
|
|
22
20
|
import ctypes
|
|
23
|
-
import functools
|
|
24
21
|
|
|
25
22
|
from mindspore import log as logger
|
|
26
|
-
from mindspore.common import dtype as mstype
|
|
27
|
-
from mindspore.parallel._ps_context import _is_ps_mode, _is_role_pserver, _is_role_sched
|
|
28
23
|
|
|
29
24
|
|
|
30
25
|
def is_shape_unknown(shape):
|
|
@@ -54,45 +49,6 @@ def get_func(func):
|
|
|
54
49
|
return func
|
|
55
50
|
|
|
56
51
|
|
|
57
|
-
def get_slice_num(dtype, shape):
|
|
58
|
-
"""Check whether size of data is too huge, and cut it to a smaller one, return slice num."""
|
|
59
|
-
slice_num = 1
|
|
60
|
-
need_split = _is_ps_mode() and (_is_role_pserver() or _is_role_sched())
|
|
61
|
-
|
|
62
|
-
if not need_split:
|
|
63
|
-
return slice_num
|
|
64
|
-
|
|
65
|
-
if "MS_EMBEDDING_REMOTE_CACHE_MEMORY_SIZE" not in os.environ:
|
|
66
|
-
return slice_num
|
|
67
|
-
|
|
68
|
-
num_element = functools.reduce(lambda x, y: x * y, shape, 1)
|
|
69
|
-
data_size = num_element * mstype.type_size_in_bytes(dtype)
|
|
70
|
-
remote_cache_size = int(os.getenv("MS_EMBEDDING_REMOTE_CACHE_MEMORY_SIZE")) << 30
|
|
71
|
-
if remote_cache_size == 0:
|
|
72
|
-
raise ValueError("The remote cache size set by env variable[MS_EMBEDDING_REMOTE_CACHE_MEMORY_SIZE]"
|
|
73
|
-
" should be greater than 0.")
|
|
74
|
-
|
|
75
|
-
if data_size <= remote_cache_size:
|
|
76
|
-
return slice_num
|
|
77
|
-
|
|
78
|
-
slice_num = math.ceil(data_size / remote_cache_size)
|
|
79
|
-
return slice_num
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def get_slice_shape(dtype, shape):
|
|
83
|
-
"""Check whether size of data is too huge, and cut it to a smaller one, return slice shape."""
|
|
84
|
-
slice_num = get_slice_num(dtype, shape)
|
|
85
|
-
if slice_num == 1:
|
|
86
|
-
return shape
|
|
87
|
-
|
|
88
|
-
new_shape = list(shape)
|
|
89
|
-
if slice_num == 0:
|
|
90
|
-
raise ValueError("The slice num is at least 1, but got 0")
|
|
91
|
-
slice_first_dim = math.ceil(new_shape[0] / slice_num)
|
|
92
|
-
new_shape[0] = slice_first_dim
|
|
93
|
-
return tuple(new_shape)
|
|
94
|
-
|
|
95
|
-
|
|
96
52
|
def _jit_fallback_raise_func(type_name, script):
|
|
97
53
|
"""raise function for jit fallback."""
|
|
98
54
|
raise type_name(script)
|