Python function
msgpack_numpy_decoder
msgpack_numpy_decoder()โ
max.interfaces.msgpack_numpy_decoder(type_, copy=False)
Create a decoder function for the specified type.
-
Parameters:
-
- type โ The type to decode into
- copy (bool) โ Copy numpy arrays if true. Defaults to True. Copy is set to True by default because most downstream usage of deserialized tensors are MAX driver tensors, which require owned numpy arrays. This is a constraint imposed by dlpack & numpy where we cannot create a buffer from read-only data. While there is a performance benefit during deserialization to removing copies by default, this often just moves the work downstream to an implicit copy during Buffer.from_numpy. As a result, it is easier to make the copy explicit here and maintain the pattern that all numpy arrays used in MAX are owned by the current process.
- type_ (Any)
-
Returns:
-
A pickleable decoder instance that decodes bytes into the specified type
-
Return type:
-
MsgpackNumpyDecoder
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!