@@ -1827,13 +1827,13 @@ The `@differentiable` attribute requires the function type it is attached to
1827
1827
have differentiable parameters and results. Each parameter and result must
1828
1828
conform to the ` Differentiable ` protocol (or `Differentiable &
1829
1829
AdditiveArithmetic` when the attribute is ` @differentiable(linear)`) unless it
1830
- is marked with ` @nondiff ` .
1830
+ is marked with ` @noDerivative ` .
1831
1831
1832
1832
<p align =" center " >
1833
1833
<img src =" assets/DifferentiableProgramming/differentiable-function-subtyping.png " >
1834
1834
</p >
1835
1835
1836
- _ Note: ` @nondiff ` stands for "not being differentiated", and will likely be
1836
+ _ Note: ` @noDerivative ` stands for "not being differentiated", and will likely be
1837
1837
unified with ` @noDerivative ` ._
1838
1838
1839
1839
#### Type conversion
@@ -1899,13 +1899,13 @@ let f2: (Float) -> Float = f1
1899
1899
```
1900
1900
1901
1901
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 ` .
1903
1903
1904
1904
``` swift
1905
1905
func addOne (_ x : Float ) -> Float { x + 1 }
1906
1906
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
1909
1909
```
1910
1910
1911
1911
#### Implied generic constraints
@@ -1975,33 +1975,33 @@ Neural network trainer objects that store loss functions, e.g.
1975
1975
Like function declarations with a ` @differentiable ` attribute, differentiable
1976
1976
function values can also be differentiable with respect to a subset of
1977
1977
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
1979
1979
each parameter that is not being differentiated with respect to.
1980
1980
1981
1981
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 `
1983
1983
function type, values of this function type are not differentiable (or linear)
1984
1984
with respect to the parameter.
1985
1985
1986
1986
``` swift
1987
1987
let f0: @differentiable (Float , Float ) -> Float = { $0 * $1 }
1988
1988
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 = {
1991
1991
$0 ? Float ($1 ) + $2 : 0
1992
1992
}
1993
1993
```
1994
1994
1995
1995
Differentiability of parameters in a function type is important for type
1996
1996
conversions and is part of the subtyping rule: Any ` @differentiable ` or
1997
1997
` @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.
1999
1999
2000
2000
``` swift
2001
2001
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
2005
2005
```
2006
2006
2007
2007
### Differentiable operators
0 commit comments