Operator Information Library Definition

You need to register the operator information to the operator information library by configuring the operator information file. The operator information library mainly reflects the physical implementation restrictions of an operator on the Ascend AI Processor, including the input and output data types, formats, and input shape of the operator. During network execution, FE performs basic verification based on the operator information in the operator information library, and determines whether to insert a proper conversion node for the operator. It also finds the corresponding operator implementation file based on the information in the operator information library and builds the operator binary file for execution.

Go to the tbe/op_info_cfg/ai_core/soc_version directory and configure the operator information library file add.ini.

soc_version indicates the the Ascend AI Processor version.

You need to modify the add.ini file automatically generated by MindStudio. The following shows the modified operator information library definition of the Add operator.

[Add]
input0.name=x1
input0.dtype=float16,float16,float16,float16,float,float,float,float,int32,int32,int32,int32
input0.format=NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND
input0.shape=all
input0.paramType=required
input1.name=x2
input1.dtype=float16,float16,float16,float16,float,float,float,float,int32,int32,int32,int32
input1.format=NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND
input1.shape=all
input1.paramType=required
output0.name=y
output0.dtype=float16,float16,float16,float16,float,float,float,float,int32,int32,int32,int32
output0.format=NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND
output0.shape=all
output0.paramType=required
opFile.value=add
opInterface.value=add

Table 1 describes the configuration options. The following table lists only the common configuration options of the operator information library. For details about other configuration options, see "Operator Development > Operator Information Library Definition > TBE Operator Information Library" in the Operator Development Guide.

Table 1 Operator information library definition of the Add operator

Configuration Option

Add Operator Configuration

Description

[OpType]

[Add]

Operator type, which is included in square brackets to mark the start of operator information. The operator type is Add according to Operator Analysis.

input0.name

x1

Name of the first input tensor of the Add operator. According to Operator Analysis, the name of the first input tensor is x1. Therefore, set this parameter to x1, which must be the same as the name in Operator Prototype Definition.

input0.dtype

input0.dtype=float16,float16,float16,float16,float,float,float,float,int32,int32,int32,int32

input0.format=NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND

Data type and data layout format supported by the input tensor.

According to Operator Analysis, the Add operator supports input types (float16, float32, and int32) and data layout formats (NCHW, NC1HWC0, NHWC, and ND).

NOTE:

If the input tensor supports multiple dtype and format combinations, dtype and format must be configured in pairs and in sequence. List all the combinations supported by the operator and separate them with commas (,).

input0.format

input0.shape

all

Shape of the input tensor.

input0.paramType

required

Type of the input tensor.

  • dynamic: indicates that the number of inputs is subject to change, which can be one or more.
  • optional: indicates that there could be one input or no input at all.
  • required: indicates that there is one and only one input.

Set input0 of the Add operator to required.

input1.name

x2

The Add operator has two inputs, while the generated configuration template has only one input. Therefore, you need to add the configuration of input1.

Name of the second input tensor of the Add operator. According to Operator Analysis, the name of the second input tensor is x2. Therefore, set this parameter to x2, which must be the same as the name in Operator Prototype Definition.

input1.dtype

input1.dtype=float16,float16,float16,float16,float,float,float,float,int32,int32,int32,int32

input1.format=NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND

Data type and data layout format supported by the input tensor.

According to Operator Analysis, the Add operator supports input types (float16, float32, and int32) and data layout formats (NCHW, NC1HWC0, NHWC, and ND).

NOTE:

If the input tensor supports multiple dtype and format combinations, dtype and format must be configured in pairs and in sequence. List all the combinations supported by the operator and separate them with commas (,).

input1.format

input1.shape

all

Shape of the input tensor.

input1.paramType

required

Type of the input tensor.

  • dynamic: indicates that the number of inputs is subject to change, which can be one or more.
  • optional: indicates that there could be one input or no input at all.
  • required: indicates that there is one and only one input.

Set input1 of the Add operator to required.

output0.name

y

Name of the output tensor of the Add operator. According to Operator Analysis, the output name of the operator is y. Therefore, set this parameter to y, which must be the same as the name in Operator Prototype Definition.

output0.dtype

output0.dtype=float16,float16,float16,float16,float,float,float,float,int32,int32,int32,int32

output0.format=NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND

Data type and data layout format supported by the output tensor.

According to Operator Analysis, the Add operator supports output types (float16, float32, and int32) and data layout formats (NCHW, NC1HWC0, NHWC, and ND).

NOTE:

If the input tensor supports multiple dtype and format combinations, dtype and format must be configured in pairs and in sequence. List all the combinations supported by the operator and separate them with commas (,).

output0.format

output0.shape

all

Shape of the output tensor.

output0.paramType

required

Type of the output tensor:

  • dynamic: indicates that the number of outputs is subject to change, which can be one or more.
  • optional: indicates that there could be one output or no output at all.
  • required: indicates that there is one and only one output.

Set output0 of the Add operator to required.

opFile.value

add

Name of the operator implementation file.

According to 4, the name of the operator implementation code complies with the rules of converting OpType to the code implementation name. Therefore, this parameter does not need to be specified.

opInterface.value

add

Name of the definition function in the operator implementation file.

The name of the operator definition function complies with the rules of converting OpType to the operator definition function name as shown in 4. Therefore, this parameter does not need to be specified.