Basic Data Structures and API List

This document describes the basic data structures and APIs required for operator development and graph development. The data structures and APIs are classified by namespace as follows:

  • GE

    Graph Engine (GE) is a general namespace dedicated to graph construction and compilation. It provides a rich set of APIs for building and managing complex graph structures. With universality and flexibility, it can meet various graph processing requirements in the design and compilation processes.

  • gert

    GE Runtime (gert) is the namespace designed for the runtime environment and provides a series of high-performance data structures to ensure optimal performance during execution.

gert Namespace

Table 1 gert namespace

Category

Data Structure/API

Function

Class and structure

AnchorInstanceInfo

Describes the relationship between the input of the IR definition prototype of an operator and the actual input.

The header file is in include/exe_graph/runtime/compute_node_info.h under the CANN component directory.

CompileTimeTensorDesc

Describes the tensor information during compilation, including the dtype and format information.

The header file is in include/exe_graph/runtime/compute_node_info.h under the CANN component directory.

ComputeNodeInfo

Serializes and saves operator compilation information so that the information can be efficiently obtained during graph execution.

The header file is in include/exe_graph/runtime/compute_node_info.h under the CANN component directory.

ContinuousVectorVector

Allocates a continuous space in the memory to store data descriptions and actual data elements. The element type is ContinuousVector.

The header file is in include/exe_graph/runtime/continuous_vector.h under the CANN component directory.

ContinuousVector

This class is a POD class, which allocates a continuous space in the memory to store descriptions and actual memory data.

The header file is in include/exe_graph/runtime/continuous_vector.h under the CANN component directory.

ExpandDimsType

Defines the rules for expanding dimensions based on the shapes resulting from the expansion.

The header file is in include/exe_graph/runtime/expand_dims_type.h under the CANN component directory.

ExtendedKernelContext

Base class of InferShapeContext and TilingContext. The methods provided in ExtendedKernelContext, such as the APIs for obtaining the operator type, name, and attributes, can be called in the InferShape and tiling functions.

The header file is in include/exe_graph/runtime/extended_kernel_context.h under the CANN component directory.

InferDataTypeContext

Context structure used for datatype derivation.

The header file is in include/exe_graph/runtime/infer_datatype_context.h under the CANN component directory.

InferShapeContext

Context structure used for shape derivation.

The header file is in include/exe_graph/runtime/infer_shape_context.h under the CANN component directory.

InferShapeRangeContext

Context structure used for shape range derivation.

The header file is in include/exe_graph/runtime/infer_shape_range_context.h under the CANN component directory.

OpImplRegisterV2

As a registration API class, OpImplRegisterV2 provides a series of operator prototype registration APIs for users to register information of a specific operator type, including the tiling function, Infershape function, and private attributes. This class is indirectly used when users call the operator prototype registration API for registration.

The header file is in include/register/op_impl_registry.h under the CANN component directory.

Range

Describes the upper and lower bounds of an object.

The header file is in include/exe_graph/runtime/range.h under the CANN component directory.

RuntimeAttrs

Stores operator attributes.

The header file is in include/exe_graph/runtime/runtime_attrs.h under the CANN component directory.

Shape

Describes the shape of a tensor.

The header file is in include/exe_graph/runtime/shape.h under the CANN component directory.

StorageFormat

Includes the original format, runtime format, and dimension expansion rule.

The header file is in include/exe_graph/runtime/storage_format.h under the CANN component directory.

StorageShape

Describes shapes of a tensor, including origin_shape and storage_shape.

The header file is in include/exe_graph/runtime/storage_shape.h under the CANN component directory.

TensorData

Stores tensor data.

The header file is in include/exe_graph/runtime/tensor_data.h under the CANN component directory.

TensorPlacementUtils

Provides a group of functions to determine the position of TensorPlacement.

The header file is in include/exe_graph/runtime/tensor_data.h under the CANN component directory.

Tensor

Describes the information and behavior of a tensor object, including the shape, format, datatype, and tensor data.

The header file is in include/exe_graph/runtime/tensor.h under the CANN component directory.

TilingContext

Context structure used for operator tiling.

The header file is in include/exe_graph/runtime/tiling_context.h under the CANN component directory.

