denizyuret / AutoGrad.jl

Julia port of the Python autograd package.
Other
169 stars 26 forks source link

Param(x) as AbstractArray? #125

Open JeffFessler opened 3 years ago

JeffFessler commented 3 years ago

Would it be possible to make Param(x) have a subtype of AbstractArray (when x is)?

julia> x = [1, 2]
2-element Vector{Int64}:
 1
 2

julia> xp = Param(x)
2-element Param{Vector{Int64}}:
 1
 2

julia> supertypes(typeof(xp))
(Param{Vector{Int64}}, AutoGrad.Tracked{Vector{Int64}}, AutoGrad.Value{Vector{Int64}}, Any)

julia> xp isa AbstractArray
false

So currently the Param version xp cannot be passed to any functions that are expecting AbstractArray inputs.

Edit: I guess it's really AutoGrad.Value{Vector{Int64}} that I am wondering if could be a subtype of AA.

denizyuret commented 3 years ago

I have no objection to this, but I am not quite sure how to do it in practice.

On Wed, Jul 14, 2021 at 6:23 AM Jeff Fessler @.***> wrote:

Would it be possible to make Param(x) have a subtype of AbstractArray (when x is)?

julia> x = [1, 2]2-element Vector{Int64}: 1 2

julia> xp = Param(x)2-element Param{Vector{Int64}}: 1 2

julia> xp isa AbstractArrayfalse

So currently the Param version xp cannot be passed to any functions that are expecting AbstractArray inputs.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/denizyuret/AutoGrad.jl/issues/125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN43JS3SUNF35IKWT427TLTXT7KTANCNFSM5AKSJ7DQ .