MLIR  20.0.0git
Public Member Functions | List of all members
mlir::sparse_tensor::CodegenEnv Class Reference

The code generation environment class aggregates a number of data structures that are needed during the code generation phase of sparsification. More...

#include "Dialect/SparseTensor/Transforms/Utils/CodegenEnv.h"

Public Member Functions

 CodegenEnv (linalg::GenericOp linop, SparsificationOptions opts, unsigned numTensors, unsigned numLoops, unsigned maxRank)
 Constructs a code generation environment which can be passed around during sparsification for bookkeeping together with some consistency asserts. More...
 
LogicalResult initTensorExp ()
 
ExprId getExprId () const
 
linalg::GenericOp op () const
 
const SparsificationOptionsoptions () const
 
bool generatingSparseIterator () const
 
Mergermerger ()
 
LoopEmitteremitter ()
 
void startEmit (SparseEmitStrategy emitStrategy)
 
std::optional< Operation * > genLoopBoundary (function_ref< std::optional< Operation * >(MutableArrayRef< Value > parameters)> callback)
 Generates loop boundary statements (entering/exiting loops). More...
 
constexpr TensorId makeTensorId (unsigned t) const
 
constexpr LoopId makeLoopId (unsigned i) const
 
constexpr TensorLoopId makeTensorLoopId (unsigned t, unsigned i) const
 
const TensorExpexp (ExprId e) const
 
const LatPointlat (LatPointId l) const
 
ArrayRef< LatPointIdset (LatSetId s) const
 
LevelType lt (TensorId t, LoopId i) const
 
LevelType lt (TensorLoopId b) const
 
unsigned getLoopNum () const
 
TensorLevel makeTensorLevel (TensorId t, Level l) const
 
TensorLevel makeTensorLevel (std::pair< TensorId, Level > tlPair) const
 
std::pair< TensorId, LevelunpackTensorLevel (TensorLevel tl) const
 
template<class ContainerTy >
auto unpackTensorLevelRange (ContainerTy &&c) const
 
unsigned getCurrentDepth () const
 
bool isAdmissibleTensorExp (ExprId e)
 Whether the tensor expression is admissible for codegen. More...
 
Value getLoopVar (LoopId i) const
 Returns the induction-variable for the given loop. More...
 
bool hasSparseOutput () const
 
bool isSparseOutput (OpOperand *o) const
 
Value getInsertionChain () const
 
void updateInsertionChain (Value chain)
 
bool atExpandLevel (OpOperand *o, unsigned rank, LoopId n) const
 
void startExpand (Value values, Value filled, Value added, Value count)
 
bool isExpand () const
 
void updateExpandCount (Value count)
 
Value getExpandValues () const
 
Value getExpandFilled () const
 
Value getExpandAdded () const
 
Value getExpandCount () const
 
void endExpand ()
 
void startReduc (ExprId exp, Value val)
 
bool isReduc () const
 
void updateReduc (Value val)
 
Value getReduc () const
 
Value endReduc ()
 
void startValidLexInsert (Value val)
 
bool isValidLexInsert () const
 
void updateValidLexInsert (Value val)
 
Value getValidLexInsert () const
 
void endValidLexInsert ()
 
void startCustomReduc (ExprId exp)
 
bool isCustomReduc () const
 
Value getCustomRedId () const
 
void endCustomReduc ()
 

Detailed Description

The code generation environment class aggregates a number of data structures that are needed during the code generation phase of sparsification.

This environment simplifies passing around such data during sparsification (rather than passing around all the individual compoments where needed). Furthermore, it provides convience methods that keep implementation details transparent to sparsification while asserting on internal consistency.

Definition at line 35 of file CodegenEnv.h.

Constructor & Destructor Documentation

◆ CodegenEnv()

CodegenEnv::CodegenEnv ( linalg::GenericOp  linop,
SparsificationOptions  opts,
unsigned  numTensors,
unsigned  numLoops,
unsigned  maxRank 
)

Constructs a code generation environment which can be passed around during sparsification for bookkeeping together with some consistency asserts.

Definition at line 44 of file CodegenEnv.cpp.

Member Function Documentation

◆ atExpandLevel()

bool CodegenEnv::atExpandLevel ( OpOperand o,
unsigned  rank,
LoopId  n 
) const

Definition at line 200 of file CodegenEnv.cpp.

Referenced by genExpand().

◆ emitter()

LoopEmitter& mlir::sparse_tensor::CodegenEnv::emitter ( )
inline

◆ endCustomReduc()

void CodegenEnv::endCustomReduc ( )

Definition at line 276 of file CodegenEnv.cpp.

References isCustomReduc(), and mlir::sparse_tensor::detail::kInvalidId.

Referenced by genExp(), and genInvariants().

◆ endExpand()

void CodegenEnv::endExpand ( )

Definition at line 219 of file CodegenEnv.cpp.

◆ endReduc()

Value CodegenEnv::endReduc ( )

◆ endValidLexInsert()

void CodegenEnv::endValidLexInsert ( )

Definition at line 261 of file CodegenEnv.cpp.

References isReduc(), and isValidLexInsert().

Referenced by genInvariants().

