20 auto linalgOp = cast<LinalgOp>(op);
21 auto *dialect =
static_cast<LinalgDialect *
>(linalgOp->getDialect());
22 LinalgDialect::RegionBuilderFunType fun =
25 assert(fun &&
"Expected a builtin named Linalg op.");
26 assert(op->
getNumRegions() == 1 &&
"Expected Linalg op with 1 region");
28 "Expected Linalg op with 0 blocks");
32 for (
OpOperand &opOperand : linalgOp->getOpOperands()) {
34 argLocs.push_back(opOperand.get().getLoc());
45 auto linalgOp = llvm::dyn_cast<mlir::linalg::LinalgOp>(
unwrap(op));
53 auto linalgOp = dyn_cast<linalg::LinalgOp>(
unwrap(op));
57 FailureOr<linalg::ContractionDimensions> maybeDims =
59 if (failed(maybeDims))
70 result.batch = toAttr(contractionDims.
batch);
71 result.m = toAttr(contractionDims.
m);
72 result.n = toAttr(contractionDims.
n);
73 result.k = toAttr(contractionDims.
k);
79 auto linalgOp = llvm::dyn_cast<mlir::linalg::LinalgOp>(
unwrap(op));
89 auto linalgOp = llvm::dyn_cast<mlir::linalg::LinalgOp>(
unwrap(op));
93 FailureOr<linalg::ConvolutionDimensions> maybeDims =
95 if (failed(maybeDims))
111 result.batch = toI32Attr(dims.
batch);
114 result.filterLoop = toI32Attr(dims.
filterLoop);
116 result.depth = toI32Attr(dims.
depth);
117 result.strides = toI64Attr(dims.
strides);
118 result.dilations = toI64Attr(dims.
dilations);
125 auto linalgOp = llvm::dyn_cast<mlir::linalg::LinalgOp>(
unwrap(op));
127 return MlirAttribute{
nullptr};
129 ArrayAttr attr = linalgOp.getIndexingMaps();
MLIR_CAPI_EXPORTED MlirLinalgConvolutionDimensions mlirLinalgInferConvolutionDimensions(MlirOperation op)
void mlirLinalgFillBuiltinNamedOpRegion(MlirOperation mlirOp)
Apply the special region builder for the builtin named Linalg op.
MLIR_CAPI_EXPORTED bool mlirLinalgIsAContractionOp(MlirOperation op)
MLIR_CAPI_EXPORTED MlirAttribute mlirLinalgGetIndexingMapsAttribute(MlirOperation op)
MLIR_CAPI_EXPORTED bool mlirLinalgIsAConvolutionOp(MlirOperation op)
MLIR_CAPI_EXPORTED MlirLinalgContractionDimensions mlirLinalgInferContractionDimensions(MlirOperation op)
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Name, Namespace, ClassName)
Block represents an ordered list of Operations.
ImplicitLocOpBuilder maintains a 'current location', allowing use of the create<> method without spec...
MLIRContext is the top-level object for a collection of MLIR operations.
void setInsertionPointToStart(Block *block)
Sets the insertion point to the start of the specified block.
Block * createBlock(Region *parent, Region::iterator insertPt={}, TypeRange argTypes=std::nullopt, ArrayRef< Location > locs=std::nullopt)
Add new block with 'argTypes' arguments and set the insertion point to the end of it.
This class represents an operand of an operation.
StringRef getStringRef() const
Return the name of this operation. This always succeeds.
Operation is the basic unit of execution within MLIR.
MLIRContext * getContext()
Return the context this operation is associated with.
unsigned getNumRegions()
Returns the number of regions held by this operation.
Location getLoc()
The source location the operation was defined or derived from.
ArrayRef< NamedAttribute > getAttrs()
Return all of the attributes on this operation.
Region & getRegion(unsigned index)
Returns the region held by this operation at position 'index'.
OperationName getName()
The name of an operation is the key identifier for it.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
BlockListType & getBlocks()
static DenseArrayAttrImpl get(MLIRContext *context, ArrayRef< int32_t > content)
Builder from ArrayRef<T>.
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
#define MLIR_CAPI_EXPORTED
FailureOr< ConvolutionDimensions > inferConvolutionDims(LinalgOp linalgOp)
Find at least 1 parallel (output_image) and reduction (filter_loop) dimension candidates that form a ...
bool isaConvolutionOpInterface(LinalgOp linalgOp, bool allowEmptyConvolvedDims=false)
Checks whether linalgOp conforms to ConvolutionOpInterface.
FailureOr< ContractionDimensions > inferContractionDims(LinalgOp linalgOp)
Find at least 2 parallel (m and n) and 1 reduction (k) dimension candidates that form a matmul subcom...
bool isaContractionOpInterface(LinalgOp linalgOp)
Checks whether linalgOp conforms to ContractionOpInterface.
Include the generated interface declarations.
Type getElementTypeOrSelf(Type type)
Return the element type or return the type itself.
Positions of a Linalg op loops that correspond to different kinds of a contraction dimension.
SmallVector< unsigned, 2 > batch
SmallVector< unsigned, 2 > m
SmallVector< unsigned, 2 > n
SmallVector< unsigned, 2 > k
Positions of a Linalg op loops that correspond to different kinds of a convolution dimension.
SmallVector< unsigned, 2 > depth
SmallVector< unsigned, 2 > outputImage
SmallVector< unsigned, 2 > outputChannel
SmallVector< int64_t, 2 > dilations
SmallVector< int64_t, 2 > strides
SmallVector< unsigned, 2 > inputChannel
SmallVector< unsigned, 2 > batch
SmallVector< unsigned, 2 > filterLoop