Skip to content

Commit cfcfaae

Browse files
committed
Add Enzyme.tupsack dispatch for Reactant.RArray
1 parent b773d9f commit cfcfaae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Enzyme.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ end
6969
return Base.zero(x)
7070
end
7171

72+
@inline function Enzyme.tupstack(
73+
data::Tuple{Vararg{<:Reactant.RArray{T}}},
74+
outshape::Tuple{Vararg{Int}},
75+
inshape::Tuple{Vararg{Int}},
76+
) where {T}
77+
res = similar(first(data), outshape..., inshape...)
78+
c = CartesianIndices(outshape)
79+
tail_dims = map(Returns(:), inshape)
80+
for (i, val) in enumerate(data)
81+
@inbounds res[c[i], tail_dims...] = val
82+
end
83+
return res
84+
end
85+
7286
macro register_make_zero_inplace(sym)
7387
quote
7488
@inline function $sym(prev::RArray{T,N})::Nothing where {T<:AbstractFloat,N}

0 commit comments

Comments
 (0)