1111
1212#include " utils/config.h"
1313
14- void OpenVINOInferenceAdapter::loadModel (const std::shared_ptr<const ov::Model>& model,
15- ov::Core& core,
16- const std::string& device,
17- const ov::AnyMap& compilationConfig,
18- size_t max_num_requests) {
19- ov::AnyMap customCompilationConfig (compilationConfig);
20- if (max_num_requests != 1 ) {
21- if (customCompilationConfig.find (" PERFORMANCE_HINT" ) == customCompilationConfig.end ()) {
22- customCompilationConfig[" PERFORMANCE_HINT" ] = ov::hint::PerformanceMode::THROUGHPUT;
23- }
24- if (max_num_requests > 0 ) {
25- if (customCompilationConfig.find (" PERFORMANCE_HINT_NUM_REQUESTS" ) == customCompilationConfig.end ()) {
26- customCompilationConfig[" PERFORMANCE_HINT_NUM_REQUESTS" ] = ov::hint::num_requests (max_num_requests);
27- }
28- }
29- } else {
30- if (customCompilationConfig.find (" PERFORMANCE_HINT" ) == customCompilationConfig.end ()) {
31- customCompilationConfig[" PERFORMANCE_HINT" ] = ov::hint::PerformanceMode::LATENCY;
32- }
33- }
34-
35- compiledModel = core.compile_model (model, device, customCompilationConfig);
36- asyncQueue = std::make_unique<AsyncInferQueue>(compiledModel, max_num_requests);
37- initInputsOutputs ();
38-
39- if (model->has_rt_info ({" model_info" })) {
40- modelConfig = model->get_rt_info <ov::AnyMap>(" model_info" );
41- }
42- }
43-
4414void OpenVINOInferenceAdapter::compileModel (const std::string& device, const ov::AnyMap& adapterConfig) {
4515 if (!model) {
4616 throw std::runtime_error (" Model is not loaded" );
@@ -70,10 +40,10 @@ void OpenVINOInferenceAdapter::compileModel(const std::string& device, const ov:
7040 initInputsOutputs ();
7141}
7242
73- void OpenVINOInferenceAdapter::loadModelFile (const std::string& modelPath,
74- const std::string& device,
75- const ov::AnyMap& adapterConfig,
76- bool preCompile) {
43+ void OpenVINOInferenceAdapter::loadModel (const std::string& modelPath,
44+ const std::string& device,
45+ const ov::AnyMap& adapterConfig,
46+ bool preCompile) {
7747 ov::Core core;
7848 model = core.read_model (modelPath);
7949 if (model->has_rt_info ({" model_info" })) {
@@ -84,11 +54,14 @@ void OpenVINOInferenceAdapter::loadModelFile(const std::string& modelPath,
8454 }
8555}
8656
87- void OpenVINOInferenceAdapter::applyModelTransform (std::function<void (std::shared_ptr<ov::Model>&)> func ) {
57+ void OpenVINOInferenceAdapter::applyModelTransform (std::function<void (std::shared_ptr<ov::Model>&)> t ) {
8858 if (!model) {
8959 throw std::runtime_error (" Model is not loaded" );
9060 }
91- func (model);
61+ t (model);
62+ if (model->has_rt_info ({" model_info" })) {
63+ modelConfig = model->get_rt_info <ov::AnyMap>(" model_info" );
64+ }
9265}
9366
9467void OpenVINOInferenceAdapter::infer (const InferenceInput& input, InferenceOutput& output) {
0 commit comments