-
Notifications
You must be signed in to change notification settings - Fork 622
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
Add fn.experimental.audio_resample
GPU
#3911
Add fn.experimental.audio_resample
GPU
#3911
Conversation
fn.experimental.audio_resample
GPU
@@ -34,64 +34,76 @@ | |||
rates = [ 16000, 22050, 12347 ] | |||
lengths = [ 10000, 54321, 12345 ] | |||
|
|||
def create_test_files(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: nose was picking this as a test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making it "private" (with leading underscore) would help, too.
Signed-off-by: Michał Zientkiewicz <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
aeb5f2d
to
bd8212a
Compare
Signed-off-by: Michał Zientkiewicz <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
dali/operators/audio/resample.h
Outdated
@@ -144,7 +148,8 @@ class ResampleBase : public Operator<Backend> { | |||
ArgValue<float> scale_{"scale", spec_}; | |||
ArgValue<int64_t> out_length_{"out_length", spec_}; | |||
|
|||
std::vector<double> scales_; | |||
using Args = kernels::signal::resampling::Args; | |||
SmallVector<Args, 128> args_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plain vector will do just fine. Large SmallVectors (however weird that sounds) are better suited for temporary local buffers, where the difference between (frequent) stack allocation (free) and heap allocation (thousands of cycles) is of essence. Here, the vector will be reallocated a few times per operator lifetime at worst (typically it will be allocated just once) - and chances are, we'll still run over 128.
SmallVector<Args, 128> args_; | |
std::vector<Args> args_; |
Signed-off-by: Joaquin Anton <[email protected]>
Signed-off-by: Joaquin Anton <[email protected]>
fc49aae
to
7a0cc7a
Compare
Signed-off-by: Joaquin Anton <[email protected]>
4e08539
to
9409cc9
Compare
…u_op Signed-off-by: Joaquin Anton <[email protected]>
9409cc9
to
d76cd88
Compare
@@ -77,13 +77,12 @@ void ResamplerGPU<Out, In>::Run(KernelContext &context, const OutListGPU<Out> &o | |||
desc.out = out_sample.data; | |||
desc.window = window_gpu_; | |||
const auto &in_sh = in_sample.shape; | |||
const auto &out_sh = out_sample.shape; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this because it was seen as not-used in release builds (therefore a warning)
CI MESSAGE: [4879759]: BUILD STARTED |
CI MESSAGE: [4879843]: BUILD STARTED |
CI MESSAGE: [4879843]: BUILD FAILED |
CI MESSAGE: [4881910]: BUILD STARTED |
CI MESSAGE: [4881910]: BUILD PASSED |
@@ -1,4 +1,4 @@ | |||
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. | |||
# Copyright (c) 2020-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a separate PR?
70b6342
to
a5782b4
Compare
assert np.allclose(out.at(i), ref, 1e-6, eps) | ||
|
||
print("Diff: ", out_arr.astype(np.float) - ref) | ||
assert False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: the original code deliberately repeated the check here, so that the error in nosetests would appear as more than False
in non-verbose runs.
dali/operators/audio/resample.h
Outdated
args_[s].in_rate = 1.0; | ||
args_[s].out_rate = in_length ? 1.0 * out_length / in_length : 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
Now that we have args
, this would increase precision - we use the inverse scale in the kernel (in_rate/out_rate), so performing the other division here and reciprocal there will decrease (albeit very slightly) the precision.
args_[s].in_rate = 1.0; | |
args_[s].out_rate = in_length ? 1.0 * out_length / in_length : 0.0; | |
args_[s].in_rate = in_length ? in_length : 1; // avoid division by 0 | |
args_[s].out_rate = out_length ? out_length : 1; // avoid division by 0 |
Signed-off-by: Joaquin Anton <[email protected]>
4d9d2ae
to
23525bf
Compare
dali/operators/audio/resample.h
Outdated
@@ -125,7 +128,8 @@ class ResampleBase : public Operator<Backend> { | |||
DALI_FAIL(make_string("Cannot produce a non-empty signal from an empty input.\n" | |||
"Error at sample ", s)); | |||
} | |||
scales_[s] = in_length ? 1.0 * out_length / in_length : 0.0; | |||
args_[s].in_rate = in_length ? in_length : 1; // avoid division by 0 | |||
args_[s].out_rate = out_length ? out_length : 1; // avoid division by 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args_[s].out_rate = out_length ? out_length : 1; // avoid division by 0 | |
args_[s].out_rate = out_length ? out_length : 1; // avoid division by 0 |
the linter will complain
Signed-off-by: Joaquin Anton <[email protected]>
@@ -34,64 +34,73 @@ | |||
rates = [ 16000, 22050, 12347 ] | |||
lengths = [ 10000, 54321, 12345 ] | |||
|
|||
def create_test_files(): | |||
def create_files(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be another way, more verbose probably:
def create_files(): | |
from nose.tools import nottest | |
@nottest | |
def create_files(): |
!build |
CI MESSAGE: [4891719]: BUILD STARTED |
CI MESSAGE: [4891719]: BUILD PASSED |
Signed-off-by: Joaquin Anton <[email protected]>
Category:
New feature
Description:
fn.experimental.audio_resample
for the GPU backend.Additional information:
Affected modules and functionalities:
New Op
Key points relevant for the review:
Test correctness?
Checklist
Tests
Documentation
DALI team only
Requirements
REQ IDs: ARES.[01-08]
JIRA TASK: DALI-1445