@@ -34,7 +34,7 @@ This document explains how differentiation is implemented in the Swift compiler,
34
34
35
35
``` swift
36
36
// From the standard library:
37
- // func gradient<T, R>(at x: T, in f: @differentiable (T) -> R) -> T.TangentVector
37
+ // func gradient<T, R>(at x: T, of f: @differentiable (T) -> R) -> T.TangentVector
38
38
// where R: FloatingPoint, R.TangentVector == R
39
39
40
40
// 1. What does the `@differentiable` attribute do?
@@ -51,7 +51,7 @@ func cubed(_ x: Float) -> Float {
51
51
// transform generates derivative functions for the closure expression. The
52
52
// `gradient` higher-order function extracts and applies a derivative function to
53
53
// evaluate a gradient value.
54
- gradient (at : 4 , in : { x in x * x * x }) // 48.0
54
+ gradient (at : 4 , of : { x in x * x * x }) // 48.0
55
55
```
56
56
57
57
> NOTE:
@@ -397,13 +397,13 @@ func cubed(_ x: Float) -> Float {
397
397
// %cubed = differentiable_function [wrt 0] %closure_ref
398
398
// with {%closure_jvp_ref, %closure_vjp_ref}
399
399
400
- gradient (at : Float (4 ), in : { x in x * x * x })
400
+ gradient (at : Float (4 ), of : { x in x * x * x })
401
401
402
402
// Swift supports implicit function conversions, which happens above.
403
403
// Below is what the conversion looks like explicitly:
404
404
// let foo: (Float) -> Float = { x in x * x * x }
405
405
// let cubed: @differentiable (Float) -> Float = foo
406
- // gradient(at: Float(4), in : cubed)
406
+ // gradient(at: Float(4), of : cubed)
407
407
```
408
408
409
409
> TODO: Update the \[ differentiable\] attribute directly above the Swift declaration of ` cubed(_:) ` with a SIL differentiability witness.
0 commit comments