Skip to content

Commit

Permalink
Merge pull request #60992 from AnthonyLatsis/migrate-test-suite-to-gh…
Browse files Browse the repository at this point in the history
…-issues-25

Gardening: Migrate test suite to GH issues p. 25
  • Loading branch information
AnthonyLatsis committed Sep 24, 2022
2 parents 7f63b4b + bd28606 commit 6907933
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 62 deletions.
@@ -1,11 +1,14 @@
// RUN: %empty-directory(%t)
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name main
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.sil -module-name main
// NOTE(SR-12090): Workaround because import declarations are not preserved in .sib files.

// https://github.com/apple/swift/issues/54526
// Workaround because import declarations are not preserved in .sib files.
// RUN: sed -e 's/import Swift$/import Swift; import _Differentiation/' %t/tmp.sil > %t/tmp_fixed.sil
// RUN: %target-sil-opt %t/tmp_fixed.sil -module-name main -emit-sorted-sil | %FileCheck %s

// NOTE(SR-12090): `shell` is required only to run `sed` as a SR-12090 workaround.
// `shell` is required only to run `sed` as a
// https://github.com/apple/swift/issues/54526 workaround.
// REQUIRES: shell

sil_stage raw
Expand Down
7 changes: 5 additions & 2 deletions test/AutoDiff/SIL/differentiability_witness_function_inst.sil
Expand Up @@ -7,7 +7,9 @@
// RUN: %empty-directory(%t)
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name main
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.sil -module-name main
// NOTE(SR-12090): Workaround because import declarations are not preserved in .sib files.

// https://github.com/apple/swift/issues/54526
// Workaround because import declarations are not preserved in .sib files.
// RUN: sed -e 's/import Swift$/import Swift; import _Differentiation/' %t/tmp.sil > %t/tmp_fixed.sil
// RUN: %target-sil-opt %t/tmp_fixed.sil -module-name main -emit-sorted-sil | %FileCheck %s

Expand All @@ -16,7 +18,8 @@
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s --check-prefix=IRGEN --check-prefix %target-cpu
// NOTE: `%target-cpu`-specific FileCheck lines exist because lowered function types in LLVM IR differ between architectures.

// NOTE(SR-12090): `shell` is required only to run `sed` as a SR-12090 workaround.
// `shell` is required only to run `sed` as a
// https://github.com/apple/swift/issues/54526 workaround.
// REQUIRES: shell

sil_stage raw
Expand Down
Expand Up @@ -11,11 +11,13 @@
// RUN: %empty-directory(%t)
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name main
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.sil -module-name main
// NOTE(SR-12090): Workaround because import declarations are not preserved in .sib files.
// https://github.com/apple/swift/issues/54526
// Workaround because import declarations are not preserved in .sib files.
// RUN: sed -e 's/import Swift$/import Swift; import _Differentiation/' %t/tmp.sil > %t/tmp_fixed.sil
// RUN: %target-sil-opt %t/tmp_fixed.sil -module-name main -emit-sorted-sil | %FileCheck %s

// NOTE(SR-12090): `shell` is required only to run `sed` as a SR-12090 workaround.
// `shell` is required only to run `sed` as a
// https://github.com/apple/swift/issues/54526 workaround.
// REQUIRES: shell

sil_stage raw
Expand Down
7 changes: 5 additions & 2 deletions test/AutoDiff/SIL/differentiable_function_inst.sil
Expand Up @@ -7,15 +7,18 @@
// RUN: %empty-directory(%t)
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name main
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.sil -module-name main
// NOTE(SR-12090): Workaround because import declarations are not preserved in .sib files.

// https://github.com/apple/swift/issues/54526
// Workaround because import declarations are not preserved in .sib files.
// RUN: sed -e 's/import Swift$/import Swift; import _Differentiation/' %t/tmp.sil > %t/tmp_fixed.sil
// RUN: %target-sil-opt %t/tmp_fixed.sil -module-name main -emit-sorted-sil | %FileCheck %s --check-prefix=CHECK-SIL

// IRGen test.

// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s --check-prefix=CHECK-IRGEN

// NOTE(SR-12090): `shell` is required only to run `sed` as a SR-12090 workaround.
// `shell` is required only to run `sed` as a
// https://github.com/apple/swift/issues/54526 workaround.
// REQUIRES: shell

