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
|
@@ -26,25 +26,35 @@ import mindspore as ms
|
|
|
26
26
|
from mindspore import log as logger
|
|
27
27
|
import mindspore.ops as ops
|
|
28
28
|
from mindspore.common import dtype as mstype
|
|
29
|
+
from mindspore.common.generator import default_generator
|
|
29
30
|
from mindspore.ops import operations as P
|
|
30
31
|
from mindspore.ops import composite as C
|
|
31
32
|
from mindspore.ops.composite.multitype_ops import _constexpr_utils as const_utils
|
|
32
33
|
from mindspore.ops.primitive import constexpr, _primexpr
|
|
33
34
|
from mindspore.ops.operations._inner_ops import TileSize
|
|
34
|
-
from mindspore.ops.auto_generate import Cummin, BatchMatMul,
|
|
35
|
+
from mindspore.ops.auto_generate import Cummin, BatchMatMul, BernoulliExt, lin_space_ext_op, BitwiseAndScalar,\
|
|
36
|
+
BitwiseAndTensor, BitwiseOrScalar, BitwiseOrTensor, BitwiseXorScalar, BitwiseXorTensor, RemainderTensorTensor,\
|
|
37
|
+
RemainderTensorScalar, RemainderScalarTensor
|
|
35
38
|
from mindspore.ops import auto_generate
|
|
36
39
|
from mindspore.ops.operations.math_ops import STFT
|
|
37
40
|
from mindspore.ops.operations.math_ops import LuUnpack
|
|
38
|
-
from mindspore.ops.
|
|
41
|
+
from mindspore.ops.auto_generate.pyboost_inner_prim import roll_impl, cross_impl
|
|
39
42
|
from mindspore.ops.operations.math_ops import Ormqr
|
|
40
43
|
from mindspore.ops.operations.math_ops import DivMod
|
|
41
44
|
from mindspore.ops.operations.array_ops import MatrixSetDiagV3, Transpose
|
|
42
|
-
from mindspore.ops.auto_generate import (minimum, maximum, mul, sin, sinc, sinh, cummax, real, conj, add, sub, cos,
|
|
45
|
+
from mindspore.ops.auto_generate import (minimum, maximum, mul, sin, sinc, sinh, cummax, real, conj, add, sub, cos,
|
|
46
|
+
cosh, nan_to_num, norm_op, lp_norm_v2_op,
|
|
43
47
|
matrix_exp, sqrt, rsqrt, square, trace, nextafter, abs, acos, acosh, angle,
|
|
44
48
|
asin, asinh, atan, atan2, atanh, ceil, equal, erf, erfc, erfinv, exp, expm1,
|
|
45
49
|
floor, floor_divide, floor_mod, gcd, greater, greater_equal, less, less_equal,
|
|
46
|
-
log, log1p, neg, not_equal, pow,
|
|
47
|
-
sum_ext_op, prod_ext_op, all, matrix_inverse_ext, atan2_ext, sign
|
|
50
|
+
log, log1p, neg, not_equal, pow, round_op, isfinite, argmax_ext, mean_ext_op,
|
|
51
|
+
sum_ext_op, prod_ext_op, all, matrix_inverse_ext, atan2_ext, sign, acos_ext,
|
|
52
|
+
acosh_ext, asin_ext, asinh_ext, atan_ext, tan, median_ext_op, median_dim_op,
|
|
53
|
+
xlogy_op, xlogy_scalar_other_op, xlogy_scalar_self_op, trunc, histc_ext)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
from mindspore.ops.auto_generate.gen_ops_def import add_ext, sub_ext, bmm_ext
|
|
48
58
|
from mindspore.ops.auto_generate import tanh
|
|
49
59
|
from mindspore.nn import layer
|
|
50
60
|
from mindspore._checkparam import check_is_number
|
|
@@ -133,6 +143,7 @@ transpose_ = P.Transpose()
|
|
|
133
143
|
xdivy_ = P.Xdivy()
|
|
134
144
|
tensor_div_ = P.Div()
|
|
135
145
|
tensor_divmod_ = DivMod()
|
|
146
|
+
generator_step_ = Tensor(10, mstype.int64)
|
|
136
147
|
|
|
137
148
|
#####################################
|
|
138
149
|
# Private Operation Functions.
|
|
@@ -150,6 +161,7 @@ atan2_ = P.Atan2()
|
|
|
150
161
|
atan_ = P.Atan()
|
|
151
162
|
atanh_ = P.Atanh()
|
|
152
163
|
batch_matmul_ = BatchMatMul()
|
|
164
|
+
bernoulli_ext_ = BernoulliExt()
|
|
153
165
|
bessel_i0_ = BesselI0()
|
|
154
166
|
bessel_i0e_ = P.BesselI0e()
|
|
155
167
|
bessel_i1_ = BesselI1()
|
|
@@ -217,9 +229,7 @@ slice_ = P.Slice()
|
|
|
217
229
|
size_ = P.Size()
|
|
218
230
|
scalar_to_tensor_ = P.ScalarToTensor()
|
|
219
231
|
shape_ = P.Shape()
|
|
220
|
-
sign_ = P.Sign()
|
|
221
232
|
sparse_segment_mean_ = SparseSegmentMean()
|
|
222
|
-
tan_ = P.Tan()
|
|
223
233
|
tanh_ = P.Tanh()
|
|
224
234
|
tensor_round_ = P.Round()
|
|
225
235
|
tile_ = P.Tile()
|
|
@@ -230,12 +240,20 @@ truncate_mod_ = P.TruncateMod()
|
|
|
230
240
|
xlogy_ = P.Xlogy()
|
|
231
241
|
zeros_ = P.Zeros()
|
|
232
242
|
zeta_ = P.Zeta()
|
|
243
|
+
bitwise_and_scalar_ = BitwiseAndScalar()
|
|
244
|
+
bitwise_and_tensor_ = BitwiseAndTensor()
|
|
245
|
+
bitwise_or_scalar_ = BitwiseOrScalar()
|
|
246
|
+
bitwise_or_tensor_ = BitwiseOrTensor()
|
|
247
|
+
bitwise_xor_scalar_ = BitwiseXorScalar()
|
|
248
|
+
bitwise_xor_tensor_ = BitwiseXorTensor()
|
|
233
249
|
|
|
234
250
|
|
|
235
251
|
#####################################
|
|
236
252
|
# Element-wise Operation Functions.
|
|
237
253
|
#####################################
|
|
238
|
-
|
|
254
|
+
remainder_tensor_tensor_ = RemainderTensorTensor()
|
|
255
|
+
remainder_tensor_scalar_ = RemainderTensorScalar()
|
|
256
|
+
remainder_scalar_tensor_ = RemainderScalarTensor()
|
|
239
257
|
|
|
240
258
|
def addn(x):
|
|
241
259
|
"""
|
|
@@ -1558,22 +1576,41 @@ def t(input):
|
|
|
1558
1576
|
return input
|
|
1559
1577
|
|
|
1560
1578
|
|
|
1561
|
-
def
|
|
1579
|
+
def xlogy(input, other):
|
|
1562
1580
|
r"""
|
|
1563
|
-
Computes
|
|
1581
|
+
Computes the first input tensor multiplied by the logarithm of second input tensor element-wise.
|
|
1582
|
+
Returns zero when `input` is zero.
|
|
1564
1583
|
|
|
1565
1584
|
.. math::
|
|
1566
1585
|
|
|
1567
|
-
out_i = \
|
|
1586
|
+
out_i = input_{i}\ln{other_{i}}
|
|
1587
|
+
|
|
1588
|
+
Inputs of `input` and `other` comply with the implicit type conversion rules to make the data types consistent.
|
|
1589
|
+
The inputs must be two tensors or one tensor and one scalar.
|
|
1590
|
+
When the inputs are two tensors, the shapes of them could be broadcast.
|
|
1591
|
+
When the inputs are one tensor and one scalar,
|
|
1592
|
+
the scalar could only be a constant.
|
|
1593
|
+
|
|
1594
|
+
.. warning::
|
|
1595
|
+
- On Ascend, the data type of `input` and `other` must be float16 or float32.
|
|
1568
1596
|
|
|
1569
1597
|
Args:
|
|
1570
|
-
input (Tensor): The input
|
|
1598
|
+
input (Union[Tensor, numbers.Number, bool]): The first input is a numbers.Number or
|
|
1599
|
+
a bool or a tensor whose data type is
|
|
1600
|
+
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ or
|
|
1601
|
+
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_.
|
|
1602
|
+
other (Union[Tensor, numbers.Number, bool]): The second input is a numbers.Number or
|
|
1603
|
+
a bool when the first input is a tensor or a tensor whose data type is number or bool\_.
|
|
1604
|
+
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool\_.
|
|
1571
1605
|
|
|
1572
1606
|
Returns:
|
|
1573
|
-
Tensor,
|
|
1607
|
+
Tensor, the shape is the same as the one after broadcasting,
|
|
1608
|
+
and the data type is the one with higher precision or higher digits among the two inputs.
|
|
1574
1609
|
|
|
1575
1610
|
Raises:
|
|
1576
|
-
TypeError: If `input` is not a Tensor.
|
|
1611
|
+
TypeError: If `input` and `other` is not a numbers.Number or a bool or a Tensor.
|
|
1612
|
+
TypeError: If dtype of `input` and `other` is not in [float16, float32, float64, complex64, complex128].
|
|
1613
|
+
ValueError: If `input` could not be broadcast to a tensor with shape of `other`.
|
|
1577
1614
|
|
|
1578
1615
|
Supported Platforms:
|
|
1579
1616
|
``Ascend`` ``GPU`` ``CPU``
|
|
@@ -1582,52 +1619,51 @@ def tan(input):
|
|
|
1582
1619
|
>>> import mindspore
|
|
1583
1620
|
>>> import numpy as np
|
|
1584
1621
|
>>> from mindspore import Tensor, ops
|
|
1585
|
-
>>> input = Tensor(np.array([-
|
|
1586
|
-
>>>
|
|
1622
|
+
>>> input = Tensor(np.array([-5, 0, 4]), mindspore.float32)
|
|
1623
|
+
>>> other = Tensor(np.array([2, 2, 2]), mindspore.float32)
|
|
1624
|
+
>>> output = ops.xlogy(input, other)
|
|
1587
1625
|
>>> print(output)
|
|
1588
|
-
[-
|
|
1626
|
+
[-3.465736 0. 2.7725887]
|
|
1589
1627
|
"""
|
|
1590
|
-
|
|
1628
|
+
if isinstance(input, Tensor) and isinstance(other, Tensor) and input.dtype == mstype.bool_ \
|
|
1629
|
+
and other.dtype == mstype.bool_:
|
|
1630
|
+
input = input.astype(mstype.float32)
|
|
1631
|
+
other = other.astype(mstype.float32)
|
|
1632
|
+
return xlogy_(input, other)
|
|
1591
1633
|
|
|
1592
1634
|
|
|
1593
|
-
def
|
|
1635
|
+
def xlogy_ext(input, other):
|
|
1594
1636
|
r"""
|
|
1595
|
-
Computes the first input
|
|
1637
|
+
Computes the first input multiplied by the logarithm of second input element-wise.
|
|
1596
1638
|
Returns zero when `input` is zero.
|
|
1597
1639
|
|
|
1598
1640
|
.. math::
|
|
1599
1641
|
|
|
1600
|
-
out_i = input_{i}\
|
|
1642
|
+
out_i = input_{i}\log{other_{i}}
|
|
1601
1643
|
|
|
1602
1644
|
Inputs of `input` and `other` comply with the implicit type conversion rules to make the data types consistent.
|
|
1603
1645
|
The inputs must be two tensors or one tensor and one scalar.
|
|
1604
1646
|
When the inputs are two tensors, the shapes of them could be broadcast.
|
|
1605
|
-
When the inputs are one tensor and one scalar,
|
|
1606
|
-
the scalar could only be a constant.
|
|
1607
|
-
|
|
1608
|
-
.. warning::
|
|
1609
|
-
- On Ascend, the data type of `input` and `other` must be float16 or float32.
|
|
1610
1647
|
|
|
1611
1648
|
Args:
|
|
1612
|
-
input (Union[Tensor,
|
|
1649
|
+
input (Union[Tensor, numbers.Number, bool]): The first input is a numbers.Number or
|
|
1613
1650
|
a bool or a tensor whose data type is
|
|
1614
|
-
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore
|
|
1615
|
-
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore
|
|
1616
|
-
other (Union[Tensor,
|
|
1617
|
-
a bool
|
|
1618
|
-
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool
|
|
1651
|
+
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ or
|
|
1652
|
+
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_.
|
|
1653
|
+
other (Union[Tensor, numbers.Number, bool]): The second input is a numbers.Number or
|
|
1654
|
+
a bool or a tensor whose data type is number or bool when the first input is a tensor.
|
|
1655
|
+
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool.
|
|
1619
1656
|
|
|
1620
1657
|
Returns:
|
|
1621
1658
|
Tensor, the shape is the same as the one after broadcasting,
|
|
1622
1659
|
and the data type is the one with higher precision or higher digits among the two inputs.
|
|
1623
1660
|
|
|
1624
1661
|
Raises:
|
|
1625
|
-
TypeError: If `input` and `other` is not a
|
|
1626
|
-
TypeError: If dtype of `input` and `other` is not in [float16, float32, float64, complex64, complex128].
|
|
1662
|
+
TypeError: If `input` and `other` is not a numbers.Number or a bool or a Tensor.
|
|
1627
1663
|
ValueError: If `input` could not be broadcast to a tensor with shape of `other`.
|
|
1628
1664
|
|
|
1629
1665
|
Supported Platforms:
|
|
1630
|
-
``Ascend``
|
|
1666
|
+
``Ascend``
|
|
1631
1667
|
|
|
1632
1668
|
Examples:
|
|
1633
1669
|
>>> import mindspore
|
|
@@ -1635,16 +1671,17 @@ def xlogy(input, other):
|
|
|
1635
1671
|
>>> from mindspore import Tensor, ops
|
|
1636
1672
|
>>> input = Tensor(np.array([-5, 0, 4]), mindspore.float32)
|
|
1637
1673
|
>>> other = Tensor(np.array([2, 2, 2]), mindspore.float32)
|
|
1638
|
-
>>> output = ops.
|
|
1674
|
+
>>> output = ops.xlogy_ext(input, other)
|
|
1639
1675
|
>>> print(output)
|
|
1640
1676
|
[-3.465736 0. 2.7725887]
|
|
1641
1677
|
"""
|
|
1642
|
-
if isinstance(input, Tensor) and isinstance(other, Tensor)
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1678
|
+
if isinstance(input, Tensor) and isinstance(other, Tensor):
|
|
1679
|
+
return xlogy_op(input, other)
|
|
1680
|
+
if isinstance(input, Tensor) and isinstance(other, (float, int, bool)):
|
|
1681
|
+
return xlogy_scalar_other_op(input, other)
|
|
1682
|
+
if isinstance(input, (float, int, bool)) and isinstance(other, Tensor):
|
|
1683
|
+
return xlogy_scalar_self_op(input, other)
|
|
1684
|
+
raise TypeError(f"For 'xlogy', at least one of input and other should be Tensor.")
|
|
1648
1685
|
|
|
1649
1686
|
def arccosh(input):
|
|
1650
1687
|
r"""
|
|
@@ -1665,6 +1702,16 @@ def arccosh(input):
|
|
|
1665
1702
|
return acosh_(input)
|
|
1666
1703
|
|
|
1667
1704
|
|
|
1705
|
+
def arccosh_ext(input):
|
|
1706
|
+
r"""
|
|
1707
|
+
Alias for :func:`mindspore.ops.acosh_ext`.
|
|
1708
|
+
|
|
1709
|
+
Supported Platforms:
|
|
1710
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1711
|
+
"""
|
|
1712
|
+
return acosh_ext(input)
|
|
1713
|
+
|
|
1714
|
+
|
|
1668
1715
|
def arcsin(x):
|
|
1669
1716
|
r"""
|
|
1670
1717
|
Alias for :func:`mindspore.ops.asin`.
|
|
@@ -1675,6 +1722,16 @@ def arcsin(x):
|
|
|
1675
1722
|
return asin_(x)
|
|
1676
1723
|
|
|
1677
1724
|
|
|
1725
|
+
def arcsin_ext(x):
|
|
1726
|
+
r"""
|
|
1727
|
+
Alias for :func:`mindspore.ops.asin_ext`.
|
|
1728
|
+
|
|
1729
|
+
Supported Platforms:
|
|
1730
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1731
|
+
"""
|
|
1732
|
+
return asin_ext(x)
|
|
1733
|
+
|
|
1734
|
+
|
|
1678
1735
|
def arctan(input):
|
|
1679
1736
|
r"""
|
|
1680
1737
|
Alias for :func:`mindspore.ops.atan`.
|
|
@@ -1694,6 +1751,16 @@ def arctan(input):
|
|
|
1694
1751
|
return atan_(input)
|
|
1695
1752
|
|
|
1696
1753
|
|
|
1754
|
+
def arctan_ext(input):
|
|
1755
|
+
r"""
|
|
1756
|
+
Alias for :func:`mindspore.ops.atan_ext`.
|
|
1757
|
+
|
|
1758
|
+
Supported Platforms:
|
|
1759
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1760
|
+
"""
|
|
1761
|
+
return atan_ext(input)
|
|
1762
|
+
|
|
1763
|
+
|
|
1697
1764
|
def arctan2(input, other):
|
|
1698
1765
|
r"""
|
|
1699
1766
|
Alias for :func:`mindspore.ops.atan2`.
|
|
@@ -1790,6 +1857,16 @@ def arccos(input):
|
|
|
1790
1857
|
return acos(input)
|
|
1791
1858
|
|
|
1792
1859
|
|
|
1860
|
+
def arccos_ext(input):
|
|
1861
|
+
"""
|
|
1862
|
+
Alias for :func:`mindspore.ops.acos_ext` .
|
|
1863
|
+
|
|
1864
|
+
Supported Platforms:
|
|
1865
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1866
|
+
"""
|
|
1867
|
+
return acos_ext(input)
|
|
1868
|
+
|
|
1869
|
+
|
|
1793
1870
|
def arcsinh(input):
|
|
1794
1871
|
r"""
|
|
1795
1872
|
Alias for :func:`mindspore.ops.asinh`.
|
|
@@ -1800,6 +1877,16 @@ def arcsinh(input):
|
|
|
1800
1877
|
return asinh(input)
|
|
1801
1878
|
|
|
1802
1879
|
|
|
1880
|
+
def arcsinh_ext(input):
|
|
1881
|
+
r"""
|
|
1882
|
+
Alias for :func:`mindspore.ops.asinh_ext`.
|
|
1883
|
+
|
|
1884
|
+
Supported Platforms:
|
|
1885
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
1886
|
+
"""
|
|
1887
|
+
return asinh_ext(input)
|
|
1888
|
+
|
|
1889
|
+
|
|
1803
1890
|
def arctanh(input):
|
|
1804
1891
|
r"""
|
|
1805
1892
|
Alias for :func:`mindspore.ops.atanh`.
|
|
@@ -1850,6 +1937,46 @@ def bitwise_and(input, other):
|
|
|
1850
1937
|
return bitwise_and_(input, other)
|
|
1851
1938
|
|
|
1852
1939
|
|
|
1940
|
+
def bitwise_and_ext(input, other):
|
|
1941
|
+
r"""
|
|
1942
|
+
Returns bitwise `and` of two tensors element-wise.
|
|
1943
|
+
|
|
1944
|
+
.. math::
|
|
1945
|
+
|
|
1946
|
+
out_i = input_{i} \wedge other_{i}
|
|
1947
|
+
|
|
1948
|
+
Note:
|
|
1949
|
+
Args of `input` and `other` comply with the implicit type conversion rules to
|
|
1950
|
+
make the data types consistent.
|
|
1951
|
+
If they have different data types, the lower precision data type will be converted to
|
|
1952
|
+
the relatively highest precision data type.
|
|
1953
|
+
|
|
1954
|
+
Args:
|
|
1955
|
+
input (Tensor): The input tensor.
|
|
1956
|
+
other (Tensor, Number.number): The input tensor or scalar. It has the same shape
|
|
1957
|
+
with `input` or its shape is able to broadcast with `input`.
|
|
1958
|
+
|
|
1959
|
+
Returns:
|
|
1960
|
+
Tensor, the shape is the same as the one after broadcasting, and the data type is same as `input`.
|
|
1961
|
+
|
|
1962
|
+
Supported Platforms:
|
|
1963
|
+
``Ascend``
|
|
1964
|
+
|
|
1965
|
+
Examples:
|
|
1966
|
+
>>> import mindspore
|
|
1967
|
+
>>> import numpy as np
|
|
1968
|
+
>>> from mindspore import Tensor, ops
|
|
1969
|
+
>>> input = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
|
|
1970
|
+
>>> other = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
|
|
1971
|
+
>>> output = ops.bitwise_and_ext(input, other)
|
|
1972
|
+
>>> print(output)
|
|
1973
|
+
[ 0 0 1 -1 1 0 1]
|
|
1974
|
+
"""
|
|
1975
|
+
if not isinstance(other, Tensor):
|
|
1976
|
+
return bitwise_and_scalar_(input, other)
|
|
1977
|
+
return bitwise_and_tensor_(input, other)
|
|
1978
|
+
|
|
1979
|
+
|
|
1853
1980
|
def bitwise_or(input, other):
|
|
1854
1981
|
r"""
|
|
1855
1982
|
Returns bitwise `or` of two tensors element-wise.
|
|
@@ -1890,6 +2017,46 @@ def bitwise_or(input, other):
|
|
|
1890
2017
|
return bitwise_or_(input, other)
|
|
1891
2018
|
|
|
1892
2019
|
|
|
2020
|
+
def bitwise_or_ext(input, other):
|
|
2021
|
+
r"""
|
|
2022
|
+
Returns bitwise `or` of two tensors element-wise.
|
|
2023
|
+
|
|
2024
|
+
.. math::
|
|
2025
|
+
|
|
2026
|
+
out_i = input_{i} \mid other_{i}
|
|
2027
|
+
|
|
2028
|
+
Note:
|
|
2029
|
+
Args of `input` and `other` comply with the implicit type conversion rules to
|
|
2030
|
+
make the data types consistent.
|
|
2031
|
+
If they have different data types, the lower precision data type will be converted to
|
|
2032
|
+
the relatively highest precision data type.
|
|
2033
|
+
|
|
2034
|
+
Args:
|
|
2035
|
+
input (Tensor): The input tensor.
|
|
2036
|
+
other (Tensor, Number.number): The input tensor or scalar. It has the same shape
|
|
2037
|
+
with `input` or its shape is able to broadcast with `input`.
|
|
2038
|
+
|
|
2039
|
+
Returns:
|
|
2040
|
+
Tensor, the shape is the same as the one after broadcasting, and the data type is same as `input`.
|
|
2041
|
+
|
|
2042
|
+
Supported Platforms:
|
|
2043
|
+
``Ascend``
|
|
2044
|
+
|
|
2045
|
+
Examples:
|
|
2046
|
+
>>> import mindspore
|
|
2047
|
+
>>> import numpy as np
|
|
2048
|
+
>>> from mindspore import Tensor, ops
|
|
2049
|
+
>>> input = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
|
|
2050
|
+
>>> other = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
|
|
2051
|
+
>>> output = ops.bitwise_or_ext(input, other)
|
|
2052
|
+
>>> print(output)
|
|
2053
|
+
[ 0 1 1 -1 -1 3 3]
|
|
2054
|
+
"""
|
|
2055
|
+
if not isinstance(other, Tensor):
|
|
2056
|
+
return bitwise_or_scalar_(input, other)
|
|
2057
|
+
return bitwise_or_tensor_(input, other)
|
|
2058
|
+
|
|
2059
|
+
|
|
1893
2060
|
def bitwise_xor(input, other):
|
|
1894
2061
|
r"""
|
|
1895
2062
|
Returns bitwise `xor` of two tensors element-wise.
|
|
@@ -1930,6 +2097,46 @@ def bitwise_xor(input, other):
|
|
|
1930
2097
|
return bitwise_xor_(input, other)
|
|
1931
2098
|
|
|
1932
2099
|
|
|
2100
|
+
def bitwise_xor_ext(input, other):
|
|
2101
|
+
r"""
|
|
2102
|
+
Returns bitwise `xor` of two tensors element-wise.
|
|
2103
|
+
|
|
2104
|
+
.. math::
|
|
2105
|
+
|
|
2106
|
+
out_i = input_{i} \oplus other_{i}
|
|
2107
|
+
|
|
2108
|
+
Note:
|
|
2109
|
+
Args of `input` and `other` comply with the implicit type conversion rules to
|
|
2110
|
+
make the data types consistent.
|
|
2111
|
+
If they have different data types, the lower precision data type will be converted to
|
|
2112
|
+
the relatively highest precision data type.
|
|
2113
|
+
|
|
2114
|
+
Args:
|
|
2115
|
+
input (Tensor): The input tensor.
|
|
2116
|
+
other (Tensor, Number.number): The input tensor or scalar. It has the same shape
|
|
2117
|
+
with `input` or its shape is able to broadcast with `input`.
|
|
2118
|
+
|
|
2119
|
+
Returns:
|
|
2120
|
+
Tensor, the shape is the same as the one after broadcasting, and the data type is same as `input`.
|
|
2121
|
+
|
|
2122
|
+
Supported Platforms:
|
|
2123
|
+
``Ascend``
|
|
2124
|
+
|
|
2125
|
+
Examples:
|
|
2126
|
+
>>> import mindspore
|
|
2127
|
+
>>> import numpy as np
|
|
2128
|
+
>>> from mindspore import Tensor, ops
|
|
2129
|
+
>>> input = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
|
|
2130
|
+
>>> other = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
|
|
2131
|
+
>>> output = ops.bitwise_xor_ext(input, other)
|
|
2132
|
+
>>> print(output)
|
|
2133
|
+
[ 0 1 0 0 -2 3 2]
|
|
2134
|
+
"""
|
|
2135
|
+
if not isinstance(other, Tensor):
|
|
2136
|
+
return bitwise_xor_scalar_(input, other)
|
|
2137
|
+
return bitwise_xor_tensor_(input, other)
|
|
2138
|
+
|
|
2139
|
+
|
|
1933
2140
|
def bitwise_left_shift(input, other):
|
|
1934
2141
|
r"""
|
|
1935
2142
|
Perform a left bitwise shift operation on the `input` element-wise, where the number of bits to shift is
|
|
@@ -2555,38 +2762,38 @@ def linspace_ext(start, end, steps, *, dtype=None):
|
|
|
2555
2762
|
\end{aligned}
|
|
2556
2763
|
|
|
2557
2764
|
Args:
|
|
2558
|
-
start (Union[
|
|
2559
|
-
|
|
2560
|
-
end (Union[
|
|
2561
|
-
|
|
2562
|
-
steps (
|
|
2563
|
-
Must be positive
|
|
2765
|
+
start (Union[float, int]): Start value of interval.
|
|
2766
|
+
It can be a float or integer.
|
|
2767
|
+
end (Union[float, int]): Last value of interval.
|
|
2768
|
+
It can be a float or integer.
|
|
2769
|
+
steps (int): Number of ticks in the interval, inclusive of start and end.
|
|
2770
|
+
Must be positive integer.
|
|
2564
2771
|
|
|
2565
2772
|
Keyword Args:
|
|
2566
|
-
dtype (mindspore.dtype, optional): The output Tensor data type. Default: ``None`` ,
|
|
2567
|
-
Tensor is float32.
|
|
2773
|
+
dtype (mindspore.dtype, optional): The output Tensor data type. Default: ``None`` ,
|
|
2774
|
+
in which case the data type of output Tensor is float32.
|
|
2568
2775
|
|
|
2569
2776
|
Returns:
|
|
2570
|
-
Tensor, has the shape of :math:`(steps,)`.
|
|
2777
|
+
Tensor, has the shape of :math:`(steps,)`, with dtype specified by `dtype`.
|
|
2571
2778
|
|
|
2572
2779
|
Raises:
|
|
2573
|
-
TypeError: If
|
|
2574
|
-
ValueError: If
|
|
2575
|
-
TypeError: If `steps` is not int or 0D int32/int64 Tensor.
|
|
2576
|
-
ValueError: If `steps` is not positive int number.
|
|
2780
|
+
TypeError: If type of `start` or dtype of `end` is not supported.
|
|
2781
|
+
ValueError: If `steps` is not positive integer.
|
|
2577
2782
|
|
|
2578
2783
|
Supported Platforms:
|
|
2579
|
-
``Ascend``
|
|
2784
|
+
``Ascend``
|
|
2580
2785
|
|
|
2581
2786
|
Examples:
|
|
2582
|
-
>>>
|
|
2583
|
-
>>>
|
|
2787
|
+
>>> import mindspore as ms
|
|
2788
|
+
>>> from mindspore import ops
|
|
2789
|
+
>>> start = 1
|
|
2790
|
+
>>> end = 10
|
|
2584
2791
|
>>> steps = 5
|
|
2585
|
-
>>> output = ops.function.math_func.linspace_ext(start, end, steps, dtype=
|
|
2792
|
+
>>> output = ops.function.math_func.linspace_ext(start, end, steps, dtype=ms.float32)
|
|
2586
2793
|
>>> print(output)
|
|
2587
2794
|
[ 1. 3.25 5.5 7.75 10. ]
|
|
2588
2795
|
"""
|
|
2589
|
-
return
|
|
2796
|
+
return lin_space_ext_op(start, end, steps, dtype)
|
|
2590
2797
|
|
|
2591
2798
|
|
|
2592
2799
|
def det(input):
|
|
@@ -2872,34 +3079,6 @@ def truncate_mod(x, y):
|
|
|
2872
3079
|
return truncate_mod_(x, y)
|
|
2873
3080
|
|
|
2874
3081
|
|
|
2875
|
-
def trunc(input):
|
|
2876
|
-
r"""
|
|
2877
|
-
Returns a new tensor with the truncated integer values of the elements of the input tensor.
|
|
2878
|
-
|
|
2879
|
-
Args:
|
|
2880
|
-
input (Tensor): The input tensor.
|
|
2881
|
-
|
|
2882
|
-
Returns:
|
|
2883
|
-
Tensor, the same shape and data type as the input.
|
|
2884
|
-
|
|
2885
|
-
Raises:
|
|
2886
|
-
TypeError: If `input` is not a Tensor.
|
|
2887
|
-
|
|
2888
|
-
Supported Platforms:
|
|
2889
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
2890
|
-
|
|
2891
|
-
Examples:
|
|
2892
|
-
>>> import mindspore
|
|
2893
|
-
>>> import numpy as np
|
|
2894
|
-
>>> from mindspore import Tensor, ops
|
|
2895
|
-
>>> x = Tensor(np.array([3.4742, 0.5466, -0.8008, -3.9079]),mindspore.float32)
|
|
2896
|
-
>>> output = ops.trunc(x)
|
|
2897
|
-
>>> print(output)
|
|
2898
|
-
[3. 0. 0. -3.]
|
|
2899
|
-
"""
|
|
2900
|
-
return trunc_(input)
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
3082
|
def ldexp(x, other):
|
|
2904
3083
|
"""
|
|
2905
3084
|
Multiplies input Tensor by :math:`2^{other}` element-wise.
|
|
@@ -2996,6 +3175,7 @@ def logit(input, eps=None):
|
|
|
2996
3175
|
logit_ = _get_cache_prim(P.Logit)(eps)
|
|
2997
3176
|
return logit_(input)
|
|
2998
3177
|
|
|
3178
|
+
|
|
2999
3179
|
#####################################
|
|
3000
3180
|
# Comparison Operation Functions.
|
|
3001
3181
|
#####################################
|
|
@@ -3031,8 +3211,8 @@ def le(input, other):
|
|
|
3031
3211
|
Args:
|
|
3032
3212
|
input (Union[Tensor, number.Number, bool]): The first input is a number.Number or
|
|
3033
3213
|
a bool or a tensor whose data type is
|
|
3034
|
-
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore
|
|
3035
|
-
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore
|
|
3214
|
+
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ or
|
|
3215
|
+
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_.
|
|
3036
3216
|
other (Union[Tensor, number.Number, bool]): The second input, when the first input is a Tensor,
|
|
3037
3217
|
the second input should be a number.Number or bool value, or a Tensor whose data type is number or bool\_.
|
|
3038
3218
|
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool\_.
|
|
@@ -3081,8 +3261,8 @@ def gt(input, other):
|
|
|
3081
3261
|
Args:
|
|
3082
3262
|
input (Union[Tensor, number.Number, bool]): The first input is a number.Number or
|
|
3083
3263
|
a bool or a tensor whose data type is
|
|
3084
|
-
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore
|
|
3085
|
-
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore
|
|
3264
|
+
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ or
|
|
3265
|
+
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ .
|
|
3086
3266
|
other (Union[Tensor, number.Number, bool]): The second input, when the first input is a Tensor,
|
|
3087
3267
|
the second input should be a number.Number or bool value, or a Tensor whose data type is number or bool\_.
|
|
3088
3268
|
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool\_.
|
|
@@ -3460,66 +3640,6 @@ def is_complex(input):
|
|
|
3460
3640
|
return input.dtype in mstype.complex_type
|
|
3461
3641
|
|
|
3462
3642
|
|
|
3463
|
-
def nan_to_num(input, nan=0.0, posinf=None, neginf=None):
|
|
3464
|
-
"""
|
|
3465
|
-
Replace the `NaN`, positive infinity and negative infinity values in 'input' with the
|
|
3466
|
-
specified values in `nan`, `posinf` and `neginf` respectively.
|
|
3467
|
-
|
|
3468
|
-
Args:
|
|
3469
|
-
input (Tensor): The shape of tensor is :math:`(input_1, input_2, ..., input_R)`.
|
|
3470
|
-
With float32 or float16 data type.
|
|
3471
|
-
nan (float): The replace value of 'NaN'. Default value is 0.0.
|
|
3472
|
-
posinf (float): the value to replace positive infinity values with. Default: ``None``,
|
|
3473
|
-
replacing positive infinity with the maximum value supported by the data type of `input`.
|
|
3474
|
-
neginf (float): the value to replace negative infinity values with. Default: ``None``,
|
|
3475
|
-
replacing negative infinity with the minimum value supported by the data type of `input`.
|
|
3476
|
-
|
|
3477
|
-
Returns:
|
|
3478
|
-
Tensor, has the same shape and dtype as the `input`.
|
|
3479
|
-
|
|
3480
|
-
Raises:
|
|
3481
|
-
TypeError: If `input` is not a Tensor.
|
|
3482
|
-
TypeError: If dtype of `input` is not float16 or float32.
|
|
3483
|
-
|
|
3484
|
-
Supported Platforms:
|
|
3485
|
-
``Ascend`` ``CPU``
|
|
3486
|
-
|
|
3487
|
-
Examples:
|
|
3488
|
-
>>> import mindspore
|
|
3489
|
-
>>> import numpy as np
|
|
3490
|
-
>>> from mindspore import Tensor, ops
|
|
3491
|
-
>>> input = Tensor(np.array([float('nan'), float('inf'), -float('inf'), 5.0]), mindspore.float32)
|
|
3492
|
-
>>> output = ops.nan_to_num(input, 1.0, 2.0, 3.0)
|
|
3493
|
-
>>> print(output)
|
|
3494
|
-
[1. 2. 3. 5.0]
|
|
3495
|
-
"""
|
|
3496
|
-
if not isinstance(input, (Tensor, Tensor_)):
|
|
3497
|
-
raise TypeError("the input x must be Tensor!")
|
|
3498
|
-
if nan is not None:
|
|
3499
|
-
if not isinstance(nan, float):
|
|
3500
|
-
raise TypeError("the parameter nan's dtype must be float.")
|
|
3501
|
-
else:
|
|
3502
|
-
nan = 0.0
|
|
3503
|
-
if posinf is not None:
|
|
3504
|
-
if not isinstance(posinf, float):
|
|
3505
|
-
raise TypeError("the parameter posinf's dtype must be float.")
|
|
3506
|
-
else:
|
|
3507
|
-
if input.dtype == mstype.float16:
|
|
3508
|
-
posinf = (float)(np.finfo(np.float16).max)
|
|
3509
|
-
elif input.dtype == mstype.float32:
|
|
3510
|
-
posinf = (float)(np.finfo(np.float32).max)
|
|
3511
|
-
if neginf is not None:
|
|
3512
|
-
if not isinstance(neginf, float):
|
|
3513
|
-
raise TypeError("the parameter neginf's dtype must be float.")
|
|
3514
|
-
else:
|
|
3515
|
-
if input.dtype == mstype.float16:
|
|
3516
|
-
neginf = (float)(np.finfo(np.float16).min)
|
|
3517
|
-
elif input.dtype == mstype.float32:
|
|
3518
|
-
neginf = (float)(np.finfo(np.float32).min)
|
|
3519
|
-
_nan_to_num = _get_cache_prim(NanToNum)(nan=nan, posinf=posinf, neginf=neginf)
|
|
3520
|
-
return _nan_to_num(input)
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
3643
|
def fmax(input, other):
|
|
3524
3644
|
r"""
|
|
3525
3645
|
Computes the maximum of input tensors element-wise.
|
|
@@ -3606,6 +3726,51 @@ def fmin(input, other):
|
|
|
3606
3726
|
return fmin_(input, other)
|
|
3607
3727
|
|
|
3608
3728
|
|
|
3729
|
+
def median_ext(input, dim=None, keepdim=False):
|
|
3730
|
+
r"""
|
|
3731
|
+
Output the median on the specified dimension ``dim`` and its corresponding index.
|
|
3732
|
+
If ``dim`` is None, calculate the median of all elements in the Tensor.
|
|
3733
|
+
|
|
3734
|
+
Args:
|
|
3735
|
+
input (Tensor): A Tensor of any dimension whose data type is uint8, int16, int32, int64, float16 or float32.
|
|
3736
|
+
dim (int, optional): Specify the axis for calculation. Default: ``None`` .
|
|
3737
|
+
keepdim (bool, optional): Whether the output tensor need to retain ``dim`` dimension or not.
|
|
3738
|
+
Default: ``False`` .
|
|
3739
|
+
|
|
3740
|
+
Returns:
|
|
3741
|
+
- y (Tensor) - Output median, with the same data type as ``input`` .
|
|
3742
|
+
|
|
3743
|
+
- If ``dim`` is ``None`` , ``y`` only has one element.
|
|
3744
|
+
- If ``keepdim`` is ``True`` , the ``y`` has the same shape as the ``input`` except the shape
|
|
3745
|
+
of ``y`` in dimension `dim` is size 1.
|
|
3746
|
+
- Otherwise, the ``y`` lacks `dim` dimension than input.
|
|
3747
|
+
|
|
3748
|
+
- indices (Tensor) - The index of the median. Shape is consistent with ``y`` , with a data type of int64.
|
|
3749
|
+
|
|
3750
|
+
Raises:
|
|
3751
|
+
TypeError: If dtype of ``input`` is not one of the following: uint8, int16, int32, int64, float16 or float32.
|
|
3752
|
+
TypeError: If input ``input`` is not a Tensor.
|
|
3753
|
+
TypeError: If ``dim`` is not a int.
|
|
3754
|
+
TypeError: If ``keepdim`` is not a bool.
|
|
3755
|
+
ValueError: If ``dim`` is not in range of [-x.dim, x.dim-1].
|
|
3756
|
+
|
|
3757
|
+
Supported Platforms:
|
|
3758
|
+
``Ascend``
|
|
3759
|
+
|
|
3760
|
+
Examples:
|
|
3761
|
+
>>> import numpy as np
|
|
3762
|
+
>>> from mindspore import Tensor, ops
|
|
3763
|
+
>>> x = Tensor(np.array([[0.57, 0.11, 0.21],[0.38, 0.50, 0.57], [0.36, 0.16, 0.44]]).astype(np.float32))
|
|
3764
|
+
>>> y = ops.function.math_func.median_ext(x, dim=0, keepdim=False)
|
|
3765
|
+
>>> print(y)
|
|
3766
|
+
(Tensor(shape=[3], dtype=Float32, value= [ 3.79999995e-01, 1.59999996e-01, 4.39999998e-01]),
|
|
3767
|
+
Tensor(shape=[3], dtype=Int64, value= [1, 2, 2]))
|
|
3768
|
+
"""
|
|
3769
|
+
if dim is None:
|
|
3770
|
+
return median_ext_op(input)
|
|
3771
|
+
return median_dim_op(input, dim, keepdim)
|
|
3772
|
+
|
|
3773
|
+
|
|
3609
3774
|
def median(input, axis=-1, keepdims=False):
|
|
3610
3775
|
r"""
|
|
3611
3776
|
Computes the median and indices of input tensor.
|
|
@@ -3959,7 +4124,7 @@ def histc(input, bins=100, min=0., max=0.):
|
|
|
3959
4124
|
max (int, float, optional): An optional float of the upper end of the range (inclusive). Default: ``0.0`` .
|
|
3960
4125
|
|
|
3961
4126
|
Returns:
|
|
3962
|
-
|
|
4127
|
+
1-D Tensor. If the input is int32, the output returns int32, otherwise it returns float32.
|
|
3963
4128
|
|
|
3964
4129
|
Raises:
|
|
3965
4130
|
TypeError: If `input` is not a Tensor.
|
|
@@ -3977,7 +4142,7 @@ def histc(input, bins=100, min=0., max=0.):
|
|
|
3977
4142
|
>>> x = Tensor([1., 2, 1])
|
|
3978
4143
|
>>> y = ops.histc(x, bins=4, min=0.0, max=3.0)
|
|
3979
4144
|
>>> print(y)
|
|
3980
|
-
[0 2 1 0]
|
|
4145
|
+
[0. 2. 1. 0.]
|
|
3981
4146
|
"""
|
|
3982
4147
|
if not isinstance(min, (int, float)):
|
|
3983
4148
|
raise TypeError(f"For 'histc', parameter 'min' must be an int or float, but got {type(min)}.")
|
|
@@ -4049,7 +4214,7 @@ def logaddexp(input, other):
|
|
|
4049
4214
|
|
|
4050
4215
|
Args:
|
|
4051
4216
|
input (Tensor): Input Tensor. The dtype of `input` must be float.
|
|
4052
|
-
other (Tensor): Input Tensor. The dtype of `
|
|
4217
|
+
other (Tensor): Input Tensor. The dtype of `other` must be float.
|
|
4053
4218
|
If the shape of `input` is not equal to the shape of `other`,
|
|
4054
4219
|
they must be broadcastable to a common shape (which becomes the shape of the output).
|
|
4055
4220
|
|
|
@@ -4078,7 +4243,7 @@ def logaddexp(input, other):
|
|
|
4078
4243
|
if not isinstance(other, (Tensor, Tensor_)):
|
|
4079
4244
|
raise TypeError(f"For logaddexp, the other must be a Tensor, but got {type(other)}.")
|
|
4080
4245
|
if not ops.is_floating_point(input) or not ops.is_floating_point(other):
|
|
4081
|
-
raise TypeError(f"For
|
|
4246
|
+
raise TypeError(f"For logaddexp, the dtype of 'input' and 'other' must be float,"
|
|
4082
4247
|
f"but got {input.dtype} and {other.dtype}.")
|
|
4083
4248
|
m = maximum(input, other)
|
|
4084
4249
|
abs_val = abs(input - other)
|
|
@@ -4991,7 +5156,7 @@ def bernoulli(input, p=0.5, seed=None):
|
|
|
4991
5156
|
positive integer. Default: ``None`` , means using the current timestamp.
|
|
4992
5157
|
|
|
4993
5158
|
Returns:
|
|
4994
|
-
output (Tensor), with the same shape and type as `input
|
|
5159
|
+
output (Tensor), with the same shape and type as `input`.
|
|
4995
5160
|
|
|
4996
5161
|
Raises:
|
|
4997
5162
|
TypeError: If dtype of `input` is not one of: int8, uint8, int16, int32, int64, bool, float32, float64.
|
|
@@ -5027,6 +5192,61 @@ def bernoulli(input, p=0.5, seed=None):
|
|
|
5027
5192
|
return bernoulli_(input, p)
|
|
5028
5193
|
|
|
5029
5194
|
|
|
5195
|
+
def bernoulli_ext(input, *, generator=None):
|
|
5196
|
+
r"""
|
|
5197
|
+
Sample from the Bernoulli distribution and randomly set the i^{th} element of the `output` to (0 or 1) according to
|
|
5198
|
+
the i^{th} probability value given in the `input`.
|
|
5199
|
+
|
|
5200
|
+
.. math::
|
|
5201
|
+
output_{i} \sim Bernoulli(p=input_{i})
|
|
5202
|
+
|
|
5203
|
+
.. warning::
|
|
5204
|
+
This is an experimental API that is subject to change or deletion.
|
|
5205
|
+
|
|
5206
|
+
Args:
|
|
5207
|
+
input (Tensor): The input tensor of Bernoulli distribution, where the i^{th} element 'input_{i}' represents the
|
|
5208
|
+
probability that the corresponding output element 'output_{i}' is set to '1', therefore each element in
|
|
5209
|
+
'input' have to be in the range '[0,1]'. Supported dtype: float16, float32, float64, bfloat16
|
|
5210
|
+
(only supported by Atlas A2 training series products).
|
|
5211
|
+
|
|
5212
|
+
Keyword Args:
|
|
5213
|
+
generator (:class:`mindspore.Generator`, optional): a pseudorandom number generator.
|
|
5214
|
+
Default: ``None``, uses the default pseudorandom number generator.
|
|
5215
|
+
|
|
5216
|
+
Returns:
|
|
5217
|
+
output (Tensor): The output tensor, with the same shape and dtype as `input`.
|
|
5218
|
+
|
|
5219
|
+
Raises:
|
|
5220
|
+
TypeError: If dtype of `input` is not one of: float16, float32, float64, bfloat16.
|
|
5221
|
+
ValueError: If any element of the `input` is not in the range [0, 1].
|
|
5222
|
+
|
|
5223
|
+
Supported Platforms:
|
|
5224
|
+
``Ascend``
|
|
5225
|
+
|
|
5226
|
+
Examples:
|
|
5227
|
+
>>> import mindspore
|
|
5228
|
+
>>> import numpy as np
|
|
5229
|
+
>>> from mindspore import Tensor
|
|
5230
|
+
>>> from mindspore import ops
|
|
5231
|
+
>>> input_x = Tensor(np.ones((3, 3)), mindspore.float32)
|
|
5232
|
+
>>> output = ops.bernoulli_ext(input_x)
|
|
5233
|
+
>>> print(output)
|
|
5234
|
+
[[ 1. 1. 1.]
|
|
5235
|
+
[ 1. 1. 1.]
|
|
5236
|
+
[ 1. 1. 1.]]
|
|
5237
|
+
>>> input_x = Tensor(np.zeros((3, 3)), mindspore.float32)
|
|
5238
|
+
>>> output = ops.bernoulli_ext(input_x)
|
|
5239
|
+
>>> print(output)
|
|
5240
|
+
[[ 0. 0. 0.]
|
|
5241
|
+
[ 0. 0. 0.]
|
|
5242
|
+
[ 0. 0. 0.]]
|
|
5243
|
+
"""
|
|
5244
|
+
if generator is None:
|
|
5245
|
+
generator = default_generator
|
|
5246
|
+
seed, offset = generator._step(generator_step_) # pylint: disable=protected-access
|
|
5247
|
+
return bernoulli_ext_(input, seed, offset)
|
|
5248
|
+
|
|
5249
|
+
|
|
5030
5250
|
def bessel_i1(x):
|
|
5031
5251
|
r"""
|
|
5032
5252
|
Computes modified Bessel function of the first kind, order 1 element-wise.
|
|
@@ -7276,14 +7496,14 @@ def _compute_vector_norm_inf(x, dim, keepdims, norm_func):
|
|
|
7276
7496
|
return ret_norm
|
|
7277
7497
|
|
|
7278
7498
|
|
|
7279
|
-
def norm_ext(
|
|
7499
|
+
def norm_ext(input, p='fro', dim=None, keepdim=False, *, dtype=None):
|
|
7280
7500
|
r"""
|
|
7281
7501
|
Returns the matrix norm or vector norm of a given tensor.
|
|
7282
7502
|
|
|
7283
|
-
`
|
|
7503
|
+
`p` is the calculation mode of norm. The following norm modes are supported.
|
|
7284
7504
|
|
|
7285
7505
|
====================== ================================ ==========================================
|
|
7286
|
-
`
|
|
7506
|
+
`p` norm for matrices norm for vectors
|
|
7287
7507
|
====================== ================================ ==========================================
|
|
7288
7508
|
`None` (default) Frobenius norm `2`-norm (see below)
|
|
7289
7509
|
`'fro'` Frobenius norm -- not supported --
|
|
@@ -7291,44 +7511,31 @@ def norm_ext(A, ord=None, dim=None, keepdim=False, *, dtype=None):
|
|
|
7291
7511
|
`inf` :math:`max(sum(abs(x), dim=1))` :math:`max(abs(x))`
|
|
7292
7512
|
`-inf` :math:`min(sum(abs(x), dim=1))` :math:`min(abs(x))`
|
|
7293
7513
|
`0` -- not supported -- :math:`sum(x != 0)`
|
|
7294
|
-
`1` :math:`max(sum(abs(x), dim=0))` as below
|
|
7295
|
-
`-1` :math:`min(sum(abs(x), dim=0))` as below
|
|
7296
|
-
`2` largest singular value as below
|
|
7297
|
-
`-2` smallest singular value as below
|
|
7298
7514
|
other `int` or `float` -- not supported -- :math:`sum(abs(x)^{ord})^{(1 / ord)}`
|
|
7299
7515
|
====================== ================================ ==========================================
|
|
7300
7516
|
|
|
7517
|
+
.. warning::
|
|
7518
|
+
This is an experimental API that is subject to change or deletion.
|
|
7519
|
+
|
|
7301
7520
|
Args:
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7521
|
+
input (Tensor): The input of LogSigmoid with data type of bfloat16, float16 or float32.
|
|
7522
|
+
The shape is :math:`(*)` where :math:`*` means, any number of additional dimensions.
|
|
7523
|
+
p (Union[int, float, inf, -inf, 'fro', 'nuc'], optional): norm's mode. refer to the table above for
|
|
7524
|
+
behavior. Default: ``fro`` .
|
|
7305
7525
|
dim (Union[int, Tuple(int)], optional): calculate the dimension of vector norm or matrix norm.
|
|
7306
7526
|
Default: ``None`` .
|
|
7307
|
-
|
|
7308
|
-
- When `dim` is int, it will be calculated by vector norm.
|
|
7309
|
-
|
|
7310
|
-
- When `dim` is a 2-tuple, it will be calculated by matrix norm.
|
|
7311
|
-
|
|
7312
|
-
- If `dim` is None and `ord` is None, `A` will be flattened to 1D and the 2-norm
|
|
7313
|
-
of the vector will be calculated.
|
|
7314
|
-
|
|
7315
|
-
- If `dim` is None and `ord` is not None, `A` must be 1D or 2D.
|
|
7316
|
-
|
|
7317
7527
|
keepdim (bool): whether the output Tensor retains the original dimension. Default: ``False`` .
|
|
7318
7528
|
|
|
7319
7529
|
Keyword Args:
|
|
7320
|
-
dtype (:class:`mindspore.dtype`, optional): When set, `
|
|
7530
|
+
dtype (:class:`mindspore.dtype`, optional): When set, `input` will be converted to the specified type,
|
|
7321
7531
|
`dtype`, before execution, and dtype of returned Tensor will also be `dtype`. Default: ``None`` .
|
|
7322
7532
|
|
|
7323
7533
|
Returns:
|
|
7324
|
-
Tensor, the result of norm calculation on the specified dimension, `dim`, has the same dtype as `
|
|
7534
|
+
Tensor, the result of norm calculation on the specified dimension, `dim`, has the same dtype as `input`.
|
|
7325
7535
|
|
|
7326
7536
|
Raises:
|
|
7327
7537
|
ValueError: If `dim` is out of range.
|
|
7328
7538
|
TypeError: If `dim` is neither an int nor a tuple of int.
|
|
7329
|
-
TypeError: If `A` is a vector and `ord` is a str.
|
|
7330
|
-
ValueError: If `A` is a matrices and `ord` is not in valid mode.
|
|
7331
|
-
ValueError: If `A` is a matrices and `ord` is an integer but not in [1, -1, 2, -2].
|
|
7332
7539
|
ValueError: If two elements of `dim` is same after normalize.
|
|
7333
7540
|
ValueError: If any elements of `dim` is out of range.
|
|
7334
7541
|
|
|
@@ -7336,23 +7543,35 @@ def norm_ext(A, ord=None, dim=None, keepdim=False, *, dtype=None):
|
|
|
7336
7543
|
``Ascend``
|
|
7337
7544
|
|
|
7338
7545
|
Note:
|
|
7339
|
-
Currently, it only support `ops.function.math_func.norm_ext(
|
|
7546
|
+
Currently, it only support `ops.function.math_func.norm_ext(input, p=number)`.
|
|
7340
7547
|
|
|
7341
7548
|
Examples:
|
|
7342
7549
|
>>> import mindspore as ms
|
|
7343
7550
|
>>> from mindspore import ops
|
|
7344
7551
|
>>> data_range = ops.arange(-13, 13, dtype=ms.float32)
|
|
7345
|
-
>>> # Exclude 0 from original data for 0 is invalid input when `ord` is negative.
|
|
7346
7552
|
>>> x = data_range[data_range != 0]
|
|
7347
7553
|
>>> y = x.reshape(5, 5)
|
|
7348
|
-
>>> print(ops.function.math_func.norm_ext(x))
|
|
7554
|
+
>>> print(ops.function.math_func.norm_ext(x, 2.0))
|
|
7349
7555
|
38.327538
|
|
7350
|
-
>>> print(ops.norm(x, 0))
|
|
7351
|
-
25.0
|
|
7352
7556
|
"""
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7557
|
+
if (dim is not None) or keepdim or (dtype is not None):
|
|
7558
|
+
raise ValueError(f"For `norm_ext`, the value of `dim`, `keepdim` and `dtype` must be default value currently.")
|
|
7559
|
+
|
|
7560
|
+
if isinstance(p, (int, float)):
|
|
7561
|
+
if float(p) in [0.0, 1.0, 2.0, 3.0]:
|
|
7562
|
+
return norm_op(input, p, dim, keepdim, dtype)
|
|
7563
|
+
if input.dtype in [mstype.bfloat16, mstype.float16, mstype.float32]:
|
|
7564
|
+
return lp_norm_v2_op(input, p, dim, keepdim, 0.0)
|
|
7565
|
+
dtype = input.dtype
|
|
7566
|
+
input = ops.cast(input, mstype.float32)
|
|
7567
|
+
return ops.cast(lp_norm_v2_op(input, p, dim, keepdim, 0.0), dtype)
|
|
7568
|
+
|
|
7569
|
+
if p == 'fro':
|
|
7570
|
+
if isinstance(dim, (list, tuple)) and len(dim) > 2:
|
|
7571
|
+
raise ValueError(f"For `norm_ext`, the size of `dim` cannot be greater than 2 "
|
|
7572
|
+
f"when the mode of norm is `fro`.")
|
|
7573
|
+
return norm_op(input, 2.0, dim, keepdim, dtype)
|
|
7574
|
+
raise ValueError(f"For `norm_ext`, the value of `p` cannot be `{p}` currently.")
|
|
7356
7575
|
|
|
7357
7576
|
def vector_norm(x, ord=2, axis=None, keepdims=False, *, dtype=None):
|
|
7358
7577
|
r"""
|
|
@@ -7822,7 +8041,7 @@ def kaiser_window(window_length, periodic=True, beta=12.0, *, dtype=None):
|
|
|
7822
8041
|
Tensor, a Kaiser window.
|
|
7823
8042
|
|
|
7824
8043
|
Raises:
|
|
7825
|
-
TypeError: If `window_length`
|
|
8044
|
+
TypeError: If `window_length` is not an integer.
|
|
7826
8045
|
TypeError: If `periodic` is not a variable of Boolean type.
|
|
7827
8046
|
ValueError: If `window_length` is negative.
|
|
7828
8047
|
|
|
@@ -8405,6 +8624,50 @@ def baddbmm(input, batch1, batch2, beta=1, alpha=1):
|
|
|
8405
8624
|
return y
|
|
8406
8625
|
|
|
8407
8626
|
|
|
8627
|
+
def baddbmm_ext(input, batch1, batch2, *, beta=1, alpha=1):
|
|
8628
|
+
r"""
|
|
8629
|
+
The result is the sum of the input and a batch matrix-matrix product of matrices in batch1 and batch2.
|
|
8630
|
+
The formula is defined as follows:
|
|
8631
|
+
|
|
8632
|
+
.. math::
|
|
8633
|
+
\text{out}_{i} = \beta \text{input}_{i} + \alpha (\text{batch1}_{i} \mathbin{@} \text{batch2}_{i})
|
|
8634
|
+
|
|
8635
|
+
Args:
|
|
8636
|
+
input (Tensor): The input Tensor. When batch1 is a :math:`(C, W, T)` Tensor and batch2 is a
|
|
8637
|
+
:math:`(C, T, H)` Tensor, input must be broadcastable with :math:`(C, W, H)` Tensor.
|
|
8638
|
+
batch1 (Tensor): :math:`batch1` in the above formula. Must be 3-D Tensor, dtype is same as input.
|
|
8639
|
+
batch2 (Tensor): :math:`batch2` in the above formula. Must be 3-D Tensor, dtype is same as input.
|
|
8640
|
+
|
|
8641
|
+
Keyword Args:
|
|
8642
|
+
beta (Union[float, int], optional): multiplier for input. Default: ``1`` .
|
|
8643
|
+
alpha (Union[float, int], optional): multiplier for :math:`batch1 @ batch2`. Default: ``1`` .
|
|
8644
|
+
|
|
8645
|
+
Returns:
|
|
8646
|
+
Tensor, has the same dtype as input, shape will be :math:`(C, W, H)`.
|
|
8647
|
+
|
|
8648
|
+
Raises:
|
|
8649
|
+
TypeError: If the type of `input`, `batch1`, `batch2` is not Tensor.
|
|
8650
|
+
TypeError: If the types of `input`, `batch1`, `batch2` are different.
|
|
8651
|
+
ValueError: If `batch1` and `batch2` are not 3-D tensors.
|
|
8652
|
+
|
|
8653
|
+
Supported Platforms:
|
|
8654
|
+
``Ascend``
|
|
8655
|
+
|
|
8656
|
+
Examples:
|
|
8657
|
+
>>> import numpy as np
|
|
8658
|
+
>>> from mindspore import Tensor, ops
|
|
8659
|
+
>>> input = Tensor(np.ones([1, 3, 3]).astype(np.float32))
|
|
8660
|
+
>>> batch1 = Tensor(np.ones([1, 3, 4]).astype(np.float32))
|
|
8661
|
+
>>> batch2 = Tensor(np.ones([1, 4, 3]).astype(np.float32))
|
|
8662
|
+
>>> output = ops.baddbmm_ext(input, batch1, batch2)
|
|
8663
|
+
>>> print(output)
|
|
8664
|
+
[[[5. 5. 5.]
|
|
8665
|
+
[5. 5. 5.]
|
|
8666
|
+
[5. 5. 5.]]]
|
|
8667
|
+
"""
|
|
8668
|
+
return ops.auto_generate.baddbmm(input, batch1, batch2, beta, alpha)
|
|
8669
|
+
|
|
8670
|
+
|
|
8408
8671
|
def log2(input):
|
|
8409
8672
|
r"""
|
|
8410
8673
|
Returns a new Tensor by taking the base 2 logarithm of the elements in the input Tensor.
|
|
@@ -8563,16 +8826,12 @@ def roll(input, shifts, dims=None):
|
|
|
8563
8826
|
>>> import mindspore as ms
|
|
8564
8827
|
>>> from mindspore import ops
|
|
8565
8828
|
>>> from mindspore import Tensor
|
|
8566
|
-
>>>
|
|
8567
|
-
>>> output = ops.roll(
|
|
8829
|
+
>>> input = Tensor(np.array([0, 1, 2, 3, 4]).astype(np.float32))
|
|
8830
|
+
>>> output = ops.roll(input, shifts=2, dims=0)
|
|
8568
8831
|
>>> print(output)
|
|
8569
8832
|
[3. 4. 0. 1. 2.]
|
|
8570
8833
|
"""
|
|
8571
|
-
|
|
8572
|
-
if dims is None:
|
|
8573
|
-
flatten_x = input.reshape(-1)
|
|
8574
|
-
return Roll(shifts, 0)(flatten_x).reshape(_shape)
|
|
8575
|
-
return Roll(shifts, dims)(input)
|
|
8834
|
+
return roll_impl(input, shifts, dims)
|
|
8576
8835
|
|
|
8577
8836
|
|
|
8578
8837
|
def xdivy(x, y):
|
|
@@ -8752,7 +9011,6 @@ def _check_is_tensor(param_name, input, cls_name):
|
|
|
8752
9011
|
raise TypeError(f"For {cls_name}, {param_name} must be a Tensor, but got {type(input)}.")
|
|
8753
9012
|
|
|
8754
9013
|
|
|
8755
|
-
|
|
8756
9014
|
def any(input, axis=None, keep_dims=False):
|
|
8757
9015
|
r"""
|
|
8758
9016
|
Reduces a dimension of `input` by the "logical OR" of all elements in the dimension, by default. And also can
|
|
@@ -8763,7 +9021,7 @@ def any(input, axis=None, keep_dims=False):
|
|
|
8763
9021
|
The `axis` with tensor type is only used for compatibility with older versions and is not recommended.
|
|
8764
9022
|
|
|
8765
9023
|
Args:
|
|
8766
|
-
input (Tensor): Input Tensor,
|
|
9024
|
+
input (Tensor): Input Tensor(bool),has the shape :math:`(N, *)` where :math:`*` means,
|
|
8767
9025
|
any number of additional dimensions.
|
|
8768
9026
|
axis (Union[int, tuple(int), list(int), Tensor], optional): The dimensions to reduce.
|
|
8769
9027
|
Suppose the rank of `input` is r, `axis` must be in the range [-rank(input), rank(input)).
|
|
@@ -8785,7 +9043,7 @@ def any(input, axis=None, keep_dims=False):
|
|
|
8785
9043
|
|
|
8786
9044
|
Raises:
|
|
8787
9045
|
TypeError: If `keep_dims` is not a bool.
|
|
8788
|
-
TypeError: If `input` is not a Tensor.
|
|
9046
|
+
TypeError: If `input` is not a Tensor(bool).
|
|
8789
9047
|
TypeError: If `axis` is not one of the following: int, tuple, list or Tensor.
|
|
8790
9048
|
|
|
8791
9049
|
Supported Platforms:
|
|
@@ -8864,6 +9122,59 @@ def remainder(input, other):
|
|
|
8864
9122
|
return out
|
|
8865
9123
|
|
|
8866
9124
|
|
|
9125
|
+
def remainder_ext(input, other):
|
|
9126
|
+
r"""
|
|
9127
|
+
Computes the remainder of `input` divided by `other` element-wise. The result has the same sign as the divisor and
|
|
9128
|
+
its absolute value is less than that of `other`.
|
|
9129
|
+
|
|
9130
|
+
Supports broadcasting to a common shape and implicit type promotion.
|
|
9131
|
+
|
|
9132
|
+
.. math::
|
|
9133
|
+
|
|
9134
|
+
remainder(input, other) = input - input.div(other, rounding\_mode="floor") * other
|
|
9135
|
+
|
|
9136
|
+
Note:
|
|
9137
|
+
Complex inputs are not supported. At least one input need to be tensor, but not both are bool tensors.
|
|
9138
|
+
|
|
9139
|
+
Args:
|
|
9140
|
+
input (Union[Tensor, numbers.Number, bool]): The dividend is a numbers.Number or
|
|
9141
|
+
a bool or a tensor whose data type is
|
|
9142
|
+
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ or
|
|
9143
|
+
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_.
|
|
9144
|
+
other (Union[Tensor, numbers.Number, bool]): The divisor is a numbers.Number or
|
|
9145
|
+
a bool or a tensor whose data type is number or bool\_ when the dividend is a tensor.
|
|
9146
|
+
When the dividend is Scalar, the divisor must be a Tensor whose data type is number or bool\_.
|
|
9147
|
+
|
|
9148
|
+
Returns:
|
|
9149
|
+
Tensor, with dtype promoted and shape broadcasted.
|
|
9150
|
+
|
|
9151
|
+
Raises:
|
|
9152
|
+
TypeError: If `input` and `other` are not of types: (tensor, tensor), (tensor, number), (tensor, bool),
|
|
9153
|
+
(number, tensor) or (bool, tensor).
|
|
9154
|
+
ValueError: If `input` and `other` are not broadcastable.
|
|
9155
|
+
|
|
9156
|
+
Supported Platforms:
|
|
9157
|
+
``Ascend``
|
|
9158
|
+
|
|
9159
|
+
Examples:
|
|
9160
|
+
>>> import numpy as np
|
|
9161
|
+
>>> from mindspore import Tensor, ops
|
|
9162
|
+
>>> x = Tensor(np.array([-4.0, 5.0, 6.0]).astype(np.float32))
|
|
9163
|
+
>>> y = Tensor(np.array([3.0, 2.0, 3.0]).astype(np.float64))
|
|
9164
|
+
>>> output = ops.remainder_ext(x, y)
|
|
9165
|
+
>>> print(output)
|
|
9166
|
+
[2. 1. 0.]
|
|
9167
|
+
"""
|
|
9168
|
+
|
|
9169
|
+
if isinstance(input, Tensor) and isinstance(other, Tensor):
|
|
9170
|
+
return remainder_tensor_tensor_(input, other)
|
|
9171
|
+
if isinstance(input, Tensor) and isinstance(other, (float, int, bool)):
|
|
9172
|
+
return remainder_tensor_scalar_(input, other)
|
|
9173
|
+
if isinstance(input, (float, int, bool)) and isinstance(other, Tensor):
|
|
9174
|
+
return remainder_scalar_tensor_(input, other)
|
|
9175
|
+
raise TypeError(f"For 'remainder', inputs should either be two tensors, or a tensor and a scalar.")
|
|
9176
|
+
|
|
9177
|
+
|
|
8867
9178
|
def accumulate_n(x):
|
|
8868
9179
|
r"""
|
|
8869
9180
|
Computes accumulation of all input tensors element-wise.
|
|
@@ -9344,8 +9655,7 @@ def cross(input, other, dim=None):
|
|
|
9344
9655
|
"""
|
|
9345
9656
|
if dim is None:
|
|
9346
9657
|
dim = -65530
|
|
9347
|
-
|
|
9348
|
-
return cross_op(input, other)
|
|
9658
|
+
return cross_impl(input, other, dim)
|
|
9349
9659
|
|
|
9350
9660
|
|
|
9351
9661
|
def _einsum_convert_num_to_char(num):
|
|
@@ -9874,10 +10184,6 @@ def logical_xor(input, other):
|
|
|
9874
10184
|
>>> print(output)
|
|
9875
10185
|
[False True]
|
|
9876
10186
|
"""
|
|
9877
|
-
if isinstance(input, Tensor) and input.dtype != mstype.bool_:
|
|
9878
|
-
input = input.astype(mstype.bool_)
|
|
9879
|
-
if isinstance(other, Tensor) and other.dtype != mstype.bool_:
|
|
9880
|
-
other = other.astype(mstype.bool_)
|
|
9881
10187
|
return logical_xor_(input, other)
|
|
9882
10188
|
|
|
9883
10189
|
|
|
@@ -11598,6 +11904,50 @@ def batch_dot(x1, x2, axes=None):
|
|
|
11598
11904
|
return final_result
|
|
11599
11905
|
|
|
11600
11906
|
|
|
11907
|
+
def round(input, *, decimals=0):
|
|
11908
|
+
r"""
|
|
11909
|
+
Returns half to even of a tensor element-wise.
|
|
11910
|
+
|
|
11911
|
+
.. math::
|
|
11912
|
+
out_i \approx input_i
|
|
11913
|
+
|
|
11914
|
+
.. note::
|
|
11915
|
+
The input data types supported by the Ascend platform include
|
|
11916
|
+
bfloat16 (Atlas training series products are not supported), float16, float32, float64, int32, and int64.
|
|
11917
|
+
|
|
11918
|
+
Args:
|
|
11919
|
+
input (Tensor): The input tensor.
|
|
11920
|
+
|
|
11921
|
+
Keyword Args:
|
|
11922
|
+
decimals (int, optional): Number of decimal places to round to (default: 0). If decimals is negative,
|
|
11923
|
+
it specifies the number of positions to the left of the decimal point. It supports converting the
|
|
11924
|
+
single-element tensor to an int.
|
|
11925
|
+
|
|
11926
|
+
Returns:
|
|
11927
|
+
Tensor, has the same shape and type as the `input`.
|
|
11928
|
+
|
|
11929
|
+
Raises:
|
|
11930
|
+
TypeError: If `input` is not a Tensor.
|
|
11931
|
+
|
|
11932
|
+
Supported Platforms:
|
|
11933
|
+
``Ascend`` ``GPU`` ``CPU``
|
|
11934
|
+
|
|
11935
|
+
Examples:
|
|
11936
|
+
>>> import mindspore
|
|
11937
|
+
>>> import numpy as np
|
|
11938
|
+
>>> from mindspore import Tensor, ops
|
|
11939
|
+
>>> input = Tensor(np.array([0.8, 1.5, 2.3, 2.5, -4.5]), mindspore.float32)
|
|
11940
|
+
>>> output = ops.round(input)
|
|
11941
|
+
>>> print(output)
|
|
11942
|
+
[ 1. 2. 2. 2. -4.]
|
|
11943
|
+
>>> input = Tensor(np.array([0.81, 1.52, 2.35, 2.53, -4.57]), mindspore.float32)
|
|
11944
|
+
>>> output = ops.round(input, decimals=1)
|
|
11945
|
+
>>> print(output)
|
|
11946
|
+
[ 0.8 1.5 2.4 2.5 -4.6]
|
|
11947
|
+
"""
|
|
11948
|
+
return round_op(input, decimals)
|
|
11949
|
+
|
|
11950
|
+
|
|
11601
11951
|
__all__ = [
|
|
11602
11952
|
'addn',
|
|
11603
11953
|
'absolute',
|
|
@@ -11821,6 +12171,7 @@ __all__ = [
|
|
|
11821
12171
|
'accumulate_n',
|
|
11822
12172
|
'iou',
|
|
11823
12173
|
'baddbmm',
|
|
12174
|
+
'baddbmm_ext',
|
|
11824
12175
|
'bmm',
|
|
11825
12176
|
'trapz',
|
|
11826
12177
|
'cholesky',
|