Skip to content

Commit 91f6f66

Browse files
committed
Apply changes to tests in #27659 and add IRGen RUN line
1 parent a86bd7f commit 91f6f66

File tree

3 files changed

+60
-46
lines changed

3 files changed

+60
-46
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name differentiable_func_type
3+
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.2.sib -module-name differentiable_func_type
4+
// RUN: %target-sil-opt %t/tmp.2.sib -module-name differentiable_func_type | %FileCheck %s -check-prefix=CHECK-SIL
5+
6+
// RUN: %target-swift-frontend %s -emit-ir -module-name differentiable_func_type | %FileCheck %s -check-prefix=CHECK-LLVM
7+
8+
sil_stage raw
9+
10+
import Swift
11+
12+
sil @takeAndReturnLinear : $@convention(thin) (@differentiable(linear) (Float) -> Float) -> @differentiable(linear) (Float) -> Float {
13+
bb0(%0 : $@differentiable(linear) (Float) -> Float):
14+
return %0 : $@differentiable(linear) (Float) -> Float
15+
}
16+
17+
// CHECK-LABEL: sil @takeAndReturnLinear : $@convention(thin) (@differentiable(linear) (Float) -> Float) -> @differentiable(linear) (Float) -> Float {
18+
// CHECK: bb0([[ARG:%.*]] : $@differentiable(linear) (Float) -> Float):
19+
// CHECK: return [[ARG]] : $@differentiable(linear) (Float) -> Float
20+
// CHECK: }
21+
22+
23+
sil @takeAndReturnDifferentiable : $@convention(thin) (@differentiable (Float) -> Float) -> @differentiable (Float) -> Float {
24+
bb0(%0 : $@differentiable (Float) -> Float):
25+
return %0 : $@differentiable (Float) -> Float
26+
}
27+
28+
// CHECK-LABEL: sil @takeAndReturnDifferentiable : $@convention(thin) (@differentiable (Float) -> Float) -> @differentiable (Float) -> Float {
29+
// CHECK: bb0([[ARG:%.*]] : $@differentiable (Float) -> Float):
30+
// CHECK: return [[ARG]] : $@differentiable (Float) -> Float
31+
// CHECK: }

test/AutoDiff/differentiable_function_inst.sil

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,35 @@ sil_stage raw
1010
import Swift
1111
import Builtin
1212

13+
sil @examplefunc : $@convention(thin) (Float, Float, Float) -> Float
14+
sil @examplemethod : $@convention(method) (Float, Float, Float) -> Float
15+
16+
// CHECK-LABEL: sil @test
17+
sil @test : $@convention(thin) () -> () {
18+
bb0:
19+
%0 = function_ref @examplefunc : $@convention(thin) (Float, Float, Float) -> Float
20+
%1 = differentiable_function [wrt 0 1 2] %0 : $@convention(thin) (Float, Float, Float) -> Float
21+
22+
// CHECK: %2 = differentiable_function_extract [vjp] %1 : $@differentiable @convention(thin) (Float, Float, Float) -> Float
23+
%2 = differentiable_function_extract [vjp] %1 : $@differentiable @convention(thin) (Float, Float, Float) -> Float
24+
%3 = differentiable_function [wrt 0] %0 : $@convention(thin) (Float, Float, Float) -> Float
25+
26+
// CHECK: %4 = differentiable_function_extract [vjp] %3 : $@differentiable @convention(thin) (Float, @nondiff Float, @nondiff Float) -> Float
27+
%4 = differentiable_function_extract [vjp] %3 : $@differentiable @convention(thin) (Float, @nondiff Float, @nondiff Float) -> Float
28+
%5 = function_ref @examplemethod : $@convention(method) (Float, Float, Float) -> Float
29+
%6 = differentiable_function [wrt 0 1 2] %5 : $@convention(method) (Float, Float, Float) -> Float
30+
31+
// CHECK: %7 = differentiable_function_extract [vjp] %6 : $@differentiable @convention(method) (Float, Float, Float) -> Float
32+
%7 = differentiable_function_extract [vjp] %6 : $@differentiable @convention(method) (Float, Float, Float) -> Float
33+
%8 = differentiable_function [wrt 0] %5 : $@convention(method) (Float, Float, Float) -> Float
34+
35+
// CHECK: %9 = differentiable_function_extract [vjp] %8 : $@differentiable @convention(method) (Float, @nondiff Float, @nondiff Float) -> Float
36+
%9 = differentiable_function_extract [vjp] %8 : $@differentiable @convention(method) (Float, @nondiff Float, @nondiff Float) -> Float
37+
38+
%ret = tuple ()
39+
return %ret : $()
40+
}
41+
1342
// The adjoint function emitted by the compiler. Parameter are a vector, as in
1443
// vector-Jacobian products, and pullback values. The function is partially
1544
// applied to a pullback struct to form a pullback, which takes a vector and

test/AutoDiff/differentiable_sil_function_type_parse.sil

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)