@@ -112,32 +112,6 @@ See also: [`accumulate`](@ref), [`accumulate!`](@ref), [`AbstractRule`](@ref)
112
112
"""
113
113
store! (Δ, rule:: AbstractRule , args... ) = materialize! (Δ, broadcastable (rule (args... )))
114
114
115
- # Special purpose updating for operations which can be done in-place. This function is
116
- # just internal and free-form; it is not a method of `accumulate!` directly as it does
117
- # not adhere to the expected method signature form, i.e. `accumulate!(value, rule, args)`.
118
- # Instead it's `_update!(old, new, extrastuff...)` and is not specific to any particular
119
- # rule.
120
-
121
- _update! (x, y) = x + y
122
- _update! (x:: Array{T,N} , y:: AbstractArray{T,N} ) where {T,N} = x .+ = y
123
-
124
- _update! (x, :: Zero ) = x
125
- _update! (:: Zero , y) = y
126
- _update! (:: Zero , :: Zero ) = Zero ()
127
-
128
- function _update! (x:: NamedTuple{Ns} , y:: NamedTuple{Ns} ) where Ns
129
- return NamedTuple {Ns} (map (p-> _update! (getproperty (x, p), getproperty (y, p)), Ns))
130
- end
131
-
132
- function _update! (x:: NamedTuple , y, p:: Symbol )
133
- new = NamedTuple {(p,)} ((_update! (getproperty (x, p), y),))
134
- return merge (x, new)
135
- end
136
-
137
- function _update! (x:: NamedTuple{Ns} , y:: NamedTuple{Ns} , p:: Symbol ) where Ns
138
- return _update! (x, getproperty (y, p), p)
139
- end
140
-
141
115
# ####
142
116
# #### `Rule`
143
117
# ####
@@ -377,23 +351,6 @@ See also: [`frule`](@ref), [`AbstractRule`](@ref), [`@scalar_rule`](@ref)
377
351
"""
378
352
rrule (:: Any , :: Vararg{Any} ; kwargs... ) = nothing
379
353
380
- @noinline function _throw_checked_rrule_error (f, args... ; kwargs... )
381
- io = IOBuffer ()
382
- print (io, " can't differentiate `" , f, ' (' )
383
- join (io, map (arg-> string (" ::" , typeof (arg)), args), " , " )
384
- if ! isempty (kwargs)
385
- print (io, " ;" )
386
- join (io, map (((k, v),)-> string (k, " =" , v), kwargs), " , " )
387
- end
388
- print (io, " )`; no matching `rrule` is defined" )
389
- throw (ArgumentError (String (take! (io))))
390
- end
391
-
392
- function _checked_rrule (f, args... ; kwargs... )
393
- r = rrule (f, args... ; kwargs... )
394
- r isa Nothing && _throw_checked_rrule_error (f, args... ; kwargs... )
395
- return r
396
- end
397
354
398
355
# ####
399
356
# #### macros
0 commit comments