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 is synchronous.
For example, if an AI Core error is reported during network inference, you can call this API to obtain the description of the error operator and then perform further troubleshooting.
The key steps for implementing the callback function are as follows:
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.
If an AI Core error is reported, the callback function fn is triggered to obtain the operator information for further troubleshooting.
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)
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. |
0 on success; else, failure.
For the API call example, see AI Core Troubleshooting.