9 #ifndef MLIR_DIALECT_LINALG_IR_LINALG_H
10 #define MLIR_DIALECT_LINALG_IR_LINALG_H
31 #include "llvm/ADT/STLFunctionalExtras.h"
68 MLIRContext *context);
73 MLIRContext *context);
76 SmallVector<AffineExpr, 4>
concat(ArrayRef<AffineExpr> a,
77 ArrayRef<AffineExpr> b);
99 #include "mlir/Dialect/Linalg/IR/LinalgOpsDialect.h.inc"
105 #include "mlir/Dialect/Linalg/IR/LinalgOpsEnums.h.inc"
125 #define GET_ATTRDEF_CLASSES
126 #include "mlir/Dialect/Linalg/IR/LinalgOpsAttrDefs.h.inc"
138 #define GET_OP_CLASSES
139 #include "mlir/Dialect/Linalg/IR/LinalgOps.h.inc"
141 #define GET_OP_CLASSES
142 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.h.inc"
144 #define GET_OP_CLASSES
145 #include "mlir/Dialect/Linalg/IR/LinalgRelayoutOps.h.inc"
151 template <
typename OpTy,
152 typename = std::enable_if_t<std::is_same_v<OpTy, linalg::PackOp> ||
153 std::is_same_v<OpTy, linalg::UnPackOp>>>
162 using MatmulOp::MatmulOp;
175 static void build(OpBuilder &builder, OperationState &result,
176 TypeRange resultTensorTypes, ValueRange inputs,
178 ArrayRef<NamedAttribute> attributes = {});
180 static MatmulTransposeAOp
create(OpBuilder &builder, Location location,
181 TypeRange resultTensorTypes,
182 ValueRange inputs, ValueRange outputs,
183 ArrayRef<NamedAttribute> attributes = {});
186 static void build(OpBuilder &builder, OperationState &result,
187 TypeRange resultTensorTypes, ValueRange inputs,
188 ValueRange outputs, Attribute cast,
189 ArrayRef<NamedAttribute> attributes = {});
191 static MatmulTransposeAOp
create(OpBuilder &builder, Location location,
192 TypeRange resultTensorTypes,
193 ValueRange inputs, ValueRange outputs,
195 ArrayRef<NamedAttribute> attributes = {});
200 static bool classof(Operation *op);
209 using MatmulOp::MatmulOp;
222 static void build(OpBuilder &builder, OperationState &result,
223 TypeRange resultTensorTypes, ValueRange inputs,
225 ArrayRef<NamedAttribute> attributes = {});
227 static MatmulTransposeBOp
create(OpBuilder &builder, Location location,
228 TypeRange resultTensorTypes,
229 ValueRange inputs, ValueRange outputs,
230 ArrayRef<NamedAttribute> attributes = {});
233 static void build(OpBuilder &builder, OperationState &result,
234 TypeRange resultTensorTypes, ValueRange inputs,
235 ValueRange outputs, Attribute cast,
236 ArrayRef<NamedAttribute> attributes = {});
238 static MatmulTransposeBOp
create(OpBuilder &builder, Location location,
239 TypeRange resultTensorTypes,
240 ValueRange inputs, ValueRange outputs,
242 ArrayRef<NamedAttribute> attributes = {});
247 static bool classof(Operation *op);
257 using BatchMatmulOp::BatchMatmulOp;
258 static ::mlir::TypeID
resolveTypeID() {
return TypeID::get<BatchMatmulOp>(); }
265 static BatchMatmulTransposeAOp
270 static void build(OpBuilder &builder, OperationState &result,
271 TypeRange resultTensorTypes, ValueRange inputs,
273 ArrayRef<NamedAttribute> attributes = {});
275 static BatchMatmulTransposeAOp
276 create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
277 ValueRange inputs, ValueRange outputs,
278 ArrayRef<NamedAttribute> attributes = {});
281 static void build(OpBuilder &builder, OperationState &result,
282 TypeRange resultTensorTypes, ValueRange inputs,
283 ValueRange outputs, Attribute cast,
284 ArrayRef<NamedAttribute> attributes = {});
286 static BatchMatmulTransposeAOp
287 create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
288 ValueRange inputs, ValueRange outputs, Attribute cast,
289 ArrayRef<NamedAttribute> attributes = {});
294 static bool classof(Operation *op);
304 using BatchMatmulOp::BatchMatmulOp;
305 static ::mlir::TypeID
resolveTypeID() {
return TypeID::get<BatchMatmulOp>(); }
312 static BatchMatmulTransposeBOp
317 static void build(OpBuilder &builder, OperationState &result,
318 TypeRange resultTensorTypes, ValueRange inputs,
320 ArrayRef<NamedAttribute> attributes = {});
322 static BatchMatmulTransposeBOp
323 create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
324 ValueRange inputs, ValueRange outputs,
325 ArrayRef<NamedAttribute> attributes = {});
328 static void build(OpBuilder &builder, OperationState &result,
329 TypeRange resultTensorTypes, ValueRange inputs,
330 ValueRange outputs, Attribute cast,
331 ArrayRef<NamedAttribute> attributes = {});
333 static BatchMatmulTransposeBOp
334 create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
335 ValueRange inputs, ValueRange outputs, Attribute cast,
336 ArrayRef<NamedAttribute> attributes = {});
341 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.