---
title: 接口列表
description: "主要介绍Scope融合规则开发接口。"
url: https://www.hiascend.com/document/detail/zh/TensorFlowCommercial/latest/Convergence/tfscopedevg/atlassfpapi_07_0103.html
sourcePath: /source/zh/TensorFlowCommercial/900/Convergence/tfscopedevg/atlassfpapi_07_0103.html
indexId: 7d77ca60b0a8b7e13240bd35bb6cdeb689f1cff353f36119a813bfe5289748a484
---
# 接口列表

主要介绍Scope融合规则开发接口。

您可以在“${INSTALL_DIR}/include/register/scope/scope_fusion_pass_register.h”查看接口定义。${INSTALL_DIR}请替换为CANN软件安装后文件存储路径。以root用户安装为例，安装后文件默认存储路径为：/usr/local/Ascend/cann。

如下接口对应的库文件是：libregister.so。

#### Scope类


**表1 Scope类接口**

| 接口名称 | 简介 |
| --- | --- |
| Scope构造函数和析构函数 | Scope构造函数和析构函数。 |
| Init | 初始化Scope对象。 |
| Name | 获取Scope的名称。 |
| SubType | 获取Scope子类型名称。 |
| AllNodesMap | 获取和Scope相关联的nodes map。 |
| GetSubScope | 获取Scope的子Scope信息。 |
| LastName | 获取Scope名称字符串中，最后一个“/”分隔符后的字符串。 |
| GetAllSubScopes | 获取Scope关联的子Scope，子Scope关联的子Scope，层层递归下去，取得所有相关联的Scope集合。 |
| GetFatherScope | 获取Scope的父Scope信息。 |


#### FusionScopesResult类


**表2 FusionScopesResult类接口**

| 接口名称 | 简介 |
| --- | --- |
| FusionScopesResult构造函数和析构函数 | FusionScopesResult构造函数和析构函数。 |
| Init | 初始化FusionScopesResult对象。 |
| SetName | 设置Scope result的名称。 |
| SetType | 设置Scope result的类型。 |
| SetDescription | 设置Scope result的描述信息。 |
| Name | 获取Scope result的名称。 |
| Nodes | 获取Scope result中的nodes信息。 |
| InsertInputs | 在FusionScopesResult中插入融合算子的输入信息。 |
| InsertOutputs | 在FusionScopesResult中插入融合算子的输出信息。 |
| SetName | 设置InnerNodeInfo的名称。 |
| SetType | 设置InnerNodeInfo的类型。 |
| InsertInput | 在InnerNodeInfo中插入输入算子相关信息。 |
| InsertOutput | 在InnerNodeInfo中插入输出算子相关信息。 |
| BuildInnerNode | 构建InnerNode。 |
| SetInputFormat | 设置InnerNode输入格式。 |
| SetOutputFormat | 设置InnerNode输出算子格式。 |
| SetDynamicInputFormat | 设置DynamicInput格式。 |
| SetDynamicOutputFormat | 设置DynamicOutput格式。 |
| MutableOperator | 定义Operator信息。 |
| GetName | 获取InnerNodeInfo名。 |
| GetType | 获取InnerNodeInfo类型。 |
| GetInputs | 获取InnerNodeInfo输入信息。 |
| GetOutputs | 获取InnerNodeInfo输出信息。 |
| InnerNodeInfo构造函数和析构函数 | InnerNodeInfo构造函数和析构函数。 |
| kScopeToMultiNodes | 特殊定义的类型，融合结果中配置了这个类型表示希望将scope映射成多个D算子。 |
| kScopeInvalidType | 特殊定义的类型，融合结果中配置了这个类型表示有错误发生。 |
| kInputFromFusionScope | 表示小算子的输入来自scope边界。 |
| kOutputToFusionScope | 表示小算子输入到scope边界。 |
| CHECK\_INNER\_NODE\_CONDITION宏 | 检查FusionScopesResult是否满足条件。 |
| AddInnerNode | 增加InnerNode节点。 |
| MutableRecentInnerNode | 最近添加的InnerNode节点。 |
| MutableInnerNode | 获取指定index的InnerNode，获取之后可以对该InnerNode进行修改。 |
| CheckInnerNodesInfo | 检查InnerNodeInfo输入输出。 |


#### ScopeTree类


**表3 ScopeTree类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopeTree构造函数和析构函数 | ScopeTree构造函数和析构函数。 |
| Init | 初始化ScopeTree对象。 |
| GetAllScopes | 获取ScopeTree中包含的所有Scope信息。 |


