-
Notifications
You must be signed in to change notification settings - Fork 120
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
Use torch.searchsorted instead of our ad-hoc implementation #19
Comments
Hi Joe, Indeed, our
Hope this makes sense. In terms of next steps, now that Thanks, Artur |
For future reference: #9 has been merged which is also using a feature that is only available in PyTorch 1.6 (non-persistent buffers). |
torch.searchsorted
instead of our ad-hoc implementation
torch.searchsorted
instead of our ad-hoc implementation
Hi!
I compared the
searchsorted
function implemented here, that doestorch.sum(inputs[..., None] >= bin_locations, dim=-1) - 1
, with the implementation in C++ here -- https://github.com/aliutkus/torchsearchsorted -- and it appears to be a lot slower on CPU at least.I modified the
benchmark.py
in torchsearchsorted and just copy-pasted the function from nflows for comparison.The output was (all on CPU)
i.e. sorting 5000 inputs into 5000 individual sets of 16 bins.
Am I missing something here? If not, it looks like the spline flows could be sped up quite a bit by using torchsearchsorted or something similar?
Cheers.
The text was updated successfully, but these errors were encountered: