yaoyaoding opened a new pull request, #254:
URL: https://github.com/apache/tvm-ffi/pull/254

   This PR introduces a new addon package `tvm-ffi-orcjit` that enables dynamic 
loading of TVM-FFI exported object files (.o) at runtime using LLVM's ORC JIT 
v2 engine. 
   
   The addon provides a Python API for loading compiled object files, load the 
tvm-ffi functions defined in the object files.
   
   The API is organized around three main concepts:
   - **ExecutionSession**: A JIT compilation context that manages the lifetime 
of dynamic libraries.
   - **DynamicLibrary**: Represents a shared library that links multiple object 
files. 
   - **Object Files**: Compiled `.o` files containing TVM-FFI exported 
functions. 
   
   ## Usage Example
   
   ```python
   from tvm_ffi_orcjit import create_session
   
   # Create an execution session (JIT compilation context)
   session = create_session()
   
   # Load an object file into the session, returns a DynamicLibrary handle
   dylib = session.load("example.o")
   
   # Get and call a function from the loaded object file
   add_func = dylib.get_function("simple_add")
   result = add_func(1, 2)
   print(f"Result: {result}")  # Output: Result: 3
   ```
   
   For incremental loading, you can add multiple object files to the same 
session:
   
   ```python
   session = create_session()
   
   # Load first object file
   dylib = session.load("math_ops.o")
   add = dylib.get_function("simple_add")
   
   # Incrementally load more object files into the same library
   dylib.load("string_ops.o")
   
   # Now both functions are accessible from the same library
   concat = dylib.get_function("string_concat")
   ```
   
   See the test for more example.
   
   ## TODO
   
   - Support Windows platform (currently Linux and macOS only)
   - Customize memory allocation for dynamic libraries (allow user-provided 
allocators)
   


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