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
15#include "mlir/Dialect/Tosa/Transforms/Passes.h"
16
17#include "mlir/Dialect/Func/IR/FuncOps.h"
18#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
19
20namespace mlir {
21namespace tosa {
22#define GEN_PASS_DEF_TOSAOPTIONALDECOMPOSITIONSPASS
23#include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
24} // namespace tosa
25} // namespace mlir
26
27using namespace mlir;
28
29namespace {
30
31struct TosaOptionalDecompositions
32 : public tosa::impl::TosaOptionalDecompositionsPassBase<
33 TosaOptionalDecompositions> {
34 void runOnOperation() override {
35 auto *ctx = &getContext();
36 RewritePatternSet patterns(ctx);
37 auto func = getOperation();
38
39 mlir::tosa::populateTosaDecomposeTransposeConv(ctx, patterns);
40 mlir::tosa::populateTosaDecomposeDepthwise(ctx, patterns);
41
42 if (applyPatternsGreedily(op: func, patterns: std::move(patterns)).failed())
43 signalPassFailure();
44 }
45};
46
47} // namespace
48

source code of mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp