blob: b6f94330a29ecaecf54a63dd6304bf3d2c429396 [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
17/* This HAL is a work in progress */
18
19package android.hardware.neuralnetworks@1.0;
20
Michael Butlere9dc1672017-09-11 13:53:19 -070021import IEvent;
Michael Butler376ec0c2017-07-27 18:28:20 -070022import IPreparedModel;
23
Michael Butlerc7821102017-09-11 16:03:36 -070024/**
25 * This interface represents a device driver.
26 */
Michael Butler376ec0c2017-07-27 18:28:20 -070027interface IDevice {
Michael Butlerc7821102017-09-11 16:03:36 -070028 /**
29 * Gets the capabilities of a driver.
30 *
31 * @return status ErrorStatus::NONE if successful.
32 * @return capabilities Capabilities of the driver.
33 */
Michael Butler61ae6ed2017-09-11 20:27:50 -070034 getCapabilities() generates (ErrorStatus status, Capabilities capabilities);
Michael Butler376ec0c2017-07-27 18:28:20 -070035
Michael Butlerc7821102017-09-11 16:03:36 -070036 /**
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 Butler61ae6ed2017-09-11 20:27:50 -070054 getSupportedOperations(Model model)
55 generates (ErrorStatus status, vec<bool> supportedOperations);
Michael Butler376ec0c2017-07-27 18:28:20 -070056
Michael Butlerc7821102017-09-11 16:03:36 -070057 /**
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 Butler61ae6ed2017-09-11 20:27:50 -070074 prepareModel(Model model, IEvent event)
75 generates (ErrorStatus status, IPreparedModel preparedModel);
Michael Butler376ec0c2017-07-27 18:28:20 -070076
Michael Butlerc7821102017-09-11 16:03:36 -070077 /**
78 * Returns the current status of a driver.
79 *
80 * @return status Status of the driver.
81 */
Michael Butler61ae6ed2017-09-11 20:27:50 -070082 getStatus() generates (DeviceStatus status);
Michael Butler376ec0c2017-07-27 18:28:20 -070083};