-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add Fastmath operators #388
Conversation
src/lib/number.jl
Outdated
|
||
fastf = fast_op[f] | ||
|
||
if unarydx != nothing |
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 seems like a strange way to write it. Why not just test hasdiffrule
directly here?
src/lib/number.jl
Outdated
|
||
DiffRules._abs_deriv(x::Complex) = x/abs(x) | ||
fastmath() |
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.
Why split this out rather than using a top-level loop as above?
This is very useful, thanks! There are quite a few whitespace changes unrelated to the main issue being fixed. While many are useful it would be better to have them as a separate PR, to make review easier. |
I have updated the code with given suggestions |
src/lib/number.jl
Outdated
|
||
# Function add adjoint for Fastmath operations | ||
# DiffRules is used to find derivatives for each operation | ||
for f in keys(fast_op) |
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.
for f in keys(fast_op) | |
for (f, fastf) in fast_op |
👍 Thanks! bors r+ |
388: Add Fastmath operators r=MikeInnes a=Satya758 Fixes issue #90 1. Basic idea is to apply @adjoint macro to all defined fastmath operators. 2. This is done by looping over fastmath [operators](https://github.com/JuliaLang/julia/blob/master/base/fastmath.jl#L31) and then retrieving defined differentiation expression for each from [DiffRules](https://github.com/JuliaDiff/DiffRules.jl/blob/master/src/rules.jl). 3. Using differentiation expression create adjoint function simillar to https://github.com/FluxML/Zygote.jl/blob/master/src/lib/number.jl#L7 I have added bunch of test cases covering unary and binary operators treating normal operators as a expected value. Co-authored-by: Satya <satyap.kommaraju@gmail.com>
Build succeeded |
Fixes issue #90
I have added bunch of test cases covering unary and binary operators treating normal operators as a expected value.