From bdcd58043ccb85b1a88d29aa5c79d5ce4c7ac937 Mon Sep 17 00:00:00 2001 From: efremale Date: Mon, 13 Jul 2020 21:50:08 +0200 Subject: [PATCH 1/5] Add failing test --- test/AutoDiff/validation-test/forward_mode.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/AutoDiff/validation-test/forward_mode.swift b/test/AutoDiff/validation-test/forward_mode.swift index b75cc1645d59e..750b8b7f3c036 100644 --- a/test/AutoDiff/validation-test/forward_mode.swift +++ b/test/AutoDiff/validation-test/forward_mode.swift @@ -1599,6 +1599,9 @@ ForwardModeTests.test("Generics") { // FIXME(SR-13210): Fix forward-mode SIL verification error. /* + let a = SIMD3(1, 2, 3) + let g = SIMD3(1, 1, 1) + func testInit(x: Scalar) -> SIMDType where SIMDType.Scalar == Scalar, SIMDType : Differentiable, From eeed1d8dc29782533f7f05b5ac3d25bf95d89ca4 Mon Sep 17 00:00:00 2001 From: Dan Zheng Date: Mon, 13 Jul 2020 14:05:23 -0700 Subject: [PATCH 2/5] Narrow down SR-13210 failing test. --- test/AutoDiff/validation-test/forward_mode.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/AutoDiff/validation-test/forward_mode.swift b/test/AutoDiff/validation-test/forward_mode.swift index 750b8b7f3c036..b75cc1645d59e 100644 --- a/test/AutoDiff/validation-test/forward_mode.swift +++ b/test/AutoDiff/validation-test/forward_mode.swift @@ -1599,9 +1599,6 @@ ForwardModeTests.test("Generics") { // FIXME(SR-13210): Fix forward-mode SIL verification error. /* - let a = SIMD3(1, 2, 3) - let g = SIMD3(1, 1, 1) - func testInit(x: Scalar) -> SIMDType where SIMDType.Scalar == Scalar, SIMDType : Differentiable, From ece04f24d5b6ea7728ab999a895c9242093ac115 Mon Sep 17 00:00:00 2001 From: efremale Date: Fri, 17 Jul 2020 22:25:21 +0000 Subject: [PATCH 3/5] Fix a bug in `_jvpMultiply` --- stdlib/public/Differentiation/SIMDDifferentiation.swift.gyb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/Differentiation/SIMDDifferentiation.swift.gyb b/stdlib/public/Differentiation/SIMDDifferentiation.swift.gyb index e4110340ad696..9eee9b6f22b8b 100644 --- a/stdlib/public/Differentiation/SIMDDifferentiation.swift.gyb +++ b/stdlib/public/Differentiation/SIMDDifferentiation.swift.gyb @@ -176,7 +176,7 @@ where ) { return (lhs * rhs, { ltan, rtan in - return lhs * ltan + rtan * rhs + return lhs * rtan + ltan * rhs }) } From ae664c3aa3b00159bc1a6e6dc4249d9ed19dfb6e Mon Sep 17 00:00:00 2001 From: efremale Date: Mon, 20 Jul 2020 19:21:56 +0000 Subject: [PATCH 4/5] Improve multiplication test --- test/AutoDiff/validation-test/forward_mode.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/AutoDiff/validation-test/forward_mode.swift b/test/AutoDiff/validation-test/forward_mode.swift index b75cc1645d59e..a17b750feae26 100644 --- a/test/AutoDiff/validation-test/forward_mode.swift +++ b/test/AutoDiff/validation-test/forward_mode.swift @@ -1537,15 +1537,17 @@ ForwardModeTests.test("Subtraction") { ForwardModeTests.test("Multiplication") { let a = SIMD4(1, 2, 3, 4) + let a2 = SIMD4(4, 3, 2, 1) let g = SIMD4(1, 1, 1, 1) + let g2 = SIMD4(0, 2, 1, 3) // SIMD * SIMD func foo1(x: SIMD4, y: SIMD4) -> SIMD4 { return x * y } - let (val1, df1) = valueWithDifferential(at: a, a, in: foo1) - expectEqual(a * a, val1) - expectEqual(a * g + g * a, df1(g, g)) + let (val1, df1) = valueWithDifferential(at: a, b, in: foo1) + expectEqual(a * b, val1) + expectEqual(a * g2 + g * b, df1(g, g2)) // SIMD * Scalar func foo2(x: SIMD4, y: Float) -> SIMD4 { From 094b0c1ca30ed1d6380d178cd0994911317f363a Mon Sep 17 00:00:00 2001 From: Dan Zheng Date: Tue, 21 Jul 2020 09:31:36 -0700 Subject: [PATCH 5/5] Update test/AutoDiff/validation-test/forward_mode.swift --- test/AutoDiff/validation-test/forward_mode.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/AutoDiff/validation-test/forward_mode.swift b/test/AutoDiff/validation-test/forward_mode.swift index a17b750feae26..c29b87f34c198 100644 --- a/test/AutoDiff/validation-test/forward_mode.swift +++ b/test/AutoDiff/validation-test/forward_mode.swift @@ -1545,9 +1545,9 @@ ForwardModeTests.test("Multiplication") { func foo1(x: SIMD4, y: SIMD4) -> SIMD4 { return x * y } - let (val1, df1) = valueWithDifferential(at: a, b, in: foo1) - expectEqual(a * b, val1) - expectEqual(a * g2 + g * b, df1(g, g2)) + let (val1, df1) = valueWithDifferential(at: a, a2, in: foo1) + expectEqual(a * a2, val1) + expectEqual(a * g2 + g * a2, df1(g, g2)) // SIMD * Scalar func foo2(x: SIMD4, y: Float) -> SIMD4 {