Skip to content

Execution count for loop + vmap #18225

Answered by jakevdp
f0uriest asked this question in Q&A
Oct 22, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

fori_loop with a static bound lowers to scan, and fori_loop with a dynamic bound lowers to while_loop. Since you are mapping over n here, it lowers to a while_loop.

When you vmap a while_loop over the bound, it results in a single while_loop over the batched body function. So in the end there will be m iterations over a vmapped call to f with a batch size of m.

Does that answer your question?

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@f0uriest
Comment options

@jakevdp
Comment options

Answer selected by f0uriest
@f0uriest
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