-
Notifications
You must be signed in to change notification settings - Fork 89
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
More restrictive @non_differentiable rand #263
Conversation
Why not just add:
?
It could also be added with varargs directly, without using the macro. |
Oh i was confused by the title. |
src/rulesets/Random/random.jl
Outdated
@non_differentiable rand(::Int, ::Int) | ||
@non_differentiable rand(::Int, ::Int, ::Int) | ||
@non_differentiable rand(::Int, ::Int, ::Int, ::Int) | ||
@non_differentiable rand(::Int, ::Int, ::Int, ::Int, ::Int) |
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 all the Int
should be Integer
to match:
[69] rand(X, d::Integer, dims::Integer...) in Random at /usr/local/src/julia/julia-1.5/usr/share/julia/stdlib/v1.5/Random/src/Random.jl:283
Can we add a test that makes sure |
I think we might also in particular want: @non_differentiable rand(::AbstractRNG, ::Random.Sampler)
@non_differentiable rand(::AbstractRNG, ::Tuple) |
Let me know what you think about my take on testing the new rules. I am really not sure if this is how it should be done. Especially because the |
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.
Nice.
A few suggestions,
once those are addressed and the version number bumped we can merge this and tag a release
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.
Just a couple of style things.
Once @oxinabox 's suggestions and these are attended to, please bump the patch version and we'll merge when tests pass :)
Thanks for the contribution -- it's much appreciated!
Great, thanks for the suggestions! I think the tests are failing because of something unrelated to this PR though... they also fail in #261 because of something |
Co-authored-by: willtebbutt <[email protected]>
Co-authored-by: Lyndon White <[email protected]>
Oh, yeah, don't worry about the Zygote integration tests -- Zygote master is currently broken. |
Actually, I am not sure about the comment on the test of the "differentiable" cases. |
Yes. |
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 am sorry, but I am a bit clueless how to test the rules on fields of a struct if they don't appear in the rand
function call... this is probably not how it should be done...
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 am going to add my suggestions and then if i didn't break CI merge this
Awesome, thank you! :) |
Addresses #262. I am really not sure if this is a good approach because there are quite a few different
rand
methods...This is what works with the use cases I have. What are the most common uses of
rand
that should be non-differentiable?