tqchen commented on code in PR #237:
URL: https://github.com/apache/tvm-ffi/pull/237#discussion_r2505881667


##########
python/tvm_ffi/cython/core.pyx:
##########
@@ -19,10 +19,18 @@
 # under the License.
 include "./base.pxi"
 include "./type_info.pxi"
-include "./dtype.pxi"
-include "./device.pxi"
 include "./object.pxi"
+_register_object_by_index(kTVMFFIObject, Object)
 include "./error.pxi"
+_register_object_by_index(kTVMFFIError, Error)
+include "./dtype.pxi"
+_register_object_by_index(kTVMFFIDataType, DataType)
+include "./device.pxi"
+_register_object_by_index(kTVMFFIDevice, Device)
 include "./string.pxi"
+_register_object_by_index(kTVMFFIStr, String)
+_register_object_by_index(kTVMFFIBytes, Bytes)
 include "./tensor.pxi"
+_register_object_by_index(kTVMFFITensor, Tensor)
 include "./function.pxi"
+_register_object_by_index(kTVMFFIFunction, Function)

Review Comment:
   why move registration to here?



##########
python/tvm_ffi/cython/object.pxi:
##########
@@ -487,6 +488,17 @@ cdef _update_registry(int type_index, object type_key, 
object type_info, object
     TYPE_INDEX_TO_CLS[type_index] = type_cls
     TYPE_INDEX_TO_INFO[type_index] = type_info
     TYPE_KEY_TO_INFO[type_key] = type_info
+    if type_cls is not None:
+        if "__tvm_ffi_type_info__" not in type_cls.__dict__:
+            setattr(type_cls, "__tvm_ffi_type_info__", type_info)
+        elif (dst_type_info := type_cls.__tvm_ffi_type_info__) is not 
type_info:
+            dst_type_info.type_cls = type_info.type_cls
+            dst_type_info.type_index = type_info.type_index
+            dst_type_info.type_key = type_info.type_key
+            dst_type_info.type_ancestors = type_info.type_ancestors

Review Comment:
   given type info may not be as freq used, it maybe more desirable still keep 
the original query by index/class and key function and just let user query 
instead of eager population



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to