MLIR  15.0.0git
Functions
ReductionTreePass.cpp File Reference
#include "mlir/IR/DialectInterface.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Reducer/PassDetail.h"
#include "mlir/Reducer/Passes.h"
#include "mlir/Reducer/ReductionNode.h"
#include "mlir/Reducer/ReductionPatternInterface.h"
#include "mlir/Reducer/Tester.h"
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/ManagedStatic.h"
+ Include dependency graph for ReductionTreePass.cpp:

Go to the source code of this file.

Functions

static void applyPatterns (Region &region, const FrozenRewritePatternSet &patterns, ArrayRef< ReductionNode::Range > rangeToKeep, bool eraseOpNotInRange)
 We implicitly number each operation in the region and if an operation's number falls into rangeToKeep, we need to keep it and apply the given rewrite patterns on it. More...
 
template<typename IteratorType >
static LogicalResult findOptimal (ModuleOp module, Region &region, const FrozenRewritePatternSet &patterns, const Tester &test, bool eraseOpNotInRange)
 We will apply the reducer patterns to the operations in the ranges specified by ReductionNode. More...
 
template<typename IteratorType >
static LogicalResult findOptimal (ModuleOp module, Region &region, const FrozenRewritePatternSet &patterns, const Tester &test)
 

Function Documentation

◆ applyPatterns()

static void applyPatterns ( Region region,
const FrozenRewritePatternSet patterns,
ArrayRef< ReductionNode::Range rangeToKeep,
bool  eraseOpNotInRange 
)
static

We implicitly number each operation in the region and if an operation's number falls into rangeToKeep, we need to keep it and apply the given rewrite patterns on it.

Definition at line 37 of file ReductionTreePass.cpp.

References mlir::applyOpPatternsAndFold(), mlir::detail::enumerate(), and mlir::Region::getOps().

Referenced by findOptimal().

◆ findOptimal() [1/2]

template<typename IteratorType >
static LogicalResult findOptimal ( ModuleOp  module,
Region region,
const FrozenRewritePatternSet patterns,
const Tester test,
bool  eraseOpNotInRange 
)
static

We will apply the reducer patterns to the operations in the ranges specified by ReductionNode.

Note that we are not able to remove an operation without replacing it with another valid operation. However, The validity of module reduction is based on the Tester provided by the user and that means certain invalid module is still interested by the use. Thus we provide an alternative way to remove operations, which is using eraseOpNotInRange to erase the operations not in the range specified by ReductionNode.

Definition at line 79 of file ReductionTreePass.cpp.

References applyPatterns(), mlir::failed(), mlir::ReductionNode::getModule(), mlir::ReductionNode::getParent(), mlir::ReductionNode::getRanges(), mlir::ReductionNode::getRegion(), mlir::ReductionNode::getSize(), mlir::ReductionNode::getStartRanges(), mlir::Tester::isInteresting(), mlir::ReductionNode::isInteresting(), mlir::Region::op_begin(), mlir::Region::op_end(), mlir::success(), mlir::Tester::True, and mlir::ReductionNode::update().

◆ findOptimal() [2/2]

template<typename IteratorType >
static LogicalResult findOptimal ( ModuleOp  module,
Region region,
const FrozenRewritePatternSet patterns,
const Tester test 
)
static