MLIR  21.0.0git
Passes.h
Go to the documentation of this file.
1 //===-- Passes.h - TOSA optimization pass declarations ----------*- C++ -*-===//
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 file declares the optimization passes for the TOSA Dialect in MLIR.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_TOSA_TRANSFORMS_PASSES_H
14 #define MLIR_DIALECT_TOSA_TRANSFORMS_PASSES_H
15 
17 #include "mlir/Dialect/Tosa/Transforms/PassesEnums.h.inc"
18 #include "mlir/Pass/Pass.h"
19 
20 namespace mlir {
21 class TypeConverter;
22 namespace tosa {
23 
24 #define GEN_PASS_DECL
25 #include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
26 
27 // Expose Rewrite Functions that decompose TOSA Ops into further TOSA Ops.
28 // The rewrites can be selectively added to a conversion pass.
29 void populateTosaDecomposeTransposeConv(MLIRContext *ctx,
30  RewritePatternSet &patterns);
31 void populateTosaDecomposeDepthwise(MLIRContext *ctx,
32  RewritePatternSet &patterns);
33 void populateTosaFoldConstantReciprocalPatterns(MLIRContext *ctx,
34  RewritePatternSet &patterns);
35 void populateTosaFoldConstantTransposePatterns(MLIRContext *ctx,
36  RewritePatternSet &patterns);
37 void populateTosaConstantReduction(MLIRContext *ctx,
38  RewritePatternSet &patterns,
39  bool aggressiveReduceConstant);
40 
41 void populateTosaTypeConversion(TypeConverter &converter);
42 
43 std::unique_ptr<Pass> createTosaLayerwiseConstantFoldPass();
44 std::unique_ptr<Pass> createTosaLayerwiseConstantFoldPass(
45  const TosaLayerwiseConstantFoldPassOptions &options);
46 std::unique_ptr<Pass> createTosaInferShapesPass();
47 std::unique_ptr<Pass> createTosaMakeBroadcastablePass();
48 std::unique_ptr<Pass> createTosaTestQuantUtilAPIPass();
49 std::unique_ptr<Pass> createTosaOptionalDecompositions();
50 
52  /// Validate if operations match for the given profile.
53  TosaProfileEnum profile = TosaProfileEnum::Undefined;
54  ValidationOptions &setProfile(TosaProfileEnum profile) {
55  this->profile = profile;
56  return *this;
57  }
58  /// Verify if the properties of certain operations align the spec requirement.
62  return *this;
63  }
64  /// Validate if operator parameters are within specfication for the given
65  /// level.
66  TosaLevelEnum level = TosaLevelEnum::EightK;
67  ValidationOptions &setLevel(TosaLevelEnum level) {
68  this->level = level;
69  return *this;
70  }
71 };
72 
73 #define GEN_PASS_REGISTRATION
74 #include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
75 
76 } // namespace tosa
77 } // namespace mlir
78 
79 #endif // MLIR_DIALECT_TOSA_TRANSFORMS_PASSES_H
static llvm::ManagedStatic< PassManagerOptions > options
std::unique_ptr< Pass > createTosaMakeBroadcastablePass()
void populateTosaDecomposeDepthwise(MLIRContext *ctx, RewritePatternSet &patterns)
std::unique_ptr< Pass > createTosaTestQuantUtilAPIPass()
void populateTosaConstantReduction(MLIRContext *ctx, RewritePatternSet &patterns, bool aggressiveReduceConstant)
std::unique_ptr< Pass > createTosaOptionalDecompositions()
void populateTosaFoldConstantReciprocalPatterns(MLIRContext *ctx, RewritePatternSet &patterns)
void populateTosaTypeConversion(TypeConverter &converter)
void populateTosaDecomposeTransposeConv(MLIRContext *ctx, RewritePatternSet &patterns)
std::unique_ptr< Pass > createTosaLayerwiseConstantFoldPass()
std::unique_ptr< Pass > createTosaInferShapesPass()
void populateTosaFoldConstantTransposePatterns(MLIRContext *ctx, RewritePatternSet &patterns)
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns
ValidationOptions & setProfile(TosaProfileEnum profile)
Definition: Passes.h:54
TosaLevelEnum level
Validate if operator parameters are within specfication for the given level.
Definition: Passes.h:66
bool strictOperationSpecAlignment
Verify if the properties of certain operations align the spec requirement.
Definition: Passes.h:59
ValidationOptions & setLevel(TosaLevelEnum level)
Definition: Passes.h:67
TosaProfileEnum profile
Validate if operations match for the given profile.
Definition: Passes.h:53
ValidationOptions & enableStrictOperationSpecAlignment(bool enable=true)
Definition: Passes.h:60