MLIR 23.0.0git
mlir::GreedyRewriteConfig Class Reference

This class allows control over how the GreedyPatternRewriteDriver works. More...

#include "mlir/Transforms/GreedyPatternRewriteDriver.h"

Public Member Functions

bool getUseTopDownTraversal () const
 This specifies the order of initial traversal that populates the rewriters worklist.
GreedyRewriteConfigsetUseTopDownTraversal (bool use=true)
GreedySimplifyRegionLevel getRegionSimplificationLevel () const
 Perform control flow optimizations to the region tree after applying all patterns.
GreedyRewriteConfigsetRegionSimplificationLevel (GreedySimplifyRegionLevel level)
int64_t getMaxIterations () const
 This specifies the maximum number of times the rewriter will iterate between applying patterns and simplifying regions.
GreedyRewriteConfigsetMaxIterations (int64_t iterations)
int64_t getMaxNumRewrites () const
 This specifies the maximum number of rewrites within an iteration.
GreedyRewriteConfigsetMaxNumRewrites (int64_t limit)
RegiongetScope () const
 Only ops within the scope are added to the worklist.
GreedyRewriteConfigsetScope (Region *scope)
GreedyRewriteStrictness getStrictness () const
 Strict mode can restrict the ops that are added to the worklist during the rewrite.
GreedyRewriteConfigsetStrictness (GreedyRewriteStrictness mode)
RewriterBase::ListenergetListener () const
 An optional listener that should be notified about IR modifications.
GreedyRewriteConfigsetListener (RewriterBase::Listener *listener)
bool isFoldingEnabled () const
 Whether this should fold while greedily rewriting.
GreedyRewriteConfigenableFolding (bool enable=true)
bool isConstantCSEEnabled () const
 If set to "true", constants are CSE'd (even across multiple regions that are in a parent-ancestor relationship).
GreedyRewriteConfigenableConstantCSE (bool enable=true)
bool isCSEBetweenIterationsEnabled () const
 If set to "true", full common-subexpression elimination is run on the scoped region between each pattern-application iteration.
GreedyRewriteConfigenableCSEBetweenIterations (bool enable=true)

Static Public Attributes

static constexpr int64_t kNoLimit = -1

Detailed Description

This class allows control over how the GreedyPatternRewriteDriver works.

Definition at line 43 of file GreedyPatternRewriteDriver.h.

Member Function Documentation

◆ enableConstantCSE()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::enableConstantCSE ( bool enable = true)
inline

◆ enableCSEBetweenIterations()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::enableCSEBetweenIterations ( bool enable = true)
inline

Definition at line 159 of file GreedyPatternRewriteDriver.h.

◆ enableFolding()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::enableFolding ( bool enable = true)
inline

◆ getListener()

RewriterBase::Listener * mlir::GreedyRewriteConfig::getListener ( ) const
inline

An optional listener that should be notified about IR modifications.

Definition at line 120 of file GreedyPatternRewriteDriver.h.

◆ getMaxIterations()

int64_t mlir::GreedyRewriteConfig::getMaxIterations ( ) const
inline

This specifies the maximum number of times the rewriter will iterate between applying patterns and simplifying regions.

Use kNoLimit to disable this iteration limit.

Note: Only applicable when simplifying entire regions.

Definition at line 76 of file GreedyPatternRewriteDriver.h.

Referenced by mlir::applyPatternsGreedily(), and mlirGreedyRewriteDriverConfigGetMaxIterations().

◆ getMaxNumRewrites()

int64_t mlir::GreedyRewriteConfig::getMaxNumRewrites ( ) const
inline

This specifies the maximum number of rewrites within an iteration.

Use kNoLimit to disable this limit.

Definition at line 84 of file GreedyPatternRewriteDriver.h.

Referenced by mlir::applyOpPatternsGreedily(), and mlirGreedyRewriteDriverConfigGetMaxNumRewrites().

◆ getRegionSimplificationLevel()

GreedySimplifyRegionLevel mlir::GreedyRewriteConfig::getRegionSimplificationLevel ( ) const
inline

Perform control flow optimizations to the region tree after applying all patterns.

Note: Only applicable when simplifying entire regions.

Definition at line 62 of file GreedyPatternRewriteDriver.h.

