tqchen opened a new pull request, #19727:
URL: https://github.com/apache/tvm/pull/19727

   This PR adds an autoload mechanism for out-of-tree backends and simplifies 
TVM's Python library loading.
   
   ## Autoload out-of-tree backends
   
   Out-of-tree packages can register an autoload callable under the 
`tvm.backends` entry-point group (mirroring torch's device-backend autoload). 
At `import tvm` startup each entry point is discovered and its callable invoked 
once, after the core runtime and the `tvm` namespace are fully initialized, so 
an extension can register ops/targets/funcs or load extra libraries.
   
   ```toml
   [project.entry-points."tvm.backends"]
   tvm_foo = "tvm_foo:_autoload"
   ```
   
   A failing extension is caught and surfaced via `warnings.warn` so it cannot 
break `import tvm`. Autoload can be disabled with 
`TVM_DEVICE_BACKEND_AUTOLOAD=0`.
   
   ## Simplify library loading
   
   The library-loading path in `base.py` is consolidated around a single 
`_LOADED_LIBS` dict (basename to ctypes handle) so downstream and autoloaded 
extensions can skip already-loaded libraries; the per-backend runtime DSO list 
is folded into `load_backend_libs`. Accumulated cruft is removed: the 
Python-3.9 check, the readline shim, the `_FFI_MODE` ctypes check, the 
`base.__version__` re-export, `py_str` (call sites inline `.decode("utf-8")`), 
and the `TVMError = Exception` alias (sites now use the `RuntimeError`-based 
`tvm.error.TVMError`).
   


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