Skip to content

support functors in at-non_differentiable#298

Merged
simeonschaub merged 5 commits intomasterfrom
sds/nondiff_functors
Feb 12, 2021
Merged

support functors in at-non_differentiable#298
simeonschaub merged 5 commits intomasterfrom
sds/nondiff_functors

Conversation

@simeonschaub
Copy link
Copy Markdown
Member

No description provided.

:function,
Expr(:call, propagator_name(primal_name, :pullback), :_),
Expr(:tuple, NO_FIELDS, Expr(:(...), tup_expr))
Expr(:tuple, isfunctor ? DoesNotExist() : NO_FIELDS, Expr(:(...), tup_expr))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ratherr than passing in isfunctor to do this in the macro defintition
could we do something in the body that compiles away like check T<:Function && fieldcount(T) == 0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think that check would work well for types, since e.g. DataTypes do have fields, but we don't care about the fields for the purposes of Zygote.
Of course, we could also just always return DoesNotExist() here, so @non_differentiable would just always imply that the function argument has no well-defined derivative, where it's not really important whether it actually has fields or not.

Copy link
Copy Markdown
Member

@oxinabox oxinabox Feb 8, 2021

Choose a reason for hiding this comment

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

Yeah, we could just return DoesNotExist for all.
Things without fields are not pertubable so DoesNotExist is not invalid for them.
(Zero is also valid since there is no errror for perturrbing them since it is impossible to pertube them)
I think i would be down with that change.

I don't think it would be breaking since nothing checks types of AbstractZero, just that that are zero.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We do technically document that the derivative for the primal itself is NO_FIELDS, but I agree with your assessment that it's unlikely to break any actual code. Would you say that's still fine for a patch release?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@oxinabox patch is fine right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bump. Since this is holding up JuliaDiff/ChainRules.jl#358

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am pretty sure it is fine

Copy link
Copy Markdown
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 for the PR, looks good to me. Some minor style comments added.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Feb 9, 2021

Codecov Report

Merging #298 (42091e2) into master (0726513) will decrease coverage by 1.51%.
The diff coverage is 90.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #298      +/-   ##
==========================================
- Coverage   89.39%   87.87%   -1.52%     
==========================================
  Files          13       13              
  Lines         462      429      -33     
==========================================
- Hits          413      377      -36     
- Misses         49       52       +3     
Impacted Files Coverage Δ
src/rule_definition_tools.jl 93.22% <90.00%> (-1.09%) ⬇️
src/differentials/thunks.jl 56.52% <0.00%> (-7.48%) ⬇️
src/differentials/composite.jl 79.80% <0.00%> (-2.65%) ⬇️
src/ruleset_loading.jl 94.73% <0.00%> (-1.01%) ⬇️
src/accumulation.jl 96.66% <0.00%> (-0.40%) ⬇️
src/differentials/abstract_zero.jl 93.75% <0.00%> (-0.37%) ⬇️
src/differential_arithmetic.jl 96.15% <0.00%> (-0.10%) ⬇️

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 0726513...42091e2. Read the comment docs.

simeonschaub added a commit to JuliaDiff/ChainRules.jl that referenced this pull request Feb 12, 2021
simeonschaub added a commit to JuliaDiff/ChainRules.jl that referenced this pull request Feb 12, 2021
simeonschaub added a commit to JuliaDiff/ChainRules.jl that referenced this pull request Feb 12, 2021
@simeonschaub simeonschaub merged commit f81ccda into master Feb 12, 2021
@simeonschaub simeonschaub deleted the sds/nondiff_functors branch February 12, 2021 22:59
simeonschaub added a commit to JuliaDiff/ChainRules.jl that referenced this pull request Feb 13, 2021
* fix tests for JuliaDiff/ChainRulesCore.jl#298

* Apply suggestions from code review

Co-authored-by: Lyndon White <oxinabox@ucc.asn.au>

Co-authored-by: Lyndon White <oxinabox@ucc.asn.au>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs version bump rule definition helper relating to helpers for declaring rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants