Skip to content

How to bind a void pointer in the new FFI API #27763

Answered by dfm
Vandermode asked this question in Q&A
Discussion options

You must be logged in to vote

Many questions here - let me try to answer them all!

Btw, do I really need to use FFI interface to expose this C function to jax?

If you can already call your function from Python, another option would be to use jax.pure_callback. You can typically get better performance and more features (e.g. in-place operations as discussed below) via the FFI, at the cost of an extra interface code.

or is there any alternative to use FFI inplace compute?

Yep! The parameter you're looking for is input_output_aliases for ffi_call.

Replies: 1 comment 9 replies

Comment options

dfm
Apr 7, 2025
Collaborator

You must be logged in to vote
9 replies
@Vandermode
Comment options

@Vandermode
Comment options

@Vandermode
Comment options

@dfm
Comment options

dfm Apr 8, 2025
Collaborator

Answer selected by Vandermode
@Vandermode
Comment options

@dfm
Comment options

dfm Apr 8, 2025
Collaborator

@Vandermode
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants