@@ -38,8 +38,8 @@ struct Protected{N}
38
38
a
39
39
end
40
40
(p:: Protected )(args... ) = getfield (p, :a )(args... )[1 ]
41
- @Base . aggressive_constprop (:: ∂⃖{N})(p:: Protected{N} , args... ) where {N} = getfield (p, :a )(args... )
42
- @Base . aggressive_constprop (:: ∂⃖{1 })(p:: Protected{1} , args... ) = getfield (p, :a )(args... )
41
+ @Base . constprop :aggressive (:: ∂⃖{N})(p:: Protected{N} , args... ) where {N} = getfield (p, :a )(args... )
42
+ @Base . constprop :aggressive (:: ∂⃖{1 })(p:: Protected{1} , args... ) = getfield (p, :a )(args... )
43
43
(:: ∂⃖{N})(p:: Protected , args... ) where {N} = error (" TODO: Can we support this?" )
44
44
45
45
struct OpticBundle{T}
94
94
end
95
95
96
96
struct ∂⃖weaveInnerOdd{N, O}; b̄; end
97
- @Base . aggressive_constprop function (w: :∂⃖weaveInnerOdd {N, N})(Δ) where {N}
97
+ @Base . constprop :aggressive function (w: :∂⃖weaveInnerOdd {N, N})(Δ) where {N}
98
98
@destruct c, c̄ = w. b̄ (Δ... )
99
99
return (c̄, c)
100
100
end
101
- @Base . aggressive_constprop function (w: :∂⃖weaveInnerOdd {N, O})(Δ) where {N, O}
101
+ @Base . constprop :aggressive function (w: :∂⃖weaveInnerOdd {N, O})(Δ) where {N, O}
102
102
@destruct c, c̄ = w. b̄ (Δ... )
103
103
return (c̄, c), ∂⃖weaveInnerEven {plus1(N), O} ()
104
104
end
105
105
struct ∂⃖weaveInnerEven{N, O}; end
106
- @Base . aggressive_constprop function (w: :∂⃖weaveInnerEven {N, O})(Δ′, x... ) where {N, O}
106
+ @Base . constprop :aggressive function (w: :∂⃖weaveInnerEven {N, O})(Δ′, x... ) where {N, O}
107
107
@destruct y, ȳ = Δ′ (x... )
108
108
return y, ∂⃖weaveInnerOdd {plus1(N), O} (ȳ)
109
109
end
110
110
111
111
struct ∂⃖weaveOuterOdd{N, O}; end
112
- @Base . aggressive_constprop function (w: :∂⃖weaveOuterOdd {N, N})((Δ′′, Δ′′′)) where {N}
112
+ @Base . constprop :aggressive function (w: :∂⃖weaveOuterOdd {N, N})((Δ′′, Δ′′′)) where {N}
113
113
return (NoTangent (), Δ′′′ (Δ′′)... )
114
114
end
115
- @Base . aggressive_constprop function (w: :∂⃖weaveOuterOdd {N, O})((Δ′′, Δ′′′)) where {N, O}
115
+ @Base . constprop :aggressive function (w: :∂⃖weaveOuterOdd {N, O})((Δ′′, Δ′′′)) where {N, O}
116
116
@destruct α, ᾱ = Δ′′′ (Δ′′)
117
117
return (NoTangent (), α... ), ∂⃖weaveOuterEven {plus1(N), O} (ᾱ)
118
118
end
119
119
struct ∂⃖weaveOuterEven{N, O}; ᾱ end
120
- @Base . aggressive_constprop function (w: :∂⃖weaveOuterEven {N, O})(Δ⁴... ) where {N, O}
120
+ @Base . constprop :aggressive function (w: :∂⃖weaveOuterEven {N, O})(Δ⁴... ) where {N, O}
121
121
return w. ᾱ (Base. tail (Δ⁴)... ), ∂⃖weaveOuterOdd {plus1(N), O} ()
122
122
end
123
123
@@ -156,33 +156,33 @@ struct ∂⃖rruleB{N, O}; ᾱ; ȳ̄ ; end
156
156
struct ∂⃖rruleC{N, O}; ȳ̄ ; Δ′′′; β̄ ; end
157
157
struct ∂⃖rruleD{N, O}; γ̄; β̄ ; end
158
158
159
- @Base . aggressive_constprop function (a: :∂⃖rruleA {N, O})(Δ) where {N, O}
159
+ @Base . constprop :aggressive function (a: :∂⃖rruleA {N, O})(Δ) where {N, O}
160
160
# TODO : Is this unthunk in the right place
161
161
@destruct (α, ᾱ) = a.∂ (a. ȳ, unthunk (Δ))
162
162
(α, ∂⃖rruleB {N, O} (ᾱ, a. ȳ̄))
163
163
end
164
164
165
- @Base . aggressive_constprop function (b: :∂⃖rruleB {N, O})(Δ′... ) where {N, O}
165
+ @Base . constprop :aggressive function (b: :∂⃖rruleB {N, O})(Δ′... ) where {N, O}
166
166
@destruct ((Δ′′′, β), β̄) = b. ᾱ (Δ′)
167
167
(β, ∂⃖rruleC {N, O} (b. ȳ̄, Δ′′′, β̄))
168
168
end
169
169
170
- @Base . aggressive_constprop function (c: :∂⃖rruleC {N, O})(Δ′′) where {N, O}
170
+ @Base . constprop :aggressive function (c: :∂⃖rruleC {N, O})(Δ′′) where {N, O}
171
171
@destruct (γ, γ̄) = c. ȳ̄ ((Δ′′, c. Δ′′′))
172
172
(Base. tail (γ), ∂⃖rruleD {N, O} (γ̄, c. β̄))
173
173
end
174
174
175
- @Base . aggressive_constprop function (d: :∂⃖rruleD {N, O})(Δ⁴... ) where {N, O}
175
+ @Base . constprop :aggressive function (d: :∂⃖rruleD {N, O})(Δ⁴... ) where {N, O}
176
176
(δ₁, δ₂), δ̄ = d. γ̄ (ZeroTangent (), Δ⁴... )
177
177
(δ₁, ∂⃖rruleA {N, O+1} (d. β̄ , δ₂, δ̄ ))
178
178
end
179
179
180
180
# Terminal cases
181
- @Base . aggressive_constprop function (c: :∂⃖rruleB {N, N})(Δ′... ) where {N}
181
+ @Base . constprop :aggressive function (c: :∂⃖rruleB {N, N})(Δ′... ) where {N}
182
182
@destruct (Δ′′′, β) = c. ᾱ (Δ′)
183
183
(β, ∂⃖rruleC {N, N} (c. ȳ̄, Δ′′′, nothing ))
184
184
end
185
- @Base . aggressive_constprop (c: :∂⃖rruleC {N, N})(Δ′′) where {N} =
185
+ @Base . constprop :aggressive (c: :∂⃖rruleC {N, N})(Δ′′) where {N} =
186
186
Base. tail (c. ȳ̄ ((Δ′′, c. Δ′′′)))
187
187
(:: ∂⃖rruleD{N, N})(Δ... ) where {N} = error (" Should not be reached" )
188
188
@@ -255,17 +255,17 @@ function ChainRulesCore.rrule(::KwFunc, kwargs, f, args...)
255
255
end
256
256
end
257
257
258
- @Base . aggressive_constprop function ChainRulesCore. rrule (:: typeof (Core. getfield), s, field:: Symbol )
258
+ @Base . constprop :aggressive function ChainRulesCore. rrule (:: typeof (Core. getfield), s, field:: Symbol )
259
259
getfield (s, field), let P = typeof (s)
260
- @Base . aggressive_constprop Δ-> begin
260
+ @Base . constprop :aggressive Δ-> begin
261
261
nt = NamedTuple {(field,)} ((Δ,))
262
262
(NoTangent (), Tangent {P, typeof(nt)} (nt), NoTangent ())
263
263
end
264
264
end
265
265
end
266
266
267
267
struct ∂⃖getfield{n, f}; end
268
- @Base . aggressive_constprop function (:: ∂⃖getfield{n, f})(Δ) where {n,f}
268
+ @Base . constprop :aggressive function (:: ∂⃖getfield{n, f})(Δ) where {n,f}
269
269
if @generated
270
270
return Expr (:call , tuple, NoTangent (),
271
271
Expr (:call , tuple, (i == f ? :(Δ) : ZeroTangent () for i = 1 : n). .. ),
@@ -279,31 +279,31 @@ struct EvenOddEven{O, P, F, G}; f::F; g::G; end
279
279
EvenOddEven {O, P} (f:: F , g:: G ) where {O, P, F, G} = EvenOddEven {O, P, F, G} (f, g)
280
280
struct EvenOddOdd{O, P, F, G}; f:: F ; g:: G ; end
281
281
EvenOddOdd {O, P} (f:: F , g:: G ) where {O, P, F, G} = EvenOddOdd {O, P, F, G} (f, g)
282
- @Base . aggressive_constprop (o:: EvenOddOdd{O, P, F, G} )(Δ) where {O, P, F, G} = (o. f (Δ), EvenOddEven {plus1(O), P, F, G} (o. f, o. g))
283
- @Base . aggressive_constprop (e:: EvenOddEven{O, P, F, G} )(Δ... ) where {O, P, F, G} = (e. g (Δ... ), EvenOddOdd {plus1(O), P, F, G} (e. f, e. g))
284
- @Base . aggressive_constprop (o:: EvenOddOdd{O, O} )(Δ) where {O} = o. f (Δ)
282
+ @Base . constprop :aggressive (o:: EvenOddOdd{O, P, F, G} )(Δ) where {O, P, F, G} = (o. f (Δ), EvenOddEven {plus1(O), P, F, G} (o. f, o. g))
283
+ @Base . constprop :aggressive (e:: EvenOddEven{O, P, F, G} )(Δ... ) where {O, P, F, G} = (e. g (Δ... ), EvenOddOdd {plus1(O), P, F, G} (e. f, e. g))
284
+ @Base . constprop :aggressive (o:: EvenOddOdd{O, O} )(Δ) where {O} = o. f (Δ)
285
285
286
286
287
- @Base . aggressive_constprop function (:: ∂⃖{N})(:: typeof (Core. getfield), s, field:: Int ) where {N}
287
+ @Base . constprop :aggressive function (:: ∂⃖{N})(:: typeof (Core. getfield), s, field:: Int ) where {N}
288
288
getfield (s, field), EvenOddOdd {1, c_order(N)} (
289
289
∂⃖getfield {nfields(s), field} (),
290
- @Base . aggressive_constprop (_, Δ, _)-> getfield (Δ, field))
290
+ @Base . constprop :aggressive (_, Δ, _)-> getfield (Δ, field))
291
291
end
292
292
293
- @Base . aggressive_constprop function (:: ∂⃖{N})(:: typeof (Base. getindex), s:: Tuple , field:: Int ) where {N}
293
+ @Base . constprop :aggressive function (:: ∂⃖{N})(:: typeof (Base. getindex), s:: Tuple , field:: Int ) where {N}
294
294
getfield (s, field), EvenOddOdd {1, c_order(N)} (
295
295
∂⃖getfield {nfields(s), field} (),
296
- @Base . aggressive_constprop (_, Δ, _)-> lifted_getfield (Δ, field))
296
+ @Base . constprop :aggressive (_, Δ, _)-> lifted_getfield (Δ, field))
297
297
end
298
298
299
299
function (:: ∂⃖{N})(:: typeof (Core. getfield), s, field:: Symbol ) where {N}
300
300
getfield (s, field), let P = typeof (s)
301
301
EvenOddOdd {1, c_order(N)} (
302
- (@Base . aggressive_constprop Δ-> begin
302
+ (@Base . constprop :aggressive Δ-> begin
303
303
nt = NamedTuple {(field,)} ((Δ,))
304
304
(NoTangent (), Tangent {P, typeof(nt)} (nt), NoTangent ())
305
305
end ),
306
- (@Base . aggressive_constprop (_, Δs, _)-> begin
306
+ (@Base . constprop :aggressive (_, Δs, _)-> begin
307
307
isa (Δs, Union{ZeroTangent, NoTangent}) ? Δs : getfield (ChainRulesCore. backing (Δs), field)
308
308
end ))
309
309
end
@@ -313,13 +313,13 @@ end
313
313
function (:: ∂⃖{N})(:: typeof (Base. getindex), a:: Array , inds... ) where {N}
314
314
getindex (a, inds... ), let
315
315
EvenOddOdd {1, c_order(N)} (
316
- (@Base . aggressive_constprop Δ-> begin
316
+ (@Base . constprop :aggressive Δ-> begin
317
317
Δ isa AbstractZero && return (NoTangent (), Δ, map (Returns (Δ), inds)... )
318
318
BB = zero (a)
319
319
BB[inds... ] = Δ
320
320
(NoTangent (), BB, map (x-> NoTangent (), inds)... )
321
321
end ),
322
- (@Base . aggressive_constprop (_, Δ, _)-> begin
322
+ (@Base . constprop :aggressive (_, Δ, _)-> begin
323
323
getindex (Δ, inds... )
324
324
end ))
325
325
end
@@ -355,15 +355,15 @@ end
355
355
356
356
struct ApplyOdd{O, P}; u; ∂⃖f; end
357
357
struct ApplyEven{O, P}; u; ∂⃖∂⃖f; end
358
- @Base . aggressive_constprop function (a:: ApplyOdd{O, P} )(Δ) where {O, P}
358
+ @Base . constprop :aggressive function (a:: ApplyOdd{O, P} )(Δ) where {O, P}
359
359
r, ∂⃖∂⃖f = a.∂⃖f (Δ)
360
360
(a. u (r), ApplyEven {plus1(O), P} (a. u, ∂⃖∂⃖f))
361
361
end
362
- @Base . aggressive_constprop function (a:: ApplyEven{O, P} )(_, _, ff, args... ) where {O, P}
362
+ @Base . constprop :aggressive function (a:: ApplyEven{O, P} )(_, _, ff, args... ) where {O, P}
363
363
r, ∂⃖∂⃖∂⃖f = Core. _apply_iterate (iterate, a.∂⃖∂⃖f, (ff,), args... )
364
364
(r, ApplyOdd {plus1(O), P} (a. u, ∂⃖∂⃖∂⃖f))
365
365
end
366
- @Base . aggressive_constprop function (a:: ApplyOdd{O, O} )(Δ) where {O}
366
+ @Base . constprop :aggressive function (a:: ApplyOdd{O, O} )(Δ) where {O}
367
367
r = a.∂⃖f (Δ)
368
368
a. u (r)
369
369
end
381
381
Core. apply_type (head, args... ), NonDiffOdd {plus1(plus1(length(args))), 1, c_order(N)} ()
382
382
end
383
383
384
- @Base . aggressive_constprop lifted_getfield (x, s) = getfield (x, s)
384
+ @Base . constprop :aggressive lifted_getfield (x, s) = getfield (x, s)
385
385
lifted_getfield (x:: ZeroTangent , s) = ZeroTangent ()
386
386
lifted_getfield (x:: NoTangent , s) = NoTangent ()
387
387
0 commit comments