mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Previously, two conditions were necessary to enable differentiable programming: - Using the `-enable-experimental-differentiable-programming` frontend flag. - Importing the `_Differentiation` module. Importing the `_Differentiation` module is the true condition because it contains the required compiler-known `Differentiable` protocol. The frontend flag is redundant and cumbersome. Now, the frontend flag is removed. Importing `_Differentiation` is the only condition.
24 lines
999 B
Swift
24 lines
999 B
Swift
// RUN: %target-swift-frontend -typecheck -verify %s
|
|
|
|
// expected-error @+1 {{'@differentiable' attribute used without importing module '_Differentiation'}}
|
|
let _: @differentiable (Float) -> Float
|
|
|
|
// expected-error @+2 {{'@differentiable' attribute used without importing module '_Differentiation'}}
|
|
// expected-error @+1 {{'@noDerivative' attribute used without importing module '_Differentiation'}}
|
|
let _: @differentiable (Float, @noDerivative Float) -> Float
|
|
|
|
// expected-error @+1 {{'@noDerivative' attribute used without importing module '_Differentiation'}}
|
|
let _: (Float, @noDerivative Float) -> Float
|
|
|
|
// expected-error @+1 {{'@noDerivative' attribute used without importing module '_Differentiation'}}
|
|
let _: @noDerivative Float
|
|
|
|
func id(_ x: Float) -> Float {
|
|
return x
|
|
}
|
|
// expected-error @+1 {{@derivative attribute used without importing module '_Differentiation'}}
|
|
@derivative(of: id)
|
|
func jvpId(x: Float) -> (value: Float, differential: (Float) -> (Float)) {
|
|
return (x, { $0 })
|
|
}
|