1.12 calling conv rewrite error
source of the 1.12 comrade ci failure:
```julia
using Enzyme
using Enzyme.EnzymeRules
abstract type AbstractDomain end
mutable struct InnerPlan
b::Float64
end
struct MyPlan
a::Int64
b::Float64
c::Int32
d::Int32
plan::InnerPlan
phases::Vector{Float64}
indices::Tuple{Vector{Int64}, Vector{Int64}}
h::Int64
end
struct MyDomain <: AbstractDomain
plan::MyPlan
end
@noinline forward_plan(g::AbstractDomain) = getfield(g, :plan)
EnzymeRules.inactive(::typeof(forward_plan), args...) = nothing
@noinline getplan(p::MyPlan) = getfield(p, :plan)
EnzymeRules.inactive(::typeof(getplan), args...) = nothing
@noinline getindices(p::MyPlan) = getfield(p, :indices)
EnzymeRules.inactive(::typeof(getindices), args...) = nothing
@noinline function _my_nuft!(out, A, b)
out .= b .* A.b
return nothing
end
function EnzymeRules.augmented_primal(
config::EnzymeRules.RevConfigWidth,
func::Const{typeof(_my_nuft!)}, ::Type{<:Const},
out::Annotation,
A::Annotation,
b::Annotation
)
primal = EnzymeRules.needs_primal(config) ? out.val : nothing
shadow = EnzymeRules.needs_shadow(config) ? out.dval : nothing
func.val(out.val, A.val, b.val)
return EnzymeRules.AugmentedReturn(primal, shadow, nothing)
end
function EnzymeRules.reverse(
config::EnzymeRules.RevConfigWidth,
::Const{typeof(_my_nuft!)},
::Type{RT}, tape,
out::Annotation, A::Annotation,
b::Annotation
) where {RT}
b.dval .+= out.dval .* A.val.b
fill!(out.dval, 0)
return (nothing, nothing, nothing)
end
function applyphases!(vis, phases)
for i in eachindex(vis, phases)
vis[i] = vis[i] * phases[i]
end
return vis
end
@inline function applyft(p, img)
vis = similar(img)
plan = getplan(p)
iminds, visinds = getindices(p)
for i in eachindex(iminds, visinds)
imind = iminds[i]
visind = visinds[i]
vis_view = @view(vis[visind:visind])
img_view = @view(img[imind:imind])
_my_nuft!(vis_view, plan, img_view)
end
applyphases!(vis, p.phases)
return vis
end
@noinline function visibilitymap_numeric(grid::AbstractDomain, img::Vector{Float64})
vis = applyft(forward_plan(grid), img)
return vis
end
@noinline function foo(grid::AbstractDomain, img)
vis = visibilitymap_numeric(grid, img)
return sum(vis)
end
function run_repro()
inner = InnerPlan(2.0)
plan = MyPlan(1, 2.0, 3, 4, inner, [2.0, 3.0, 4.0], ([1, 2, 3], [1, 2, 3]), 7)
grid = MyDomain(plan)
img = [1.0, 2.0, 3.0]
dimg = [0.0, 0.0, 0.0]
autodiff(set_runtime_activity(Enzyme.Reverse), foo, Active, Const(grid), Duplicated(img, dimg))
@show dimg
end
run_repro()
```
0 条评论