1 /*
2 * Copyright (C) 2019 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 #define LOG_TAG "SampleDriverFull"
18
19 #include "SampleDriverFull.h"
20
21 #include <Utils.h>
22 #include <ValidateHal.h>
23
24 #include <vector>
25
26 namespace android {
27 namespace nn {
28 namespace sample_driver {
29
getCapabilities_1_3(getCapabilities_1_3_cb cb)30 hardware::Return<void> SampleDriverFull::getCapabilities_1_3(getCapabilities_1_3_cb cb) {
31 android::nn::initVLogMask();
32 VLOG(DRIVER) << "getCapabilities_1_3()";
33 V1_3::Capabilities capabilities = {
34 .relaxedFloat32toFloat16PerformanceScalar = mPerf,
35 .relaxedFloat32toFloat16PerformanceTensor = mPerf,
36 .operandPerformance = nonExtensionOperandPerformance<HalVersion::V1_3>(mPerf),
37 .ifPerformance = mPerf,
38 .whilePerformance = mPerf};
39 cb(V1_3::ErrorStatus::NONE, capabilities);
40 return hardware::Void();
41 }
42
getSupportedOperations_1_3(const V1_3::Model & model,getSupportedOperations_1_3_cb cb)43 hardware::Return<void> SampleDriverFull::getSupportedOperations_1_3(
44 const V1_3::Model& model, getSupportedOperations_1_3_cb cb) {
45 VLOG(DRIVER) << "getSupportedOperations_1_3()";
46 if (validateModel(model)) {
47 const size_t count = model.main.operations.size();
48 std::vector<bool> supported(count, true);
49 for (size_t i = 0; i < count; i++) {
50 const V1_3::Operation& operation = model.main.operations[i];
51 supported[i] = !isExtensionOperationType(operation.type);
52 }
53 cb(V1_3::ErrorStatus::NONE, supported);
54 } else {
55 std::vector<bool> supported;
56 cb(V1_3::ErrorStatus::INVALID_ARGUMENT, supported);
57 }
58 return hardware::Void();
59 }
60
61 } // namespace sample_driver
62 } // namespace nn
63 } // namespace android
64