brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · ec1865a Raw
48 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// Pass to apply the Tosa operations decompositions10// exposed as populate functions in11// include/mlir/Dialect/Tosa/Transforms/Passes.h12//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_TOSAOPTIONALDECOMPOSITIONSPASS23#include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"24} // namespace tosa25} // namespace mlir26 27using namespace mlir;28 29namespace {30 31struct TosaOptionalDecompositions32    : 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(func, std::move(patterns)).failed())43      signalPassFailure();44  }45};46 47} // namespace48