#### ScopeGraph类


**表4 ScopeGraph类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopeGraph构造函数和析构函数 | ScopeGraph构造函数和析构函数。 |
| Init | 初始化ScopeGraph对象。 |
| GetScopeTree | 获取ScopeTree对象实例。 |
| GetNodesMap | 获取ScopeGraph中包含的nodes信息。 |


#### ScopeAttrValue类


**表5 ScopeAttrValue类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopeAttrValue构造函数和析构函数 | ScopeAttrValue构造函数和析构函数。 |
| SetIntValue | 设置ScopeAttrValue的整型值。 |
| SetFloatValue | 设置ScopeAttrValue的浮点类型值。 |
| SetStringValue | 设置ScopeAttrValue的string类型值。 |
| SetBoolValue | 设置ScopeAttrValue的布尔类型值。 |


#### ScopeBaseFeature类


**表6 ScopeBaseFeature类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopeBaseFeature构造函数和析构函数 | ScopeBaseFeature析构函数。 |
| Match | Scope融合匹配接口。 |


#### NodeOpTypeFeature类


**表7 NodeOpTypeFeature类接口**

| 接口名称 | 简介 |
| --- | --- |
| NodeOpTypeFeature构造函数和析构函数 | NodeOpTypeFeature构造函数和析构函数。 |
| Match | Scope融合匹配接口。 |


#### NodeAttrFeature类


**表8 NodeAttrFeature类接口**

| 接口名称 | 简介 |
| --- | --- |
| NodeAttrFeature构造函数和析构函数 | NodeAttrFeature构造函数和析构函数。 |
| Match | Scope融合匹配接口。 |


#### ScopeFeature类


**表9 ScopeFeature类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopeFeature构造函数和析构函数 | ScopeFeature构造函数和析构函数。 |
| Match | Scope融合匹配接口。 |


#### ScopePattern类


**表10 ScopePattern类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopePattern构造函数和析构函数 | ScopePattern构造函数和析构函数。 |
| SetSubType | Scope匹配到融合规则之后，设置该Scope的类型。 |
| AddNodeOpTypeFeature | 添加NodeOpTypeFeature对象到ScopePattern。 |
| AddNodeAttrFeature | 添加NodeAttrFeature对象到ScopePattern。 |
| AddScopeFeature | 添加ScopeFeature对象到ScopePattern。 |


#### ScopesResult类


**表11 ScopesResult类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopesResult构造函数和析构函数 | ScopesResult构造函数和析构函数。 |
| SetScopes | 设置ScopeResult中包含的scopes。 |
| SetNodes | 设置ScopeResult中包含的nodes。 |


#### ScopeBasePass类


**表12 ScopeBasePass类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopeBasePass构造函数和析构函数 | ScopeBasePass构造函数和析构函数。 |
| DefinePatterns | 方法定义，子类实现各自的融合策略并构建Patterns。 |
| PassName | 方法定义，定义scope融合规则的名称。 |
| LastMatchScopesAndOPs | 方法定义，子类实现scope匹配及运算符融合方法。 |
| GenerateFusionResult | 方法定义，子类实现各自的融合结果，并设置最终融合算子的输入和输出。 |


#### ScopeUtil类


**表13 ScopeUtil类接口**

| 接口名称 | 简介 |
| --- | --- |
| StringReplaceAll | 将字符串str中包含old\_value的字符串用new\_value替换。 |
| FreeScopePatterns | 释放ScopePattern集的资源。 |
| FreeOneBatchPattern | 释放一个batch包含的ScopePattern资源。 |


#### ScopeFusionPassRegistry类


**表14 ScopeFusionPassRegistry类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopeFusionPassRegistry析构函数 | ScopeFusionPassRegistry析构函数。 |
| GetInstance | 获得ScopeFusionPassRegistry单例对象。 |
| RegisterScopeFusionPass | 注册融合算子。 |


#### ScopeFusionPassRegistrar类


**表15 ScopeFusionPassRegistrar类接口**

| 接口名称 | 简介 |
| --- | --- |
| ScopeFusionPassRegistrar构造函数和析构函数 | ScopeFusionPassRegistrar构造函数和析构函数。 |


#### 宏


**表16 宏**

| 接口名称 | 简介 |
| --- | --- |
| REGISTER\_SCOPE\_FUSION\_PASS | 注册Scope融合算子的宏。 |
