---
title: SetResourceContext
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/atlasgeapi_07_0601.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/atlasgeapi_07_0601.html
indexId: 82647beb9f650c8a50fc2bc09250330af1c1732669911818103c6b3762b135b972
---
# SetResourceContext

#### 产品支持情况

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


#### 头文件/库文件

- 头文件：#include <graph/inference_context.h>
- 库文件：libgraph.so


#### 功能说明

为标识为key的资源，设置资源上下文对象，并交由资源上下文管理器管理。

此接口一般由写类型的资源类算子调用，如stack push等。


#### 函数原型

```
graphStatus SetResourceContext(const ge::AscendString &key, ResourceContext *resource_context)
```


#### 参数说明

| 参数名 | 输入/输出 | 描述 |
| --- | --- | --- |
| key | 输入 | 资源唯一标识。 |
| resource\_context | 输入 | 资源上下文对象指针，可参见GetResourceContext接口的返回值说明。 |


#### 返回值说明

graphStatus类型：GRAPH_SUCCESS，代表成功；GRAPH_FAILED，代表失败。


#### 约束说明

若使用Create接口创建InferenceContext时未传入resource context管理器指针，则该接口返回失败。
