-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Reimplement Kaiser window #87330
Reimplement Kaiser window #87330
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/87330
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 38550c5: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@mruberry @lezcano I'm getting this lint error. >>> Lint for torch/__init__.py:
Error (MYPY) [no-redef]
Name "kaiser_window" already defined (possibly by an import)
874 |
875 |# Importing alias functions due to backward compatibility.
876 |# Link to a detailed conversation: https://github.com/pytorch/pytorch/pull/87082
>>> 877 |from torch._windows import kaiser_window
878 |
879 |# Quantized, sparse, AO, etc. should be last to get imported, as nothing
880 |# is expected to depend on them. I feel like we need to somehow stop generating the Python bindings for the C++ implementation for this warning to get solved. Additionally, I also feel like we should remove this block as it has old documentation and doesn't really add anything. We're doing the alias to a different implementation; at the moment it gets overridden by the alias function's docstring. Lines 12723 to 12765 in c9b6184
One last question. What should I do next? I got lost a little bit in the previous conversation about what to do with the C++ implementations, the PrimTorch, and the |
You can stop PyTorch from generating bindings by adding a |
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.
This looks great; I would just leave torch.kaiser_window
as-is for the moment and focus on the development of torch.signal.windows
. (That thought goes for the development of additional windows, too). I made some small inline comments about torch.signal.windows.kaiser
for your review.
We can review aligning the existing torch
windowing operations with torch.signal.windows
later.
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.
@mruberry addressed a couple of your comments with additional comments 😛
This comment was marked as resolved.
This comment was marked as resolved.
I did mention we may want to update the C++ implementations, but I think it's alright to leave them as they are for now, so that we don't generate unnecessary extra work. |
@lezcano I tried using |
8254bc7
to
9a9a231
Compare
9a9a231
to
035b5f6
Compare
follow up PR LGTM! |
torch/signal/windows/windows.py
Outdated
if M == 1: | ||
return torch.ones((1,), dtype=dtype, layout=layout, device=device, requires_grad=requires_grad) | ||
|
||
if beta <= 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.
check for beta should go before returning the wrong value for M=1
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.
What's interesting is that SciPy does not require a positive beta:
scipy.signal.windows.kaiser(1, beta=-5)
: array([1.])
scipy.signal.windows.kaiser(10, beta=-5.)
: array([0.03671089, 0.20127873, 0.47552746, 0.7753221 , 0.97273069,
0.97273069, 0.7753221 , 0.47552746, 0.20127873, 0.03671089])
The wikipedia entry stipulates that beta should be non-negative, but not strictly positive: https://en.wikipedia.org/wiki/Kaiser_window
So, follow-up questions:
- why are we requiring a positive beta?
- should the documentation discuss this requirement?
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.
Sure, let's make it non-negative. Definition includes I0(beta) and I0 is not defined for negative args (and there's no alternative definition for 1), so looks like scipy is wrong.
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.
Agreed with @ngimel. I'll turn that precheck into a non-negative one, and I'll move it up as well.
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.
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.
yup. Feel free to add it to this PR if oyu want.
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'll do it in #87082
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.
Agreed with @ngimel. I'll turn that precheck into a non-negative one, and I'll move it up as well.
But why not just allow negative betas, too?
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.
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 understand, just interesting that SciPy allows them
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.
Leaving aside a small point I left and Natalia's valid point, this LGTM. Let's see what Mike has to say though.
As always, thank you for doing all this ground work!
- Make the precheck non-negative. - Call fewer kernels by adding beta in the construction of k
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.
See one suggestion about mentioning non-negative requirement for beta in the documentation, otherwise LGTM! Thanks @alvgaona
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Hey @alvgaona. |
Relates to pytorch#85366 - For reference follow pytorch#87082. Pull Request resolved: pytorch#87330 Approved by: https://github.com/lezcano, https://github.com/mruberry
Relates to pytorch#85366 - For reference follow pytorch#87082. Pull Request resolved: pytorch#87330 Approved by: https://github.com/lezcano, https://github.com/mruberry
Relates to pytorch#85366 - For reference follow pytorch#87082. Pull Request resolved: pytorch#87330 Approved by: https://github.com/lezcano, https://github.com/mruberry
Relates to #85366