Skip to content

Calling jex.ffi.ffi_call three times, getting only one output. #23963

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

You must be logged in to vote

Good question! There are a few issues here that I'm happy to explain. Let me start by saying that if you do want some sort of printing op, you should use jax.debug.print rather than trying to write your own because it handles all the issues that I'll talk about here.

The main point to note is that ffi_call assumes that the custom calls are pure, which means that we're allowed to re-order or choose to not call the function at all. With that in mind, I'm actually surprised that you even see the printing once! When I tested the same function, I don't see any output. The reason for this is that, since your ffi_call doesn't return any outputs, there's no need for it to ever be called.

So, you …

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@dfm
Comment options

@hyhieu
Comment options

@dfm
Comment options

@hyhieu
Comment options

@hyhieu
Comment options

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