You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionmy_func(x)
returnsin(x)
endusing ChainRulesCore
using AbstractDifferentiation: derivative, jacobian
using Diffractor: DiffractorForwardBackend, DiffractorRuleConfig
function ChainRulesCore.frule(config::RuleConfig{>:HasForwardsMode}, (_, dx), ::typeof(my_func), x)
res=my_func(x)
_, der_fwd = ChainRulesCore.frule_via_ad(config, (ChainRulesCore.NoTangent(), dx), sin, x)
@show"hello from fd with right config with calling back"return res, der_fwd
endfunctionmy_func2(x)
returnsin(x)
endfunction ChainRulesCore.frule((_, dx), ::typeof(my_func2), x)
res=my_func2(x)
_, der_fwd = ChainRulesCore.frule_via_ad(DiffractorRuleConfig(), (ChainRulesCore.NoTangent(), dx), sin, x)
@show"hello from fd with wrong config with calling back"return res, der_fwd
endderivative(DiffractorForwardBackend(), my_func, 1.0)
derivative(DiffractorForwardBackend(), my_func2, 1.0)
and I get the output just for the second call, in the first case the frule has something wrong. Is it supported this way of defining the rules for Diffractor.jl? Am I doing anything wrong?
The text was updated successfully, but these errors were encountered:
You are not, you are doing everything correct.
Its just that right now diffractor forward mode isn't using its config.
I am not sure why it was commented out.
See here: https://github.com/JuliaDiff/Diffractor.jl/blob/b3e4ee058ef0ae59bc5c7623ed6770b52b6324f2/src/stage1/forward.jl#L110C17-L110C37
Could be we can just uncomment it out and add a test and be good to go.
It might have just been commented out while investigating something and forgotten to undone.
Or it might be something more annoying like inference issues.
I have the following:
and I get the output just for the second call, in the first case the frule has something wrong. Is it supported this way of defining the rules for Diffractor.jl? Am I doing anything wrong?
The text was updated successfully, but these errors were encountered: