You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tvm.apache.org by Johnson9009 via Apache TVM Discuss <no...@discuss.tvm.ai> on 2025/06/13 14:34:21 UTC

[Apache TVM Discuss] [Development] Introducing and modernize FFI system


Rencently we upgrade our work on the newest code, honestly it is a hard work to do it, but it is worth, everybody can gain lots from the new ffi's design and implementation. 

The new ffi drop the ctypes solution, only Cython solution is provided, this make debug a little harder, now if you want to know debug the argument process logic, remember below  c function name, add breakpoint in gdb.

__pyx_f_3tvm_3ffi_4core_make_args
__pyx_f_3tvm_3ffi_4core_FuncCall
TVMFFIFunctionCall





---
[Visit Topic](https://discuss.tvm.apache.org/t/introducing-and-modernize-ffi-system/18304/4) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/4585898624ac8c57af0f50397c53f5824b3d71a1b39f322b4cc8abd071dd373b).

[Apache TVM Discuss] [Development] Introducing and modernize FFI system

Posted by tqchen via Apache TVM Discuss <no...@discuss.tvm.ai>.

Note that in the new ffi, we have better backtrace support through lib backtrace, so right now if an exception is thrown from cxx end, the trace will be incorporated into the python trace and also clickable if we are in editors like vscode

```python
from tvm import ffi as tvm_ffi

def error_trace():
    # call a test function that raises error from c++ end
    cxx_test_raise_error = tvm_ffi.get_global_func("testing.test_raise_error")
    cxx_test_raise_error("ValueError", "error XYZ")

error_trace()
```

Will return something like

```bash
Traceback (most recent call last):
  File "/tvm/apps/debug.py", line 25, in <module>
    error_trace()
  File "/tvm/apps/debug.py", line 23, in error_trace
    cxx_test_raise_error("ValueError", "error XYZ")
  File "tvm/ffi/cython/function.pxi", line 228, in tvm.ffi.core.Function.__call__
    raise move_from_last_error().py_error()
  File "/tvm/ffi/src/ffi/testing.cc", line 30, in tvm::ffi::TestRaiseError(tvm::ffi::String, tvm::ffi::String)
    throw ffi::Error(kind, msg, TVM_FFI_TRACEBACK_HERE);
ValueError: error XYZ
```





---
[Visit Topic](https://discuss.tvm.apache.org/t/introducing-and-modernize-ffi-system/18304/5) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/b042bdef26e5f81b277b93d2f70e02d31c22fe962b8d3a8c747137cb7944406f).