ml-explore / mlx

MLX: An array framework for Apple silicon
https://ml-explore.github.io/mlx/
MIT License
14.83k stars 845 forks source link

Add bitwise ops #1037

Closed awni closed 3 weeks ago

awni commented 3 weeks ago

Add the numpy bitwise ops:

NB I did these all in a single BitwiseBinary primitive rather than a primitive for each. Uses a lot less code.. and also since the transform semantics are the same seemed ok. But it's a slight departure from our other binary ops so I'm open to changing it.

Also changed ^ to be the bitwise_xor rather than power which is I think more consistent with Python / the C++ meaning of the actual operator.