// Would need to update for arm64e.
Expand Down
4 changes: 3 additions & 1 deletion test/AutoDiff/SIL/linear_function_inst.sil
Expand Up @@ -7,7 +7,9 @@
// RUN: %empty-directory(%t)
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name main
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.sil -module-name main
// NOTE(SR-12090): Workaround because import declarations are not preserved in .sib files.

// https://github.com/apple/swift/issues/54526
// Workaround because import declarations are not preserved in .sib files.
// RUN: sed -e 's/import Swift$/import Swift; import _Differentiation/' %t/tmp.sil > %t/tmp_fixed.sil
// RUN: %target-sil-opt %t/tmp_fixed.sil -module-name main -emit-sorted-sil | %FileCheck %s --check-prefix=CHECK-SIL

Expand Down
7 changes: 5 additions & 2 deletions test/AutoDiff/SIL/sil_differentiability_witness.sil
Expand Up @@ -7,15 +7,18 @@
// RUN: %empty-directory(%t)
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name main
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.sil -module-name main
// NOTE(SR-12090): Workaround because import declarations are not preserved in .sib files.

// https://github.com/apple/swift/issues/54526
// Workaround because import declarations are not preserved in .sib files.
// RUN: sed -e 's/import Swift$/import Swift; import _Differentiation/' %t/tmp.sil > %t/tmp_fixed.sil
// RUN: %target-sil-opt %t/tmp_fixed.sil -module-name main -emit-sorted-sil | %FileCheck --check-prefix=ROUNDTRIP %s

// IRGen test.

// RUN: %target-swift-frontend -emit-ir %s | %FileCheck --check-prefix=IRGEN %s

// NOTE(SR-12090): `shell` is required only to run `sed` as a SR-12090 workaround.
// `shell` is required only to run `sed` as a
// https://github.com/apple/swift/issues/54526 workaround.
// REQUIRES: shell

sil_stage raw
Expand Down
@@ -1,7 +1,8 @@
// RUN: %target-swift-emit-silgen -verify -module-name main %s -warn-redundant-requirements | %FileCheck %s
// RUN: %target-swift-emit-sil -verify -module-name main %s -warn-redundant-requirements

// NOTE(SR-11950): SILParser crashes for SILGen round-trip.
// NOTE: SILParser crashes for SILGen round-trip
// (https://github.com/apple/swift/issues/54370).

