17 #ifndef MLIR_REDUCER_REDUCTIONNODE_H
18 #define MLIR_REDUCER_REDUCTIONNODE_H
26 #include "llvm/ADT/ArrayRef.h"
27 #include "llvm/Support/Allocator.h"
28 #include "llvm/Support/ToolOutputFile.h"
46 template <TraversalMode mode>
49 using Range = std::pair<int, int>;
52 llvm::SpecificBumpPtrAllocator<ReductionNode> &allocator);
86 void update(std::pair<Tester::Interestingness, size_t> result);
103 template <
typename T>
107 BaseIterator(
const BaseIterator &) =
default;
108 BaseIterator() =
default;
110 static BaseIterator end() {
return BaseIterator(); }
113 return visitQueue == i.visitQueue;
115 bool operator!=(
const BaseIterator &i) {
return !(*
this == i); }
121 visitQueue.push(node);
126 BaseIterator tmp = *
this;
132 ReductionNode *operator->()
const {
return visitQueue.front(); }
135 ArrayRef<ReductionNode *> getNeighbors(
ReductionNode *node) {
136 return static_cast<T *
>(
this)->getNeighbors(node);
140 std::queue<ReductionNode *> visitQueue;
145 OwningOpRef<ModuleOp> module;
148 Region *region =
nullptr;
170 std::vector<Range> ranges;
177 const std::vector<Range> startRanges;
181 std::vector<ReductionNode *> variants;
183 llvm::SpecificBumpPtrAllocator<ReductionNode> &allocator;
189 :
public BaseIterator<iterator<SinglePath>> {
190 friend BaseIterator<iterator<SinglePath>>;
191 using BaseIterator::BaseIterator;
OpTy get() const
Allow accessing the internal op.
ReductionTreePass will build a reduction tree during module reduction and the ReductionNode represent...
std::pair< int, int > Range
LogicalResult initialize(ModuleOp parentModule, Region &parentRegion)
Each Reduction Node contains a copy of module for applying rewrite patterns.
ReductionNode(ReductionNode *parent, const std::vector< Range > &range, llvm::SpecificBumpPtrAllocator< ReductionNode > &allocator)
Root node will have the parent pointer point to themselves.
size_t getSize() const
Return the size of the module.
ModuleOp getModule() const
If the ReductionNode hasn't been tested the interestingness, it'll be the same module as the one in t...
Region & getRegion() const
Return the region we're reducing.
Tester::Interestingness isInteresting() const
Returns true if the module exhibits the interesting behavior.
ArrayRef< ReductionNode * > generateNewVariants()
Split the ranges and generate new variants.
ArrayRef< Range > getRanges() const
Return the range set we are using to generate variants.
ArrayRef< ReductionNode * > getVariants() const
Return the generated variants(the child nodes).
ReductionNode * getParent() const
ArrayRef< Range > getStartRanges() const
Return the range information that how this node is reduced from the parent node.
void update(std::pair< Tester::Interestingness, size_t > result)
Update the interestingness result from tester.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
static MappingLevel & operator++(MappingLevel &mappingLevel)
Bounded increment on MappingLevel.
Include the generated interface declarations.
bool operator==(StringAttr lhs, std::nullptr_t)
Define comparisons for StringAttr against nullptr and itself to avoid the StringRef overloads from be...
bool operator!=(RegionBranchPoint lhs, RegionBranchPoint rhs)
AffineExpr operator*(int64_t val, AffineExpr expr)
TraversalMode
Defines the traversal method options to be used in the reduction tree traversal.
This class represents an efficient way to signal success or failure.