IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /get-started.md).

Python function

cache_tensor

cache_tensor()​

max.nn.common_layers.kv_cache.cache_tensor(shards, mapping=None)

source

Returns one cache input’s shards as a tensor, keeping real ones.

Like from_shard_values(), except that real tensors, as a decoder called eagerly gets, keep their buffers, so ops that write the cache in place write the decoder’s buffers.

Parameters:

Returns:

A tensor backed by shards.

Return type:

Tensor