Skip to content

Commit 44b05ab

Browse files
authored
Don't create nested thunks when accumulating
Otherwise, it's too easy to create massive types that freeze compilation and blow the stack.
1 parent 572eb2a commit 44b05ab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/lib.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ accum(x::ChainRulesCore.Tangent, y::NamedTuple) = accum(wrap_chainrules_output(x
4343
accum(x::Nothing, y::AbstractThunk) = y
4444
accum(x::AbstractThunk, y::Nothing) = x
4545

46-
accum(x, y::AbstractThunk) = @thunk(accum(x, unthunk(y)))
47-
accum(x::AbstractThunk, y) = @thunk(accum(unthunk(x), y))
48-
accum(x::AbstractThunk, y::AbstractThunk) = @thunk(accum(unthunk(x), unthunk(y)))
46+
accum(x, y::AbstractThunk) = accum(x, unthunk(y))
47+
accum(x::AbstractThunk, y) = accum(unthunk(x), y))
48+
accum(x::AbstractThunk, y::AbstractThunk) = accum(unthunk(x), unthunk(y))
4949

5050
# Core functions
5151
@_adjoint_keepthunks deepcopy(x) = deepcopy(x), ȳ -> (ȳ,)

0 commit comments

Comments
 (0)