1
1
// ===- StructuredOpMatcher.h -------------------------------------*- C++-*-===//
2
2
//
3
- // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3
+ // This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
5
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
- #ifndef TPP_IR_STRUCTUREDOPMATCHER_H
10
- #define TPP_IR_STRUCTUREDOPMATCHER_H
9
+ #ifndef GC_UTILS_STRUCTUREDOPMATCHER_H
10
+ #define GC_UTILS_STRUCTUREDOPMATCHER_H
11
11
12
12
#include " mlir/Dialect/Arith/IR/Arith.h"
13
13
#include " mlir/Dialect/Linalg/IR/Linalg.h"
@@ -20,18 +20,6 @@ namespace mlir {
20
20
class Operation ;
21
21
namespace structured_match {
22
22
23
- struct KindAdd {
24
- static bool classof (const Operation *op) {
25
- return isa<arith::AddFOp>(op) || isa<arith::AddIOp>(op);
26
- }
27
- };
28
-
29
- struct KindMul {
30
- static bool classof (const Operation *op) {
31
- return isa<arith::MulFOp>(op) || isa<arith::MulIOp>(op);
32
- }
33
- };
34
-
35
23
// Base class for the matcher predicates selection tag.
36
24
struct MatchSelector {
37
25
MatchSelector () = delete ;
@@ -61,14 +49,6 @@ struct MatchOne : public MatchSelector {
61
49
MatchOne (size_t idx) : MatchSelector(idx, idx + 1 ) {}
62
50
};
63
51
64
- // Selector which specifies that predicate should apply only on range of values
65
- // at positions from `lowerBound` up to - but not including - `upperBound`.
66
- struct MatchRange : public MatchSelector {
67
- MatchRange () = delete ;
68
- MatchRange (size_t lowerBound, size_t upperBound)
69
- : MatchSelector(lowerBound, upperBound) {}
70
- };
71
-
72
52
// Callable object to check if the number of loops in `op` satisfies `fun`.
73
53
struct NumOfLoops {
74
54
NumOfLoops () = delete ;
@@ -152,13 +132,6 @@ struct Identity {
152
132
bool operator ()(AffineMap map) const { return map.isIdentity (); }
153
133
};
154
134
155
- // Callable object to capture any map.
156
- struct Any {
157
- Any () = default ;
158
-
159
- bool operator ()(AffineMap map) const { return true ; }
160
- };
161
-
162
135
// Callable object to verify if `operand` has static shape.
163
136
struct HasStaticShape {
164
137
HasStaticShape () = default ;
@@ -244,48 +217,6 @@ template <typename T> struct EqualsTo {
244
217
};
245
218
template <typename T> EqualsTo (T) -> EqualsTo<T>;
246
219
247
- // Callable object to check if the input is less than or equal to specified
248
- // `value`.
249
- struct LessThanOrEqualTo {
250
- LessThanOrEqualTo () = delete ;
251
- explicit LessThanOrEqualTo (size_t value) : value(value){};
252
- const size_t value;
253
-
254
- bool operator ()(size_t value) const { return value <= this ->value ; }
255
- };
256
-
257
- // Callable object to check if the input is greater than or equal to specified
258
- // `value`.
259
- struct GreaterThanOrEqualTo {
260
- GreaterThanOrEqualTo () = delete ;
261
- explicit GreaterThanOrEqualTo (size_t value) : value(value){};
262
- const size_t value;
263
-
264
- bool operator ()(size_t value) const { return value >= this ->value ; }
265
- };
266
-
267
- // Callable object to check if `op` has tensor semantics.
268
- struct HasTensorSemantics {
269
- HasTensorSemantics () = default ;
270
-
271
- bool operator ()(Operation *op) const {
272
- if (auto linalgOp = dyn_cast_or_null<linalg::LinalgOp>(op))
273
- return linalgOp.hasPureTensorSemantics ();
274
- return false ;
275
- }
276
- };
277
-
278
- // Callable object to check if `op` buffer semantics.
279
- struct HasBufferSemantics {
280
- HasBufferSemantics () = default ;
281
-
282
- bool operator ()(Operation *op) const {
283
- if (auto linalgOp = dyn_cast_or_null<linalg::LinalgOp>(op))
284
- return linalgOp.hasPureBufferSemantics ();
285
- return false ;
286
- }
287
- };
288
-
289
220
// Callable object to validate number of init operands for `op`.
290
221
struct NumDpsInits {
291
222
NumDpsInits () = delete ;
@@ -300,20 +231,6 @@ struct NumDpsInits {
300
231
std::function<bool (size_t )> fun;
301
232
};
302
233
303
- // Callable object to check the number of affine map for `op`.
304
- struct NumAffineMaps {
305
- NumAffineMaps () = delete ;
306
- explicit NumAffineMaps (std::function<bool (size_t )> fun) : fun(std::move(fun)){};
307
-
308
- bool operator ()(Operation *op) const {
309
- if (auto linalgOp = dyn_cast_or_null<linalg::LinalgOp>(op))
310
- return fun (linalgOp.getIndexingMapsArray ().size ());
311
- return false ;
312
- }
313
-
314
- std::function<bool (size_t )> fun;
315
- };
316
-
317
234
// Callable object to validate number of input operands for `op`.
318
235
struct NumDpsInputs {
319
236
NumDpsInputs () = delete ;
@@ -458,4 +375,4 @@ class StructuredOpMatcher {
458
375
} // namespace structured_match
459
376
} // namespace mlir
460
377
461
- #endif // TPP_IR_STRUCTUREDOPMATCHER_H
378
+ #endif // GC_UTILS_STRUCTUREDOPMATCHER_H
0 commit comments