GraphNeuralNetworks.jl icon indicating copy to clipboard operation
GraphNeuralNetworks.jl copied to clipboard

`@functor` default for `GNNLayer`s

Open CarloLucibello opened this issue 1 year ago • 0 comments

Consider adding the definitions

function Functors.functor(::Type{<:GNNLayer}, m::T) where T
    childr = (; (f => getfield(m, f) for f in fieldnames(T))...)
    Tstripped = Base.typename(T).wrapper # remove all parameters. From https://discourse.julialang.org/t/stripping-parameter-from-parametric-types/8293/16
    re = x -> Tstripped(x...)
    return childr, re
end

so that we don't need to add @functor to types inheriting from GNNLayer.

I'm not sure if this change should be considered breaking.

CarloLucibello avatar May 25 '23 07:05 CarloLucibello