Skip to content

Conversation

@devmotion
Copy link
Member

This PR removes the dependency on the MuladdMacro package and instead explicitly adds muladd calls to the constructed expression.

The propagation expression is so "clean" with clearly define multiplications and additions that the muladd calls can easily be added manually instead of applying the @muladd macro that takes care of many special cases such as subtraction etc.

There is one catch to it: it seems currently the @muladd macro is applied to the full expression including the partials and therefore also rewrites the user-provided definitions whereas this manual construction only adds muladd calls to the products and sum of partials and input gradients.

@devmotion devmotion changed the title Replace with MuladdMacro with manual application of muladd Replace MuladdMacro with manual application of muladd Jan 6, 2021
@oxinabox oxinabox requested a review from YingboMa January 6, 2021 00:33
Copy link
Member

@YingboMa YingboMa left a comment

Choose a reason for hiding this comment

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

It looks good to me. Just need to change broadcasts into ntuples.

end
end
else
# Note: we don't want to do broadcasting with only 1 multiply (no `+`),
Copy link
Member

Choose a reason for hiding this comment

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

This comment is no longer true. Do you mind to delete it?

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, it might be better to actually do what is stated in the comment and to not apply broadcasting in this case. Somehow I missed the comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

I switched back to the old non-broadcasting behaviour in this case.

@devmotion
Copy link
Member Author

Since Travis tests don't run anymore and Github Action only runs with the latest Julia version (ref: #267), I checked locally that tests pass with Julia 1.0 and there are no problems with broadcasting *.

@oxinabox
Copy link
Member

oxinabox commented Jan 6, 2021

I have PRs open to get us to GHA, they are jsut a long way down my backlog :-(

@oxinabox
Copy link
Member

@devmotion can you give this a quick rebase so it gets the new CI and then we can merge?

@codecov-io
Copy link

codecov-io commented Jan 12, 2021

Codecov Report

Merging #272 (a9f5641) into master (f9f1766) will decrease coverage by 1.93%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #272      +/-   ##
==========================================
- Coverage   89.73%   87.79%   -1.94%     
==========================================
  Files          13       13              
  Lines         458      418      -40     
==========================================
- Hits          411      367      -44     
- Misses         47       51       +4     
Impacted Files Coverage Δ
src/ChainRulesCore.jl 100.00% <ø> (ø)
src/rule_definition_tools.jl 93.51% <100.00%> (-0.65%) ⬇️
src/differentials/one.jl 83.33% <0.00%> (-16.67%) ⬇️
src/differentials/thunks.jl 56.52% <0.00%> (-7.48%) ⬇️
src/ruleset_loading.jl 94.73% <0.00%> (-3.14%) ⬇️
src/differentials/composite.jl 79.61% <0.00%> (-2.69%) ⬇️
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 f9f1766...a9f5641. Read the comment docs.

@devmotion
Copy link
Member Author

I rebased the PR and updated docs/Manifest.toml since there was some problem with it after removing MuladdMacro.

@oxinabox
Copy link
Member

CI failing Ubuntu for Julia 1.0 is because for some reason that allocates less (unlike Mac or Windows). It is a unexpected pass.
Super weird, but not a problem. I am goign to just drop that @test_broken so that dones't block this PR

@oxinabox oxinabox merged commit 937981c into JuliaDiff:master Jan 12, 2021
@devmotion devmotion deleted the muladdmacro branch January 12, 2021 14:49
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