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

Add GPU variant of Spectrogram operator #1786

Merged
merged 2 commits into from
Mar 5, 2020

Conversation

mzient
Copy link
Contributor

@mzient mzient commented Mar 3, 2020

Add tests for GPU spectrogram op.
Extend tests for custom window functions.
Switch to GPU spectrogram in Jupyter example.

Signed-off-by: Michal Zientkiewicz michalz@nvidia.com

Why we need this PR?

Pick one, remove the rest

  • It exposed SpectrogramGPU as an operator

What happened in this PR?

Fill relevant points, put NA otherwise. Replace anything inside []

  • What solution was applied:
    • Implemented Impl class using SpectrogramGPU kernel
    • Added tests
    • Switched to GPU in Jupyter
  • Affected modules and functionalities:
    • Spectrogram operator
    • Jupyter
    • Spectrogram tests
  • Key points relevant for the review:
    • ?
  • Validation and testing:
    • Python tests
  • Documentation (including examples):
    • Jupyter updated; support chart should update automatically

JIRA TASK: DALI-1168 (followup)

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

You'll be able to see Jupyter notebook diff and discuss changes. Powered by ReviewNB.

Add tests for GPU spectrogram op.
Extend tests for custom window functions.
Switch to GPU spectrogram in Jupyter example.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@mzient
Copy link
Contributor Author

mzient commented Mar 3, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1165994]: BUILD STARTED

Copy link
Contributor

@JanuszL JanuszL left a comment

Choose a reason for hiding this comment

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

Doesn't GPU STFT kernel provides a build-in toDecibel conversion as well? How it is exposed here?

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1165994]: BUILD PASSED

@mzient
Copy link
Contributor Author

mzient commented Mar 4, 2020

Doesn't GPU STFT kernel provides a build-in toDecibel conversion as well? How it is exposed here?

The conversion to decibels requires a reference which, by default, is the maximum of the signal - we don't have min/max for GPU yet. When we do (which we'll have to to implement ToDecibels anyway), we can insert additional call to the max kernel in Spectrogram and enable this fusion at the operator level - it should be quite easy.

Copy link
Contributor

@jantonguirao jantonguirao left a comment

Choose a reason for hiding this comment

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

LGTM, except some minor comments

make_string("Invalid window length: ", args.window_length));
DALI_ENFORCE(args.window_step > 0, make_string("Invalid window step: ", args.window_step));
DALI_ENFORCE(args.window_length <= args.nfft,
make_string("`window_length` must not exceed ransform size (`nfft`). Got nfft = ", args.nfft,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
make_string("`window_length` must not exceed ransform size (`nfft`). Got nfft = ", args.nfft,
make_string("`window_length` must not exceed transform size (`nfft`). Got nfft = ", args.nfft,

auto &in = ws.InputRef<GPUBackend>(0);
KernelContext ctx;
ctx.gpu.stream = ws.stream();
auto in_shape = in.shape().to_static<1>();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add some validation of the input (e.g. number of dimensions) and give a meaningful error msg to the user if it is not as expected

ctx.gpu.stream = ws.stream();
auto in_shape = in.shape().to_static<1>();
auto req = kmgr.Setup<SpectrogramGPU>(0, ctx, in_shape, args);
CopyWindowToDevice(ctx.gpu.stream);
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just copying the window to the GPU during construction?

Copy link
Contributor Author

@mzient mzient Mar 4, 2020

Choose a reason for hiding this comment

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

I don't know if the device is properly set there - and I don't have a stream, so I'd have to resort to cudaDeviceSynchronize

@mzient
Copy link
Contributor Author

mzient commented Mar 4, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1168412]: BUILD STARTED

Added reshape function for TensorListView.
Fixed const-correctness in TensorListView construction with double pointer.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@mzient
Copy link
Contributor Author

mzient commented Mar 4, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1168436]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1168436]: BUILD PASSED

@mzient mzient merged commit 4735a26 into NVIDIA:master Mar 5, 2020
@mzient mzient deleted the SpectrogramOp_GPU branch March 27, 2020 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants