Skip to content

JIT ignore #6299

Answered by jakevdp
xmax1 asked this question in Q&A
Mar 31, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

When you JIT-compile a function, everything within the function is JIT-compiled, and there is no way to call non-JIT compiled code from within JIT-compiled code (the reason for this is essentially that non-JIT code is executed in Python, while JIT compiled code is executed in XLA, and there's no easy way for XLA to call back to Python)

If you want to mix JIT and non-JIT code, you can do that by only JIT-compiling the pieces you want to be JIT-compiled. In your example, it might be something like this:

jitted_can_be_jit = jit(can_be_jit)

def loop_function(x):
    for _ in range(10):
        x = cannot_be_jit(x)
        jitted_can_be_jit(x)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@xmax1
Comment options

Answer selected by xmax1
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