Skip to content

Commit 17113f8

Browse files
authored
[REFACTOR] Formalize namespace for all objects (#18101)
This PR formalizes the namespace for all object registered so we do not have object that sits on root namespace Also fixes the Visitor style in TensorMapNode
1 parent 83c0c4c commit 17113f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+167
-179
lines changed

docs/arch/runtime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ Each ``Object`` subclass will override this to register its members. Here is an
233233
hash_reduce(value);
234234
}
235235
236-
static constexpr const char* _type_key = "IntImm";
236+
static constexpr const char* _type_key = "ir.IntImm";
237237
TVM_DECLARE_FINAL_OBJECT_INFO(IntImmNode, PrimExprNode);
238238
};
239239
// in cc file

ffi/include/tvm/ffi/container/array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class ArrayObj : public Object, public details::InplaceArrayBase<ArrayObj, TVMFF
156156
}
157157

158158
static constexpr const int32_t _type_index = TypeIndex::kTVMFFIArray;
159-
static constexpr const char* _type_key = "object.Array";
159+
static constexpr const char* _type_key = StaticTypeKey::kTVMFFIArray;
160160
static const constexpr bool _type_final = true;
161161
TVM_FFI_DECLARE_STATIC_OBJECT_INFO(ArrayObj, Object);
162162

ffi/include/tvm/ffi/container/map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class MapObj : public Object {
6868
static_assert(sizeof(KVType) == 32, "sizeof(KVType) incorrect");
6969

7070
static constexpr const int32_t _type_index = TypeIndex::kTVMFFIMap;
71-
static constexpr const char* _type_key = "object.Map";
71+
static constexpr const char* _type_key = StaticTypeKey::kTVMFFIMap;
7272
static const constexpr bool _type_final = true;
7373
TVM_FFI_DECLARE_STATIC_OBJECT_INFO(MapObj, Object);
7474

ffi/include/tvm/ffi/error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct EnvErrorAlreadySet : public std::exception {};
8686
class ErrorObj : public Object, public TVMFFIErrorCell {
8787
public:
8888
static constexpr const int32_t _type_index = TypeIndex::kTVMFFIError;
89-
static constexpr const char* _type_key = "object.Error";
89+
static constexpr const char* _type_key = "ffi.Error";
9090

9191
TVM_FFI_DECLARE_STATIC_OBJECT_INFO(ErrorObj, Object);
9292
};

ffi/include/tvm/ffi/function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class FunctionObj : public Object, public TVMFFIFunctionCell {
9393
}
9494

9595
static constexpr const uint32_t _type_index = TypeIndex::kTVMFFIFunction;
96-
static constexpr const char* _type_key = "object.Function";
96+
static constexpr const char* _type_key = StaticTypeKey::kTVMFFIFunction;
9797

9898
TVM_FFI_DECLARE_STATIC_OBJECT_INFO(FunctionObj, Object);
9999

ffi/include/tvm/ffi/object.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@ struct StaticTypeKey {
5252
static constexpr const char* kTVMFFIRawStr = "const char*";
5353
static constexpr const char* kTVMFFIByteArrayPtr = "TVMFFIByteArray*";
5454
static constexpr const char* kTVMFFIObjectRValueRef = "ObjectRValueRef";
55-
static constexpr const char* kTVMFFIBytes = "object.Bytes";
56-
static constexpr const char* kTVMFFIStr = "object.String";
57-
static constexpr const char* kTVMFFIShape = "object.Shape";
58-
static constexpr const char* kTVMFFINDArray = "object.NDArray";
55+
static constexpr const char* kTVMFFIBytes = "ffi.Bytes";
56+
static constexpr const char* kTVMFFIStr = "ffi.String";
57+
static constexpr const char* kTVMFFIShape = "ffi.Shape";
58+
static constexpr const char* kTVMFFINDArray = "ffi.NDArray";
59+
static constexpr const char* kTVMFFIObject = "ffi.Object";
60+
static constexpr const char* kTVMFFIFunction = "ffi.Function";
61+
static constexpr const char* kTVMFFIArray = "ffi.Array";
62+
static constexpr const char* kTVMFFIMap = "ffi.Map";
5963
};
6064

6165
/*!
@@ -197,7 +201,7 @@ class Object {
197201
}
198202

199203
// Information about the object
200-
static constexpr const char* _type_key = "object.Object";
204+
static constexpr const char* _type_key = StaticTypeKey::kTVMFFIObject;
201205

202206
// Default object type properties for sub-classes
203207
static constexpr bool _type_final = false;

include/tvm/arith/int_set.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ enum SignType { kPositive, kNegative, kZero, kUnknown };
5656
*/
5757
class IntSetNode : public Object {
5858
public:
59-
static constexpr const char* _type_key = "IntSet";
59+
static constexpr const char* _type_key = "ir.IntSet";
6060
static constexpr bool _type_has_method_sequal_reduce = false;
6161
TVM_DECLARE_BASE_OBJECT_INFO(IntSetNode, Object);
6262
};

include/tvm/ir/attrs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class AttrFieldInfoNode : public Object {
104104
v->Visit("description", &description);
105105
}
106106

107-
static constexpr const char* _type_key = "AttrFieldInfo";
107+
static constexpr const char* _type_key = "ir.AttrFieldInfo";
108108
static constexpr bool _type_has_method_sequal_reduce = false;
109109
static constexpr bool _type_has_method_shash_reduce = false;
110110
TVM_DECLARE_FINAL_OBJECT_INFO(AttrFieldInfoNode, Object);
@@ -164,7 +164,7 @@ class BaseAttrsNode : public Object {
164164

165165
static constexpr const bool _type_has_method_sequal_reduce = true;
166166
static constexpr const bool _type_has_method_shash_reduce = true;
167-
static constexpr const char* _type_key = "Attrs";
167+
static constexpr const char* _type_key = "ir.Attrs";
168168
TVM_DECLARE_BASE_OBJECT_INFO(BaseAttrsNode, Object);
169169
};
170170

@@ -201,7 +201,7 @@ class DictAttrsNode : public BaseAttrsNode {
201201
Array<AttrFieldInfo> ListFieldInfo() const final;
202202

203203
// type info
204-
static constexpr const char* _type_key = "DictAttrs";
204+
static constexpr const char* _type_key = "ir.DictAttrs";
205205
TVM_DECLARE_FINAL_OBJECT_INFO(DictAttrsNode, BaseAttrsNode);
206206
};
207207

include/tvm/ir/env_func.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class EnvFuncNode : public Object {
6666
hash_reduce(name);
6767
}
6868

69-
static constexpr const char* _type_key = "EnvFunc";
69+
static constexpr const char* _type_key = "ir.EnvFunc";
7070
static constexpr bool _type_has_method_sequal_reduce = true;
7171
static constexpr bool _type_has_method_shash_reduce = true;
7272
TVM_DECLARE_FINAL_OBJECT_INFO(EnvFuncNode, Object);

include/tvm/ir/expr.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class BaseExprNode : public Object {
6161
refl::ObjectDef<BaseExprNode>().def_ro("span", &BaseExprNode::span, refl::DefaultValue(Span()));
6262
}
6363

64-
static constexpr const char* _type_key = "BaseExpr";
64+
static constexpr const char* _type_key = "ir.BaseExpr";
6565
static constexpr const bool _type_has_method_visit_attrs = true;
6666
static constexpr const bool _type_has_method_sequal_reduce = true;
6767
static constexpr const bool _type_has_method_shash_reduce = true;
@@ -117,7 +117,7 @@ class PrimExprNode : public BaseExprNode {
117117

118118
TVM_OBJECT_ENABLE_SCRIPT_PRINTER();
119119

120-
static constexpr const char* _type_key = "PrimExpr";
120+
static constexpr const char* _type_key = "ir.PrimExpr";
121121
static constexpr const uint32_t _type_child_slots = 40;
122122
TVM_DECLARE_BASE_OBJECT_INFO(PrimExprNode, BaseExprNode);
123123
};
@@ -161,7 +161,7 @@ class PrimExprConvertibleNode : public Object {
161161
virtual ~PrimExprConvertibleNode() {}
162162
virtual PrimExpr ToPrimExpr() const = 0;
163163

164-
static constexpr const char* _type_key = "PrimExprConvertible";
164+
static constexpr const char* _type_key = "ir.PrimExprConvertible";
165165
TVM_DECLARE_BASE_OBJECT_INFO(PrimExprConvertibleNode, Object);
166166
};
167167

@@ -433,7 +433,7 @@ class RelaxExprNode : public BaseExprNode {
433433
refl::ObjectDef<RelaxExprNode>().def_ro("struct_info_", &RelaxExprNode::struct_info_);
434434
}
435435

436-
static constexpr const char* _type_key = "RelaxExpr";
436+
static constexpr const char* _type_key = "ir.RelaxExpr";
437437
static constexpr const uint32_t _type_child_slots = 22;
438438
TVM_DECLARE_BASE_OBJECT_INFO(RelaxExprNode, BaseExprNode);
439439
};
@@ -478,7 +478,7 @@ class GlobalVarNode : public RelaxExprNode {
478478
hash_reduce.FreeVarHashImpl(this);
479479
}
480480

