Skip to content

Commit cad9ea9

Browse files
committed
don't blindly unwrap_eltype in elem_apply_via_while_loop
1 parent ab24bd3 commit cad9ea9

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
@@ -1113,7 +1113,12 @@ function elem_apply_via_while_loop(f, args::Vararg{Any,Nargs}) where {Nargs}
11131113

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

11181123
ind_var = Ref(0)
11191124
f_ref = Ref(f)

0 commit comments

Comments
 (0)