Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 1 | /* |
| 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 Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 17 | package android.hardware.neuralnetworks@1.0; |
| 18 | |
Michael Butler | e9dc167 | 2017-09-11 13:53:19 -0700 | [diff] [blame] | 19 | import IEvent; |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 20 | import IPreparedModel; |
| 21 | |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 22 | /** |
| 23 | * This interface represents a device driver. |
| 24 | */ |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 25 | interface IDevice { |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Gets the capabilities of a driver. |
| 28 | * |
Michael Butler | 926df1e | 2017-09-19 16:26:47 -0700 | [diff] [blame] | 29 | * @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 Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 33 | * @return capabilities Capabilities of the driver. |
| 34 | */ |
Michael Butler | 61ae6ed | 2017-09-11 20:27:50 -0700 | [diff] [blame] | 35 | getCapabilities() generates (ErrorStatus status, Capabilities capabilities); |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 36 | |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 37 | /** |
| 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 Butler | 926df1e | 2017-09-19 16:26:47 -0700 | [diff] [blame] | 47 | * @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 Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 52 | * @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 Butler | 61ae6ed | 2017-09-11 20:27:50 -0700 | [diff] [blame] | 59 | getSupportedOperations(Model model) |
Michael Butler | 926df1e | 2017-09-19 16:26:47 -0700 | [diff] [blame] | 60 | generates (ErrorStatus status, vec<bool> supportedOperations); |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 61 | |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 62 | /** |
| 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 Butler | 926df1e | 2017-09-19 16:26:47 -0700 | [diff] [blame] | 68 | * or compilation into the device's native binary format. |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 69 | * |
| 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 Butler | 926df1e | 2017-09-19 16:26:47 -0700 | [diff] [blame] | 76 | * @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 Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 82 | * @return preparedModel A handle to the resultant prepared model. |
| 83 | */ |
Michael Butler | 61ae6ed | 2017-09-11 20:27:50 -0700 | [diff] [blame] | 84 | prepareModel(Model model, IEvent event) |
Michael Butler | 926df1e | 2017-09-19 16:26:47 -0700 | [diff] [blame] | 85 | generates (ErrorStatus status, IPreparedModel preparedModel); |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 86 | |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 87 | /** |
| 88 | * Returns the current status of a driver. |
| 89 | * |
Michael Butler | 926df1e | 2017-09-19 16:26:47 -0700 | [diff] [blame] | 90 | * @return status Status of the driver, one of: |
| 91 | * - DeviceStatus::AVAILABLE |
| 92 | * - DeviceStatus::BUSY |
| 93 | * - DeviceStatus::OFFLINE |
| 94 | * - DeviceStatus::UNKNOWN |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 95 | */ |
Michael Butler | 61ae6ed | 2017-09-11 20:27:50 -0700 | [diff] [blame] | 96 | getStatus() generates (DeviceStatus status); |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 97 | }; |