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 17 #ifndef ANDROID_HARDWARE_NEURALNETWORKS_V1_0_PREPAREDMODEL_H 18 #define ANDROID_HARDWARE_NEURALNETWORKS_V1_0_PREPAREDMODEL_H 19 20 #include <android/hardware/neuralnetworks/1.0/IPreparedModel.h> 21 #include <hidl/MQDescriptor.h> 22 #include <hidl/Status.h> 23 #include <memory> 24 #include "HexagonModel.h" 25 #include "hexagon_nn_controller/hexagon_nn_controller.h" 26 27 namespace android { 28 namespace hardware { 29 namespace neuralnetworks { 30 namespace V1_0 { 31 namespace implementation { 32 33 using ::android::sp; 34 using ::android::hardware::hidl_array; 35 using ::android::hardware::hidl_memory; 36 using ::android::hardware::hidl_string; 37 using ::android::hardware::hidl_vec; 38 using ::android::hardware::Return; 39 using ::android::hardware::Void; 40 41 struct PreparedModel : public IPreparedModel { 42 private: 43 PreparedModel() = delete; 44 PreparedModel(const PreparedModel&) = delete; 45 PreparedModel(PreparedModel&&) = delete; 46 PreparedModel& operator=(const PreparedModel&) = delete; 47 PreparedModel& operator=(PreparedModel&&) = delete; 48 49 public: 50 PreparedModel(const Model& neuralNetworksModel, 51 const std::shared_ptr<hexagon::Model>& hexagonModel); 52 ~PreparedModel() override; 53 54 // Methods from IPreparedModel follow. 55 Return<ErrorStatus> execute(const Request& request, 56 const sp<IExecutionCallback>& callback) override; 57 58 private: 59 Model mNeuralNetworksModel; 60 std::shared_ptr<hexagon::Model> mHexagonModel; 61 }; 62 63 } // namespace implementation 64 } // namespace V1_0 65 } // namespace neuralnetworks 66 } // namespace hardware 67 } // namespace android 68 69 #endif // ANDROID_HARDWARE_NEURALNETWORKS_V1_0_PREPAREDMODEL_H 70