MLIR  19.0.0git
Public Member Functions | Public Attributes | List of all members
mlir::affine::ComputationSliceState Struct Reference

ComputationSliceState aggregates loop IVs, loop bound AffineMaps and their associated operands for a set of loops within a loop nest (typically the set of loops surrounding a store operation). More...

#include "mlir/Dialect/Affine/Analysis/Utils.h"

Public Member Functions

LogicalResult getAsConstraints (FlatAffineValueConstraints *cst) const
 
LogicalResult getSourceAsConstraints (FlatAffineValueConstraints &cst) const
 Adds to 'cst' constraints which represent the original loop bounds on 'ivs' in 'this'. More...
 
void clearBounds ()
 
bool isEmpty () const
 Returns true if the computation slice is empty. More...
 
std::optional< bool > isMaximal () const
 Returns true if the computation slice encloses all the iterations of the sliced loop nest. More...
 
std::optional< bool > isSliceValid () const
 Checks the validity of the slice computed. More...
 
void dump () const
 

Public Attributes

SmallVector< Value, 4 > ivs
 
SmallVector< AffineMap, 4 > lbs
 
SmallVector< AffineMap, 4 > ubs
 
std::vector< SmallVector< Value, 4 > > lbOperands
 
std::vector< SmallVector< Value, 4 > > ubOperands
 
Block::iterator insertPoint
 

Detailed Description

ComputationSliceState aggregates loop IVs, loop bound AffineMaps and their associated operands for a set of loops within a loop nest (typically the set of loops surrounding a store operation).

Loop bound AffineMaps which are non-null represent slices of that loop's iteration space.

Definition at line 259 of file Utils.h.

Member Function Documentation

◆ clearBounds()

void ComputationSliceState::clearBounds ( )

Definition at line 716 of file Utils.cpp.

Referenced by mlir::affine::computeSliceUnion().

◆ dump()

void ComputationSliceState::dump ( ) const

Definition at line 723 of file Utils.cpp.

References mlir::detail::enumerate().

◆ getAsConstraints()

LogicalResult ComputationSliceState::getAsConstraints ( FlatAffineValueConstraints cst) const

◆ getSourceAsConstraints()

LogicalResult ComputationSliceState::getSourceAsConstraints ( FlatAffineValueConstraints cst) const

Adds to 'cst' constraints which represent the original loop bounds on 'ivs' in 'this'.

This corresponds to the original domain of the loop nest from which the slice is being computed. Returns failure if we cannot add loop bounds because of unsupported cases.

Definition at line 664 of file Utils.cpp.

References mlir::affine::FlatAffineValueConstraints::addAffineForOpDomain(), mlir::failed(), mlir::failure(), mlir::affine::getForInductionVarOwner(), and mlir::success().

◆ isEmpty()

bool mlir::affine::ComputationSliceState::isEmpty ( ) const
inline

Returns true if the computation slice is empty.

Definition at line 291 of file Utils.h.

References ivs.

Referenced by isFusionProfitable().

◆ isMaximal()

std::optional< bool > ComputationSliceState::isMaximal ( ) const

Returns true if the computation slice encloses all the iterations of the sliced loop nest.

Returns false if it does not. Returns std::nullopt if it cannot determine if the slice is maximal or not.

Definition at line 888 of file Utils.cpp.

References mlir::affine::FlatAffineValueConstraints::addAffineForOpDomain(), mlir::affine::FlatAffineValueConstraints::addDomainFromSliceMaps(), mlir::failed(), mlir::affine::getForInductionVarOwner(), mlir::presburger::IntegerRelation::getNumDimVars(), mlir::presburger::PresburgerRelation::isIntegerEmpty(), and mlir::presburger::PresburgerSet::subtract().

Referenced by canRemoveSrcNodeAfterFusion(), and mlir::affine::getComputationSliceState().

◆ isSliceValid()

std::optional< bool > ComputationSliceState::isSliceValid ( ) const

Checks the validity of the slice computed.

Returns true if it is deterministically verified that the original iteration space of the slice is contained within the new iteration space that is created after fusing 'this' slice into its destination.

This is done using the following steps:

  1. Get the new domain of the slice that would be created if fusion succeeds. This domain gets constructed with source loop IVS and destination loop IVS as dimensions.
  2. Project out the dimensions of the destination loop from the domain above calculated in step(1) to express it purely in terms of the source loop IVs.
  3. Calculate a set difference between the iterations of the new domain and the original domain of the source loop. If this difference is empty, the slice is declared to be valid. Otherwise, return false as it implies that the effective fusion results in at least one iteration of the slice that was not originally in the source's domain. If the validity cannot be determined, returns std::nullopt.

Definition at line 818 of file Utils.cpp.

References mlir::presburger::IntegerRelation::dump(), mlir::failed(), mlir::presburger::IntegerRelation::getNumLocalVars(), mlir::presburger::IntegerRelation::getNumSymbolVars(), mlir::presburger::IntegerRelation::getNumVars(), mlir::presburger::PresburgerRelation::isIntegerEmpty(), mlir::FlatLinearValueConstraints::projectOut(), and mlir::presburger::PresburgerSet::subtract().

Referenced by mlir::affine::computeSliceUnion().

Member Data Documentation

◆ insertPoint

Block::iterator mlir::affine::ComputationSliceState::insertPoint

◆ ivs

SmallVector<Value, 4> mlir::affine::ComputationSliceState::ivs

◆ lbOperands

std::vector<SmallVector<Value, 4> > mlir::affine::ComputationSliceState::lbOperands

◆ lbs

SmallVector<AffineMap, 4> mlir::affine::ComputationSliceState::lbs

◆ ubOperands

std::vector<SmallVector<Value, 4> > mlir::affine::ComputationSliceState::ubOperands

◆ ubs

SmallVector<AffineMap, 4> mlir::affine::ComputationSliceState::ubs

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