24#ifndef TVM_SYM_INT_SET_H_
25#define TVM_SYM_INT_SET_H_
30#include <unordered_map>
63class IntSet :
public ffi::ObjectRef {
70 ffi::Optional<Range>
CoverRange(ffi::Optional<Range> max_range)
const;
173ffi::Map<Var, IntSet>
ConvertDomMap(
const std::unordered_map<const VarNode*, IntSet>& dom_map);
216ffi::Array<IntSet>
EvalSet(
const ffi::Array<Range>& region,
const ffi::Map<Var, IntSet>& dom_map);
218using ExprIntSetMap = std::unordered_map<PrimExpr, IntSet, ffi::ObjectPtrHash, ffi::ObjectPtrEqual>;
228 const std::unordered_map<const VarNode*, IntSet>& dom_map);
242ffi::Array<IntSet>
UnionRegion(
const ffi::Array<ffi::Array<IntSet>>& nd_int_sets);
279ffi::Map<Var, sym::IntSet>
AsIntSet(
const ffi::Map<Var, Range>& var_dom);
292 const ffi::Array<Range>& region,
const ffi::Map<Var, Range>& var_dom,
const PrimExpr& predicate,
306 const ffi::Array<Range>& region,
const ffi::Map<Var, Range>& var_dom,
const PrimExpr& predicate,
320 const ffi::Map<Var, Range>& var_dom,
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Range container
Definition expr.h:1025
Managed reference to AnalyzerObj.
Definition analyzer.h:916
Base class of all Integer set containers. represent a set of integers in one dimension.
Definition int_set.h:54
TVM_FFI_DECLARE_OBJECT_INFO("ir.IntSet", IntSetObj, ffi::Object)
Managed reference to IntSetObj.
Definition int_set.h:63
static IntSet FromRange(tvm::Range r)
Construct a set representing a range.
bool CanProveNonPositive() const
PrimExpr PointValue() const
The single point value, call only if IsSinglePoint is true.
bool CanProveSinglePoint(const Analyzer &ana) const
Check if we can prove it is a single point.
ffi::Optional< Range > CoverRange(ffi::Optional< Range > max_range) const
Find a range that covers the region.
bool HasUpperBound() const
SignType GetSignType() const
bool CanProveNegative() const
static IntSet SinglePoint(PrimExpr point)
construct a point set.
static IntSet Interval(PrimExpr min, PrimExpr max)
Construct a set representing a interval.
bool CanProvePositive() const
bool HasLowerBound() const
bool MatchRange(const tvm::Range &r) const
Try to match IntSet with range r.
bool IsEverything() const
static IntSet Vector(PrimExpr vec)
construct a integer set from vector expression.
bool IsSinglePoint() const
static IntSet FromMinExtent(PrimExpr min, PrimExpr extent)
Construct a set representing a range [min, min + extent).
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IntSet, ffi::ObjectRef, IntSetObj)
bool CanProveNonNegative() const
static IntSet Everything()
TVM_TIRX_DLL ffi::Optional< ffi::Array< IntSet > > EstimateRegionLowerBound(const ffi::Array< Range > ®ion, const ffi::Map< Var, Range > &var_dom, const PrimExpr &predicate, const sym::Analyzer &analyzer)
Analyze the region with affine map, given the domain of variables and their predicate....
SignType
Sign type of an integer expression.
Definition int_set.h:47
@ kUnknown
Definition int_set.h:47
@ kZero
Definition int_set.h:47
@ kPositive
Definition int_set.h:47
@ kNegative
Definition int_set.h:47
ffi::Map< Var, IntSet > ConvertDomMap(const std::unordered_map< const VarNode *, IntSet > &dom_map)
Convert std::unordered_map<const VarNode*, IntSet> to ffi::Map<Var, IntSet>
IntSet Intersect(const ffi::Array< IntSet > &sets)
Create an intersected set of all sets.
IntSet Union(const ffi::Array< IntSet > &sets)
Create a union set of all sets, possibly relaxed.
IntSet UnionLowerBound(const ffi::Array< IntSet > &sets)
Create a lower-bound of union set, where some of the segments may be dropped.
ffi::Array< IntSet > UnionRegionLowerBound(const ffi::Array< ffi::Array< IntSet > > &nd_int_sets)
The union of N-dimensional integer sets.
IntSet EvalSet(PrimExpr e, const ffi::Map< Var, IntSet > &dom_map)
Find an symbolic integer set that contains all possible values of e given the domain of each variable...
TVM_TIRX_DLL ffi::Array< IntSet > EstimateRegionUpperBound(const ffi::Array< Range > ®ion, const ffi::Map< Var, Range > &var_dom, const PrimExpr &predicate, const sym::Analyzer &analyzer)
Analyze the region with affine map, given the domain of variables and their predicate Relaxation of t...
std::unordered_map< PrimExpr, IntSet, ffi::ObjectPtrHash, ffi::ObjectPtrEqual > ExprIntSetMap
Map from Expr to IntSet.
Definition int_set.h:218
ExprIntSetMap EvalSetForEachSubExpr(PrimExpr e, const std::unordered_map< const VarNode *, IntSet > &dom_map)
Find the integer set of every sub-expression, given the domain of each iteration variables.
ffi::Map< Var, sym::IntSet > AsIntSet(const ffi::Map< Var, Range > &var_dom)
Converts the Ranges to IntSets.
TVM_TIRX_DLL ffi::Optional< ffi::Array< IntSet > > EstimateRegionStrictBound(const ffi::Array< Range > ®ion, const ffi::Map< Var, Range > &var_dom, const PrimExpr &predicate, const sym::Analyzer &analyzer)
Analyze the region with affine map, given the domain of variables and their predicate....
ffi::Array< IntSet > UnionRegion(const ffi::Array< ffi::Array< IntSet > > &nd_int_sets)
The union of N-dimensional integer sets.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
#define TVM_TIRX_DLL
Definition base.h:83