Skip to content

Commit

Permalink
Add a make_zero path for TracedRArray
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed May 27, 2024
1 parent 4ccff4b commit f23abb5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Reactant.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ end
seen[prev] = res
return res
end

if RT <: TracedRArray
@assert typeof(prev) <: RT # prev has concrete shape while RT might not have that
res = typeof(prev)(prev.paths, prev.mlir_data)
seen[prev] = res
return res
end

attr = fill(MLIR.IR.Attribute(eltype(RT)(0)), mlir_type(prev))
cst = MLIR.IR.result(MLIR.Dialects.stablehlo.constant(value=attr), 1)
Expand All @@ -146,8 +153,6 @@ end
return res
end



function Base.promote_rule(A::Type{TracedRArray{T, Shape, N}}, B::Type{TracedRArray{S, Shape, N}}) where {T, S, Shape, N}
TracedRArray{Base.promote_type(T, S), Shape, N}
end
Expand Down

0 comments on commit f23abb5

Please sign in to comment.