// This file tests:
// - The "derivative generic signature" of `@differentiable` and `@derivative`
Expand Down
3 changes: 2 additions & 1 deletion test/AutoDiff/SILOptimizer/derivative_sil.swift
Expand Up @@ -89,7 +89,8 @@ func foo(_ x: Float) -> Float {
// CHECK-SIL: return [[DX]] : $Float
// CHECK-SIL: }

// Check the conventions of the generated functions for a method (SR-13945).
// https://github.com/apple/swift/issues/56342
// Check the conventions of the generated functions for a method.
struct ExampleStruct {
@_silgen_name("fooMethod")
@differentiable(reverse)
Expand Down
26 changes: 14 additions & 12 deletions test/AutoDiff/SILOptimizer/differentiation_diagnostics.swift
Expand Up @@ -618,7 +618,8 @@ func testClassTangentPropertyNotStored(_ c: ClassTangentPropertyNotStored) -> Fl
// CHECK-LABEL: sil {{.*}} @test_class_tangent_property_not_stored
// CHECK: ref_element_addr {{%.*}} : $ClassTangentPropertyNotStored, #ClassTangentPropertyNotStored.x

// SR-13134: Test stored property access with conditionally `Differentiable` base type.
// https://github.com/apple/swift/issues/55580
// Test stored property access with conditionally `Differentiable` base type.

struct Complex<T: FloatingPoint> {
var real: T
Expand All @@ -630,7 +631,7 @@ extension Complex: Differentiable where T: Differentiable {
extension Complex: AdditiveArithmetic {}

@differentiable(reverse)
func SR_13134(lhs: Complex<Float>, rhs: Complex<Float>) -> Float {
func f_55580(lhs: Complex<Float>, rhs: Complex<Float>) -> Float {
return lhs.real + rhs.real
}

Expand Down Expand Up @@ -692,7 +693,8 @@ func projectedValueAccess(_ s: Struct) -> Float {
s.$y.wrappedValue
}

// SR-12640: Test `wrapperValue.modify` differentiation.
// https://github.com/apple/swift/issues/55084
// Test `wrapperValue.modify` differentiation.

// expected-error @+2 {{function is not differentiable}}
// expected-note @+2 {{when differentiating this function definition}}
Expand Down Expand Up @@ -722,7 +724,7 @@ func tupleArrayLiteralInitialization(_ x: Float, _ y: Float) -> Float {
// Subset parameter differentiation thunks
//===----------------------------------------------------------------------===//

// FIXME(SR-13046): Non-differentiability diagnostic crash due to invalid source location.
// FIXME: Non-differentiability diagnostic crash due to invalid source location (https://github.com/apple/swift/issues/55492).
/*
func testNoDerivativeParameter(_ f: @differentiable(reverse) (Float, @noDerivative Float) -> Float) -> Float {
return gradient(at: 2) { x in f(x * x, x) }
Expand Down Expand Up @@ -774,27 +776,27 @@ public func fragileDifferentiable(_ x: Float) -> Float {
}


// FIXME(rdar://87429620): Differentiable curry thunk RequirementMachine error.
// FIXME: Differentiable curry thunk RequirementMachine error (rdar://87429620, https://github.com/apple/swift/issues/54819).
#if false
// TF-1208: Test curry thunk differentiation regression.
public struct SR_14228_Struct<Scalar> {
public struct Struct_54819<Scalar> {
var x: Scalar
}
extension SR_14228_Struct: Differentiable where Scalar: Differentiable {
extension Struct_54819: Differentiable where Scalar: Differentiable {
@differentiable(reverse)
public static func id(x: Self) -> Self {
return x
}
}
@differentiable(reverse, wrt: x)
public func SR_14228<Scalar: Differentiable>(
_ x: SR_14228_Struct<Scalar>,
// NOTE(TF-1208): This diagnostic is unexpected because `SR_14228_Struct.id` is marked `@differentiable`.
public func f_54819<Scalar: Differentiable>(
_ x: Struct_54819<Scalar>,
// NOTE(TF-1208): This diagnostic is unexpected because `Struct_54819.id` is marked `@differentiable`.
// xpected-error @+3 2 {{function is not differentiable}}
// 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}}
// xpected-note @+1 {{opaque non-'@differentiable' function is not differentiable}}
reduction: @differentiable(reverse) (SR_14228_Struct<Scalar>) -> SR_14228_Struct<Scalar> = SR_14228_Struct.id
) -> SR_14228_Struct<Scalar> {
reduction: @differentiable(reverse) (Struct_54819<Scalar>) -> Struct_54819<Scalar> = Struct_54819.id
) -> Struct_54819<Scalar> {
reduction(x)
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions test/AutoDiff/SILOptimizer/forward_mode_diagnostics.swift
Expand Up @@ -119,7 +119,7 @@ func activeInoutParamMutatingMethod(_ x: Mut) -> Mut {
// Subset parameter differentiation thunks
//===----------------------------------------------------------------------===//

// FIXME(SR-13046): Non-differentiability diagnostic crash due to invalid source location.
// FIXME: Non-differentiability diagnostic crash due to invalid source location (https://github.com/apple/swift/issues/55492).
/*
func testNoDerivativeParameter(_ f: @differentiable(reverse) (Float, @noDerivative Float) -> Float) -> Float {
return derivative(at: 2, 3) { (x, y) in f(x * x, y) }
Expand Down Expand Up @@ -238,7 +238,7 @@ final class ClassTangentPropertyWrongType: Differentiable {
func move(by offset: TangentVector) {}
}

// SR-13464: Missing support for classes in forward-mode AD
// FIXME: Missing support for classes in forward-mode AD causes crash (https://github.com/apple/swift/issues/55906).
/*
// xpected-error @+2 {{function is not differentiable}}
// xpected-note @+3 {{when differentiating this function definition}}
Expand Down Expand Up @@ -287,7 +287,7 @@ final class ClassTangentPropertyNotStored: Differentiable {
func move(by offset: TangentVector) {}
}

// SR-13464: Missing support for classes in forward-mode AD
// FIXME: Missing support for classes in forward-mode AD causes crash (https://github.com/apple/swift/issues/55906).
/*
// xpected-error @+2 {{function is not differentiable}}
// xpected-note @+3 {{when differentiating this function definition}}
Expand Down
10 changes: 7 additions & 3 deletions test/AutoDiff/SILOptimizer/property_wrappers.swift
Expand Up @@ -47,7 +47,9 @@ struct Struct: Differentiable {
@Wrapper @SimpleWrapper var trivial: Float = 10
@Wrapper @SimpleWrapper var tracked: Tracked<Float> = 20
@Wrapper @SimpleWrapper var nontrivial: NontrivialLoadable<Float> = 30
// Tests SR-12800: semantic member accessors should have empty linear map structs.

// https://github.com/apple/swift/issues/55245
// Semantic member accessors should have empty linear map structs.
@DifferentiableWrapper var differentiableWrapped: Float = 40

static func testGetters() {
Expand Down Expand Up @@ -75,15 +77,17 @@ struct GenericStruct<T: Differentiable>: Differentiable {
@Wrapper @SimpleWrapper var nontrivial: NontrivialLoadable<Float> = 30
@Wrapper @SimpleWrapper var addressOnly: T

// SR-12778: Test getter pullback for non-trivial loadable property.
// https://github.com/apple/swift/issues/55223
// Test getter pullback for non-trivial loadable property.
static func testGetters() {
let _: @differentiable(reverse) (Self) -> Float = { $0.trivial }
let _: @differentiable(reverse) (Self) -> Tracked<Float> = { $0.tracked }
let _: @differentiable(reverse) (Self) -> NontrivialLoadable<Float> = { $0.nontrivial }
let _: @differentiable(reverse) (Self) -> T = { $0.addressOnly }
}

// SR-12779: Test setter pullback for non-trivial loadable property.
// https://github.com/apple/swift/issues/55224
// Test setter pullback for non-trivial loadable property.
static func testSetters() {
let _: @differentiable(reverse) (inout Self, Float) -> Void =
{ $0.trivial = $1 }
Expand Down
7 changes: 4 additions & 3 deletions test/AutoDiff/TBD/derivative_symbols.swift
Expand Up @@ -83,7 +83,8 @@ extension Array where Element == Struct {
}
}

// SR-13866: Dispatch thunks and method descriptor mangling.
// https://github.com/apple/swift/issues/56264
// Dispatch thunks and method descriptor mangling.
public protocol P: Differentiable {
@differentiable(reverse, wrt: self)
@differentiable(reverse, wrt: (self, x))
Expand Down Expand Up @@ -129,7 +130,7 @@ public final class Class: Differentiable {
@differentiable(reverse)
get { x }

// FIXME(SR-13096)
// FIXME: https://github.com/apple/swift/issues/55542
// @differentiable(reverse)
// set { stored = newValue }
}
Expand All @@ -141,7 +142,7 @@ public final class Class: Differentiable {
fatalError()
}

// FIXME(SR-13096)
// FIXME: https://github.com/apple/swift/issues/55542
// @derivative(of: subscript.set)
// public func vjpSubscriptSetter(_ x: Float, _ newValue: Float) -> (
// value: (), pullback: (inout TangentVector) -> (Float, Float)
Expand Down
11 changes: 6 additions & 5 deletions test/AutoDiff/validation-test/control_flow.swift
@@ -1,7 +1,7 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test

// FIXME(SR-12741): Enable test for all platforms after debugging
// FIXME: Enable test for all platforms after debugging (https://github.com/apple/swift/issues/55186).
// iphonesimulator-i386-specific failures.
// REQUIRES: CPU=x86_64

Expand Down Expand Up @@ -717,8 +717,9 @@ ControlFlowTests.test("Loops") {
expectEqual((52, 80), valueWithGradient(at: 2, of: { x in nested_loop2(x, count: 3) }))
expectEqual((24, 28), valueWithGradient(at: 2, of: { x in nested_loop2(x, count: 4) }))

// SR13945: Loops in methods caused a runtime segfault.
struct SR13945 {
// https://github.com/apple/swift/issues/56342
// Loops in methods caused a runtime segfault.
struct S_56342 {
func loopInMethod(_ x: Float) -> Float {
var result = x
for _ in 0..<2 {
Expand All @@ -727,8 +728,8 @@ ControlFlowTests.test("Loops") {
return result
}
}
expectEqual((0, 0), valueWithGradient(at: 0, of: { SR13945().loopInMethod($0) }))
expectEqual((1, 4), valueWithGradient(at: 1, of: { SR13945().loopInMethod($0) }))
expectEqual((0, 0), valueWithGradient(at: 0, of: { S_56342().loopInMethod($0) }))
expectEqual((1, 4), valueWithGradient(at: 1, of: { S_56342().loopInMethod($0) }))
}

ControlFlowTests.test("BranchingCastInstructions") {
Expand Down
@@ -1,8 +1,7 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test

// Disabled due to test failure with `-O`: SR-13250.
// SR-13250 is tracking the fix for compiling this test with optimizations.
// FIXME: Disabled due to test failure with `-O` (https://github.com/apple/swift/issues/55690).
// XFAIL: swift_test_mode_optimize
// XFAIL: swift_test_mode_optimize_size
// XFAIL: swift_test_mode_optimize_unchecked
Expand Down
2 changes: 1 addition & 1 deletion test/AutoDiff/validation-test/forward_mode_simd.swift
Expand Up @@ -178,7 +178,7 @@ ForwardModeTests.test("Generics") {
let a = SIMD3<Double>(1, 2, 3)
let g = SIMD3<Double>(1, 1, 1)

// FIXME(SR-13210): Fix forward-mode SIL verification error.
// FIXME: Fix forward-mode SIL verification error (https://github.com/apple/swift/issues/55650).
/*
func testInit<Scalar, SIMDType: SIMD>(x: Scalar) -> SIMDType
where SIMDType.Scalar == Scalar,
Expand Down
19 changes: 10 additions & 9 deletions test/AutoDiff/validation-test/forward_mode_simple.swift
Expand Up @@ -361,7 +361,7 @@ ForwardModeTests.test("TupleNonDifferentiableElements") {
tuple.2 = x
return tuple.1.1 * tuple.2
}
// FIXME(SR-12911): Fix runtime segfault.
// FIXME: Fix runtime segfault (https://github.com/apple/swift/issues/55357).
// expectEqual((16, 8), valueWithDerivative(at: 4, of: nested))

struct Wrapper<T> {
Expand Down Expand Up @@ -746,7 +746,7 @@ ForwardModeTests.test("SimpleWrtSelf") {
// FIXME(TF-648): Dummy to make `Super.AllDifferentiableVariables` be nontrivial.
var _nontrivial: [Float] = []

// FIXME(SR-12175): Fix forward-mode differentiation tangent buffer crash.
// FIXME: Fix forward-mode differentiation tangent buffer crash (https://github.com/apple/swift/issues/54600).
// @differentiable(reverse)
required init(base: Float) {
self.base = base
Expand Down Expand Up @@ -792,7 +792,7 @@ ForwardModeTests.test("SimpleWrtSelf") {
}
}

// FIXME(SR-12175): Fix forward-mode differentiation tangent buffer crash.
// FIXME: Fix forward-mode differentiation tangent buffer crash (https://github.com/apple/swift/issues/54600).
// let v = Super.TangentVector(base: 100, _nontrivial: [])
// expectEqual(100, pullback(at: 1337) { x in Super(base: x) }(v))
// expectEqual(100, pullback(at: 1337) { x in SubOverride(base: x) }(v))
Expand Down Expand Up @@ -1070,7 +1070,7 @@ ForwardModeTests.test("ResultSelection") {
expectEqual(1, derivative(at: 3, 3, of: { x, y in tuple(x, y).0 }))
expectEqual(1, derivative(at: 3, 3, of: { x, y in tuple(x, y).1 }))

// FIXME(SR-12175): Fix forward-mode differentiation tangent buffer crash.
// FIXME: Fix forward-mode differentiation tangent buffer crash (https://github.com/apple/swift/issues/54600).
/*
func tupleGeneric<T>(_ x: T, _ y: T) -> (T, T) {
return (x, y)
Expand Down Expand Up @@ -1389,15 +1389,16 @@ ForwardModeTests.test("ApplyNonActiveIndirectResult") {
expectEqual(1.0, derivative(at: 2, of: applyNonactiveArgumentActiveIndirectResult))
}

ForwardModeTests.test("SR-13530") {
// SR-13530: Test "leaked owned value" ownership verification failure related
// to differential generation for `copy_value` instruction.
ForwardModeTests.test("https://github.com/apple/swift/issues/55967") {
// https://github.com/apple/swift/issues/55967
// Test "leaked owned value" ownership verification failure related to
// differential generation for `copy_value` instruction.
@differentiable(reverse)
func SR_13530(_ x: NonresilientTracked<Float>) -> NonresilientTracked<Float> {
func f(_ x: NonresilientTracked<Float>) -> NonresilientTracked<Float> {
precondition(x >= 0)
return x
}
expectEqual(1, derivative(at: 2, of: SR_13530))
expectEqual(1, derivative(at: 2, of: f))
}

runAllTests()

0 comments on commit 6907933

Please sign in to comment.