Hello, I get for the following small example the strage output:
freeing without malloc %53 = call noalias nonnull dereferenceable(32) dereferenceable_or_null(32) i8* @malloc(i64 noundef 32) #20, !enzyme_cache_alloc !57
freeing without malloc %_malloccache107.i.i = call noalias nonnull dereferenceable(4) dereferenceable_or_null(4) i8* @malloc(i64 noundef 4) #20, !enzyme_cache_alloc !59
freeing without malloc %_malloccache110.i.i = call noalias nonnull dereferenceable(4) dereferenceable_or_null(4) i8* @malloc(i64 noundef 4) #20, !enzyme_cache_alloc !61
My julia version 1.11.2.
I hope you have any ideas, thank you!
My code:
using Enzyme
function foo1(uv)
out = zeros(2)
for i in eachindex(uv)
out .+= uv[i]
end
out
end
function fun(uv::V,pars) where {V}
s = zero(Float64)
for _ in 1:4
∇u_x = foo1(uv)
s += sum(∇u_x)
end
return s
end
function fun_grad(f::F,uv::V,
uvb::V,pars) where {T<:Float64,V<:AbstractVector{T},F<:Function}
Enzyme.autodiff(Reverse,Const(f),Duplicated(uv,uvb),Const(pars))
nothing
end
uv = rand(4);
vx = ([1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0])
fe = rand(4)
Ke = ([0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0])
v = rand(10)
Enzyme.autodiff(Enzyme.Forward, fun_grad,
Const(fun),
BatchDuplicated(uv,vx),
BatchDuplicated(fe,Ke),
Const(v))