blob: 91a9555b6d56a21484c1332681ae0d552c259fdf [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 Butlere9dc1672017-09-11 13:53:19 -070019import IEvent;
Michael Butler376ec0c2017-07-27 18:28:20 -070020import IPreparedModel;
21
Michael Butlerc7821102017-09-11 16:03:36 -070022/**
23 * This interface represents a device driver.
24 */
Michael Butler376ec0c2017-07-27 18:28:20 -070025interface IDevice {
Michael Butlerc7821102017-09-11 16:03:36 -070026 /**
27 * Gets the capabilities of a driver.
28 *
Michael Butler926df1e2017-09-19 16:26:47 -070029 * @return status Error status of the call, must be:
30 * - NONE if successful
31 * - DEVICE_UNAVAILABLE if driver is offline or busy
32 * - GENERAL_FAILURE if there is an unspecified error
Michael Butlerc7821102017-09-11 16:03:36 -070033 * @return capabilities Capabilities of the driver.
34 */
Michael Butler61ae6ed2017-09-11 20:27:50 -070035 getCapabilities() generates (ErrorStatus status, Capabilities capabilities);
Michael Butler376ec0c2017-07-27 18:28:20 -070036
Michael Butlerc7821102017-09-11 16:03:36 -070037 /**
38 * Gets the supported operations in a model.
39 *
40 * getSupportedSubgraph provides a more nuanced indication on whether a
41 * model is able to be compiled by the driver. Having the entire model
42 * allows for additional information such as tensor shapes to inputs or
43 * tensor strides, information which is not known in "initialize".
44 *
45 * @param model A model whose operations--and their corresponding
46 * operands--are to be verified by the driver.
Michael Butler926df1e2017-09-19 16:26:47 -070047 * @return status Error status of the call, must be:
48 * - NONE if successful
49 * - DEVICE_UNAVAILABLE if driver is offline or busy
50 * - GENERAL_FAILURE if there is an unspecified error
51 * - INVALID_ARGUMENT when provided model is invalid
Michael Butlerc7821102017-09-11 16:03:36 -070052 * @return supportedOperations A list of supported operations, where true
53 * indicates the operation is supported and
54 * false indicates the operation is not
55 * supported. The index of "supported"
56 * corresponds with the index of the operation
57 * it is describing.
58 */
Michael Butler61ae6ed2017-09-11 20:27:50 -070059 getSupportedOperations(Model model)
Michael Butler926df1e2017-09-19 16:26:47 -070060 generates (ErrorStatus status, vec<bool> supportedOperations);
Michael Butler376ec0c2017-07-27 18:28:20 -070061
Michael Butlerc7821102017-09-11 16:03:36 -070062 /**
63 * Prepares a model for execution.
64 *
65 * prepareModel is used to make any necessary transformations or alternative
66 * representations to a model for execution, possible including
67 * transformations on the constant data, optimization on the model's graph,
Michael Butler926df1e2017-09-19 16:26:47 -070068 * or compilation into the device's native binary format.
Michael Butlerc7821102017-09-11 16:03:36 -070069 *
70 * The only information that may be unknown to the model at this stage is
71 * the shape of the tensors, which may only be known at execution time.
72 *
73 * @param model The model to be prepared for execution.
74 * @param event A synchronization callback that must be signaled once the
75 * execution has finished.
Michael Butler926df1e2017-09-19 16:26:47 -070076 * @return status Error status of the call, must be:
77 * - NONE if preparation task is successfully launched
78 * - DEVICE_UNAVAILABLE if driver is offline or busy
79 * - GENERAL_FAILURE if there is an unspecified error
80 * - INVALID_ARGUMENT when one of the input arguments is
81 * invalid
Michael Butlerc7821102017-09-11 16:03:36 -070082 * @return preparedModel A handle to the resultant prepared model.
83 */
Michael Butler61ae6ed2017-09-11 20:27:50 -070084 prepareModel(Model model, IEvent event)
Michael Butler926df1e2017-09-19 16:26:47 -070085 generates (ErrorStatus status, IPreparedModel preparedModel);
Michael Butler376ec0c2017-07-27 18:28:20 -070086
Michael Butlerc7821102017-09-11 16:03:36 -070087 /**
88 * Returns the current status of a driver.
89 *
Michael Butler926df1e2017-09-19 16:26:47 -070090 * @return status Status of the driver, one of:
91 * - DeviceStatus::AVAILABLE
92 * - DeviceStatus::BUSY
93 * - DeviceStatus::OFFLINE
94 * - DeviceStatus::UNKNOWN
Michael Butlerc7821102017-09-11 16:03:36 -070095 */
Michael Butler61ae6ed2017-09-11 20:27:50 -070096 getStatus() generates (DeviceStatus status);
Michael Butler376ec0c2017-07-27 18:28:20 -070097};