-
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
Change SVD to use Composite
#157
Conversation
nickrobinson251
commented
Jan 20, 2020
•
edited
Loading
edited
- part of Update Cholesky and SVD to use Composite #151
- Very WIP
- Currently presumes we have Make getproperty on unset Composite properties return Zero(). ChainRulesCore.jl#107
Very excited for replacing |
when returning julia> extern(Zero()) ≈ zeros(2, 2)
ERROR: MethodError: no method matching isapprox(::Bool, ::Array{Float64,2})
Closest candidates are:
isapprox(::Missing, ::Any; kwargs...) at missing.jl:90
isapprox(::Any, ::Missing; kwargs...) at missing.jl:91
isapprox(::Number, ::Number; atol, rtol, nans) at floatfuncs.jl:274
...
Stacktrace:
[1] top-level scope at REPL[15]:1
julia> extern(Zero()) == zeros(2, 2)
false |
i guess i can just write the tests to account for this, i.e. compare element-wise, but the output on failure is less good: # now; where in practice we have `Zero` instead of `zeros(2, 2)`
julia> @test all(isapprox.(zeros(2, 2), ones(2, 2)))
Test Failed at REPL[34]:1
Expression: all(isapprox.(zeros(2, 2), ones(2, 2)))
ERROR: There was an error during testing
# before; better message but didn't work with `Zero` instead of `zeros(2, 2)`
julia> @test isapprox(zeros(2, 2), ones(2, 2))
Test Failed at REPL[35]:1
Expression: isapprox(zeros(2, 2), ones(2, 2))
Evaluated: isapprox([0.0 0.0; 0.0 0.0], [1.0 1.0; 1.0 1.0])
ERROR: There was an error during testing |
The current version of this PR is what it would look like if we extended various linear algebra function to handle (We do already extend This maybe leaves some optimizations still up for grabs, but it's a lot cleaner than naively checking |
What's up with is |
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 can't see anything to disagree with here.
Composite
ca618f8
to
8b01d44
Compare
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.
Other than the stuff commented this LGTM
# Deal with name clashes, by defining in this module which one we mean. | ||
const accumulate = ChainRulesCore.accumulate | ||
const accumulate! = ChainRulesCore.accumulate! | ||
using ChainRulesCore: AbstractZero |
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.
Remove mis-use of InplaceableThunk Move test utlitity to test_util file Use unthunk instead of extern Remove unnecessary thunking Extend LinearAlgebra to handle Zero Change NamedTuple to Composite in accumulate! test Use accumulate from ChainRulesCore #110 Clean-up TODOs Replace `accumulate` with `+` Update to use `AbstractZero` Co-Authored-By: Lyndon White <[email protected]> Add note about MulAddMacro Co-Authored-By: Lyndon White <[email protected]> Apply PR review suggestions
* Remove `store!`, `accumulate`, `accumulate!` * Remove `test_accumulate` functions
30c6d86
to
9bb6649
Compare