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

[WIP] Replace Zygote adjoints with ChainRules' rrules #153

Closed
wants to merge 4 commits into from

Conversation

sharanry
Copy link
Contributor

@sharanry sharanry commented Aug 13, 2020

#116 (comment)

Currently a lot of AD tests fail. Still need to work on revamping the AD tests to use ChainRulesTestUtils.jl.

TODO

  • Use rrule_test for each of the rrules. Plain usage of them results in errors with FiniteDifferences. Figure of if this is due to the incorrect rrules.
  • test/utils.jl seems pass with minimal imports but fail other wise. Figure out why.

src/chainrules.jl Outdated Show resolved Hide resolved
src/chainrules.jl Outdated Show resolved Hide resolved
src/chainrules.jl Outdated Show resolved Hide resolved
src/chainrules.jl Outdated Show resolved Hide resolved
src/chainrules.jl Outdated Show resolved Hide resolved
src/chainrules.jl Outdated Show resolved Hide resolved
src/chainrules.jl Outdated Show resolved Hide resolved
src/chainrules.jl Outdated Show resolved Hide resolved
src/chainrules.jl Outdated Show resolved Hide resolved
src/chainrules.jl Outdated Show resolved Hide resolved
Comment on lines 74 to 80
function ChainRulesCore.rrule(::typeof(ColVecs), X::AbstractMatrix)
return ColVecs(X), vecs_pullback
end

function ChainRulesCore.rrule(::typeof(RowVecs), X::AbstractMatrix)
return RowVecs(X), vecs_pullback
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willtebbutt How do we go about defining rrules for constructors?

For example, here typeof(ColVecs) results in UnionAll which is probably not what we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to replace typeof(ColVecs) with Type{ColVecs}?

@devmotion
Copy link
Member

Maybe JuliaDiff/ChainRulesCore.jl#150 could simplify some definitions?

Copy link
Member

@willtebbutt willtebbutt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. Just needs to use the tests in ChainRulesCore -- you might need to define to_vec for a few things, but that's about it.

throw(error("In slow method"))
end

function ChainRulesCore.rrule(::Type{ColVecs}, X::AbstractMatrix)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the right thing to do here would be ::Type{<:ColVecs}, would it not?

return ColVecs(X), vecs_pullback
end

function ChainRulesCore.rrule(::Type{RowVecs}, X::AbstractMatrix)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here?

@theogf
Copy link
Member

theogf commented Mar 25, 2021

Replaced by #208

@theogf theogf closed this Mar 25, 2021
@yebai yebai deleted the sharan/chainrules branch January 13, 2023 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants