forked from ivy-llc/ivy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import ivy | ||
from ivy.functional.frontends.tensorflow.func_wrapper import ( | ||
to_ivy_arrays_and_back, | ||
) | ||
from ivy.func_wrapper import with_supported_dtypes | ||
|
||
|
||
# stft | ||
@with_supported_dtypes( | ||
{ | ||
"2.5.1 and below": ( | ||
"complex64", | ||
"complex128", | ||
) | ||
}, | ||
"paddle", | ||
) | ||
@to_ivy_arrays_and_back | ||
def stft( | ||
x, | ||
n_fft, | ||
hop_length=None, | ||
win_length=None, | ||
window=None, | ||
center=True, | ||
pad_mode="reflect", | ||
normalized=False, | ||
onesided=True, | ||
name=None, | ||
): | ||
x = ivy.asarray(x) | ||
return ivy.stft( | ||
x, | ||
n_fft, | ||
hop_length=hop_length, | ||
win_length=win_length, | ||
window=window, | ||
center=center, | ||
pad_mode=pad_mode, | ||
normalized=normalized, | ||
onesided=onesided, | ||
name=name, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# global | ||
from hypothesis import strategies as st | ||
|
||
# local | ||
import ivy_tests.test_ivy.helpers as helpers | ||
from ivy_tests.test_ivy.helpers import handle_frontend_test | ||
|
||
|
||
# --- Helpers --- # | ||
# --------------- # | ||
|
||
|
||
@st.composite | ||
def _valid_stft(draw): | ||
dtype, x = draw( | ||
helpers.dtype_and_values( | ||
available_dtypes=["float32", "float64"], | ||
max_value=65280, | ||
min_value=-65280, | ||
min_num_dims=1, | ||
min_dim_size=2, | ||
shared_dtype=True, | ||
) | ||
) | ||
n_fft = draw(helpers.ints(min_value=16, max_value=100)) | ||
hop_length = draw(helpers.ints(min_value=1, max_value=50)) | ||
|
||
return dtype, x, n_fft, hop_length | ||
|
||
|
||
# --- Main --- # | ||
# ------------ # | ||
|
||
|
||
# Updated test function | ||
@handle_frontend_test( | ||
fn_tree="paddle.signal.stft", | ||
dtype_x_and_args=_valid_stft(), | ||
test_with_out=st.just(False), | ||
) | ||
def test_paddle_stft( | ||
*, | ||
dtype_x_and_args, | ||
frontend, | ||
test_flags, | ||
fn_tree, | ||
backend_fw, | ||
on_device, | ||
): | ||
input_dtype, x, n_fft, hop_length = dtype_x_and_args | ||
helpers.test_frontend_function( | ||
input_dtypes=input_dtype, | ||
backend_to_test=backend_fw, | ||
frontend=frontend, | ||
test_flags=test_flags, | ||
fn_tree=fn_tree, | ||
on_device=on_device, | ||
x=x, | ||
n_fft=n_fft, | ||
hop_length=hop_length, | ||
win_length=None, | ||
window=None, | ||
center=True, | ||
pad_mode="reflect", | ||
normalized=False, | ||
onesided=True, | ||
atol=1e-02, | ||
rtol=1e-02, | ||
) |