-
Notifications
You must be signed in to change notification settings - Fork 62
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
Let user specify Integer ->Float conversion type #628
Conversation
src/preferences.jl
Outdated
|
||
# Set it in our runtime values, as well as saving it to disk | ||
@set_preferences!("int2float" => int2float_type) | ||
@info("New int2float type set; restart your Julia session for this change to take effect!") |
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.
Maybe you know already, but one can set preferences before loading a package by specifying the package via its UUID.
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.
Thanks, I've used this in running the tests, anywhere else where this would be helpful?
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 scares me. So do most uses of preferences to be fair.
I can't see how this can be safely used.
If one package assumes one behavour and another another then it will error.
Julia provides a function, float
, to get the reference floating point type.
Though in most cases it is the chainrules conception to refuse to deal with integers.
because they represent discrete quantities.
And we treat types as having semantic meaning, not merely for computation convieience.
(See also how we treat structurally sparse array types. We don't let their derivatives have nonzeros in the wrong places)
I would have expected
ProjectTo(1)(2.0f0) === NoTangent()
@oxinabox Agree, the more I work on this PR, the less I like it. I've opened a new one with only the added tests, so at least the behavior is documented... |
Superseded by #629 |
Based on these related issues: FluxML/Flux.jl#2305, FluxML/Zygote.jl#1445, JuliaGPU/GPUArrays.jl#484
it seems like it might be useful to have a bit more control over whether
Int
projections are mapped toFloat64
or anotherAbstractFloat
subtype. While this might be possible via overloading, it would be nice to know that one hasn't broken anyChanRulesCore.jl
functionality by overloading the method. Especially for working with GPUs, greedy type conversion toFloat64
seems to be problematic.This PR introduces a local user preference
int2float
via which aFloat
type can be specified. I have also adjusted the tests so that they can be run with different preference settings.The problem which this PR solves, in a nutshell:
Disclaimer I'm new to this package and imagine that this may be the wrong way to fix the problem, so please don't hesitate to close this PR if I've missed something.