481-
static constexpr const char* _type_key = "GlobalVar";
481+
static constexpr const char* _type_key = "ir.GlobalVar";
482482
TVM_DECLARE_FINAL_OBJECT_INFO(GlobalVarNode, RelaxExprNode);
483483
};
484484

@@ -517,7 +517,7 @@ class IntImmNode : public PrimExprNode {
517517
hash_reduce(value);
518518
}
519519

520-
static constexpr const char* _type_key = "IntImm";
520+
static constexpr const char* _type_key = "ir.IntImm";
521521
TVM_DECLARE_FINAL_OBJECT_INFO(IntImmNode, PrimExprNode);
522522
};
523523

@@ -565,7 +565,7 @@ class FloatImmNode : public PrimExprNode {
565565
hash_reduce(value);
566566
}
567567

568-
static constexpr const char* _type_key = "FloatImm";
568+
static constexpr const char* _type_key = "ir.FloatImm";
569569
TVM_DECLARE_FINAL_OBJECT_INFO(FloatImmNode, PrimExprNode);
570570
};
571571

@@ -718,7 +718,7 @@ class RangeNode : public Object {
718718
hash_reduce(extent);
719719
}
720720

721-
static constexpr const char* _type_key = "Range";
721+
static constexpr const char* _type_key = "ir.Range";
722722
static constexpr const bool _type_has_method_sequal_reduce = true;
723723
static constexpr const bool _type_has_method_shash_reduce = true;
724724
TVM_DECLARE_FINAL_OBJECT_INFO(RangeNode, Object);

0 commit comments

Comments
 (0)