-
Notifications
You must be signed in to change notification settings - Fork 64
make creation of inputs to propagation consistently hyginic #276
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 all commits
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 |
|---|---|---|
|
|
@@ -142,7 +142,7 @@ function scalar_frule_expr(f, call, setup_stmts, inputs, partials) | |
|
|
||
| # Δs is the input to the propagator rule | ||
| # because this is push-forward there is one per input to the function | ||
| Δs = [esc(Symbol(:Δ, i)) for i in 1:n_inputs] | ||
| Δs = _propagator_inputs(n_inputs) | ||
| pushforward_returns = map(1:n_outputs) do output_i | ||
| ∂s = partials[output_i].args | ||
| propagation_expr(Δs, ∂s) | ||
|
|
@@ -173,7 +173,7 @@ function scalar_rrule_expr(f, call, setup_stmts, inputs, partials) | |
|
|
||
| # Δs is the input to the propagator rule | ||
| # because this is a pull-back there is one per output of function | ||
| Δs = [Symbol(:Δ, i) for i in 1:n_outputs] | ||
| Δs = _propagator_inputs(n_outputs) | ||
|
|
||
| # 1 partial derivative per input | ||
| pullback_returns = map(1:n_inputs) do input_i | ||
|
|
@@ -198,6 +198,11 @@ function scalar_rrule_expr(f, call, setup_stmts, inputs, partials) | |
| end | ||
| end | ||
|
|
||
| # For context on why this is important, see | ||
| # https://github.com/JuliaDiff/ChainRulesCore.jl/pull/276 | ||
| "Declares properly hygenic inputs for propagation expressions" | ||
| _propagator_inputs(n) = [esc(gensym(Symbol(:Δ, i))) for i in 1:n] | ||
|
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. Why do we need the
Member
Author
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.
So just incase the person had named a variable using
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. ah yes thanks |
||
|
|
||
| """ | ||
| propagation_expr(Δs, ∂s, _conj = false) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.