-
Notifications
You must be signed in to change notification settings - Fork 2.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
Make random number generator state a TH type #13
Conversation
* Style / naming needs work. * Breaks other layers within torch
…enerator if one isn't supplied when calling the function.
To test that the random number stream is identical after these changes, I ran this test with each version of torch. The output files are binary equal for the same seed.
|
hey, this is fantastic work, thank you for working on this. my only question is, before we pull this in, we make sure that there's no speed bottlenecks, if you could benchmark the RNG speed (from a single number, small tensor to huge tensors) over master branch vs your branch, we'd get an idea about speed. For example, benchmark torch.rand from 2-element tensors all the way to 200k. |
This patch is C89 compatible,
doesn't throw up any warnings. |
With these changes random number generation is ~5-10% slower. All times generated from an average over 2x10^9 random number generations. master: generator branch code:
|
Thanks for the thorough analysis :) I am waiting for the valgrind step then! |
valgrind is not showing any issues from this branch across torch.test() or nn.test(). |
Make random number generator state a TH type
Really great work, thanks a lot! |
Make random number generator state a TH type
State of the random number generator is moved from static data to a first-class type within TH: a THGenerator. These are then available within torch as a torch.Generator object. A default generator added in to the torch namespace when loading the package and used implicitly for any random functions.