1
1
// RUN: %target-swift-frontend -Xllvm -tf-dump-intermediates -O -emit-sil -verify %s
2
2
// RUN: %target-swift-frontend -Xllvm -tf-dump-intermediates -O -emit-sil -verify %s | %FileCheck %s
3
3
4
- // FIXME(b/78371828): Should this test work with optimized_stdlib?
5
- // UNSUPPORTED: optimized_stdlib
6
-
7
4
import TensorFlow
8
5
9
6
public func testTensor( a: Tensor < Float > , b: Tensor < Float > ) {
@@ -22,14 +19,17 @@ public func testTensor(a: Tensor<Float>, b: Tensor<Float>) {
22
19
// CHECK-LABEL: --- TFPartition Accelerator Result: {{.*}}testTensor{{.*}}
23
20
// CHECK: sil private @{{.*}}testTensor{{.*}} : $@callee_owned (TensorHandle<Float>, TensorHandle<Float>) -> TensorHandle<Float> {
24
21
// CHECK: bb0(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>):
25
- // CHECK-NEXT: %2 = string_literal utf8 "/device:CPU:0"
26
- // CHECK-NEXT: %3 = builtin "__tfop_Add,$in,$in,device"(%0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>, %2 : $Builtin.RawPointer) : $TensorHandle<Float>
27
- // CHECK-NEXT: %4 = string_literal utf8 "/device:CPU:0"
28
- // CHECK-NEXT: %5 = builtin "__tfop_Sub,$in,$in,device"(%3 : $TensorHandle<Float>, %3 : $TensorHandle<Float>, %4 : $Builtin.RawPointer) : $TensorHandle<Float>
29
- // CHECK-NEXT: %6 = builtin "tensorflowSend_0"<TensorHandle<Float>>(%5 : $TensorHandle<Float>) : $()
30
- // CHECK-NEXT: %7 = string_literal utf8 "/device:CPU:0"
31
- // CHECK-NEXT: %8 = builtin "__tfop_Add,$in,$in,device"(%1 : $TensorHandle<Float>, %1 : $TensorHandle<Float>, %7 : $Builtin.RawPointer) : $TensorHandle<Float>
32
- // CHECK-NEXT: return %8 : $TensorHandle<Float>
22
+ // CHECK-NEXT: %2 = metatype $@thick Float.Type
23
+ // CHECK-NEXT: %3 = string_literal utf8 "/device:CPU:0"
24
+ // CHECK-NEXT: %4 = builtin "__tfop_Add,$in,$in,T,device"(%0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>, %2 : $@thick Float.Type, %3 : $Builtin.RawPointer) : $TensorHandle<Float>
25
+ // CHECK-NEXT: %5 = metatype $@thick Float.Type
26
+ // CHECK-NEXT: %6 = string_literal utf8 "/device:CPU:0"
27
+ // CHECK-NEXT: %7 = builtin "__tfop_Sub,$in,$in,T,device"(%4 : $TensorHandle<Float>, %4 : $TensorHandle<Float>, %5 : $@thick Float.Type, %6 : $Builtin.RawPointer) : $TensorHandle<Float>
28
+ // CHECK-NEXT: %8 = builtin "tensorflowSend_0"<TensorHandle<Float>>(%7 : $TensorHandle<Float>) : $()
29
+ // CHECK-NEXT: %9 = metatype $@thick Float.Type
30
+ // CHECK-NEXT: %10 = string_literal utf8 "/device:CPU:0"
31
+ // CHECK-NEXT: %11 = builtin "__tfop_Add,$in,$in,T,device"(%1 : $TensorHandle<Float>, %1 : $TensorHandle<Float>, %9 : $@thick Float.Type, %10 : $Builtin.RawPointer) : $TensorHandle<Float>
32
+ // CHECK-NEXT: return %11 : $TensorHandle<Float>
33
33
34
34
35
35
// CHECK-LABEL: --- TFPartition Host Result: {{.*}}testTensor{{.*}}
@@ -65,8 +65,8 @@ public func testScalar(f: Float) { // expected-warning {{'f' implicitly copied t
65
65
// CHECK-NEXT: %3 = integer_literal $Builtin.Int32, 1
66
66
// CHECK: [[CONST:%.*]] = builtin "__tfop_Const,dtype$dtype,value$tensor,device"(%3 : $Builtin.Int32, %2 : $Builtin.FPIEEE32, {{.*}}) : $TensorHandle<Builtin.FPIEEE32>
67
67
// CHECK-NEXT: [[CAST:%.*]] = unchecked_ref_cast [[CONST]] : $TensorHandle<Builtin.FPIEEE32> to $TensorHandle<Float>
68
- // CHECK: [[ADD1:%.*]] = builtin "__tfop_Add,$in,$in,device"(%1 : $TensorHandle<Float>, [[CAST]] : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
69
- // CHECK: [[ADD2:%.*]] = builtin "__tfop_Add,$in,$in,device"([[ADD1]] : $TensorHandle<Float>, [[ADD1:%.*]] : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
68
+ // CHECK: [[ADD1:%.*]] = builtin "__tfop_Add,$in,$in,T, device"(%1 : $TensorHandle<Float>, [[CAST]] : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
69
+ // CHECK: [[ADD2:%.*]] = builtin "__tfop_Add,$in,$in,T, device"([[ADD1]] : $TensorHandle<Float>, [[ADD1:%.*]] : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
70
70
// CHECK-NEXT: return [[ADD2]] : $TensorHandle<Float>
71
71
// CHECK-NEXT: }
72
72
@@ -108,8 +108,8 @@ public func testExitBranch1(i: Int) {
108
108
// CHECK-NEXT: %1 = integer_literal $Builtin.Int32, 1
109
109
// CHECK: %3 = builtin "__tfop_Const,dtype$dtype,value$tensor,device"(%1 : $Builtin.Int32, %0 : $Builtin.FPIEEE32, {{.*}}) : $TensorHandle<Builtin.FPIEEE32>
110
110
// CHECK-NEXT: %4 = unchecked_ref_cast %3 : $TensorHandle<Builtin.FPIEEE32> to $TensorHandle<Float>
111
- // CHECK: %6 = builtin "__tfop_Add,$in,$in,device"(%4 : $TensorHandle<Float>, %4 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
112
- // CHECK-NEXT: return %6 : $TensorHandle<Float>
111
+ // CHECK: %7 = builtin "__tfop_Add,$in,$in,T ,device"(%4 : $TensorHandle<Float>, %4 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
112
+ // CHECK-NEXT: return %7 : $TensorHandle<Float>
113
113
// CHECK-NEXT: }
114
114
115
115
@@ -151,7 +151,7 @@ public func testExitBranch2(i: Int) {
151
151
// CHECK: cond_br {{.*}}, bb2, bb1
152
152
153
153
// CHECK: bb1:
154
- // CHECK: builtin "__tfop_Add,$in,$in,device"(
154
+ // CHECK: builtin "__tfop_Add,$in,$in,T, device"(
155
155
// CHECK-NEXT: builtin "tensorflowSend_0"<TensorHandle<Float>>(
156
156
// CHECK-NEXT: br bb2
157
157
@@ -213,7 +213,7 @@ public func test_bool_param2(cond: Bool, // expected-warning {{'cond' implicitly
213
213
// CHECK-LABEL: --- TFPartition Accelerator Result: {{.*}}test_bool_param2{{.*}}
214
214
// CHECK: sil private @{{.*}}test_bool_param2{{.*}}
215
215
// CHECK: bb0(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>, %2 : $TensorHandle<Builtin.Int1>):
216
- // CHECK: builtin "__tfop_Add,$in,$in,device"(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
216
+ // CHECK: builtin "__tfop_Add,$in,$in,T, device"(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
217
217
// CHECK-NEXT: [[BOOL:%.*]] = builtin "tf_tensor_to_i1"(%2 : $TensorHandle<Builtin.Int1>) : $Builtin.Int1
218
218
// CHECK-NEXT: cond_br [[BOOL]]
219
219
// ...
@@ -253,12 +253,12 @@ public func test_while1(maxCount: Int, // expected-warning {{'maxCount' implici
253
253
// CHECK-NEXT: integer_literal $Builtin.Int64, 0
254
254
// CHECK-NEXT: integer_literal $Builtin.Int32, 9
255
255
// CHECK: builtin "__tfop_Const,dtype$dtype,value$tensor,device"(
256
- // CHECK: builtin "__tfop_Add,$in,$in,device"(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>
256
+ // CHECK: builtin "__tfop_Add,$in,$in,T, device"(%0 : $TensorHandle<Float>, %1 : $TensorHandle<Float>
257
257
// CHECK-NEXT: builtin "tf_tensor_to_i1"(
258
258
// CHECK-NEXT: cond_br {{.*}}, bb2, bb1
259
259
260
260
// CHECK: bb3([[A:%.*]] : $TensorHandle<Float>, [[COUNT:%.*]] : $TensorHandle<Builtin.Int64>):
261
- // CHECK: [[NEXTA:%.*]] = builtin "__tfop_Sub,$in,$in,device"([[A]] : $TensorHandle<Float>, %1 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
261
+ // CHECK: [[NEXTA:%.*]] = builtin "__tfop_Sub,$in,$in,T, device"([[A]] : $TensorHandle<Float>, %1 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
262
262
// CHECK: [[NEXTCOUNT:%.*]] = builtin "__tfop_Add,$in,$in,device"([[COUNT]] : $TensorHandle<Builtin.Int64>,
263
263
// CHECK: [[CONDT:%.*]] = builtin "__tfop_Less,$in,$in,device"([[NEXTCOUNT]] : $TensorHandle<Builtin.Int64>,
264
264
// CHECK-NEXT: [[COND:%.*]] = builtin "tf_tensor_to_i1"([[CONDT]] : $TensorHandle<Builtin.Int1>) : $Builtin.Int1
@@ -305,16 +305,16 @@ public func scalar_manipulation(a : Float) -> Tensor<Float> {
305
305
// CHECK: %5 = builtin "__tfop_Const,dtype$dtype,value$tensor,device"(%3 : $Builtin.Int32, %2 : $Builtin.FPIEEE32, {{.*}}) : $TensorHandle<Builtin.FPIEEE32>
306
306
// CHECK-NEXT: %6 = unchecked_ref_cast %5 : $TensorHandle<Builtin.FPIEEE32> to $TensorHandle<Float>
307
307
308
- // CHECK: %8 = builtin "__tfop_Add,$in,$in,device"(%1 : $TensorHandle<Float>, %6 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
309
- // CHECK-NEXT: %9 = builtin "tensorflowSend_1"<TensorHandle<Float>>(%8 : $TensorHandle<Float>) : $()
310
- // CHECK-NEXT: %10 = float_literal $Builtin.FPIEEE32, 0x40000000
311
- // CHECK-NEXT: %11 = integer_literal $Builtin.Int32, 1
312
- // CHECK: %13 = builtin "__tfop_Const,dtype$dtype,value$tensor,device"(%11 : $Builtin.Int32, %10 : $Builtin.FPIEEE32, {{.*}}) : $TensorHandle<Builtin.FPIEEE32>
313
- // CHECK-NEXT: %14 = builtin "tensorflowReceive_0"<TensorHandle<Builtin.FPIEEE32>>() : $TensorHandle<Builtin.FPIEEE32>
314
- // CHECK: %16 = builtin "__tfop_Add,$in,$in,device"(%14 : $TensorHandle<Builtin.FPIEEE32>, %13 : $TensorHandle<Builtin.FPIEEE32>, {{.*}}) : $TensorHandle<Builtin.FPIEEE32>
315
- // CHECK-NEXT: %17 = unchecked_ref_cast %16 : $TensorHandle<Builtin.FPIEEE32> to $TensorHandle<Float>
316
- // CHECK: %19 = builtin "__tfop_Add,$in,$in,device"(%17 : $TensorHandle<Float>, %17 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
317
- // CHECK-NEXT: return %19 : $TensorHandle<Float>
308
+ // CHECK: %9 = builtin "__tfop_Add,$in,$in,T ,device"(%1 : $TensorHandle<Float>, %6 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
309
+ // CHECK-NEXT: %10 = builtin "tensorflowSend_1"<TensorHandle<Float>>(%9 : $TensorHandle<Float>) : $()
310
+ // CHECK-NEXT: %11 = float_literal $Builtin.FPIEEE32, 0x40000000
311
+ // CHECK-NEXT: %12 = integer_literal $Builtin.Int32, 1
312
+ // CHECK: %14 = builtin "__tfop_Const,dtype$dtype,value$tensor,device"(%12 : $Builtin.Int32, %11 : $Builtin.FPIEEE32, {{.*}}) : $TensorHandle<Builtin.FPIEEE32>
313
+ // CHECK-NEXT: %15 = builtin "tensorflowReceive_0"<TensorHandle<Builtin.FPIEEE32>>() : $TensorHandle<Builtin.FPIEEE32>
314
+ // CHECK: %17 = builtin "__tfop_Add,$in,$in,device"(%15 : $TensorHandle<Builtin.FPIEEE32>, %14 : $TensorHandle<Builtin.FPIEEE32>, {{.*}}) : $TensorHandle<Builtin.FPIEEE32>
315
+ // CHECK-NEXT: %18 = unchecked_ref_cast %17 : $TensorHandle<Builtin.FPIEEE32> to $TensorHandle<Float>
316
+ // CHECK: %21 = builtin "__tfop_Add,$in,$in,T, device"(%18 : $TensorHandle<Float>, %18 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
317
+ // CHECK-NEXT: return %21 : $TensorHandle<Float>
318
318
// CHECK-NEXT:}
319
319
320
320
@@ -327,10 +327,10 @@ public func testCast(x: Tensor<Float>) -> Tensor<Int32> {
327
327
// CHECK-LABEL: --- TFPartition Accelerator Result: {{.*}}testCast
328
328
// CHECK: sil private @{{.*}}testCast{{.*}} : $@callee_owned (TensorHandle<Float>) -> TensorHandle<Int32> {
329
329
// CHECK: bb0(%0 : $TensorHandle<Float>):
330
- // CHECK: %2 = builtin "__tfop_Add,$in,$in,device"(%0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
331
- // CHECK: %3 = metatype $@thick Int32.Type
332
- // CHECK: %5 = builtin "__tfop_Cast,$in,DstT,device"(%2 : $TensorHandle<Float>, %3 : $@thick Int32.Type, {{.*}}) : $TensorHandle<Int32>
333
- // CHECK: return %5 : $TensorHandle<Int32>
330
+ // CHECK: %3 = builtin "__tfop_Add,$in,$in,T ,device"(%0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
331
+ // CHECK: %5 = metatype $@thick Int32.Type
332
+ // CHECK: %7 = builtin "__tfop_Cast,$in,SrcT, DstT,device"(%3 : $TensorHandle<Float>, %4 : $@thick Float.Type, %5 : $@thick Int32.Type, {{.*}}) : $TensorHandle<Int32>
333
+ // CHECK: return %7 : $TensorHandle<Int32>
334
334
335
335
336
336
@@ -351,7 +351,7 @@ public func testInputListArguments(a: TensorHandle<Float>, b: Tensor<Float>) ->
351
351
CHECK: [[PACK1:%.*]] = builtin "__tfop_Pack,$in,$inelt,$inelt,$inelt,device"(%2 : $@thin TensorHandle<Float>.Type, %0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
352
352
CHECK: [[TYPE:%.*]] = metatype $@thin Tensor<Float>.Type
353
353
CHECK: [[PACK2:%.*]] = builtin "__tfop_Pack,$in,$inelt,$inelt,$inelt,device"([[TYPE]] : $@thin Tensor<Float>.Type, %1 : $TensorHandle<Float>, %1 : $TensorHandle<Float>, %1 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
354
- CHECK: [[RET:%.*]] = builtin "__tfop_Add,$in,$in,device"([[PACK1]] : $TensorHandle<Float>, [[PACK2]] : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
354
+ CHECK: [[RET:%.*]] = builtin "__tfop_Add,$in,$in,T, device"([[PACK1]] : $TensorHandle<Float>, [[PACK2]] : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
355
355
CHECK: return [[RET]] : $TensorHandle<Float>
356
356
CHECK: }
357
357
*/
@@ -378,7 +378,7 @@ public func liveOutTest(
378
378
379
379
/*
380
380
CHECK-LABEL: --- TFPartition Host Result: {{.*}}liveOutTest{{.*}}
381
- CHECK: @{{.*}}liveOutTest{{.*}} : $@convention(thin) (@owned Tensor<Float>, @owned Tensor<Float>, @owned Tensor<Float>) -> @owned Tensor<Float> {
381
+ CHECK: @{{.*}}liveOutTest{{.*}} : $@convention(thin) (@guaranteed Tensor<Float>, @guaranteed Tensor<Float>, @guaranteed Tensor<Float>) -> @owned Tensor<Float> {
382
382
383
383
// [[RESULTBUF:%.*]] = alloc_stack $OpaquePointer
384
384
// [[RESULTACCESS:%.*]] = begin_access [modify] [static] [[RESULTBUF]] : $*OpaquePointer
@@ -441,8 +441,8 @@ func shouldntInline(_ a: Tensor<Float>) -> Tensor<Float> {
441
441
442
442
// CHECK-LABEL: --- TFPartition Accelerator Result: {{.*}}shouldntInline
443
443
// CHECK: bb0(%0 : $TensorHandle<Float>):
444
- // CHECK: %2 = builtin "__tfop_Mul,$in,$in,device"(%0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
445
- // CHECK: return %2 : $TensorHandle<Float>
444
+ // CHECK: %3 = builtin "__tfop_Mul,$in,$in,T ,device"(%0 : $TensorHandle<Float>, %0 : $TensorHandle<Float>, {{.*}}) : $TensorHandle<Float>
445
+ // CHECK: return %3 : $TensorHandle<Float>
446
446
// CHECK-LABEL: ----
447
447
448
448
public func testNotInlined( ) {
@@ -514,5 +514,5 @@ public func test77437755(_ hiddenSize: Float) {
514
514
// CHECK-LABEL: ---- INPUT FUNCTION {{.*}}test77437755{{.*}} ----------
515
515
// CHECK: [[STDDEV:%.*]] = builtin "fdiv_FPIEEE32"
516
516
// CHECK: [[STDDEVT:%.*]] = builtin "__tfop_tfc.scalarToTensor,$in"([[STDDEV]] : $Builtin.FPIEEE32) : $TensorHandle<Float>
517
- // CHECK: builtin "__tfop_Mul,$in,$in"({{.*}} : $TensorHandle<Float>, [[STDDEVT]] : $TensorHandle<Float>)
517
+ // CHECK: builtin "__tfop_Mul,$in,$in,T "({{.*}} : $TensorHandle<Float>, [[STDDEVT]] : $TensorHandle<Float>, {{.*}} )
518
518
// CHECK-LABEL: ---- END OF INPUT FUNCTION ----------
0 commit comments