Skip to content

Commit 6664e8f

Browse files
authored
Merge pull request #646 from JuliaDiff/ox/nomutationexample
Remove example of mutation support config from docs
2 parents 1b0e41a + 7e09871 commit 6664e8f

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

docs/src/rule_author/superpowers/ruleconfig.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,11 @@ end
5959

6060
The `>:HasReverseMode` and `>:HasForwardsMode` are two examples of special properties that a `RuleConfig` could allow.
6161
Others could also exist, but right now they are the only two.
62-
It is likely that in the future such will be provided for e.g. mutation support.
63-
64-
Such a thing would look like:
65-
```julia
66-
struct SupportsMutation end
67-
68-
function rrule(
69-
::RuleConfig{>:SupportsMutation}, typeof(push!), x::Vector
70-
)
71-
y = push!(x)
72-
73-
function push!_pullback(ȳ)
74-
pop!(x) # undo change to primal incase it is used in another pullback we haven't called yet
75-
pop!(ȳ) # accumulate gradient via mutating ȳ, then return ZeroTangent
76-
return NoTangent(), ZeroTangent()
77-
end
78-
79-
return y, push!_pullback
80-
end
81-
```
82-
and it would be used in the AD e.g. as follows:
83-
```julia
84-
struct EnzymeRuleConfig <: RuleConfig{Union{SupportsMutation, HasReverseMode, NoForwardsMode}}
85-
```
62+
It is likely that in the future other such will be provided
8663

8764
Note: you can only depend on the presence of a feature, not its absence.
8865
This means we may need to define features and their complements, when one is not the obvious default (as in the case of [`HasReverseMode`](@ref)/[`NoReverseMode`](@ref) and [`HasForwardsMode`](@ref)/[`NoForwardsMode`](@ref).).
8966

90-
9167
Such special properties generally should only be defined in `ChainRulesCore`.
9268
(Theoretically, they could be defined elsewhere, but the AD and the package containing the rule need to load them, and ChainRulesCore is the place for things like that.)
9369

0 commit comments

Comments
 (0)