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 as follows:
- Graph Engine (ge) namespace
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.
- GE Runtime (gert) namespace
gert is the namespace designed for the runtime environment and provides a series of high-performance data structures to ensure optimal performance during execution.
- C API
C API is a C language API for operator and graph development.
gert Namespace
Category |
Data Structure/API |
Function |
|---|---|---|
Class and structure |
Describes the relationship between the input of the IR prototype definition of the operator and the actual input. The header file is in include/exe_graph/runtime/compute_node_info.h under the CANN component directory. |
|
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. |
||
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. |
||
Manages the context for implementing function execution for operators on the host. The constructed context stores only pointers. To facilitate lifecycle and ownership management, the ContextHolder class is provided for resource management. The header file is in include/base/context_builder/context_holder.h under the CANN component directory. |
||
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. |
||
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. |
||
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. |
||
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. |
||
Context structure used for datatype derivation. The header file is in include/exe_graph/runtime/infer_datatype_context.h under the CANN component directory. |
||
InferFormatContext is inherited from ExtendedKernelContext and is a context class used for format derivation. The header file is located in include/graph/infer_format_context.h under the CANN component directory. |
||
Context structure used for shape derivation. The header file is in include/exe_graph/runtime/infer_shape_context.h under the CANN component directory. |
||
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. |
||
OpContextBuilderBase is the base class of each ContextBuilder. It is used to construct operator information in the subclass Context, including the operator type, name, number of input and output prototypes, number of input and output instances, and attributes. The header file is in include/base/context_builder/op_context_builder_base.h under the CANN component directory. |
||
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. |
||
OpInferDataTypeContextBuilder is used to construct InferDataTypeContext. The constructed Context serves as an input parameter during operator data type inference to obtain necessary operator input and output data. After the inference is complete, the result is written back to the context. The header file is in include/base/context_builder/op_infer_datatype_context_builder.h under the CANN component directory. |
||
OpInferShapeContextBuilder is used to construct InferShapeContext. The constructed Context serves as an input parameter during operator Shape inference to obtain necessary operator input and output data. After the inference is complete, the result is written back to the context. The header file is in include/base/context_builder/op_infer_shape_context_builder.h under the CANN component directory. |
||
OpInferShapeRangeContextBuilder is used to construct InferShapeRangeContext. The constructed context serves as an input parameter during operator ShapeRange inference to obtain necessary operator input and output data. After the inference is complete, the result is written back to the context. The header file is in include/base/context_builder/op_infer_shape_range_context_builder.h under the CANN component directory. |
||
Constructs a common KernelContext object, which is used as the input context of the operator Host in the actual execution phase. The header file is in include/base/context_builder/op_kernel_run_context_builder.h under the CANN component directory. |
||
OpTilingContextBuilder is used to construct TilingContext. The constructed context serves as an input parameter during operator tiling computation to obtain necessary data like the operator input and output. After the tilling computation is complete, the result is written back to the context. The header file is in include/base/context_builder/op_tiling_context_builder.h under the CANN component directory. |
||
OpTilingParseContextBuilder is used to construct TilingParseContext. The constructed context serves as an input parameter during operator TilingParse computation to obtain necessary operator input and output data. After the Parser computation is complete, the result is written back to the context. The header file is in include/base/context_builder/op_tiling_parse_context_builder.h under the CANN component directory. |
||
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. |
||
Stores operator attributes. The header file is in include/exe_graph/runtime/runtime_attrs.h under the CANN component directory. |
||
Describes the shape of a tensor. The header file is in include/exe_graph/runtime/shape.h under the CANN component directory. |
||
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. |
||
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. |
||
Stores tensor data. The header file is in include/exe_graph/runtime/tensor_data.h under the CANN component directory. |
||
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. |
||
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. |
||
Context structure used for operator tiling. The header file is in include/exe_graph/runtime/tiling_context.h under the CANN component directory. |
||
Stores tiling data. The header file is in include/exe_graph/runtime/tiling_data.h under the CANN component directory. |
||
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 |
Enumerates the tensor locations. The header file is in include/exe_graph/runtime/tensor_data.h under the CANN component directory. |
ge Namespace
Category |
Data Structure/API |
Function |
|---|---|---|
Class and structure |
Supports the external allocator registered by users. The header file is in include/ge/ge_allocator.h under the CANN component directory. |
|
Stores strings.
|
||
An internal associated API, used during plugin adaptation, is called indirectly and remains imperceptible to developers. |
||
An internal associated API, used during plugin adaptation, is called indirectly and remains imperceptible to developers. |
||
Functions as a template class with template parameter T. It is used to check whether an integer is within the valid range of the specified data type T. The header file is in include/utils/extern_math_util.h under the CANN component directory. |
||
Provides APIs for creating and managing tasks delivered to devices. The APIs allow developers to set or obtain the launch information about the tasks to be delivered to devices. The header file is in include/graph/kernel_launch_info.h under the CANN component directory. |
||
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. |
||
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. |
||
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. |
||
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. |
||
Receives the registration information of a custom pass.
|
||
Registers the mapping relationship of a custom pass.
|
||
Class and structure |
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. |
|
Stores the shape information of a tensor.
|
||
Stores the tensor description. The header file is in include/graph/types.h under the CANN component directory. |
||
Accesses and manages the tensor description.
|
||
Defines the data types supported by the input or output. The header file is in include/graph/types.h under the CANN component directory. |
||
Tensor structure.
|
||
Type conversion utility class. The header file is in include/graph/utils/type_utils.h under the CANN component directory. |
||
Function |
A template function to determine whether overflow occurs when two numbers are added. If no overflow occurs, the correct computation result is returned. The header file is in include/utils/extern_math_util.h under the CANN component directory. |
|
A template function to convert strings of different types to those of the AscendString type. Accepts a template argument T and converts it to the AscendString type. The header file is in include/graph/operator_reg.h under the CANN component directory. |
||
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. |
||
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. |
||
Parses C0 format information from the actual format. The header file is in include/graph/types.h under the CANN component directory. |
||
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. |
||
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. |
||
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. |
||
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. |
||
Parses primary format information from the actual format. The header file is in include/graph/types.h under the CANN component directory. |
||
Obtains the memory size occupied by the passed data_type. The header file is in include/graph/types.h under the CANN component directory. |
||
Obtains the total memory size occupied by data_type (number specified by element_count) based on the input element_count and data_type. The header file is in include/graph/types.h under the CANN component directory. |
||
Parses sub-format information from the actual format. The header file is in include/graph/types.h under the CANN component directory. |
||
Returns if the actual format contains a C0 format. The header file is in include/graph/types.h under the CANN component directory. |
||
Returns if the actual format contains a sub-format. The header file is in include/graph/types.h under the CANN component directory. |
||
A template function to determine whether overflow occurs when two numbers are multiplied. If no overflow occurs, the correct computation result is returned. The header file is in include/utils/extern_math_util.h under the CANN component directory. |
||
Type definition |
Return code status description. The header file is in include/graph/ge_error_codes.h under the CANN component directory. |
|
Enum |
Data type enum values. The header file is in include/graph/types.h under the CANN component directory. |
|
Data format enum values. The header file is in include/graph/types.h under the CANN component directory. |
||
Macro |
Registers error codes along with their corresponding descriptions. The header file is in include/register/register_error_codes.h under the CANN component directory. |
C API
Data Structure/API |
Function |
|---|---|
Data type enum values. The header file is in include/graph/c_types.h under the CANN component directory. |
|
Data format enum values. The header file is in include/graph/c_types.h under the CANN component directory. |