Scenarios with Callback
The callback flow is briefly described as follows:
- The user needs to create a callback function in advance to obtain and process the model inference or operator execution result.
- The user needs to create a thread and customize a thread function in advance. Once acl.rt.process_report is called in the thread function, the created callback function will be triggered after a specified period of time.
- Call acl.rt.subscribe_report to specify the thread for processing the callback function in the stream created in advance.
- Call acl.rt.launch_callback to add the created callback function to be executed on the host or device to the task stream.
- Call acl.rt.unsubscribe_report to unsubscribe a thread. (The callback function in the stream is no longer processed by the specified thread.)
- In the asynchronous inference scenario with callback processing, acl.rt.synchronize_stream needs to be called before the stream is destroyed to ensure all tasks in a stream are complete and all inference results are handled by the callback function.