2019-03-03 14:34:18 +08:00
|
|
|
// RUN: mlir-opt %s | FileCheck %s
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2018-10-27 00:07:10 +08:00
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1, d2, d3, d4)[s0] -> (d0, d1, d2, d4, d3)
|
|
|
|
#map0 = (d0, d1, d2, d3, d4)[s0] -> (d0, d1, d2, d4, d3)
|
2018-07-18 07:56:54 +08:00
|
|
|
|
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0) -> (d0)
|
2018-07-17 00:45:22 +08:00
|
|
|
#map1 = (d0) -> (d0)
|
2018-07-18 07:56:54 +08:00
|
|
|
|
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1, d2) -> (d0, d1, d2)
|
2018-07-17 00:45:22 +08:00
|
|
|
#map2 = (d0, d1, d2) -> (d0, d1, d2)
|
2018-07-18 07:56:54 +08:00
|
|
|
|
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1, d2) -> (d1, d0, d2)
|
2018-07-17 00:45:22 +08:00
|
|
|
#map3 = (d0, d1, d2) -> (d1, d0, d2)
|
2018-07-18 07:56:54 +08:00
|
|
|
|
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1, d2) -> (d2, d1, d0)
|
2018-07-17 00:45:22 +08:00
|
|
|
#map4 = (d0, d1, d2) -> (d2, d1, d0)
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2018-08-25 14:38:14 +08:00
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = ()[s0] -> (0, s0 - 1)
|
|
|
|
#inline_map_minmax_loop1 = ()[s0] -> (0, s0 - 1)
|
|
|
|
|
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = ()[s0] -> (100, s0 + 1)
|
|
|
|
#inline_map_minmax_loop2 = ()[s0] -> (100, s0 + 1)
|
|
|
|
|
2018-10-30 21:11:29 +08:00
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1)[s0] -> (d0 + d1 + s0)
|
2018-08-25 14:38:14 +08:00
|
|
|
#bound_map1 = (i, j)[s] -> (i + j + s)
|
|
|
|
|
2018-10-30 21:11:29 +08:00
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1) -> (d0 + d1)
|
2018-08-25 14:38:14 +08:00
|
|
|
#inline_map_loop_bounds2 = (d0, d1) -> (d0 + d1)
|
|
|
|
|
2018-10-30 21:11:29 +08:00
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0)[s0] -> (d0 + s0, d0 - s0)
|
2018-08-25 14:38:14 +08:00
|
|
|
#bound_map2 = (i)[s] -> (i + s, i - s)
|
|
|
|
|
2018-10-30 21:11:29 +08:00
|
|
|
// All maps appear in arbitrary order before all sets, in arbitrary order.
|
|
|
|
// CHECK-EMPTY
|
|
|
|
|
2019-01-21 22:59:58 +08:00
|
|
|
// CHECK-DAG: #set{{[0-9]+}} = (d0)[s0, s1] : (d0 >= 0, -d0 + s0 >= 0, s0 - 5 == 0, -d0 + s1 + 1 >= 0)
|
2018-10-26 09:33:42 +08:00
|
|
|
#set0 = (i)[N, M] : (i >= 0, -i + N >= 0, N - 5 == 0, -i + M + 1 >= 0)
|
2018-08-08 05:24:38 +08:00
|
|
|
|
2018-10-26 13:13:03 +08:00
|
|
|
// CHECK-DAG: #set{{[0-9]+}} = (d0, d1)[s0] : (d0 >= 0, d1 >= 0)
|
|
|
|
#set1 = (d0, d1)[s0] : (d0 >= 0, d1 >= 0)
|
|
|
|
|
|
|
|
// CHECK-DAG: #set{{[0-9]+}} = (d0) : (d0 - 1 == 0)
|
|
|
|
#set2 = (d0) : (d0 - 1 == 0)
|
|
|
|
|
2019-02-03 13:01:11 +08:00
|
|
|
// CHECK-DAG: [[SET_TRUE:#set[0-9]+]] = () : (0 == 0)
|
|
|
|
|
2019-01-21 22:59:58 +08:00
|
|
|
// CHECK-DAG: #set{{[0-9]+}} = (d0)[s0] : (d0 - 2 >= 0, -d0 + 4 >= 0)
|
2018-08-08 05:24:38 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @foo(i32, i64) -> f32
|
|
|
|
func @foo(i32, i64) -> f32
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @bar()
|
|
|
|
func @bar() -> ()
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @baz() -> (i1, index, f32)
|
|
|
|
func @baz() -> (i1, index, f32)
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @missingReturn()
|
|
|
|
func @missingReturn()
|
2018-06-23 06:52:02 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @int_types(i1, i2, i4, i7, i87) -> (i1, index, i19)
|
|
|
|
func @int_types(i1, i2, i4, i7, i87) -> (i1, index, i19)
|
2018-06-30 13:08:05 +08:00
|
|
|
|
2018-06-23 06:52:02 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @vectors(vector<1xf32>, vector<2x4xf32>)
|
|
|
|
func @vectors(vector<1 x f32>, vector<2x4xf32>)
|
2018-06-23 06:52:02 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @tensors(tensor<*xf32>, tensor<*xvector<2x4xf32>>, tensor<1x?x4x?x?xi32>, tensor<i8>)
|
|
|
|
func @tensors(tensor<* x f32>, tensor<* x vector<2x4xf32>>,
|
Eliminate "primitive" types from being a thing, splitting them into FloatType
and OtherType. Other type is now the thing that holds AffineInt, Control,
eventually Resource, Variant, String, etc. FloatType holds the floating point
types, and allows convenient query of isa<FloatType>().
This fixes issues where we allowed control to be the element type of tensor,
memref, vector. At the same time, ban AffineInt from being an element of a
vector/memref/tensor as well since we don't need it.
I updated the spec to match this as well.
PiperOrigin-RevId: 206361942
2018-07-28 04:09:58 +08:00
|
|
|
tensor<1x?x4x?x?xi32>, tensor<i8>)
|
2018-06-23 06:52:02 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs(memref<1x?x4x?x?xi32, #map{{[0-9]+}}>, memref<8xi8>)
|
|
|
|
func @memrefs(memref<1x?x4x?x?xi32, #map0>, memref<8xi8, #map1, #map1>)
|
2018-06-23 13:03:48 +08:00
|
|
|
|
2018-07-17 00:45:22 +08:00
|
|
|
// Test memref affine map compositions.
|
2018-06-24 07:03:42 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs2(memref<2x4x8xi8, 1>)
|
|
|
|
func @memrefs2(memref<2x4x8xi8, #map2, 1>)
|
2018-07-17 00:45:22 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs23(memref<2x4x8xi8, #map{{[0-9]+}}>)
|
|
|
|
func @memrefs23(memref<2x4x8xi8, #map2, #map3, 0>)
|
2018-07-17 00:45:22 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs234(memref<2x4x8xi8, #map{{[0-9]+}}, #map{{[0-9]+}}, 3>)
|
|
|
|
func @memrefs234(memref<2x4x8xi8, #map2, #map3, #map4, 3>)
|
2018-07-17 00:45:22 +08:00
|
|
|
|
2018-10-30 21:11:29 +08:00
|
|
|
// Test memref inline affine map compositions, minding that identity maps are removed.
|
2018-07-17 00:45:22 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs3(memref<2x4x8xi8>)
|
|
|
|
func @memrefs3(memref<2x4x8xi8, (d0, d1, d2) -> (d0, d1, d2)>)
|
2018-07-17 00:45:22 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs33(memref<2x4x8xi8, #map{{[0-9]+}}, 1>)
|
|
|
|
func @memrefs33(memref<2x4x8xi8, (d0, d1, d2) -> (d0, d1, d2), (d0, d1, d2) -> (d1, d0, d2), 1>)
|
2018-07-17 00:45:22 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs_drop_triv_id_inline(memref<2xi8>)
|
|
|
|
func @memrefs_drop_triv_id_inline(memref<2xi8, (d0) -> (d0)>)
|
2018-10-27 00:07:10 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs_drop_triv_id_inline0(memref<2xi8>)
|
|
|
|
func @memrefs_drop_triv_id_inline0(memref<2xi8, (d0) -> (d0), 0>)
|
2018-10-27 00:07:10 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs_drop_triv_id_inline1(memref<2xi8, 1>)
|
|
|
|
func @memrefs_drop_triv_id_inline1(memref<2xi8, (d0) -> (d0), 1>)
|
2018-10-27 00:07:10 +08:00
|
|
|
|
2018-10-30 21:11:29 +08:00
|
|
|
// Identity maps should be dropped from the composition, but not the pair of
|
|
|
|
// "interchange" maps that, if composed, would be also an identity.
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs_drop_triv_id_composition(memref<2x2xi8, #map{{[0-9]+}}, #map{{[0-9]+}}>)
|
|
|
|
func @memrefs_drop_triv_id_composition(memref<2x2xi8,
|
2018-10-30 21:11:29 +08:00
|
|
|
(d0, d1) -> (d1, d0),
|
|
|
|
(d0, d1) -> (d0, d1),
|
|
|
|
(d0, d1) -> (d1, d0),
|
|
|
|
(d0, d1) -> (d0, d1),
|
|
|
|
(d0, d1) -> (d0, d1)>)
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs_drop_triv_id_trailing(memref<2x2xi8, #map{{[0-9]+}}>)
|
|
|
|
func @memrefs_drop_triv_id_trailing(memref<2x2xi8, (d0, d1) -> (d1, d0),
|
2018-10-30 21:11:29 +08:00
|
|
|
(d0, d1) -> (d0, d1)>)
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs_drop_triv_id_middle(memref<2x2xi8, #map{{[0-9]+}}, #map{{[0-9]+}}>)
|
|
|
|
func @memrefs_drop_triv_id_middle(memref<2x2xi8, (d0, d1) -> (d0, d1 + 1),
|
2018-10-30 21:11:29 +08:00
|
|
|
(d0, d1) -> (d0, d1),
|
|
|
|
(d0, d1) -> (d0 + 1, d1)>)
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs_drop_triv_id_multiple(memref<2xi8>)
|
|
|
|
func @memrefs_drop_triv_id_multiple(memref<2xi8, (d0) -> (d0), (d0) -> (d0)>)
|
2018-10-30 21:11:29 +08:00
|
|
|
|
2018-10-27 00:07:10 +08:00
|
|
|
// These maps appeared before, so they must be uniqued and hoisted to the beginning.
|
2018-10-30 21:11:29 +08:00
|
|
|
// Identity map should be removed.
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @memrefs_compose_with_id(memref<2x2xi8, #map{{[0-9]+}}>)
|
|
|
|
func @memrefs_compose_with_id(memref<2x2xi8, (d0, d1) -> (d0, d1),
|
2018-10-27 00:07:10 +08:00
|
|
|
(d0, d1) -> (d1, d0)>)
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @functions((memref<1x?x4x?x?xi32, #map0>, memref<8xi8>) -> (), () -> ())
|
|
|
|
func @functions((memref<1x?x4x?x?xi32, #map0, 0>, memref<8xi8, #map1, 0>) -> (), ()->())
|
2018-06-24 07:03:42 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @simpleCFG(%arg0: i32, %arg1: f32) -> i1 {
|
|
|
|
func @simpleCFG(%arg0: i32, %f: f32) -> i1 {
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %0 = "foo"() : () -> i64
|
2018-07-19 23:35:28 +08:00
|
|
|
%1 = "foo"() : ()->i64
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: "bar"(%0) : (i64) -> (i1, i1, i1)
|
2018-07-21 00:28:54 +08:00
|
|
|
%2 = "bar"(%1) : (i64) -> (i1,i1,i1)
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: return %1#1
|
2018-07-23 23:42:19 +08:00
|
|
|
return %2#1 : i1
|
2018-07-19 06:31:25 +08:00
|
|
|
// CHECK: }
|
|
|
|
}
|
2018-06-24 07:03:42 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @simpleCFGUsingBBArgs(%arg0: i32, %arg1: i64) {
|
|
|
|
func @simpleCFGUsingBBArgs(i32, i64) {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb42 (%arg0: i32, %f: i64):
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: "bar"(%arg1) : (i64) -> (i1, i1, i1)
|
2018-07-23 06:45:24 +08:00
|
|
|
%2 = "bar"(%f) : (i64) -> (i1,i1,i1)
|
2018-08-02 23:28:20 +08:00
|
|
|
// CHECK: return{{$}}
|
2018-07-23 06:45:24 +08:00
|
|
|
return
|
|
|
|
// CHECK: }
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @multiblock() {
|
|
|
|
func @multiblock() {
|
2018-07-15 14:06:24 +08:00
|
|
|
return // CHECK: return
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb1: // CHECK: ^bb1: // no predecessors
|
|
|
|
br ^bb4 // CHECK: br ^bb3
|
|
|
|
^bb2: // CHECK: ^bb2: // pred: ^bb2
|
|
|
|
br ^bb2 // CHECK: br ^bb2
|
|
|
|
^bb4: // CHECK: ^bb3: // pred: ^bb1
|
2018-07-15 14:06:24 +08:00
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @emptyMLF() {
|
|
|
|
func @emptyMLF() {
|
2018-07-15 14:06:24 +08:00
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
2018-06-29 08:02:32 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @func_with_one_arg(%arg0: i1) -> i2 {
|
|
|
|
func @func_with_one_arg(%c : i1) -> i2 {
|
2018-08-07 02:54:39 +08:00
|
|
|
// CHECK: %0 = "foo"(%arg0) : (i1) -> i2
|
|
|
|
%b = "foo"(%c) : (i1) -> (i2)
|
2018-08-10 03:28:58 +08:00
|
|
|
return %b : i2 // CHECK: return %0 : i2
|
|
|
|
} // CHECK: }
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @func_with_two_args(%arg0: f16, %arg1: i8) -> (i1, i32) {
|
|
|
|
func @func_with_two_args(%a : f16, %b : i8) -> (i1, i32) {
|
2018-08-10 03:28:58 +08:00
|
|
|
// CHECK: %0 = "foo"(%arg0, %arg1) : (f16, i8) -> (i1, i32)
|
|
|
|
%c = "foo"(%a, %b) : (f16, i8)->(i1, i32)
|
|
|
|
return %c#0, %c#1 : i1, i32 // CHECK: return %0#0, %0#1 : i1, i32
|
|
|
|
} // CHECK: }
|
|
|
|
|
2019-02-06 03:47:02 +08:00
|
|
|
// CHECK-LABEL: func @second_order_func() -> (() -> ()) {
|
|
|
|
func @second_order_func() -> (() -> ()) {
|
|
|
|
// CHECK-NEXT: %f = constant @emptyMLF : () -> ()
|
|
|
|
%c = constant @emptyMLF : () -> ()
|
|
|
|
// CHECK-NEXT: return %f : () -> ()
|
|
|
|
return %c : () -> ()
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @third_order_func() -> (() -> (() -> ())) {
|
|
|
|
func @third_order_func() -> (() -> (() -> ())) {
|
|
|
|
// CHECK-NEXT: %f = constant @second_order_func : () -> (() -> ())
|
|
|
|
%c = constant @second_order_func : () -> (() -> ())
|
|
|
|
// CHECK-NEXT: return %f : () -> (() -> ())
|
|
|
|
return %c : () -> (() -> ())
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @identity_functor(%arg0: () -> ()) -> (() -> ()) {
|
|
|
|
func @identity_functor(%a : () -> ()) -> (() -> ()) {
|
|
|
|
// CHECK-NEXT: return %arg0 : () -> ()
|
|
|
|
return %a : () -> ()
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @func_ops_in_loop() {
|
|
|
|
func @func_ops_in_loop() {
|
2018-07-27 09:09:20 +08:00
|
|
|
// CHECK: %0 = "foo"() : () -> i64
|
|
|
|
%a = "foo"() : ()->i64
|
2019-02-07 13:54:18 +08:00
|
|
|
// CHECK: for %i0 = 1 to 10 {
|
|
|
|
for %i = 1 to 10 {
|
2018-07-27 09:09:20 +08:00
|
|
|
// CHECK: %1 = "doo"() : () -> f32
|
|
|
|
%b = "doo"() : ()->f32
|
|
|
|
// CHECK: "bar"(%0, %1) : (i64, f32) -> ()
|
|
|
|
"bar"(%a, %b) : (i64, f32) -> ()
|
|
|
|
// CHECK: }
|
|
|
|
}
|
|
|
|
// CHECK: return
|
|
|
|
return
|
|
|
|
// CHECK: }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @loops() {
|
|
|
|
func @loops() {
|
2019-02-07 13:54:18 +08:00
|
|
|
// CHECK: for %i0 = 1 to 100 step 2 {
|
|
|
|
for %i = 1 to 100 step 2 {
|
|
|
|
// CHECK: for %i1 = 1 to 200 {
|
|
|
|
for %j = 1 to 200 {
|
2018-07-15 14:06:24 +08:00
|
|
|
} // CHECK: }
|
|
|
|
} // CHECK: }
|
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @complex_loops() {
|
|
|
|
func @complex_loops() {
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i1 = 1 to 100 { // CHECK: for %i0 = 1 to 100 {
|
|
|
|
for %j1 = 1 to 100 { // CHECK: for %i1 = 1 to 100 {
|
2018-10-07 08:21:53 +08:00
|
|
|
// CHECK: "foo"(%i0, %i1) : (index, index) -> ()
|
|
|
|
"foo"(%i1, %j1) : (index,index) -> ()
|
2018-07-31 06:18:10 +08:00
|
|
|
} // CHECK: }
|
|
|
|
"boo"() : () -> () // CHECK: "boo"() : () -> ()
|
2019-02-07 13:54:18 +08:00
|
|
|
for %j2 = 1 to 10 { // CHECK: for %i2 = 1 to 10 {
|
|
|
|
for %k2 = 1 to 10 { // CHECK: for %i3 = 1 to 10 {
|
2018-07-31 06:18:10 +08:00
|
|
|
"goo"() : () -> () // CHECK: "goo"() : () -> ()
|
|
|
|
} // CHECK: }
|
|
|
|
} // CHECK: }
|
|
|
|
} // CHECK: }
|
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @triang_loop(%arg0: index, %arg1: memref<?x?xi32>) {
|
|
|
|
func @triang_loop(%arg0: index, %arg1: memref<?x?xi32>) {
|
2018-08-25 14:38:14 +08:00
|
|
|
%c = constant 0 : i32 // CHECK: %c0_i32 = constant 0 : i32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 1 to %arg0 { // CHECK: for %i0 = 1 to %arg0 {
|
|
|
|
for %i1 = (d0)[]->(d0)(%i0)[] to %arg0 { // CHECK: for %i1 = #map{{[0-9]+}}(%i0) to %arg0 {
|
2018-08-25 14:38:14 +08:00
|
|
|
store %c, %arg1[%i0, %i1] : memref<?x?xi32> // CHECK: store %c0_i32, %arg1[%i0, %i1]
|
|
|
|
} // CHECK: }
|
|
|
|
} // CHECK: }
|
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: func @minmax_loop(%arg0: index, %arg1: index, %arg2: memref<100xf32>) {
|
|
|
|
func @minmax_loop(%arg0: index, %arg1: index, %arg2: memref<100xf32>) {
|
2019-02-07 13:54:18 +08:00
|
|
|
// CHECK: for %i0 = max #map{{.*}}()[%arg0] to min #map{{.*}}()[%arg1] {
|
|
|
|
for %i0 = max()[s]->(0,s-1)()[%arg0] to min()[s]->(100,s+1)()[%arg1] {
|
2018-10-07 08:21:53 +08:00
|
|
|
// CHECK: "foo"(%arg2, %i0) : (memref<100xf32>, index) -> ()
|
|
|
|
"foo"(%arg2, %i0) : (memref<100xf32>, index) -> ()
|
2018-08-25 14:38:14 +08:00
|
|
|
} // CHECK: }
|
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @loop_bounds(%arg0: index) {
|
|
|
|
func @loop_bounds(%N : index) {
|
2018-10-07 08:21:53 +08:00
|
|
|
// CHECK: %0 = "foo"(%arg0) : (index) -> index
|
|
|
|
%s = "foo"(%N) : (index) -> index
|
2019-02-07 13:54:18 +08:00
|
|
|
// CHECK: for %i0 = %0 to %arg0
|
|
|
|
for %i = %s to %N {
|
|
|
|
// CHECK: for %i1 = #map{{[0-9]+}}(%i0) to 0
|
|
|
|
for %j = (d0)[]->(d0)(%i)[] to 0 step 1 {
|
2019-02-07 03:08:18 +08:00
|
|
|
// CHECK: %1 = affine.apply #map{{.*}}(%i0, %i1)[%0]
|
|
|
|
%w1 = affine.apply(d0, d1)[s0] -> (d0+d1) (%i, %j) [%s]
|
|
|
|
// CHECK: %2 = affine.apply #map{{.*}}(%i0, %i1)[%0]
|
|
|
|
%w2 = affine.apply(d0, d1)[s0] -> (s0+1) (%i, %j) [%s]
|
2019-02-07 13:54:18 +08:00
|
|
|
// CHECK: for %i2 = #map{{.*}}(%1, %i0)[%arg0] to #map{{.*}}(%2, %i1)[%0] {
|
|
|
|
for %k = #bound_map1 (%w1, %i)[%N] to (i, j)[s] -> (i + j + s) (%w2, %j)[%s] {
|
2018-10-07 08:21:53 +08:00
|
|
|
// CHECK: "foo"(%i0, %i1, %i2) : (index, index, index) -> ()
|
|
|
|
"foo"(%i, %j, %k) : (index, index, index)->()
|
|
|
|
// CHECK: %c30 = constant 30 : index
|
|
|
|
%c = constant 30 : index
|
2019-02-07 03:08:18 +08:00
|
|
|
// CHECK: %3 = affine.apply #map{{.*}}(%arg0, %c30)
|
|
|
|
%u = affine.apply (d0, d1)->(d0+d1) (%N, %c)
|
2019-02-07 13:54:18 +08:00
|
|
|
// CHECK: for %i3 = max #map{{.*}}(%i0)[%3] to min #map{{.*}}(%i2)[%c30] {
|
|
|
|
for %l = max #bound_map2(%i)[%u] to min #bound_map2(%k)[%c] {
|
2018-10-07 08:21:53 +08:00
|
|
|
// CHECK: "bar"(%i3) : (index) -> ()
|
|
|
|
"bar"(%l) : (index) -> ()
|
2018-08-25 14:38:14 +08:00
|
|
|
} // CHECK: }
|
|
|
|
} // CHECK: }
|
|
|
|
} // CHECK: }
|
|
|
|
} // CHECK: }
|
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @ifinst(%arg0: index) {
|
|
|
|
func @ifinst(%N: index) {
|
2018-10-07 08:21:53 +08:00
|
|
|
%c = constant 200 : index // CHECK %c200 = constant 200
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i = 1 to 10 { // CHECK for %i0 = 1 to 10 {
|
2019-03-25 11:35:07 +08:00
|
|
|
affine.if #set0(%i)[%N, %c] { // CHECK affine.if #set0(%i0)[%arg0, %c200] {
|
2018-08-08 05:24:38 +08:00
|
|
|
%x = constant 1 : i32
|
|
|
|
// CHECK: %c1_i32 = constant 1 : i32
|
2018-10-07 08:21:53 +08:00
|
|
|
%y = "add"(%x, %i) : (i32, index) -> i32 // CHECK: %0 = "add"(%c1_i32, %i0) : (i32, index) -> i32
|
2018-08-08 05:24:38 +08:00
|
|
|
%z = "mul"(%y, %y) : (i32, i32) -> i32 // CHECK: %1 = "mul"(%0, %0) : (i32, i32) -> i32
|
2019-01-29 13:23:53 +08:00
|
|
|
} else { // CHECK } else {
|
2019-03-25 11:35:07 +08:00
|
|
|
affine.if (i)[N] : (i - 2 >= 0, 4 - i >= 0)(%i)[%N] { // CHECK affine.if (#set1(%i0)[%arg0]) {
|
2019-01-29 13:23:53 +08:00
|
|
|
// CHECK: %c1 = constant 1 : index
|
|
|
|
%u = constant 1 : index
|
2019-02-07 03:08:18 +08:00
|
|
|
// CHECK: %2 = affine.apply #map{{.*}}(%i0, %i0)[%c1]
|
|
|
|
%w = affine.apply (d0,d1)[s0] -> (d0+d1+s0) (%i, %i) [%u]
|
2019-01-29 13:23:53 +08:00
|
|
|
} else { // CHECK } else {
|
|
|
|
%v = constant 3 : i32 // %c3_i32 = constant 3 : i32
|
|
|
|
}
|
2018-08-08 05:24:38 +08:00
|
|
|
} // CHECK }
|
|
|
|
} // CHECK }
|
|
|
|
return // CHECK return
|
|
|
|
} // CHECK }
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @simple_ifinst(%arg0: index) {
|
|
|
|
func @simple_ifinst(%N: index) {
|
2018-10-07 08:21:53 +08:00
|
|
|
%c = constant 200 : index // CHECK %c200 = constant 200
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i = 1 to 10 { // CHECK for %i0 = 1 to 10 {
|
2019-03-25 11:35:07 +08:00
|
|
|
affine.if #set0(%i)[%N, %c] { // CHECK affine.if #set0(%i0)[%arg0, %c200] {
|
2018-09-01 13:33:47 +08:00
|
|
|
%x = constant 1 : i32
|
|
|
|
// CHECK: %c1_i32 = constant 1 : i32
|
2018-10-07 08:21:53 +08:00
|
|
|
%y = "add"(%x, %i) : (i32, index) -> i32 // CHECK: %0 = "add"(%c1_i32, %i0) : (i32, index) -> i32
|
2018-09-01 13:33:47 +08:00
|
|
|
%z = "mul"(%y, %y) : (i32, i32) -> i32 // CHECK: %1 = "mul"(%0, %0) : (i32, i32) -> i32
|
|
|
|
} // CHECK }
|
|
|
|
} // CHECK }
|
|
|
|
return // CHECK return
|
|
|
|
} // CHECK }
|
2018-07-15 14:06:24 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @attributes() {
|
|
|
|
func @attributes() {
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: "foo"()
|
2018-07-19 06:31:25 +08:00
|
|
|
"foo"(){} : ()->()
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-08-03 07:54:36 +08:00
|
|
|
// CHECK: "foo"() {a: 1, b: -423, c: [true, false], d: 1.600000e+01} : () -> ()
|
|
|
|
"foo"() {a: 1, b: -423, c: [true, false], d: 16.0 } : () -> ()
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-08-03 07:54:36 +08:00
|
|
|
// CHECK: "foo"() {map1: #map{{[0-9]+}}}
|
|
|
|
"foo"() {map1: #map1} : () -> ()
|
2018-07-19 07:29:21 +08:00
|
|
|
|
2018-08-03 07:54:36 +08:00
|
|
|
// CHECK: "foo"() {map2: #map{{[0-9]+}}}
|
|
|
|
"foo"() {map2: (d0, d1, d2) -> (d0, d1, d2)} : () -> ()
|
2018-07-19 07:29:21 +08:00
|
|
|
|
2018-08-03 07:54:36 +08:00
|
|
|
// CHECK: "foo"() {map12: [#map{{[0-9]+}}, #map{{[0-9]+}}]}
|
|
|
|
"foo"() {map12: [#map1, #map2]} : () -> ()
|
2018-07-19 07:29:21 +08:00
|
|
|
|
2018-10-26 13:13:03 +08:00
|
|
|
// CHECK: "foo"() {set1: #set{{[0-9]+}}}
|
|
|
|
"foo"() {set1: #set1} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "foo"() {set2: #set{{[0-9]+}}}
|
|
|
|
"foo"() {set2: (d0, d1, d2) : (d0 >= 0, d1 >= 0, d2 - d1 == 0)} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "foo"() {set12: [#set{{[0-9]+}}, #set{{[0-9]+}}]}
|
|
|
|
"foo"() {set12: [#set1, #set2]} : () -> ()
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK: "foo"() {d: 1.000000e-09, func: [], i123: 7, if: "foo"} : () -> ()
|
|
|
|
"foo"() {if: "foo", func: [], i123: 7, d: 1.e-9} : () -> ()
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-12-29 08:05:35 +08:00
|
|
|
// CHECK: "foo"() {fn: @attributes : () -> (), if: @ifinst : (index) -> ()} : () -> ()
|
|
|
|
"foo"() {fn: @attributes : () -> (), if: @ifinst : (index) -> ()} : () -> ()
|
2019-02-05 23:12:46 +08:00
|
|
|
|
|
|
|
// CHECK: "foo"() {int: 0} : () -> ()
|
|
|
|
"foo"() {int: 0 : i64} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "foo"() {int: 0 : i42} : () -> ()
|
|
|
|
"foo"() {int: 0 : i42} : () -> ()
|
2018-07-06 00:12:11 +08:00
|
|
|
return
|
2018-07-05 11:45:39 +08:00
|
|
|
}
|
2018-07-21 09:41:34 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @ssa_values() -> (i16, i8) {
|
|
|
|
func @ssa_values() -> (i16, i8) {
|
2018-07-21 09:41:34 +08:00
|
|
|
// CHECK: %0 = "foo"() : () -> (i1, i17)
|
|
|
|
%0 = "foo"() : () -> (i1, i17)
|
2018-12-30 03:32:37 +08:00
|
|
|
br ^bb2
|
2018-07-21 09:41:34 +08:00
|
|
|
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb1: // CHECK: ^bb1: // pred: ^bb2
|
2018-07-22 05:32:09 +08:00
|
|
|
// CHECK: %1 = "baz"(%2#1, %2#0, %0#1) : (f32, i11, i17) -> (i16, i8)
|
|
|
|
%1 = "baz"(%2#1, %2#0, %0#1) : (f32, i11, i17) -> (i16, i8)
|
2018-07-25 01:41:30 +08:00
|
|
|
|
2018-07-25 06:01:27 +08:00
|
|
|
// CHECK: return %1#0, %1#1 : i16, i8
|
2018-07-24 02:56:17 +08:00
|
|
|
return %1#0, %1#1 : i16, i8
|
2018-07-21 09:41:34 +08:00
|
|
|
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb2: // CHECK: ^bb2: // pred: ^bb0
|
2018-07-21 09:41:34 +08:00
|
|
|
// CHECK: %2 = "bar"(%0#0, %0#1) : (i1, i17) -> (i11, f32)
|
|
|
|
%2 = "bar"(%0#0, %0#1) : (i1, i17) -> (i11, f32)
|
2018-12-30 03:32:37 +08:00
|
|
|
br ^bb1
|
2018-07-23 23:42:19 +08:00
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @bbargs() -> (i16, i8) {
|
|
|
|
func @bbargs() -> (i16, i8) {
|
2018-07-23 23:42:19 +08:00
|
|
|
// CHECK: %0 = "foo"() : () -> (i1, i17)
|
|
|
|
%0 = "foo"() : () -> (i1, i17)
|
2018-12-30 03:32:37 +08:00
|
|
|
br ^bb1(%0#1, %0#0 : i17, i1)
|
2018-07-23 23:42:19 +08:00
|
|
|
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb1(%x: i17, %y: i1): // CHECK: ^bb1(%1: i17, %2: i1):
|
2018-07-23 23:42:19 +08:00
|
|
|
// CHECK: %3 = "baz"(%1, %2, %0#1) : (i17, i1, i17) -> (i16, i8)
|
|
|
|
%1 = "baz"(%x, %y, %0#1) : (i17, i1, i17) -> (i16, i8)
|
2018-07-24 02:56:17 +08:00
|
|
|
return %1#0, %1#1 : i16, i8
|
2018-07-23 23:42:19 +08:00
|
|
|
}
|
2018-07-25 06:01:27 +08:00
|
|
|
|
2019-01-10 04:28:30 +08:00
|
|
|
// CHECK-LABEL: func @verbose_terminators() -> (i1, i17)
|
|
|
|
func @verbose_terminators() -> (i1, i17) {
|
|
|
|
%0 = "foo"() : () -> (i1, i17)
|
|
|
|
// CHECK: br ^bb1(%0#0, %0#1 : i1, i17)
|
2019-03-03 10:03:03 +08:00
|
|
|
"std.br"()[^bb1(%0#0, %0#1 : i1, i17)] : () -> ()
|
2019-01-10 04:28:30 +08:00
|
|
|
|
|
|
|
^bb1(%x : i1, %y : i17):
|
|
|
|
// CHECK: cond_br %1, ^bb2(%2 : i17), ^bb3(%1, %2 : i1, i17)
|
2019-03-03 10:03:03 +08:00
|
|
|
"std.cond_br"(%x)[^bb2(%y : i17), ^bb3(%x, %y : i1, i17)] : (i1) -> ()
|
2019-01-10 04:28:30 +08:00
|
|
|
|
|
|
|
^bb2(%a : i17):
|
|
|
|
%true = constant 1 : i1
|
|
|
|
// CHECK: return %true, %3 : i1, i17
|
2019-03-03 10:03:03 +08:00
|
|
|
"std.return"(%true, %a) : (i1, i17) -> ()
|
2019-01-10 04:28:30 +08:00
|
|
|
|
|
|
|
^bb3(%b : i1, %c : i17):
|
|
|
|
// CHECK: return %4, %5 : i1, i17
|
2019-03-03 10:03:03 +08:00
|
|
|
"std.return"(%b, %c) : (i1, i17) -> ()
|
2019-01-10 04:28:30 +08:00
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @condbr_simple
|
|
|
|
func @condbr_simple() -> (i32) {
|
2018-07-25 06:01:27 +08:00
|
|
|
%cond = "foo"() : () -> i1
|
|
|
|
%a = "bar"() : () -> i32
|
|
|
|
%b = "bar"() : () -> i64
|
2018-12-30 03:32:37 +08:00
|
|
|
// CHECK: cond_br %0, ^bb1(%1 : i32), ^bb2(%2 : i64)
|
|
|
|
cond_br %cond, ^bb1(%a : i32), ^bb2(%b : i64)
|
2018-07-25 06:01:27 +08:00
|
|
|
|
2018-12-30 03:32:37 +08:00
|
|
|
// CHECK: ^bb1({{.*}}: i32): // pred: ^bb0
|
|
|
|
^bb1(%x : i32):
|
|
|
|
br ^bb2(%b: i64)
|
2018-07-25 06:01:27 +08:00
|
|
|
|
2018-12-30 03:32:37 +08:00
|
|
|
// CHECK: ^bb2({{.*}}: i64): // 2 preds: ^bb0, ^bb1
|
|
|
|
^bb2(%y : i64):
|
2018-07-25 06:01:27 +08:00
|
|
|
%z = "foo"() : () -> i32
|
|
|
|
return %z : i32
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @condbr_moarargs
|
|
|
|
func @condbr_moarargs() -> (i32) {
|
2018-07-25 06:01:27 +08:00
|
|
|
%cond = "foo"() : () -> i1
|
|
|
|
%a = "bar"() : () -> i32
|
|
|
|
%b = "bar"() : () -> i64
|
2018-12-30 03:32:37 +08:00
|
|
|
// CHECK: cond_br %0, ^bb1(%1, %2 : i32, i64), ^bb2(%2, %1, %1 : i64, i32, i32)
|
|
|
|
cond_br %cond, ^bb1(%a, %b : i32, i64), ^bb2(%b, %a, %a : i64, i32, i32)
|
2018-07-25 06:01:27 +08:00
|
|
|
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb1(%x : i32, %y : i64):
|
2018-07-25 06:01:27 +08:00
|
|
|
return %x : i32
|
|
|
|
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb2(%x2 : i64, %y2 : i32, %z2 : i32):
|
2018-07-25 06:01:27 +08:00
|
|
|
%z = "foo"() : () -> i32
|
|
|
|
return %z : i32
|
|
|
|
}
|
2018-08-02 01:43:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
// Test pretty printing of constant names.
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @constants
|
|
|
|
func @constants() -> (i32, i23, i23, i1, i1) {
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %c42_i32 = constant 42 : i32
|
|
|
|
%x = constant 42 : i32
|
|
|
|
// CHECK: %c17_i23 = constant 17 : i23
|
|
|
|
%y = constant 17 : i23
|
|
|
|
|
|
|
|
// This is a redundant definition of 17, the asmprinter gives it a unique name
|
|
|
|
// CHECK: %c17_i23_0 = constant 17 : i23
|
|
|
|
%z = constant 17 : i23
|
|
|
|
|
2018-08-03 08:16:58 +08:00
|
|
|
// CHECK: %true = constant 1 : i1
|
|
|
|
%t = constant 1 : i1
|
|
|
|
// CHECK: %false = constant 0 : i1
|
|
|
|
%f = constant 0 : i1
|
|
|
|
|
2019-02-08 00:36:50 +08:00
|
|
|
// The trick to parse type declarations should not interfere with hex
|
|
|
|
// literals.
|
|
|
|
// CHECK: %c3890_i32 = constant 3890 : i32
|
|
|
|
%h = constant 0xf32 : i32
|
|
|
|
|
2018-08-03 08:16:58 +08:00
|
|
|
// CHECK: return %c42_i32, %c17_i23, %c17_i23_0, %true, %false
|
|
|
|
return %x, %y, %z, %t, %f : i32, i23, i23, i1, i1
|
2018-08-02 01:43:18 +08:00
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @typeattr
|
|
|
|
func @typeattr() -> () {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
2018-09-14 01:43:35 +08:00
|
|
|
// CHECK: "foo"() {bar: tensor<*xf32>} : () -> ()
|
|
|
|
"foo"(){bar: tensor<*xf32>} : () -> ()
|
2018-08-03 16:54:46 +08:00
|
|
|
return
|
|
|
|
}
|
2018-08-14 16:16:45 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @stringquote
|
|
|
|
func @stringquote() -> () {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
2018-08-16 00:09:54 +08:00
|
|
|
// CHECK: "foo"() {bar: "a\22quoted\22string"} : () -> ()
|
2018-08-14 16:16:45 +08:00
|
|
|
"foo"(){bar: "a\"quoted\"string"} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
2018-08-16 00:09:54 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @floatAttrs
|
|
|
|
func @floatAttrs() -> () {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
2018-08-16 00:09:54 +08:00
|
|
|
// CHECK: "foo"() {a: 4.000000e+00, b: 2.000000e+00, c: 7.100000e+00, d: -0.000000e+00} : () -> ()
|
|
|
|
"foo"(){a: 4.0, b: 2.0, c: 7.1, d: -0.0} : () -> ()
|
|
|
|
return
|
2018-08-21 05:37:39 +08:00
|
|
|
}
|
2018-09-19 07:36:26 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @externalfuncattr
|
|
|
|
func @externalfuncattr() -> ()
|
2019-03-03 14:34:18 +08:00
|
|
|
// CHECK: attributes {dialect.a: "a\22quoted\22string", dialect.b: 4.000000e+00, dialect.c: tensor<*xf32>}
|
|
|
|
attributes {dialect.a: "a\"quoted\"string", dialect.b: 4.0, dialect.c: tensor<*xf32>}
|
2018-09-19 07:36:26 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @funcattrempty
|
|
|
|
func @funcattrempty() -> ()
|
2018-09-19 07:36:26 +08:00
|
|
|
// CHECK-EMPTY
|
|
|
|
attributes {}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @funcattr
|
|
|
|
func @funcattr() -> ()
|
2019-03-03 14:34:18 +08:00
|
|
|
// CHECK: attributes {dialect.a: "a\22quoted\22string", dialect.b: 4.000000e+00, dialect.c: tensor<*xf32>}
|
|
|
|
attributes {dialect.a: "a\"quoted\"string", dialect.b: 4.0, dialect.c: tensor<*xf32>} {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
2018-09-19 07:36:26 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @funcattrwithblock
|
|
|
|
func @funcattrwithblock() -> ()
|
2018-09-19 07:36:26 +08:00
|
|
|
// CHECK-EMPTY
|
|
|
|
attributes {} {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
2018-09-19 07:36:26 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-label func @funcsimplemap
|
2018-09-26 08:15:54 +08:00
|
|
|
#map_simple0 = ()[] -> (10)
|
|
|
|
#map_simple1 = ()[s0] -> (s0)
|
|
|
|
#map_non_simple0 = (d0)[] -> (d0)
|
|
|
|
#map_non_simple1 = (d0)[s0] -> (d0 + s0)
|
|
|
|
#map_non_simple2 = ()[s0, s1] -> (s0 + s1)
|
|
|
|
#map_non_simple3 = ()[s0] -> (s0 + 3)
|
2019-01-03 02:20:00 +08:00
|
|
|
func @funcsimplemap(%arg0: index, %arg1: index) -> () {
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to #map_simple0()[] {
|
|
|
|
// CHECK: for %i0 = 0 to 10 {
|
|
|
|
for %i1 = 0 to #map_simple1()[%arg1] {
|
|
|
|
// CHECK: for %i1 = 0 to %arg1 {
|
|
|
|
for %i2 = 0 to #map_non_simple0(%i0)[] {
|
|
|
|
// CHECK: for %i2 = 0 to #map{{[a-z_0-9]*}}(%i0) {
|
|
|
|
for %i3 = 0 to #map_non_simple1(%i0)[%arg1] {
|
|
|
|
// CHECK: for %i3 = 0 to #map{{[a-z_0-9]*}}(%i0)[%arg1] {
|
|
|
|
for %i4 = 0 to #map_non_simple2()[%arg1, %arg0] {
|
|
|
|
// CHECK: for %i4 = 0 to #map{{[a-z_0-9]*}}()[%arg1, %arg0] {
|
|
|
|
for %i5 = 0 to #map_non_simple3()[%arg0] {
|
|
|
|
// CHECK: for %i5 = 0 to #map{{[a-z_0-9]*}}()[%arg0] {
|
2018-09-26 08:15:54 +08:00
|
|
|
%c42_i32 = constant 42 : i32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-23 01:35:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2018-10-10 23:57:51 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @splattensorattr
|
|
|
|
func @splattensorattr() -> () {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
2019-03-19 04:42:55 +08:00
|
|
|
// CHECK: "splatBoolTensor"() {bar: splat<tensor<i1>, false>} : () -> ()
|
|
|
|
"splatBoolTensor"(){bar: splat<tensor<i1>, false>} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "splatIntTensor"() {bar: splat<tensor<2x1x4xi32>, 5>} : () -> ()
|
2018-10-10 23:57:51 +08:00
|
|
|
"splatIntTensor"(){bar: splat<tensor<2x1x4xi32>, 5>} : () -> ()
|
2019-03-19 04:42:55 +08:00
|
|
|
|
|
|
|
// CHECK: "splatFloatTensor"() {bar: splat<tensor<2x1x4xf32>, -5.000000e+00>} : () -> ()
|
2018-10-10 23:57:51 +08:00
|
|
|
"splatFloatTensor"(){bar: splat<tensor<2x1x4xf32>, -5.0>} : () -> ()
|
2019-03-19 04:42:55 +08:00
|
|
|
|
|
|
|
// CHECK: "splatIntVector"() {bar: splat<vector<2x1x4xi64>, 5>} : () -> ()
|
2018-10-10 23:57:51 +08:00
|
|
|
"splatIntVector"(){bar: splat<vector<2x1x4xi64>, 5>} : () -> ()
|
2019-03-19 04:42:55 +08:00
|
|
|
|
|
|
|
// CHECK: "splatFloatVector"() {bar: splat<vector<2x1x4xf16>, -5.000000e+00>} : () -> ()
|
2018-10-10 23:57:51 +08:00
|
|
|
"splatFloatVector"(){bar: splat<vector<2x1x4xf16>, -5.0>} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
2018-10-19 04:54:44 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @opaquetensorattr
|
|
|
|
func @opaquetensorattr() -> () {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
2019-02-12 14:51:34 +08:00
|
|
|
// CHECK: "opaqueIntTensor"() {bar: opaque<"tf", tensor<2x1x4xi32>, "0x68656C6C6F">} : () -> ()
|
|
|
|
"opaqueIntTensor"(){bar: opaque<"tf", tensor<2x1x4xi32>, "0x68656C6C6F">} : () -> ()
|
|
|
|
// CHECK: "opaqueFloatTensor"() {bar: opaque<"tf", tensor<2x1x4xf32>, "0x68656C6C6F">} : () -> ()
|
|
|
|
"opaqueFloatTensor"(){bar: opaque<"tf", tensor<2x1x4xf32>, "0x68656C6C6F">} : () -> ()
|
|
|
|
// CHECK: "opaqueStringTensor"() {bar: opaque<"tf", tensor<2x1x4x!tf<"string">>, "0x68656C6C6F">} : () -> ()
|
|
|
|
"opaqueStringTensor"(){bar: opaque<"tf", tensor<2x1x4x!tf<"string">>, "0x68656C6C6F">} : () -> ()
|
|
|
|
// CHECK: "opaqueResourceTensor"() {bar: opaque<"tf", tensor<2x1x4x!tf<"resource">>, "0x68656C6C6F">} : () -> ()
|
|
|
|
"opaqueResourceTensor"(){bar: opaque<"tf", tensor<2x1x4x!tf<"resource">>, "0x68656C6C6F">} : () -> ()
|
2018-10-24 04:44:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @densetensorattr
|
|
|
|
func @densetensorattr() -> () {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
2018-10-19 04:54:44 +08:00
|
|
|
|
|
|
|
// NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
|
|
|
|
// CHECK: "fooi3"() {bar: dense<tensor<2x1x4xi3>, {{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
"fooi3"(){bar: dense<tensor<2x1x4xi3>, [[[1, -2, 1, 2]], [[0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi6"() {bar: dense<tensor<2x1x4xi6>, {{\[\[\[}}5, -6, 1, 2]], {{\[\[}}7, 8, 3, 4]]]>} : () -> ()
|
|
|
|
"fooi6"(){bar: dense<tensor<2x1x4xi6>, [[[5, -6, 1, 2]], [[7, 8, 3, 4]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi8"() {bar: dense<tensor<1x1x1xi8>, {{\[\[\[}}5]]]>} : () -> ()
|
|
|
|
"fooi8"(){bar: dense<tensor<1x1x1xi8>, [[[5]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi13"() {bar: dense<tensor<2x1x4xi13>, {{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
"fooi13"(){bar: dense<tensor<2x1x4xi13>, [[[1, -2, 1, 2]], [[0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi16"() {bar: dense<tensor<1x1x1xi16>, {{\[\[\[}}-5]]]>} : () -> ()
|
|
|
|
"fooi16"(){bar: dense<tensor<1x1x1xi16>, [[[-5]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi23"() {bar: dense<tensor<2x1x4xi23>, {{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
"fooi23"(){bar: dense<tensor<2x1x4xi23>, [[[1, -2, 1, 2]], [[0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi32"() {bar: dense<tensor<1x1x1xi32>, {{\[\[\[}}5]]]>} : () -> ()
|
|
|
|
"fooi32"(){bar: dense<tensor<1x1x1xi32>, [[[5]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi33"() {bar: dense<tensor<2x1x4xi33>, {{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
"fooi33"(){bar: dense<tensor<2x1x4xi33>, [[[1, -2, 1, 2]], [[0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi43"() {bar: dense<tensor<2x1x4xi43>, {{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
"fooi43"(){bar: dense<tensor<2x1x4xi43>, [[[1, -2, 1, 2]], [[0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi53"() {bar: dense<tensor<2x1x4xi53>, {{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
"fooi53"(){bar: dense<tensor<2x1x4xi53>, [[[1, -2, 1, 2]], [[0, 2, -1, 2]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi64"() {bar: dense<tensor<2x1x4xi64>, {{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 3, -1, 2]]]>} : () -> ()
|
|
|
|
"fooi64"(){bar: dense<tensor<2x1x4xi64>, [[[1, -2, 1, 2]], [[0, 3, -1, 2]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi64"() {bar: dense<tensor<1x1x1xi64>, {{\[\[\[}}-5]]]>} : () -> ()
|
|
|
|
"fooi64"(){bar: dense<tensor<1x1x1xi64>, [[[-5]]]>} : () -> ()
|
2019-01-18 06:11:05 +08:00
|
|
|
// CHECK: "fooi67"() {bar: dense<vector<1x1x4xi67>, {{\[\[\[}}-5, 4, 6, 2]]]>} : () -> ()
|
|
|
|
"fooi67"(){bar: dense<vector<1x1x4xi67>, [[[-5, 4, 6, 2]]]>} : () -> ()
|
2018-10-19 04:54:44 +08:00
|
|
|
|
|
|
|
// CHECK: "foo2"() {bar: dense<tensor<0xi32>, []>} : () -> ()
|
2019-02-08 00:36:50 +08:00
|
|
|
"foo2"(){bar: dense<tensor<0xi32>, []>} : () -> ()
|
2018-10-19 04:54:44 +08:00
|
|
|
// CHECK: "foo2"() {bar: dense<tensor<1x0xi32>, {{\[\[}}]]>} : () -> ()
|
2019-02-08 00:36:50 +08:00
|
|
|
"foo2"(){bar: dense<tensor<1x0xi32>, [[]]>} : () -> ()
|
2018-10-19 04:54:44 +08:00
|
|
|
// CHECK: "foo3"() {bar: dense<tensor<2x1x4xi32>, {{\[\[\[}}5, -6, 1, 2]], {{\[\[}}7, 8, 3, 4]]]>} : () -> ()
|
|
|
|
"foo3"(){bar: dense<tensor<2x1x4xi32>, [[[5, -6, 1, 2]], [[7, 8, 3, 4]]]>} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "float1"() {bar: dense<tensor<1x1x1xf32>, {{\[\[\[}}5.000000e+00]]]>} : () -> ()
|
|
|
|
"float1"(){bar: dense<tensor<1x1x1xf32>, [[[5.0]]]>} : () -> ()
|
|
|
|
// CHECK: "float2"() {bar: dense<tensor<0xf32>, []>} : () -> ()
|
2019-02-08 00:36:50 +08:00
|
|
|
"float2"(){bar: dense<tensor<0xf32>, []>} : () -> ()
|
2018-10-19 04:54:44 +08:00
|
|
|
// CHECK: "float2"() {bar: dense<tensor<1x0xf32>, {{\[\[}}]]>} : () -> ()
|
2019-02-08 00:36:50 +08:00
|
|
|
"float2"(){bar: dense<tensor<1x0xf32>, [[]]>} : () -> ()
|
2018-10-19 04:54:44 +08:00
|
|
|
|
|
|
|
// CHECK: "bfloat16"() {bar: dense<tensor<2x1x4xbf16>, {{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]>} : () -> ()
|
|
|
|
"bfloat16"(){bar: dense<tensor<2x1x4xbf16>, [[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]>} : () -> ()
|
|
|
|
// CHECK: "float16"() {bar: dense<tensor<2x1x4xf16>, {{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]>} : () -> ()
|
|
|
|
"float16"(){bar: dense<tensor<2x1x4xf16>, [[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]>} : () -> ()
|
|
|
|
// CHECK: "float32"() {bar: dense<tensor<2x1x4xf32>, {{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]>} : () -> ()
|
|
|
|
"float32"(){bar: dense<tensor<2x1x4xf32>, [[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]>} : () -> ()
|
|
|
|
// CHECK: "float64"() {bar: dense<tensor<2x1x4xf64>, {{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]>} : () -> ()
|
|
|
|
"float64"(){bar: dense<tensor<2x1x4xf64>, [[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]>} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @densevectorattr
|
|
|
|
func @densevectorattr() -> () {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
2018-10-19 04:54:44 +08:00
|
|
|
// NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
|
|
|
|
// CHECK: "fooi8"() {bar: dense<vector<1x1x1xi8>, {{\[\[\[}}5]]]>} : () -> ()
|
|
|
|
"fooi8"(){bar: dense<vector<1x1x1xi8>, [[[5]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi16"() {bar: dense<vector<1x1x1xi16>, {{\[\[\[}}-5]]]>} : () -> ()
|
|
|
|
"fooi16"(){bar: dense<vector<1x1x1xi16>, [[[-5]]]>} : () -> ()
|
|
|
|
// CHECK: "foo32"() {bar: dense<vector<1x1x1xi32>, {{\[\[\[}}5]]]>} : () -> ()
|
|
|
|
"foo32"(){bar: dense<vector<1x1x1xi32>, [[[5]]]>} : () -> ()
|
|
|
|
// CHECK: "fooi64"() {bar: dense<vector<1x1x1xi64>, {{\[\[\[}}-5]]]>} : () -> ()
|
|
|
|
"fooi64"(){bar: dense<vector<1x1x1xi64>, [[[-5]]]>} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "foo3"() {bar: dense<vector<2x1x4xi32>, {{\[\[\[}}5, -6, 1, 2]], {{\[\[}}7, 8, 3, 4]]]>} : () -> ()
|
|
|
|
"foo3"(){bar: dense<vector<2x1x4xi32>, [[[5, -6, 1, 2]], [[7, 8, 3, 4]]]>} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "float1"() {bar: dense<vector<1x1x1xf32>, {{\[\[\[}}5.000000e+00]]]>} : () -> ()
|
|
|
|
"float1"(){bar: dense<vector<1x1x1xf32>, [[[5.0]]]>} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "bfloat16"() {bar: dense<vector<2x1x4xbf16>, {{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]>} : () -> ()
|
|
|
|
"bfloat16"(){bar: dense<vector<2x1x4xbf16>, [[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]>} : () -> ()
|
|
|
|
// CHECK: "float16"() {bar: dense<vector<2x1x4xf16>, {{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]>} : () -> ()
|
|
|
|
"float16"(){bar: dense<vector<2x1x4xf16>, [[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]>} : () -> ()
|
|
|
|
// CHECK: "float32"() {bar: dense<vector<2x1x4xf32>, {{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]>} : () -> ()
|
|
|
|
"float32"(){bar: dense<vector<2x1x4xf32>, [[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]>} : () -> ()
|
|
|
|
// CHECK: "float64"() {bar: dense<vector<2x1x4xf64>, {{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]>} : () -> ()
|
|
|
|
"float64"(){bar: dense<vector<2x1x4xf64>, [[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]>} : () -> ()
|
|
|
|
return
|
Add support to constant sparse tensor / vector attribute
The SparseElementsAttr uses (COO) Coordinate List encoding to represents a
sparse tensor / vector. Specifically, the coordinates and values are stored as
two dense elements attributes. The first dense elements attribute is a 2-D
attribute with shape [N, ndims], which contains the indices of the elements
with nonzero values in the constant vector/tensor. The second elements
attribute is a 1-D attribute list with shape [N], which supplies the values for
each element in the first elements attribute. ndims is the rank of the
vector/tensor and N is the total nonzero elements.
The syntax is:
`sparse<` (tensor-type | vector-type)`, ` indices-attribute-list, values-attribute-list `>`
Example: a sparse tensor
sparse<vector<3x4xi32>, [[0, 0], [1, 2]], [1, 2]> represents the dense tensor
[[1, 0, 0, 0]
[0, 0, 2, 0]
[0, 0, 0, 0]]
PiperOrigin-RevId: 217764319
2018-10-19 05:02:20 +08:00
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @sparsetensorattr
|
|
|
|
func @sparsetensorattr() -> () {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
Add support to constant sparse tensor / vector attribute
The SparseElementsAttr uses (COO) Coordinate List encoding to represents a
sparse tensor / vector. Specifically, the coordinates and values are stored as
two dense elements attributes. The first dense elements attribute is a 2-D
attribute with shape [N, ndims], which contains the indices of the elements
with nonzero values in the constant vector/tensor. The second elements
attribute is a 1-D attribute list with shape [N], which supplies the values for
each element in the first elements attribute. ndims is the rank of the
vector/tensor and N is the total nonzero elements.
The syntax is:
`sparse<` (tensor-type | vector-type)`, ` indices-attribute-list, values-attribute-list `>`
Example: a sparse tensor
sparse<vector<3x4xi32>, [[0, 0], [1, 2]], [1, 2]> represents the dense tensor
[[1, 0, 0, 0]
[0, 0, 2, 0]
[0, 0, 0, 0]]
PiperOrigin-RevId: 217764319
2018-10-19 05:02:20 +08:00
|
|
|
// NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
|
|
|
|
// CHECK: "fooi8"() {bar: sparse<tensor<1x1x1xi8>, {{\[\[}}0, 0, 0]], {{\[}}-2]>} : () -> ()
|
|
|
|
"fooi8"(){bar: sparse<tensor<1x1x1xi8>, [[0, 0, 0]], [-2]>} : () -> ()
|
|
|
|
// CHECK: "fooi16"() {bar: sparse<tensor<2x2x2xi16>, {{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2, -1, 5]>} : () -> ()
|
|
|
|
"fooi16"(){bar: sparse<tensor<2x2x2xi16>, [[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2, -1, 5]>} : () -> ()
|
|
|
|
// CHECK: "fooi32"() {bar: sparse<tensor<1x1xi32>, {{\[}}], {{\[}}]>} : () -> ()
|
|
|
|
"fooi32"(){bar: sparse<tensor<1x1xi32>, [], []>} : () -> ()
|
|
|
|
// CHECK: "fooi64"() {bar: sparse<tensor<1xi64>, {{\[\[}}0]], {{\[}}-1]>} : () -> ()
|
|
|
|
"fooi64"(){bar: sparse<tensor<1xi64>, [[0]], [-1]>} : () -> ()
|
|
|
|
// CHECK: "foo2"() {bar: sparse<tensor<0xi32>, {{\[}}], {{\[}}]>} : () -> ()
|
2019-02-08 00:36:50 +08:00
|
|
|
"foo2"(){bar: sparse<tensor<0xi32>, [], []>} : () -> ()
|
Add support to constant sparse tensor / vector attribute
The SparseElementsAttr uses (COO) Coordinate List encoding to represents a
sparse tensor / vector. Specifically, the coordinates and values are stored as
two dense elements attributes. The first dense elements attribute is a 2-D
attribute with shape [N, ndims], which contains the indices of the elements
with nonzero values in the constant vector/tensor. The second elements
attribute is a 1-D attribute list with shape [N], which supplies the values for
each element in the first elements attribute. ndims is the rank of the
vector/tensor and N is the total nonzero elements.
The syntax is:
`sparse<` (tensor-type | vector-type)`, ` indices-attribute-list, values-attribute-list `>`
Example: a sparse tensor
sparse<vector<3x4xi32>, [[0, 0], [1, 2]], [1, 2]> represents the dense tensor
[[1, 0, 0, 0]
[0, 0, 2, 0]
[0, 0, 0, 0]]
PiperOrigin-RevId: 217764319
2018-10-19 05:02:20 +08:00
|
|
|
|
|
|
|
// CHECK: "foof16"() {bar: sparse<tensor<1x1x1xf16>, {{\[\[}}0, 0, 0]], {{\[}}-2.000000e+00]>} : () -> ()
|
|
|
|
"foof16"(){bar: sparse<tensor<1x1x1xf16>, [[0, 0, 0]], [-2.0]>} : () -> ()
|
|
|
|
// CHECK: "foobf16"() {bar: sparse<tensor<2x2x2xbf16>, {{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2.000000e+00, -1.000000e+00, 5.000000e+00]>} : () -> ()
|
|
|
|
"foobf16"(){bar: sparse<tensor<2x2x2xbf16>, [[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2.0, -1.0, 5.0]>} : () -> ()
|
2019-02-08 00:36:50 +08:00
|
|
|
// CHECK: "foof32"() {bar: sparse<tensor<1x0x1xf32>, {{\[}}], {{\[}}]>} : () -> ()
|
Add support to constant sparse tensor / vector attribute
The SparseElementsAttr uses (COO) Coordinate List encoding to represents a
sparse tensor / vector. Specifically, the coordinates and values are stored as
two dense elements attributes. The first dense elements attribute is a 2-D
attribute with shape [N, ndims], which contains the indices of the elements
with nonzero values in the constant vector/tensor. The second elements
attribute is a 1-D attribute list with shape [N], which supplies the values for
each element in the first elements attribute. ndims is the rank of the
vector/tensor and N is the total nonzero elements.
The syntax is:
`sparse<` (tensor-type | vector-type)`, ` indices-attribute-list, values-attribute-list `>`
Example: a sparse tensor
sparse<vector<3x4xi32>, [[0, 0], [1, 2]], [1, 2]> represents the dense tensor
[[1, 0, 0, 0]
[0, 0, 2, 0]
[0, 0, 0, 0]]
PiperOrigin-RevId: 217764319
2018-10-19 05:02:20 +08:00
|
|
|
"foof32"(){bar: sparse<tensor<1x0x1xf32>, [], []>} : () -> ()
|
|
|
|
// CHECK: "foof64"() {bar: sparse<tensor<1xf64>, {{\[\[}}0]], {{\[}}-1.000000e+00]>} : () -> ()
|
|
|
|
"foof64"(){bar: sparse<tensor<1xf64>, [[0]], [-1.0]>} : () -> ()
|
|
|
|
// CHECK: "foof320"() {bar: sparse<tensor<0xf32>, {{\[}}], {{\[}}]>} : () -> ()
|
2019-02-08 00:36:50 +08:00
|
|
|
"foof320"(){bar: sparse<tensor<0xf32>, [], []>} : () -> ()
|
Add support to constant sparse tensor / vector attribute
The SparseElementsAttr uses (COO) Coordinate List encoding to represents a
sparse tensor / vector. Specifically, the coordinates and values are stored as
two dense elements attributes. The first dense elements attribute is a 2-D
attribute with shape [N, ndims], which contains the indices of the elements
with nonzero values in the constant vector/tensor. The second elements
attribute is a 1-D attribute list with shape [N], which supplies the values for
each element in the first elements attribute. ndims is the rank of the
vector/tensor and N is the total nonzero elements.
The syntax is:
`sparse<` (tensor-type | vector-type)`, ` indices-attribute-list, values-attribute-list `>`
Example: a sparse tensor
sparse<vector<3x4xi32>, [[0, 0], [1, 2]], [1, 2]> represents the dense tensor
[[1, 0, 0, 0]
[0, 0, 2, 0]
[0, 0, 0, 0]]
PiperOrigin-RevId: 217764319
2018-10-19 05:02:20 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @sparsevectorattr
|
|
|
|
func @sparsevectorattr() -> () {
|
2018-12-30 03:32:37 +08:00
|
|
|
^bb0:
|
Add support to constant sparse tensor / vector attribute
The SparseElementsAttr uses (COO) Coordinate List encoding to represents a
sparse tensor / vector. Specifically, the coordinates and values are stored as
two dense elements attributes. The first dense elements attribute is a 2-D
attribute with shape [N, ndims], which contains the indices of the elements
with nonzero values in the constant vector/tensor. The second elements
attribute is a 1-D attribute list with shape [N], which supplies the values for
each element in the first elements attribute. ndims is the rank of the
vector/tensor and N is the total nonzero elements.
The syntax is:
`sparse<` (tensor-type | vector-type)`, ` indices-attribute-list, values-attribute-list `>`
Example: a sparse tensor
sparse<vector<3x4xi32>, [[0, 0], [1, 2]], [1, 2]> represents the dense tensor
[[1, 0, 0, 0]
[0, 0, 2, 0]
[0, 0, 0, 0]]
PiperOrigin-RevId: 217764319
2018-10-19 05:02:20 +08:00
|
|
|
// NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
|
|
|
|
// CHECK: "fooi8"() {bar: sparse<vector<1x1x1xi8>, {{\[\[}}0, 0, 0]], {{\[}}-2]>} : () -> ()
|
|
|
|
"fooi8"(){bar: sparse<vector<1x1x1xi8>, [[0, 0, 0]], [-2]>} : () -> ()
|
|
|
|
// CHECK: "fooi16"() {bar: sparse<vector<2x2x2xi16>, {{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2, -1, 5]>} : () -> ()
|
|
|
|
"fooi16"(){bar: sparse<vector<2x2x2xi16>, [[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2, -1, 5]>} : () -> ()
|
|
|
|
// CHECK: "fooi32"() {bar: sparse<vector<1x1xi32>, {{\[}}], {{\[}}]>} : () -> ()
|
|
|
|
"fooi32"(){bar: sparse<vector<1x1xi32>, [], []>} : () -> ()
|
|
|
|
// CHECK: "fooi64"() {bar: sparse<vector<1xi64>, {{\[\[}}0]], {{\[}}-1]>} : () -> ()
|
|
|
|
"fooi64"(){bar: sparse<vector<1xi64>, [[0]], [-1]>} : () -> ()
|
2018-12-17 23:19:53 +08:00
|
|
|
|
Add support to constant sparse tensor / vector attribute
The SparseElementsAttr uses (COO) Coordinate List encoding to represents a
sparse tensor / vector. Specifically, the coordinates and values are stored as
two dense elements attributes. The first dense elements attribute is a 2-D
attribute with shape [N, ndims], which contains the indices of the elements
with nonzero values in the constant vector/tensor. The second elements
attribute is a 1-D attribute list with shape [N], which supplies the values for
each element in the first elements attribute. ndims is the rank of the
vector/tensor and N is the total nonzero elements.
The syntax is:
`sparse<` (tensor-type | vector-type)`, ` indices-attribute-list, values-attribute-list `>`
Example: a sparse tensor
sparse<vector<3x4xi32>, [[0, 0], [1, 2]], [1, 2]> represents the dense tensor
[[1, 0, 0, 0]
[0, 0, 2, 0]
[0, 0, 0, 0]]
PiperOrigin-RevId: 217764319
2018-10-19 05:02:20 +08:00
|
|
|
// CHECK: "foof16"() {bar: sparse<vector<1x1x1xf16>, {{\[\[}}0, 0, 0]], {{\[}}-2.000000e+00]>} : () -> ()
|
|
|
|
"foof16"(){bar: sparse<vector<1x1x1xf16>, [[0, 0, 0]], [-2.0]>} : () -> ()
|
|
|
|
// CHECK: "foobf16"() {bar: sparse<vector<2x2x2xbf16>, {{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2.000000e+00, -1.000000e+00, 5.000000e+00]>} : () -> ()
|
|
|
|
"foobf16"(){bar: sparse<vector<2x2x2xbf16>, [[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2.0, -1.0, 5.0]>} : () -> ()
|
|
|
|
// CHECK: "foof64"() {bar: sparse<vector<1xf64>, {{\[\[}}0]], {{\[}}-1.000000e+00]>} : () -> ()
|
|
|
|
"foof64"(){bar: sparse<vector<1xf64>, [[0]], [-1.0]>} : () -> ()
|
|
|
|
return
|
2018-10-26 09:33:42 +08:00
|
|
|
}
|
2018-12-30 05:36:59 +08:00
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @loops_with_blockids() {
|
|
|
|
func @loops_with_blockids() {
|
2018-12-30 05:36:59 +08:00
|
|
|
^block0:
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i = 1 to 100 step 2 {
|
2018-12-30 05:36:59 +08:00
|
|
|
^block1:
|
2019-02-07 13:54:18 +08:00
|
|
|
for %j = 1 to 200 {
|
2018-12-30 05:36:59 +08:00
|
|
|
^block2:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-01-08 01:58:34 +08:00
|
|
|
// CHECK-LABEL: func @unknown_dialect_type() -> !bar<""> {
|
|
|
|
func @unknown_dialect_type() -> !bar<""> {
|
|
|
|
// Unregistered dialect 'bar'.
|
|
|
|
// CHECK: "foo"() : () -> !bar<"">
|
|
|
|
%0 = "foo"() : () -> !bar<"">
|
|
|
|
|
|
|
|
// CHECK: "foo"() : () -> !bar<"baz">
|
|
|
|
%1 = "foo"() : () -> !bar<"baz">
|
|
|
|
|
|
|
|
return %0 : !bar<"">
|
|
|
|
}
|
2018-12-30 05:36:59 +08:00
|
|
|
|
2019-01-08 10:42:04 +08:00
|
|
|
// CHECK-LABEL: func @type_alias() -> i32 {
|
|
|
|
!i32_type_alias = type i32
|
|
|
|
func @type_alias() -> !i32_type_alias {
|
|
|
|
|
|
|
|
// Return a non-aliased i32 type.
|
|
|
|
%0 = "foo"() : () -> i32
|
|
|
|
return %0 : i32
|
|
|
|
}
|
2019-01-26 04:48:25 +08:00
|
|
|
|
2019-02-03 13:01:11 +08:00
|
|
|
// CHECK-LABEL: func @no_integer_set_constraints(
|
|
|
|
func @no_integer_set_constraints() {
|
2019-03-25 11:35:07 +08:00
|
|
|
// CHECK: affine.if [[SET_TRUE]]() {
|
|
|
|
affine.if () : () () {
|
2019-02-03 13:01:11 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-01-26 04:48:25 +08:00
|
|
|
// CHECK-LABEL: func @verbose_if(
|
|
|
|
func @verbose_if(%N: index) {
|
|
|
|
%c = constant 200 : index
|
|
|
|
|
2019-03-25 11:35:07 +08:00
|
|
|
// CHECK: affine.if #set0(%c200)[%arg0, %c200] {
|
|
|
|
"affine.if"(%c, %N, %c) { condition: #set0 } : (index, index, index) -> () {
|
2019-01-26 04:48:25 +08:00
|
|
|
// CHECK-NEXT: "add"
|
|
|
|
%y = "add"(%c, %N) : (index, index) -> index
|
2019-01-29 13:23:53 +08:00
|
|
|
// CHECK-NEXT: } else {
|
2019-03-15 01:38:44 +08:00
|
|
|
} { // The else region.
|
2019-01-26 04:48:25 +08:00
|
|
|
// CHECK-NEXT: "add"
|
|
|
|
%z = "add"(%c, %c) : (index, index) -> index
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2019-02-09 01:52:26 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: func @unregistered_term
|
|
|
|
func @unregistered_term(%arg0 : i1) -> i1 {
|
|
|
|
// CHECK-NEXT: "unregistered_br"()[^bb1(%arg0 : i1)] : () -> ()
|
|
|
|
"unregistered_br"()[^bb1(%arg0 : i1)] : () -> ()
|
|
|
|
|
|
|
|
^bb1(%arg1 : i1):
|
|
|
|
return %arg1 : i1
|
|
|
|
}
|
2019-02-27 04:52:51 +08:00
|
|
|
|
2019-03-03 14:34:18 +08:00
|
|
|
// CHECK-LABEL: func @dialect_attrs
|
|
|
|
func @dialect_attrs()
|
|
|
|
// CHECK-NEXT: attributes {dialect.attr: 10
|
|
|
|
attributes {dialect.attr: 10} {
|
2019-02-27 04:52:51 +08:00
|
|
|
return
|
|
|
|
}
|
2019-02-27 09:11:24 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: func @_valid.function$name
|
|
|
|
func @_valid.function$name()
|
2019-03-01 01:30:52 +08:00
|
|
|
|
2019-03-03 14:34:18 +08:00
|
|
|
// CHECK-LABEL: func @external_func_arg_attrs(i32, i1 {dialect.attr: 10}, i32)
|
|
|
|
func @external_func_arg_attrs(i32, i1 {dialect.attr: 10}, i32)
|
2019-03-01 01:30:52 +08:00
|
|
|
|
2019-03-03 14:34:18 +08:00
|
|
|
// CHECK-LABEL: func @func_arg_attrs(%arg0: i1 {dialect.attr: 10})
|
|
|
|
func @func_arg_attrs(%arg0: i1 {dialect.attr: 10}) {
|
2019-03-01 01:30:52 +08:00
|
|
|
return
|
|
|
|
}
|
2019-03-20 01:59:02 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: func @empty_tuple(tuple<>)
|
|
|
|
func @empty_tuple(tuple<>)
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @tuple_single_element(tuple<i32>)
|
|
|
|
func @tuple_single_element(tuple<i32>)
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @tuple_multi_element(tuple<i32, i16, f32>)
|
|
|
|
func @tuple_multi_element(tuple<i32, i16, f32>)
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @tuple_nested(tuple<tuple<tuple<i32>>>)
|
|
|
|
func @tuple_nested(tuple<tuple<tuple<i32>>>)
|