TilingData

Stores tiling data.

The header file is in include/exe_graph/runtime/tiling_data.h under the CANN component directory.

TypedContinuousVector

Inherits from the ContinuousVector class. Unlike the ContinuousVector class, MutableData and GetData return addresses of a specified type instead of void *. Therefore, Typed is added to the class name.

The header file is in include/exe_graph/runtime/continuous_vector.h under the CANN component directory.

Enum

TensorPlacement

Enumerates the tensor locations.

The header file is in include/exe_graph/runtime/tensor_data.h under the CANN component directory.

GE Namespace

Table 2 GE namespace

Category

Data Structure/API

Function

Class and structure

Allocator

Supports the external allocator registered by users.

The header file is in include/ge/ge_allocator.h under the CANN component directory.

AscendString

Stores strings.

  • The header file is in include/graph/ascend_string.h under the CANN component directory.
  • Library file: libgraph.so

AttrValue

Stores attribute values.

  • The header file is in include/graph/attr_value.h under the CANN component directory.
  • Library file: libgraph_base.so

AutoMappingSubgraphIOIndexFuncRegister

An internal associated API, used during plugin adaptation, is called indirectly and remains imperceptible to developers.

FrameworkRegistry

An internal associated API, used during plugin adaptation, is called indirectly and remains imperceptible to developers.

InferenceContext

Obtains the inference context object and sets the shape and data type of the object for resource operators.

The header file is in include/graph/inference_context.h under the CANN component directory.

InferFormatFuncRegister

Registers the operator InferFormat function. This API is referenced by other header files and is not directly called by the operator developer.

InferShapeFuncRegister

Registers the operator infershape function. This API is referenced by other header files and is not directly called by the operator developer.

InferValueRangeFuncRegister

Registers the operator InferValueRangeFuncRegister function. This API is referenced by other header files and is not directly called by the operator developer.

ListTensorType

Defines the data types supported by the input or output. It is the encapsulation of TensorType and is used to list the multiple supported data types.

The header file is in include/graph/types.h under the CANN component directory.

MemBlock

Used together with the Allocator class to support the external allocator registered by users.

The header file is in include/ge/ge_allocator.h under the CANN component directory.

OperatorCreatorRegister

Registers an operator prototype and is referenced by other header files. Therefore, it is not directly called by the operator developer.

OperatorFactory

An internal associated API, which is referenced by other header files and is not directly called by the operator developer.

Operator

Operator class.

  • The header file is in include/graph/operator.h under the CANN component directory.
  • Library file: libgraph.so

OpReceiver

Receives the registration information of custom operators for the development of plugins to adapt to AI frameworks.

The header file is in include/register/register.h under the CANN component directory.

OpRegistrationData

Registers the mapping relationship when writing adapter plugins to adapt operators for AI framework integration.

The header file is in include/register/register.h under the CANN component directory.

Promote

Indicates that the output data type is the promotion type between the data types specified by the input or attribute.

The header file is in include/graph/types.h under the CANN component directory.

ShapeAndType

Sets and obtains the shape and data type of an object.

The header file is in include/graph/inference_context.h under the CANN component directory.

Shape

Stores the shape information of a tensor.

  • The header file is in include/graph/tensor.h under the CANN component directory.
  • Library file: libgraph_base.so

TensorDescInfo

Stores the tensor description.

TensorDesc

Accesses and manages the tensor description.

  • The header file is in include/graph/tensor.h under the CANN component directory.
  • Library file: libgraph_base.so

TensorType

Defines the data types supported by the input or output.

Tensor

Tensor structure.

  • The header file is in include/graph/tensor.h under the CANN component directory.
  • Library file: libgraph_base.so

TypeUtils

Type conversion tool class.

The header file is in include/graph/utils/type_utils.h under the CANN component directory.

VerifyFuncRegister

Registers the operator verifyFunc function. This API is referenced by other header files and is not directly called by the operator developer.

Function

ConvertToAscendString

A template function to convert strings of different types to those of the AscendString type. Accepts a template parameter T and converts it to the AscendString type.

The header file is in include/graph/operator_reg.h under the CANN component directory.

ConvertToListAscendString

