OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[core] Move malloc_tim to compile model implementation (#27881)
Pawel Raasz395340ef1dd6
diff --git a/src/inference/dev_api/openvino/runtime/icompiled_model.hpp b/src/inference/dev_api/openvino/runtime/icompiled_model.hppindex 01f7b556da9..3a3d5d99103 100644--- a/src/inference/dev_api/openvino/runtime/icompiled_model.hpp+++ b/src/inference/dev_api/openvino/runtime/icompiled_model.hpp@@ -136,11 +136,11 @@ public:/*** @brief Release intermediate memory- *+ **/virtual void release_memory();- virtual ~ICompiledModel() = default;+ virtual ~ICompiledModel();private:std::shared_ptr<const ov::IPlugin> m_plugin;diff --git a/src/inference/src/cpp/compiled_model.cpp b/src/inference/src/cpp/compiled_model.cppindex d675cba4714..c780bbee1e9 100644--- a/src/inference/src/cpp/compiled_model.cpp+++ b/src/inference/src/cpp/compiled_model.cpp@@ -8,10 +8,6 @@#include "openvino/runtime/icompiled_model.hpp"#include "openvino/runtime/properties.hpp"-#if defined(OPENVINO_GNU_LIBC) && !defined(__ANDROID__)-# include <malloc.h>-#endif-#define OV_COMPILED_MODEL_CALL_STATEMENT(...) \if (_impl == nullptr) \OPENVINO_THROW("CompiledModel was not initialized."); \@@ -27,12 +23,6 @@ namespace ov {CompiledModel::~CompiledModel() {_impl = {};-#if defined(OPENVINO_GNU_LIBC) && !defined(__ANDROID__)- // Linux memory margent doesn't return system memory immediate after release.- // It depends on memory chunk size and allocation history.- // Try return memory from a process to system now to reduce memory usage and not wait to the end of the process.- malloc_trim(0);-#endif}CompiledModel::CompiledModel(const std::shared_ptr<ov::ICompiledModel>& impl, const std::shared_ptr<void>& so)diff --git a/src/inference/src/dev/icompiled_model.cpp b/src/inference/src/dev/icompiled_model.cppindex b1cbedac163..f452dd3a330 100644--- a/src/inference/src/dev/icompiled_model.cpp+++ b/src/inference/src/dev/icompiled_model.cpp@@ -10,6 +10,10 @@#include "openvino/runtime/properties.hpp"#include "transformations/utils/utils.hpp"+#if defined(OPENVINO_GNU_LIBC) && !defined(__ANDROID__)+# include <malloc.h>+#endif+ov::ICompiledModel::ICompiledModel(const std::shared_ptr<const ov::Model>& model,const std::shared_ptr<const ov::IPlugin>& plugin,const std::shared_ptr<ov::threading::ITaskExecutor>& task_executor,@@ -151,3 +155,12 @@ void ov::ICompiledModel::set_model_shared_object(ov::Model& model, const std::shvoid ov::ICompiledModel::release_memory() {// nothing to do}++ov::ICompiledModel::~ICompiledModel() {+#if defined(OPENVINO_GNU_LIBC) && !defined(__ANDROID__)+ // Linux memory margent doesn't return system memory immediate after release.+ // It depends on memory chunk size and allocation history.+ // Try return memory from a process to system now to reduce memory usage and not wait to the end of the process.+ malloc_trim(0);+#endif+}