gemini-code-assist[bot] commented on code in PR #115:
URL: https://github.com/apache/tvm-ffi/pull/115#discussion_r2429311886
##########
python/tvm_ffi/cython/function.pxi:
##########
@@ -267,16 +267,16 @@ cdef int TVMFFIPyArgSetterDLPack_(
return 0
-cdef int TVMFFIPyArgSetterFFITensorCompatible_(
+cdef int TVMFFIPyArgSetterFFIObjectCompatible_(
TVMFFIPyArgSetter* handle, TVMFFIPyCallContext* ctx,
PyObject* py_arg, TVMFFIAny* out
) except -1:
- """Setter for objects that implement the `__tvm_ffi_tensor__` protocol."""
+ """Setter for objects that implement the `__tvm_ffi_object__` protocol."""
cdef object arg = <object>py_arg
cdef TVMFFIObjectHandle temp_chandle
- cdef Tensor tensor = arg.__tvm_ffi_tensor__()
- cdef long ref_count = Py_REFCNT(tensor)
- temp_chandle = tensor.chandle
+ cdef Object obj = arg.__tvm_ffi_object__()
+ cdef long ref_count = Py_REFCNT(obj)
+ temp_chandle = obj.chandle
out.type_index = kTVMFFITensor
Review Comment:

The `__tvm_ffi_object__` protocol has been generalized to support any
`Object`, not just `Tensor`. However, the type index here is hardcoded to
`kTVMFFITensor`. This will lead to incorrect behavior if an object that is not
a `Tensor` is passed via this protocol. The type index should be dynamically
retrieved from the object handle to correctly support generic objects.
```
out.type_index = TVMFFIObjectGetTypeIndex(temp_chandle)
```
##########
python/tvm_ffi/cython/function.pxi:
##########
@@ -403,12 +403,12 @@ cdef int TVMFFIPyArgSetterPyNativeObjectGeneral_(
TVMFFIPyArgSetter* handle, TVMFFIPyCallContext* ctx,
PyObject* py_arg, TVMFFIAny* out
) except -1:
- """Specially handle Bytes as its __tvm_ffi_object__ may be empty"""
+ """Specially handle Bytes as its _tvm_ffi_cached_object may be empty"""
Review Comment:

This docstring appears to be a copy-paste from the `Bytes` setter. It should
be updated to reflect that this function handles general `PyNativeObject`
instances, not `Bytes`.
```
"""Setter for general PyNativeObject."""
```
--
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]