blob: 7aea4160b0158665e30bbd378c05eea5a6842438 [file] [log] [blame]
Xusong Wang62a760c2019-10-25 12:07:17 -07001/*
2 * Copyright (C) 2019 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.3;
18
19import @1.0::ErrorStatus;
20import @1.0::Request;
Xusong Wang62a760c2019-10-25 12:07:17 -070021import @1.2::IExecutionCallback;
22import @1.2::IPreparedModel;
Xusong Wangebd88ba2019-10-28 11:11:19 -070023import @1.2::MeasureTiming;
24import @1.2::OutputShape;
25import @1.2::Timing;
Xusong Wang62a760c2019-10-25 12:07:17 -070026
27/**
28 * IPreparedModel describes a model that has been prepared for execution and
29 * is used to launch executions.
30 */
31interface IPreparedModel extends @1.2::IPreparedModel {
32 /**
33 * Launches an asynchronous execution on a prepared model.
34 *
35 * The execution is performed asynchronously with respect to the caller.
36 * execute_1_3 must verify the inputs to the function are correct. If there is
37 * an error, execute_1_3 must immediately invoke the callback with the
38 * appropriate ErrorStatus value, then return with the same ErrorStatus. If
39 * the inputs to the function are valid and there is no error, execute_1_3 must
40 * launch an asynchronous task to perform the execution in the background,
41 * and immediately return with ErrorStatus::NONE. If the asynchronous task
42 * fails to launch, execute_1_3 must immediately invoke the callback with
43 * ErrorStatus::GENERAL_FAILURE, then return with
44 * ErrorStatus::GENERAL_FAILURE.
45 *
46 * When the asynchronous task has finished its execution, it must
47 * immediately invoke the callback object provided as an input to the
48 * execute_1_3 function. This callback must be provided with the ErrorStatus of
49 * the execution.
50 *
51 * If the launch is successful, the caller must not change the content of
52 * any data object referenced by 'request' (described by the
53 * {@link @1.0::DataLocation} of a {@link @1.0::RequestArgument}) until the
54 * asynchronous task has invoked the callback object. The asynchronous task
55 * must not change the content of any of the data objects corresponding to
56 * 'request' inputs.
57 *
58 * If the prepared model was prepared from a model wherein all tensor
59 * operands have fully specified dimensions, and the inputs to the function
60 * are valid, then:
61 * - the execution should launch successfully (ErrorStatus::NONE): There
62 * must be no failure unless the device itself is in a bad state.
63 * - if at execution time every operation's input operands have legal
64 * values, the execution should complete successfully (ErrorStatus::NONE):
65 * There must be no failure unless the device itself is in a bad state.
66 *
Xusong Wangebd88ba2019-10-28 11:11:19 -070067 * Any number of calls to the execute* and executeSynchronously* functions,
68 * in any combination, may be made concurrently, even on the same
Xusong Wang62a760c2019-10-25 12:07:17 -070069 * IPreparedModel object.
70 *
71 * @param request The input and output information on which the prepared
72 * model is to be executed.
73 * @param measure Specifies whether or not to measure duration of the execution.
74 * The duration runs from the time the driver sees the call
75 * to the execute_1_3 function to the time the driver invokes
76 * the callback.
77 * @param callback A callback object used to return the error status of
78 * the execution. The callback object's notify function must
79 * be called exactly once, even if the execution was
80 * unsuccessful.
81 * @return status Error status of the call, must be:
82 * - NONE if task is successfully launched
83 * - DEVICE_UNAVAILABLE if driver is offline or busy
84 * - GENERAL_FAILURE if there is an unspecified error
85 * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
86 * not large enough to store the resultant values
87 * - INVALID_ARGUMENT if one of the input arguments is
88 * invalid
89 */
90 execute_1_3(Request request, MeasureTiming measure, IExecutionCallback callback)
91 generates (ErrorStatus status);
Xusong Wangebd88ba2019-10-28 11:11:19 -070092
93 /**
94 * Performs a synchronous execution on a prepared model.
95 *
96 * The execution is performed synchronously with respect to the caller.
97 * executeSynchronously_1_3 must verify the inputs to the function are
98 * correct. If there is an error, executeSynchronously_1_3 must immediately
99 * return with the appropriate ErrorStatus value. If the inputs to the
100 * function are valid and there is no error, executeSynchronously_1_3 must
101 * perform the execution, and must not return until the execution is
102 * complete.
103 *
104 * The caller must not change the content of any data object referenced by
105 * 'request' (described by the {@link @1.0::DataLocation} of a
106 * {@link @1.0::RequestArgument}) until executeSynchronously_1_3
107 * returns. executeSynchronously_1_3 must not change the content of any of the
108 * data objects corresponding to 'request' inputs.
109 *
110 * If the prepared model was prepared from a model wherein all tensor
111 * operands have fully specified dimensions, and the inputs to the function
112 * are valid, and at execution time every operation's input operands have
113 * legal values, then the execution should complete successfully
114 * (ErrorStatus::NONE): There must be no failure unless the device itself is
115 * in a bad state.
116 *
117 * Any number of calls to the execute* and executeSynchronously* functions,
118 * in any combination, may be made concurrently, even on the same
119 * IPreparedModel object.
120 *
121 * @param request The input and output information on which the prepared
122 * model is to be executed.
123 * @param measure Specifies whether or not to measure duration of the execution.
124 * The duration runs from the time the driver sees the call
125 * to the executeSynchronously_1_3 function to the time the driver
126 * returns from the function.
127 * @return status Error status of the execution, must be:
128 * - NONE if execution is performed successfully
129 * - DEVICE_UNAVAILABLE if driver is offline or busy
130 * - GENERAL_FAILURE if there is an unspecified error
131 * - OUTPUT_INSUFFICIENT_SIZE if at least one output
132 * operand buffer is not large enough to store the
133 * corresponding output
134 * - INVALID_ARGUMENT if one of the input arguments is
135 * invalid
136 * @return outputShapes A list of shape information of model output operands.
137 * The index into "outputShapes" corresponds to the index
138 * of the output operand in the Request outputs vector.
139 * outputShapes must be empty unless the status is either
140 * NONE or OUTPUT_INSUFFICIENT_SIZE.
141 * @return Timing Duration of execution. Unless measure is YES and status is
142 * NONE, all times must be reported as UINT64_MAX. A driver may
143 * choose to report any time as UINT64_MAX, indicating that
144 * measurement is not available.
145 */
146 executeSynchronously_1_3(Request request, MeasureTiming measure)
147 generates (ErrorStatus status, vec<OutputShape> outputShapes, Timing timing);
Xusong Wang62a760c2019-10-25 12:07:17 -0700148};