Defines a template function ConvertToListAscendString to convert strings of different types to those of the AscendString type.

The header file is in include/graph/operator_reg.h under the CANN component directory.

GetC0Format

Obtains the value of C0 format based on the actual format.

The header file is in include/graph/types.h under the CANN component directory.

GetC0Value

Parses C0 format information from the actual format.

The header file is in include/graph/types.h under the CANN component directory.

GetFormatFromC0

Obtains the actual format based on the input format and C0 format.

The header file is in include/graph/types.h under the CANN component directory.

GetFormatFromSub

Obtains the actual format based on the input primary format and sub-format.

The header file is in include/graph/types.h under the CANN component directory.

GetFormatFromSubAndC0

Obtains the actual format based on the input primary format, sub-format, and C0 format.

The header file is in include/graph/types.h under the CANN component directory.

GetFormatName

Obtains the string description of the format based on the input format type.

The header file is in include/graph/types.h under the CANN component directory.

GetPrimaryFormat

Parses primary format information from the actual format.

The header file is in include/graph/types.h under the CANN component directory.

GetSizeByDataType

Obtains the memory size occupied by the passed data_type.

The header file is in include/graph/types.h under the CANN component directory.

GetSizeInBytes

Obtains the total memory size occupied by data_type (number specified by element_cout) based on the passed element_cout and data_type.

The header file is in include/graph/types.h under the CANN component directory.

GetSubFormat

Parses sub-format information from the actual format.

The header file is in include/graph/types.h under the CANN component directory.

HasC0Format

Returns if the actual format contains a C0 format.

The header file is in include/graph/types.h under the CANN component directory.

HasSubFormat

Returns if the actual format contains a sub-format.

The header file is in include/graph/types.h under the CANN component directory.

Type definition

ge::graphStatus

Return code status description.

The header file is in include/graph/ge_error_codes.h under the CANN component directory.

Enum

DataType

Data type enum values.

The header file is in include/graph/types.h under the CANN component directory.

Format

Data format enum values.

The header file is in include/graph/types.h under the CANN component directory.

Macro

BROADCAST_INFER

Encapsulated macro of common functions, facilitating the development of the InferShape function. This function sets the output shape based on the shapes of two inputs. This macro sets the shape only, and does not set the data type.

The header file is in include/graph/operator_reg.h under the CANN component directory.

COMMON_INFER_FUNC_REG

Registers the InferShape function of an operator.

The header file is in include/graph/operator_reg.h under the CANN component directory.

DECLARE_ERRORNO

Registers error codes along with their corresponding descriptions.

The header file is in include/register/register_error_codes.h under the CANN component directory.

ELMTWISE_INFER_SHAPEANDTYPE

Encapsulated macro of common functions, facilitating the development of the InferShape function. This API sets the output shape and dtype based on the input shape and dtype.

The header file is in include/graph/operator_reg.h under the CANN component directory.

IMPLEMT_COMMON_INFERFUNC

Encapsulates the Common_InferShape function of an operator.

The header file is in include/graph/operator_reg.h under the CANN component directory.

IMPLEMT_INFERFORMAT_FUNC

Encapsulates the inferFormat function of an operator.

The header file is in include/graph/operator_reg.h under the CANN component directory.

IMPLEMT_INFERFUNC

Encapsulates the InferShape function of an operator.

The header file is in include/graph/operator_reg.h under the CANN component directory.

IMPLEMT_VERIFIER

Encapsulates the Verify function of an operator.

The header file is in include/graph/operator_reg.h under the CANN component directory.

INFER_FORMAT_FUNC_REG

Registers the InferFormat implementation of an operator.

The header file is in include/graph/operator_reg.h under the CANN component directory.

INFER_FUNC_REG

Registers the InferShape function of an operator.

The header file is in include/graph/operator_reg.h under the CANN component directory.

Prototype Definition (REG_OP)

Prototype definition API.

The header file is in include/graph/operator_reg.h under the CANN component directory.

Prototype Definition Derivative APIs

Prototype definition derivative APIs.

The header file is in include/graph/operator_reg.h under the CANN component directory.

VERIFY_FUNC_REG

Registers the Verify function of an operator.

The header file is in include/graph/operator_reg.h under the CANN component directory.