Function: create_and_get_op_desc
Applicability
|
Product |
Supported (√/x) |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function Usage
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.
Prototype
- C Prototype
1aclError 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)
- Python Function
1op_name, input_desc, num_inputs, output_desc, num_outputs, ret = acl.mdl.create_and_get_op_desc(device_id, stream_id, task_id, op_name_len)
Parameter Description
|
Parameter |
Description |
|---|---|
|
device_id |
Int, device ID. Call acl.rt.get_device_id_from_exception_info to obtain the device ID in the exception information. |
|
stream_id |
Int, stream ID. Call acl.rt.get_stream_id_from_exception_info to obtain the stream ID in the exception information. |
|
task_id |
Int, task ID. Call acl.rt.get_task_id_from_exception_info to obtain the task ID in the exception information. |
|
op_name_len |
Int, length of the operator name string. If the specified length is shorter than the actual length of the operator name, an error is returned. |
Return Value Description
|
Return Value |
Description |
|---|---|
|
op_name |
String, operator name string. |
|
input_desc |
Int, description of all input tensors of the operator, pointing to the start address of a contiguous memory space. |
|
num_inputs |
Int, number of inputs. |
|
output_desc |
Int, description of all output tensors of the operator, pointing to the start address of a contiguous memory space. |
|
num_outputs |
Int, number of outputs. |
|
ret |
Int, error code: 0 on success; else, failure. |
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.
- Define and implement the exception callback function fn (of the aclrtExceptionInfoCallback type). For details about the callback function prototype, see acl.rt.set_exception_info_callback.
The key steps for implementing the callback function are as follows:
- Call acl.rt.get_device_id_from_exception_info, acl.rt.get_stream_id_from_exception_info, and acl.rt.get_task_id_from_exception_info in fn to obtain the device ID, stream ID, and task ID, respectively.
- Call acl.mdl.create_and_get_op_desc in fn to obtain the operator description.
- Call acl.get_tensor_desc_by_index in fn to obtain the input/output tensor description of the operator.
- In fn, obtain the tensor description for further analysis.
For example, call acl.get_tensor_desc_address to obtain the tensor data address, call acl.get_tensor_desc_type to obtain the data type in the tensor description, call acl.get_tensor_desc_format to obtain the tensor format, call acl.get_tensor_desc_num_dims to obtain the tensor dimension count, and call acl.get_tensor_desc_dim_v2 to obtain the size of a specified dimension.
- Call acl.rt.set_exception_info_callback to set the exception callback function.
- Perform model inference.
If an AI Core error is reported, fn is triggered to obtain the operator information for further troubleshooting.