Skip to content

Commit a43dedc

Browse files
committed
don't blindly unwrap_eltype in elem_apply_via_while_loop
1 parent 1102ff4 commit a43dedc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/TracedUtils.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,12 @@ function elem_apply_via_while_loop(f, args::Vararg{Any,Nargs}) where {Nargs}
11151115

11161116
# This wont be a mutating function so we can safely execute it once
11171117
res_tmp = @allowscalar(f([@allowscalar(arg[1]) for arg in flat_args]...))
1118-
result = similar(first(flat_args), Reactant.unwrapped_eltype(res_tmp), L)
1118+
1119+
# TODO: perhaps instead of this logic, we should have
1120+
# `similar(::TracedRArray, TracedRNumber{T}) where T = similar(::TracedRArray, T)`
1121+
# and just not unwrap here?
1122+
T_res = typeof(res_tmp) <: TracedRNumber ? unwrapped_eltype(res_tmp) : typeof(res_tmp)
1123+
result = similar(first(flat_args), T_res, L)
11191124

11201125
ind_var = Ref(0)
11211126
f_ref = Ref(f)

0 commit comments

Comments
 (0)