From 7e09871bec23e62a646aba88bfd0a5529e2b44e6 Mon Sep 17 00:00:00 2001 From: Frames White Date: Thu, 28 Dec 2023 16:48:21 +0800 Subject: [PATCH] Remove example of mutation support config from docs --- .../src/rule_author/superpowers/ruleconfig.md | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/docs/src/rule_author/superpowers/ruleconfig.md b/docs/src/rule_author/superpowers/ruleconfig.md index bd74fc0fb..7d22fd450 100644 --- a/docs/src/rule_author/superpowers/ruleconfig.md +++ b/docs/src/rule_author/superpowers/ruleconfig.md @@ -59,35 +59,11 @@ end The `>:HasReverseMode` and `>:HasForwardsMode` are two examples of special properties that a `RuleConfig` could allow. Others could also exist, but right now they are the only two. -It is likely that in the future such will be provided for e.g. mutation support. - -Such a thing would look like: -```julia -struct SupportsMutation end - -function rrule( - ::RuleConfig{>:SupportsMutation}, typeof(push!), x::Vector -) - y = push!(x) - - function push!_pullback(ȳ) - pop!(x) # undo change to primal incase it is used in another pullback we haven't called yet - pop!(ȳ) # accumulate gradient via mutating ȳ, then return ZeroTangent - return NoTangent(), ZeroTangent() - end - - return y, push!_pullback -end -``` -and it would be used in the AD e.g. as follows: -```julia -struct EnzymeRuleConfig <: RuleConfig{Union{SupportsMutation, HasReverseMode, NoForwardsMode}} -``` +It is likely that in the future other such will be provided Note: you can only depend on the presence of a feature, not its absence. 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).). - Such special properties generally should only be defined in `ChainRulesCore`. (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.)