Skip to content

Does vmap work with python control structures (branch)? #6359

Answered by bbfrog
bbfrog asked this question in Q&A
Discussion options

You must be logged in to vote

If changes the branch function to use lax.cond, it works with vmap. Thanks!

def branch(x):
return lax.cond(x>0, lambda x:x, lambda x:-x, x)

Replies: 1 comment 2 replies

Comment options

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

@bbfrog
Comment options

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