@@ -34,7 +34,7 @@ This document explains how differentiation is implemented in the Swift compiler,
3434
3535``` swift
3636// 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
3838// where R: FloatingPoint, R.TangentVector == R
3939
4040// 1. What does the `@differentiable` attribute do?
@@ -51,7 +51,7 @@ func cubed(_ x: Float) -> Float {
5151// transform generates derivative functions for the closure expression. The
5252// `gradient` higher-order function extracts and applies a derivative function to
5353// 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
5555```
5656
5757> NOTE:
@@ -397,13 +397,13 @@ func cubed(_ x: Float) -> Float {
397397// %cubed = differentiable_function [wrt 0] %closure_ref
398398// with {%closure_jvp_ref, %closure_vjp_ref}
399399
400- gradient (at : Float (4 ), in : { x in x * x * x })
400+ gradient (at : Float (4 ), of : { x in x * x * x })
401401
402402// Swift supports implicit function conversions, which happens above.
403403// Below is what the conversion looks like explicitly:
404404// let foo: (Float) -> Float = { x in x * x * x }
405405// let cubed: @differentiable (Float) -> Float = foo
406- // gradient(at: Float(4), in : cubed)
406+ // gradient(at: Float(4), of : cubed)
407407```
408408
409409> TODO: Update the \[ differentiable\] attribute directly above the Swift declaration of ` cubed(_:) ` with a SIL differentiability witness.
0 commit comments