JuliaDiff / ChainRulesCore.jl

AD-backend agnostic system defining custom forward and reverse mode rules. This is the light weight core to allow you to define rules for your functions in your packages, without depending on any particular AD system.
Other
254 stars 62 forks source link

Composite clarification #221

Open mzgubic opened 4 years ago

mzgubic commented 4 years ago

The docs say that Composite users should disregard the T parameter as it is an implementation detail.

However both ChainRules and Zygote do not always follow this recommendation.

There is a difference between the two constructors and it is not clear when to apply which one. Perhaps a comment could be added to the docs?

julia> xt = (1, 2)
(1, 2)

julia> ct1 = Composite{Any, typeof(xt)}(xt)
Composite{Any}(1, 2)

julia> ct2 = Composite{Any}(xt)
Composite{Any}((1, 2),)
mzgubic commented 4 years ago

As a consequence they behave differently when splatted:

julia> println(ct1...)
12

julia> println(ct2...)
(1, 2)
nickrobinson251 commented 3 years ago

Xref #198