API List

This topic describes the APIs for developing scope fusion patterns.

You can view the API definition in Ascend-CANN-Toolkit installation path/ascend-toolkit/latest/compiler/include/register/scope/scope_fusion_pass_register.h.

The library file corresponding to the following APIs is libregister.so.

Class Scope

Table 1 Scope class APIs

API

Introduction

Scope Constructor and Destructor

Constructs/Destructs a Scope object.

Init

Initializes a Scope object.

Name

Obtains the name of a scope.

SubType

Obtains the name of a scope subtype.

AllNodesMap

Obtains the node map associated with a scope,

GetSubScope

Obtains the subscope information of a scope.

LastNameGetAllSubScopes

Obtains the string after the last slash (/) in the scope name.

GetAllSubScopes

Obtains the subscopes associated with a scope. A collection of all the associated subscopes are obtained through recursion.

GetFatherScope

Obtains the parent scope information of a scope.

Class FusionScopesResult

Table 2 FusionScopesResult class APIs

API

Introduction

FusionScopesResult Constructor and Destructor

Constructs/Destructs a FusionScopesResult object.

Init

Initializes a FusionScopesResult object.

SetName

Specifies the name of a scope result.

SetType

Sets the scope result type.

SetDescription

Sets the description of a scope result.

Name

Obtains the scope result name.

Nodes

Obtains the node information in the scope result.

InsertInputs

Inserts the input information of the fused operator into FusionScopesResult.

InsertOutputs

Inserts the output information of the fused operator into FusionScopesResult.

SetName

Sets the name of an InnerNodeInfo object.

SetType

Sets the type of an InnerNodeInfo object.

InsertInput

Inserts the input operator information into an InnerNodeInfo object.

InsertOutput

Inserts the output operator information into an InnerNodeInfo object.

BuildInnerNode

Builds an inner node.

SetInputFormat

Sets the input format of an inner node.

SetOutputFormat

Sets the output operator format of an inner node.

SetDynamicInputFormat

Sets the dynamic input format.

SetDynamicOutputFormat

Sets the dynamic output format.

MutableOperator

Defines operator information.

GetName

Obtains the name of an InnerNodeInfo object.

GetType

Obtains the type of an InnerNodeInfo object.

GetInputs

Obtains the input information of an InnerNodeInfo object.

GetOutputs

Obtains the output information of an InnerNodeInfo object.

InnerNodeInfo Constructor and Destructor

Constructs/Destructs an InnerNodeInfo object.

kScopeToMultiNodes

Specially defined constant type, indicating that the scope will be mapped to multiple D operators.

kScopeInvalidType

Specially defined constant type, indicating that an error occurs.

kInputFromFusionScope

Defines a constant indicating that the input of small operators comes from the scope boundary.

kOutputToFusionScope

Defines a constant indicating that the output of small operators is output to the scope boundary.

Macro CHECK_INNER_NODE_CONDITION

Checks whether FusionScopesResult meets the requirements.

AddInnerNode

Adds an inner node.

MutableRecentInnerNode

Defines an inner node that is added recently.

MutableInnerNode

Obtains the InnerNode of a specified index. You can modify the returned InnerNode.

CheckInnerNodesInfo

Checks the input and output of an InnerNodeInfo object.

Class ScopeTree

Table 3 ScopeTree class APIs

API

Introduction

ScopeTree Constructor and Destructor

Constructs/Destructs a ScopeTree object.

Init

Initializes a ScopeTree object.

GetAllScopes

Obtains all scope information contained in a scope tree.

Class ScopeGraph

Table 4 ScopeGraph class APIs

API

Introduction

ScopeGraph Constructor and Destructor

Constructs/Destructs a ScopeGraph object.

Init

Initializes a ScopeGraph object.

GetScopeTree

Obtains a ScopeTree object.

GetNodesMap

Obtains the node information contained in a ScopeGraph object.

Class ScopeAttrValue

Table 5 ScopeAttrValue class APIs

API

Introduction

ScopeAttrValue Constructor and Destructor

Constructs/Destructs a ScopeAttrValue object.

SetIntValue

Sets the value of a ScopeAttrValue object to an integer.

SetFloatValue

Sets the floating-point value of a ScopeAttrValue object.

SetStringValue

Sets a value of the string type for a ScopeAttrValue object.

SetBoolValue

Sets the Boolean value of a ScopeAttrValue object.

Class ScopeBaseFeature

Table 6 ScopeBaseFeature class APIs

API

Introduction

ScopeBaseFeature Constructor and Destructor

Destructs a ScopeBaseFeature object.

Match

Matches a scope for fusion.

Class NodeOpTypeFeature

Table 7 NodeOpTypeFeature class APIs

API

Introduction

NodeOpTypeFeature Constructor and Destructor

Constructs/Destructs a NodeOpTypeFeature object.

Match

Matches a scope for fusion.

Class NodeAttrFeature

Table 8 NodeAttrFeature class APIs

API

Introduction

NodeAttrFeature Constructor and Destructor

Constructs/Destructs a NodeAttrFeature object.

Match

Matches a scope for fusion.

Class ScopeFeature

Table 9 ScopeFeature class APIs

API

Introduction

ScopeFeature Constructor and Destructor

Constructs/Destructs a ScopeFeature object.

Match

Matches a scope for fusion.

Class ScopePattern

Table 10 ScopePattern class APIs

API

Introduction

ScopePattern Constructor and Destructor

Constructs/Destructs a ScopePattern object.

SetSubType

Sets the type of a scope after it matches a fusion pattern.

AddNodeOpTypeFeature

Adds a NodeOpTypeFeature object to a ScopePattern object.

AddNodeAttrFeature

Adds a NodeAttrFeature object to a ScopePattern object.

AddScopeFeature

Adds a ScopeFeature object to a ScopePattern object.

Class ScopesResult

Table 11 ScopesResult class APIs

API

Introduction

ScopesResult Constructor and Destructor

Constructs/Destructs a ScopesResult object.

SetScopes

Sets the scopes contained in a ScopeResult object.

SetNodes

Sets the nodes contained in a ScopeResult object.

Class ScopeBasePass

Table 12 ScopeBasePass class APIs

API

Introduction

ScopeBasePass Constructor and Destructor

Constructs/Destructs a ScopeBasePass object.

DefinePatterns

Defines a pattern. The subclasses implement their own fusion policies and build patterns.

PassName

Defines the name of a scope fusion pattern.

LastMatchScopesAndOPs

Matches a scope and defines how operators are fused.

GenerateFusionResult

Generates a fusion result and sets the input and output of the final fused operator.

Class ScopeUtil

Table 13 ScopeUtil class APIs

API

Introduction

StringReplaceAll

Replaces the old_value string in str with new_value.

FreeScopePatterns

Releases the resources of the ScopePattern set.

FreeOneBatchPattern

Releases the ScopePattern resources contained in a batch.

Class ScopeFusionPassRegistry

Table 14 ScopeFusionPassRegistry class APIs

API

Introduction

ScopeFusionPassRegistry Destructor

Destructs a ScopeFusionPassRegistry object.

GetInstance

Obtains a ScopeFusionPassRegistry singleton object.

RegisterScopeFusionPass

Registers a fused operator.

Class ScopeFusionPassRegistrar

Table 15 ScopeFusionPassRegistrar class APIs

API

Introduction

ScopeFusionPassRegistrar Constructor and Destructor

Constructs/Destructs a ScopeFusionPassRegistrar object.

Macro

Table 16 Macro

API

Introduction

REGISTER_SCOPE_FUSION_PASS

Registers the macro of a Scope fused operator.