24#ifndef TVM_TOPI_DETAIL_CONSTANT_UTILS_H_
25#define TVM_TOPI_DETAIL_CONSTANT_UTILS_H_
28#include <tvm/runtime/logging.h>
58inline bool IsConstIntArray(ffi::Array<PrimExpr> array) {
59 bool IsConstInt =
true;
60 for (
auto const& elem : array) {
61 IsConstInt &= !elem.defined() || elem->IsInstance<
tvm::IntImmObj>();
74inline int64_t GetConstInt(
PrimExpr expr) {
78 LOG(ERROR) <<
"expr must be a constant integer";
91inline std::vector<int> GetConstIntValues(ffi::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 TVM_FFI_ICHECK(IsConstInt(expr))
96 <<
"All elements of " << var_name <<
" must be constant integers";
97 result.push_back(GetConstInt(expr));
111inline std::vector<int64_t> GetConstInt64Values(ffi::Array<PrimExpr> exprs,
112 const std::string& var_name) {
113 std::vector<int64_t> result;
114 if (!exprs.defined())
return result;
115 for (
auto expr : exprs) {
116 TVM_FFI_ICHECK(IsConstInt(expr))
117 <<
"All elements of " << var_name <<
" must be constant integers";
118 result.push_back(GetConstInt(expr));
133 bool result = expr_equal(lhs, rhs);
137 result = i->value == 0;
Algebra expression simplifications.
Constant integer literals in the program.
Definition expr.h:314
Typed reference/view over any Expr whose ExprObj::ty is PrimType.
Definition expr.h:187
Managed reference to AnalyzerObj.
Definition analyzer.h:750
Tensor expression language DSL.
Definition extracted_task.h:33
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
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 expr.h:795