summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'neuralnetworks/1.0/IDevice.hal')
-rw-r--r--neuralnetworks/1.0/IDevice.hal126
1 files changed, 126 insertions, 0 deletions
diff --git a/neuralnetworks/1.0/IDevice.hal b/neuralnetworks/1.0/IDevice.hal
new file mode 100644
index 00000000..49c29674
--- /dev/null
+++ b/neuralnetworks/1.0/IDevice.hal
@@ -0,0 +1,126 @@
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
17package android.hardware.neuralnetworks@1.0;
18
19import IPreparedModelCallback;
20
21/**
22 * This interface represents a device driver.
23 */
24interface IDevice {
25 /**
26 * Gets the capabilities of a driver.
27 *
28 * @return status Error status of the call, must be:
29 * - NONE if successful
30 * - DEVICE_UNAVAILABLE if driver is offline or busy
31 * - GENERAL_FAILURE if there is an unspecified error
32 * @return capabilities Capabilities of the driver.
33 */
34 getCapabilities() generates (ErrorStatus status, Capabilities capabilities);
35
36 /**
37 * Gets the supported operations in a model.
38 *
39 * getSupportedSubgraph indicates which operations of a model are fully
40 * supported by the vendor driver. If an operation may not be supported for
41 * any reason, getSupportedOperations must return false for that operation.
42 *
43 * @param model A model whose operations--and their corresponding
44 * operands--are to be verified by the driver.
45 * @return status Error status of the call, must be:
46 * - NONE if successful
47 * - DEVICE_UNAVAILABLE if driver is offline or busy
48 * - GENERAL_FAILURE if there is an unspecified error
49 * - INVALID_ARGUMENT if provided model is invalid
50 * @return supportedOperations A list of supported operations, where true
51 * indicates the operation is supported and
52 * false indicates the operation is not
53 * supported. The index of "supported"
54 * corresponds with the index of the operation
55 * it is describing.
56 */
57 getSupportedOperations(Model model)
58 generates (ErrorStatus status, vec<bool> supportedOperations);
59
60 /**
61 * Creates a prepared model for execution.
62 *
63 * prepareModel is used to make any necessary transformations or alternative
64 * representations to a model for execution, possiblly including
65 * transformations on the constant data, optimization on the model's graph,
66 * or compilation into the device's native binary format. The model itself
67 * is not changed.
68 *
69 * The model is prepared asynchronously with respect to the caller. The
70 * prepareModel function must verify the inputs to the prepareModel function
71 * are correct. If there is an error, prepareModel must immediately invoke
72 * the callback with the appropriate ErrorStatus value and nullptr for the
73 * IPreparedModel, then return with the same ErrorStatus. If the inputs to
74 * the prepareModel function are valid and there is no error, prepareModel
75 * must launch an asynchronous task to prepare the model in the background,
76 * and immediately return from prepareModel with ErrorStatus::NONE. If the
77 * asynchronous task fails to launch, prepareModel must immediately invoke
78 * the callback with ErrorStatus::GENERAL_FAILURE and nullptr for the
79 * IPreparedModel, then return with ErrorStatus::GENERAL_FAILURE.
80 *
81 * When the asynchronous task has finished preparing the model, it must
82 * immediately invoke the callback function provided as an input to
83 * prepareModel. If the model was prepared successfully, the callback object
84 * must be invoked with an error status of ErrorStatus::NONE and the
85 * produced IPreparedModel object. If an error occurred preparing the model,
86 * the callback object must be invoked with the appropriate ErrorStatus
87 * value and nullptr for the IPreparedModel.
88 *
89 * The only information that may be unknown to the model at this stage is
90 * the shape of the tensors, which may only be known at execution time. As
91 * such, some driver services may return partially prepared models, where
92 * the prepared model can only be finished when it is paired with a set of
93 * inputs to the model. Note that the same prepared model object can be
94 * used with different shapes of inputs on different (possibly concurrent)
95 * executions.
96 *
97 * Multiple threads can call prepareModel on the same model concurrently.
98 *
99 * @param model The model to be prepared for execution.
100 * @param callback A callback object used to return the error status of
101 * preparing the model for execution and the prepared model
102 * if successful, nullptr otherwise. The callback object's
103 * notify function must be called exactly once, even if the
104 * model could not be prepared.
105 * @return status Error status of launching a task which prepares the model
106 * in the background; must be:
107 * - NONE if preparation task is successfully launched
108 * - DEVICE_UNAVAILABLE if driver is offline or busy
109 * - GENERAL_FAILURE if there is an unspecified error
110 * - INVALID_ARGUMENT if one of the input arguments is
111 * invalid
112 */
113 prepareModel(Model model, IPreparedModelCallback callback)
114 generates (ErrorStatus status);
115
116 /**
117 * Returns the current status of a driver.
118 *
119 * @return status Status of the driver, one of:
120 * - DeviceStatus::AVAILABLE
121 * - DeviceStatus::BUSY
122 * - DeviceStatus::OFFLINE
123 * - DeviceStatus::UNKNOWN
124 */
125 getStatus() generates (DeviceStatus status);
126};