-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
@functor
is confused about properties vs fields
#46
Comments
With the reversion of #48, I guess our second attempt would be to try to use all properties? It won't be type stable for most types that define custom |
So the problem in #48 is For Functors to use properties-not-fields everywhere, I think it would have to be |
In my refactor with ConstructionBase, I tried making |
One barrier to properties-everywhere is that Zygote uses fields: julia> using ProtoStructs, Zygote
julia> @proto struct Mine
num::Float64
end
julia> gradient(x -> x.num^2, Mine(3.0))[1]
(properties = (num = 6.0,),)
julia> propertynames(Mine(3.0))
(:num,) |
And because we return plain NamedTuples instead of e.g. |
It was noticed in FluxML/Flux.jl#2107 that Functors.jl + ProtoStruct.jl doesn't work, as Functors uses
fieldnames
+getproperty
, which is overloaded by ProtoStruct.jl.https://github.com/FluxML/Functors.jl/blob/v0.3.0/src/functor.jl#L11-L16
This is a bug, Functors should use
getfield
to be consistent. (Possibly the code was written beforegetproperty
existed?)The text was updated successfully, but these errors were encountered: