@@ -65,27 +65,33 @@ class Var;
6565 */
6666class VarNode : public PrimExprNode {
6767 public:
68+ /* ! \brief constructor */
69+ VarNode () {}
70+ VarNode (DataType dtype, std::string name_hint);
71+
6872 /* !
6973 * \brief The hint to the variable name.
7074 * \note Each variable is uniquely identified by its address.
7175 */
7276 std::string name_hint;
7377
74- static Var make (DataType dtype, std::string name_hint);
75-
7678 void VisitAttrs (AttrVisitor* v) {
7779 v->Visit (" dtype" , &dtype);
7880 v->Visit (" name" , &name_hint);
7981 }
8082
8183 static constexpr const char * _type_key = " Variable" ;
82- TVM_DECLARE_FINAL_OBJECT_INFO (VarNode, PrimExprNode);
84+ TVM_DECLARE_BASE_OBJECT_INFO (VarNode, PrimExprNode);
8385};
8486
8587/* ! \brief a named variable in TVM */
8688class Var : public PrimExpr {
8789 public:
8890 explicit Var (ObjectPtr<Object> n) : PrimExpr(n) {}
91+ /* ! \brief constructor
92+ * \param name_hint variable name
93+ * \param t data type
94+ */
8995 TVM_DLL explicit Var (std::string name_hint = " v" ,
9096 DataType t = DataType::Int(32 ));
9197 /* !
@@ -114,6 +120,53 @@ class Var : public PrimExpr {
114120 using ContainerType = VarNode;
115121};
116122
123+ class SizeVar ;
124+ /* !
125+ * \brief A variable node represent a tensor index size,
126+ * whose value must be non-negative.
127+ */
128+ class SizeVarNode : public VarNode {
129+ public:
130+ /* ! \brief constructor */
131+ SizeVarNode () {}
132+ /* ! \brief constructor
133+ * \param dtype data type
134+ * \param name_hint variable name
135+ */
136+ SizeVarNode (DataType dtype, std::string name_hint);
137+
138+ static constexpr const char * _type_key = " SizeVar" ;
139+ TVM_DECLARE_FINAL_OBJECT_INFO (SizeVarNode, VarNode);
140+ };
141+
142+ /* ! \brief a named variable represents a tensor index size */
143+ class SizeVar : public Var {
144+ public:
145+ explicit SizeVar (ObjectPtr<Object> n) : Var(n) {}
146+ /* ! \brief constructor
147+ * \param name_hint variable name
148+ * \param t data type
149+ */
150+ TVM_DLL explicit SizeVar (std::string name_hint = " s" ,
151+ DataType t = DataType::Int(32 ));
152+ /* !
153+ * \brief Get pointer to the internal value.
154+ * \return the corresponding Variable.
155+ */
156+ const SizeVarNode* operator ->() const {
157+ return get ();
158+ }
159+ /* !
160+ * \brief Get pointer to the internal value.
161+ * \return the corresponding Variable.
162+ */
163+ const SizeVarNode* get () const {
164+ return static_cast <const SizeVarNode*>(data_.get ());
165+ }
166+ /* ! \brief type indicate the container type */
167+ using ContainerType = SizeVarNode;
168+ };
169+
117170/* !
118171 * \brief Container of constant int that adds more constructors.
119172 *
0 commit comments