MLIR 22.0.0git
ReductionTreePass.cpp File Reference
#include "mlir/IR/DialectInterface.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/Support/Allocator.h"
#include "mlir/Reducer/Passes.h.inc"

Go to the source code of this file.

Classes

class  mlir::impl::ReductionTreePassBase< DerivedT >

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::impl
 Attribute collections provide a dictionary-like interface.

Macros

#define GEN_PASS_DEF_REDUCTIONTREEPASS

Functions

std::unique_ptr<::mlir::Passmlir::impl::createReductionTreePass ()
std::unique_ptr<::mlir::Passmlir::impl::createReductionTreePass (ReductionTreePassOptions options)
std::unique_ptr<::mlir::Passmlir::createReductionTreePass ()
std::unique_ptr<::mlir::Passmlir::createReductionTreePass (ReductionTreePassOptions options)
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.
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.
template<typename IteratorType>
static LogicalResult findOptimal (ModuleOp module, Region &region, const FrozenRewritePatternSet &patterns, const Tester &test)

Macro Definition Documentation

◆ GEN_PASS_DEF_REDUCTIONTREEPASS

#define GEN_PASS_DEF_REDUCTIONTREEPASS

Definition at line 29 of file ReductionTreePass.cpp.

Function Documentation

◆ applyPatterns()

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 38 of file ReductionTreePass.cpp.

References mlir::applyOpPatternsGreedily(), mlir::ExistingOps, mlir::Region::getOps(), and mlir::patterns.

Referenced by findOptimal().

◆ findOptimal() [1/2]

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

Definition at line 149 of file ReductionTreePass.cpp.

◆ findOptimal() [2/2]

template<typename IteratorType>
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 84 of file ReductionTreePass.cpp.

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

Referenced by mlir::impl::ReductionTreePassBase< DerivedT >::getPassName().