MLIR: include/mlir/Dialect/Utils/StructuredOpsUtils.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef MLIR_DIALECT_UTILS_STRUCTUREDOPSUTILS_H
18#define MLIR_DIALECT_UTILS_STRUCTUREDOPSUTILS_H
19
25
26
27#include "mlir/Dialect/Utils/DialectUtilsEnums.h.inc"
28
29namespace mlir {
30
33
34
35
36
37
39
40
41
42
43
45
46
47
48
49
51
52
53
54
55
57
58
59
60
61
63
64
65
66
67
69
70
71
72
73
75
76
78 utils::IteratorType iteratorTypeName,
80 for (const auto &en : llvm::enumerate(iteratorTypes)) {
81 if (en.value() == iteratorTypeName)
82 res.push_back(en.index());
83 }
84}
85
86
87
88
89template <typename StructuredOpInterface, typename IteratorTypeT>
91public:
93
96 bool isOfType(IteratorTypeT expectedIter) const {
97 return expectedIter == iter;
98 }
100 };
107
112
114 if (its.size() != iterators.size())
115 return false;
116 for (int i = 0, e = its.size(); i != e; ++i) {
117 if (!its[i].isOfType(iterators[i]))
118 return false;
119 }
120 return true;
121 }
122
124 auto infer = [&](MapList m) {
126 };
127 return maps == infer(l);
128 }
129
130protected:
137};
138
139
140
141
144template
147 return cast(clone(b, op.getOperation(), newResultTypes, newOperands));
148}
149
150
151
155
156
157
160
161}
162
163#endif
b
Return true if permutation is a valid permutation of the outer_dims_perm (case OuterOrInnerPerm::Oute...
static SmallVector< AffineMap, 4 > inferFromExprList(ArrayRef< ArrayRef< AffineExpr > > exprsList, MLIRContext *context)
Returns a vector of AffineMaps; each with as many results as exprs.size(), as many dims as the larges...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
This class helps build Operations.
Operation is the basic unit of execution within MLIR.
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
MLIRContext * ctx
Definition StructuredOpsUtils.h:132
bool layout(MapList l)
Definition StructuredOpsUtils.h:123
Operation * op
Definition StructuredOpsUtils.h:136
SmallVector< AffineMap, 4 > maps
Definition StructuredOpsUtils.h:135
Location loc
Definition StructuredOpsUtils.h:133
bool iters(ArrayRef< IteratorType > its)
Definition StructuredOpsUtils.h:113
SmallVector< IteratorTypeT > iterators
Definition StructuredOpsUtils.h:134
StructuredGenerator(RewriterBase &rewriter, StructuredOpInterface op)
Definition StructuredOpsUtils.h:108
ArrayRef< ArrayRef< AffineExpr > > MapList
Definition StructuredOpsUtils.h:92
RewriterBase & rewriter
Definition StructuredOpsUtils.h:131
This class provides an abstraction over the various different ranges of value types.
This class provides an abstraction over the different types of ranges over Values.
Include the generated interface declarations.
bool isColumnMajorMatmul(ArrayAttr indexingMaps)
Tests whether the given maps describe a column major matmul.
bool isBatchMatvec(ArrayAttr indexingMaps)
Tests whether the given maps describe a batch matrix vector multiplication.
Operation * cloneWithoutRegions(OpBuilder &b, Operation *op, TypeRange newResultTypes, ValueRange newOperands)
bool isMatvec(ArrayAttr indexingMaps)
Tests whether the given maps describe a matrix vector multiplication.
bool isBatchVecmat(ArrayAttr indexingMaps)
Tests whether the given maps describe a batch vector matrix multiplication.
bool isRowMajorBatchMatmul(ArrayAttr indexingMaps)
Tests whether the given maps describe a row major batch matmul.
Operation * clone(OpBuilder &b, Operation *op, TypeRange newResultTypes, ValueRange newOperands)
bool isVecmat(ArrayAttr indexingMaps)
Tests whether the given maps describe a vector matrix multiplication.
void findPositionsOfType(ArrayRef< utils::IteratorType > iteratorTypes, utils::IteratorType iteratorTypeName, SmallVectorImpl< unsigned > &res)
Return positions in iteratorTypes that match iteratorTypeName.
Definition StructuredOpsUtils.h:77
bool isRowMajorMatmul(ArrayAttr indexingMaps)
Tests whether the given maps describe a row major matmul.
SmallVector< NamedAttribute > getPrunedAttributeList(Operation *op, ArrayRef< StringRef > elidedAttrs)
IteratorType(IteratorTypeT iter)
Definition StructuredOpsUtils.h:95
IteratorTypeT iter
Definition StructuredOpsUtils.h:99
bool isOfType(IteratorTypeT expectedIter) const
Definition StructuredOpsUtils.h:96
Par()
Definition StructuredOpsUtils.h:102
Red()
Definition StructuredOpsUtils.h:105