blob: c04809fea15d78ab2713cef2b5504e5646c33000 [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;
21import @1.2::MeasureTiming;
22import @1.2::IExecutionCallback;
23import @1.2::IPreparedModel;
24
25/**
26 * IPreparedModel describes a model that has been prepared for execution and
27 * is used to launch executions.
28 */
29interface IPreparedModel extends @1.2::IPreparedModel {
30 /**
31 * Launches an asynchronous execution on a prepared model.
32 *
33 * The execution is performed asynchronously with respect to the caller.
34 * execute_1_3 must verify the inputs to the function are correct. If there is
35 * an error, execute_1_3 must immediately invoke the callback with the
36 * appropriate ErrorStatus value, then return with the same ErrorStatus. If
37 * the inputs to the function are valid and there is no error, execute_1_3 must
38 * launch an asynchronous task to perform the execution in the background,
39 * and immediately return with ErrorStatus::NONE. If the asynchronous task
40 * fails to launch, execute_1_3 must immediately invoke the callback with
41 * ErrorStatus::GENERAL_FAILURE, then return with
42 * ErrorStatus::GENERAL_FAILURE.
43 *
44 * When the asynchronous task has finished its execution, it must
45 * immediately invoke the callback object provided as an input to the
46 * execute_1_3 function. This callback must be provided with the ErrorStatus of
47 * the execution.
48 *
49 * If the launch is successful, the caller must not change the content of
50 * any data object referenced by 'request' (described by the
51 * {@link @1.0::DataLocation} of a {@link @1.0::RequestArgument}) until the
52 * asynchronous task has invoked the callback object. The asynchronous task
53 * must not change the content of any of the data objects corresponding to
54 * 'request' inputs.
55 *
56 * If the prepared model was prepared from a model wherein all tensor
57 * operands have fully specified dimensions, and the inputs to the function
58 * are valid, then:
59 * - the execution should launch successfully (ErrorStatus::NONE): There
60 * must be no failure unless the device itself is in a bad state.
61 * - if at execution time every operation's input operands have legal
62 * values, the execution should complete successfully (ErrorStatus::NONE):
63 * There must be no failure unless the device itself is in a bad state.
64 *
65 * Any number of calls to the execute, execute_1_2, execute_1_3, and executeSynchronously
66 * functions, in any combination, may be made concurrently, even on the same
67 * IPreparedModel object.
68 *
69 * @param request The input and output information on which the prepared
70 * model is to be executed.
71 * @param measure Specifies whether or not to measure duration of the execution.
72 * The duration runs from the time the driver sees the call
73 * to the execute_1_3 function to the time the driver invokes
74 * the callback.
75 * @param callback A callback object used to return the error status of
76 * the execution. The callback object's notify function must
77 * be called exactly once, even if the execution was
78 * unsuccessful.
79 * @return status Error status of the call, must be:
80 * - NONE if task is successfully launched
81 * - DEVICE_UNAVAILABLE if driver is offline or busy
82 * - GENERAL_FAILURE if there is an unspecified error
83 * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
84 * not large enough to store the resultant values
85 * - INVALID_ARGUMENT if one of the input arguments is
86 * invalid
87 */
88 execute_1_3(Request request, MeasureTiming measure, IExecutionCallback callback)
89 generates (ErrorStatus status);
90};