Skip to content

Inequation inside Jax.jit function #3740

Answered by jakevdp
fasghq asked this question in General
Jul 13, 2020 · 2 comments · 11 replies
Discussion options

You must be logged in to vote

What is x=0 meant to do within your loop? It looks like a no-op, because the variable is never used.

It looks like you can replace this block

for x in s:
    if x < delta:
        x = 0
        if rc > p:
            rc = p
    p = p + 1

with

p = len(s)
rc = max(rc, (s < delta).sum())

which will generally be much more efficient, and will have no issue with compilation.

Replies: 2 comments 11 replies

Comment options

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

@jakevdp
Comment options

@fasghq
Comment options

Comment options

You must be logged in to vote
8 replies
@jakevdp
Comment options

@fasghq
Comment options

@jakevdp
Comment options

@fasghq
Comment options

@fasghq
Comment options

Answer selected by fasghq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3740 on July 13, 2020 21:16.