aclopCompile

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Function Usage

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

As the inputs and outputs of operators are organized differently from each other, the API organizes operators in strict accordance with their input and output parameters. When aclopCompile is called, the API searches for the corresponding task based on the optype, input tensor description, output tensor description, and attributes before compiling the operator.

Prototype

1
2
3
4
5
6
7
8
9
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 operator input tensor description. For details about the type definition, see aclTensorDesc.

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

The array length must be consistent with numInputs.

numOutputs

Input

Number of output tensors.

outputDesc

Input

Pointer array of the operator output tensor description. For details about the type definition, see aclTensorDesc.

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

The array length must be consistent with numOutputs.

attr

Input

Pointer to the operator attributes. For details about the type definition, see aclopAttr.

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

engineType

Input

Operator execution engine. For details about the type definition, see aclopEngineType.

compileFlag

Input

Operator compiled flag. For details about the type definition, see aclopCompileType.

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

0 on success; else, failure. For details, see aclError.

Restrictions

  • 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 of the aclTensorDesc type by using the aclCreateTensorDesc call, and then call aclSetTensorShapeRange to set the size range of each dimension for a tensor. 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 data of the aclTensorDesc type by using the aclCreateTensorDesc call, for example, int64_t dims[] = {-2}.
  • To compile 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.