24 #ifndef TVM_TOPI_DETAIL_CONSTANT_UTILS_H_
25 #define TVM_TOPI_DETAIL_CONSTANT_UTILS_H_
58 inline bool IsConstIntArray(Array<PrimExpr> array) {
60 for (
auto const& elem : array) {
74 inline int64_t GetConstInt(PrimExpr expr) {
78 LOG(ERROR) <<
"expr must be a constant integer";
91 inline std::vector<int> GetConstIntValues(Array<PrimExpr> exprs,
const std::string& var_name) {
92 std::vector<int> result;
93 if (!exprs.defined())
return result;
94 for (
auto expr : exprs) {
95 ICHECK(IsConstInt(expr)) <<
"All elements of " << var_name <<
" must be constant integers";
96 result.push_back(GetConstInt(expr));
110 inline std::vector<int64_t> GetConstInt64Values(Array<PrimExpr> exprs,
111 const std::string& var_name) {
112 std::vector<int64_t> result;
113 if (!exprs.defined())
return result;
114 for (
auto expr : exprs) {
115 ICHECK(IsConstInt(expr)) <<
"All elements of " << var_name <<
" must be constant integers";
116 result.push_back(GetConstInt(expr));
129 inline bool EqualCheck(PrimExpr lhs, PrimExpr rhs) {
131 bool result = expr_equal(lhs, rhs);
135 result = i->value == 0;
Algebra expression simplifications.
Constant integer literals in the program.
Definition: expr.h:501
Analyzer that contains bunch of sub-analyzers.
Definition: analyzer.h:629
PrimExpr Simplify(const PrimExpr &expr, int steps=2)
Simplify expr.
Tensor expression language DSL.
Definition: extracted_task.h:33
bool is_const_int(const PrimExpr &x, int64_t value)
Check whether x is a constant integer expression.
Definition: op.h:910
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Operation node can generate one or multiple Tensors.
Compare two expressions recursively and check if they are equal to each other without var remapping.
Definition: analysis.h:61
Analysis utilities and passes for TIR.