MLIR
20.0.0git
|
This class represents a piece-wise MultiAffineFunction. More...
#include "mlir/Analysis/Presburger/PWMAFunction.h"
Classes | |
struct | Piece |
Public Member Functions | |
PWMAFunction (const PresburgerSpace &space) | |
const PresburgerSpace & | getSpace () const |
void | addPiece (const Piece &piece) |
unsigned | getNumPieces () const |
unsigned | getNumVarKind (VarKind kind) const |
unsigned | getNumDomainVars () const |
unsigned | getNumOutputs () const |
unsigned | getNumSymbolVars () const |
void | removeOutputs (unsigned start, unsigned end) |
Remove the specified range of outputs. More... | |
PresburgerSpace | getDomainSpace () const |
Get the domain/output space of the function. More... | |
PresburgerSpace | getOutputSpace () const |
PresburgerSet | getDomain () const |
Return the domain of this piece-wise MultiAffineFunction. More... | |
std::optional< SmallVector< DynamicAPInt, 8 > > | valueAt (ArrayRef< DynamicAPInt > point) const |
Return the output of the function at the given point. More... | |
std::optional< SmallVector< DynamicAPInt, 8 > > | valueAt (ArrayRef< int64_t > point) const |
ArrayRef< Piece > | getAllPieces () const |
Return all the pieces of this piece-wise function. More... | |
bool | isEqual (const PWMAFunction &other) const |
Return whether this and other are equal as PWMAFunctions, i.e. More... | |
PWMAFunction | unionLexMin (const PWMAFunction &func) |
Return a function defined on the union of the domains of this and func, such that when only one of the functions is defined, it outputs the same as that function, and if both are defined, it outputs the lexmax/lexmin of the two outputs. More... | |
PWMAFunction | unionLexMax (const PWMAFunction &func) |
void | print (raw_ostream &os) const |
void | dump () const |
This class represents a piece-wise MultiAffineFunction.
This can be thought of as a list of MultiAffineFunction with disjoint domains, with each having their own affine expressions for their output tuples. For example, we could have a function with two input variables (x, y), defined as
f(x, y) = (2*x + y, y - 4) if x >= 0, y >= 0 = (-2*x + y, y + 4) if x < 0, y < 0 = (4, 1) if x < 0, y >= 0
Note that the domains all have to be disjoint. Otherwise, the behaviour of this class is undefined. The domains need not cover all possible points; this represents a partial function and so could be undefined at some points.
As in PresburgerSets, the input vars are partitioned into dimension vars and symbolic vars.
Support is provided to compare equality of two such functions as well as finding the value of the function at a point.
Definition at line 153 of file PWMAFunction.h.
|
inline |
Definition at line 164 of file PWMAFunction.h.
References mlir::presburger::PresburgerSpace::getNumLocalVars().
void PWMAFunction::addPiece | ( | const Piece & | piece | ) |
Definition at line 296 of file PWMAFunction.cpp.
References mlir::presburger::PWMAFunction::Piece::domain, getDomain(), mlir::presburger::PresburgerSet::intersect(), and mlir::presburger::PWMAFunction::Piece::isConsistent().
void PWMAFunction::dump | ( | ) | const |
Definition at line 314 of file PWMAFunction.cpp.
References print().
Return all the pieces of this piece-wise function.
Definition at line 204 of file PWMAFunction.h.
Referenced by mlir::presburger::IntegerRelation::findSymbolicIntegerLexMax().
PresburgerSet PWMAFunction::getDomain | ( | ) | const |
Return the domain of this piece-wise MultiAffineFunction.
This is the union of the domains of all the pieces.
Definition at line 53 of file PWMAFunction.cpp.
References getDomainSpace(), mlir::presburger::PresburgerSet::getEmpty(), and mlir::presburger::PresburgerRelation::unionInPlace().
Referenced by addPiece(), mlir::presburger::IntegerRelation::computeReprWithOnlyDivLocals(), and isEqual().
|
inline |
Get the domain/output space of the function.
The returned space is a set space.
Definition at line 188 of file PWMAFunction.h.
References mlir::presburger::PresburgerSpace::getDomainSpace().
Referenced by getDomain().
|
inline |
Definition at line 179 of file PWMAFunction.h.
References mlir::presburger::PresburgerSpace::getNumDomainVars().
Referenced by valueAt().
|
inline |
Definition at line 180 of file PWMAFunction.h.
References mlir::presburger::PresburgerSpace::getNumRangeVars().
Referenced by mlir::presburger::IntegerRelation::findSymbolicIntegerLexMin().
|
inline |
Definition at line 175 of file PWMAFunction.h.
Referenced by print().
|
inline |
Definition at line 181 of file PWMAFunction.h.
References mlir::presburger::PresburgerSpace::getNumSymbolVars().
Referenced by valueAt().
|
inline |
Definition at line 176 of file PWMAFunction.h.
References mlir::presburger::PresburgerSpace::getNumVarKind().
|
inline |
Definition at line 189 of file PWMAFunction.h.
References mlir::presburger::PresburgerSpace::getDomainSpace().
|
inline |
Definition at line 170 of file PWMAFunction.h.
Referenced by mlir::presburger::IntegerRelation::findSymbolicIntegerLexMax().
bool PWMAFunction::isEqual | ( | const PWMAFunction & | other | ) | const |
Return whether this
and other
are equal as PWMAFunctions, i.e.
Two PWMAFunctions are equal if they have the same dimensionalities, the same domain, and take the same value at every point in the domain.
whether they have the same dimensions, the same domain and they take the same value at every point in the domain.
Definition at line 277 of file PWMAFunction.cpp.
References getDomain(), and mlir::presburger::PresburgerSpace::isCompatible().
void PWMAFunction::print | ( | raw_ostream & | os | ) | const |
Definition at line 303 of file PWMAFunction.cpp.
References getNumPieces(), and mlir::presburger::PresburgerSpace::print().
Referenced by dump().
void PWMAFunction::removeOutputs | ( | unsigned | start, |
unsigned | end | ||
) |
Remove the specified range of outputs.
Definition at line 461 of file PWMAFunction.cpp.
References mlir::presburger::Range, and mlir::presburger::PresburgerSpace::removeVarRange().
Referenced by mlir::presburger::IntegerRelation::findSymbolicIntegerLexMin().
PWMAFunction PWMAFunction::unionLexMax | ( | const PWMAFunction & | func | ) |
Definition at line 383 of file PWMAFunction.cpp.
Referenced by findSymbolicIntegerLexOpt().
PWMAFunction PWMAFunction::unionLexMin | ( | const PWMAFunction & | func | ) |
Return a function defined on the union of the domains of this and func, such that when only one of the functions is defined, it outputs the same as that function, and if both are defined, it outputs the lexmax/lexmin of the two outputs.
On points where neither function is defined, the returned function is not defined either.
Currently this does not support PWMAFunctions which have pieces containing divisions. TODO: Support division in pieces.
Definition at line 379 of file PWMAFunction.cpp.
Referenced by findSymbolicIntegerLexOpt().
std::optional< SmallVector< DynamicAPInt, 8 > > PWMAFunction::valueAt | ( | ArrayRef< DynamicAPInt > | point | ) | const |
Return the output of the function at the given point.
Definition at line 468 of file PWMAFunction.cpp.
References getNumDomainVars(), and getNumSymbolVars().
Referenced by valueAt().
|
inline |
Definition at line 199 of file PWMAFunction.h.
References mlir::presburger::getDynamicAPIntVec(), and valueAt().