Referenced by mlirGreedyRewriteDriverConfigGetRegionSimplificationLevel().

◆ getScope()

Region * mlir::GreedyRewriteConfig::getScope ( ) const
inline

Only ops within the scope are added to the worklist.

If no scope is specified, the closest enclosing region around the initial list of ops (or the specified region, depending on which greedy rewrite entry point is used) is used as a scope. Any region being simplified must be enclosed by the scope (or equal to it).

Definition at line 97 of file GreedyPatternRewriteDriver.h.

Referenced by mlir::applyOpPatternsGreedily(), and mlir::applyPatternsGreedily().

◆ getStrictness()

GreedyRewriteStrictness mlir::GreedyRewriteConfig::getStrictness ( ) const
inline

Strict mode can restrict the ops that are added to the worklist during the rewrite.

Definition at line 113 of file GreedyPatternRewriteDriver.h.

Referenced by mlirGreedyRewriteDriverConfigGetStrictness().

◆ getUseTopDownTraversal()

bool mlir::GreedyRewriteConfig::getUseTopDownTraversal ( ) const
inline

This specifies the order of initial traversal that populates the rewriters worklist.

When set to true, it walks the operations top-down, which is generally more efficient in compile time. When set to false, its initial traversal of the region tree is bottom up on each block, which may match larger patterns when given an ambiguous pattern set.

Note: Only applicable when simplifying entire regions.

Definition at line 52 of file GreedyPatternRewriteDriver.h.

Referenced by mlirGreedyRewriteDriverConfigGetUseTopDownTraversal().

◆ isConstantCSEEnabled()

bool mlir::GreedyRewriteConfig::isConstantCSEEnabled ( ) const
inline

If set to "true", constants are CSE'd (even across multiple regions that are in a parent-ancestor relationship).

Definition at line 135 of file GreedyPatternRewriteDriver.h.

Referenced by mlirGreedyRewriteDriverConfigIsConstantCSEEnabled().

◆ isCSEBetweenIterationsEnabled()

bool mlir::GreedyRewriteConfig::isCSEBetweenIterationsEnabled ( ) const
inline

If set to "true", full common-subexpression elimination is run on the scoped region between each pattern-application iteration.

Unlike cseConstants (which only deduplicates constant ops via the operation folder) this runs the standard CSE algorithm and can unblock further canonicalizations on the next iteration. Off by default because it rebuilds dominance info each iteration.

Caveats when enabling this option:

  • Any listener attached via setListener will be notified of notifyOperationReplaced / notifyOperationErased events generated by CSE. Pattern authors relying on operation identity (e.g., the transform dialect's handle tracking) must account for this.
  • CSE-driven changes feed back into the iteration loop: a pattern that re-materializes duplicates that CSE keeps collapsing can extend the iteration count and, in the worst case, hit maxIterations. Under testConvergence=true such pipelines will be reported as non-convergent.

Definition at line 158 of file GreedyPatternRewriteDriver.h.

◆ isFoldingEnabled()

bool mlir::GreedyRewriteConfig::isFoldingEnabled ( ) const
inline

Whether this should fold while greedily rewriting.

Definition at line 127 of file GreedyPatternRewriteDriver.h.

Referenced by mlirGreedyRewriteDriverConfigIsFoldingEnabled().

◆ setListener()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::setListener ( RewriterBase::Listener * listener)
inline

Definition at line 121 of file GreedyPatternRewriteDriver.h.

◆ setMaxIterations()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::setMaxIterations ( int64_t iterations)
inline

◆ setMaxNumRewrites()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::setMaxNumRewrites ( int64_t limit)
inline

◆ setRegionSimplificationLevel()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::setRegionSimplificationLevel ( GreedySimplifyRegionLevel level)
inline

◆ setScope()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::setScope ( Region * scope)
inline

◆ setStrictness()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::setStrictness ( GreedyRewriteStrictness mode)
inline

◆ setUseTopDownTraversal()

GreedyRewriteConfig & mlir::GreedyRewriteConfig::setUseTopDownTraversal ( bool use = true)
inline

Member Data Documentation

◆ kNoLimit

int64_t mlir::GreedyRewriteConfig::kNoLimit = -1
staticconstexpr

Definition at line 90 of file GreedyPatternRewriteDriver.h.


The documentation for this class was generated from the following file: