mindspore 2.3.0__cp39-cp39-win_amd64.whl → 2.4.0__cp39-cp39-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 +3 -1
- mindspore/_c_dataengine.cp39-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp39-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp39-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +50 -9
- mindspore/_extends/parse/compile_config.py +41 -0
- mindspore/_extends/parse/parser.py +9 -7
- mindspore/_extends/parse/standard_method.py +52 -14
- mindspore/_extends/pijit/pijit_func_white_list.py +350 -24
- mindspore/amp.py +24 -10
- 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/common/__init__.py +6 -4
- mindspore/common/_pijit_context.py +190 -0
- mindspore/common/_register_for_tensor.py +2 -1
- mindspore/common/_tensor_overload.py +139 -0
- mindspore/common/api.py +102 -87
- mindspore/common/dump.py +5 -6
- mindspore/common/generator.py +1 -7
- mindspore/common/hook_handle.py +14 -26
- mindspore/common/mindir_util.py +2 -2
- mindspore/common/parameter.py +46 -13
- mindspore/common/recompute.py +39 -9
- mindspore/common/sparse_tensor.py +7 -3
- mindspore/common/tensor.py +209 -29
- mindspore/communication/__init__.py +1 -1
- mindspore/communication/_comm_helper.py +38 -3
- mindspore/communication/comm_func.py +310 -55
- mindspore/communication/management.py +14 -14
- mindspore/context.py +123 -22
- mindspore/dataset/__init__.py +1 -1
- mindspore/dataset/audio/__init__.py +1 -1
- mindspore/dataset/core/config.py +7 -0
- mindspore/dataset/core/validator_helpers.py +7 -0
- mindspore/dataset/engine/cache_client.py +1 -1
- mindspore/dataset/engine/datasets.py +72 -44
- mindspore/dataset/engine/datasets_audio.py +7 -7
- mindspore/dataset/engine/datasets_standard_format.py +53 -3
- mindspore/dataset/engine/datasets_text.py +20 -20
- mindspore/dataset/engine/datasets_user_defined.py +174 -104
- mindspore/dataset/engine/datasets_vision.py +33 -33
- mindspore/dataset/engine/iterators.py +29 -0
- mindspore/dataset/engine/obs/util.py +7 -0
- mindspore/dataset/engine/queue.py +114 -60
- mindspore/dataset/engine/serializer_deserializer.py +2 -2
- mindspore/dataset/engine/validators.py +34 -14
- mindspore/dataset/text/__init__.py +1 -4
- mindspore/dataset/transforms/__init__.py +0 -3
- mindspore/dataset/utils/line_reader.py +2 -0
- mindspore/dataset/vision/__init__.py +1 -4
- mindspore/dataset/vision/utils.py +1 -1
- mindspore/dataset/vision/validators.py +2 -1
- mindspore/dnnl.dll +0 -0
- mindspore/{nn/extend → experimental/es}/__init__.py +4 -11
- mindspore/experimental/es/embedding_service.py +883 -0
- mindspore/{nn/layer → experimental/es}/embedding_service_layer.py +218 -30
- mindspore/experimental/llm_boost/__init__.py +21 -0
- mindspore/{nn/extend/layer → experimental/llm_boost/atb}/__init__.py +4 -8
- mindspore/experimental/llm_boost/atb/boost_base.py +211 -0
- mindspore/experimental/llm_boost/atb/llama_boost.py +115 -0
- mindspore/experimental/llm_boost/atb/qwen_boost.py +101 -0
- mindspore/experimental/llm_boost/register.py +129 -0
- mindspore/experimental/llm_boost/utils.py +31 -0
- mindspore/experimental/optim/adamw.py +85 -0
- mindspore/experimental/optim/optimizer.py +3 -0
- mindspore/hal/__init__.py +3 -3
- mindspore/hal/contiguous_tensors_handle.py +175 -0
- mindspore/hal/stream.py +18 -0
- mindspore/include/api/model_group.h +13 -1
- mindspore/include/api/types.h +10 -10
- mindspore/include/dataset/config.h +2 -2
- mindspore/include/dataset/constants.h +2 -2
- mindspore/include/dataset/execute.h +2 -2
- mindspore/include/dataset/vision.h +4 -0
- mindspore/jpeg62.dll +0 -0
- mindspore/log.py +1 -1
- mindspore/mindrecord/filewriter.py +68 -51
- mindspore/mindspore_backend.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_np_dtype.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mint/__init__.py +495 -46
- mindspore/mint/distributed/__init__.py +31 -0
- mindspore/mint/distributed/distributed.py +254 -0
- mindspore/mint/nn/__init__.py +266 -21
- mindspore/mint/nn/functional.py +125 -19
- mindspore/mint/nn/layer/__init__.py +39 -0
- mindspore/mint/nn/layer/activation.py +133 -0
- mindspore/mint/nn/layer/normalization.py +477 -0
- mindspore/mint/nn/layer/pooling.py +110 -0
- mindspore/mint/optim/adamw.py +28 -7
- mindspore/mint/special/__init__.py +63 -0
- mindspore/multiprocessing/__init__.py +2 -1
- mindspore/nn/__init__.py +0 -1
- mindspore/nn/cell.py +275 -93
- mindspore/nn/layer/activation.py +211 -44
- mindspore/nn/layer/basic.py +113 -3
- mindspore/nn/layer/embedding.py +120 -2
- mindspore/nn/layer/normalization.py +101 -5
- mindspore/nn/layer/padding.py +34 -48
- mindspore/nn/layer/pooling.py +161 -7
- mindspore/nn/layer/transformer.py +3 -3
- mindspore/nn/loss/__init__.py +2 -2
- mindspore/nn/loss/loss.py +84 -6
- mindspore/nn/optim/__init__.py +2 -1
- mindspore/nn/optim/adadelta.py +1 -1
- mindspore/nn/optim/adam.py +1 -1
- mindspore/nn/optim/lamb.py +1 -1
- mindspore/nn/optim/tft_wrapper.py +127 -0
- mindspore/nn/wrap/cell_wrapper.py +12 -23
- mindspore/nn/wrap/grad_reducer.py +5 -5
- mindspore/nn/wrap/loss_scale.py +17 -3
- mindspore/numpy/__init__.py +1 -1
- mindspore/numpy/array_creations.py +65 -68
- mindspore/numpy/array_ops.py +64 -60
- mindspore/numpy/fft.py +610 -75
- mindspore/numpy/logic_ops.py +11 -10
- mindspore/numpy/math_ops.py +85 -84
- mindspore/numpy/utils_const.py +4 -4
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/__init__.py +6 -4
- mindspore/ops/_grad_experimental/grad_comm_ops.py +47 -3
- mindspore/ops/_grad_experimental/grad_math_ops.py +0 -22
- mindspore/ops/_vmap/vmap_array_ops.py +2 -4
- mindspore/ops/_vmap/vmap_math_ops.py +17 -1
- mindspore/ops/_vmap/vmap_nn_ops.py +43 -2
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +85 -7
- mindspore/ops/auto_generate/gen_arg_dtype_cast.py +2 -0
- mindspore/ops/auto_generate/gen_extend_func.py +734 -13
- mindspore/ops/auto_generate/gen_ops_def.py +2420 -381
- mindspore/ops/auto_generate/gen_ops_prim.py +5196 -1659
- mindspore/ops/auto_generate/pyboost_inner_prim.py +176 -56
- mindspore/ops/composite/base.py +85 -48
- mindspore/ops/composite/multitype_ops/_compile_utils.py +1 -0
- mindspore/ops/composite/multitype_ops/not_in_impl.py +2 -2
- mindspore/ops/function/__init__.py +22 -0
- mindspore/ops/function/array_func.py +490 -153
- mindspore/ops/function/debug_func.py +113 -1
- mindspore/ops/function/fft_func.py +15 -2
- mindspore/ops/function/grad/grad_func.py +3 -2
- mindspore/ops/function/math_func.py +558 -207
- mindspore/ops/function/nn_func.py +817 -383
- mindspore/ops/function/other_func.py +3 -2
- mindspore/ops/function/random_func.py +184 -8
- mindspore/ops/function/reshard_func.py +13 -11
- mindspore/ops/function/sparse_unary_func.py +1 -1
- mindspore/ops/function/vmap_func.py +3 -2
- mindspore/ops/functional.py +24 -14
- mindspore/ops/op_info_register.py +3 -3
- mindspore/ops/operations/__init__.py +6 -1
- mindspore/ops/operations/_grad_ops.py +2 -76
- mindspore/ops/operations/_infer_ops.py +1 -1
- mindspore/ops/operations/_inner_ops.py +71 -94
- mindspore/ops/operations/array_ops.py +12 -146
- mindspore/ops/operations/comm_ops.py +42 -53
- mindspore/ops/operations/custom_ops.py +83 -19
- mindspore/ops/operations/debug_ops.py +42 -10
- mindspore/ops/operations/manually_defined/_inner.py +12 -0
- mindspore/ops/operations/manually_defined/ops_def.py +265 -10
- mindspore/ops/operations/math_ops.py +12 -223
- mindspore/ops/operations/nn_ops.py +20 -114
- mindspore/ops/operations/other_ops.py +7 -4
- mindspore/ops/operations/random_ops.py +46 -1
- mindspore/ops/primitive.py +18 -6
- mindspore/ops_generate/arg_dtype_cast.py +2 -0
- mindspore/ops_generate/gen_aclnn_implement.py +11 -11
- mindspore/ops_generate/gen_constants.py +36 -0
- mindspore/ops_generate/gen_ops.py +67 -52
- mindspore/ops_generate/gen_ops_inner_prim.py +1 -1
- mindspore/ops_generate/gen_pyboost_func.py +131 -47
- mindspore/ops_generate/op_proto.py +10 -3
- mindspore/ops_generate/pyboost_utils.py +14 -1
- mindspore/ops_generate/template.py +43 -21
- mindspore/parallel/__init__.py +3 -1
- mindspore/parallel/_auto_parallel_context.py +28 -8
- mindspore/parallel/_cell_wrapper.py +83 -0
- mindspore/parallel/_parallel_serialization.py +47 -19
- mindspore/parallel/_tensor.py +81 -11
- mindspore/parallel/_utils.py +13 -1
- mindspore/parallel/algo_parameter_config.py +5 -5
- mindspore/parallel/checkpoint_transform.py +46 -39
- mindspore/parallel/cluster/process_entity/__init__.py +1 -1
- mindspore/parallel/cluster/process_entity/_api.py +31 -23
- mindspore/parallel/cluster/process_entity/_utils.py +2 -27
- mindspore/parallel/parameter_broadcast.py +3 -4
- mindspore/parallel/shard.py +162 -31
- mindspore/parallel/transform_safetensors.py +993 -0
- mindspore/profiler/__init__.py +2 -1
- mindspore/profiler/common/constant.py +29 -0
- mindspore/profiler/common/registry.py +47 -0
- mindspore/profiler/common/util.py +28 -0
- mindspore/profiler/dynamic_profiler.py +694 -0
- mindspore/profiler/envprofiling.py +17 -19
- mindspore/profiler/parser/ascend_analysis/constant.py +18 -0
- mindspore/profiler/parser/ascend_analysis/file_manager.py +25 -4
- mindspore/profiler/parser/ascend_analysis/function_event.py +43 -19
- mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +31 -26
- mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +56 -10
- mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +55 -8
- mindspore/profiler/parser/ascend_analysis/path_manager.py +313 -0
- mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +27 -20
- mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +9 -2
- mindspore/profiler/parser/ascend_msprof_exporter.py +5 -4
- mindspore/profiler/parser/ascend_timeline_generator.py +27 -25
- mindspore/profiler/parser/base_timeline_generator.py +19 -25
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +25 -12
- mindspore/profiler/parser/framework_parser.py +1 -391
- mindspore/profiler/parser/gpu_analysis/__init__.py +14 -0
- mindspore/profiler/parser/gpu_analysis/function_event.py +44 -0
- mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +89 -0
- mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +72 -0
- mindspore/profiler/parser/memory_usage_parser.py +0 -154
- mindspore/profiler/parser/profiler_info.py +78 -6
- mindspore/profiler/profiler.py +153 -0
- mindspore/profiler/profiling.py +280 -412
- mindspore/rewrite/__init__.py +1 -2
- mindspore/rewrite/common/namespace.py +4 -4
- mindspore/rewrite/symbol_tree/symbol_tree.py +3 -3
- mindspore/run_check/_check_version.py +36 -103
- mindspore/safeguard/rewrite_obfuscation.py +591 -247
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/__init__.py +4 -3
- mindspore/train/_utils.py +28 -2
- mindspore/train/amp.py +171 -53
- mindspore/train/callback/__init__.py +2 -2
- mindspore/train/callback/_callback.py +4 -4
- mindspore/train/callback/_checkpoint.py +85 -22
- mindspore/train/callback/_cluster_monitor.py +1 -1
- mindspore/train/callback/_flops_collector.py +1 -0
- mindspore/train/callback/_loss_monitor.py +3 -3
- mindspore/train/callback/_on_request_exit.py +134 -31
- mindspore/train/callback/_summary_collector.py +5 -5
- mindspore/train/callback/_tft_register.py +352 -0
- mindspore/train/dataset_helper.py +7 -3
- mindspore/train/metrics/metric.py +3 -3
- mindspore/train/metrics/roc.py +4 -4
- mindspore/train/mind_ir_pb2.py +44 -39
- mindspore/train/model.py +134 -58
- mindspore/train/serialization.py +336 -112
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +21 -0
- mindspore/utils/utils.py +60 -0
- mindspore/version.py +1 -1
- {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/METADATA +6 -2
- {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/RECORD +258 -252
- mindspore/include/c_api/ms/abstract.h +0 -67
- mindspore/include/c_api/ms/attribute.h +0 -197
- mindspore/include/c_api/ms/base/handle_types.h +0 -43
- mindspore/include/c_api/ms/base/macros.h +0 -32
- mindspore/include/c_api/ms/base/status.h +0 -33
- mindspore/include/c_api/ms/base/types.h +0 -283
- mindspore/include/c_api/ms/context.h +0 -102
- mindspore/include/c_api/ms/graph.h +0 -160
- mindspore/include/c_api/ms/node.h +0 -606
- mindspore/include/c_api/ms/tensor.h +0 -161
- mindspore/include/c_api/ms/value.h +0 -84
- mindspore/mindspore_shared_lib.dll +0 -0
- mindspore/nn/extend/basic.py +0 -140
- mindspore/nn/extend/embedding.py +0 -143
- mindspore/nn/extend/layer/normalization.py +0 -109
- mindspore/nn/extend/pooling.py +0 -117
- mindspore/nn/layer/embedding_service.py +0 -531
- mindspore/ops/_op_impl/aicpu/strided_slice_v2.py +0 -93
- mindspore/ops/_op_impl/aicpu/strided_slice_v2_grad.py +0 -66
- mindspore/ops/extend/__init__.py +0 -53
- mindspore/ops/extend/array_func.py +0 -218
- mindspore/ops/extend/math_func.py +0 -76
- mindspore/ops/extend/nn_func.py +0 -308
- mindspore/ops/silent_check.py +0 -162
- mindspore/profiler/parser/msadvisor_analyzer.py +0 -82
- mindspore/profiler/parser/msadvisor_parser.py +0 -240
- mindspore/train/callback/_mindio_ttp.py +0 -443
- {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/WHEEL +0 -0
- {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/entry_points.txt +0 -0
- {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/top_level.txt +0 -0
mindspore/numpy/array_ops.py
CHANGED
|
@@ -87,7 +87,7 @@ def squeeze(a, axis=None):
|
|
|
87
87
|
|
|
88
88
|
Args:
|
|
89
89
|
a (Tensor): Input tensor array.
|
|
90
|
-
axis (Union[None, int, list(int), tuple(list)]): The axis(axes) to squeeze,
|
|
90
|
+
axis (Union[None, int, list(int), tuple(list)], optional): The axis(axes) to squeeze,
|
|
91
91
|
default: ``None`` .
|
|
92
92
|
|
|
93
93
|
Returns:
|
|
@@ -117,7 +117,7 @@ def transpose(a, axes=None):
|
|
|
117
117
|
|
|
118
118
|
Args:
|
|
119
119
|
a (Tensor): a tensor to be transposed
|
|
120
|
-
axes (Union[None, tuple, list]): the axes order, if `axes` is `None`, transpose
|
|
120
|
+
axes (Union[None, tuple, list], optional): the axes order, if `axes` is `None`, transpose
|
|
121
121
|
the entire tensor. Default: ``None`` .
|
|
122
122
|
|
|
123
123
|
Returns:
|
|
@@ -211,7 +211,7 @@ def rollaxis(x, axis, start=0):
|
|
|
211
211
|
if start < axis:
|
|
212
212
|
if axis + 1 < ndim:
|
|
213
213
|
new_perm = perm[0:start] + perm[axis:axis + 1] + \
|
|
214
|
-
perm[start:axis] + perm[axis+1:]
|
|
214
|
+
perm[start:axis] + perm[axis + 1:]
|
|
215
215
|
else:
|
|
216
216
|
new_perm = perm[0:start] + perm[axis:axis + 1] + perm[start:axis]
|
|
217
217
|
if start > axis:
|
|
@@ -219,7 +219,7 @@ def rollaxis(x, axis, start=0):
|
|
|
219
219
|
new_perm = perm[0:axis] + perm[axis + 1:start] + \
|
|
220
220
|
perm[axis:axis + 1] + perm[start:]
|
|
221
221
|
else:
|
|
222
|
-
new_perm = perm[0:axis] + perm[axis+1:start] + \
|
|
222
|
+
new_perm = perm[0:axis] + perm[axis + 1:start] + \
|
|
223
223
|
perm[axis:axis + 1]
|
|
224
224
|
|
|
225
225
|
return F.transpose(x, new_perm)
|
|
@@ -401,6 +401,8 @@ def concatenate(arrays, axis=0):
|
|
|
401
401
|
>>> print(x.shape)
|
|
402
402
|
(1, 2, 4)
|
|
403
403
|
"""
|
|
404
|
+
if arrays is None:
|
|
405
|
+
_raise_type_error('expect Union[Tensor, tuple(Tensor), list(Tensor)], but got None')
|
|
404
406
|
if isinstance(arrays, Tensor):
|
|
405
407
|
# if only one tensor is provided, it is treated as a tuple along the
|
|
406
408
|
# first dimension. For example, a tensor of shape (3,4,5) will be treated
|
|
@@ -447,7 +449,7 @@ def append(arr, values, axis=None):
|
|
|
447
449
|
values (Tensor): These values are appended to a copy of `arr`. It must be of
|
|
448
450
|
the correct shape (the same shape as `arr`, excluding `axis`). If `axis` is
|
|
449
451
|
not specified, `values` can be any shape and will be flattened before use.
|
|
450
|
-
axis (
|
|
452
|
+
axis (int, optional): The `axis` along which values are appended. If `axis` is not
|
|
451
453
|
given, both `arr` and `values` are flattened before use, default is ``None``.
|
|
452
454
|
|
|
453
455
|
Returns:
|
|
@@ -669,12 +671,12 @@ def where(condition, x=None, y=None):
|
|
|
669
671
|
|
|
670
672
|
Note:
|
|
671
673
|
As nonzero is not supported, both `x` and `y` must be provided Tensor
|
|
672
|
-
|
|
674
|
+
input.
|
|
673
675
|
|
|
674
676
|
Args:
|
|
675
677
|
condition (Tensor): where True, yield `x`, otherwise yield `y`.
|
|
676
|
-
x (Tensor): Values from which to choose. Default: ``None`` .
|
|
677
|
-
y (Tensor): Values from which to choose. `x`, `y` and `condition` need
|
|
678
|
+
x (Tensor, optional): Values from which to choose. Default: ``None`` .
|
|
679
|
+
y (Tensor, optional): Values from which to choose. `x`, `y` and `condition` need
|
|
678
680
|
to be broadcastable to some shape. Default: ``None`` .
|
|
679
681
|
|
|
680
682
|
Returns:
|
|
@@ -929,7 +931,7 @@ def stack(arrays, axis=0):
|
|
|
929
931
|
ndim = F.rank(arrays)
|
|
930
932
|
axis = axis % ndim
|
|
931
933
|
axes = F.make_range(ndim)
|
|
932
|
-
perm = axes[1:axis+1] + (0,) + axes[axis+1:]
|
|
934
|
+
perm = axes[1:axis + 1] + (0,) + axes[axis + 1:]
|
|
933
935
|
if _is_shape_empty(shape):
|
|
934
936
|
return _empty(mstype.float32, shape[1:axis + 1] + (shape[0],) + shape[axis + 1:])
|
|
935
937
|
return transpose(arrays, perm)
|
|
@@ -969,7 +971,7 @@ def unique(x, return_inverse=False):
|
|
|
969
971
|
|
|
970
972
|
Args:
|
|
971
973
|
x (Tensor): The input tensor to be processed.
|
|
972
|
-
return_inverse (bool): If `True`, also return the indices of the unique tensor.
|
|
974
|
+
return_inverse (bool, optional): If `True`, also return the indices of the unique tensor.
|
|
973
975
|
Default: ``False`` .
|
|
974
976
|
|
|
975
977
|
Returns:
|
|
@@ -1151,9 +1153,9 @@ def moveaxis(a, source, destination):
|
|
|
1151
1153
|
|
|
1152
1154
|
Args:
|
|
1153
1155
|
a (Tensor): The array whose axes should be reordered.
|
|
1154
|
-
source (int
|
|
1156
|
+
source (int, sequence of ints): Original positions of the
|
|
1155
1157
|
axes to move. These must be unique.
|
|
1156
|
-
destination (int
|
|
1158
|
+
destination (int, sequence of ints): Destination positions
|
|
1157
1159
|
for each of the original axes. These must also be unique.
|
|
1158
1160
|
|
|
1159
1161
|
Returns:
|
|
@@ -1203,7 +1205,7 @@ def tile(a, reps):
|
|
|
1203
1205
|
|
|
1204
1206
|
Args:
|
|
1205
1207
|
a (Tensor): The input array.
|
|
1206
|
-
reps (int
|
|
1208
|
+
reps (int, sequence of ints): The number of repetitions of `a` along
|
|
1207
1209
|
each axis.
|
|
1208
1210
|
|
|
1209
1211
|
Returns:
|
|
@@ -1270,14 +1272,14 @@ def broadcast_to(array, shape):
|
|
|
1270
1272
|
Supported Platforms:
|
|
1271
1273
|
``Ascend`` ``GPU`` ``CPU``
|
|
1272
1274
|
|
|
1273
|
-
|
|
1275
|
+
Examples:
|
|
1274
1276
|
>>> import mindspore.numpy as np
|
|
1275
1277
|
>>> x = np.array([1, 2, 3])
|
|
1276
1278
|
>>> output = np.broadcast_to(x, (3, 3))
|
|
1277
1279
|
>>> print(output)
|
|
1278
1280
|
[[1 2 3]
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
+
[1 2 3]
|
|
1282
|
+
[1 2 3]]
|
|
1281
1283
|
"""
|
|
1282
1284
|
def _check(shape_a, shape):
|
|
1283
1285
|
if not _check_can_broadcast_to(shape_a, shape):
|
|
@@ -1308,7 +1310,7 @@ def broadcast_arrays(*args):
|
|
|
1308
1310
|
Supported Platforms:
|
|
1309
1311
|
``Ascend`` ``GPU`` ``CPU``
|
|
1310
1312
|
|
|
1311
|
-
|
|
1313
|
+
Examples:
|
|
1312
1314
|
>>> import mindspore.numpy as np
|
|
1313
1315
|
>>> x = np.array([[1,2,3]])
|
|
1314
1316
|
>>> y = np.array([[4],[5]])
|
|
@@ -1329,16 +1331,16 @@ def broadcast_arrays(*args):
|
|
|
1329
1331
|
|
|
1330
1332
|
|
|
1331
1333
|
def array_split(x, indices_or_sections, axis=0):
|
|
1332
|
-
"""
|
|
1334
|
+
r"""
|
|
1333
1335
|
Splits a tensor into multiple sub-tensors.
|
|
1334
1336
|
|
|
1335
1337
|
Note:
|
|
1336
|
-
Currently, array_split only supports
|
|
1338
|
+
Currently, array_split only supports ``mindspore.float32`` on ``CPU``.
|
|
1337
1339
|
|
|
1338
1340
|
The only difference between ``np.split`` and ``np.array_split`` is that
|
|
1339
1341
|
``np.array_split`` allows indices_or_sections to be an integer that does not
|
|
1340
1342
|
equally divide the axis. For a tensor of length l that should be split into
|
|
1341
|
-
n sections, it returns :math:`l
|
|
1343
|
+
n sections, it returns :math:`l \% n` sub-arrays of size :math:`l//n + 1` and
|
|
1342
1344
|
the rest of size :math:`l//n`.
|
|
1343
1345
|
|
|
1344
1346
|
Args:
|
|
@@ -1349,7 +1351,7 @@ def array_split(x, indices_or_sections, axis=0):
|
|
|
1349
1351
|
If tuple(int), list(int) or of sorted integers,
|
|
1350
1352
|
the entries indicate where along axis the array is split.
|
|
1351
1353
|
For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
|
|
1352
|
-
three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
|
|
1354
|
+
three sub-tensors :math:`x[:2]`, :math:`x[2:3]` and :math:`x[3:]`.
|
|
1353
1355
|
If an index exceeds the dimension of the array along axis,
|
|
1354
1356
|
an empty sub-array is returned correspondingly.
|
|
1355
1357
|
axis (int): The axis along which to split. Default: ``0`` .
|
|
@@ -1394,10 +1396,10 @@ def split(x, indices_or_sections, axis=0):
|
|
|
1394
1396
|
If tuple(int), list(int) or of sorted integers,
|
|
1395
1397
|
the entries indicate where along axis the array is split.
|
|
1396
1398
|
For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
|
|
1397
|
-
three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
|
|
1399
|
+
three sub-tensors :math:`x[:2]`, :math:`x[2:3]` and :math:`x[3:]`.
|
|
1398
1400
|
If an index exceeds the dimension of the array along axis,
|
|
1399
1401
|
an empty sub-array is returned correspondingly.
|
|
1400
|
-
axis (int): The axis along which to split. Default: ``0`` .
|
|
1402
|
+
axis (int, optional): The axis along which to split. Default: ``0`` .
|
|
1401
1403
|
|
|
1402
1404
|
Returns:
|
|
1403
1405
|
A tuple of sub-tensors.
|
|
@@ -1481,7 +1483,7 @@ def _split_sub_tensors(x, indices, axis):
|
|
|
1481
1483
|
begin = _list_comprehensions(x.ndim, 0)
|
|
1482
1484
|
end = _list_comprehensions(x.shape)
|
|
1483
1485
|
for i, idx in enumerate(indices):
|
|
1484
|
-
begin[axis] = 0 if i == 0 else indices[i-1]
|
|
1486
|
+
begin[axis] = 0 if i == 0 else indices[i - 1]
|
|
1485
1487
|
end[axis] = idx
|
|
1486
1488
|
if end[axis] <= begin[axis]:
|
|
1487
1489
|
_raise_value_error("empty sub-tensor encountered.")
|
|
@@ -1504,7 +1506,7 @@ def vsplit(x, indices_or_sections):
|
|
|
1504
1506
|
If tuple(int), list(int) or of sorted integers,
|
|
1505
1507
|
the entries indicate where along axis the array is split.
|
|
1506
1508
|
For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
|
|
1507
|
-
three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
|
|
1509
|
+
three sub-tensors :math:`x[:2]`, :math:`x[2:3]` and :math:`x[3:]`.
|
|
1508
1510
|
If an index exceeds the dimension of the array along axis,
|
|
1509
1511
|
an empty sub-array is returned correspondingly.
|
|
1510
1512
|
|
|
@@ -1546,7 +1548,7 @@ def hsplit(x, indices_or_sections):
|
|
|
1546
1548
|
If tuple(int), list(int) or of sorted integers,
|
|
1547
1549
|
the entries indicate where along axis the array is split.
|
|
1548
1550
|
For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
|
|
1549
|
-
three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
|
|
1551
|
+
three sub-tensors :math:`x[:2]`, :math:`x[2:3]` and :math:`x[3:]`.
|
|
1550
1552
|
If an index exceeds the dimension of the array along axis,
|
|
1551
1553
|
an empty sub-array is returned correspondingly.
|
|
1552
1554
|
|
|
@@ -1591,7 +1593,7 @@ def dsplit(x, indices_or_sections):
|
|
|
1591
1593
|
If tuple(int), list(int) or of sorted integers,
|
|
1592
1594
|
the entries indicate where along axis the array is split.
|
|
1593
1595
|
For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
|
|
1594
|
-
three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
|
|
1596
|
+
three sub-tensors :math:`x[:2]`, :math:`x[2:3]` and :math:`x[3:]`.
|
|
1595
1597
|
If an index exceeds the dimension of the array along axis,
|
|
1596
1598
|
an empty sub-array is returned correspondingly.
|
|
1597
1599
|
|
|
@@ -1645,7 +1647,7 @@ def flip(m, axis=None):
|
|
|
1645
1647
|
|
|
1646
1648
|
Args:
|
|
1647
1649
|
m (Tensor): Input array.
|
|
1648
|
-
axis (
|
|
1650
|
+
axis (Union[int, tuple(int), None], optional): Axis or axes along which
|
|
1649
1651
|
to flip over. The default, ``axis=None``, will flip over all of the axes
|
|
1650
1652
|
of the input array. If `axis` is negative it counts from the last to
|
|
1651
1653
|
the first axis. If `axis` is a tuple of integers, flipping is performed on
|
|
@@ -1660,21 +1662,21 @@ def flip(m, axis=None):
|
|
|
1660
1662
|
Supported Platforms:
|
|
1661
1663
|
``GPU`` ``CPU``
|
|
1662
1664
|
|
|
1663
|
-
|
|
1665
|
+
Examples:
|
|
1664
1666
|
>>> import mindspore.numpy as np
|
|
1665
1667
|
>>> A = np.arange(8.0).reshape((2,2,2))
|
|
1666
1668
|
>>> output = np.flip(A)
|
|
1667
1669
|
>>> print(output)
|
|
1668
1670
|
[[[7. 6.]
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1671
|
+
[5. 4.]]
|
|
1672
|
+
[[3. 2.]
|
|
1673
|
+
[1. 0.]]]
|
|
1672
1674
|
>>> output = np.flip(A, (0, 2))
|
|
1673
1675
|
>>> print(output)
|
|
1674
1676
|
[[[5. 4.]
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1677
|
+
[7. 6.]]
|
|
1678
|
+
[[1. 0.]
|
|
1679
|
+
[3. 2.]]]
|
|
1678
1680
|
"""
|
|
1679
1681
|
_check_input_tensor(m)
|
|
1680
1682
|
ndim = F.rank(m)
|
|
@@ -1711,15 +1713,15 @@ def flipud(m):
|
|
|
1711
1713
|
Supported Platforms:
|
|
1712
1714
|
``GPU`` ``CPU``
|
|
1713
1715
|
|
|
1714
|
-
|
|
1716
|
+
Examples:
|
|
1715
1717
|
>>> import mindspore.numpy as np
|
|
1716
1718
|
>>> A = np.arange(8.0).reshape((2,2,2))
|
|
1717
1719
|
>>> output = np.flipud(A)
|
|
1718
1720
|
>>> print(output)
|
|
1719
1721
|
[[[4. 5.]
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1722
|
+
[6. 7.]]
|
|
1723
|
+
[[0. 1.]
|
|
1724
|
+
[2. 3.]]]
|
|
1723
1725
|
"""
|
|
1724
1726
|
return flip(m, 0)
|
|
1725
1727
|
|
|
@@ -1741,15 +1743,15 @@ def fliplr(m):
|
|
|
1741
1743
|
Supported Platforms:
|
|
1742
1744
|
``GPU`` ``CPU``
|
|
1743
1745
|
|
|
1744
|
-
|
|
1746
|
+
Examples:
|
|
1745
1747
|
>>> import mindspore.numpy as np
|
|
1746
1748
|
>>> A = np.arange(8.0).reshape((2,2,2))
|
|
1747
1749
|
>>> output = np.fliplr(A)
|
|
1748
1750
|
>>> print(output)
|
|
1749
1751
|
[[[2. 3.]
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1752
|
+
[0. 1.]]
|
|
1753
|
+
[[6. 7.]
|
|
1754
|
+
[4. 5.]]]
|
|
1753
1755
|
"""
|
|
1754
1756
|
return flip(m, 1)
|
|
1755
1757
|
|
|
@@ -1780,15 +1782,15 @@ def take_along_axis(arr, indices, axis):
|
|
|
1780
1782
|
Supported Platforms:
|
|
1781
1783
|
``Ascend`` ``GPU`` ``CPU``
|
|
1782
1784
|
|
|
1783
|
-
|
|
1785
|
+
Examples:
|
|
1784
1786
|
>>> import mindspore.numpy as np
|
|
1785
1787
|
>>> x = np.arange(12).reshape(3, 4)
|
|
1786
1788
|
>>> indices = np.arange(3).reshape(1, 3)
|
|
1787
1789
|
>>> output = np.take_along_axis(x, indices, 1)
|
|
1788
1790
|
>>> print(output)
|
|
1789
1791
|
[[ 0 1 2]
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
+
[ 4 5 6]
|
|
1793
|
+
[ 8 9 10]]
|
|
1792
1794
|
"""
|
|
1793
1795
|
_check_input_tensor(arr, indices)
|
|
1794
1796
|
if axis is None:
|
|
@@ -1861,11 +1863,11 @@ def take(a, indices, axis=None, mode='clip'):
|
|
|
1861
1863
|
mode ('raise', 'wrap', 'clip', optional): Specifies how out-of-bounds
|
|
1862
1864
|
indices will behave. Default: ``'clip'`` .
|
|
1863
1865
|
|
|
1864
|
-
'raise'
|
|
1866
|
+
'raise' - raise an error;
|
|
1865
1867
|
|
|
1866
|
-
'wrap'
|
|
1868
|
+
'wrap' - wrap around;
|
|
1867
1869
|
|
|
1868
|
-
'clip'
|
|
1870
|
+
'clip' - clip to the range. 'clip' mode means that all indices that are
|
|
1869
1871
|
too large are replaced by the index that addresses the last element
|
|
1870
1872
|
along that axis. Note that this disables indexing with negative numbers.
|
|
1871
1873
|
|
|
@@ -1902,7 +1904,7 @@ def repeat(a, repeats, axis=None):
|
|
|
1902
1904
|
|
|
1903
1905
|
Args:
|
|
1904
1906
|
a (Tensor): Input array.
|
|
1905
|
-
repeats (int
|
|
1907
|
+
repeats (int, sequence of ints): The number of repetitions for each element.
|
|
1906
1908
|
`repeats` is broadcasted to fit the shape of the given axis.
|
|
1907
1909
|
axis (int, optional): The axis along which to repeat values. By default,
|
|
1908
1910
|
use the flattened input array, and return a flat output array. Default: ``None`` .
|
|
@@ -1949,7 +1951,7 @@ def rot90(a, k=1, axes=(0, 1)):
|
|
|
1949
1951
|
Args:
|
|
1950
1952
|
a (Tensor): Input tensor of two or more dimensions.
|
|
1951
1953
|
k (int): Number of times the tensor is rotated by 90 degrees. Default: ``1`` .
|
|
1952
|
-
axes (Union[tuple(int), list(int)]): The tensor is rotated in the plane
|
|
1954
|
+
axes (Union[tuple(int), list(int)], optional): The tensor is rotated in the plane
|
|
1953
1955
|
defined by the axes. Default: ``(0, 1)`` .
|
|
1954
1956
|
Axes must be different and with the shape of `(2,)`.
|
|
1955
1957
|
|
|
@@ -2137,11 +2139,11 @@ def choose(a, choices, mode='clip'):
|
|
|
2137
2139
|
mode ('raise', 'wrap', 'clip', optional): Specifies how indices outside
|
|
2138
2140
|
``[0, n-1]`` will be treated:
|
|
2139
2141
|
|
|
2140
|
-
'raise'
|
|
2142
|
+
'raise' - raise an error;
|
|
2141
2143
|
|
|
2142
|
-
'wrap'
|
|
2144
|
+
'wrap' - wrap around;
|
|
2143
2145
|
|
|
2144
|
-
'clip'
|
|
2146
|
+
'clip' - clip to the range. 'clip' mode means that all indices that are
|
|
2145
2147
|
too large are replaced by the index that addresses the last element
|
|
2146
2148
|
along that axis. Note that this disables indexing with negative numbers.
|
|
2147
2149
|
|
|
@@ -2205,7 +2207,7 @@ def size(a, axis=None):
|
|
|
2205
2207
|
|
|
2206
2208
|
Args:
|
|
2207
2209
|
a (Union[int, float, bool, list, tuple, Tensor]): Input data.
|
|
2208
|
-
axis (int): Axis along which the elements are counted. Default: ``None``.
|
|
2210
|
+
axis (int, optional): Axis along which the elements are counted. Default: ``None``.
|
|
2209
2211
|
If None, give the total number of elements.
|
|
2210
2212
|
|
|
2211
2213
|
Returns:
|
|
@@ -2349,14 +2351,14 @@ def piecewise(x, condlist, funclist, *args, **kw):
|
|
|
2349
2351
|
|
|
2350
2352
|
Args:
|
|
2351
2353
|
x (Union[int, float, bool, list, tuple, Tensor]): The input domain.
|
|
2352
|
-
condlist (Union[bool, list
|
|
2354
|
+
condlist (Union[bool, list[Tensor, bool]]): Each boolean array corresponds to a
|
|
2353
2355
|
function in `funclist`. Wherever `condlist[i]` is True, `funclist[i](x)` is used as
|
|
2354
2356
|
the output value. Each boolean array in `condlist` selects a piece of `x`, and
|
|
2355
2357
|
should therefore be of the same shape as `x`. The length of `condlist` must
|
|
2356
2358
|
correspond to that of `funclist`. If one extra function is given, i.e. if
|
|
2357
2359
|
``len(funclist) == len(condlist) + 1``, then that extra function is the default
|
|
2358
2360
|
value, used wherever all conditions are false.
|
|
2359
|
-
funclist (Union[list
|
|
2361
|
+
funclist (Union[list[callables], list[scalars]]): Each function is evaluated over
|
|
2360
2362
|
`x` wherever its corresponding condition is True. It should take a 1d array as input
|
|
2361
2363
|
and give an 1d array or a scalar value as output. If, instead of a callable, a scalar
|
|
2362
2364
|
is provided then a constant function ``(lambda x: scalar)`` is assumed.
|
|
@@ -2416,7 +2418,7 @@ def unravel_index(indices, shape, order='C'):
|
|
|
2416
2418
|
Args:
|
|
2417
2419
|
indices (Union[int, float, bool, list, tuple, Tensor]): An integer array whose elements
|
|
2418
2420
|
are indices into the flattened version of an array of dimensions shape.
|
|
2419
|
-
shape (tuple
|
|
2421
|
+
shape (tuple(int)): The shape of the array to use for unraveling indices.
|
|
2420
2422
|
order (Union['C', 'F'], optional): Determines whether the indices should be viewed as
|
|
2421
2423
|
indexing in row-major (C-style) or column-major (Fortran-style) order. Default: ``'C'`` .
|
|
2422
2424
|
|
|
@@ -2528,7 +2530,7 @@ def argwhere(a):
|
|
|
2528
2530
|
|
|
2529
2531
|
Returns:
|
|
2530
2532
|
Tensor. Indices of elements that are non-zero. Indices are grouped by element.
|
|
2531
|
-
This Tensor will have shape :math:`(N, a.ndim)` where N is the number of non-zero items.
|
|
2533
|
+
This Tensor will have shape :math:`(N, a.ndim)` where :math:`N` is the number of non-zero items.
|
|
2532
2534
|
|
|
2533
2535
|
Raises:
|
|
2534
2536
|
TypeError: If input `a` is not array_like.
|
|
@@ -2617,7 +2619,9 @@ def intersect1d(ar1, ar2, assume_unique=False, return_indices=False):
|
|
|
2617
2619
|
|
|
2618
2620
|
if return_indices:
|
|
2619
2621
|
ar1_indices = F.masked_select(concat_sort_indices[:-1], mask_res)
|
|
2620
|
-
ar2_indices = F.masked_select(concat_sort_indices[1:], mask_res)
|
|
2622
|
+
ar2_indices = F.masked_select(concat_sort_indices[1:], mask_res)
|
|
2623
|
+
if ar2_indices.shape[0] > 0:
|
|
2624
|
+
ar2_indices = ar2_indices - array1.size
|
|
2621
2625
|
if not assume_unique:
|
|
2622
2626
|
ar1_indices = ind1.index_select(0, ar1_indices)
|
|
2623
2627
|
ar2_indices = ind2.index_select(0, ar2_indices)
|