Skip to content
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

Correct chainrules for abs2, abs, conj and angle #196

Merged
merged 34 commits into from
Jun 28, 2020
Merged
Changes from 2 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6101dfa
restrict abs2 to ::Real
MasonProtter May 20, 2020
70f3f94
add Seth's frules
MasonProtter May 23, 2020
40ccb2b
Update src/rulesets/Base/fastmath_able.jl
MasonProtter May 23, 2020
b653379
Update src/rulesets/Base/fastmath_able.jl
MasonProtter May 23, 2020
4f7bd85
updates
MasonProtter May 27, 2020
be7c008
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 1, 2020
78578f3
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 1, 2020
abb15e0
don't test conj and angle on complex inputs (yet)
MasonProtter Jun 1, 2020
9cf260c
put in missing factor of two
MasonProtter Jun 23, 2020
98f0c73
drop incorrect conj
MasonProtter Jun 23, 2020
33f7b1f
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 23, 2020
9fe148d
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 23, 2020
9f4344e
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 23, 2020
a83cd0f
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 23, 2020
81862c0
Merge github.com:JuliaDiff/ChainRules.jl into patch-1
MasonProtter Jun 23, 2020
f8de55a
fix testing for abs and abs2 (still needs a refactor)
MasonProtter Jun 23, 2020
5c1b65b
test fastmath versions as well
MasonProtter Jun 23, 2020
250c22e
add rules for conj and angle
MasonProtter Jun 23, 2020
2f74b6a
fixes and cleanup
MasonProtter Jun 24, 2020
538c798
testing fixes
MasonProtter Jun 24, 2020
8bfefd2
testing fixes again
MasonProtter Jun 24, 2020
66e312d
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 25, 2020
49cf303
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 25, 2020
9706f91
use subgradient convention and special-case angle for reals
MasonProtter Jun 26, 2020
546ad0b
remove extra code that wasn't needed
MasonProtter Jun 26, 2020
761fbd1
consolidate abs2 rrules
MasonProtter Jun 26, 2020
de13870
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 26, 2020
16518ec
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 26, 2020
be2bf11
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 26, 2020
f2d5f86
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 26, 2020
d531bb9
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 26, 2020
860d7f8
Update src/rulesets/Base/fastmath_able.jl
MasonProtter Jun 26, 2020
ec18a77
increment version
MasonProtter Jun 27, 2020
50cc4ce
Merge branch 'patch-1' of github.com:MasonProtter/ChainRules.jl into …
MasonProtter Jun 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/rulesets/Base/fastmath_able.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ let

# Unary complex functions
@scalar_rule abs(x::Real) sign(x)
@scalar_rule abs2(x) 2x
@scalar_rule abs2(x::Real) 2x
@scalar_rule angle(x::Real) Zero()
@scalar_rule conj(x::Real) One()
function frule((Δx,), abs, x::ComplexF64)
MasonProtter marked this conversation as resolved.
Show resolved Hide resolved
Ω = abs(x)
return Ω, (real(x) * real(Δx) + imag(x) * imag(Δx)) / Ω
end
function frule((Δx,), abs2, x::ComplexF64)
MasonProtter marked this conversation as resolved.
Show resolved Hide resolved
return abs2(x), 2 * (real(x) * real(Δx) + imag(x) * imag(Δx))
end

# Binary functions
@scalar_rule hypot(x::Real, y::Real) (x / Ω, y / Ω)
Expand Down