Instructions

Description

The APIs provided in this section are used to implement the data queue and data forwarding functions on the device.

A queue can be operated only by a single consumer or producer. Enqueue or dequeue should be performed by a single thread. Concurrency is not supported.

Typical Application Scenario Example

You can use the queue management APIs and a queue-based model loading API (aclmdlLoadFromFileWithQ or aclmdlLoadFromMemWithQ) to implement data-driven model inference. The process of calling key APIs in this scenario is as follows:

  1. Call acltdtCreateQueue multiple times to allocate queues for storing the model input and output data. One input corresponds to one input queue ID, and one output corresponds to one output queue ID.
  2. Call a queue-based model loading API (aclmdlLoadFromFileWithQ or aclmdlLoadFromMemWithQ) to pass the model, input queue ID, and output queue ID.
  3. Allocate the memory for storing the input and output data.
  4. Read the input data of model inference into the memory and call acltdtEnqueueData to enqueue the input data.

    At this time, the API automatically triggers model inference based on the input data enqueued. After the inference is complete, the result data is automatically stored in the output queue.

  5. Call acltdtDequeueData to obtain the data of each output for further postprocessing.
  6. After obtaining the inference result, free the resources in a timely manner, including freeing the input and output buffer, calling aclmdlUnload to unload the model, and calling acltdtDestroyQueue to destroy the queue.