Skip to content

jax.lax.dynamic_slice accepting numpy slice syntax #19519

Answered by jakevdp
jglaser asked this question in Ideas
Discussion options

You must be logged in to vote

Hi - the reason this is different is because in dynamic_slice, the start index is dynamic, but the slice size is static. There is no way to construct such a slice using NumPy's slice syntax; for example, if you have a dynamic start_index and a static length, then you would have to write something like this:

end_index = start_index + length
x[start_index:end_index]

Because end_index is derived from start_index, it is dynamic, and your indexing expression no longer has any way to statically determine the length!

We may someday introduce a higher-level syntax for this: for example pallas has a dynamic slice object that makes dynamic-slice indexing look something like x[dslice(start_index, l…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by jglaser
Comment options

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

@davisyoshida
Comment options

@patrick-kidger
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
4 participants