Skip to content

Commit

Permalink
Added #23457
Browse files Browse the repository at this point in the history
  • Loading branch information
ptdatta committed Sep 13, 2023
1 parent 80989d7 commit 555a298
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ivy/functional/backends/paddle/experimental/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": (
Expand Down
15 changes: 15 additions & 0 deletions ivy/functional/frontends/paddle/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
45 changes: 45 additions & 0 deletions ivy/functional/ivy/experimental/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 555a298

Please sign in to comment.