aclmdlCreateAndGetOpDesc

Description

Obtains the description of an operator, including the operator name, input tensor description, and output tensor description. If the specified operator cannot be found, an error is returned. This API does not support the dynamic shape scenario.

Restrictions

Application scenario: For example, if an AI Core error is reported during network inference (dynamic shape scenarios unsupported), you can call this API to obtain the description of the error operator and then perform further troubleshooting.

The recommended API call sequence is as follows:
  1. Define and implement the exception callback function fn (of the aclrtExceptionInfoCallback type). For details about the callback function prototype, see aclrtSetExceptionInfoCallback.

    The key steps for implementing the callback function are as follows:

    1. Call aclrtGetDeviceIdFromExceptionInfo, aclrtGetStreamIdFromExceptionInfo, and aclrtGetTaskIdFromExceptionInfo in fn to obtain the device ID, stream ID, and task ID, respectively.
    2. Call aclmdlCreateAndGetOpDesc in fn to obtain the operator description.
    3. Call aclGetTensorDescByIndex in fn to obtain the input/output tensor description of the operator.
    4. In the exception callback function fn, call the following APIs to obtain the tensor description for further analysis.

      For example, call aclGetTensorDescAddress to obtain the tensor data address, call aclGetTensorDescType to obtain the data type in the tensor description, call aclGetTensorDescFormat to obtain the tensor format, call aclGetTensorDescNumDims to obtain the tensor dimension count, and call aclGetTensorDescDimV2 to obtain the size of a specified dimension.

  2. Call aclrtSetExceptionInfoCallback to set the exception callback function.
  3. Run model inference.

    If an AI Core error is reported, the callback function fn is triggered to obtain the operator information for further troubleshooting.

Prototype

aclError aclmdlCreateAndGetOpDesc(uint32_t deviceId, uint32_t streamId, uint32_t taskId, char *opName, size_t opNameLen, aclTensorDesc **inputDesc, size_t *numInputs, aclTensorDesc **outputDesc, size_t *numOutputs)

Parameters

Parameter

Input/Output

Description

deviceId

Input

Device ID.

Call aclrtGetDeviceIdFromExceptionInfo to obtain the device ID in the exception information.

streamId

Input

Stream ID.

Call aclrtGetStreamIdFromExceptionInfo to obtain the stream ID in the exception information.

taskId

Input

Task ID.

Call aclrtGetTaskIdFromExceptionInfo to obtain the task ID in the exception information.

opName

Output

Pointer to the operator name string.

opNameLen

Input

Length of the operator name string.

If the specified length is shorter than the actual length of the operator name, an error is returned.

inputDesc

Output

Pointer to the description of all input tensors of the operator, pointing to the start address of a contiguous memory space.

numInputs

Output

Pointer to the number of inputs.

outputDesc

Output

Pointer to the description of all output tensors of the operator, pointing to the start address of a contiguous memory space.

numOutputs

Output

Pointer to the number of outputs.

Returns

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

See Also

For the API call example, see AI Core Troubleshooting.