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 | |
| 17 | /* This HAL is a work in progress */ |
| 18 | |
| 19 | package android.hardware.neuralnetworks@1.0; |
| 20 | |
Michael Butler | e9dc167 | 2017-09-11 13:53:19 -0700 | [diff] [blame] | 21 | import IEvent; |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 22 | import IPreparedModel; |
| 23 | |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 24 | /** |
| 25 | * This interface represents a device driver. |
| 26 | */ |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 27 | interface IDevice { |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 28 | /** |
| 29 | * Gets the capabilities of a driver. |
| 30 | * |
| 31 | * @return status ErrorStatus::NONE if successful. |
| 32 | * @return capabilities Capabilities of the driver. |
| 33 | */ |
Michael Butler | 61ae6ed | 2017-09-11 20:27:50 -0700 | [diff] [blame] | 34 | getCapabilities() generates (ErrorStatus status, Capabilities capabilities); |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 35 | |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 36 | /** |
| 37 | * Gets the supported operations in a model. |
| 38 | * |
| 39 | * getSupportedSubgraph provides a more nuanced indication on whether a |
| 40 | * model is able to be compiled by the driver. Having the entire model |
| 41 | * allows for additional information such as tensor shapes to inputs or |
| 42 | * tensor strides, information which is not known in "initialize". |
| 43 | * |
| 44 | * @param model A model whose operations--and their corresponding |
| 45 | * operands--are to be verified by the driver. |
| 46 | * @return status ErrorStatus::NONE if successful. |
| 47 | * @return supportedOperations A list of supported operations, where true |
| 48 | * indicates the operation is supported and |
| 49 | * false indicates the operation is not |
| 50 | * supported. The index of "supported" |
| 51 | * corresponds with the index of the operation |
| 52 | * it is describing. |
| 53 | */ |
Michael Butler | 61ae6ed | 2017-09-11 20:27:50 -0700 | [diff] [blame] | 54 | getSupportedOperations(Model model) |
| 55 | generates (ErrorStatus status, vec<bool> supportedOperations); |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 56 | |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 57 | /** |
| 58 | * Prepares a model for execution. |
| 59 | * |
| 60 | * prepareModel is used to make any necessary transformations or alternative |
| 61 | * representations to a model for execution, possible including |
| 62 | * transformations on the constant data, optimization on the model's graph, |
| 63 | * or compilation into the device's native binary. |
| 64 | * |
| 65 | * The only information that may be unknown to the model at this stage is |
| 66 | * the shape of the tensors, which may only be known at execution time. |
| 67 | * |
| 68 | * @param model The model to be prepared for execution. |
| 69 | * @param event A synchronization callback that must be signaled once the |
| 70 | * execution has finished. |
| 71 | * @return status ErrorStatus::NONE if successful. |
| 72 | * @return preparedModel A handle to the resultant prepared model. |
| 73 | */ |
Michael Butler | 61ae6ed | 2017-09-11 20:27:50 -0700 | [diff] [blame] | 74 | prepareModel(Model model, IEvent event) |
| 75 | generates (ErrorStatus status, IPreparedModel preparedModel); |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 76 | |
Michael Butler | c782110 | 2017-09-11 16:03:36 -0700 | [diff] [blame] | 77 | /** |
| 78 | * Returns the current status of a driver. |
| 79 | * |
| 80 | * @return status Status of the driver. |
| 81 | */ |
Michael Butler | 61ae6ed | 2017-09-11 20:27:50 -0700 | [diff] [blame] | 82 | getStatus() generates (DeviceStatus status); |
Michael Butler | 376ec0c | 2017-07-27 18:28:20 -0700 | [diff] [blame] | 83 | }; |