24#ifndef TVM_ARITH_INT_SOLVER_H_
25#define TVM_ARITH_INT_SOLVER_H_
31#include <unordered_map>
67 namespace refl = tvm::ffi::reflection;
68 refl::ObjectDef<IntGroupBoundsNode>()
96 ffi::Array<PrimExpr> upper);
146 namespace refl = tvm::ffi::reflection;
147 refl::ObjectDef<IntConstraintsNode>()
171 ffi::Array<PrimExpr> relations);
198 namespace refl = tvm::ffi::reflection;
199 refl::ObjectDef<IntConstraintsTransformNode>()
228 ffi::Map<Var, PrimExpr> src_to_dst,
229 ffi::Map<Var, PrimExpr> dst_to_src);
262 std::vector<PrimExpr>*
x, std::vector<PrimExpr>*
y);
304 const ffi::Map<Var, IntGroupBounds>&
bounds,
305 const ffi::Array<PrimExpr>& relations);
Algebra expression simplifications.
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:401
Range container
Definition expr.h:610
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Represent integer constrains including (integer) variables, their ranges and the relations between th...
Definition int_solver.h:133
ffi::Array< PrimExpr > relations
Definition int_solver.h:143
static void RegisterReflection()
Definition int_solver.h:145
ffi::Map< Var, Range > ranges
Definition int_solver.h:140
ffi::Array< PrimVar > variables
Definition int_solver.h:136
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("arith.IntConstraints", IntConstraintsNode, ffi::Object)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition int_solver.h:153
Managed reference to IntConstraintsNode.
Definition int_solver.h:161
IntConstraints(ffi::Array< PrimVar > variables, ffi::Map< Var, Range > ranges, ffi::Array< PrimExpr > relations)
Constructor by fields.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(IntConstraints, ffi::ObjectRef, IntConstraintsNode)
Represent integer grouped bounds which are classified into lower bounds (inclusive),...
Definition int_solver.h:59
PrimExpr coef
Definition int_solver.h:61
static void RegisterReflection()
Definition int_solver.h:66
ffi::Array< PrimExpr > equal
Definition int_solver.h:63
ffi::Array< PrimExpr > upper
Definition int_solver.h:64
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("arith.IntGroupBounds", IntGroupBoundsNode, ffi::Object)
ffi::Array< PrimExpr > lower
Definition int_solver.h:62
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition int_solver.h:75
Managed reference to IntGroupBoundsNode.
Definition int_solver.h:83
static IntGroupBounds FromRange(const Range &r)
Construct bounds from a range.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(IntGroupBounds, ffi::ObjectRef, IntGroupBoundsNode)
IntGroupBounds(PrimExpr coef, ffi::Array< PrimExpr > lower, ffi::Array< PrimExpr > equal, ffi::Array< PrimExpr > upper)
Constructor by fields.
Range FindBestRange(const ffi::Map< Var, Range > &vranges_addl={}) const
Find the best range from the grouped bounds.
IntGroupBounds operator+(const Range &r)
Combine the bounds with another range.
IntGroupBounds Substitute(const ffi::Map< Var, PrimExpr > &subst) const
Perform substitution on all components of the struct.
std::pair< ffi::Map< Var, IntGroupBounds >, ffi::Array< PrimExpr > > PartialSolvedInequalities
Definition int_solver.h:244
IntConstraints SolveInequalitiesToRange(const IntConstraints &system_to_solve)
Solve linear inequalities and infer the range of each variable.
void SmithNormalFormDiag(std::vector< std::vector< int64_t > > *S, std::vector< std::vector< int64_t > > *V, std::vector< PrimExpr > *x, std::vector< PrimExpr > *y)
Obtain Smith Normal Form of linear equation A x = y. Smith Normal Form of matrix A_{mxn} is S_{mxn} =...
constexpr int kSimplifyRewriteCanonicalRewrite
Definition int_solver.h:48
IntConstraintsTransform SolveInequalitiesDeskewRange(const IntConstraints &system_to_solve)
Solve linear inequalities and deskew the ranges towards zero.
PartialSolvedInequalities SolveLinearInequalities(const IntConstraints &system_to_solve)
Solve linear inequalities.
ffi::Array< PrimExpr > AsConditions(const ffi::Array< PrimVar > &variables, const ffi::Map< Var, IntGroupBounds > &bounds, const ffi::Array< PrimExpr > &relations)
Combine the information into an array of (in)equalities.
IntConstraintsTransform SolveLinearEquations(const IntConstraints &system_to_solve)
Solve linear equations.
tvm::Var Var
Definition var.h:38
tvm::VarNode VarNode
Definition var.h:37
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
Common operators defined for Expr.