dfdx / Yota.jl

Reverse-mode automatic differentiation in Julia
MIT License
158 stars 12 forks source link

Better type stability and constprop for getfield+getproperty rules #133

Open ToucheSir opened 1 year ago

ToucheSir commented 1 year ago

Found while trying to optimize the performance of https://github.com/jeremiedb/ADTests.jl/blob/main/experiments/yota/dense.jl. The @constprop :aggressive incantation is what Diffractor uses in its getproperty rule. It should be supported back to Julia 1.7 through Compat.jl.

I've also taken the liberty to improve type stability for a couple of rules. Future work could improve this further by considering Tuples and NamedTuples as natural tangents of themselves, thus removing the need to wrap in Tangent.

codecov-commenter commented 1 year ago

Codecov Report

Base: 81.70% // Head: 81.46% // Decreases project coverage by -0.25% :warning:

Coverage data is based on head (1548631) compared to base (b9ae446). Patch coverage: 92.30% of modified lines in pull request are covered.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #133 +/- ## ========================================== - Coverage 81.70% 81.46% -0.25% ========================================== Files 8 8 Lines 492 491 -1 ========================================== - Hits 402 400 -2 - Misses 90 91 +1 ``` | [Impacted Files](https://codecov.io/gh/dfdx/Yota.jl/pull/133?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrei+Zhabinski) | Coverage Δ | | |---|---|---| | [src/rulesets.jl](https://codecov.io/gh/dfdx/Yota.jl/pull/133?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrei+Zhabinski#diff-c3JjL3J1bGVzZXRzLmps) | `96.69% <92.30%> (ø)` | | | [src/grad.jl](https://codecov.io/gh/dfdx/Yota.jl/pull/133?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrei+Zhabinski#diff-c3JjL2dyYWQuamw=) | `89.75% <0.00%> (-0.61%)` | :arrow_down: | | [src/chainrules.jl](https://codecov.io/gh/dfdx/Yota.jl/pull/133?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrei+Zhabinski#diff-c3JjL2NoYWlucnVsZXMuamw=) | `96.61% <0.00%> (-0.06%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrei+Zhabinski). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrei+Zhabinski)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.