MLIR 22.0.0git
TosaToMLProgramPass.cpp
Go to the documentation of this file.
1//===- TosaToMLProgramPass.cpp - Lowering Tosa to MLProgram 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 the TOSA dialect to the MLProgram dialect.
10//
11//===----------------------------------------------------------------------===//
12
19
20namespace mlir {
21#define GEN_PASS_DEF_TOSATOMLPROGRAM
22#include "mlir/Conversion/Passes.h.inc"
23} // namespace mlir
24
25using namespace mlir;
26using namespace tosa;
27
28namespace {
29struct TosaToMLProgram : public impl::TosaToMLProgramBase<TosaToMLProgram> {
30public:
31 void runOnOperation() override {
32 auto *context = &getContext();
33 auto moduleOp = getOperation();
34
35 RewritePatternSet patterns(context);
36 ConversionTarget target(*context);
37 target.addIllegalOp<tosa::VariableOp, tosa::VariableReadOp,
38 tosa::VariableWriteOp>();
39 target.markUnknownOpDynamicallyLegal([](Operation *) { return true; });
40
42
43 if (failed(applyPartialConversion(moduleOp, target, std::move(patterns))))
44 signalPassFailure();
45 }
46};
47} // namespace
b getContext())
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:561
void populateTosaToMLProgramConversionPatterns(RewritePatternSet *patterns)
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns