junrushao commented on code in PR #174:
URL: https://github.com/apache/tvm-ffi/pull/174#discussion_r2443439542
##########
python/tvm_ffi/registry.py:
##########
@@ -273,15 +273,25 @@ def _add_class_attrs(type_cls: type, type_info: TypeInfo)
-> type:
name = field.name
if not hasattr(type_cls, name): # skip already defined attributes
setattr(type_cls, name, field.as_property(type_cls))
+ has_c_init = False
for method in type_info.methods:
name = method.name
if name == "__ffi_init__":
name = "__c_ffi_init__"
+ has_c_init = True
if not hasattr(type_cls, name):
setattr(type_cls, name, method.as_callable(type_cls))
+ if "__init__" not in type_cls.__dict__ and has_c_init:
+ setattr(type_cls, "__init__", getattr(type_cls, "__ffi_init__"))
+ elif not type_info.type_key.startswith("ffi."):
+ setattr(type_cls, "__init__", __init__invalid)
Review Comment:
Good catch!! Fixed
--
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]