◆ exp()

const TensorExp& mlir::sparse_tensor::CodegenEnv::exp ( ExprId  e) const
inline

◆ generatingSparseIterator()

bool mlir::sparse_tensor::CodegenEnv::generatingSparseIterator ( ) const
inline

Definition at line 52 of file CodegenEnv.h.

References mlir::kSparseIterator, and mlir::SparsificationOptions::sparseEmitStrategy.

Referenced by genStmt().

◆ genLoopBoundary()

std::optional< Operation * > CodegenEnv::genLoopBoundary ( function_ref< std::optional< Operation * >(MutableArrayRef< Value > parameters)>  callback)

Generates loop boundary statements (entering/exiting loops).

The function passes and updates the passed-in parameters.

Definition at line 103 of file CodegenEnv.cpp.

References isExpand(), isReduc(), and isValidLexInsert().

Referenced by endLoop(), genCoIteration(), and genStmt().

◆ getCurrentDepth()

unsigned mlir::sparse_tensor::CodegenEnv::getCurrentDepth ( ) const
inline

◆ getCustomRedId()

Value CodegenEnv::getCustomRedId ( ) const

Definition at line 271 of file CodegenEnv.cpp.

References exp(), isCustomReduc(), and op().

Referenced by genInsertionLoadReduce(), and genInvariants().

◆ getExpandAdded()

Value mlir::sparse_tensor::CodegenEnv::getExpandAdded ( ) const
inline

Definition at line 144 of file CodegenEnv.h.

Referenced by genInsertionStore().

◆ getExpandCount()

Value mlir::sparse_tensor::CodegenEnv::getExpandCount ( ) const
inline

Definition at line 145 of file CodegenEnv.h.

Referenced by endIf(), finalizeWhileOp(), genInsertionStore(), and genStmt().

◆ getExpandFilled()

Value mlir::sparse_tensor::CodegenEnv::getExpandFilled ( ) const
inline

Definition at line 143 of file CodegenEnv.h.

Referenced by genInsertionLoadReduce(), and genInsertionStore().

◆ getExpandValues()

Value mlir::sparse_tensor::CodegenEnv::getExpandValues ( ) const
inline

Definition at line 142 of file CodegenEnv.h.

Referenced by genInsertionLoad(), genInsertionLoadReduce(), and genInsertionStore().

◆ getExprId()

ExprId mlir::sparse_tensor::CodegenEnv::getExprId ( ) const
inline

Definition at line 48 of file CodegenEnv.h.

◆ getInsertionChain()

Value mlir::sparse_tensor::CodegenEnv::getInsertionChain ( ) const
inline

◆ getLoopNum()

unsigned mlir::sparse_tensor::CodegenEnv::getLoopNum ( ) const
inline

Definition at line 89 of file CodegenEnv.h.

References mlir::sparse_tensor::Merger::getNumLoops().

Referenced by genStmt(), isAdmissibleTensorExp(), and startEmit().

◆ getLoopVar()

Value CodegenEnv::getLoopVar ( LoopId  i) const

Returns the induction-variable for the given loop.

Definition at line 187 of file CodegenEnv.cpp.

References mlir::sparse_tensor::LoopEmitter::getLoopIV().

Referenced by endLoopSeq(), genExp(), genIf(), genIndex(), relinkBranch(), and startLoopSeq().

◆ getReduc()

Value mlir::sparse_tensor::CodegenEnv::getReduc ( ) const
inline

Definition at line 155 of file CodegenEnv.h.

Referenced by endIf(), finalizeWhileOp(), genIf(), and genStmt().

◆ getValidLexInsert()

Value mlir::sparse_tensor::CodegenEnv::getValidLexInsert ( ) const
inline

Definition at line 161 of file CodegenEnv.h.

Referenced by finalizeWhileOp(), genIf(), genInsertionStore(), and genStmt().

◆ hasSparseOutput()

bool mlir::sparse_tensor::CodegenEnv::hasSparseOutput ( ) const
inline

Definition at line 132 of file CodegenEnv.h.

Referenced by genInvariants(), and isParallelFor().

◆ initTensorExp()

LogicalResult CodegenEnv::initTensorExp ( )

◆ isAdmissibleTensorExp()

bool CodegenEnv::isAdmissibleTensorExp ( ExprId  e)

◆ isCustomReduc()

bool mlir::sparse_tensor::CodegenEnv::isCustomReduc ( ) const
inline

◆ isExpand()

bool mlir::sparse_tensor::CodegenEnv::isExpand ( ) const
inline

◆ isReduc()

bool mlir::sparse_tensor::CodegenEnv::isReduc ( ) const
inline

◆ isSparseOutput()

bool mlir::sparse_tensor::CodegenEnv::isSparseOutput ( OpOperand o) const
inline

Definition at line 133 of file CodegenEnv.h.

Referenced by genTensorLoad(), and genTensorStore().

◆ isValidLexInsert()

bool mlir::sparse_tensor::CodegenEnv::isValidLexInsert ( ) const
inline

◆ lat()

const LatPoint& mlir::sparse_tensor::CodegenEnv::lat ( LatPointId  l) const
inline

