Skip to content
Discussion options

You must be logged in to vote

The index argument to delete must be static, so the easiest way to jit-compile this function is to mark the argument as static:

zjit = jit(zdel, static_argnames=['indx'])

If you need to use a dynamic index, you can often compute the same result using operations that are compatible with dynamic values. Here's one way you might do it:

@jit
def zdel2(x, indx):
  return jnp.where(jnp.arange(len(result) - 1) < indx, x[:-1], x[1:])

print(zjit(x, indx))
# [1. 2. 3. 4. 5. 7. 8. 9.]

Replies: 1 comment 3 replies

Comment options

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

@jakevdp
Comment options

@fuglede
Comment options

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