Skip to content

Commit 17ab3b9

Browse files
authored
Fix various AD tests. (#24557)
- Add `[ossa]` tags. - Add expected note for `differentiable_attr_type_checking.swift`.
1 parent 3edf725 commit 17ab3b9

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

test/AutoDiff/derived_differentiable_properties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct Foo : Differentiable {
1818
// CHECK-AST: public typealias CotangentVector = Foo.AllDifferentiableVariables
1919

2020
// CHECK-SILGEN-LABEL: // Foo.a.getter
21-
// CHECK-SILGEN-NEXT: sil [transparent] [serialized] [differentiable source 0 wrt 0] @$s33derived_differentiable_properties3FooV1aSfvg : $@convention(method) (Foo) -> Float
21+
// CHECK-SILGEN-NEXT: sil [transparent] [serialized] [differentiable source 0 wrt 0] [ossa] @$s33derived_differentiable_properties3FooV1aSfvg : $@convention(method) (Foo) -> Float
2222

2323
struct AdditiveTangentIsSelf : AdditiveArithmetic, Differentiable {
2424
var a: Float

test/AutoDiff/differentiable_attr_silgen.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ public func foo(_ x: Float, _ y: Float) -> Float {
1010
return 1
1111
}
1212

13-
// CHECK-LABEL: sil [differentiable source 0 wrt 0, 1 vjp @dfoo] @foo
13+
// CHECK-LABEL: sil [differentiable source 0 wrt 0, 1 vjp @dfoo] [ossa] @foo
1414

1515
@_silgen_name("dfoo")
1616
public func dfoo(_ x: Float, _ y: Float) -> (Float, (Float) -> (Float, Float)) {
1717
return (foo(x, y), { _ in (1, 1) })
1818
}
1919

20-
// CHECK-LABEL: sil @dfoo
20+
// CHECK-LABEL: sil [ossa] @dfoo
2121

2222
//===----------------------------------------------------------------------===//
2323
// Indirect returns
@@ -29,8 +29,8 @@ public func foo_indir_ret<T: Differentiable>(_ x: Float, _ y: T) -> T {
2929
return y
3030
}
3131

32-
// CHECK-LABEL: sil [differentiable source 0 wrt 0, 1 vjp @dfoo_indir_ret] @foo_indir_ret : $@convention(thin) <T where T : Differentiable> (Float, @in_guaranteed T) -> @out T {
33-
// CHECK: bb0(%0 : @trivial $*T, %1 : @trivial $Float, %2 : @trivial $*T):
32+
// CHECK-LABEL: sil [differentiable source 0 wrt 0, 1 vjp @dfoo_indir_ret] [ossa] @foo_indir_ret : $@convention(thin) <T where T : Differentiable> (Float, @in_guaranteed T) -> @out T {
33+
// CHECK: bb0(%0 : $*T, %1 : $Float, %2 : $*T):
3434

3535
@_silgen_name("dfoo_indir_ret")
3636
public func dfoo_indir_ret<T: Differentiable>(_ x: Float, _ y: T) -> (T, (T.CotangentVector) -> (Float, T.CotangentVector)) {
@@ -47,14 +47,14 @@ public func hasjvp(_ x: Float, _ y: Float) -> Float {
4747
return 1
4848
}
4949

50-
// CHECK-LABEL: sil [differentiable source 0 wrt 0, 1 jvp @dhasjvp] @hasjvp
50+
// CHECK-LABEL: sil [differentiable source 0 wrt 0, 1 jvp @dhasjvp] [ossa] @hasjvp
5151

5252
@_silgen_name("dhasjvp")
5353
public func dhasjvp(_ x: Float, _ y: Float) -> (Float, (Float, Float) -> Float) {
5454
return (1, { _, _ in 1 })
5555
}
5656

57-
// CHECK-LABEL: sil @dhasjvp
57+
// CHECK-LABEL: sil [ossa] @dhasjvp
5858

5959
//===----------------------------------------------------------------------===//
6060
// VJP
@@ -67,14 +67,14 @@ public func hasvjp(_ x: Float, _ y: Float) -> Float {
6767
return 1
6868
}
6969

70-
// CHECK-LABEL: sil [serialized] [differentiable source 0 wrt 0, 1 vjp @dhasvjp] @hasvjp
70+
// CHECK-LABEL: sil [serialized] [differentiable source 0 wrt 0, 1 vjp @dhasvjp] [ossa] @hasvjp
7171

7272
@_silgen_name("dhasvjp")
7373
public func dhasvjp(_ x: Float, _ y: Float) -> (Float, (Float) -> (Float, Float)) {
7474
return (1, { _ in (1, 1) })
7575
}
7676

77-
// CHECK-LABEL: sil @dhasvjp
77+
// CHECK-LABEL: sil [ossa] @dhasvjp
7878

7979
//===----------------------------------------------------------------------===//
8080
// Stored property
@@ -163,4 +163,4 @@ public struct MyLayer: Differentiable {
163163
}
164164

165165
// CHECK-LABEL: initialization expression of MyLayer.x
166-
// CHECK-NEXT: sil [transparent] @$s26differentiable_attr_silgen7MyLayerV1xSfvpfi : $@convention(thin) () -> Float
166+
// CHECK-NEXT: sil [transparent] [ossa] @$s26differentiable_attr_silgen7MyLayerV1xSfvpfi : $@convention(thin) () -> Float

test/AutoDiff/differentiable_attr_type_checking.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,9 @@ func vjpNonvariadic(_ x: Float, indices: [Int32]) -> (Float, (Float) -> Float) {
564564
return (x, { $0 })
565565
}
566566

567-
// expected-error @+2 {{type 'Scalar' constrained to non-protocol, non-class type 'Float'}}
568-
// expected-error @+1 {{can only differentiate with respect to parameters that conform to 'Differentiable', but 'Scalar' does not conform to 'Differentiable'}}
567+
// expected-error @+3 {{type 'Scalar' constrained to non-protocol, non-class type 'Float'}}
568+
// expected-error @+2 {{can only differentiate with respect to parameters that conform to 'Differentiable', but 'Scalar' does not conform to 'Differentiable'}}
569+
// expected-note @+1 {{use 'Scalar == Float' to require 'Scalar' to be 'Float'}}
569570
@differentiable(where Scalar : Float)
570571
func invalidRequirementConformance<Scalar>(x: Scalar) -> Scalar {
571572
return x

0 commit comments

Comments
 (0)