Skip to content

Slicing an array inside a JIT compiled function vs using sliced arrays as inputs to JIT compiled function #18319

Closed Answered by jakevdp
JaySandesara asked this question in Q&A
Discussion options

You must be logged in to vote

Oh I see – the difference is that when you compile func, you are passing all the arguments past the first one as arguments to the function, and so they are treated as runtime traced values. When you compile func_wrapper, you are closing over all the variables after the first one, and their global values are stored as numpy arrays, so they are being treated as compile-time constants. This changes the compilation characteristics: in particular the compiler can often specialize execution if a value is a constant, but sometimes this can lead to longer compilation times because the compiler has more flexibility, and more potential optimizations to explore. Does that answer your question?

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@JaySandesara
Comment options

@jakevdp
Comment options

@JaySandesara
Comment options

@jakevdp
Comment options

Answer selected by JaySandesara
@JaySandesara
Comment options

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