-
Notifications
You must be signed in to change notification settings - Fork 40
Remove Zygote dependency and update documentation for ForwardDiff integration #393
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
Changes from 6 commits
160d289
990da50
502952d
218aab9
fd7260c
ba1bf9c
3ccd657
2d2d684
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,6 @@ jobs: | |
| - Mooncake | ||
| - Tracker | ||
| - ReverseDiff | ||
| - Zygote | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,5 +286,48 @@ function ChainRulesCore.rrule(::typeof(pd_from_upper), X::AbstractMatrix) | |
| end | ||
| end | ||
|
|
||
| # Fixes Zygote's issues with `@debug` | ||
| # Fixes AD issues with `@debug` | ||
| ChainRulesCore.@non_differentiable _debug(::Any) | ||
|
Comment on lines
+289
to
290
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know if this is still needed? Does some other AD backend rely on this? |
||
|
|
||
yebai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # ChainRules for utility functions used by PlanarLayer | ||
|
||
| function ChainRulesCore.rrule(::typeof(aT_b), a::AbstractVector, b::AbstractMatrix) | ||
| y = aT_b(a, b) | ||
| function aT_b_pullback(Δy) | ||
| # For y = a' * b, we have: | ||
| # ∂y/∂a = b * Δy (since y is 1×n and a is m×1) | ||
| # ∂y/∂b = a * Δy (since y is 1×n and b is m×n) | ||
| Δa = b * vec(Δy) | ||
| Δb = a * Δy | ||
| return ChainRulesCore.NoTangent(), Δa, Δb | ||
| end | ||
| return y, aT_b_pullback | ||
| end | ||
|
|
||
| function ChainRulesCore.rrule(::typeof(aT_b), a::AbstractVector, b::AbstractVector) | ||
| y = aT_b(a, b) | ||
| function aT_b_pullback(Δy) | ||
| # For y = dot(a, b), we have: | ||
| # ∂y/∂a = b * Δy | ||
| # ∂y/∂b = a * Δy | ||
| return ChainRulesCore.NoTangent(), b * Δy, a * Δy | ||
| end | ||
| return y, aT_b_pullback | ||
| end | ||
|
|
||
| function ChainRulesCore.rrule(::typeof(_vec), x::AbstractArray) | ||
| y = _vec(x) | ||
| function _vec_pullback(Δy) | ||
| # Reshape the gradient back to the original shape | ||
| Δx = reshape(Δy, size(x)) | ||
| return ChainRulesCore.NoTangent(), Δx | ||
| end | ||
| return y, _vec_pullback | ||
| end | ||
|
|
||
| function ChainRulesCore.rrule(::typeof(_vec), x::Real) | ||
| y = _vec(x) | ||
| function _vec_pullback(Δy) | ||
| return ChainRulesCore.NoTangent(), Δy | ||
| end | ||
| return y, _vec_pullback | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.