22 #define GEN_PASS_DEF_TOSALAYERWISECONSTANTFOLDPASS
23 #include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
32 template <
typename... Args>
34 (Args::getCanonicalizationPatterns(patterns, ctx), ...);
37 void populateTosaOpsCanonicalizationPatterns(
MLIRContext *ctx,
39 addOpsCanonicalizations<
41 #include "mlir/Dialect/Tosa/IR/TosaOps.cpp.inc"
45 struct TosaLayerwiseConstantFoldPass
46 :
public tosa::impl::TosaLayerwiseConstantFoldPassBase<
47 TosaLayerwiseConstantFoldPass> {
48 TosaLayerwiseConstantFoldPass(
49 const TosaLayerwiseConstantFoldPassOptions &
options)
50 : TosaLayerwiseConstantFoldPassBase(
options) {}
52 void runOnOperation()
override {
55 auto func = getOperation();
60 aggressiveReduceConstant);
61 populateTosaOpsCanonicalizationPatterns(ctx, patterns);
71 return std::make_unique<TosaLayerwiseConstantFoldPass>(
72 TosaLayerwiseConstantFoldPassOptions{
false});
76 const TosaLayerwiseConstantFoldPassOptions &
options) {
77 return std::make_unique<TosaLayerwiseConstantFoldPass>(
options);
static MLIRContext * getContext(OpFoldResult val)
static llvm::ManagedStatic< PassManagerOptions > options
MLIRContext is the top-level object for a collection of MLIR operations.
void populateTosaConstantReduction(MLIRContext *ctx, RewritePatternSet &patterns, bool aggressiveReduceConstant)
void populateTosaFoldConstantReciprocalPatterns(MLIRContext *ctx, RewritePatternSet &patterns)
std::unique_ptr< Pass > createTosaLayerwiseConstantFoldPass()
void populateTosaFoldConstantTransposePatterns(MLIRContext *ctx, RewritePatternSet &patterns)
Include the generated interface declarations.
LogicalResult applyPatternsAndFoldGreedily(Region ®ion, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr)
Rewrite ops in the given region, which must be isolated from above, by repeatedly applying the highes...
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.