blob: 5590487538d6ca4f120663bf1fa34b86b8f69b50 [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 *
54 * Multiple threads can call the execute_1_2 function on the same IPreparedModel
55 * object concurrently with different requests.
56 *
57 * @param request The input and output information on which the prepared
58 * model is to be executed.
59 * @param callback A callback object used to return the error status of
60 * the execution. The callback object's notify function must
61 * be called exactly once, even if the execution was
62 * unsuccessful.
63 * @return status Error status of the call, must be:
64 * - NONE if task is successfully launched
65 * - DEVICE_UNAVAILABLE if driver is offline or busy
66 * - GENERAL_FAILURE if there is an unspecified error
67 * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
68 * not large enough to store the resultant values
69 * - INVALID_ARGUMENT if one of the input arguments is
70 * invalid
71 */
72 execute_1_2(Request request, IExecutionCallback callback)
73 generates (ErrorStatus status);
74};