Skip to content

Commit cd4ac8d

Browse files
committed
InplaceableThunk
1 parent b1ed9eb commit cd4ac8d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/projection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ ProjectTo(::Any) = identity
128128
ProjectTo(::AbstractZero) = ProjectTo{NoTangent}() # Any x::Zero in forward pass makes this one projector,
129129
(::ProjectTo{NoTangent})(dx) = NoTangent() # but this is the projection only for nonzero gradients,
130130
(::ProjectTo{NoTangent})(dx::AbstractZero) = dx # and this one solves an ambiguity.
131-
(::ProjectTo{NoTangent})(::AbstractThunk) = NoTangent() # solves ambiguity, #685
131+
(::ProjectTo{NoTangent})(::InplaceableThunk) = NoTangent() # solves ambiguity, #685
132132
(::ProjectTo{NoTangent})(::Thunk) = NoTangent() # solves ambiguity, #685
133133

134134
# Also, any explicit construction with fields, where all fields project to zero, itself

test/projection.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,10 @@ struct NoSuperType end
465465
end
466466

467467
@testset "#685" begin
468-
@test ProjectTo(BitArray([0]))(@thunk[1.0]) == NoTangent()
468+
@test ProjectTo(BitArray([0]))([1.0]) == NoTangent()
469+
@test ProjectTo(BitArray([0]))(@thunk [1.0]) == NoTangent()
470+
471+
it = InplaceableThunk(x -> x + [1], @thunk [1.0])
472+
@test ProjectTo(BitArray([0]))(it) == NoTangent()
469473
end
470474
end

0 commit comments

Comments
 (0)