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