Skip to content

Commit fa6c07d

Browse files
authored
[Docs] [AutoDiff] Rename '@nondiff' to '@noDerivative'.
We agreed to move to rename `@nondiff` to `@noDerivative` (in line with the `@noDerivative` declaration attribute) in #28278.
1 parent 3932133 commit fa6c07d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

docs/DifferentiableProgramming.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,13 +1827,13 @@ The `@differentiable` attribute requires the function type it is attached to
18271827
have differentiable parameters and results. Each parameter and result must
18281828
conform to the `Differentiable` protocol (or `Differentiable &
18291829
AdditiveArithmetic` when the attribute is `@differentiable(linear)`) unless it
1830-
is marked with `@nondiff`.
1830+
is marked with `@noDerivative`.
18311831

18321832
<p align="center">
18331833
<img src="assets/DifferentiableProgramming/differentiable-function-subtyping.png">
18341834
</p>
18351835

1836-
_Note: `@nondiff` stands for "not being differentiated", and will likely be
1836+
_Note: `@noDerivative` stands for "not being differentiated", and will likely be
18371837
unified with `@noDerivative`._
18381838

18391839
#### Type conversion
@@ -1899,13 +1899,13 @@ let f2: (Float) -> Float = f1
18991899
```
19001900

19011901
A `@differentiable` function can also be converted to a function which is
1902-
identical except that more of its parameters are marked with `@nondiff`.
1902+
identical except that more of its parameters are marked with `@noDerivative`.
19031903

19041904
```swift
19051905
func addOne(_ x: Float) -> Float { x + 1 }
19061906
let f0: @differentiable (Float, Float, Float) -> Float = addOne
1907-
let f1: @differentiable (@nondiff Float, Float, Float) -> Float = f0
1908-
let f2: @differentiable (@nondiff Float, Float, @nondiff Float) -> Float = f1
1907+
let f1: @differentiable (@noDerivative Float, Float, Float) -> Float = f0
1908+
let f2: @differentiable (@noDerivative Float, Float, @noDerivative Float) -> Float = f1
19091909
```
19101910

19111911
#### Implied generic constraints
@@ -1975,33 +1975,33 @@ Neural network trainer objects that store loss functions, e.g.
19751975
Like function declarations with a `@differentiable` attribute, differentiable
19761976
function values can also be differentiable with respect to a subset of
19771977
parameters. This is expressed as part of type information, in `@differentiable`
1978-
and `@differentiable(linear)` function types, using a `@nondiff` attribute at
1978+
and `@differentiable(linear)` function types, using a `@noDerivative` attribute at
19791979
each parameter that is not being differentiated with respect to.
19801980

19811981
By default, all parameters are being differentiated with respect to. When a
1982-
`@nondiff` attribute is specified for a parameter in a `@differentiable`
1982+
`@noDerivative` attribute is specified for a parameter in a `@differentiable`
19831983
function type, values of this function type are not differentiable (or linear)
19841984
with respect to the parameter.
19851985

19861986
```swift
19871987
let f0: @differentiable (Float, Float) -> Float = { $0 * $1 }
19881988
let f1: @differentiable(linear) (Float, Float) -> Float = { $0 + $1 }
1989-
let f2: @differentiable(linear) (Float, @nondiff Float) -> Float = { $0 * $1 }
1990-
let f3: @differentiable (@nondiff Int, Float, @nondiff Int) -> Float = {
1989+
let f2: @differentiable(linear) (Float, @noDerivative Float) -> Float = { $0 * $1 }
1990+
let f3: @differentiable (@noDerivative Int, Float, @noDerivative Int) -> Float = {
19911991
$0 ? Float($1) + $2 : 0
19921992
}
19931993
```
19941994

19951995
Differentiability of parameters in a function type is important for type
19961996
conversions and is part of the subtyping rule: Any `@differentiable` or
19971997
`@differentiable(linear)` function type is a subtype of the same function type
1998-
with more `@nondiff` parameters than there originally are.
1998+
with more `@noDerivative` parameters than there originally are.
19991999

20002000
```swift
20012001
let f0: @differentiable (Float, Float) -> Float = { $0 * $1 }
2002-
_ = f0 as @differentiable (Float, @nondiff Float) -> Float
2003-
_ = f0 as @differentiable (@nondiff Float, Float) -> Float
2004-
_ = f0 as @differentiable (@nondiff Float, @nondiff Float) -> Float
2002+
_ = f0 as @differentiable (Float, @noDerivative Float) -> Float
2003+
_ = f0 as @differentiable (@noDerivative Float, Float) -> Float
2004+
_ = f0 as @differentiable (@noDerivative Float, @noDerivative Float) -> Float
20052005
```
20062006

20072007
### Differentiable operators

0 commit comments

Comments
 (0)