---
title: get_cache_tensors
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/others/llmdatadistdev/llmpr_42_0042.html
sourcePath: /source/zh/canncommercial/900/others/llmdatadistdev/llmpr_42_0042.html
indexId: 8e8891932d387602310ff6e5004cb4ae1bb9e076a6a468817b4e3e1b6bbf5b7070
---
# get_cache_tensors

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | x |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | x |
| Atlas 推理系列产品 | x |
| Atlas 训练系列产品 | x |


说明：针对 Atlas A2 训练系列产品 / Atlas A2 推理系列产品 ，仅支持Atlas 800I A2 推理服务器、A200I A2 Box 异构组件。


#### 函数功能

获取cache tensor。


#### 函数原型

```
get_cache_tensors(cache: KvCache, tensor_index: int = 0) -> List[Tensor]
```


#### 参数说明

| 参数名称 | 数据类型 | 取值说明 |
| --- | --- | --- |
| cache | KvCache | 要获取的tensor所在的KvCache。 |
| tensor\_index | int | 要获取的tensor在Cache中的index。 |


#### 调用示例

```
tensors = kv_cache_manager.get_cache_tensors(kv_cache, 0)
```


#### 返回值

正常情况下返回List[Tensor]。

参数错误可能抛出TypeError或ValueError。

执行时间超过sync_kv_timeout配置会抛出LLMException异常。


#### 约束说明

本接口不支持并发调用。
