@@ -13,7 +13,6 @@ abstract type AbstractRule end
13
13
mutable struct Leaf{R,S} # mutable so that its identity encodes parameter sharing
14
14
rule:: R
15
15
state:: S
16
- frozen:: Bool # mutability also allows this flag to be changed
17
16
end
18
17
19
18
@functor Leaf
@@ -35,7 +34,7 @@ function Base.show(io::IO, ℓ::Leaf) # show method is mostly to hide its long
35
34
ioc = IOContext (io, :compact => true )
36
35
print (ioc, " Leaf(" , ℓ. rule, " , " )
37
36
show (ioc, ℓ. state)
38
- print (ioc, " , " , ℓ . frozen, " )" )
37
+ print (ioc, " )" )
39
38
end
40
39
41
40
# ##
@@ -49,7 +48,6 @@ function update!(tree, model, grad)
49
48
grads! (dict, tree, model, grad)
50
49
# Second walk is to update the model. The walk taken follows Leaf identity
51
50
newmodel = fmap (tree, model; exclude = ℓ -> ℓ isa Leaf, walk = _second_walk, cache = LeafCache ()) do ℓ, x
52
- ℓ. frozen && return x
53
51
haskey (dict, ℓ) || return x # no gradient seen, nothing to do
54
52
s′, x̄′ = apply! (ℓ. rule, ℓ. state, x, dict[ℓ])
55
53
ℓ. state = s′ # to get state out of here, rely on mutability of Leaf
0 commit comments