xref: /llvm-project/mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (revision 5ce271ef74dd3325993c827f496e460ced41af11)
1 //===-- TosaToLinalg.h - TOSA optimization pass declarations ----------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the passes for the TOSA Linalg Dialect in MLIR.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_CONVERSION_TOSATOLINALG_TOSATOLINALG_H
15 #define MLIR_CONVERSION_TOSATOLINALG_TOSATOLINALG_H
16 
17 #include "mlir/Dialect/Tosa/Transforms/Passes.h"
18 #include "mlir/Pass/Pass.h"
19 
20 namespace mlir {
21 
22 #define GEN_PASS_DECL_TOSATOLINALG
23 #define GEN_PASS_DECL_TOSATOLINALGNAMED
24 #include "mlir/Conversion/Passes.h.inc"
25 
26 namespace tosa {
27 
28 std::unique_ptr<Pass> createTosaToLinalg();
29 std::unique_ptr<Pass> createTosaToLinalgNamed(
30     const TosaToLinalgNamedOptions &options = TosaToLinalgNamedOptions());
31 
32 /// Populates passes to convert from TOSA to Linalg on buffers. At the end of
33 /// the pass, the function will only contain linalg ops or standard ops if the
34 /// pipeline succeeds.  The option to disable decompositions is available for
35 /// benchmarking performance improvements from the canonicalizations.
36 void addTosaToLinalgPasses(
37     OpPassManager &pm, const TosaToLinalgOptions &options,
38     const TosaToLinalgNamedOptions &tosaToLinalgNamedOptions =
39         TosaToLinalgNamedOptions(),
40     // Note: Default to 'none' level unless otherwise specified.
41     std::optional<tosa::TosaValidationOptions> validationOptions =
42         tosa::TosaValidationOptions{
43             {"none"}, false, tosa::TosaLevelEnum::None});
44 
45 /// Populates TOSA to linalg pipelines
46 /// Currently, this includes only the "tosa-to-linalg-pipeline".
47 void registerTosaToLinalgPipelines();
48 
49 /// Populates conversion passes from TOSA dialect to Linalg dialect.
50 void populateTosaToLinalgConversionPatterns(const TypeConverter &converter,
51                                             RewritePatternSet *patterns);
52 
53 /// Populates conversion passes from TOSA dialect to Linalg named operations.
54 void populateTosaToLinalgNamedConversionPatterns(
55     const TypeConverter &converter, RewritePatternSet *patterns,
56     const TosaToLinalgNamedOptions &options);
57 
58 } // namespace tosa
59 } // namespace mlir
60 
61 #endif // MLIR_CONVERSION_TOSATOLINALG_TOSATOLINALG_H
62