aclopCompile

Description

Compiles an operator. The compilation options are set by using the aclSetCompileopt call.

Restrictions

  • As the inputs and outputs of each operator are organized differently, the app needs to organize operators in strict accordance with their input and output parameters. When aclopCompile is called, AscendCL searches for the corresponding task based on the optype, input tensor description, output tensor description, and attributes before compiling the operator.
  • To compile a dynamic-shape operator with known shape range, set the element value in the dims array that indicates a dynamic dimension to –1 when creating data aclTensorDesc of the type by using the aclCreateTensorDesc call, and then call aclSetTensorShapeRange to set the size range of each dimension. To compile a dynamic-shape operator with an unknown shape range (which is reserved in the current version), set the dims array to –2 when creating the aclTensorDesc by using the aclCreateTensorDesc call, for example, int64_t dims[] = {-2}.
  • To build an operator with an unused optional input, create data of the aclTensorDesc type by using the aclCreateTensorDesc(ACL_DT_UNDEFINED, 0, nullptr, ACL_FORMAT_UNDEFINED) call, indicating that the data type is ACL_DT_UNDEFINED, the format is ACL_FORMAT_UNDEFINED, and the shape is nullptr.
  • Before compiling an operator with constant input, call aclSetTensorConst to set the constant input. The constant input passed to the aclopCompile and aclopExecuteV2 calls must be consistent.

Prototype

aclError aclopCompile(const char *opType,

int numInputs,

const aclTensorDesc *const inputDesc[],

int numOutputs,

const aclTensorDesc *const outputDesc[],

const aclopAttr *attr,

aclopEngineType engineType,

aclopCompileType compileFlag,

const char *opPath)

Parameters

Parameter

Input/Output

Description

opType

Input

Pointer to the operator type name.

numInputs

Input

Number of input tensors.

inputDesc

Input

Pointer array of the input tensor description.

Call aclCreateTensorDesc to create data of the aclTensorDesc type in advance.

The array length is consistent with numInputs.

numOutputs

Input

Number of output tensors.

outputDesc

Input

Pointer array of the output tensor description.

Call aclCreateTensorDesc to create data of the aclTensorDesc type in advance.

The array length is consistent with numOutputs.

attr

Input

Pointer to the operator attributes.

Call aclopCreateAttr to create data of the aclopAttr type in advance.

engineType

Input

Operator execution engine.

compileFlag

Input

Operator compiled flag.

opPath

Input

Pointer to the path of the operator implementation file (.py), excluding the file name. This parameter is reserved. Currently, this parameter can only be set to nullptr.

Returns

The value 0 indicates success, and other values indicate failure. For details, see aclError.