1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 17 #ifndef NEURAL_NETWORK_RUNTIME_HDI_PREPARED_MODEL_H 18 #define NEURAL_NETWORK_RUNTIME_HDI_PREPARED_MODEL_H 19 20 #include <vector> 21 22 #include "refbase.h" 23 #include "hdi_interfaces.h" 24 #include "prepared_model.h" 25 #include "cpp_type.h" 26 27 namespace OHOS { 28 namespace NeuralNetworkRuntime { 29 class HDIPreparedModel : public PreparedModel { 30 public: 31 explicit HDIPreparedModel(OHOS::sptr<V1_0::IPreparedModel> hdiPreparedModel); 32 33 OH_NN_ReturnCode ExportModelCache(std::vector<ModelBuffer>& modelCache) override; 34 35 OH_NN_ReturnCode Run(const std::vector<IOTensor>& inputs, 36 const std::vector<IOTensor>& outputs, 37 std::vector<std::vector<int32_t>>& outputsDims, 38 std::vector<bool>& isOutputBufferEnough) override; 39 40 private: 41 // first: major version, second: minor version 42 std::pair<uint32_t, uint32_t> m_hdiVersion; 43 OHOS::sptr<V1_0::IPreparedModel> m_hdiPreparedModel {nullptr}; 44 }; 45 } // namespace NeuralNetworkRuntime 46 } // OHOS 47 #endif // NEURAL_NETWORK_RUNTIME_HDI_PREPARED_MODEL_H