pub unsafe extern "C" fn ANeuralNetworksExecution_setTimeout(
execution: *mut ANeuralNetworksExecution,
duration: u64,
) -> c_intExpand description
Set the maximum expected duration of the specified execution.
If the device is not able to complete the execution within the specified duration, the execution may be aborted. The timeout duration begins at a call to one of:
- {@link ANeuralNetworksExecution_burstCompute}
- {@link ANeuralNetworksExecution_compute}
- {@link ANeuralNetworksExecution_startCompute}
- {@link ANeuralNetworksExecution_startComputeWithDependencies}
This timeout duration acts as a hint to drivers, and can be used to both free up compute resources within the driver and return control back to the application quicker than is possible without the hint. It enables drivers that are able to estimate how long an execution will take to abort the execution before it has even started if the driver believes the execution cannot be completed within the timeout duration. Similarly, it enables drivers to abort an ongoing execution if it is taking too long. However, this call does not guarantee that the execution will complete or abort within the timeout duration.
By default (i.e., unless ANeuralNetworksExecution_setTimeout is called), the timeout duration for execution is considered infinite.
The {@link ANeuralNetworksExecution} must have been created from an {@link ANeuralNetworksCompilation} which in turn was created from {@link ANeuralNetworksCompilation_createForDevices} with numDevices = 1, otherwise this function will fail with ANEURALNETWORKS_BAD_DATA. If the device has a feature level reported by {@link ANeuralNetworksDevice_getFeatureLevel} that is lower than 30, then the timeout duration hint will be ignored.
See {@link ANeuralNetworksExecution} for information on multithreaded usage.
@param execution The execution to be modified. @param duration The maximum amount of time in nanoseconds that is expected to be spent executing a model. If this duration is exceeded, the execution may be aborted. If set to 0, the timeout duration is considered infinite.
@return ANEURALNETWORKS_NO_ERROR if successful.
Available since API level 30.