Skip to content

Commit ad0217b

Browse files
authored
1 parent 9f698f7 commit ad0217b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/forward.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function forward_eval(storage::AbstractVector{T}, partials_storage::AbstractVect
6666
for c_idx in children_idx
6767
@inbounds tmp_prod *= storage[children_arr[c_idx]]
6868
end
69-
if tmp_prod == zero(T) # inefficient
69+
if tmp_prod == zero(T) || n_children <= 2 # inefficient
7070
for c_idx in children_idx
7171
prod_others = one(T)
7272
for c_idx2 in children_idx
@@ -274,7 +274,7 @@ function forward_eval_ϵ(storage::AbstractVector{T},
274274
end
275275
# By a quirk of floating-point numbers, we can have
276276
# anyzero == true && ForwardDiff.value(tmp_prod) != zero(T)
277-
if anyzero # inefficient
277+
if anyzero || n_children <= 2 # inefficient
278278
for c_idx in children_idx
279279
prod_others = one(ForwardDiff.Dual{TAG,T,N})
280280
for c_idx2 in children_idx

0 commit comments

Comments
 (0)