-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Labels
Structural TangentRelated to the `Tangent` type for structured (composite) valuesRelated to the `Tangent` type for structured (composite) values
Description
What do we think about the following:
julia> c = Composite{Any}(;a=1, b=2);
julia> canonicalize(c)
ERROR: ArgumentError: type does not have a definite number of fields
Stacktrace:
[1] fieldcount(::Any) at ./reflection.jl:725
[2] #s15#27 at /Users/mzgubic/JuliaEnvs/test/alex/dev/ChainRulesCore/src/differentials/composite.jl:189 [inlined]
[3] #s15#27(::Any, ::Any, ::Any) at ./none:0
[4] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:543
[5] canonicalize(::Composite{Any,NamedTuple{(:a, :b),Tuple{Int64,Int64}}}) at /Users/mzgubic/JuliaEnvs/test/alex/dev/ChainRulesCore/src/differentials/composite.jl:166
[6] top-level scope at REPL[5]:1I suppose this should never really happen (but it does in higher order AD in Zygote).
Would it make sense to define something like
canonicalize(c::Composite{Any}) = csince in that case we don't know what the fields are, or do we prefer the error to be thrown?
Metadata
Metadata
Assignees
Labels
Structural TangentRelated to the `Tangent` type for structured (composite) valuesRelated to the `Tangent` type for structured (composite) values