MLIR  21.0.0git
TosaOptionalDecompositions.cpp
Go to the documentation of this file.
1 //===- TosaOptionalDecompositions.cpp -------------------------------------===//
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 // Pass to apply the Tosa operations decompositions
10 // exposed as populate functions in
11 // include/mlir/Dialect/Tosa/Transforms/Passes.h
12 //
13 //===----------------------------------------------------------------------===//
14 
16 
19 
20 namespace mlir {
21 namespace tosa {
22 #define GEN_PASS_DEF_TOSAOPTIONALDECOMPOSITIONSPASS
23 #include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
24 } // namespace tosa
25 } // namespace mlir
26 
27 using namespace mlir;
28 
29 namespace {
30 
31 struct TosaOptionalDecompositions
32  : public tosa::impl::TosaOptionalDecompositionsPassBase<
33  TosaOptionalDecompositions> {
34  void runOnOperation() override {
35  auto *ctx = &getContext();
37  auto func = getOperation();
38 
41 
42  if (applyPatternsGreedily(func, std::move(patterns)).failed())
43  signalPassFailure();
44  }
45 };
46 
47 } // namespace
static MLIRContext * getContext(OpFoldResult val)
void populateTosaDecomposeDepthwise(MLIRContext *ctx, RewritePatternSet &patterns)
void populateTosaDecomposeTransposeConv(MLIRContext *ctx, RewritePatternSet &patterns)
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