2018-07-25 01:13:31 +08:00
|
|
|
// RUN: %S/../../mlir-opt %s -o - | FileCheck %s
|
|
|
|
|
2018-08-01 07:21:36 +08:00
|
|
|
// CHECK: #map0 = (d0) -> (d0 + 1)
|
2018-07-29 00:36:25 +08:00
|
|
|
|
2018-08-01 07:21:36 +08:00
|
|
|
// CHECK: #map1 = (d0, d1) -> (d0 + 1, d1 + 2)
|
2018-07-25 01:13:31 +08:00
|
|
|
#map5 = (d0, d1) -> (d0 + 1, d1 + 2)
|
2018-07-29 00:36:25 +08:00
|
|
|
|
2018-08-01 07:21:36 +08:00
|
|
|
// CHECK: #map2 = (d0, d1)[s0, s1] -> (d0 + s1, d1 + s0)
|
|
|
|
// CHECK: #map3 = ()[s0] -> (s0 + 1)
|
2018-07-25 01:13:31 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: cfgfunc @cfgfunc_with_ops(f32) {
|
|
|
|
cfgfunc @cfgfunc_with_ops(f32) {
|
|
|
|
bb0(%a : f32):
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %0 = "getTensor"() : () -> tensor<4x4x?xf32>
|
2018-07-25 01:13:31 +08:00
|
|
|
%t = "getTensor"() : () -> tensor<4x4x?xf32>
|
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %1 = dim %0, 2 : tensor<4x4x?xf32>
|
2018-07-25 01:13:31 +08:00
|
|
|
%t2 = "dim"(%t){index: 2} : (tensor<4x4x?xf32>) -> affineint
|
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %2 = addf %arg0, %arg0 : f32
|
2018-07-25 01:13:31 +08:00
|
|
|
%x = "addf"(%a, %a) : (f32,f32) -> (f32)
|
|
|
|
|
|
|
|
// CHECK: return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-07-26 02:15:20 +08:00
|
|
|
// CHECK-LABEL: cfgfunc @standard_instrs(tensor<4x4x?xf32>, f32) {
|
|
|
|
cfgfunc @standard_instrs(tensor<4x4x?xf32>, f32) {
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: bb0(%arg0: tensor<4x4x?xf32>, %arg1: f32):
|
2018-07-26 02:15:20 +08:00
|
|
|
bb42(%t: tensor<4x4x?xf32>, %f: f32):
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %0 = dim %arg0, 2 : tensor<4x4x?xf32>
|
2018-07-26 02:15:20 +08:00
|
|
|
%a = "dim"(%t){index: 2} : (tensor<4x4x?xf32>) -> affineint
|
2018-07-25 01:13:31 +08:00
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %1 = dim %arg0, 2 : tensor<4x4x?xf32>
|
2018-07-26 02:15:20 +08:00
|
|
|
%a2 = dim %t, 2 : tensor<4x4x?xf32>
|
2018-07-25 01:13:31 +08:00
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %2 = addf %arg1, %arg1 : f32
|
2018-07-26 02:15:20 +08:00
|
|
|
%f2 = "addf"(%f, %f) : (f32,f32) -> f32
|
2018-07-25 01:41:30 +08:00
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %3 = addf %2, %2 : f32
|
2018-07-26 02:15:20 +08:00
|
|
|
%f3 = addf %f2, %f2 : f32
|
2018-07-25 01:13:31 +08:00
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %c42_i32 = constant 42 : i32
|
2018-07-25 01:13:31 +08:00
|
|
|
%x = "constant"(){value: 42} : () -> i32
|
2018-08-02 01:43:18 +08:00
|
|
|
|
|
|
|
// CHECK: %c42_i32_0 = constant 42 : i32
|
|
|
|
%7 = constant 42 : i32
|
2018-08-03 07:54:36 +08:00
|
|
|
|
|
|
|
// CHECK: %c43 = constant 43 {crazy: "foo"} : affineint
|
|
|
|
%8 = constant 43 {crazy: "foo"} : affineint
|
2018-08-17 07:56:40 +08:00
|
|
|
|
|
|
|
// CHECK: %4 = constant 4.300000e+01 : bf16
|
|
|
|
%9 = constant 43.0 : bf16
|
2018-07-25 01:13:31 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: cfgfunc @affine_apply() {
|
|
|
|
cfgfunc @affine_apply() {
|
|
|
|
bb0:
|
2018-07-25 01:41:30 +08:00
|
|
|
%i = "constant"() {value: 0} : () -> affineint
|
|
|
|
%j = "constant"() {value: 1} : () -> affineint
|
2018-07-25 01:13:31 +08:00
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: affine_apply #map0(%c0)
|
2018-07-29 00:36:25 +08:00
|
|
|
%a = "affine_apply" (%i) { map: (d0) -> (d0 + 1) } :
|
2018-07-25 01:13:31 +08:00
|
|
|
(affineint) -> (affineint)
|
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: affine_apply #map1(%c0, %c1)
|
2018-07-29 00:36:25 +08:00
|
|
|
%b = "affine_apply" (%i, %j) { map: #map5 } :
|
2018-07-25 01:13:31 +08:00
|
|
|
(affineint, affineint) -> (affineint, affineint)
|
2018-07-29 00:36:25 +08:00
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: affine_apply #map2(%c0, %c1)[%c1, %c0]
|
2018-07-29 00:36:25 +08:00
|
|
|
%c = affine_apply (i,j)[m,n] -> (i+n, j+m)(%i, %j)[%j, %i]
|
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: affine_apply #map3()[%c0]
|
2018-07-29 00:36:25 +08:00
|
|
|
%d = affine_apply ()[x] -> (x+1)()[%i]
|
|
|
|
|
2018-07-25 01:13:31 +08:00
|
|
|
return
|
2018-07-26 02:15:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: cfgfunc @load_store
|
2018-07-26 03:55:50 +08:00
|
|
|
cfgfunc @load_store(memref<4x4xi32>, affineint) {
|
|
|
|
bb0(%0: memref<4x4xi32>, %1: affineint):
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %0 = load %arg0[%arg1, %arg1] : memref<4x4xi32>
|
2018-07-26 03:55:50 +08:00
|
|
|
%2 = "load"(%0, %1, %1) : (memref<4x4xi32>, affineint, affineint)->i32
|
2018-07-26 02:15:20 +08:00
|
|
|
|
2018-08-02 01:43:18 +08:00
|
|
|
// CHECK: %1 = load %arg0[%arg1, %arg1] : memref<4x4xi32>
|
2018-07-26 03:55:50 +08:00
|
|
|
%3 = load %0[%1, %1] : memref<4x4xi32>
|
2018-07-26 02:15:20 +08:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-08-10 03:28:58 +08:00
|
|
|
// CHECK-LABEL: mlfunc @return_op(%arg0 : i32) -> i32 {
|
|
|
|
mlfunc @return_op(%a : i32) -> i32 {
|
|
|
|
// CHECK: return %arg0 : i32
|
|
|
|
"return" (%a) : (i32)->()
|
|
|
|
}
|