Internal Associated APIs
During operator prototype registration, tiling implementation, and shape inference, some auxiliary data structures and APIs are called in the external open APIs, which are referred to as internal associated APIs. Developers will not directly call internal associated APIs, so this section is only for brief introduction.
KernelContext Class
This class encapsulates the underlying data structure KernelRunContext, including the numbers of operator inputs and outputs, input and output data information, compute_node_info, and kernel_extend_info required for kernel execution.
API |
Function |
|---|---|
GetInput |
Obtains the input chain pointer. Chain is a class that can be used to store any type of data. |
GetInputNum |
Obtains the number of kernel inputs. |
GetInputPointer |
Obtains the pointer to input data. This function first obtains the input chain and then obtains the pointer from the input chain. |
GetInputStrPointer |
Obtains the pointer to the input string. This function first obtains the input chain and then obtains the pointer from the input chain. |
GetInputValue |
Obtains the value of input data. This function first obtains the input chain and then obtains the value from the input chain. |
GetOutput |
Obtains the output chain pointer. |
GetOutput2 |
Obtains the output chain pointer. |
GetOutputNum |
Obtains the number of kernel outputs. |
GetOutputPointer |
Obtains the pointer to output data. This function first obtains the output chain and then obtains the pointer from the output chain. |
GetContext |
Obtains the lower-layer context structure. |
GetKernelExtend |
Obtains the pointer to the kernel extension information. |
GetComputeNodeExtend |
Obtains the pointer to the compute node information. |
MutableInput |
Obtains the input chain pointer. |
MutableInputPointer |
Obtains the pointer to input data. This function first obtains the input chain and then obtains the pointer from the input chain. |
IsInlineSize |
Determines whether a data element is stored in inline mode based on the data length. Inline storage indicates that data is saved in the context without the need for separate memory allocation. |
TilingParseContext Class
The information required for TilingParse is stored in this class. This class provides context information for writing the TilingParse function of an operator. The required information can be obtained from this class during TilingParse.
API |
Function |
|---|---|
GetCompiledJson |
Obtains the JSON string generated during operator build. |
GetCompiledInfo |
Obtains the CompiledInfo instance. |
GetPlatformInfo |
Obtains the fe::PlatFormInfos pointer. |
Chain Class
Chain is a class that can be used to store any type of data. You can use the Set API to save data, and the GetPointer or GetValue method to obtain the saved data.
API |
Function |
|---|---|
GetPointer |
Obtains the pointer that points to the data stored in the chain. |
GetValue |
Obtains the value of the data stored in the chain. |
Set |
Sets the data to the chain. During setting of the data pointer, the deleter is called to delete the data stored in the chain. |
SetWithDefaultDeleter |
Sets the data to the chain. During setting of the data pointer, the deleter is called to delete the data stored in the chain. |
HasDeleter |
Checks whether data stored in the current chain contains the deleter. |
ContinuousBuffer Class
The ContinuousBuffer class is used to continuously store data of any type. Each data element is converted into a uint8_t array for storage, and each memory unit is called a buffer. ContinuousBuffer uses two attributes to describe the stored data, namely the number of storage buffers and the memory offset offsets_ of each buffer. Every buffer is continuous in the memory.
API |
Function |
|---|---|
GetNum |
Obtains the number of buffers. |
GetTotalLength |
Obtains the total length of the current instance. |
Get |
Obtains the buffer pointer and length information. |
KernelExtendInfo Class
This class is used to store additional information for kernel running, including the kernel name, type, index of the kernel types used for profiling registration, and index of the compute node names.
API |
Function |
|---|---|
GetKernelName |
Obtains the kernel name. |
SetKernelName |
Sets the kernel name. |
GetKernelType |
Obtains the kernel type. An operator can correspond to multiple kernels, so it can correspond to multiple kernel types. |
SetKernelType |
Sets the kernel type. |
SetKernelTypeIdx |
Sets kernel_type_idx_ for profiling. It indicates the idx of the kernel type character string set during profiling. Use idx to replace the kernel type character string as the identifier to improve the speed. |
SetNodeNameIdx |
Sets compute_node_name_idx_ for profiling. During profiling, use idx to replace the node name string as the identifier to improve the speed. |
GetNodeNameIdx |
Obtains compute_node_name_idx_ for profiling. |
GetKernelTypeIdx |
Obtains kernel_type_idx_ for profiling. |
TensorOperateType
enum TensorOperateType {
kGetTensorAddress, ///< Obtain the tensor address.
kFreeTensor, ///< Free the tensor.
kPlusShareCount, ///< Share the tensor.
kTensorOperateType
};
StructSizeInfoBase Class
The StructSizeInfoBase class is used to store and obtain the sizes of tiling structures defined by Ascend C high-level APIs and users. It uses a singleton to implement a structure information library.
API |
Function |
|---|---|
GetInstance |
Obtains the singleton of the StructSizeInfoBase class. |
SetStructSize |
Sets the sizes of tiling structures defined by high-level APIs and users. |
GetStructSize |
Obtains the sizes of tiling structures defined by high-level APIs and users. |
TilingDataStructBase Class
The TilingDataStructBase class is used to record the information about the tiling structure construction process. The following APIs are provided:
API |
Function |
|---|---|
GetInstance |
Obtains the singleton of the TilingDataStructBase class. |
RecordTilingStruct |
Used by the framework to check whether different operators register different tiling structures with the same name. If yes, a warning is printed. |
OpExecuteContext Class
This class is used to save the contexts when single-operator execution APIs are called in graph mode.
API |
Function |
|---|---|
GetInputTensor |
Obtains the input tensor of a specified index. |
GetOptionalInputTensor |
Obtains the optional input tensor of a specified index. |
GetDynamicInputTensor |
Obtains the tensor with a dynamic number of inputs at a specified index. |
GetRequiredInputTensor |
Obtains the required input tensor of a specified index. |
GetOutputTensor |
Obtains the output tensor of a specified index. |
GetDynamicOutputTensor |
Obtains the tensor with a dynamic number of outputs at a specified index. |
GetRequiredOutputTensor |
Obtains the required output tensor of a specified index. |
GetStream |
Obtains the stream information of a delivered operator. |
GetOpExecuteFunc |
Obtains the execution callback function of a multi-kernel operator. |
MallocWorkspace |
Allocates workspaces. |
FreeWorkspace |
Frees workspaces. |
GetDeterministic |
Obtains configuration items for deterministic computing. |
GetAllowHf32 |
Obtains the allow_hf32 configuration item. |
GetPrecisionMode |
Obtains configuration items of a precision mode. |
OpExecutePrepareContext Class
This class is used to save contexts when single-operator first-phase execution APIs (preparing operator delivery parameters) are called in graph mode.
API |
Function |
|---|---|
GetInputTensor |
Obtains the input tensor of a specified index. |
GetOptionalInputTensor |
Obtains the optional input tensor of a specified index. |
GetDynamicInputTensor |
Obtains the tensor with a dynamic number of inputs at a specified index. |
GetRequiredInputTensor |
Obtains the required input tensor of a specified index. |
GetOutputTensor |
Obtains the output tensor of a specified index. |
GetDynamicOutputTensor |
Obtains the tensor with a dynamic number of outputs at a specified index. |
GetRequiredOutputTensor |
Obtains the required output tensor of a specified index. |
SetOpApiParamsWithDefaultDeleter |
Sets the parameter structure pointer passed to the operator delivery phase to the output chain. |
SetOpApiParams |
Sets the parameter structure pointer passed to the operator delivery phase to the output chain. |
SetWorkspaceSizes |
Sets the size of the workspace memory to be allocated. |
GetDeterministic |
Obtains configuration items for deterministic computing. |
GetAllowHf32 |
Obtains the allow_hf32 configuration item. |
GetPrecisionMode |
Obtains configuration items of a precision mode. |
OpExecuteLaunchContext Class
This class is used to save contexts when single-operator second-phase execution APIs (delivering operators) are called in graph mode.
API |
Function |
|---|---|
GetInputTensor |
Obtains the input tensor of a specified index. |
GetOptionalInputTensor |
Obtains the optional input tensor of a specified index. |
GetDynamicInputTensor |
Obtains the tensor with a dynamic number of inputs at a specified index. |
GetRequiredInputTensor |
Obtains the required input tensor of a specified index. |
GetOutputTensor |
Obtains the output tensor of a specified index. |
GetDynamicOutputTensor |
Obtains the tensor with a dynamic number of outputs at a specified index. |
GetRequiredOutputTensor |
Obtains the required output tensor of a specified index. |
GetOpApiParams |
Sets the output data of the first phase to the output chain. |
GetWorkspaceSizes |
Obtains the size of the allocated workspace memory. |
GetWorkspaceAddrs |
Obtains the address of the allocated workspace. |
GetStream |
Obtains the stream information of a delivered operator. |
OpImplSpaceRegistryV2 Class
This class is used to store operator deliverables, manage and isolate operator deliverables of different offline models and different versions in the default installation directory.
API |
Function |
|---|---|
OpImplSpaceRegistryV2 |
Construct an object of the OpImplSpaceRegistryV2 class. |
~OpImplSpaceRegistryV2 |
Destructs an object of the OpImplSpaceRegistryV2 class. |
AddSoToRegistry |
Reads the .so path and parses the operator deliverables contained in the .so file. |
GetOpImpl |
Obtains all deliverables of an operator type in the version. |
DefaultOpImplSpaceRegistryV2 Class
Singleton class, which is used to manage the operator deliverable registration center in the default installation path. It is called the default registration center and has only one copy in a process.
Function Name |
Description |
|---|---|
GetSpaceRegistry |
Obtains the space registry of the default registration center. The space registry corresponds to an object of the OpImplSpaceRegistryV2 class. |
SetSpaceRegistry |
Sets the space registry of the default registration center. The space registry corresponds to an object of the OpImplSpaceRegistryV2 class. |
ClearSpaceRegistry |
Clears all space registries stored in the current default registration center. |
OppSoDesc Class
This class is used to organize the so path of the operator deliverables and the type of the package (built-in or custom operator package) to which so belongs.
Function Name |
Description |
|---|---|
OppSoDesc |
Constructor of so description information, including an input so path and the so description information. |
OppSoDesc |
Constructor of so description information, including a group of input so paths and the so description information. |
OppSoDesc |
Move constructor of the so description information |
GetSoPaths |
Obtains the so path in the current so description information. |
GetPackageName |
Obtains the package name in the current so description information. |
OppPackageUtils Class
This class is used to load all .so files in the installation directory based on priorities, in the following descending order: custom operators, built-in installation directory operators.
Function Name |
Description |
|---|---|
LoadAllOppPackage |
Static member method, which is used to load all .so files in the installation directory. |
OppImplVersionTag Class
enum class OppImplVersionTag {
kOpp,
kOppKernel,
// add new version definitions here
kVersionEnd = 20
};
OpImplFunctions Class
This class is used to store information (such as shape, ShapeRange, DataType inference, tiling computation, and value dependency) registered by operators. It cannot be extended.
Function Name |
Description |
|---|---|
operator= |
Copy assignment function. |
HasDataDependency |
Determines whether an operator has registered the InferShape value dependency to indicate that shape inference depends on the input value. |
IsInputDataDependency |
Determines whether input index of an operator depends on the InferShape value. index indicates the prototype input sequence of the operator. |
SetInputDataDependency |
Sets input index of an operator as InferShape value dependency. index indicates the prototype input sequence of the operator. |
HasHostInput |
Determines whether the registered input address of an operator needs to be a host address. |
IsHostInput |
Determines whether input index of an operator needs to be a host address. index indicates the prototype input sequence of the operator. |
SetHostInputs |
Sets input index of an operator to be a host address. index indicates the prototype input sequence of the operator. |
HasTilingInputDataDependency |
Determines whether an operator has registered the tiling value dependency to indicate that tiling computation depends on the input value. |
IsTilingInputDataDependency |
Determines whether input index of an operator depends on the tiling value. index indicates the prototype input sequence of the operator. |
SetTilingInputDataDependency |
Sets input index of an operator as tiling value dependency. index indicates the prototype input sequence of the operator. |
IsSupportTilingDependencyPlacement |
Determines whether an operator supports the device type specified by an input parameter for tiling computation. |
SetTilingDependencyPlacement |
Sets the device type for the tiling computation of an operator. This setting is required when the operator registers the tiling value dependency. |
IsOutputShapeDependOnCompute |
Determines whether the output shape of an operator can be obtained only after the computation is complete. |
IsOutputShapeDependOnCompute |
Determines whether output shape index of an operator can be obtained only after the computation is complete. index indicates the prototype input sequence of the operator. |
SetOutputShapeDependOnCompute |
Sets output shape index of an operator to be obtained only after the computation is complete. index indicates the prototype input sequence of the operator. |
OpImplFunctionsV2 Class
Subclass of OpImplFunctions. It can be extended and is used to store information such as GenerateTask and CheckSupport registered by operators.
Function Name |
Description |
|---|---|
OpImplFunctionsV2 |
Default constructor. |
operator= |
Copy assignment function. |