blob: 4e91c6754e2af5d5ec46ef95bea715875f611ab4 [file] [log] [blame]
Xusong Wang1a06e772018-10-31 08:43:12 -07001/*
2 * Copyright (C) 2018 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
17package android.hardware.neuralnetworks@1.2;
18
19import @1.0::ErrorStatus;
20import @1.0::IPreparedModel;
21import @1.0::Request;
22import IExecutionCallback;
23
24/**
25 * IPreparedModel describes a model that has been prepared for execution and
26 * is used to launch executions.
27 */
28interface IPreparedModel extends @1.0::IPreparedModel {
29 /**
30 * Launches an asynchronous execution on a prepared model.
31 *
32 * The execution is performed asynchronously with respect to the caller.
33 * execute_1_2 must verify the inputs to the function are correct. If there is
34 * an error, execute_1_2 must immediately invoke the callback with the
35 * appropriate ErrorStatus value, then return with the same ErrorStatus. If
36 * the inputs to the function are valid and there is no error, execute_1_2 must
37 * launch an asynchronous task to perform the execution in the background,
38 * and immediately return with ErrorStatus::NONE. If the asynchronous task
39 * fails to launch, execute_1_2 must immediately invoke the callback with
40 * ErrorStatus::GENERAL_FAILURE, then return with
41 * ErrorStatus::GENERAL_FAILURE.
42 *
43 * When the asynchronous task has finished its execution, it must
44 * immediately invoke the callback object provided as an input to the
45 * execute_1_2 function. This callback must be provided with the ErrorStatus of
46 * the execution.
47 *
48 * If the prepared model was prepared from a model wherein all
49 * tensor operands have fully specified dimensions, and the inputs
50 * to the function are valid, then the execution should launch
51 * and complete successfully (ErrorStatus::NONE). There must be
52 * no failure unless the device itself is in a bad state.
53 *
David Gross4592ed12018-12-21 11:20:26 -080054 * Any number of calls to the execute, execute_1_2, and executeSynchronously
55 * functions, in any combination, may be made concurrently, even on the same
56 * IPreparedModel object.
Xusong Wang1a06e772018-10-31 08:43:12 -070057 *
58 * @param request The input and output information on which the prepared
59 * model is to be executed.
60 * @param callback A callback object used to return the error status of
61 * the execution. The callback object's notify function must
62 * be called exactly once, even if the execution was
63 * unsuccessful.
64 * @return status Error status of the call, must be:
65 * - NONE if task is successfully launched
66 * - DEVICE_UNAVAILABLE if driver is offline or busy
67 * - GENERAL_FAILURE if there is an unspecified error
68 * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
69 * not large enough to store the resultant values
70 * - INVALID_ARGUMENT if one of the input arguments is
71 * invalid
72 */
73 execute_1_2(Request request, IExecutionCallback callback)
74 generates (ErrorStatus status);
David Gross4592ed12018-12-21 11:20:26 -080075
76 /**
77 * Performs a synchronous execution on a prepared model.
78 *
79 * The execution is performed synchronously with respect to the caller.
80 * executeSynchronously must verify the inputs to the function are
81 * correct. If there is an error, executeSynchronously must immediately
82 * return with the appropriate ErrorStatus value. If the inputs to the
83 * function are valid and there is no error, executeSynchronously must
84 * perform the execution, and must not return until the execution is
85 * complete.
86 *
87 * If the prepared model was prepared from a model wherein all tensor
88 * operands have fully specified dimensions, and the inputs to the function
89 * are valid, then the execution should complete successfully
90 * (ErrorStatus::NONE). There must be no failure unless the device itself is
91 * in a bad state.
92 *
93 * Any number of calls to the execute, execute_1_2, and executeSynchronously
94 * functions, in any combination, may be made concurrently, even on the same
95 * IPreparedModel object.
96 *
97 * @param request The input and output information on which the prepared
98 * model is to be executed.
99 * @return status Error status of the execution, must be:
100 * - NONE if execution is performed successfully
101 * - DEVICE_UNAVAILABLE if driver is offline or busy
102 * - GENERAL_FAILURE if there is an unspecified error
103 * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
104 * not large enough to store the resultant values
105 * - INVALID_ARGUMENT if one of the input arguments is
106 * invalid
107 */
108 executeSynchronously(Request request)
109 generates (ErrorStatus status);
Xusong Wang1a06e772018-10-31 08:43:12 -0700110};