Skip to content

Commit 9439257

Browse files
committed
Unconditionally disable thunks for 2nd order AD
1 parent 2564fc1 commit 9439257

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/tangent_types/thunks.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const UTILIZE_THUNKS = Ref{Function}(() -> true)
1+
_usethunks() = true
2+
rrule(::typeof(_usethunks)) = false, (NoTangent(),)
23

34
abstract type AbstractThunk <: AbstractTangent end
45

@@ -144,7 +145,7 @@ macro thunk(body)
144145
# so we get useful stack traces if it errors.
145146
func = Expr(:->, Expr(:tuple), Expr(:block, __source__, body))
146147
return quote
147-
$(esc(UTILIZE_THUNKS))[]() ?
148+
$(esc(_usethunks))() ?
148149
Thunk($(esc(func))) :
149150
$(esc(func))()
150151
end
@@ -241,7 +242,7 @@ struct InplaceableThunk{T<:Thunk,F} <: AbstractThunk
241242
val::T
242243

243244
function InplaceableThunk(add!::F, val::T) where {F, T}
244-
UTILIZE_THUNKS[]() ?
245+
_usethunks() ?
245246
new{T, F}(add!, val) :
246247
val
247248
end

0 commit comments

Comments
 (0)