Skip to content

Commit

Permalink
Running cleanup before -iree-stream-optimization-pipeline. (#8156)
Browse files Browse the repository at this point in the history
Turns out that if you write passes that rely on canonicalization and CSE
it really helps if you actually run them.
  • Loading branch information
benvanik authored Jan 21, 2022
1 parent 7dd6719 commit 11056ea
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions iree/compiler/Dialect/Stream/Transforms/Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,15 @@ void buildStreamCmdPassPipeline(OpPassManager &passManager,

void buildStreamOptimizationPassPipeline(
OpPassManager &passManager, const TransformOptions &transformOptions) {
// Forming streams involves a fair amount of subgraph stitching, which can
// cause duplication. Run CSE to collapse.
addCleanupPatterns(passManager);

//----------------------------------------------------------------------------
// Binding optimization
//----------------------------------------------------------------------------

if (transformOptions.optimizeBindings) {
// Canonicalizer needs to run so that we have predictable inputs for fusion.
passManager.addPass(mlir::createCanonicalizerPass());
passManager.addPass(IREE::Stream::createFuseDispatchBindingsPass());

// Folding operands requires that CSE folds the inputs that we check for.
Expand Down Expand Up @@ -284,8 +286,7 @@ void buildStreamTransformPassPipeline(
// Post-pipeline cleanup
//----------------------------------------------------------------------------

// Forming streams involves a fair amount of subgraph stitching, which can
// cause duplication. Run CSE to collapse.
// Final cleanup after we optimize dispatches and fuse operands and bindings.
addCleanupPatterns(passManager);

// Symbol DCE any remaining variables/functions that are now no longer
Expand Down

0 comments on commit 11056ea

Please sign in to comment.