2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ML_ML_SINGLE_MANAGER_H_
18 #define ML_ML_SINGLE_MANAGER_H_
22 #include "common/platform_result.h"
24 #include "ml_singleshot.h"
25 #include "ml_tensors_info_manager.h"
26 #include "nnstreamer/nnstreamer-single.h"
28 using common::PlatformResult;
35 SingleManager(TensorsInfoManager* tim);
38 SingleManager() = delete;
39 SingleManager(const SingleManager&) = delete;
40 SingleManager& operator=(const SingleManager&) = delete;
42 // MachineLearningSingle::openModel()
43 PlatformResult OpenModel(const std::string& modelPath, TensorsInfo* inTensorsInfo,
44 TensorsInfo* outTensorsInfo, ml_nnfw_type_e nnfw_e, ml_nnfw_hw_e hw_e,
45 bool isDynamicMode, int* res_id);
46 // MachineLearningSingle::openModelAsync()
47 // OpenModelSuccessCallback
48 PlatformResult GetNativeTensorsInfo(int id, bool get_input_mode, int* res_id);
49 PlatformResult SetNativeInputInfo(int id, TensorsInfo* inTensorsInfo);
50 PlatformResult Invoke(int id, TensorsData* in_tensors_data, TensorsData** out_tensors_data);
51 PlatformResult GetValue(int id, const std::string& name, std::string& value);
52 PlatformResult SetValue(int id, const std::string& name, const std::string& value);
53 PlatformResult SetTimeout(int id, unsigned long timeout);
54 PlatformResult Close(int id);
58 std::map<int, std::unique_ptr<SingleShot>> singles_;
59 std::mutex singles_mutex_;
60 TensorsInfoManager* tim_;
61 SingleShot* GetSingleShot(int id);
65 } // namespace extension
67 #endif // ML_ML_SINGLE_MANAGER_H_