@@ -23,10 +23,10 @@ import _Differentiation
2323@inlinable
2424public func valueWithGradient< T, R> (
2525 at x: T ,
26- in f: @differentiable ( T ) -> Tensor < R >
26+ in f: @differentiable ( reverse ) ( T ) -> Tensor < R >
2727) -> ( value: Tensor < R > , gradient: T . TangentVector )
2828where T: Differentiable , R: TensorFlowFloatingPoint {
29- let ( y, pullback) = valueWithPullback ( at: x, in : f)
29+ let ( y, pullback) = valueWithPullback ( at: x, of : f)
3030 precondition (
3131 y. rank == 0 ,
3232 """
@@ -40,10 +40,10 @@ where T: Differentiable, R: TensorFlowFloatingPoint {
4040public func valueWithGradient< T, U, R> (
4141 at x: T ,
4242 _ y: U ,
43- in f: @differentiable ( T , U ) -> Tensor < R >
43+ in f: @differentiable ( reverse ) ( T , U ) -> Tensor < R >
4444) -> ( value: Tensor < R > , gradient: ( T . TangentVector , U . TangentVector ) )
4545where T: Differentiable , U: Differentiable , R: TensorFlowFloatingPoint {
46- let ( y, pullback) = valueWithPullback ( at: x, y, in : f)
46+ let ( y, pullback) = valueWithPullback ( at: x, y, of : f)
4747 precondition (
4848 y. rank == 0 ,
4949 """
@@ -58,10 +58,10 @@ public func valueWithGradient<T, U, V, R>(
5858 at x: T ,
5959 _ y: U ,
6060 _ z: V ,
61- in f: @differentiable ( T , U , V ) -> Tensor < R >
61+ in f: @differentiable ( reverse ) ( T , U , V ) -> Tensor < R >
6262) -> ( value: Tensor < R > , gradient: ( T . TangentVector , U . TangentVector , V . TangentVector ) )
6363where T: Differentiable , U: Differentiable , V: Differentiable , R: TensorFlowFloatingPoint {
64- let ( y, pullback) = valueWithPullback ( at: x, y, z, in : f)
64+ let ( y, pullback) = valueWithPullback ( at: x, y, z, of : f)
6565 precondition ( y. rank == 0 )
6666 return ( y, pullbackOfOneLikeY ( y: y, pullback: pullback) )
6767}
@@ -70,23 +70,23 @@ where T: Differentiable, U: Differentiable, V: Differentiable, R: TensorFlowFloa
7070
7171@inlinable
7272public func valueWithGradient< T, R> (
73- of f: @escaping @differentiable ( T ) -> Tensor < R >
73+ of f: @escaping @differentiable ( reverse ) ( T ) -> Tensor < R >
7474) -> ( T ) -> ( value: Tensor < R > , gradient: T . TangentVector )
7575where T: Differentiable , R: TensorFlowFloatingPoint {
7676 return { x in valueWithGradient ( at: x, in: f) }
7777}
7878
7979@inlinable
8080public func valueWithGradient< T, U, R> (
81- of f: @escaping @differentiable ( T , U ) -> Tensor < R >
81+ of f: @escaping @differentiable ( reverse ) ( T , U ) -> Tensor < R >
8282) -> ( T , U ) -> ( value: Tensor < R > , gradient: ( T . TangentVector , U . TangentVector ) )
8383where T: Differentiable , U: Differentiable , R: TensorFlowFloatingPoint {
8484 return { x, y in valueWithGradient ( at: x, y, in: f) }
8585}
8686
8787@inlinable
8888public func valueWithGradient< T, U, V, R> (
89- of f: @escaping @differentiable ( T , U , V ) -> Tensor < R >
89+ of f: @escaping @differentiable ( reverse ) ( T , U , V ) -> Tensor < R >
9090) -> ( T , U , V ) -> (
9191 value: Tensor < R > ,
9292 gradient: ( T . TangentVector , U . TangentVector , V . TangentVector )
@@ -100,7 +100,7 @@ where T: Differentiable, U: Differentiable, V: Differentiable, R: TensorFlowFloa
100100@inlinable
101101public func gradient< T, R> (
102102 at x: T ,
103- in f: @differentiable ( T ) -> Tensor < R >
103+ in f: @differentiable ( reverse ) ( T ) -> Tensor < R >
104104) -> T . TangentVector where T: Differentiable , R: TensorFlowFloatingPoint {
105105 return valueWithGradient ( at: x, in: f) . 1
106106}
@@ -109,7 +109,7 @@ public func gradient<T, R>(
109109public func gradient< T, U, R> (
110110 at x: T ,
111111 _ y: U ,
112- in f: @differentiable ( T , U ) -> Tensor < R >
112+ in f: @differentiable ( reverse ) ( T , U ) -> Tensor < R >
113113) -> ( T . TangentVector , U . TangentVector )
114114where T: Differentiable , U: Differentiable , R: TensorFlowFloatingPoint {
115115 return valueWithGradient ( at: x, y, in: f) . 1
@@ -120,7 +120,7 @@ public func gradient<T, U, V, R>(
120120 at x: T ,
121121 _ y: U ,
122122 _ z: V ,
123- in f: @differentiable ( T , U , V ) -> Tensor < R >
123+ in f: @differentiable ( reverse ) ( T , U , V ) -> Tensor < R >
124124) -> ( T . TangentVector , U . TangentVector , V . TangentVector )
125125where T: Differentiable , U: Differentiable , V: Differentiable , R: TensorFlowFloatingPoint {
126126 return valueWithGradient ( at: x, y, z, in: f) . 1
@@ -130,22 +130,22 @@ where T: Differentiable, U: Differentiable, V: Differentiable, R: TensorFlowFloa
130130
131131@inlinable
132132public func gradient< T, R> (
133- of f: @escaping @differentiable ( T ) -> Tensor < R >
133+ of f: @escaping @differentiable ( reverse ) ( T ) -> Tensor < R >
134134) -> ( T ) -> T . TangentVector where T: Differentiable , R: TensorFlowFloatingPoint {
135135 return { x in gradient ( at: x, in: f) }
136136}
137137
138138@inlinable
139139public func gradient< T, U, R> (
140- of f: @escaping @differentiable ( T , U ) -> Tensor < R >
140+ of f: @escaping @differentiable ( reverse ) ( T , U ) -> Tensor < R >
141141) -> ( T , U ) -> ( T . TangentVector , U . TangentVector )
142142where T: Differentiable , U: Differentiable , R: TensorFlowFloatingPoint {
143143 return { x, y in gradient ( at: x, y, in: f) }
144144}
145145
146146@inlinable
147147public func gradient< T, U, V, R> (
148- of f: @escaping @differentiable ( T , U , V ) -> Tensor < R >
148+ of f: @escaping @differentiable ( reverse ) ( T , U , V ) -> Tensor < R >
149149) -> ( T , U , V ) -> ( T . TangentVector , U . TangentVector , V . TangentVector )
150150where T: Differentiable , U: Differentiable , V: Differentiable , R: TensorFlowFloatingPoint {
151151 return { x, y, z in gradient ( at: x, y, z, in: f) }
0 commit comments