1
- // RUN: %target-swift-frontend -Xllvm -tf-dump-intermediates -Xllvm -tf-strict-deabstraction=false -O -emit-sil %s | %FileCheck %s
2
- // RUN: %target-swift-frontend -Xllvm -tf-dump-intermediates -Xllvm -tf-strict-deabstraction -O -emit-sil -verify %s | %FileCheck %s -check-prefix=STRICTDA
1
+ // RUN: %target-swift-frontend -Xllvm -tf-dump-intermediates -O -emit-sil -verify %s | %FileCheck %s
3
2
4
3
import TensorFlow
5
4
@@ -11,10 +10,6 @@ import TensorFlow
11
10
// Please keep it so no errors or warnings are generated by functions in this
12
11
// file.
13
12
14
-
15
- /* TODO build this out.
16
- STRICTDA: --- TFDeabstraction Result: {{.*}}testSelect
17
- */
18
13
public func testSelect( conds1: Tensor < Bool > , x1: Tensor < Float > , y1: Tensor < Float > )
19
14
-> Tensor < Float > {
20
15
let conds = conds1. toAccelerator ( )
@@ -25,27 +20,16 @@ public func testSelect(conds1: Tensor<Bool>, x1: Tensor<Float>, y1: Tensor<Float
25
20
26
21
return result. toHost ( )
27
22
}
28
-
29
23
/*
30
24
CHECK-LABEL: --- TFPartition Accelerator Result: {{.*}}testSelect
31
25
CHECK: sil private @{{.*}}testSelect{{.*}} : $@callee_owned (TensorHandle<Float>, TensorHandle<Bool>, TensorHandle<Float>) -> TensorHandle<Float> {
32
26
CHECK: bb0(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Bool>, %2 : $TensorHandle<Float>):
33
- CHECK: %5 = builtin "__tfop_Add,$in,$in,T,__device "(%0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>
34
- CHECK: %8 = builtin "__tfop_Select,$in,$in,$in,T,__device "(%1 : $TensorHandle<Bool>, %5 : $TensorHandle<Float>, %2 : $TensorHandle<Float>
35
- CHECK: %11 = builtin "__tfop_Mul,$in,$in,T,__device"(%8 : $TensorHandle<Float>, %2 : $TensorHandle<Float>
36
- CHECK-NEXT: return %11 : $TensorHandle<Float>
27
+ CHECK: [[A:%.*]] = graph_op "Add,i,i "(%0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>
28
+ CHECK: [[B:%.*]] = graph_op "Select,i,i,i "(%1 : $TensorHandle<Bool>, [[A]] : $TensorHandle<Float>, %2 : $TensorHandle<Float>
29
+ CHECK: [[C:%.*]] = graph_op "Mul,i,i"([[B]] : $TensorHandle<Float>, %2 : $TensorHandle<Float>
30
+ CHECK-NEXT: return [[C]] : $TensorHandle<Float>
37
31
CHECK-NEXT:}
38
32
*/
39
- /*
40
- STRICTDA-LABEL: --- TFPartition Accelerator Result: {{.*}}testSelect
41
- STRICTDA: sil private @{{.*}}testSelect{{.*}} : $@callee_owned (TensorHandle<Float>, TensorHandle<Bool>, TensorHandle<Float>) -> TensorHandle<Float> {
42
- STRICTDA: bb0(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Bool>, %2 : $TensorHandle<Float>):
43
- STRICTDA: [[A:%.*]] = graph_op "Add,i,i"(%0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>
44
- STRICTDA: [[B:%.*]] = graph_op "Select,i,i,i"(%1 : $TensorHandle<Bool>, [[A]] : $TensorHandle<Float>, %2 : $TensorHandle<Float>
45
- STRICTDA: [[C:%.*]] = graph_op "Mul,i,i"([[B]] : $TensorHandle<Float>, %2 : $TensorHandle<Float>
46
- STRICTDA-NEXT: return [[C]] : $TensorHandle<Float>
47
- STRICTDA-NEXT:}
48
- */
49
33
50
34
public func testEmptyScalarsArray( ) {
51
35
let y = Tensor < Int32 > ( shape: [ 0 , 20 , 30 ] , scalars: [ ] )
@@ -56,14 +40,7 @@ public func testEmptyScalarsArray() {
56
40
CHECK: sil private @{{.*}}testEmptyScalarsArray{{.*}} : $@callee_owned () -> () {
57
41
CHECK: bb0:
58
42
CHECK: graph_op "Const"() {dtype: $Int32, value$tensor: [$Int32: ], value$shape: [$Int32: (i32 0), (i32 20), (i32 30)],
59
- CHECK: builtin "__tfop_Add,$in,$in,T,__device"({{.*}} : $TensorHandle<Int32>, {{.*}} : $TensorHandle<Int32>
60
- */
61
- /*
62
- STRICTDA-LABEL: --- TFPartition Accelerator Result: {{.*}}testEmptyScalarsArray
63
- STRICTDA: sil private @{{.*}}testEmptyScalarsArray{{.*}} : $@callee_owned () -> () {
64
- STRICTDA: bb0:
65
- STRICTDA: graph_op "Const"() {dtype: $Int32, value$tensor: [$Int32: ], value$shape: [$Int32: (i32 0), (i32 20), (i32 30)],
66
- STRICTDA: graph_op "Add,i,i"({{.*}} : $TensorHandle<Int32>, {{.*}} : $TensorHandle<Int32>
43
+ CHECK: graph_op "Add,i,i"({{.*}} : $TensorHandle<Int32>, {{.*}} : $TensorHandle<Int32>
67
44
*/
68
45
69
46
// This tests the attributes necessary to get arrays of integers and strings going.
@@ -75,25 +52,10 @@ public func testConvolution(x: Tensor<Float>, filter: Tensor<Float>) -> Tensor<F
75
52
// CHECK-LABEL: --- TFPartition Accelerator Result: {{.*}}testConvolution
76
53
// CHECK: sil private @{{.*}}testConvolution{{.*}} : $@callee_owned (TensorHandle<Float>, TensorHandle<Float>) -> TensorHandle<Float> {
77
54
// CHECK: bb0(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>):
78
- // CHECK-NEXT: %2 = metatype $@thick Float.Type
79
- // CHECK-NEXT: %3 = metatype $@thin Int32.Type
80
- // CHECK-NEXT: %4 = integer_literal $Builtin.Int32, 1
81
- // CHECK-NEXT: %5 = integer_literal $Builtin.Int32, 2
82
- // CHECK-NEXT: %6 = integer_literal $Builtin.Int32, 3
83
- // CHECK-NEXT: %7 = integer_literal $Builtin.Int32, 4
84
- // CHECK-NEXT: %8 = integer_literal $Builtin.Int1, -1
85
- // CHECK-NEXT: %9 = string_literal utf8 "SAME"
86
- // CHECK: builtin "__tfop_Conv2D,$in,$in,T,strides$array,$elt,$elt,$elt,$elt,use_cudnn_on_gpu,padding,data_format,dilations$array,$elt,$elt,$elt,$elt,__device"(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>, %2 : $@thick Float.Type, %3 : $@thin Int32.Type, %4 : $Builtin.Int32, %5 : $Builtin.Int32, %6 : $Builtin.Int32, %7 : $Builtin.Int32, %8 : $Builtin.Int1, %9 : $Builtin.RawPointer, %10 : $Builtin.RawPointer, %11 : $@thin Int32.Type, %12 : $Builtin.Int32, %13 : $Builtin.Int32, %14 : $Builtin.Int32, %15 : $Builtin.Int32, %16 : $Builtin.RawPointer) : $TensorHandle<Float>
87
- // CHECK-NEXT: return %17 : $TensorHandle<Float>
55
+ // CHECK: [[A:%.*]] = graph_op "Conv2D,i,i"(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>) {T: $Float, strides: [$Int32: (i32 1), (i32 2), (i32 3), (i32 4)], use_cudnn_on_gpu: i1 -1, padding: "SAME", data_format: "NHWC", dilations: [$Int32: (i32 1), (i32 1), (i32 1), (i32 1)], __device: "/device:CPU:0"} : $TensorHandle<Float>
56
+ // CHECK-NEXT: return [[A]] : $TensorHandle<Float>
88
57
// CHECK-NEXT:}
89
58
90
- // STRICTDA-LABEL: --- TFPartition Accelerator Result: {{.*}}testConvolution
91
- // STRICTDA: sil private @{{.*}}testConvolution{{.*}} : $@callee_owned (TensorHandle<Float>, TensorHandle<Float>) -> TensorHandle<Float> {
92
- // STRICTDA: bb0(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>):
93
- // STRICTDA: [[A:%.*]] = graph_op "Conv2D,i,i"(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>) {T: $Float, strides: [$Int32: (i32 1), (i32 2), (i32 3), (i32 4)], use_cudnn_on_gpu: i1 -1, padding: "SAME", data_format: "NHWC", dilations: [$Int32: (i32 1), (i32 1), (i32 1), (i32 1)], __device: "/device:CPU:0"} : $TensorHandle<Float>
94
- // STRICTDA-NEXT: return [[A]] : $TensorHandle<Float>
95
- // STRICTDA-NEXT:}
96
-
97
59
// Testcase for an op that uses the $tensor and $shape modifiers.
98
60
public func testConstantArray( ) -> TensorHandle < Float > {
99
61
return #tfop( " Const " , dtype: Float . self, value$tensor: [ 1.0 , 2.0 ] , value$shape: [ 2 ] )
@@ -102,20 +64,8 @@ public func testConstantArray() -> TensorHandle<Float> {
102
64
// CHECK-LABEL: --- TFPartition Accelerator Result: {{.*}}testConstantArray
103
65
// CHECK: sil private @{{.*}}testConstantArray{{.*}} : $@callee_owned () -> TensorHandle<Float> {
104
66
// CHECK: bb0:
105
- // CHECK-NEXT: %0 = metatype $@thin Float.Type
106
- // CHECK-NEXT: %1 = metatype $@thin Double.Type
107
- // CHECK-NEXT: %2 = float_literal $Builtin.FPIEEE64, 0x3FF0000000000000 // 1
108
- // CHECK-NEXT: %3 = float_literal $Builtin.FPIEEE64, 0x4000000000000000 // 2
109
- // CHECK-NEXT: %4 = metatype $@thin Int.Type
110
- // CHECK-NEXT: %5 = integer_literal $Builtin.Int64, 2
111
- // CHECK: %7 = builtin "__tfop_Const,dtype,value$tensor,$elt,$elt,value$shape,$elt,__device"(%0 : $@thin Float.Type, %1 : $@thin Double.Type, %2 : $Builtin.FPIEEE64, %3 : $Builtin.FPIEEE64, %4 : $@thin Int.Type, %5 : $Builtin.Int64
112
- // CHECK-NEXT: return %7 : $TensorHandle<Float>
113
-
114
- // STRICTDA-LABEL: --- TFPartition Accelerator Result: {{.*}}testConstantArray
115
- // STRICTDA: sil private @{{.*}}testConstantArray{{.*}} : $@callee_owned () -> TensorHandle<Float> {
116
- // STRICTDA: bb0:
117
- // STRICTDA: %0 = graph_op "Const"() {dtype: $Float, value$tensor: [$Double: (f64 0x3FF0000000000000 /* 1 */), (f64 0x4000000000000000 /* 2 */)], value$shape: [$Int: (i64 2)], __device: "/device:CPU:0"} : $TensorHandle<Float>
118
- // STRICTDA-NEXT: return %0 : $TensorHandle<Float>
67
+ // CHECK: %0 = graph_op "Const"() {dtype: $Float, value$tensor: [$Double: (f64 0x3FF0000000000000 /* 1 */), (f64 0x4000000000000000 /* 2 */)], value$shape: [$Int: (i64 2)], __device: "/device:CPU:0"} : $TensorHandle<Float>
68
+ // CHECK-NEXT: return %0 : $TensorHandle<Float>
119
69
120
70
// Sigmoid shouldn't cause copies. This should compile with no copy warnings/errors.
121
71
public func testSigmoid( x: Tensor < Float > , y: Tensor < Float > ) -> ( Tensor < Float > , Tensor < Float > ) {
0 commit comments