File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments