MLIR  20.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 #include "mlir/Pass/Pass.h"
21 
22 namespace mlir {
23 namespace tosa {
24 #define GEN_PASS_DEF_TOSAOPTIONALDECOMPOSITIONS
25 #include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
26 } // namespace tosa
27 } // namespace mlir
28 
29 using namespace mlir;
30 
31 namespace {
32 
33 struct TosaOptionalDecompositions
34  : public tosa::impl::TosaOptionalDecompositionsBase<
35  TosaOptionalDecompositions> {
36  void runOnOperation() override {
37  auto *ctx = &getContext();
38  RewritePatternSet patterns(ctx);
39  auto func = getOperation();
40 
44 
45  if (applyPatternsAndFoldGreedily(func, std::move(patterns)).failed())
46  signalPassFailure();
47  }
48 };
49 
50 } // namespace
51 
53  return std::make_unique<TosaOptionalDecompositions>();
54 }
static MLIRContext * getContext(OpFoldResult val)
void populateTosaDecomposeDepthwise(MLIRContext *ctx, RewritePatternSet &patterns)
void populateTosaDecomposeConv2D(MLIRContext *ctx, RewritePatternSet &patterns)
std::unique_ptr< Pass > createTosaOptionalDecompositions()
void populateTosaDecomposeTransposeConv(MLIRContext *ctx, RewritePatternSet &patterns)
Include the generated interface declarations.
LogicalResult applyPatternsAndFoldGreedily(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...