mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
- Ensure it really accumulates the adjoint buffer - Handle Optional.none case when there is no value to propagate to Fixes #75280
14 lines
469 B
Swift
14 lines
469 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify %s
|
|
|
|
// https://github.com/swiftlang/swift/issues/75280
|
|
// Ensure we accumulate adjoints properly for inject_enum_addr instructions and
|
|
// handle `nil` case (no adjoint value to propagate)
|
|
|
|
|
|
import _Differentiation
|
|
@differentiable(reverse) func a<F, A>(_ f: Optional<F>, c: @differentiable(reverse) (F) -> A) -> Optional<A> where F: Differentiable, A: Differentiable
|
|
{
|
|
guard let f else {return nil}
|
|
return c(f)
|
|
}
|