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

Port a few rules from Diffractor #463

Merged
merged 16 commits into from
Jul 30, 2021

Conversation

Keno
Copy link
Contributor

@Keno Keno commented Jul 1, 2021

No description provided.

Copy link
Member

@simeonschaub simeonschaub left a comment

Choose a reason for hiding this comment

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

Some small style nits, but otherwise LGTM.

src/rulesets/Core/core.jl Outdated Show resolved Hide resolved
src/rulesets/Core/core.jl Outdated Show resolved Hide resolved
src/rulesets/Core/core.jl Outdated Show resolved Hide resolved
src/rulesets/Core/core.jl Outdated Show resolved Hide resolved
test/rulesets/Core/core.jl Outdated Show resolved Hide resolved
@@ -98,27 +98,31 @@ end
Adjoint_mat_pullback(ȳ::Tangent) = (NoTangent(), ȳ.parent)
Adjoint_mat_pullback(ȳ::AbstractVecOrMat) = (NoTangent(), adjoint(ȳ))
Adjoint_mat_pullback(ȳ::AbstractThunk) = return Adjoint_mat_pullback(unthunk(ȳ))
Adjoint_mat_pullback(ȳ::AbstractZero) = (NoTangent(), ȳ)
Copy link
Member

@mzgubic mzgubic Jul 2, 2021

Choose a reason for hiding this comment

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

Just an FYI: we are considering handling this at the AD level, see: #442 (comment)

But that is currently blocked by ProjectTo PR which I am working on at the moment.

Copy link
Member

Choose a reason for hiding this comment

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

Should these lines be removed before this is merged? Or commented # remove me once X?

Copy link
Member

Choose a reason for hiding this comment

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

Ideally removed, but it needs Diffractor to automatically propagate AbstractZeros, something like Zygote's https://github.com/FluxML/Zygote.jl/blob/5b803d12f2d235755ba6f23a9017fc29fefd9985/src/compiler/chainrules.jl#L143

If Diffractor does not do that, we should make an issue about it (and link it here)

Copy link
Member

Choose a reason for hiding this comment

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

So is it fine to leave this in or should I just remove that part for now?

Copy link
Member

@mzgubic mzgubic Jul 30, 2021

Choose a reason for hiding this comment

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

Yeah let's keep them in to make sure it all works for Diffractor and just link this: JuliaDiff/Diffractor.jl#25.
We can revisit when the issue above is solved

src/rulesets/Base/array.jl Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2021

Codecov Report

Merging #463 (998846f) into master (3f18cd6) will decrease coverage by 0.33%.
The diff coverage is 57.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #463      +/-   ##
==========================================
- Coverage   98.38%   98.04%   -0.34%     
==========================================
  Files          21       22       +1     
  Lines        2287     2306      +19     
==========================================
+ Hits         2250     2261      +11     
- Misses         37       45       +8     
Impacted Files Coverage Δ
src/rulesets/Base/nondiff.jl 66.66% <ø> (ø)
src/rulesets/LinearAlgebra/structured.jl 94.00% <0.00%> (-5.30%) ⬇️
src/rulesets/Core/core.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f18cd6...998846f. Read the comment docs.

Copy link
Member

@mzgubic mzgubic left a comment

Choose a reason for hiding this comment

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

Thanks, looks good! Feel free to merge when the style comments are addressed

test/rulesets/Core/core.jl Outdated Show resolved Hide resolved
test/rulesets/Core/core.jl Outdated Show resolved Hide resolved
Comment on lines 465 to 471
@non_differentiable similar(::Any...)
@non_differentiable eltype(::Type)

@non_differentiable one(::Any)
@non_differentiable ones(::Any...)
@non_differentiable zero(::Any)
@non_differentiable zeros(::Any...)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@non_differentiable similar(::Any...)
@non_differentiable eltype(::Type)
@non_differentiable one(::Any)
@non_differentiable ones(::Any...)
@non_differentiable zero(::Any)
@non_differentiable zeros(::Any...)
@non_differentiable eltype(::Type)

could we also move the eltype to the right place alphabetically?

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean

Suggested change
@non_differentiable similar(::Any...)
@non_differentiable eltype(::Type)
@non_differentiable one(::Any)
@non_differentiable ones(::Any...)
@non_differentiable zero(::Any)
@non_differentiable zeros(::Any...)
@non_differentiable eltype(::Type)
@non_differentiable similar(::Any...)
@non_differentiable one(::Any)
@non_differentiable ones(::Any...)
@non_differentiable zero(::Any)
@non_differentiable zeros(::Any...)

?

Copy link
Member

Choose a reason for hiding this comment

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

No, sorry, I did mean to delete the others, since they are already in base.jl on master, see e.g.

@non_differentiable one(::Any)

julia> @which ones
Base

Copy link
Member

Choose a reason for hiding this comment

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

actually eltype also seems to belong to Base

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, I misunderstood. eltype should still be in Base/nondiff.jl though, right?

Copy link
Member

Choose a reason for hiding this comment

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

Correct! My bad, forgot that Base/base.jl exists 😄

Project.toml Outdated Show resolved Hide resolved
Co-authored-by: Miha Zgubic <mzgubic@users.noreply.github.com>
@simeonschaub simeonschaub merged commit cf55350 into JuliaDiff:master Jul 30, 2021
@simeonschaub simeonschaub removed the needs version bump Version needs to be incremented or set to -DEV in Project.toml label Jul 30, 2021
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.

5 participants