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.PrepareCacheForAccessmethod and set theblockingparameter tofalse. - Use
Tensor.PrepareCacheForAccessagain to check if the data is complete. - The method returns
truewhen the data is complete. You can then access the data.
Refer to the AsyncReadback/AsyncReadbackCompute example in the sample scripts for a working example.