blob: ee406fb79b4390e7ad72c2fd4558a9e029a3b6d0 [file] [log] [blame]
Michael Butler376ec0c2017-07-27 18:28:20 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Michael Butler376ec0c2017-07-27 18:28:20 -070017package android.hardware.neuralnetworks@1.0;
18
Michael Butlercf22a572017-09-22 13:26:12 -070019import IExecutionCallback;
Michael Butler0e2ac1b2017-09-01 10:59:38 -070020
Michael Butlerc7821102017-09-11 16:03:36 -070021/**
22 * IPreparedModel describes a model that has been prepared for execution and
23 * is used to launch executions.
24 */
Michael Butler376ec0c2017-07-27 18:28:20 -070025interface IPreparedModel {
Michael Butlerc7821102017-09-11 16:03:36 -070026 /**
Michael Butlercf22a572017-09-22 13:26:12 -070027 * Launches an asynchronous execution on a prepared model.
Michael Butlerc7821102017-09-11 16:03:36 -070028 *
Michael Butlercf22a572017-09-22 13:26:12 -070029 * The execution is performed asynchronously with respect to the caller.
30 * execute must verify the inputs to the function are correct. If there is
31 * an error, execute must immediately invoke the callback with the
32 * appropriate ErrorStatus value, then return with the same ErrorStatus. If
33 * the inputs to the function are valid and there is no error, execute must
34 * launch an asynchronous task to perform the execution in the background,
35 * and immediately return with ErrorStatus::NONE. If the asynchronous task
36 * fails to launch, execute must immediately invoke the callback with
37 * ErrorStatus::GENERAL_FAILURE, then return with
38 * ErrorStatus::GENERAL_FAILURE.
Michael Butlerc7821102017-09-11 16:03:36 -070039 *
Michael Butlercf22a572017-09-22 13:26:12 -070040 * When the asynchronous task has finished its execution, it must
41 * immediately invoke the callback object provided as an input to the
42 * execute function. This callback must be provided with the ErrorStatus of
43 * the execution.
44 *
45 * Multiple threads can call the execute function on the same IPreparedModel
46 * object concurrently with different requests.
Michael Butlerc7821102017-09-11 16:03:36 -070047 *
48 * @param request The input and output information on which the prepared
49 * model is to be executed.
Michael Butlercf22a572017-09-22 13:26:12 -070050 * @param callback A callback object used to return the error status of
51 * the execution. The callback object's notify function must
52 * be called exactly once, even if the execution was
53 * unsuccessful.
Michael Butler926df1e2017-09-19 16:26:47 -070054 * @return status Error status of the call, must be:
55 * - NONE if task is successfully launched
56 * - DEVICE_UNAVAILABLE if driver is offline or busy
57 * - GENERAL_FAILURE if there is an unspecified error
58 * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
59 * not large enough to store the resultant values
Michael Butlercf22a572017-09-22 13:26:12 -070060 * - INVALID_ARGUMENT if one of the input arguments is
Michael Butler926df1e2017-09-19 16:26:47 -070061 * invalid
Michael Butlerc7821102017-09-11 16:03:36 -070062 */
Michael Butlercf22a572017-09-22 13:26:12 -070063 execute(Request request, IExecutionCallback callback)
64 generates (ErrorStatus status);
Michael Butler376ec0c2017-07-27 18:28:20 -070065};