mindspore 2.3.0__cp310-cp310-win_amd64.whl → 2.4.0__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +3 -1
- mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
- mindspore/_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/atlprov.dll +0 -0
- 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/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.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/dpcmi.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/msobj140.dll +0 -0
- mindspore/mspdb140.dll +0 -0
- mindspore/mspdbcore.dll +0 -0
- mindspore/mspdbst.dll +0 -0
- mindspore/mspft140.dll +0 -0
- mindspore/msvcdis140.dll +0 -0
- mindspore/msvcp140_1.dll +0 -0
- mindspore/msvcp140_2.dll +0 -0
- mindspore/msvcp140_atomic_wait.dll +0 -0
- mindspore/msvcp140_codecvt_ids.dll +0 -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/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -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/tbbmalloc.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/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -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 +281 -275
- 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/fft.py
CHANGED
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
# ============================================================================
|
|
15
15
|
"""Fast Fourier Transform operations, the function docs are adapted from Numpy API."""
|
|
16
16
|
from __future__ import absolute_import
|
|
17
|
-
__all__ = ['
|
|
17
|
+
__all__ = ['fft', 'ifft', 'fft2', 'ifft2', 'fftn', 'ifftn',
|
|
18
|
+
'rfft', 'irfft', 'rfft2', 'irfft2', 'rfftn', 'irfftn',
|
|
19
|
+
'hfft', 'ihfft', 'hfft2', 'ihfft2', 'hfftn', 'ihfftn',
|
|
20
|
+
'fftshift', 'ifftshift', 'fftfreq', 'rfftfreq']
|
|
18
21
|
from mindspore import ops
|
|
19
22
|
|
|
20
23
|
|
|
@@ -40,8 +43,9 @@ def fftshift(x, axes=None):
|
|
|
40
43
|
>>> import mindspore.numpy as np
|
|
41
44
|
>>> from mindspore import dtype as mstype
|
|
42
45
|
>>> x = np.array([0, 1, 2, 3, 4, -5, -4, -3, -2, -1], dtype=mstype.int32)
|
|
43
|
-
>>> np.fft.fftshift(x)
|
|
44
|
-
|
|
46
|
+
>>> out = np.fft.fftshift(x)
|
|
47
|
+
>>> print(out)
|
|
48
|
+
[-5 -4 -3 -2 -1 0 1 2 3 4]
|
|
45
49
|
"""
|
|
46
50
|
return ops.fftshift(x, axes)
|
|
47
51
|
|
|
@@ -68,8 +72,9 @@ def ifftshift(x, axes=None):
|
|
|
68
72
|
>>> import mindspore.numpy as np
|
|
69
73
|
>>> from mindspore import dtype as mstype
|
|
70
74
|
>>> x = np.array([0, 1, 2, 3, 4, -5, -4, -3, -2, -1], dtype=mstype.int32)
|
|
71
|
-
>>> np.fft.ifftshift(np.fft.fftshift(x))
|
|
72
|
-
|
|
75
|
+
>>> out = np.fft.ifftshift(np.fft.fftshift(x))
|
|
76
|
+
>>> print(out)
|
|
77
|
+
[ 0 1 2 3 4 -5 -4 -3 -2 -1]
|
|
73
78
|
"""
|
|
74
79
|
return ops.ifftshift(x, axes)
|
|
75
80
|
|
|
@@ -87,12 +92,12 @@ def fft(a, n=None, axis=-1, norm=None):
|
|
|
87
92
|
|
|
88
93
|
- Ascend/CPU: int16, int32, int64, float16, float32, float64, complex64, complex128.
|
|
89
94
|
|
|
90
|
-
n (int, optional): Length of the transformed `
|
|
91
|
-
If given, the size of the `
|
|
95
|
+
n (int, optional): Length of the transformed `axis` of the result.
|
|
96
|
+
If given, the size of the `axis` will be zero-padded or truncated to `n` before calculating `fft`.
|
|
92
97
|
Default: ``None`` , which does not need to process `a`.
|
|
93
|
-
axis (int, optional):
|
|
94
|
-
Default: ``-1`` , which means the last
|
|
95
|
-
norm (
|
|
98
|
+
axis (int, optional): The dimension along which to take the one dimensional `fft`.
|
|
99
|
+
Default: ``-1`` , which means transform the last dimension of `a`.
|
|
100
|
+
norm (str, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
96
101
|
Three modes are defined as,
|
|
97
102
|
|
|
98
103
|
- ``"backward"`` (no normalization).
|
|
@@ -109,10 +114,13 @@ def fft(a, n=None, axis=-1, norm=None):
|
|
|
109
114
|
``Ascend`` ``CPU``
|
|
110
115
|
|
|
111
116
|
Examples:
|
|
117
|
+
>>> import mindspore
|
|
112
118
|
>>> import mindspore.numpy as np
|
|
113
|
-
>>>
|
|
114
|
-
>>> np.fft.fft(
|
|
115
|
-
|
|
119
|
+
>>> a = np.array([ 1.6243454, -0.6117564, -0.5281718, -1.0729686])
|
|
120
|
+
>>> out = np.fft.fft(a, n=4, axis=-1, norm="backward")
|
|
121
|
+
>>> print(out)
|
|
122
|
+
[-0.5885514+0.j 2.1525173-0.46121222j 2.7808986+0.j
|
|
123
|
+
2.1525173+0.46121222j]
|
|
116
124
|
"""
|
|
117
125
|
return ops.fft(a, n, axis, norm)
|
|
118
126
|
|
|
@@ -130,18 +138,17 @@ def ifft(a, n=None, axis=-1, norm=None):
|
|
|
130
138
|
|
|
131
139
|
- Ascend/CPU: int16, int32, int64, float16, float32, float64, complex64, complex128.
|
|
132
140
|
|
|
133
|
-
n (int, optional): Length of the transformed `
|
|
134
|
-
|
|
135
|
-
If given, the input will either be zero-padded or trimmed to this length before computing `ifft`.
|
|
141
|
+
n (int, optional): Length of the transformed `axis` of the result.
|
|
142
|
+
If given, the size of the `axis` will be zero-padded or truncated to `n` before calculating `ifft`.
|
|
136
143
|
Default: ``None`` , which does not need to process `a`.
|
|
137
|
-
axis (int, optional):
|
|
138
|
-
Default: ``-1`` , which means the last
|
|
139
|
-
norm (
|
|
144
|
+
axis (int, optional): The dimension along which to take the one dimensional `ifft`.
|
|
145
|
+
Default: ``-1`` , which means transform the last dimension of `a`.
|
|
146
|
+
norm (str, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
140
147
|
Three modes are defined as,
|
|
141
148
|
|
|
142
|
-
- ``"backward"`` (
|
|
143
|
-
- ``"forward"`` (
|
|
144
|
-
- ``"ortho"`` (normalize by :math:`1
|
|
149
|
+
- ``"backward"`` (normalize by :math:`1/n`).
|
|
150
|
+
- ``"forward"`` (no normalization).
|
|
151
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
145
152
|
|
|
146
153
|
Returns:
|
|
147
154
|
Tensor, The result of `ifft()` function. The default is the same shape as `a`.
|
|
@@ -153,10 +160,13 @@ def ifft(a, n=None, axis=-1, norm=None):
|
|
|
153
160
|
``Ascend`` ``CPU``
|
|
154
161
|
|
|
155
162
|
Examples:
|
|
163
|
+
>>> import mindspore
|
|
156
164
|
>>> import mindspore.numpy as np
|
|
157
|
-
>>>
|
|
158
|
-
>>> np.fft.ifft(
|
|
159
|
-
|
|
165
|
+
>>> a = np.array([ 1.6243454, -0.6117564, -0.5281718, -1.0729686])
|
|
166
|
+
>>> out = np.fft.ifft(a, n=4, axis=-1, norm="backward")
|
|
167
|
+
>>> print(out)
|
|
168
|
+
[-0.14713785+0.j 0.5381293 +0.11530305j 0.69522464+0.j
|
|
169
|
+
0.5381293 -0.11530305j]
|
|
160
170
|
"""
|
|
161
171
|
return ops.ifft(a, n, axis, norm)
|
|
162
172
|
|
|
@@ -190,11 +200,10 @@ def rfft(a, n=None, axis=-1, norm=None):
|
|
|
190
200
|
|
|
191
201
|
Examples:
|
|
192
202
|
>>> import mindspore
|
|
193
|
-
>>>
|
|
194
|
-
>>>
|
|
195
|
-
>>>
|
|
196
|
-
>>>
|
|
197
|
-
>>> print(y)
|
|
203
|
+
>>> import mindspore.numpy as np
|
|
204
|
+
>>> a = np.array([1, 2, 3, 4])
|
|
205
|
+
>>> out = np.fft.rfft(a, n=4, axis=-1, norm='backward')
|
|
206
|
+
>>> print(out)
|
|
198
207
|
[10.+0.j -2.+2.j -2.+0.j]
|
|
199
208
|
"""
|
|
200
209
|
return ops.rfft(a, n, axis, norm)
|
|
@@ -205,11 +214,11 @@ def irfft(a, n=None, axis=-1, norm=None):
|
|
|
205
214
|
Calculates the inverse of `rfft()`.
|
|
206
215
|
|
|
207
216
|
Refer to :func:`mindspore.ops.irfft` for more details.
|
|
208
|
-
The difference is that `a` corresponds to `
|
|
217
|
+
The difference is that `a` corresponds to `a` and `axis` corresponds to `dim`.
|
|
209
218
|
|
|
210
219
|
Args:
|
|
211
220
|
a (Tensor): The input tensor.
|
|
212
|
-
n (int, optional): Length of the transformed `
|
|
221
|
+
n (int, optional): Length of the transformed `axis` of the result.
|
|
213
222
|
If given, the input will either be zero-padded or trimmed to this length before computing `rfft`.
|
|
214
223
|
If n is not given, it is taken to be :math:`2*(a.shape[axis]-1)`.
|
|
215
224
|
Default: ``None``.
|
|
@@ -218,8 +227,8 @@ def irfft(a, n=None, axis=-1, norm=None):
|
|
|
218
227
|
norm (string, optional): Normalization mode. Default: ``None`` that means ``"backward"``.
|
|
219
228
|
Three modes are defined as,
|
|
220
229
|
|
|
221
|
-
- ``"backward"`` (
|
|
222
|
-
- ``"forward"`` (
|
|
230
|
+
- ``"backward"`` (normalize by :math:`1/n`).
|
|
231
|
+
- ``"forward"`` (no normalization).
|
|
223
232
|
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
224
233
|
|
|
225
234
|
Returns:
|
|
@@ -230,13 +239,11 @@ def irfft(a, n=None, axis=-1, norm=None):
|
|
|
230
239
|
|
|
231
240
|
Examples:
|
|
232
241
|
>>> import mindspore
|
|
233
|
-
>>>
|
|
234
|
-
>>>
|
|
235
|
-
>>>
|
|
236
|
-
>>> y = mnp.fft.irfft(input)
|
|
242
|
+
>>> import mindspore.numpy as np
|
|
243
|
+
>>> a = np.array([1, 2, 3, 4])
|
|
244
|
+
>>> y = np.fft.irfft(a, n=6, axis=-1, norm='backward')
|
|
237
245
|
>>> print(y)
|
|
238
|
-
[ 2.
|
|
239
|
-
4.2470195e-16 -6.6666669e-01]
|
|
246
|
+
[ 2.5 -0.6666667 0. -0.16666667 0. -0.6666667 ]
|
|
240
247
|
"""
|
|
241
248
|
return ops.irfft(a, n, axis, norm)
|
|
242
249
|
|
|
@@ -260,7 +267,7 @@ def fft2(a, s=None, axes=(-2, -1), norm=None):
|
|
|
260
267
|
axes (tuple[int], optional): The dimension along which to take the one dimensional `fft2`.
|
|
261
268
|
Default: ``(-2, -1)`` , which means transform the last two dimension of `a`.
|
|
262
269
|
norm (string, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
263
|
-
Three modes are defined as,
|
|
270
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
264
271
|
|
|
265
272
|
- ``"backward"`` (no normalization).
|
|
266
273
|
- ``"forward"`` (normalize by :math:`1/n`).
|
|
@@ -278,12 +285,12 @@ def fft2(a, s=None, axes=(-2, -1), norm=None):
|
|
|
278
285
|
Examples:
|
|
279
286
|
>>> import mindspore.numpy as np
|
|
280
287
|
>>> a = np.ones((4, 4))
|
|
281
|
-
>>> np.fft.fft2(a, s=(4, 4), axes=(0, 1), norm="backward")
|
|
282
|
-
|
|
283
|
-
[[16
|
|
284
|
-
[
|
|
285
|
-
[
|
|
286
|
-
[
|
|
288
|
+
>>> out = np.fft.fft2(a, s=(4, 4), axes=(0, 1), norm="backward")
|
|
289
|
+
>>> print(out)
|
|
290
|
+
[[16.+0.j 0.+0.j 0.+0.j 0.+0.j]
|
|
291
|
+
[ 0.+0.j 0.+0.j 0.+0.j 0.+0.j]
|
|
292
|
+
[ 0.+0.j 0.+0.j 0.+0.j 0.+0.j]
|
|
293
|
+
[ 0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
|
|
287
294
|
"""
|
|
288
295
|
return ops.fft2(a, s, axes, norm)
|
|
289
296
|
|
|
@@ -302,16 +309,16 @@ def ifft2(a, s=None, axes=(-2, -1), norm=None):
|
|
|
302
309
|
- Ascend/CPU: int16, int32, int64, float16, float32, float64, complex64, complex128.
|
|
303
310
|
|
|
304
311
|
s (tuple[int], optional): Length of the transformed `axes` of the result.
|
|
305
|
-
If given, the
|
|
312
|
+
If given, the `a.shape[axes[i]]` will be zero-padded or truncated to `s[i]` before calculating `ifft2`.
|
|
306
313
|
Default: ``None`` , which does not need to process `a`.
|
|
307
314
|
axes (tuple[int], optional): The dimension along which to take the one dimensional `ifft2`.
|
|
308
315
|
Default: ``(-2, -1)`` , which means transform the last two dimension of `a`.
|
|
309
|
-
norm (
|
|
310
|
-
Three modes are defined as,
|
|
316
|
+
norm (str, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
317
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
311
318
|
|
|
312
|
-
- ``"backward"`` (
|
|
313
|
-
- ``"forward"`` (
|
|
314
|
-
- ``"ortho"`` (normalize by :math:`1
|
|
319
|
+
- ``"backward"`` (normalize by :math:`1/n`).
|
|
320
|
+
- ``"forward"`` (no normalization).
|
|
321
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
315
322
|
|
|
316
323
|
Returns:
|
|
317
324
|
Tensor, The result of `ifft2()` function. The default is the same shape as `a`.
|
|
@@ -325,12 +332,12 @@ def ifft2(a, s=None, axes=(-2, -1), norm=None):
|
|
|
325
332
|
Examples:
|
|
326
333
|
>>> import mindspore.numpy as np
|
|
327
334
|
>>> a = np.ones((4, 4))
|
|
328
|
-
>>> np.fft.ifft2(a, s=(4, 4), axes=(0, 1), norm="backward")
|
|
329
|
-
|
|
330
|
-
[[1
|
|
331
|
-
[0
|
|
332
|
-
[0
|
|
333
|
-
[0
|
|
335
|
+
>>> out = np.fft.ifft2(a, s=(4, 4), axes=(0, 1), norm="backward")
|
|
336
|
+
>>> print(out)
|
|
337
|
+
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
|
|
338
|
+
[0.+0.j 0.+0.j 0.+0.j 0.+0.j]
|
|
339
|
+
[0.+0.j 0.+0.j 0.+0.j 0.+0.j]
|
|
340
|
+
[0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
|
|
334
341
|
"""
|
|
335
342
|
return ops.ifft2(a, s, axes, norm)
|
|
336
343
|
|
|
@@ -355,7 +362,7 @@ def fftn(a, s=None, axes=None, norm=None):
|
|
|
355
362
|
Default: ``None`` , which means transform the all dimension of `a`,
|
|
356
363
|
or the last `len(s)` dimensions if s is given.
|
|
357
364
|
norm (string, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
358
|
-
Three modes are defined as,
|
|
365
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
359
366
|
|
|
360
367
|
- ``"backward"`` (no normalization).
|
|
361
368
|
- ``"forward"`` (normalize by :math:`1/n`).
|
|
@@ -373,12 +380,12 @@ def fftn(a, s=None, axes=None, norm=None):
|
|
|
373
380
|
Examples:
|
|
374
381
|
>>> import mindspore.numpy as np
|
|
375
382
|
>>> a = np.ones((2, 2, 2))
|
|
376
|
-
>>> np.fft.fftn(a, s=(2, 2, 2), axes=(0, 1, 2), norm="backward")
|
|
377
|
-
|
|
378
|
-
[[[8
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
383
|
+
>>> out = np.fft.fftn(a, s=(2, 2, 2), axes=(0, 1, 2), norm="backward")
|
|
384
|
+
>>> print(out)
|
|
385
|
+
[[[8.+0.j 0.+0.j]
|
|
386
|
+
[0.+0.j 0.+0.j]]
|
|
387
|
+
[[0.+0.j 0.+0.j]
|
|
388
|
+
[0.+0.j 0.+0.j]]]
|
|
382
389
|
"""
|
|
383
390
|
return ops.fftn(a, s, axes, norm)
|
|
384
391
|
|
|
@@ -403,11 +410,11 @@ def ifftn(a, s=None, axes=None, norm=None):
|
|
|
403
410
|
Default: ``None`` , which means transform the all dimension of `a`,
|
|
404
411
|
or the last `len(s)` dimensions if s is given.
|
|
405
412
|
norm (string, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
406
|
-
Three modes are defined as,
|
|
413
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
407
414
|
|
|
408
|
-
- ``"backward"`` (
|
|
409
|
-
- ``"forward"`` (
|
|
410
|
-
- ``"ortho"`` (normalize by :math:`1
|
|
415
|
+
- ``"backward"`` (normalize by :math:`1/n`).
|
|
416
|
+
- ``"forward"`` (no normalization).
|
|
417
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
411
418
|
|
|
412
419
|
Returns:
|
|
413
420
|
Tensor, The result of `ifftn()` function. The default is the same shape as `a`.
|
|
@@ -421,11 +428,539 @@ def ifftn(a, s=None, axes=None, norm=None):
|
|
|
421
428
|
Examples:
|
|
422
429
|
>>> import mindspore.numpy as np
|
|
423
430
|
>>> a = np.ones((2, 2, 2))
|
|
424
|
-
>>> np.fft.ifftn(a, s=(2, 2, 2), axes=(0, 1, 2), norm="backward")
|
|
431
|
+
>>> out = np.fft.ifftn(a, s=(2, 2, 2), axes=(0, 1, 2), norm="backward")
|
|
432
|
+
>>> print(out)
|
|
433
|
+
[[[1.+0.j 0.+0.j]
|
|
434
|
+
[0.+0.j 0.+0.j]]
|
|
435
|
+
[[0.+0.j 0.+0.j]
|
|
436
|
+
[0.+0.j 0.+0.j]]]
|
|
437
|
+
"""
|
|
438
|
+
return ops.ifftn(a, s, axes, norm)
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def rfft2(a, s=None, axes=(-2, -1), norm=None):
|
|
442
|
+
r"""
|
|
443
|
+
Calculates the two dimensional discrete Fourier transform for real input `a`.
|
|
444
|
+
|
|
445
|
+
Refer to :func:`mindspore.ops.rfft2` for more details.
|
|
446
|
+
The difference is that `a` corresponds to `input` and `axes` corresponds to `dim`.
|
|
447
|
+
|
|
448
|
+
Args:
|
|
449
|
+
a (Tensor): The input tensor.
|
|
450
|
+
Supported dtypes:
|
|
451
|
+
|
|
452
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64.
|
|
453
|
+
|
|
454
|
+
s (tuple[int], optional): Length of the transformed `axes` of the result.
|
|
455
|
+
If given, the size of the `axes[i]` axis will be zero-padded or truncated to `s[i]`
|
|
456
|
+
before calculating `rfft2`.
|
|
457
|
+
Default: ``None`` , which does not need to process `a`.
|
|
458
|
+
axes (tuple[int], optional): The dimension along which to take the one dimensional `rfft2`.
|
|
459
|
+
Default: ``(-2, -1)`` , which means transform the last two dimension of `a`.
|
|
460
|
+
norm (string, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
461
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
462
|
+
|
|
463
|
+
- ``"backward"`` (no normalization).
|
|
464
|
+
- ``"forward"`` (normalize by :math:`1/n`).
|
|
465
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
466
|
+
|
|
467
|
+
Returns:
|
|
468
|
+
Tensor, the result of `rfft2()` function, dtype of the result is complex64/128.
|
|
469
|
+
If `s` is given, result.shape[axes[i]] is :math:`s[i]`, while result.shape[axes[-1]] is :math:`s[-1] // 2 + 1`.
|
|
470
|
+
|
|
471
|
+
Supported Platforms:
|
|
472
|
+
``Ascend`` ``CPU``
|
|
473
|
+
|
|
474
|
+
Examples:
|
|
475
|
+
>>> import mindspore
|
|
476
|
+
>>> from mindspore import Tensor
|
|
477
|
+
>>> from mindspore import numpy as mnp
|
|
478
|
+
>>> a = mnp.ones((2, 2))
|
|
479
|
+
>>> mnp.fft.rfft2(a, s=(2, 2), axes=(0, 1), norm="backward")
|
|
480
|
+
Tensor(shape=[2, 2], dtype=Complex64, value=
|
|
481
|
+
[[4+0j, 0+0j],
|
|
482
|
+
[0+0j, 0+0j]])
|
|
483
|
+
"""
|
|
484
|
+
return ops.rfft2(a, s, axes, norm)
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def irfft2(a, s=None, axes=(-2, -1), norm=None):
|
|
488
|
+
r"""
|
|
489
|
+
Calculates the inverse of `rfft2()`.
|
|
490
|
+
|
|
491
|
+
Refer to :func:`mindspore.ops.irfft2` for more details.
|
|
492
|
+
The difference is that `a` corresponds to `input` and `axes` corresponds to `dim`.
|
|
493
|
+
|
|
494
|
+
Args:
|
|
495
|
+
a (Tensor): The input tensor.
|
|
496
|
+
Supported dtypes:
|
|
497
|
+
|
|
498
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64, complex64, complex128.
|
|
499
|
+
|
|
500
|
+
s (tuple[int], optional): Length of the transformed `axes` of the result.
|
|
501
|
+
If given, the input will either be zero-padded or trimmed to this length before computing `irfft2`.
|
|
502
|
+
Default: ``None`` , the axes[-1] of the `a` will be zero-padded to :math:`2*(a.shape[axes[-1]]-1)`.
|
|
503
|
+
axes (tuple[int], optional): The dimension along which to take the one dimensional `irfft2`.
|
|
504
|
+
Default: ``(-2, -1)`` , which means transform the last two dimension of `a`.
|
|
505
|
+
norm (string, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
506
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
507
|
+
|
|
508
|
+
- ``"backward"`` (normalize by :math:`1/n`).
|
|
509
|
+
- ``"forward"`` (no normalization).
|
|
510
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
511
|
+
|
|
512
|
+
Returns:
|
|
513
|
+
Tensor, The result of `irfft2()` function, result.shape[axes[i]] is s[i].
|
|
514
|
+
When the `a` is int16, int32, int64, float16, float32, complex64, the return value type is float32.
|
|
515
|
+
When the `a` is float64 or complex128, the return value type is float64.
|
|
516
|
+
|
|
517
|
+
Supported Platforms:
|
|
518
|
+
``Ascend`` ``CPU``
|
|
519
|
+
|
|
520
|
+
Examples:
|
|
521
|
+
>>> import mindspore
|
|
522
|
+
>>> from mindspore import Tensor
|
|
523
|
+
>>> from mindspore import numpy as mnp
|
|
524
|
+
>>> a = mnp.ones((4, 4))
|
|
525
|
+
>>> mnp.fft.irfft2(a, s=(4, 4), axes=(0, 1), norm="backward")
|
|
526
|
+
Tensor(shape=[4, 4], dtype=Float32, value=
|
|
527
|
+
[[ 1.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
|
|
528
|
+
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
|
|
529
|
+
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
|
|
530
|
+
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]])
|
|
531
|
+
"""
|
|
532
|
+
return ops.irfft2(a, s, axes, norm)
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
def rfftn(a, s=None, axes=None, norm=None):
|
|
536
|
+
r"""
|
|
537
|
+
Calculates the N dimensional discrete Fourier transform for real input `a`.
|
|
538
|
+
|
|
539
|
+
Refer to :func:`mindspore.ops.rfftn` for more details.
|
|
540
|
+
The difference is that `a` corresponds to `input` and `axes` corresponds to `dim`.
|
|
541
|
+
|
|
542
|
+
Args:
|
|
543
|
+
a (Tensor): The input tensor.
|
|
544
|
+
Supported dtypes:
|
|
545
|
+
|
|
546
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64.
|
|
547
|
+
|
|
548
|
+
s (tuple[int], optional): Length of the transformed `axes` of the result.
|
|
549
|
+
If given, the input will either be zero-padded or trimmed to this length before computing `rfftn`.
|
|
550
|
+
Default: ``None`` , which does not need to process `a`.
|
|
551
|
+
axes (tuple[int], optional): The dimension along which to take the one dimensional `rfftn`.
|
|
552
|
+
Default: ``None`` , which means transform the all dimension of `a`,
|
|
553
|
+
or the last `len(s)` dimensions if s is given.
|
|
554
|
+
norm (string, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
555
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
556
|
+
|
|
557
|
+
- ``"backward"`` (no normalization).
|
|
558
|
+
- ``"forward"`` (normalize by :math:`1/n`).
|
|
559
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
560
|
+
|
|
561
|
+
Returns:
|
|
562
|
+
Tensor, the result of `rfftn()` function, dtype of the result is complex64/128.
|
|
563
|
+
If `s` is given, result.shape[axes[i]] is :math:`s[i]`, while result.shape[axes[-1]] is :math:`s[-1] // 2 + 1`.
|
|
564
|
+
|
|
565
|
+
Supported Platforms:
|
|
566
|
+
``Ascend`` ``CPU``
|
|
567
|
+
|
|
568
|
+
Examples:
|
|
569
|
+
>>> import mindspore
|
|
570
|
+
>>> from mindspore import Tensor
|
|
571
|
+
>>> from mindspore import numpy as mnp
|
|
572
|
+
>>> a = mnp.ones((2, 2, 2))
|
|
573
|
+
>>> mnp.fft.rfftn(a, s=(2, 2, 2), axes=(0, 1, 2), norm="backward")
|
|
425
574
|
Tensor(shape=[2, 2, 2], dtype=Complex64, value=
|
|
426
|
-
[[[
|
|
427
|
-
|
|
575
|
+
[[[8+0j, 0+0j],
|
|
576
|
+
[0+0j, 0+0j]],
|
|
428
577
|
[[0+0j, 0+0j],
|
|
429
|
-
|
|
578
|
+
[0+0j, 0+0j]]])
|
|
430
579
|
"""
|
|
431
|
-
return ops.
|
|
580
|
+
return ops.rfftn(a, s, axes, norm)
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
def irfftn(a, s=None, axes=None, norm=None):
|
|
584
|
+
r"""
|
|
585
|
+
Calculates the inverse of `rfftn()`.
|
|
586
|
+
|
|
587
|
+
Refer to :func:`mindspore.ops.irfftn` for more details.
|
|
588
|
+
The difference is that `a` corresponds to `input` and `axes` corresponds to `dim`.
|
|
589
|
+
|
|
590
|
+
Args:
|
|
591
|
+
a (Tensor): The input tensor.
|
|
592
|
+
Supported dtypes:
|
|
593
|
+
|
|
594
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64, complex64, complex128.
|
|
595
|
+
|
|
596
|
+
s (tuple[int], optional): Length of the transformed `axes` of the result.
|
|
597
|
+
If given, the input will either be zero-padded or trimmed to this length before computing `irfftn`.
|
|
598
|
+
Default: ``None`` , the axes[-1] of the `a` will be zero-padded to :math:`2*(a.shape[axes[-1]]-1)`.
|
|
599
|
+
axes (tuple[int], optional): The dimension along which to take the one dimensional `irfftn`.
|
|
600
|
+
Default: ``None`` , which means transform the all dimension of `a`,
|
|
601
|
+
or the last `len(s)` dimensions if s is given.
|
|
602
|
+
norm (string, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
603
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
604
|
+
|
|
605
|
+
- ``"backward"`` (normalize by :math:`1/n`).
|
|
606
|
+
- ``"forward"`` (no normalization).
|
|
607
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
608
|
+
|
|
609
|
+
Returns:
|
|
610
|
+
Tensor, The result of `irfft2()` function, result.shape[axes[i]] is s[i].
|
|
611
|
+
When the `a` is int16, int32, int64, float16, float32, complex64, the return value type is float32.
|
|
612
|
+
When the `a` is float64 or complex128, the return value type is float64.
|
|
613
|
+
|
|
614
|
+
Supported Platforms:
|
|
615
|
+
``Ascend`` ``CPU``
|
|
616
|
+
|
|
617
|
+
Examples:
|
|
618
|
+
>>> import mindspore
|
|
619
|
+
>>> from mindspore import Tensor
|
|
620
|
+
>>> from mindspore import numpy as mnp
|
|
621
|
+
>>> a = mnp.ones((2, 2, 2))
|
|
622
|
+
>>> mnp.fft.irfftn(a, s=(2, 2, 2), axes=(0, 1, 2), norm="backward")
|
|
623
|
+
Tensor(shape=[2, 2, 2], dtype=Float32, value=
|
|
624
|
+
[[[ 1.00000000e+00, 0.00000000e+00],
|
|
625
|
+
[ 0.00000000e+00, 0.00000000e+00]],
|
|
626
|
+
[[ 0.00000000e+00, 0.00000000e+00],
|
|
627
|
+
[ 0.00000000e+00, 0.00000000e+00]]])
|
|
628
|
+
"""
|
|
629
|
+
return ops.irfftn(a, s, axes, norm)
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
def hfft(a, n=None, axis=-1, norm=None):
|
|
633
|
+
r"""
|
|
634
|
+
Calculates the one dimensional discrete Fourier transform of of a Hermitian symmetric `a` signal.
|
|
635
|
+
|
|
636
|
+
Refer to :func:`mindspore.ops.hfft` for more details.
|
|
637
|
+
The difference is that `a` corresponds to `input` and `axis` corresponds to `dim`.
|
|
638
|
+
|
|
639
|
+
Args:
|
|
640
|
+
a (Tensor): The input tensor.
|
|
641
|
+
Supported dtypes:
|
|
642
|
+
|
|
643
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64, complex64, complex128.
|
|
644
|
+
|
|
645
|
+
n (int, optional): Length of the transformed `axis` of the result.
|
|
646
|
+
If given, the size of the `axis` axis will be zero-padded or truncated to `n` before calculating `hfft`.
|
|
647
|
+
Default: ``None`` , which does not need to process `a`.
|
|
648
|
+
axis (int, optional): The dimension along which to take the one dimensional `hfft`.
|
|
649
|
+
Default: ``-1`` , which means transform the last dimension of `a`.
|
|
650
|
+
norm (str, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
651
|
+
Three modes are defined as,
|
|
652
|
+
|
|
653
|
+
- ``"backward"`` (no normalization).
|
|
654
|
+
- ``"forward"`` (normalize by :math:`1/n`).
|
|
655
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
656
|
+
|
|
657
|
+
Returns:
|
|
658
|
+
Tensor, The result of `hfft()` function.
|
|
659
|
+
If `n` is given, result.shape[axis] is :math:`(n - 1) * 2`, otherwise math:`(a.shape[axis] - 1) * 2`.
|
|
660
|
+
When the `a` is int16, int32, int64, float16, float32, complex64, the return value type is float32.
|
|
661
|
+
When the `a` is float64 or complex128, the return value type is float64.
|
|
662
|
+
|
|
663
|
+
Supported Platforms:
|
|
664
|
+
``Ascend`` ``CPU``
|
|
665
|
+
|
|
666
|
+
Examples:
|
|
667
|
+
>>> import mindspore
|
|
668
|
+
>>> from mindspore import Tensor
|
|
669
|
+
>>> from mindspore import numpy as np
|
|
670
|
+
>>> a = np.array([ 1.6243454, -0.6117564, -0.5281718, -1.0729686])
|
|
671
|
+
>>> out = np.fft.hfft(a, n=4, axis=-1, norm="backward")
|
|
672
|
+
>>> print(out)
|
|
673
|
+
[-0.12733912 2.1525173 2.3196864 2.1525173 ]
|
|
674
|
+
"""
|
|
675
|
+
return ops.hfft(a, n, axis, norm)
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
def ihfft(a, n=None, axis=-1, norm=None):
|
|
679
|
+
r"""
|
|
680
|
+
Calculates the inverse of `hfft()`.
|
|
681
|
+
|
|
682
|
+
Refer to :func:`mindspore.ops.ihfft` for more details.
|
|
683
|
+
The difference is that `a` corresponds to `input` and `axis` corresponds to `dim`.
|
|
684
|
+
|
|
685
|
+
Note:
|
|
686
|
+
- `ihfft` is currently only used in `mindscience` scientific computing scenarios and
|
|
687
|
+
dose not support other usage scenarios.
|
|
688
|
+
- `ihfft` is not supported on Windows platform yet.
|
|
689
|
+
|
|
690
|
+
Args:
|
|
691
|
+
a (Tensor): The input tensor.
|
|
692
|
+
Supported dtypes:
|
|
693
|
+
|
|
694
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64.
|
|
695
|
+
|
|
696
|
+
n (int, optional): Length of the transformed `axis` of the result.
|
|
697
|
+
If given, the size of the `axis` will be zero-padded or truncated to `n` before calculating `ihfft`.
|
|
698
|
+
Default: ``None`` , which does not need to process `a`.
|
|
699
|
+
axis (int, optional): The dimension along which to take the one dimensional `ihfft`.
|
|
700
|
+
Default: ``-1`` , which means transform the last dimension of `a`.
|
|
701
|
+
norm (str, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
702
|
+
Three modes are defined as,
|
|
703
|
+
|
|
704
|
+
- ``"backward"`` (normalize by :math:`1/n`).
|
|
705
|
+
- ``"forward"`` (no normalization).
|
|
706
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
707
|
+
|
|
708
|
+
Returns:
|
|
709
|
+
Tensor, The result of `ihfft()` function.
|
|
710
|
+
If `n` is given, result.shape[axis] is :math:`n // 2 + 1`, otherwise math:`a.shape[axis] // 2 + 1`.
|
|
711
|
+
When the `a` is int16, int32, int64, float16, float32, the return value type is complex64.
|
|
712
|
+
When the `a` is float64, the return value type is complex128.
|
|
713
|
+
|
|
714
|
+
Supported Platforms:
|
|
715
|
+
``Ascend`` ``CPU``
|
|
716
|
+
|
|
717
|
+
Examples:
|
|
718
|
+
>>> import mindspore
|
|
719
|
+
>>> from mindspore import Tensor
|
|
720
|
+
>>> from mindspore import numpy as np
|
|
721
|
+
>>> a = np.array([ 1.6243454, -0.6117564, -0.5281718, -1.0729686])
|
|
722
|
+
>>> out = np.fft.ihfft(a, n=4, axis=-1, norm="backward")
|
|
723
|
+
>>> print(out)
|
|
724
|
+
[-0.14713785-0.j 0.5381293 +0.11530305j 0.69522464-0.j ]
|
|
725
|
+
"""
|
|
726
|
+
return ops.ihfft(a, n, axis, norm)
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
def hfft2(a, s=None, axes=(-2, -1), norm=None):
|
|
730
|
+
r"""
|
|
731
|
+
Calculates the two dimensional discrete Fourier transform of of a Hermitian symmetric `a` signal.
|
|
732
|
+
|
|
733
|
+
Refer to :func:`mindspore.ops.hfft2` for more details.
|
|
734
|
+
The difference is that `a` corresponds to `input` and `axes` corresponds to `dim`.
|
|
735
|
+
|
|
736
|
+
Args:
|
|
737
|
+
a (Tensor): The input tensor.
|
|
738
|
+
Supported dtypes:
|
|
739
|
+
|
|
740
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64, complex64, complex128.
|
|
741
|
+
|
|
742
|
+
s (tuple[int], optional): Length of the transformed `axes` of the result.
|
|
743
|
+
If given, the `a.shape[axes[i]]` will be zero-padded or truncated to `s[i]` before calculating `hfft2`.
|
|
744
|
+
Default: ``None`` , which does not need to process `a`.
|
|
745
|
+
axes (tuple[int], optional): The dimension along which to take the one dimensional `hfft2`.
|
|
746
|
+
Default: ``(-2, -1)`` , which means transform the last two dimension of `a`.
|
|
747
|
+
norm (str, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
748
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
749
|
+
|
|
750
|
+
- ``"backward"`` (no normalization).
|
|
751
|
+
- ``"forward"`` (normalize by :math:`1/n`).
|
|
752
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
753
|
+
|
|
754
|
+
Returns:
|
|
755
|
+
Tensor, The result of `hfft2()` function.
|
|
756
|
+
If `s` is given, result.shape[axes[i]] is s[i], and for the last transformed axes,
|
|
757
|
+
result.shape[axes[-1]] is :math:`(s[-1] - 1) * 2`, otherwise :math:`(a.shape[axes[-1]] - 1) * 2`.
|
|
758
|
+
When the `a` is int16, int32, int64, float16, float32, complex64, the return value type is complex64.
|
|
759
|
+
When the `a` is float64 or complex128, the return value type is complex128.
|
|
760
|
+
|
|
761
|
+
Supported Platforms:
|
|
762
|
+
``Ascend`` ``CPU``
|
|
763
|
+
|
|
764
|
+
Examples:
|
|
765
|
+
>>> import mindspore.numpy as np
|
|
766
|
+
>>> a = np.ones((4, 4))
|
|
767
|
+
>>> out = np.fft.hfft2(a, s=(4, 4), axes=(0, 1), norm="backward")
|
|
768
|
+
>>> print(out)
|
|
769
|
+
[[16. 0. 0. 0.]
|
|
770
|
+
[ 0. 0. 0. 0.]
|
|
771
|
+
[ 0. 0. 0. 0.]
|
|
772
|
+
[ 0. 0. 0. 0.]]
|
|
773
|
+
"""
|
|
774
|
+
return ops.hfft2(a, s, axes, norm)
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
def ihfft2(a, s=None, axes=(-2, -1), norm=None):
|
|
778
|
+
r"""
|
|
779
|
+
Computes the two dimensional inverse discrete Fourier transform of real `a`.
|
|
780
|
+
|
|
781
|
+
Refer to :func:`mindspore.ops.ihfft2` for more details.
|
|
782
|
+
The difference is that `a` corresponds to `input` and `axes` corresponds to `dim`.
|
|
783
|
+
|
|
784
|
+
Args:
|
|
785
|
+
a (Tensor): The input tensor.
|
|
786
|
+
Supported dtypes:
|
|
787
|
+
|
|
788
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64.
|
|
789
|
+
|
|
790
|
+
s (tuple[int], optional): Length of the transformed `axes` of the result.
|
|
791
|
+
If given, the `a.shape[axes[i]]` will be zero-padded or truncated to `s[i]` before calculating `ihfft2`.
|
|
792
|
+
Default: ``None`` , which does not need to process `a`.
|
|
793
|
+
axes (tuple[int], optional): The dimension along which to take the one dimensional `ihfft2`.
|
|
794
|
+
Default: ``(-2, -1)`` , which means transform the last two dimension of `a`.
|
|
795
|
+
norm (str, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
796
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
797
|
+
|
|
798
|
+
- ``"backward"`` (normalize by :math:`1/n`).
|
|
799
|
+
- ``"forward"`` (no normalization).
|
|
800
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
801
|
+
|
|
802
|
+
Returns:
|
|
803
|
+
Tensor, The result of `ihfft2()` function.
|
|
804
|
+
If `s` is given, result.shape[axes[i]] is s[i], and for the last transformed `axes`,
|
|
805
|
+
result.shape[axes[-1]] is :math:`s[-1] // 2 + 1`, otherwise :math:`a.shape[axes[-1]] // 2 + 1`.
|
|
806
|
+
When the `a` is int16, int32, int64, float16, float32, the return value type is complex64.
|
|
807
|
+
When the `a` is float64, the return value type is complex128.
|
|
808
|
+
|
|
809
|
+
Supported Platforms:
|
|
810
|
+
``Ascend`` ``CPU``
|
|
811
|
+
|
|
812
|
+
Examples:
|
|
813
|
+
>>> import mindspore.numpy as np
|
|
814
|
+
>>> a = np.ones((4, 4))
|
|
815
|
+
>>> out = np.fft.ihfft2(a, s=(4, 4), axes=(0, 1), norm="backward")
|
|
816
|
+
>>> print(out)
|
|
817
|
+
[[1.-0.j 0.-0.j 0.-0.j]
|
|
818
|
+
[0.-0.j 0.-0.j 0.-0.j]
|
|
819
|
+
[0.-0.j 0.-0.j 0.-0.j]
|
|
820
|
+
[0.-0.j 0.-0.j 0.-0.j]]
|
|
821
|
+
"""
|
|
822
|
+
return ops.ihfft2(a, s, axes, norm)
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
def hfftn(a, s=None, axes=None, norm=None):
|
|
826
|
+
r"""
|
|
827
|
+
Calculates the N dimensional discrete Fourier transform of of a Hermitian symmetric `a`.
|
|
828
|
+
|
|
829
|
+
Refer to :func:`mindspore.ops.hfftn` for more details.
|
|
830
|
+
The difference is that `a` corresponds to `input` and `axes` corresponds to `dim`.
|
|
831
|
+
|
|
832
|
+
Args:
|
|
833
|
+
a (Tensor): The input tensor.
|
|
834
|
+
Supported dtypes:
|
|
835
|
+
|
|
836
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64, complex64, complex128.
|
|
837
|
+
|
|
838
|
+
s (tuple[int], optional): Length of the transformed `axes` of the result.
|
|
839
|
+
If given, the `a.shape[axes[i]]` will be zero-padded or truncated to `s[i]` before calculating `hfftn`.
|
|
840
|
+
Default: ``None`` , which does not need to process `a`.
|
|
841
|
+
axes (tuple[int], optional): The dimension along which to take the one dimensional `hfftn`.
|
|
842
|
+
Default: ``(-2, -1)`` , which means transform the last two dimension of `a`.
|
|
843
|
+
norm (str, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
844
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
845
|
+
|
|
846
|
+
- ``"backward"`` (no normalization).
|
|
847
|
+
- ``"forward"`` (normalize by :math:`1/n`).
|
|
848
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
849
|
+
|
|
850
|
+
Returns:
|
|
851
|
+
Tensor, The result of `hfftn()` function.
|
|
852
|
+
If `s` is given, result.shape[axes[i]] is s[i], and for the last transformed `axes`,
|
|
853
|
+
result.shape[axes[-1]] is :math:`(s[-1] - 1) * 2`, otherwise :math:`(a.shape[axes[-1]] - 1) * 2`.
|
|
854
|
+
When the `a` is int16, int32, int64, float16, float32, complex64, the return value type is complex64.
|
|
855
|
+
When the `a` is float64 or complex128, the return value type is complex128.
|
|
856
|
+
|
|
857
|
+
Supported Platforms:
|
|
858
|
+
``Ascend`` ``CPU``
|
|
859
|
+
|
|
860
|
+
Examples:
|
|
861
|
+
>>> import mindspore.numpy as np
|
|
862
|
+
>>> a = np.ones((4, 4))
|
|
863
|
+
>>> out = np.fft.hfftn(a, s=(4, 4), axes=(0, 1), norm="backward")
|
|
864
|
+
>>> print(out)
|
|
865
|
+
[[16. 0. 0. 0.]
|
|
866
|
+
[ 0. 0. 0. 0.]
|
|
867
|
+
[ 0. 0. 0. 0.]
|
|
868
|
+
[ 0. 0. 0. 0.]]
|
|
869
|
+
"""
|
|
870
|
+
return ops.hfftn(a, s, axes, norm)
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
def ihfftn(a, s=None, axes=None, norm=None):
|
|
874
|
+
r"""
|
|
875
|
+
Computes the N dimensional inverse discrete Fourier transform of real `a`.
|
|
876
|
+
|
|
877
|
+
Refer to :func:`mindspore.ops.ihfftn` for more details.
|
|
878
|
+
The difference is that `a` corresponds to `input` and `axes` corresponds to `dim`.
|
|
879
|
+
|
|
880
|
+
Args:
|
|
881
|
+
a (Tensor): The input tensor.
|
|
882
|
+
Supported dtypes:
|
|
883
|
+
|
|
884
|
+
- Ascend/CPU: int16, int32, int64, float16, float32, float64.
|
|
885
|
+
|
|
886
|
+
s (tuple[int], optional): Length of the transformed `axes` of the result.
|
|
887
|
+
If given, the `a.shape[axes[i]]` will be zero-padded or truncated to `s[i]` before calculating `ihfftn`.
|
|
888
|
+
Default: ``None`` , which does not need to process `a`.
|
|
889
|
+
axes (tuple[int], optional): The dimension along which to take the one dimensional `ihfftn`.
|
|
890
|
+
Default: ``(-2, -1)`` , which means transform the last two dimension of `a`.
|
|
891
|
+
norm (str, optional): Normalization mode. Default: ``None`` that means ``"backward"`` .
|
|
892
|
+
Three modes are defined as, where :math: `n = prod(s)`
|
|
893
|
+
|
|
894
|
+
- ``"backward"`` (normalize by :math:`1/n`).
|
|
895
|
+
- ``"forward"`` (no normalization).
|
|
896
|
+
- ``"ortho"`` (normalize by :math:`1/\sqrt{n}`).
|
|
897
|
+
|
|
898
|
+
Returns:
|
|
899
|
+
Tensor, The result of `ihfftn()` function.
|
|
900
|
+
If `s` is given, result.shape[axes[i]] is s[i], and for the last transformed `axes`,
|
|
901
|
+
result.shape[axes[-1]] is :math:`s[-1] // 2 + 1`, otherwise :math:`a.shape[axes[-1]] // 2 + 1`.
|
|
902
|
+
When the `a` is int16, int32, int64, float16, float32, the return value type is complex64.
|
|
903
|
+
When the `a` is float64, the return value type is complex128.
|
|
904
|
+
|
|
905
|
+
Supported Platforms:
|
|
906
|
+
``Ascend`` ``CPU``
|
|
907
|
+
|
|
908
|
+
Examples:
|
|
909
|
+
>>> import mindspore.numpy as np
|
|
910
|
+
>>> a = np.ones((4, 4))
|
|
911
|
+
>>> out = np.fft.ihfftn(a, s=(4, 4), axes=(0, 1), norm="backward")
|
|
912
|
+
>>> print(out)
|
|
913
|
+
[[16. 0. 0. 0.]
|
|
914
|
+
[ 0. 0. 0. 0.]
|
|
915
|
+
[ 0. 0. 0. 0.]
|
|
916
|
+
[ 0. 0. 0. 0.]]
|
|
917
|
+
"""
|
|
918
|
+
return ops.hfftn(a, s, axes, norm)
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
def fftfreq(n, d=1.0, dtype=None):
|
|
922
|
+
r"""
|
|
923
|
+
Return the Discrete Fourier Transform sample frequencies.
|
|
924
|
+
|
|
925
|
+
Args:
|
|
926
|
+
n (int): Window length.
|
|
927
|
+
d (float, optional): Sample spacing (inverse of the sampling rate). Default: ``1.0`` .
|
|
928
|
+
dtype (mindspore.dtype, optional): The dtype of the returned frequencies. Default: ``float32`` .
|
|
929
|
+
|
|
930
|
+
Returns:
|
|
931
|
+
Tensor, Array of length ``n`` containing the sample frequencies.
|
|
932
|
+
|
|
933
|
+
Supported Platforms:
|
|
934
|
+
``Ascend`` ``CPU``
|
|
935
|
+
|
|
936
|
+
Examples:
|
|
937
|
+
>>> import mindspore.numpy as np
|
|
938
|
+
>>> out = np.fft.fftfreq(n=4, d=1.0)
|
|
939
|
+
>>> print(out)
|
|
940
|
+
[ 0. 0.25 -0.5 -0.25]
|
|
941
|
+
"""
|
|
942
|
+
return ops.fftfreq(n, d, dtype)
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
def rfftfreq(n, d=1.0, dtype=None):
|
|
946
|
+
r"""
|
|
947
|
+
Return the Discrete Fourier Transform sample frequencies (for usage with rfft, irfft).
|
|
948
|
+
|
|
949
|
+
Args:
|
|
950
|
+
n (int): Window length.
|
|
951
|
+
d (float, optional): Sample spacing (inverse of the sampling rate). Default: ``1.0`` .
|
|
952
|
+
dtype (mindspore.dtype, optional): The dtype of the returned frequencies. Default: ``float32`` .
|
|
953
|
+
|
|
954
|
+
Returns:
|
|
955
|
+
Tensor, Array of length math:`n // 2 + 1` containing the sample frequencies.
|
|
956
|
+
|
|
957
|
+
Supported Platforms:
|
|
958
|
+
``Ascend`` ``CPU``
|
|
959
|
+
|
|
960
|
+
Examples:
|
|
961
|
+
>>> import mindspore.numpy as np
|
|
962
|
+
>>> out = np.fft.rfftfreq(n=4, d=1.0)
|
|
963
|
+
>>> print(out)
|
|
964
|
+
[0. 0.25 0.5 ]
|
|
965
|
+
"""
|
|
966
|
+
return ops.rfftfreq(n, d, dtype)
|