26 #include "llvm/ADT/TypeSwitch.h"
62 constexpr const ::llvm::StringLiteral
63 LinalgDialect::kMemoizedIndexingMapsAttrName;
66 template <
typename T,
typename... Args>
73 template <
typename OpType,
typename = std::enable_if_t<
76 llvm::StringMap<LinalgDialect::RegionBuilderFunType> &map) {
80 template <
typename OpType,
81 typename = std::enable_if_t<detect_has_region_builder<OpType>::value>,
84 llvm::StringMap<LinalgDialect::RegionBuilderFunType> &map) {
85 map.insert(std::make_pair(
86 OpType::getOperationName(),
87 static_cast<LinalgDialect::RegionBuilderFunType
>(OpType::regionBuilder)));
90 template <
typename... OpTypes>
92 llvm::StringMap<LinalgDialect::RegionBuilderFunType> &map) {
93 (addNamedOpBuilderImpl<OpTypes>(map), ...);
96 void mlir::linalg::LinalgDialect::initialize() {
98 #define GET_ATTRDEF_LIST
99 #include "mlir/Dialect/Linalg/IR/LinalgOpsAttrDefs.cpp.inc"
103 #include "mlir/Dialect/Linalg/IR/LinalgOps.cpp.inc"
107 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
111 #include "mlir/Dialect/Linalg/IR/LinalgRelayoutOps.cpp.inc"
117 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
118 >(namedStructuredOpRegionBuilders);
120 addInterfaces<LinalgInlinerInterface>();
122 declarePromisedInterface<mesh::ShardingInterface, GenericOp>();
123 declarePromisedInterfaces<mesh::ShardingInterface,
125 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
127 declarePromisedInterface<SubsetOpInterface, CopyOp>();
128 declarePromisedInterface<SubsetInsertionOpInterface, CopyOp>();
131 declarePromisedInterface<ValueBoundsOpInterface, IndexOp>();
133 declarePromisedInterface<PartialReductionOpInterface, linalg::GenericOp>();
136 declarePromisedInterface<TilingInterface, linalg::GenericOp>();
137 declarePromisedInterfaces<TilingInterface,
139 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
141 declarePromisedInterfaces<TilingInterface,
143 #include "mlir/Dialect/Linalg/IR/LinalgRelayoutOps.cpp.inc"
145 declarePromisedInterfaces<PartialReductionOpInterface,
147 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
149 declarePromisedInterfaces<bufferization::BufferizableOpInterface,
151 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
155 LogicalResult LinalgDialect::verifyOperationAttribute(
Operation *op,
157 if (attr.
getName() == LinalgDialect::kMemoizedIndexingMapsAttrName)
160 <<
"' not supported by the linalg dialect";
163 #include "mlir/Dialect/Linalg/IR/LinalgOpsEnums.cpp.inc"
165 #define GET_ATTRDEF_CLASSES
166 #include "mlir/Dialect/Linalg/IR/LinalgOpsAttrDefs.cpp.inc"
168 #include "mlir/Dialect/Linalg/IR/LinalgOpsDialect.cpp.inc"
static bool isLegalToInline(InlinerInterface &interface, Region *src, Region *insertRegion, bool shouldCloneInlinedRegion, IRMapping &valueMapping)
Utility to check that all of the operations within 'src' can be inlined.
llvm::is_detected< has_region_builder, T > detect_has_region_builder
decltype(T::regionBuilder) has_region_builder
Trait to check if T provides a regionBuilder method.
void addNamedOpBuilders(llvm::StringMap< LinalgDialect::RegionBuilderFunType > &map)
void addNamedOpBuilderImpl(llvm::StringMap< LinalgDialect::RegionBuilderFunType > &map)
SFINAE helper for single C++ class without a regionBuilder method (e.g.
This is the interface that must be implemented by the dialects of operations to be inlined.
DialectInlinerInterface(Dialect *dialect)
This is a utility class for mapping one set of IR entities to another.
NamedAttribute represents a combination of a name and an Attribute value.
StringAttr getName() const
Return the name of the attribute.
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This class provides an abstraction over the different types of ranges over Values.
Include the generated interface declarations.