MLIR 22.0.0git
TosaToArithPass.cpp
Go to the documentation of this file.
1//===- TosaToArithPass.cpp - Lowering Tosa to Linalg Dialect -----------===//
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 transformation pass legalizes Tosa operations to the Arith dialect.
10//
11//===----------------------------------------------------------------------===//
12
14
19
20namespace mlir {
21#define GEN_PASS_DEF_TOSATOARITHPASS
22#include "mlir/Conversion/Passes.h.inc"
23} // namespace mlir
24
25using namespace mlir;
26using namespace tosa;
27
28namespace {
29struct TosaToArith : public impl::TosaToArithPassBase<TosaToArith> {
30 using Base::Base;
31
32 void runOnOperation() override {
33 RewritePatternSet patterns(&getContext());
34 ConversionTarget target(getContext());
35 target.addIllegalOp<tosa::ConstOp>();
36 target.addLegalDialect<arith::ArithDialect>();
37
39
40 if (this->includeApplyRescale) {
42 this->use32Bit);
43 target.addIllegalOp<tosa::ApplyScaleOp>();
44 }
45
46 if (failed(applyPartialConversion(getOperation(), target,
47 std::move(patterns))))
48 signalPassFailure();
49 }
50};
51} // namespace
b getContext())
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:561
void populateTosaRescaleToArithConversionPatterns(RewritePatternSet *patterns, bool include32Bit=false)
void populateTosaToArithConversionPatterns(RewritePatternSet *patterns)
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns