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 and are referred to as internal associated APIs. Developers will not directly call internal associated APIs, so this section is only for brief introduction.

CTilingDataClassFactory

The CTilingDataClassFactory class is used to register Ascend C high-level APIs and user-defined tiling structures. It is a factory class implemented through only one instance and is used in REGISTER_TILING_DATA_CLASS in TilingData Structure Registration.

Table 1 Member functions of the CTilingDataClassFactory class

Function

Description

GetInstance

Obtains the only one instance of the CTilingDataClassFactory class.

RegisterTilingData

Registers the tiling structure constructor of op_type with the CTilingDataClassFactory class.

CreateTilingDataInstance

Obtains the tiling structure based on the operator name.

OpDef APIs

This part describes internal APIs related to prototype registration, including OpDef, OpParamDef, and OpAICoreConfig. These APIs are required only by the framework to generate related projects and can be ignored by users.

Table 2 OpDef classes and their member functions

Class

API

Description

OpAICoreDef

GetTiling

Obtains the tiling information.

GetCheckSupport

Obtains the parameter check information.

GetOpSelectFormat

Obtains the inference function.

GetOpSupportInfo

Obtains the operator tiling information function.

GetOpSpecInfo

Obtains additional operator information for the FE to parse functions.

GetParamGeneralize

Obtains the operator generalization function.

SetOpSupportInfo

Sets the operator tiling information function.

SetOpSpecInfo

Sets additional operator information for the FE to parse functions.

SetParamGeneralize

Sets the operator generalization function.

OpDef

GetInferShape

Obtains the shape inference function.

GetInferShapeRange

Obtains the ShapeRange inference function.

GetInferDataType

Obtains the DataType inference function.

OpDefFactory

OpDefRegister

Registers an operator.

OpCheckFuncHelper

-

Checks operator-related functions and verifies input and output shapes, including operator parameter validation and callback function derivation.

Tiling Definition Auxiliary APIs

The following APIs are auxiliary tiling definition APIs. Ascend C provides a series of definition macros of tiling type, including BEGIN_TILING_DATA_DEF, TILING_DATA_FIELD_DEF, TILING_DATA_FIELD_DEF_ARR, TILING_DATA_FIELD_DEF_STRUCT, and REGISTER_TILING_DATA_CLASS. When these macros are called, the following APIs are called to further process the tiling information, including structure reservation and byte alignment.

// TilingDef class
void SaveToBuffer(void *pdata, size_t capacity);
std::vector<FieldInfo> GetFieldInfo() const;
const char *GetTilingClassName() const;
size_t GetDataSize() const;
void SetDataPtr(void *dataPtr);
void CheckAlignAndGenPlaceHolder(const char *name, size_t typeSize);
// FieldInfo class
FieldInfo(const char *dtype, const char *name)
FieldInfo(const char *dtype, const char *name, size_t arrSize)
FieldInfo(const char *dtype, const char *name, const char *structType,size_t structSize)