Open termi-official opened 2 weeks ago
This is a known limitation; Adapt currently only works with callable objects (functions, closures) as emitted by the Julia front-end.
Why are you even declaring AbstractSuperType2{t} <: Function
in the first place? Can you show an example where this fails with normal functions? By doing so, you're triggering the predefined adapt rule that works with Julia-defined functions, which your types aren't. I'd suggest not defining <: Function
and writing your own adapt convertors.
Why are you even declaring
AbstractSuperType2{t} <: Function
in the first place?
I am working on a package downstream of SciMLBase where I have some objects subtyping from https://github.com/SciML/SciMLBase.jl/blob/e3a0de8451d7a924807975de892673404c5b8d9a/src/SciMLBase.jl#L578 to represent my PDE discretization and I simply wanted to have a reproducer for the issue with similar structure to what I do (and to show that the issue is not subtyping per-se but subtyping from Function
.
Can you show an example where this fails with normal functions? [...]
I was not able to find reproduce the issue for normal functions.
This is a known limitation; Adapt currently only works with callable objects (functions, closures) as emitted by the Julia front-end.
Please note that Adapt works as expected in the cases when
I am currently simply use 2 to work around this issue. I just wanted to report this since I spend a bit of time to track this down the exact problem, so others don't have to.
I am working on a package downstream of SciMLBase where I have some objects subtyping from https://github.com/SciML/SciMLBase.jl/blob/e3a0de8451d7a924807975de892673404c5b8d9a/src/SciMLBase.jl#L578 to represent my PDE discretization and I simply wanted to have a reproducer for the issue with similar structure to what I do (and to show that the issue is not subtyping per-se but subtyping from
Function
.
@ChrisRackauckas What's the reason for the <: Function
there?
It's a function, it has f(u,p,t)
calls.
It's a function, it has
f(u,p,t)
calls.
All objects are callable when you add methods to its type. Why does it need the <: Function
?
It's pretty common for people to annotate callable structs as <:Function
adapt_structure
fails if there are mixed concrete types and parametric types in a function type.Tests: