Skip to content

Commit ce2fe03

Browse files
authored
Merge pull request swiftlang#40813 from rxwei/rid-of-requirement-machine-flag
2 parents 3987cb2 + a1cb9bb commit ce2fe03

File tree

2 files changed

+58
-11
lines changed

2 files changed

+58
-11
lines changed

test/AutoDiff/SILOptimizer/differentiation_diagnostics.swift

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-sil -requirement-machine=off -verify %s
1+
// RUN: %target-swift-frontend -emit-sil -verify %s
22

33
// Test differentiation transform diagnostics.
44

@@ -773,27 +773,31 @@ public func fragileDifferentiable(_ x: Float) -> Float {
773773
implicitlyDifferentiableFromFragile(x)
774774
}
775775

776+
777+
// FIXME(rdar://87429620): Differentiable curry thunk RequirementMachine error.
778+
#if false
776779
// TF-1208: Test curry thunk differentiation regression.
777-
public struct TF_1208_Struct<Scalar> {
780+
public struct SR_14228_Struct<Scalar> {
778781
var x: Scalar
779782
}
780-
extension TF_1208_Struct: Differentiable where Scalar: Differentiable {
783+
extension SR_14228_Struct: Differentiable where Scalar: Differentiable {
781784
@differentiable(reverse)
782785
public static func id(x: Self) -> Self {
783786
return x
784787
}
785788
}
786789
@differentiable(reverse, wrt: x)
787-
public func TF_1208<Scalar: Differentiable>(
788-
_ x: TF_1208_Struct<Scalar>,
789-
// NOTE(TF-1208): This diagnostic is unexpected because `TF_1208_Struct.id` is marked `@differentiable`.
790-
// expected-error @+3 2 {{function is not differentiable}}
791-
// expected-note @+2 {{differentiated functions in '@inlinable' functions must be marked '@differentiable' or have a public '@derivative'; this is not possible with a closure, make a top-level function instead}}
792-
// expected-note @+1 {{opaque non-'@differentiable' function is not differentiable}}
793-
reduction: @differentiable(reverse) (TF_1208_Struct<Scalar>) -> TF_1208_Struct<Scalar> = TF_1208_Struct.id
794-
) -> TF_1208_Struct<Scalar> {
790+
public func SR_14228<Scalar: Differentiable>(
791+
_ x: SR_14228_Struct<Scalar>,
792+
// NOTE(TF-1208): This diagnostic is unexpected because `SR_14228_Struct.id` is marked `@differentiable`.
793+
// xpected-error @+3 2 {{function is not differentiable}}
794+
// xpected-note @+2 {{differentiated functions in '@inlinable' functions must be marked '@differentiable' or have a public '@derivative'; this is not possible with a closure, make a top-level function instead}}
795+
// xpected-note @+1 {{opaque non-'@differentiable' function is not differentiable}}
796+
reduction: @differentiable(reverse) (SR_14228_Struct<Scalar>) -> SR_14228_Struct<Scalar> = SR_14228_Struct.id
797+
) -> SR_14228_Struct<Scalar> {
795798
reduction(x)
796799
}
800+
#endif
797801

798802
//===----------------------------------------------------------------------===//
799803
// Coroutines (SIL function yields, `begin_apply`) (not yet supported)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %target-swift-frontend -emit-sil -verify %s
2+
// XFAIL: *
3+
4+
// rdar://87429620 (Differentiable curry thunk RequirementMachine error)
5+
6+
import _Differentiation
7+
8+
public struct SR_14228_Struct<Scalar> {
9+
var x: Scalar
10+
}
11+
12+
extension SR_14228_Struct: Differentiable where Scalar: Differentiable {
13+
@differentiable(reverse)
14+
public static func id(x: Self) -> Self {
15+
return x
16+
}
17+
}
18+
19+
@differentiable(reverse, wrt: x)
20+
public func SR_14228<Scalar: Differentiable>(
21+
_ x: SR_14228_Struct<Scalar>,
22+
reduction: @differentiable(reverse) (SR_14228_Struct<Scalar>) -> SR_14228_Struct<Scalar> = SR_14228_Struct.id
23+
) -> SR_14228_Struct<Scalar> {
24+
reduction(x)
25+
}
26+
27+
// Invalid type parameter in getCanonicalTypeInContext()
28+
// Original type: τ_0_0.TangentVector
29+
// Simplified term: τ_0_0.[Differentiable:TangentVector]
30+
// Longest valid prefix: τ_0_0
31+
// Prefix type: τ_0_0
32+
//
33+
// Requirement machine for <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 == τ_0_1, τ_0_2 == τ_0_3>
34+
// Rewrite system: {
35+
// - τ_0_1 => τ_0_0 [explicit]
36+
// - τ_0_3 => τ_0_2 [explicit]
37+
// }
38+
// Rewrite loops: {
39+
// }
40+
// Property map: {
41+
// }
42+
// Conformance access paths: {
43+
// }

0 commit comments

Comments
 (0)