junrushao1994 commented on pull request #7919:
URL: https://github.com/apache/tvm/pull/7919#issuecomment-939562902


   @tqchen while this approach is more specific to cython, I would love to 
discuss the possibility about a ctype-based generic approach to register 
arbitrary python api with `TVMBackendRegisterEnvCAPI`:
   
   It seems that `ctypes.pythonapi.*` provides all the python C apis. For 
example:
   - `ctypes.pythonapi.Py_IncRef` corresponds to `Py_IncRef` in Python.h
   - `ctypes.pythonapi.Py_DecRef` corresponds to `Py_DecRef` in Python.h
   - `ctypes.pythonapi.PyMem_RawMalloc` corresponds to `PyMem_RawMalloc` in 
Python.h
   - `ctypes.pythonapi.PyMem_RawFree` corresponds to `PyMem_RawFree` in Python.h
   
   Therefore, instead of registering cython method, what about we register apis 
under `ctypes.pythonapi` after CDLL is loaded with ctypes? This way, it could 
work for both ctypes and cython, and probably generalizable to future work to 
call more python apis without having to depend on Python.h.
   
   CC: @zxybazh 


-- 
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]


Reply via email to