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

Update kwargs fallback rules after RuleConfig rewrite #372

Merged
merged 4 commits into from
Jun 18, 2021

Conversation

Keno
Copy link
Contributor

@Keno Keno commented Jun 18, 2021

Fixes #368

@codecov-commenter
Copy link

codecov-commenter commented Jun 18, 2021

Codecov Report

Merging #372 (a2e266b) into master (bf01ddf) will increase coverage by 0.59%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #372      +/-   ##
==========================================
+ Coverage   88.86%   89.46%   +0.59%     
==========================================
  Files          14       14              
  Lines         485      560      +75     
==========================================
+ Hits          431      501      +70     
- Misses         54       59       +5     
Impacted Files Coverage Δ
src/rule_definition_tools.jl 96.89% <ø> (ø)
src/rules.jl 100.00% <100.00%> (ø)
src/differentials/abstract_zero.jl 86.66% <0.00%> (-6.20%) ⬇️
src/differentials/thunks.jl 93.75% <0.00%> (+1.15%) ⬆️

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 bf01ddf...a2e266b. Read the comment docs.

@Keno Keno force-pushed the kf/updatespecialrules branch 2 times, most recently from d64e504 to dc52994 Compare June 18, 2021 04:16
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.

Probably good if @oxinabox takes a look as well, but i can't see anything wrong so approving

src/rules.jl Outdated
@@ -58,10 +58,25 @@ will be hit as a fallback. This is the case for most rules.

See also: [`rrule`](@ref), [`@scalar_rule`](@ref), [`RuleConfig`](@ref)
"""
frule(::Any, ::Any, ::Vararg{Any}; kwargs...) = nothing
frule(::Any, ::Any, ::Vararg{Any}) = nothing
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we don't just do

Suggested change
frule(::Any, ::Any, ::Vararg{Any}) = nothing
frule(::Vararg{Any}) = nothing

?

Copy link
Member

Choose a reason for hiding this comment

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

yes, we require at least 2 arguments.
The minimum number of arguments a function can have is zero.
Which has the case frule(Tuple(), f).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Either way is fine. The system doesn't care, but this makes it explicit that at least two arguments are expected, so you get a method error otherwise. I guess by the same reasoning, I should put back the two arguments below.

src/rules.jl Outdated
# still has to manually analyze). Manually declare this method with an
# explicitly empty body to save the compiler that work.
const frule_kwfunc = Core.kwftype(typeof(frule)).instance
(::typeof(frule_kwfunc))(::Any, ::typeof(frule), ::Any, ::Vararg{Any}) = nothing
Copy link
Member

Choose a reason for hiding this comment

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

I guess either having the two Anys

Suggested change
(::typeof(frule_kwfunc))(::Any, ::typeof(frule), ::Any, ::Vararg{Any}) = nothing
(::typeof(frule_kwfunc))(::Any, ::typeof(frule), ::Any, ::Any, ::Vararg{Any}) = nothing

or pack them all into Vararg

Suggested change
(::typeof(frule_kwfunc))(::Any, ::typeof(frule), ::Any, ::Vararg{Any}) = nothing
(::typeof(frule_kwfunc))(::Any, ::typeof(frule), ::Vararg{Any}) = nothing

right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, let me make it consistent.

@Keno Keno force-pushed the kf/updatespecialrules branch from dc52994 to 7c40e72 Compare June 18, 2021 21:25
src/rules.jl Outdated Show resolved Hide resolved
@oxinabox oxinabox merged commit 4550d7e into JuliaDiff:master Jun 18, 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.

Special kwarg function for rrule with RuleConfig
4 participants