目录

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:

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.
Class and structure CompileTimeTensorDesc Describes the tensor information during compilation, including the dtype and format information.
Class and structure ComputeNodeInfo Serializes and saves operator compilation information so that the information can be efficiently obtained during graph execution.
Class and structure ContinuousVectorVector Allocates a continuous space in the memory to store data descriptions and actual data elements. The element type is ContinuousVector.
Class and structure ContinuousVector This class is a POD class, which allocates a continuous space in the memory to store descriptions and actual memory data.
Class and structure ExpandDimsType The ExpandDimsType class defines the rules for expanding dimensions based on the shapes resulting from the expansion.
Class and structure 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.
Class and structure InferDataTypeContext Context structure used for datatype derivation.
Class and structure InferShapeContext Context structure used for shape derivation.
Class and structure InferShapeRangeContext Context structure used for shape range derivation.
Class and structure OpImplRegisterV2 As a registration API class, OpImplRegisterV2 provides a series of operator prototype registration APIs for you to register information of a specific operator type, including the Tiling function, Infershape function, and private attributes. This class is indirectly used when you call the operator prototype registration API for registration.
Class and structure Range Describes the upper and lower bounds of an object.
Class and structure RuntimeAttrs Stores operator attributes.
Class and structure Shape Describes the shape of a tensor.
Class and structure StorageFormat Includes the original format, runtime format, and dimension expansion rule.
Class and structure StorageShape This class describes shapes of a tensor, including origin_shape and storage_shape.
Class and structure TensorPlacementUtils Provides a group of functions to determine the position of TensorPlacement.
Class and structure Tensor Describes the information and behavior of a tensor object, including the shape, format, datatype, and tensor data.
Class and structure TilingContext Context structure used for operator tiling.
Class and structure TilingData Stores tiling data.
Class and structure 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.
Enumeration TensorPlacement Enumerates the tensor locations.

ge Namespace

Table 2 ge namespace

Category Data Structure/API Function
Class and structure Allocator The external allocator registered by you can be used. The header file is stored in the include/ge/ge_allocator.h directory under the file storage directory after the CANN software is installed.
Class and structure AscendString

Stores strings.

- The header file is located in include/graph/ascend_string.h in the file storage path after the CANN software is installed.

- Library file: libgraph.so

Class and structure AttrValue

Stores attribute values.

- The header file is located in include/graph/attr_value.h in the file storage path after the CANN software is installed.

- Library file: libgraph_base.so

Class and structure AutoMappingSubgraphIOIndexFuncRegister An internal associated API, used during plugin adaptation, is called indirectly and remains imperceptible to developers.
Class and structure FrameworkRegistry An internal associated API, used during plugin adaptation, is called indirectly and remains imperceptible to developers.
Class and structure InferenceContext Obtains the inference context object and sets the shape and data type of the object. It is mainly used for resource operators.
Class and structure InferFormatFuncRegister Registers the operator InferFormat function. This API is referenced by other header files and is not directly called by operator developers.
Class and structure InferShapeFuncRegister Registers the operator InferShape function. This API is referenced by other header files and is not directly called by operator developers.
Class and structure InferValueRangeFuncRegister This API registers the operator InferValueRangeFuncRegister function. It is referenced by other header files and is not directly called by operator developers.
Class and structure 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.
Class and structure MemBlock Used together with the Allocator class to support the external allocator function registered by you. The header file is stored in the include/ge/ge_allocator.h directory under the file storage directory after the CANN software is installed.
Class and structure OperatorCreatorRegister This API registers an operator prototype and is referenced by other header files. Therefore, it is not directly called by operator developers.
Class and structure OperatorFactory An internal associated API, which is referenced by other header files and is not directly called by operator developers.
Class and structure Operator

Operator class.

- The header file is located in include/graph/operator.h in the file storage path after the CANN software is installed.

- Library file: libgraph.so

Class and structure OpReceiver Registers the mapping relationship when writing adapter plugins to adapt operators for AI framework integration.
Class and structure OpRegistrationData Registers the mapping relationship when writing adapter plugins to adapt operators for AI framework integration.
Class and structure Promote Indicates that the output data type is the promotion type between the data types specified by the input or attribute.
Class and structure ShapeAndType Sets and obtains the shape and data type of an object.
Class and structure Shape

Stores the shape information of a tensor.

- The header file is located in include/graph/tensor.h in the file storage path after the CANN software is installed.

- Library file: libgraph_base.so

Class and structure TensorDescInfo Stores the tensor description.
Class and structure TensorDesc

Accesses and manages the tensor description.

- The header file is located in include/graph/tensor.h in the file storage path after the CANN software is installed.

- Library file: libgraph_base.so

Class and structure TensorType Defines the data types supported by the input or output.
Class and structure Tensor

Tensor structure.

- The header file is located in include/graph/tensor.h in the file storage path after the CANN software is installed.

- Library file: libgraph_base.so

Class and structure TypeUtils Type conversion utility class.
Class and structure VerifyFuncRegister Registers the operator verifyFunc function. This API is referenced by other header files and is not directly called by operator developers.
Function ConvertToAscendString A template function. It takes a template parameter T and converts it to the AscendString type. It is mainly used to convert strings of different types to those of the AscendString type.
Function ConvertToListAscendString Defines a template function ConvertToListAscendString to convert strings of different types to those of the AscendString type.
Function GetC0Format Obtains the value of C0 format based on the actual format.
Function GetC0Value Parses C0 format information from the actual format.
Function GetFormatFromC0 Obtains the actual format based on the input format and C0 format.
Function GetFormatFromSub Obtains the actual format based on the input primary format and sub-format.
Function GetFormatFromSubAndC0 Obtains the actual format based on the input primary format, sub-format, and C0 format.
Function GetFormatName Obtains the string description of the format based on the input format type.
Function GetPrimaryFormat Parses primary format information from the actual format.
Function GetSizeByDataType Obtains the memory size occupied by the passed data_type.
Function GetSizeInBytes Obtains the total memory size occupied by data_type (number specified by element_count) based on the input element_count and data_type.
Function GetSubFormat Parses sub-format information from the actual format.
Function HasC0Format Returns if the actual format contains a C0 format.
Function HasSubFormat Returns if the actual format contains a sub-format.
Type ge::graphStatus Return code status description.
Enumeration DataType Enumerates the data types.
Enumeration Format Data format enum values.
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.
Macro COMMON_INFER_FUNC_REG Registers the InferShape function of an operator.
Macro DECLARE_ERRORNO Registers error codes along with their corresponding descriptions.
Macro ELMTWISE_INFER_SHAPEANDTYPE Encapsulated macro of common functions, facilitating the development of the InferShape function. This API sets the output shape and data type based on the input shape and data type.
Macro IMPLEMT_COMMON_INFERFUNC Encapsulates the Common_InferShape function of an operator.
Macro IMPLEMT_INFERFORMAT_FUNC Encapsulates the inferFormat function of an operator.
Macro IMPLEMT_INFERFUNC Encapsulates the InferShape function of an operator.
Macro IMPLEMT_VERIFIER Encapsulates the Verify function of an operator.
Macro INFER_FORMAT_FUNC_REG Registers the InferFormat function of an operator.
Macro INFER_FUNC_REG Registers the InferShape function of an operator.
Macro Prototype Definition (REG_OP) Defines the operator prototype.
Macro Prototype Definition Derivative API Description Defines the prototype definition derivative APIs.
Macro VERIFY_FUNC_REG Registers the Verify function of an operator.