Skip to content

Commit 95e63d0

Browse files
committed
improve docs
1 parent 2d61f41 commit 95e63d0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/src/rule_author/superpowers/mutation_support.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ There are a few key points to follow:
4141
- There must be a mutable tangent input for every mutated primal input
4242
- When the primal value is changed, the corresponding change must be made to its tangent partner
4343
- When a value is returned, return its partnered tangent.
44-
44+
- If two primals alias, then their tangents must also alias.
4545

4646
### Example
4747
For example, consider the primal function with:
@@ -61,14 +61,14 @@ end
6161

6262
The frule for this would be:
6363
```julia
64-
function ChainRulesCore.frule((ȧ, ḃ), ::typeof(foo!), a::Base.RefValue, b::Base.RefValue)
64+
function ChainRulesCore.frule((_, ȧ, ḃ), ::typeof(foo!), a::Base.RefValue, b::Base.RefValue)
6565
@assertisa MutableTangent{typeof(a)}
6666
@assertisa MutableTangent{typeof(b)}
6767

6868
a[] *= 2
6969
.x *= 2 # `.x` is the field that lives behind RefValues
7070

71-
b[]=5.0
71+
b[] = 5.0
7272
.x = zero_tangent(5.0) # or since we know that the zero for a Float64 is zero could write `ḃ.x = 0.0`
7373

7474
return a, ȧ

0 commit comments

Comments
 (0)