Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move audio_resample out of experimental module #4194

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion dali/operators/audio/resample.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace dali {

DALI_SCHEMA(experimental__AudioResample)
DALI_SCHEMA(AudioResample)
.DocStr(R"(Resamples an audio signal.

The resampling is achieved by applying a sinc filter with Hann window with an extent
Expand Down Expand Up @@ -96,6 +96,17 @@ type. Example::
)",
nullptr, false);

// Deprecated alias
DALI_SCHEMA(experimental__AudioResample)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: Please look at the rendered documentation too, when available

klecki marked this conversation as resolved.
Show resolved Hide resolved
.AddParent("AudioResample")
.NumInput(1)
.NumOutput(1)
klecki marked this conversation as resolved.
Show resolved Hide resolved
.Deprecate(
"AudioResample",
R"code(This is just an deprecated alias kept for backward compatibility.)code"); // Deprecated
klecki marked this conversation as resolved.
Show resolved Hide resolved
// in 1.18


namespace audio {

using kernels::InTensorCPU;
Expand Down Expand Up @@ -185,6 +196,10 @@ class ResampleCPU : public ResampleBase<CPUBackend> {

} // namespace audio


// Kept for backwards compatibility
DALI_REGISTER_OPERATOR(experimental__AudioResample, audio::ResampleCPU, CPU);

DALI_REGISTER_OPERATOR(AudioResample, audio::ResampleCPU, CPU);

} // namespace dali
4 changes: 4 additions & 0 deletions dali/operators/audio/resample_gpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class ResampleGPU : public ResampleBase<GPUBackend> {

} // namespace audio


// Kept for backwards compatibility
DALI_REGISTER_OPERATOR(experimental__AudioResample, audio::ResampleGPU, GPU);

DALI_REGISTER_OPERATOR(AudioResample, audio::ResampleGPU, GPU);

} // namespace dali
8 changes: 4 additions & 4 deletions dali/test/python/operator/test_audio_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def audio_decoder_pipe(device):
audio1, sr1 = fn.decoders.audio(encoded, dtype=types.FLOAT, sample_rate=out_sr)
if device == 'gpu':
audio0 = audio0.gpu()
audio2 = fn.experimental.audio_resample(audio0, in_rate=sr0, out_rate=out_sr)
audio3 = fn.experimental.audio_resample(audio0, scale=out_sr / sr0)
audio4 = fn.experimental.audio_resample(audio0, out_length=fn.shapes(audio1)[0])
audio2 = fn.audio_resample(audio0, in_rate=sr0, out_rate=out_sr)
audio3 = fn.audio_resample(audio0, scale=out_sr / sr0)
audio4 = fn.audio_resample(audio0, out_length=fn.shapes(audio1)[0])
return audio1, audio2, audio3, audio4


Expand Down Expand Up @@ -87,7 +87,7 @@ def _test_type_conversion(device, src_type, in_values, dst_type, out_values, eps
@pipeline_def(batch_size=len(in_values))
def test_pipe(device):
input = fn.external_source(in_data, batch=False, cycle='quiet', device=device)
return fn.experimental.audio_resample(input, dtype=dst_type, scale=1, quality=0)
return fn.audio_resample(input, dtype=dst_type, scale=1, quality=0)

pipe = test_pipe(device, device_id=0, num_threads=4)
pipe.build()
Expand Down
4 changes: 2 additions & 2 deletions dali/test/python/test_dali_cpu_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def test_to_decibels_cpu():


def test_audio_resample():
check_single_input(fn.experimental.audio_resample, get_data=get_audio_data, input_layout=None,
check_single_input(fn.audio_resample, get_data=get_audio_data, input_layout=None,
scale=1.25)


Expand Down Expand Up @@ -1231,7 +1231,7 @@ def file_properties(files):
"math.min",
"numba.fn.experimental.numba_function",
"dl_tensor_python_function",
"experimental.audio_resample",
"audio_resample",
]

excluded_methods = [
Expand Down
4 changes: 2 additions & 2 deletions dali/test/python/test_dali_variable_batch_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def test_ops_image_custom_args():
(fn.preemphasis_filter, {}),
(fn.spectrogram, {'nfft': 60, 'window_length': 50, 'window_step': 25}),
(fn.to_decibels, {}),
(fn.experimental.audio_resample, {'devices': ['cpu'], 'scale': 1.2}),
(fn.audio_resample, {'devices': ['cpu'], 'scale': 1.2}),
]


Expand Down Expand Up @@ -1261,7 +1261,7 @@ def pipeline():
"random_bbox_crop",
"ssd_random_crop",
"optical_flow",
"experimental.audio_resample",
"audio_resample",
]

excluded_methods = [
Expand Down
4 changes: 2 additions & 2 deletions dali/test/python/test_eager_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def test_to_decibels():

def test_audio_resample():
get_data = GetData(audio_data)
check_single_input('experimental.audio_resample', fn_source=get_data.fn_source,
check_single_input('audio_resample', fn_source=get_data.fn_source,
eager_source=get_data.eager_source, layout=None, scale=1.25)


Expand Down Expand Up @@ -1138,7 +1138,7 @@ def test_batch_permutation():
'spectrogram',
'mel_filter_bank',
'to_decibels',
'experimental.audio_resample',
'audio_resample',
'mfcc',
'one_hot',
'transpose',
Expand Down
2 changes: 1 addition & 1 deletion dali/test/python/test_torch_pipeline_rnnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def rnnt_train_pipe(files,
# Speed perturbation 0.85x - 1.15x
if speed_perturb:
target_sr_factor = fn.random.uniform(device="cpu", range=(1 / 1.15, 1 / 0.85))
audio = fn.experimental.audio_resample(audio, scale=target_sr_factor)
audio = fn.audio_resample(audio, scale=target_sr_factor)

# Silence trimming
if silence_trim:
Expand Down