int_set_internal.h 1.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*!
 *  Copyright (c) 2017 by Contributors
 * \file int_set_internal.h
 * \brief Implementations of integer set
 */
#ifndef TVM_ARITHMETIC_INT_SET_INTERNAL_H_
#define TVM_ARITHMETIC_INT_SET_INTERNAL_H_

#include <tvm/ir.h>
#include <tvm/ir_pass.h>
11
#include <tvm/arithmetic.h>
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

namespace tvm {
namespace arith {

using Halide::Internal::Interval;

/*! \brief Set of continuous interval */
struct IntervalSet : public IntSetNode {
  /*! \brief the internal interval*/
  Interval i;

  static IntSet make(Interval i) {
    std::shared_ptr<IntervalSet> n =
        std::make_shared<IntervalSet>();
    n->i = i;
    return IntSet(n);
  }
  static IntSet make(Expr min, Expr max) {
    std::shared_ptr<IntervalSet> n =
        std::make_shared<IntervalSet>();
    n->i.min = min;
    n->i.max = max;
    return IntSet(n);
  }

  static constexpr const char* _type_key = "IntervalSet";
38
  TVM_DECLARE_NODE_TYPE_INFO(IntervalSet, IntSetNode);
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
};

/*!
 * \brief set represented by strided integers
 *  Reserved for cases where strided access is supported.
 */
struct StrideSet : public IntSetNode {
  /*! \brief the base inetrval */
  Interval base;
  /*! \brief additional extents in positive number */
  Array<Expr> extents;
  /*! \brief additional strides in positive number */
  Array<Expr> strides;

  static constexpr const char* _type_key = "StrideSet";
54
  TVM_DECLARE_NODE_TYPE_INFO(StrideSet, IntSetNode);
55 56
};

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
/*!
 * \brief Set represented by range of ModularEntry.
 *  Used for front-end modular analysis.
 */
struct ModularSet : public IntSetNode {
  /*! \brief Internal modular entry */
  ModularEntry e;

  void VisitAttrs(AttrVisitor* v) final {
    v->Visit("base", &(e.base));
    v->Visit("coeff", &(e.coeff));
  }
  static constexpr const char* _type_key = "ModularSet";
  TVM_DECLARE_NODE_TYPE_INFO(ModularSet, IntSetNode);
};


74 75 76 77
}  // namespace arith
}  // namespace tvm

#endif  // TVM_ARITHMETIC_INT_SET_INTERNAL_H_