---
title: 简介
description: "获取推理上下文对象，并设置相应对象的形状和数据类型，主要用于资源类算子。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/atlasgeapi_07_0591.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/atlasgeapi_07_0591.html
indexId: 830fc631b5d05e0b779e029c6e62905fea8c150815d2fcb1beb34799eed6bc3772
---
# 简介

获取推理上下文对象，并设置相应对象的形状和数据类型，主要用于资源类算子。

#### 需要包含的头文件

```
#include <graph/inference_context.h>
```


#### Public成员函数

```
void SetInputHandleShapesAndTypes(std::vector<std::vector<ShapeAndType>> &&shapes_and_types)
void SetOutputHandleShapesAndTypes(const std::vector<std::vector<ShapeAndType>> &shapes_and_types)
void SetOutputHandleShapesAndTypes(std::vector<std::vector<ShapeAndType>> &&shapes_and_types)
const std::vector<std::vector<ShapeAndType>> &GetInputHandleShapesAndTypes() const
const std::vector<std::vector<ShapeAndType>> &GetOutputHandleShapesAndTypes() const
void SetMarks(const std::vector<std::string> &marks)
void SetMarks(const std::vector<AscendString> &marks)
const std::vector<std::string> &GetMarks() const
void GetMarks(std::vector<AscendString> &marks) const
static std::unique_ptr<InferenceContext> Create(
void *resource_context_mgr = nullptr
)
ResourceContext *GetResourceContext(const ge::AscendString &key)
graphStatus SetResourceContext(const ge::AscendString &key, ResourceContext *resource_context)
graphStatus RegisterReliedOnResourceKey(const ge::AscendString &key)
graphStatus AddChangedResourceKey(const ge::AscendString &key)
const std::set<ge::AscendString>& GetReliedOnResourceKeys() const
const std::set<ge::AscendString>& GetChangedResourceKeys() const
void ClearChangedResourceKeys()
```
