Skip to content

Recommended method for control flow with mlx types #1375

Answered by angeloskath
kyrollosyanny asked this question in Q&A
Discussion options

You must be logged in to vote

The way would be using mx.where as follows

a = mx.array(5)
s = mx.where(a == 0, mx.array(5), 1/a)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kyrollosyanny
Comment options

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