diff --git a/ivy/functional/backends/paddle/experimental/layers.py b/ivy/functional/backends/paddle/experimental/layers.py index 1369a98b8d6b3..f41f61af07ecf 100644 --- a/ivy/functional/backends/paddle/experimental/layers.py +++ b/ivy/functional/backends/paddle/experimental/layers.py @@ -477,6 +477,27 @@ def rfftn( return result.astype("complex128") +@with_supported_dtypes( + { + "2.5.1 and below": ( + "complex64", + "complex128", + ) + }, + backend_version, +) +def hfftn( + x: paddle.Tensor, + s: Optional[Union[int, Tuple[int]]] = None, + axes: Optional[Union[int, Tuple[int]]] = None, + *, + norm: Optional[str] = "backward", + out: Optional[paddle.Tensor] = None, +) -> paddle.Tensor: + result = paddle.fft.hfftn(x, s, axes, norm) + return result + + @with_supported_dtypes( { "2.5.1 and below": ( diff --git a/ivy/functional/frontends/paddle/fft.py b/ivy/functional/frontends/paddle/fft.py index 4355c8d954eef..c172d819b93f5 100644 --- a/ivy/functional/frontends/paddle/fft.py +++ b/ivy/functional/frontends/paddle/fft.py @@ -131,3 +131,18 @@ def rfftfreq(n, d=1.0, dtype=None, name=None): pos_max = n // 2 + 1 indices = ivy.arange(0, pos_max, dtype=dtype) return indices * val + + +@with_supported_dtypes( + { + "2.5.1 and below": ( + "complex64", + "complex128", + ) + }, + "paddle", +) +@to_ivy_arrays_and_back +def hfftn(x, n=None, axis=None, norm="backward", name=None): + result = ivy.hfftn(x, axis, n=n, norm=norm) + return ivy.real(result) \ No newline at end of file diff --git a/ivy/functional/ivy/experimental/layers.py b/ivy/functional/ivy/experimental/layers.py index 8b8db56bd375c..587179b01693a 100644 --- a/ivy/functional/ivy/experimental/layers.py +++ b/ivy/functional/ivy/experimental/layers.py @@ -1193,6 +1193,51 @@ def ifft( return ivy.current_backend(x).ifft(x, dim, norm=norm, n=n, out=out) +@handle_exceptions +@handle_backend_invalid +@handle_nestable +@handle_array_like_without_promotion +@handle_out_argument +@to_native_arrays_and_back +@handle_device_shifting +def hfftn( + x: Union[ivy.Array, ivy.NativeArray], + dim: int, + /, + *, + s: Optional[Union[int, Tuple[int, ...]]] = None, + norm: str = "backward", + n: Optional[Union[int, Tuple[int]]] = None, + out: Optional[ivy.Array] = None, +) -> ivy.Array: + r""" + Compute the FFT of a signal that has Hermitian symmetry, a real spectrum. + + Parameters + ---------- + x + The input data. It's a Tensor type. It's a complex. + n + The length of the output transform axis. + axis + Axis used to calculate FFT. If not specified, the last axis + is used by default. + norm + Indicates which direction to scale the `forward` or `backward` transform + pair and what normalization factor to use. The parameter value must be one + of "forward" or "backward" or "ortho". Default is "backward". + name + The default value is None. Normally there is no need for user to set + this property. For more information, please refer to :ref:`api_guide_Name` . + + Returns + ------- + ret + The result of HFFTN operation. + """ + return ivy.current_backend(x).hfftn(x, s, dim, norm=norm, n=n, out=out) + + @handle_exceptions @handle_backend_invalid @handle_nestable