Files
Anton Korobeynikov f861e3d3bb Initial version of autodiff activity analysis for async functions (#93158)
In addition:

- Preliminary version of differential operators (we're currently debating if Differentiable implies Sendable)
- Some projection adjoints
2026-10-16 00:13:33 -07:00

29 lines
688 B
Swift

// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking)
// REQUIRES: executable_test
// REQUIRES: concurrency
// REQUIRES: concurrency_runtime
import _Concurrency
import StdlibUnittest
import DifferentiationUnittest
var AsyncTests = TestSuite("Async")
@_semantics("autodiff.opaque")
func iidentity(_ x: Float) async -> Float { x }
@derivative(of: iidentity)
func vjpIdentity(_ x: Float) async -> (value: Float, pullback: (Float) -> Float) {
(x, { $0 })
}
AsyncTests.test("CustomVJP") {
let (value, pullback) = await valueWithPullback(at: Float(42.0), of: iidentity)
expectEqual(42.0, value)
expectEqual(2.0, pullback(2.0))
}
await runAllTestsAsync()