MLIR 22.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
21
22namespace mlir {
23#define GEN_PASS_DEF_TOSATOTENSORPASS
24#include "mlir/Conversion/Passes.h.inc"
25} // namespace mlir
26
27using namespace mlir;
28using namespace tosa;
29
30namespace {
31struct TosaToTensor : public impl::TosaToTensorPassBase<TosaToTensor> {
32public:
33 void runOnOperation() override {
34 RewritePatternSet patterns(&getContext());
35 ConversionTarget target(getContext());
36 target.addIllegalOp<tosa::ConcatOp>();
37 target.addIllegalOp<tosa::ReshapeOp>();
38 target.addIllegalOp<tosa::SliceOp>();
39 target.addIllegalOp<tosa::PadOp>();
40 target.addLegalDialect<arith::ArithDialect>();
41 target.addLegalDialect<tensor::TensorDialect>();
42
43 TypeConverter converter;
45
47
48 if (failed(applyPartialConversion(getOperation(), target,
49 std::move(patterns))))
50 signalPassFailure();
51 }
52};
53} // namespace
b getContext())
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:561
void populateTosaTypeConversion(TypeConverter &converter)
void populateTosaToTensorConversionPatterns(const TypeConverter &converter, RewritePatternSet *patterns)
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns