MLIR 22.0.0git
MorphOps.cpp
Go to the documentation of this file.
1//===- MorphOps.cpp - conversion between named,category and generic ops ---===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements conversions between linalg ops:
10// named <--> category (elementwise, contraction, ..) <--> generic.
11//===----------------------------------------------------------------------===//
12
21
22namespace mlir {
23#define GEN_PASS_DEF_LINALGMORPHOPSPASS
24#include "mlir/Dialect/Linalg/Passes.h.inc"
25} // namespace mlir
26
27#define DEBUG_TYPE "linalg-morphism"
28
29using namespace mlir;
30using namespace mlir::linalg;
31
32namespace {
33struct LinalgMorphOpsPass
34 : public impl::LinalgMorphOpsPassBase<LinalgMorphOpsPass> {
35
37 LinalgMorphOpsPass>::LinalgMorphOpsPassBase;
38
39 void runOnOperation() override;
40};
41
42void LinalgMorphOpsPass::runOnOperation() {
43
45
46 // Lowering paths (named -> category -> generic)
47 if (namedToCategory) {
49 }
50 if (namedToGeneric || categoryToGeneric) {
52 }
53
54 // Lifting paths (named <- category <- generic)
55 if (genericToNamed) {
57 }
58
59 if (failed(applyPatternsGreedily(getOperation(), std::move(patterns))))
60 signalPassFailure();
61}
62} // namespace
b getContext())
void populateLinalgNamedOpsGeneralizationPatterns(RewritePatternSet &patterns)
Linalg generalization patterns.
void populateLinalgGenericOpsSpecializationPatterns(RewritePatternSet &patterns)
Populates patterns with patterns to convert linalg.generic ops to named ops where possible.
void populateLinalgNamedToElementwisePatterns(RewritePatternSet &patterns)
Populates patterns that convert linalg named ops e.g.
Include the generated interface declarations.
LogicalResult applyPatternsGreedily(Region &region, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr)
Rewrite ops in the given region, which must be isolated from above, by repeatedly applying the highes...
const FrozenRewritePatternSet & patterns