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