9 #ifndef MLIR_DIALECT_LINALG_IR_LINALG_H
10 #define MLIR_DIALECT_LINALG_IR_LINALG_H
32 #include "llvm/ADT/STLFunctionalExtras.h"
69 MLIRContext *context);
74 MLIRContext *context);
77 SmallVector<AffineExpr, 4>
concat(ArrayRef<AffineExpr> a,
78 ArrayRef<AffineExpr> b);
100 #include "mlir/Dialect/Linalg/IR/LinalgOpsDialect.h.inc"
106 #include "mlir/Dialect/Linalg/IR/LinalgOpsEnums.h.inc"
126 #define GET_ATTRDEF_CLASSES
127 #include "mlir/Dialect/Linalg/IR/LinalgOpsAttrDefs.h.inc"
139 #define GET_OP_CLASSES
140 #include "mlir/Dialect/Linalg/IR/LinalgOps.h.inc"
142 #define GET_OP_CLASSES
143 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.h.inc"
145 #define GET_OP_CLASSES
146 #include "mlir/Dialect/Linalg/IR/LinalgRelayoutOps.h.inc"
152 template <
typename OpTy,
153 typename = std::enable_if_t<std::is_same_v<OpTy, linalg::PackOp> ||
154 std::is_same_v<OpTy, linalg::UnPackOp>>>
163 using MatmulOp::MatmulOp;
176 static void build(OpBuilder &builder, OperationState &result,
177 TypeRange resultTensorTypes, ValueRange inputs,
179 ArrayRef<NamedAttribute> attributes = {});
181 static MatmulTransposeAOp
create(OpBuilder &builder, Location location,
182 TypeRange resultTensorTypes,
183 ValueRange inputs, ValueRange outputs,
184 ArrayRef<NamedAttribute> attributes = {});
187 static void build(OpBuilder &builder, OperationState &result,
188 TypeRange resultTensorTypes, ValueRange inputs,
189 ValueRange outputs, Attribute cast,
190 ArrayRef<NamedAttribute> attributes = {});
192 static MatmulTransposeAOp
create(OpBuilder &builder, Location location,
193 TypeRange resultTensorTypes,
194 ValueRange inputs, ValueRange outputs,
196 ArrayRef<NamedAttribute> attributes = {});
201 static bool classof(Operation *op);
210 using MatmulOp::MatmulOp;
223 static void build(OpBuilder &builder, OperationState &result,
224 TypeRange resultTensorTypes, ValueRange inputs,
226 ArrayRef<NamedAttribute> attributes = {});
228 static MatmulTransposeBOp
create(OpBuilder &builder, Location location,
229 TypeRange resultTensorTypes,
230 ValueRange inputs, ValueRange outputs,
231 ArrayRef<NamedAttribute> attributes = {});
234 static void build(OpBuilder &builder, OperationState &result,
235 TypeRange resultTensorTypes, ValueRange inputs,
236 ValueRange outputs, Attribute cast,
237 ArrayRef<NamedAttribute> attributes = {});
239 static MatmulTransposeBOp
create(OpBuilder &builder, Location location,
240 TypeRange resultTensorTypes,
241 ValueRange inputs, ValueRange outputs,
243 ArrayRef<NamedAttribute> attributes = {});
248 static bool classof(Operation *op);
258 using BatchMatmulOp::BatchMatmulOp;
259 static ::mlir::TypeID
resolveTypeID() {
return TypeID::get<BatchMatmulOp>(); }
266 static BatchMatmulTransposeAOp
271 static void build(OpBuilder &builder, OperationState &result,
272 TypeRange resultTensorTypes, ValueRange inputs,
274 ArrayRef<NamedAttribute> attributes = {});
276 static BatchMatmulTransposeAOp
277 create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
278 ValueRange inputs, ValueRange outputs,
279 ArrayRef<NamedAttribute> attributes = {});
282 static void build(OpBuilder &builder, OperationState &result,
283 TypeRange resultTensorTypes, ValueRange inputs,
284 ValueRange outputs, Attribute cast,
285 ArrayRef<NamedAttribute> attributes = {});
287 static BatchMatmulTransposeAOp
288 create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
289 ValueRange inputs, ValueRange outputs, Attribute cast,
290 ArrayRef<NamedAttribute> attributes = {});
295 static bool classof(Operation *op);
305 using BatchMatmulOp::BatchMatmulOp;
306 static ::mlir::TypeID
resolveTypeID() {
return TypeID::get<BatchMatmulOp>(); }
313 static BatchMatmulTransposeBOp
318 static void build(OpBuilder &builder, OperationState &result,
319 TypeRange resultTensorTypes, ValueRange inputs,
321 ArrayRef<NamedAttribute> attributes = {});
323 static BatchMatmulTransposeBOp
324 create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
325 ValueRange inputs, ValueRange outputs,
326 ArrayRef<NamedAttribute> attributes = {});
329 static void build(OpBuilder &builder, OperationState &result,
330 TypeRange resultTensorTypes, ValueRange inputs,
331 ValueRange outputs, Attribute cast,
332 ArrayRef<NamedAttribute> attributes = {});
334 static BatchMatmulTransposeBOp
335 create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
336 ValueRange inputs, ValueRange outputs, Attribute cast,
337 ArrayRef<NamedAttribute> attributes = {});
342 static bool classof(Operation *op);
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
This class provides an abstraction over the different types of ranges over Values.
Specialization of linalg.batch_matmul op that has a transpose map on A.
static bool isDefaultIndexingMaps(Attribute attr)
Checks if the affine map is the expected one for this operation.
static bool classof(Operation *op)
static BatchMatmulTransposeAOp create(OpBuilder &builder, Location location, ValueRange inputs, ValueRange outputs, ArrayRef< NamedAttribute > attributes={})
::mlir::TypeID resolveTypeID()
static void build(OpBuilder &builder, OperationState &result, ValueRange inputs, ValueRange outputs, ArrayRef< NamedAttribute > attributes={})
Build a transpose A matmul.
Specialization of linalg.batch_matmul op that has a transpose map on B.
static void build(OpBuilder &builder, OperationState &result, ValueRange inputs, ValueRange outputs, ArrayRef< NamedAttribute > attributes={})
Build a transpose B matmul.
::mlir::TypeID resolveTypeID()
static bool classof(Operation *op)
static BatchMatmulTransposeBOp create(OpBuilder &builder, Location location, ValueRange inputs, ValueRange outputs, ArrayRef< NamedAttribute > attributes={})
static bool isDefaultIndexingMaps(Attribute attr)
Checks if the affine map is the expected one for this operation.
Specialization of linalg.matmul op that has a transpose map on A.
static bool isDefaultIndexingMaps(Attribute attr)
Checks if the affine map is the expected one for this operation.
static MatmulTransposeAOp create(OpBuilder &builder, Location location, ValueRange inputs, ValueRange outputs, ArrayRef< NamedAttribute > attributes={})
::mlir::TypeID resolveTypeID()
static void build(OpBuilder &builder, OperationState &result, ValueRange inputs, ValueRange outputs, ArrayRef< NamedAttribute > attributes={})
Build a transpose A matmul.
static bool classof(Operation *op)
Specialization of linalg.matmul op that has a transpose map on B.
::mlir::TypeID resolveTypeID()
static void build(OpBuilder &builder, OperationState &result, ValueRange inputs, ValueRange outputs, ArrayRef< NamedAttribute > attributes={})
Build a transpose B matmul.
static MatmulTransposeBOp create(OpBuilder &builder, Location location, ValueRange inputs, ValueRange outputs, ArrayRef< NamedAttribute > attributes={})
static bool isDefaultIndexingMaps(Attribute attr)
Checks if the affine map is the expected one for this operation.
static bool classof(Operation *op)
SmallVector< AffineExpr, 4 > concat(ArrayRef< AffineExpr > a, ArrayRef< AffineExpr > b)
Return the vector that is the concatenation of a and b.
OpFoldResult createFoldedDimOp(OpBuilder &b, Location loc, Value val, int64_t dim)
Create one memref::DimOp or tensor::DimOp depending on the type of val.
std::string generateLibraryCallName(Operation *op)
Returns the name mangled library call name to disambiguate between different overloads at the C level...
AffineMap extractOrIdentityMap(std::optional< AffineMap > maybeMap, unsigned rank, MLIRContext *context)
Returns maybeMap.get() if maybeMap is set, otherwise returns the symbol-less identity map of rank.
SmallVector< AffineExpr, 4 > makeAffineDimExprs(unsigned num, unsigned &startIdx, MLIRContext *context)
Returns num AffineDimExpr dimensions at positions [startIdx, startIdx + num) and increments startIdx ...
Value createOrFoldDimOp(OpBuilder &b, Location loc, Value val, int64_t dim)
Create one memref::DimOp or tensor::DimOp depending on the type of val.
std::pair< int64_t, int64_t > getFmrFromWinogradConv2DFmr(WinogradConv2DFmr fmr)
Converts the given WinogradConv2DFmr enumeration value to a pair of m and r parameters.
std::optional< WinogradConv2DFmr > getWinogradConv2DFmr(int64_t m, int64_t r)
Converts the given m and r parameters to a WinogradConv2DFmr enumeration value.
SmallVector< int64_t > getPackedOuterShapeWithoutTransposition(OpTy packOrUnPack)
Returns the outer shape in the packed domain before applying the transposition.
Include the generated interface declarations.
This represents an operation in an abstracted form, suitable for use with the builder APIs.