You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This came up while working on applying Enzyme to SpeedyWeather.jl
Sorry, for the lengthy title, not sure how to better put this into words.
As a MWE, without our data structures from there:
import Pkg
Pkg.activate("test")
using Enzyme
@kwdefstruct StructA{A<:AbstractArray, B<:AbstractArray}
vor::NTuple{2,A}=ntuple(i ->zeros(20,20), 2)
div::NTuple{2,A}=ntuple(i ->zeros(20,20), 2)
pres::NTuple{2,B}=ntuple(i ->zeros(20), 2)
other::B=zeros(20)
other_int::Int=0end@kwdefstruct StructB{A<:AbstractArray, B<:AbstractArray}
vor_tend::A=zeros(20,20)
div_tend::A=zeros(20,20)
pres_tend::B=zeros(20)
other::B=zeros(20)
other_int::Int=0endfunctionlf2!(
progn::StructA,
tend::StructB)
for (varname, tendname) inzip((:vor,:div,:pres), (:vor_tend,:div_tend,:pres_tend))
var_old, var_new =getfield(progn, varname)
var_tend =getfield(tend, tendname)
compute_something!(var_old, var_new, var_tend)
endreturnnothingendfunctioncompute_something!(A, B, C)
A .+= C
B .-= C
returnnothingend
A =StructA()
dA =StructA(vor=ntuple(i ->ones(20,20), 2), div=ntuple(i ->ones(20,20), 2))
B =StructB()
dB =make_zero(B)
autodiff(Reverse, lf2!, Const, Duplicated(A, dA), Duplicated(B, dB))
With Enzyme in Julia 1.10 this works, with Enzyme in Julia 1.11 this first got me some type analysis errors, and now in this exact version a seg fault.
With simpler data structures, that still contain different array types (like in StructB), but not nested within tuples as above in StructA it also works.
There are ways I could make the code of lf2! a bit more explicit and avoid doing it like above, but it does already work just fine with Enzyme in 1.10 like it is, just not with Julia 1.11.
The text was updated successfully, but these errors were encountered:
This came up while working on applying Enzyme to SpeedyWeather.jl
Sorry, for the lengthy title, not sure how to better put this into words.
As a MWE, without our data structures from there:
With Enzyme in Julia 1.10 this works, with Enzyme in Julia 1.11 this first got me some type analysis errors, and now in this exact version a seg fault.
With simpler data structures, that still contain different array types (like in
StructB
), but not nested within tuples as above inStructA
it also works.There are ways I could make the code of
lf2!
a bit more explicit and avoid doing it like above, but it does already work just fine with Enzyme in 1.10 like it is, just not with Julia 1.11.The text was updated successfully, but these errors were encountered: