AllocateCache
产品支持情况
产品 |
是否支持 |
---|---|
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
函数功能
分配Cache。
函数原型
1 | Status AllocateCache(const CacheDesc &cache_desc, Cache &cache) |
参数说明
参数名称 |
输入/输出 |
取值说明 |
---|---|---|
cache_desc |
输入 |
Cache的描述。 |
cache |
输出 |
分配出的Cache,当该接口返回LLM_SUCCESS时有效。 |
调用示例
1 2 3 4 5 6 | CacheDesc kv_desc{}; kv_desc.num_tensors = 80; kv_desc.data_type = DT_FLOAT16; kv_desc.shape = {1, 256}; Cache cache; Status ret = llm_datadist.AllocateCache(kv_desc, cache); |
返回值
- LLM_SUCCESS:成功
- LLM_PARAM_INVALID:参数错误
- LLM_DEVICE_OUT_OF_MEMORY: device内存不足
- 其他:失败
约束说明
需要在Initialize接口初始化完成后调用。
仅支持参数“cache_desc”中的placement为CachePlacement::kDevice时,该接口生效。Cache的描述请参考CacheDesc。
父主题: 待废弃接口