ANeuralNetworksCompilation_setTimeout

Function ANeuralNetworksCompilation_setTimeout 

Source
pub unsafe extern "C" fn ANeuralNetworksCompilation_setTimeout(
    compilation: *mut ANeuralNetworksCompilation,
    duration: u64,
) -> c_int
Expand description

Set the maximum expected duration for compiling the model.

If the device is not able to complete the compilation within the specified duration, the compilation may be aborted. The timeout duration begins at the call to {@link ANeuralNetworksCompilation_finish}.

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 a compilation will take to abort the compilation before it has even started if the driver believes the compilation cannot be completed within the timeout duration. Similarly, it enables drivers to abort an ongoing compilation if it is taking too long. However, this call does not guarantee that the compilation will complete or abort within the timeout duration.

By default (i.e., unless ANeuralNetworksCompilation_setTimeout is called), the timeout duration for compiling the model is considered infinite.

The {@link ANeuralNetworksCompilation} must have been created with {@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 ANeuralNetworksCompilation} for information on multithreaded usage.

@param compilation The compilation to be modified. @param duration The maximum amount of time in nanoseconds that is expected to be spent finishing a compilation. If this duration is exceeded, the compilation may be aborted. If set to 0, the timeout duration is considered infinite.

@return ANEURALNETWORKS_NO_ERROR if successful.

Available since API level 30.