MLIR 24.0.0git
TosaToTensorPass.cpp
Go to the documentation of this file.
1//===- TosaToTensorPass.cpp - Lowering Tosa to Tensor 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 Tensor dialect.
10//
11//===----------------------------------------------------------------------===//
12
14
22
23namespace mlir {
24#define GEN_PASS_DEF_TOSATOTENSORPASS
25#include "mlir/Conversion/Passes.h.inc"
26} // namespace mlir
27
28using namespace mlir;
29using namespace tosa;
30
31namespace {
32struct TosaToTensor : public impl::TosaToTensorPassBase<TosaToTensor> {
33public:
34 void runOnOperation() override {
35 RewritePatternSet patterns(&getContext());
36 ConversionTarget target(getContext());
37 target.addIllegalOp<tosa::ConcatOp>();
38 target.addIllegalOp<tosa::ReshapeOp>();
39 target.addIllegalOp<tosa::SliceOp>();
40 target.addIllegalOp<tosa::PadOp>();
41 target.addLegalDialect<arith::ArithDialect>();
42 target.addLegalDialect<cf::ControlFlowDialect>();
43 target.addLegalDialect<tensor::TensorDialect>();
44
45 TypeConverter converter;
47
49
50 if (failed(applyPartialConversion(getOperation(), target,
51 std::move(patterns))))
52 signalPassFailure();
53 }
54};
55} // namespace
b getContext())
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:734
void populateTosaTypeConversion(TypeConverter &converter)
void populateTosaToTensorConversionPatterns(const TypeConverter &converter, RewritePatternSet *patterns)
Include the generated interface declarations.