IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python function

msgpack_numpy_decoder

msgpack_numpy_decoder()โ€‹

max.pipelines.modeling.types.msgpack_numpy_decoder(type_, copy=False)

source

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