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

#### 产品支持情况

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


#### 头文件/库文件

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


#### 功能说明

通过资源标识key来获取对应的资源上下文对象。


#### 函数原型

```
ResourceContext *GetResourceContext(const ge::AscendString &key)
```


#### 参数说明

| 参数名 | 输入/输出 | 描述 |
| --- | --- | --- |
| key | 输入 | 资源的唯一标识。由资源类算子infershape函数指定。 |


#### 返回值说明

资源上下文对象。

基础定义如下，资源类算子可以基于此扩展。

```
struct ResourceContext {  virtual
~
ResourceContext() {}};
```

用于保存资源相关信息，如shape、datatype等。


#### 约束说明

若使用Create接口创建InferenceContext时未传入resource context管理器指针，则该接口返回空指针，因此使用其返回值之前需要判空。
