compose_maps.mlir
5.65 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// RUN: mlir-opt %s -affine-vectorizer-test -compose-maps 2>&1 | FileCheck %s
// For all these cases, the test traverses the `test_affine_map` ops and
// composes them in order one-by-one.
// For instance, the pseudo-sequence:
// "test_affine_map"() { affine_map = f } : () -> ()
// "test_affine_map"() { affine_map = g } : () -> ()
// "test_affine_map"() { affine_map = h } : () -> ()
// will produce the sequence of compositions: f, g(f), h(g(f)) and print the
// AffineMap h(g(f)), which is what FileCheck checks against.
func @simple1() {
// CHECK: Composed map: (d0) -> (d0)
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 1)> } : () -> ()
return
}
func @simple2() {
// CHECK: Composed map: (d0)[s0, s1] -> (d0 - s0 + s1)
"test_affine_map"() { affine_map = affine_map<(d0)[s0] -> (d0 + s0 - 1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0)[s0] -> (d0 - s0 + 1)> } : () -> ()
return
}
func @simple3a() {
// CHECK: Composed map: (d0, d1)[s0, s1, s2, s3] -> ((d0 ceildiv s2) * s0, (d1 ceildiv s3) * s1)
"test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 ceildiv s0, d1 ceildiv s1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 * s0, d1 * s1)> } : () -> ()
return
}
func @simple3b() {
// CHECK: Composed map: (d0, d1)[s0, s1] -> (d0 mod s0, d1 mod s1)
"test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 mod s0, d1 mod s1)> } : () -> ()
return
}
func @simple3c() {
// CHECK: Composed map: (d0, d1)[s0, s1, s2, s3, s4, s5] -> ((d0 ceildiv s4) * s4 + d0 mod s2, (d1 ceildiv s5) * s5 + d1 mod s3)
"test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> ((d0 ceildiv s0) * s0, (d1 ceildiv s1) * s1, d0, d1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0, d1, d2, d3)[s0, s1, s2, s3] -> (d0 + d2 mod s2, d1 + d3 mod s3)> } : () -> ()
return
}
func @simple4() {
// CHECK: Composed map: (d0, d1)[s0, s1] -> (d1 * s1, d0 ceildiv s0)
"test_affine_map"() { affine_map = affine_map<(d0, d1) -> (d1, d0)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 * s1, d1 ceildiv s0)> } : () -> ()
return
}
func @simple5a() {
// CHECK: Composed map: (d0) -> (d0 * 3 + 18)
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 24)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 ceildiv 8)> } : () -> ()
return
}
func @simple5b() {
// CHECK: Composed map: (d0) -> ((d0 + 6) ceildiv 2)
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 4)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 ceildiv 8)> } : () -> ()
return
}
func @simple5c() {
// CHECK: Composed map: (d0) -> (d0 * 8 + 48)
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 24)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 floordiv 3)> } : () -> ()
return
}
func @simple5d() {
// CHECK: Composed map: (d0) -> ((d0 * 4) floordiv 3 + 8)
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 4)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 floordiv 3)> } : () -> ()
return
}
func @simple5e() {
// CHECK: Composed map: (d0) -> ((d0 + 6) ceildiv 8)
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 ceildiv 8)> } : () -> ()
return
}
func @simple5f() {
// CHECK: Composed map: (d0) -> ((d0 * 4 - 4) floordiv 3)
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 4)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0) -> (d0 floordiv 3)> } : () -> ()
return
}
func @perm_and_proj() {
// CHECK: Composed map: (d0, d1, d2, d3) -> (d1, d3, d0)
"test_affine_map"() { affine_map = affine_map<(d0, d1, d2, d3) -> (d3, d1, d2, d0)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0, d1, d2, d3) -> (d1, d0, d3)> } : () -> ()
return
}
func @symbols1() {
// CHECK: Composed map: (d0)[s0] -> (d0 + s0 + 1, d0 - s0 - 1)
"test_affine_map"() { affine_map = affine_map<(d0)[s0] -> (d0 + s0, d0 - s0)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0, d1) -> (d0 + 1, d1 - 1)> } : () -> ()
return
}
func @drop() {
// CHECK: Composed map: (d0, d1, d2)[s0, s1] -> (d0 * 2 + d1 + d2 + s1)
"test_affine_map"() { affine_map = affine_map<(d0, d1, d2)[s0, s1] -> (d0 + s1, d1 + s0, d0 + d1 + d2)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0, d1, d2) -> (d0 + d2)> } : () -> ()
return
}
func @multi_symbols() {
// CHECK: Composed map: (d0)[s0, s1, s2] -> (d0 + s1 + s2 + 1, d0 - s0 - s2 - 1)
"test_affine_map"() { affine_map = affine_map<(d0)[s0] -> (d0 + s0, d0 - s0)> } : () -> ()
"test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 + 1 + s1, d1 - 1 - s0)> } : () -> ()
return
}