Definition at line 82 of file CodegenEnv.h.

References mlir::sparse_tensor::Merger::lat().

Referenced by genStmt(), getAllTidLvlsInLatPoints(), and startLoopSeq().

◆ lt() [1/2]

LevelType mlir::sparse_tensor::CodegenEnv::lt ( TensorId  t,
LoopId  i 
) const
inline

◆ lt() [2/2]

LevelType mlir::sparse_tensor::CodegenEnv::lt ( TensorLoopId  b) const
inline

Definition at line 87 of file CodegenEnv.h.

References mlir::sparse_tensor::Merger::getLvlType().

◆ makeLoopId()

constexpr LoopId mlir::sparse_tensor::CodegenEnv::makeLoopId ( unsigned  i) const
inlineconstexpr

Definition at line 75 of file CodegenEnv.h.

References mlir::sparse_tensor::Merger::makeLoopId().

Referenced by genIndex(), and relinkBranch().

◆ makeTensorId()

constexpr TensorId mlir::sparse_tensor::CodegenEnv::makeTensorId ( unsigned  t) const
inlineconstexpr

◆ makeTensorLevel() [1/2]

TensorLevel mlir::sparse_tensor::CodegenEnv::makeTensorLevel ( std::pair< TensorId, Level tlPair) const
inline

Definition at line 104 of file CodegenEnv.h.

References makeTensorLevel().

◆ makeTensorLevel() [2/2]

TensorLevel mlir::sparse_tensor::CodegenEnv::makeTensorLevel ( TensorId  t,
Level  l 
) const
inline

◆ makeTensorLoopId()

constexpr TensorLoopId mlir::sparse_tensor::CodegenEnv::makeTensorLoopId ( unsigned  t,
unsigned  i 
) const
inlineconstexpr

Definition at line 78 of file CodegenEnv.h.

References mlir::sparse_tensor::Merger::makeTensorLoopId().

◆ merger()

Merger& mlir::sparse_tensor::CodegenEnv::merger ( )
inline

◆ op()

linalg::GenericOp mlir::sparse_tensor::CodegenEnv::op ( ) const
inline

◆ options()

const SparsificationOptions& mlir::sparse_tensor::CodegenEnv::options ( ) const
inline

Definition at line 51 of file CodegenEnv.h.

Referenced by genSubscript(), genTensorLoad(), getAllTidLvlsInLatPoints(), and isParallelFor().

◆ set()

ArrayRef<LatPointId> mlir::sparse_tensor::CodegenEnv::set ( LatSetId  s) const
inline

Definition at line 83 of file CodegenEnv.h.

References mlir::sparse_tensor::Merger::set().

Referenced by genStmt(), and startLoopSeq().

◆ startCustomReduc()

void CodegenEnv::startCustomReduc ( ExprId  exp)

Definition at line 266 of file CodegenEnv.cpp.

References exp(), isCustomReduc(), and mlir::sparse_tensor::detail::kInvalidId.

Referenced by genExp(), and genInvariants().

◆ startEmit()

void CodegenEnv::startEmit ( SparseEmitStrategy  emitStrategy)

◆ startExpand()

void CodegenEnv::startExpand ( Value  values,
Value  filled,
Value  added,
Value  count 
)

Definition at line 205 of file CodegenEnv.cpp.

◆ startReduc()

void CodegenEnv::startReduc ( ExprId  exp,
Value  val 
)

◆ startValidLexInsert()

void CodegenEnv::startValidLexInsert ( Value  val)

Definition at line 251 of file CodegenEnv.cpp.

References isReduc(), and isValidLexInsert().

Referenced by genInvariants().

◆ unpackTensorLevel()

std::pair<TensorId, Level> mlir::sparse_tensor::CodegenEnv::unpackTensorLevel ( TensorLevel  tl) const
inline

Definition at line 107 of file CodegenEnv.h.

References mlir::sparse_tensor::LoopEmitter::unpackTensorLevel().

Referenced by shouldTryParallize().

◆ unpackTensorLevelRange()

template<class ContainerTy >
auto mlir::sparse_tensor::CodegenEnv::unpackTensorLevelRange ( ContainerTy &&  c) const
inline

Definition at line 111 of file CodegenEnv.h.

References mlir::sparse_tensor::LoopEmitter::unpackTensorLevelRange().

Referenced by startLoop().

◆ updateExpandCount()

void CodegenEnv::updateExpandCount ( Value  count)

Definition at line 214 of file CodegenEnv.cpp.

Referenced by endIf(), finalizeWhileOp(), and genInsertionStore().

◆ updateInsertionChain()

void CodegenEnv::updateInsertionChain ( Value  chain)

Definition at line 195 of file CodegenEnv.cpp.

Referenced by endIf(), finalizeWhileOp(), genInsertionStore(), and genTensorStore().

◆ updateReduc()

void CodegenEnv::updateReduc ( Value  val)

◆ updateValidLexInsert()

void CodegenEnv::updateValidLexInsert ( Value  val)

Definition at line 256 of file CodegenEnv.cpp.

References isReduc().

Referenced by endIf(), endLoop(), and finalizeWhileOp().


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