Skip to content

Commit 91b0be4

Browse files
committed
Add comments about at .
1 parent d2876cf commit 91b0be4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/rule_definition_tools.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,19 @@ function propagation_expr(Δs, ∂s)
211211
∂s = map(esc, ∂s)
212212
n∂s = length(∂s)
213213

214+
# Due to bugs in Julia 1.0, we can't use `.+` or `.*` inside expression
215+
# literals.
214216
∂_mul_Δs = ntuple(i->:($(∂s[i]) * $(Δs[i])), n∂s)
215217

216-
# avoiding the extra `+` operation, it is potentially
217-
# expensive for vector mode AD
218+
# Avoiding the extra `+` operation, it is potentially expensive for vector
219+
# mode AD.
218220
sumed_∂_mul_Δs = if n∂s > 1
221+
# we use `@.` to broadcast `*` and `+`
219222
:(@. +($(∂_mul_Δs...)))
220223
else
224+
# Note: we don't want to do broadcasting with only 1 multiply (no `+`),
225+
# because some arrays overload multiply with scalar. Avoiding
226+
# broadcasting saves compilation time.
221227
∂_mul_Δs[1]
222228
end
223229

0 commit comments

Comments
 (0)