JuliaGPU / JuliaGPU/Adapt.jl

Support for arbitrary callables

Open
#84 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
120
Forks
29
Avg merge
1d 18h
Merged PRs (30d)
1

Description

`adapt_structure` fails if there are mixed concrete types and parametric types in a function type.

Tests:
```julia
using Adapt

# This should be equivalent to what adapt_structure does
g(f::T) where T = length(T.parameters)

abstract type AbstractSuperType{t} end

abstract type AbstractSuperType2{t} <: Function end

struct A{T}
a::T
end
a = A(1)
@assert g(a) == 1 # Works
Adapt.adapt_structure(1.0, a) # Works

struct B{T} <: AbstractSuperType2{true}
b::T
end
b = B(1)
@assert g(b) == 1 # Works
Adapt.adapt_structure(1.0, b) # works

struct B2 <: AbstractSuperType2{true}
b::Int
end
b2 = B2(1)
@assert g(b2) == 0 # Works
Adapt.adapt_structure(1.0, b2) # works

struct C{T} <: AbstractSuperType2{true}
b::T
a::Int
end
c = C(1,1)
@assert g(c) == 1 # Works
Adapt.adapt_structure(1.0, c) # fails

struct C2{T}
b::T
a::Int
end
c2 = C2(1,1)
@assert g(c2) == 1 # Works
Adapt.adapt_structure(1.0, c2) # works

struct C3{T} <: AbstractSuperType{true}
b::T
a::Int
end
c3 = C3(1,1)
@assert g(c3) == 1 # Works
Adapt.adapt_structure(1.0, c3) # works

struct D{T} <: AbstractSuperType2{true}
a::Int
b::T
end
d = D(1,1)
@assert g(d) == 1 # Works
Adapt.adapt_structure(1.0, d) # fails

struct D2{T}
a::Int
b::T
end
d2 = D2(1,1)
@assert g(d2) == 1 # Works
Adapt.adapt_structure(1.0, d2) # works

struct D3{T} <: AbstractSuperType{true}
a::Int
b::T
end
d3 = D3(1,1)
@assert g(d3) == 1 # Works
Adapt.adapt_structure(1.0, d3) # works

struct D4{T} <: AbstractSuperType2{true}
a::Int
b::T
end
d4 = D4(1,1)
@assert g(d4) == 1 # Works
Adapt.adapt_structure(1.0, d4) # fails

struct E{T} <: AbstractSuperType2{true}
a::Int
b::T
c::Int
end
e = E(1,1,1)
@assert g(e) == 1 # Works
Adapt.adapt_structure(1.0, e) # fails
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided Julia reproducer and the adapt_structure entry point, focusing on the mixed concrete and parametric field types in C, D, D4, and E. The work is done when those cases no longer fail while the existing assertions and successful examples continue to pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.