@@ -1827,15 +1827,12 @@ 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
1837
- unified with ` @noDerivative ` ._
1838
-
1839
1836
#### Type conversion
1840
1837
1841
1838
The subtyping relation among ` @differentiable(linear) ` , ` @differentiable ` , and
@@ -1899,13 +1896,13 @@ let f2: (Float) -> Float = f1
1899
1896
```
1900
1897
1901
1898
A ` @differentiable ` function can also be converted to a function which is
1902
- identical except that more of its parameters are marked with ` @nondiff ` .
1899
+ identical except that more of its parameters are marked with ` @noDerivative ` .
1903
1900
1904
1901
``` swift
1905
1902
func addOne (_ x : Float ) -> Float { x + 1 }
1906
1903
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
1904
+ let f1: @differentiable (@noDerivative Float , Float , Float ) -> Float = f0
1905
+ let f2: @differentiable (@noDerivative Float , Float , @noDerivative Float ) -> Float = f1
1909
1906
```
1910
1907
1911
1908
#### Implied generic constraints
@@ -1975,33 +1972,33 @@ Neural network trainer objects that store loss functions, e.g.
1975
1972
Like function declarations with a ` @differentiable ` attribute, differentiable
1976
1973
function values can also be differentiable with respect to a subset of
1977
1974
parameters. This is expressed as part of type information, in ` @differentiable `
1978
- and ` @differentiable(linear) ` function types, using a ` @nondiff ` attribute at
1975
+ and ` @differentiable(linear) ` function types, using a ` @noDerivative ` attribute at
1979
1976
each parameter that is not being differentiated with respect to.
1980
1977
1981
1978
By default, all parameters are being differentiated with respect to. When a
1982
- ` @nondiff ` attribute is specified for a parameter in a ` @differentiable `
1979
+ ` @noDerivative ` attribute is specified for a parameter in a ` @differentiable `
1983
1980
function type, values of this function type are not differentiable (or linear)
1984
1981
with respect to the parameter.
1985
1982
1986
1983
``` swift
1987
1984
let f0: @differentiable (Float , Float ) -> Float = { $0 * $1 }
1988
1985
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 = {
1986
+ let f2: @differentiable (linear) (Float , @noDerivative Float ) -> Float = { $0 * $1 }
1987
+ let f3: @differentiable (@noDerivative Int , Float , @noDerivative Int ) -> Float = {
1991
1988
$0 ? Float ($1 ) + $2 : 0
1992
1989
}
1993
1990
```
1994
1991
1995
1992
Differentiability of parameters in a function type is important for type
1996
1993
conversions and is part of the subtyping rule: Any ` @differentiable ` or
1997
1994
` @differentiable(linear) ` function type is a subtype of the same function type
1998
- with more ` @nondiff ` parameters than there originally are.
1995
+ with more ` @noDerivative ` parameters than there originally are.
1999
1996
2000
1997
``` swift
2001
1998
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
1999
+ _ = f0 as @differentiable (Float , @noDerivative Float ) -> Float
2000
+ _ = f0 as @differentiable (@noDerivative Float , Float ) -> Float
2001
+ _ = f0 as @differentiable (@noDerivative Float , @noDerivative Float ) -> Float
2005
2002
```
2006
2003
2007
2004
### Differentiable operators
0 commit comments