@@ -254,33 +254,33 @@ Base.conj(x::AbstractThunk) = @thunk(conj(extern(x)))
254
254
Base. show (io:: IO , x:: Thunk ) = println (io, " Thunk($(repr (x. f)) )" )
255
255
256
256
"""
257
- InplaceableThunk (val::Thunk, add!::Function)
257
+ InplaceThunk (val::Thunk, add!::Function)
258
258
259
259
A wrapper for a `Thunk`, that allows it to define an inplace `add!` function,
260
- which is used internally in `accumulate!(Δ, ::InplaceableThunk )`.
260
+ which is used internally in `accumulate!(Δ, ::InplaceThunk )`.
261
261
262
262
`add!` should be defined such that: `ithunk.add!(Δ) = Δ .+= ithunk.val`
263
263
but it should do this more efficently than simply doing this directly.
264
264
(Otherwise one can just use a normal `Thunk`).
265
265
266
- Most operations on an `InplaceableThunk ` treat it just like a normal `Thunk`;
266
+ Most operations on an `InplaceThunk ` treat it just like a normal `Thunk`;
267
267
and destroy its inplacability.
268
268
"""
269
- struct InplaceableThunk {T<: Thunk , F} <: AbstractThunk
269
+ struct InplaceThunk {T<: Thunk , F} <: AbstractThunk
270
270
val:: T
271
271
add!:: F
272
272
end
273
273
274
- (x:: InplaceableThunk )() = x. val ()
275
- @inline extern (x:: InplaceableThunk ) = extern (x. val)
274
+ (x:: InplaceThunk )() = x. val ()
275
+ @inline extern (x:: InplaceThunk ) = extern (x. val)
276
276
277
- function Base. show (io:: IO , x:: InplaceableThunk )
278
- println (io, " InplaceableThunk ($(repr (x. val)) , $(repr (x. add!)) )" )
277
+ function Base. show (io:: IO , x:: InplaceThunk )
278
+ println (io, " InplaceThunk ($(repr (x. val)) , $(repr (x. add!)) )" )
279
279
end
280
280
281
281
# The real reason we have this:
282
- accumulate! (Δ, ∂:: InplaceableThunk ) = ∂. add! (Δ)
283
- store! (Δ, ∂:: InplaceableThunk ) = ∂. add! ((Δ.*= false )) # zero it, then add to it.
282
+ accumulate! (Δ, ∂:: InplaceThunk ) = ∂. add! (Δ)
283
+ store! (Δ, ∂:: InplaceThunk ) = ∂. add! ((Δ.*= false )) # zero it, then add to it.
284
284
285
285
"""
286
286
NO_FIELDS
0 commit comments