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
using Enzyme, Test
Enzyme.API.printall!(true)
concat() = ()
concat(a) = a
concat(a, b) = (a..., b...)
concat(a, b, c...) =concat(concat(a, b), c...)
functionmake_byref(out, arg)
res =0.0
x =concat(arg...)
#x = concat(arg[1], arg[2])for v in x
v = v::Tuple{Float64, Vector{Float64}}
res += v[1]
end
out[] = res
nothingendfunctiontupapprox(a, b)
if a isa Tuple && b isa Tuple
iflength(a) !=length(b)
returnfalseendfor (aa, bb) inzip(a, b)
if!tupapprox(aa, bb)
returnfalseendendreturntrueendif a isa Array && b isa Array
ifsize(a) !=size(b)
returnfalseendfor i inlength(a)
if!tupapprox(a[i], b[i])
returnfalseendendreturntrueendreturn a ≈ b
end
x = [[(2.0, [2.7]), (3.0, [3.14])], [(7.9, [47.0]), (11.2, [56.0])]]
make_byref(Ref(0.0), x)
dx = [[(0.0, [0.0]), (0.0, [0.0])], [(0.0, [0.0]), (0.0, [0.0])]]
dx2 = [[(0.0, [0.0]), (0.0, [0.0])], [(0.0, [0.0]), (0.0, [0.0])]]
out =Ref(0.0)
dout =Ref(1.0)
dout2 =Ref(3.0)
Enzyme.autodiff(Reverse, make_byref, Const, BatchDuplicatedNoNeed(out, (dout, dout2)), BatchDuplicated(x, (dx, dx2)))
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: