Skip to content

Commit

Permalink
Apply review suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Min Chen committed May 27, 2023
1 parent ddbe714 commit 8697d7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/arith/presburger_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
namespace tvm {
namespace arith {

#ifdef TVM_MLIR_VERSION
#if TVM_MLIR_VERSION >= 150
using namespace tir;

void Update(const PrimExpr& constraint, PresburgerSetNode* intset) {
static void Update(const PrimExpr& constraint, PresburgerSetNode* intset) {
auto& space = intset->space;
auto constraints_union = ExtractComponents(constraint);
for (const PrimExpr& subconstraint : constraints_union) {
Expand Down Expand Up @@ -166,7 +167,7 @@ PrimExpr PresburgerSetNode::GenerateConstraint() const {
return constraint;
}

PresburgerSet Union(Array<PresburgerSet> sets) {
PresburgerSet Union(const Array<PresburgerSet>& sets) {
CHECK_GT(sets.size(), 0);
if (sets.size() == 1) return sets[0];
auto relations = sets[0]->disjuncts;
Expand Down Expand Up @@ -229,6 +230,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable)
p->stream << "}";
});

#endif // TVM_MLIR_VERSION >= 150
#endif // TVM_MLIR_VERSION

PresburgerSet MakePresburgerSet(const PrimExpr& constraint) { return PresburgerSet(constraint); }
Expand Down
10 changes: 7 additions & 3 deletions src/arith/presburger_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
#ifndef TVM_ARITH_PRESBURGER_SET_H_
#define TVM_ARITH_PRESBURGER_SET_H_

#ifdef TVM_MLIR_VERSION
#if TVM_MLIR_VERSION >= 150
#include <mlir/Analysis/Presburger/IntegerRelation.h>
#include <mlir/Analysis/Presburger/PresburgerRelation.h>
#include <mlir/Analysis/Presburger/Simplex.h>
#endif
#endif

#include <tvm/arith/analyzer.h>
#include <tvm/tir/op.h>
Expand All @@ -41,6 +43,7 @@
namespace tvm {
namespace arith {

#ifdef TVM_MLIR_VERSION
#if TVM_MLIR_VERSION >= 150
using namespace mlir;
using namespace presburger;
Expand Down Expand Up @@ -150,7 +153,8 @@ class PresburgerSet : public IntSet {
TVM_DEFINE_OBJECT_REF_COW_METHOD(PresburgerSetNode);
TVM_DEFINE_OBJECT_REF_METHODS(PresburgerSet, IntSet, PresburgerSetNode);
};
#else
#endif // TVM_MLIR_VERSION >= 150
#else // TVM_MLIR_VERSION
// Class definition when MLIR is not enabled, to prevent compile-time error.
class PresburgerSetNode : public IntSetNode {
public:
Expand All @@ -170,13 +174,13 @@ class PresburgerSet : public IntSet {
*/
TVM_DLL PresburgerSet(const PrimExpr& constraint) { LOG(FATAL) << "MLIR is not enabled!"; }
};
#endif
#endif // TVM_MLIR_VERSION
/*!
* \brief Create a union set of all sets
* \param sets The sets to be combined
* \return the set after union
*/
PresburgerSet Union(const Array<PresburgerSet> sets);
PresburgerSet Union(const Array<PresburgerSet>& sets);

/*!
* \brief Create an intersected set of all sets
Expand Down

0 comments on commit 8697d7b

Please sign in to comment.