@@ -1827,13 +1827,13 @@ The `@differentiable` attribute requires the function type it is attached to
18271827have differentiable parameters and results. Each parameter and result must
18281828conform to the ` Differentiable ` protocol (or `Differentiable &
18291829AdditiveArithmetic` 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
18371837unified with ` @noDerivative ` ._
18381838
18391839#### Type conversion
@@ -1899,13 +1899,13 @@ let f2: (Float) -> Float = f1
18991899```
19001900
19011901A ` @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
19051905func addOne (_ x : Float ) -> Float { x + 1 }
19061906let 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.
19751975Like function declarations with a ` @differentiable ` attribute, differentiable
19761976function values can also be differentiable with respect to a subset of
19771977parameters. 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
19791979each parameter that is not being differentiated with respect to.
19801980
19811981By 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 `
19831983function type, values of this function type are not differentiable (or linear)
19841984with respect to the parameter.
19851985
19861986``` swift
19871987let f0: @differentiable (Float , Float ) -> Float = { $0 * $1 }
19881988let 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
19951995Differentiability of parameters in a function type is important for type
19961996conversions 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
20012001let 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