• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SampleDriverPartial"
18 
19 #include "SampleDriverPartial.h"
20 
21 #include <HalInterfaces.h>
22 #include <Utils.h>
23 #include <ValidateHal.h>
24 #include <android-base/logging.h>
25 
26 #include <thread>
27 #include <vector>
28 
29 #include "SampleDriverUtils.h"
30 
31 namespace android {
32 namespace nn {
33 namespace sample_driver {
34 
getSupportedOperations_1_3(const V1_3::Model & model,getSupportedOperations_1_3_cb cb)35 hardware::Return<void> SampleDriverPartial::getSupportedOperations_1_3(
36         const V1_3::Model& model, getSupportedOperations_1_3_cb cb) {
37     VLOG(DRIVER) << "getSupportedOperations()";
38     if (validateModel(model)) {
39         std::vector<bool> supported = getSupportedOperationsImpl(model);
40         cb(V1_3::ErrorStatus::NONE, supported);
41     } else {
42         std::vector<bool> supported;
43         cb(V1_3::ErrorStatus::INVALID_ARGUMENT, supported);
44     }
45     return hardware::Void();
46 }
47 
prepareModel_1_3(const V1_3::Model & model,V1_1::ExecutionPreference preference,V1_3::Priority priority,const V1_3::OptionalTimePoint & deadline,const hardware::hidl_vec<hardware::hidl_handle> &,const hardware::hidl_vec<hardware::hidl_handle> &,const HalCacheToken &,const sp<V1_3::IPreparedModelCallback> & callback)48 hardware::Return<V1_3::ErrorStatus> SampleDriverPartial::prepareModel_1_3(
49         const V1_3::Model& model, V1_1::ExecutionPreference preference, V1_3::Priority priority,
50         const V1_3::OptionalTimePoint& deadline, const hardware::hidl_vec<hardware::hidl_handle>&,
51         const hardware::hidl_vec<hardware::hidl_handle>&, const HalCacheToken&,
52         const sp<V1_3::IPreparedModelCallback>& callback) {
53     std::vector<bool> supported = getSupportedOperationsImpl(model);
54     bool isModelFullySupported =
55             std::all_of(supported.begin(), supported.end(), [](bool v) { return v; });
56     return prepareModelBase(model, this, preference, priority, deadline, callback,
57                             isModelFullySupported);
58 }
59 
60 }  // namespace sample_driver
61 }  // namespace nn
62 }  // namespace android
63