-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathlower_polygeist_ops.mlir
More file actions
48 lines (42 loc) · 2.47 KB
/
lower_polygeist_ops.mlir
File metadata and controls
48 lines (42 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// RUN: polygeist-opt --lower-polygeist-ops --split-input-file %s | FileCheck %s
// CHECK-LABEL: func @main(
// CHECK-SAME: %[[VAL_0:.*]]: index) -> memref<30xi32> {
// CHECK: %[[VAL_1:.*]] = memref.alloca() : memref<30x30xi32>
// CHECK: %[[VAL_2:.*]] = arith.constant 30 : index
// CHECK: %[[VAL_3:.*]] = arith.muli %[[VAL_0]], %[[VAL_2]] : index
// CHECK: %[[VAL_4:.*]] = memref.reinterpret_cast %[[VAL_1]] to offset: {{\[}}%[[VAL_3]]], sizes: [30], strides: [1] : memref<30x30xi32> to memref<30xi32>
// CHECK: return %[[VAL_4]] : memref<30xi32>
// CHECK: }
func @main(%arg0 : index) -> memref<30xi32> {
%0 = memref.alloca() : memref<30x30xi32>
%1 = "polygeist.subindex"(%0, %arg0) : (memref<30x30xi32>, index) -> memref<30xi32>
return %1 : memref<30xi32>
}
// -----
// CHECK-LABEL: func @main(
// CHECK-SAME: %[[VAL_0:.*]]: index) -> memref<42x43x44x45xi32> {
// CHECK: %[[VAL_1:.*]] = memref.alloca() : memref<41x42x43x44x45xi32>
// CHECK: %[[VAL_2:.*]] = arith.constant 3575880 : index
// CHECK: %[[VAL_3:.*]] = arith.muli %[[VAL_0]], %[[VAL_2]] : index
// CHECK: %[[VAL_4:.*]] = memref.reinterpret_cast %[[VAL_1]] to offset: {{\[}}%[[VAL_3]]], sizes: [42, 43, 44, 45], strides: [85140, 1980, 45, 1] : memref<41x42x43x44x45xi32> to memref<42x43x44x45xi32>
// CHECK: return %[[VAL_4]] : memref<42x43x44x45xi32>
// CHECK: }
func @main(%arg0 : index) -> memref<42x43x44x45xi32> {
%0 = memref.alloca() : memref<41x42x43x44x45xi32>
%1 = "polygeist.subindex"(%0, %arg0) : (memref<41x42x43x44x45xi32>, index) -> memref<42x43x44x45xi32>
return %1 : memref<42x43x44x45xi32>
}
// -----
// CHECK-LABEL: func @main(
// CHECK-SAME: %[[VAL_0:.*]]: index) -> memref<29x30xi32> {
// CHECK: %[[VAL_1:.*]] = memref.alloca() : memref<30x30xi32>
// CHECK: %[[VAL_2:.*]] = arith.constant 870 : index
// CHECK: %[[VAL_3:.*]] = arith.muli %[[VAL_0]], %[[VAL_2]] : index
// CHECK: %[[VAL_4:.*]] = memref.reinterpret_cast %[[VAL_1]] to offset: {{\[}}%[[VAL_3]]], sizes: [29, 30], strides: [30, 1] : memref<30x30xi32> to memref<29x30xi32>
// CHECK: return %[[VAL_4]] : memref<29x30xi32>
// CHECK: }
func @main(%arg0 : index) -> memref<29x30xi32> {
%0 = memref.alloca() : memref<30x30xi32>
%1 = "polygeist.subindex"(%0, %arg0) : (memref<30x30xi32>, index) -> memref<29x30xi32>
return %1 : memref<29x30xi32>
}