Read output from a model asynchronously
After you run a model, you can read the output from a model asynchronously. This avoids Sentis blocking the main thread while it waits for the model to finish running then downloads the output data to the CPU.
Follow these steps:
- Get a reference to the tensor output data using
PeekOutput
. - Use the
Tensor.PrepareCacheForAccess
method and set theblocking
parameter tofalse
. - Use
Tensor.PrepareCacheForAccess
again to check if the data is complete. - The method returns
true
when the data is complete. You can then access the data.
Refer to the AsyncReadback/AsyncReadbackCompute
example in the sample scripts for a working example.