17 #ifndef MLIR_DIALECT_UTILS_STRUCTUREDOPSUTILS_H 18 #define MLIR_DIALECT_UTILS_STRUCTUREDOPSUTILS_H 24 #include "llvm/ADT/StringRef.h" 59 return "distribution_types";
105 return llvm::makeArrayRef(names);
112 assert(llvm::is_contained(names, name));
113 return llvm::count_if(iteratorTypes, [name](
Attribute a) {
114 return a.
cast<StringAttr>().getValue() == name;
135 llvm_unreachable(
"Unsupported IteratorType");
141 template <
typename StructuredOpInterface>
149 auto sAttr = attr.
dyn_cast<StringAttr>();
150 return sAttr && sAttr.getValue() ==
strRef;
165 : builder(builder), ctx(op.getContext()), loc(op.getLoc()),
166 iterators(op.getIteratorTypes()), maps(op.getIndexingMaps()), op(op) {}
169 if (its.size() != iterators.size())
171 for (
int i = 0, e = its.size(); i != e; ++i) {
172 if (!its[i].isOfType(iterators[i]))
180 return maps == infer(l);
194 #endif // MLIR_DIALECT_UTILS_STRUCTUREDOPSUTILS_H
Include the generated interface declarations.
ArrayRef< StringRef > getAllIteratorTypeNames()
Use to encode that a particular iterator type has window semantics.
constexpr StringRef getParallelIteratorTypeName()
Use to encode that a particular iterator type has parallel semantics.
U dyn_cast_or_null() const
Operation is a basic unit of execution within MLIR.
bool isRowMajorBatchMatmul(ArrayAttr indexingMaps)
Tests whether the given maps describe a row major batch matmul.
bool isParallelIterator(Attribute attr)
constexpr StringRef getPaddingAttrName()
Attribute name for the StrArrayAttr which encodes the value of paddings.
constexpr StringRef getWindowIteratorTypeName()
Use to encode that a particular iterator type has window semantics.
IteratorType
Typed representation for loop type strings.
constexpr StringRef getIteratorTypesAttrName()
Attribute name for the StrArrayAttr which encodes the type of a structured op's iterators.
bool isColumnMajorMatmul(ArrayAttr indexingMaps)
Tests whether the given maps describe a column major matmul.
constexpr StringRef getDocAttrName()
Attribute name for the StringAttr which encodes an optional documentation string of the structured op...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
bool isOfType(Attribute attr) const
constexpr StringRef getDistributionTypesAttrName()
Attribute name for the StrArrayAttr which encodes the distribution type for linalg.tiled_loop.
unsigned getNumIterators(StringRef name, ArrayAttr iteratorTypes)
Returns the iterator of a certain type.
constexpr StringRef getDilationsAttrName()
Attribute name for the StrArrayAttr which encodes the value of dilations.
Attributes are known-constant values of operations.
SmallVector< AffineMap, 4 > maps
bool isReductionIterator(Attribute attr)
constexpr StringRef getLibraryCallAttrName()
Attribute name for the StrArrayAttr which encodes the external library function that implements the s...
constexpr StringRef getIndexingMapsAttrName()
Attribute name for the AffineArrayAttr which encodes the relationship between a structured op iterato...
constexpr StringRef getStridesAttrName()
Attribute name for the StrArrayAttr which encodes the value of strides.
MLIRContext is the top-level object for a collection of MLIR operations.
bool isWindowIterator(Attribute attr)
StructuredGenerator(OpBuilder &builder, StructuredOpInterface op)
StringRef toString(IteratorType t)
constexpr StringRef getReductionIteratorTypeName()
Use to encode that a particular iterator type has reduction semantics.
static SmallVector< AffineMap, 4 > inferFromExprList(ArrayRef< ArrayRef< AffineExpr >> exprsList)
Returns a vector of AffineMaps; each with as many results as exprs.size(), as many dims as the larges...
This class helps build Operations.
bool isRowMajorMatmul(ArrayAttr indexingMaps)
Tests whether the given maps describe a row major matmul.
Helper StructuredGenerator class to manipulate and rewrite ops with StructuredOpInterface.
bool iters(ArrayRef< IteratorType > its)
IteratorType(StringRef strRef)