Skip to content

Are there equivalents to numpy.tobytes(), numpy.frombuffer() in mlx? #1303

Answered by awni
mzbac asked this question in Q&A
Discussion options

You must be logged in to vote

MLX implements the Python buffer protocol. So you can do:

>>> a =mx.array([1,2,3])
>>> x = memoryview(a)
>>> mx.array(x)
array([1, 2, 3], dtype=int32)

I'm curious though why not use mx.distributed? It will generally be faster as it keeps the communication ops inside the graph and avoids unnecessary copies.

Replies: 1 comment 3 replies

Comment options

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

@angeloskath
Comment options

@mzbac
Comment options

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