OpAICoreConfig Registration API (REGISTER_OP_AICORE_CONFIG)

Function

The operator prototype definition varies with the hardware form. You can add OpAICoreConfig to register differentiated operator prototypes for different AI processor models. The REGISTER_OP_AICORE_CONFIG macro allows you to add a separate file to register the differentiated information of operators on different hardware forms without changing the original registration.

To use this registration macro, include the following header file:

1
#include "register/op_config_registry.h"

Prototype

1
REGISTER_OP_AICORE_CONFIG(opType, socVersion, opFunc)

Parameters

Parameter

Input/Output

Description

opType

Input

Operator type.

socVersion

Input

Supported AI Processor model.

opFunc

Input

Returns the callback function pointer of OpAICoreConfig. The prototype of the callback function is defined as follows:

1
OpAICoreConfig (*)()

Returns

None

Restrictions

If the operator uses both AddConfig and AddConfig to register the AI processor model supported by the operator and the OpAICoreConfig information, and the AI processor models are the same, the configuration registered in AddConfig mode has a higher priority and overwrites the OpAICoreConfig information registered using the REGISTER_OP_AICORE_CONFIG macro.

Example

Assume that the prototype registration file op_host/add_custom.cpp is implemented as follows, and the AI processor model ascendxxx1 supported by the operator and the input and output prototype information of the operator are configured:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
namespace ops {
class AddCustom : public OpDef {
public:
    AddCustom(const char* name) : OpDef(name)
    {
        this->Input("x")
            .ParamType(REQUIRED)
            .DataType({ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_INT32})
            .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
        this->Input("y")
            .ParamType(REQUIRED)
            .DataType({ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_INT32})
            .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
        this->Output("z")
            .ParamType(REQUIRED)
            .DataType({ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_INT32})
            .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
        this->AICore()
            .SetTiling(optiling::TilingFunc);
        // Replace it with the actual AI processor model.
        this->AICore().AddConfig("ascendxxx1");
    }
};
OP_ADD(AddCustom);
} // namespace ops

You can add the op_host/add_custom_xxx.cpp file and use REGISTER_OP_AICORE_CONFIG to register the AI processor model ascendxxx2 supported by the operator. The following is an example:

#include "register/op_config_registry.h"
namespace ops {
REGISTER_OP_AICORE_CONFIG(AddCustom, ascendxxx2, []() {
    ops::OpAICoreConfig config("ascendxxx2");
    return config;
});
}