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
[GPU] dynamic model gets the memory from non_padded_pool (#31896)
Sungeun Kimed3986d36da8
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory_pool.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory_pool.hppindex 66146198302..e02b567c611 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory_pool.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory_pool.hpp@@ -157,7 +157,6 @@ class memory_pool {std::multimap<uint64_t, memory_record> _non_padded_pool;std::map<layout, std::list<memory_record>, padded_pool_comparer> _padded_pool;- std::multimap<uint64_t, memory_record> _no_reusable_pool;engine* _engine;const ExecutionConfig& _config;diff --git a/src/plugins/intel_gpu/src/runtime/memory_pool.cpp b/src/plugins/intel_gpu/src/runtime/memory_pool.cppindex 64d5c532443..8bfed34bf0d 100644--- a/src/plugins/intel_gpu/src/runtime/memory_pool.cpp+++ b/src/plugins/intel_gpu/src/runtime/memory_pool.cpp@@ -270,30 +270,9 @@ memory::ptr memory_pool::get_memory(const layout& layout,GPU_DEBUG_IF(_config.get_disable_memory_reuse()) {do_reuse = false;}- if (do_reuse) {- // reusable within the same network- if (!layout.format.is_image() && !layout.data_padding) {- // non-padded buffers- return get_from_non_padded_pool(layout, prim_id, unique_id, network_id, restrictions, type, reset, is_dynamic);- } else if (!layout.format.is_image()) {- // padded buffers- return get_from_padded_pool(layout, prim_id, unique_id, network_id, restrictions, type);- } else {- // images (reuse not yet implemented)- auto mem = alloc_memory(layout, type, reset);-#ifdef GPU_DEBUG_CONFIG- GPU_DEBUG_IF(_config.get_dump_memory_pool()) {- auto allocated_mem_size = mem->size();- _no_reusable_mems.push_back(- memory_record({{MEM_USER(unique_id, network_id, prim_id, allocated_mem_size)}}, mem, network_id, type));- total_mem_size_no_reusable += allocated_mem_size;- if (type == allocation_type::usm_host)- mem_size_no_reusable_host += allocated_mem_size;- }-#endif- return mem;- }- } else {++ if (!do_reuse || layout.format.is_image()) {+ // images (reuse not yet implemented)auto mem = alloc_memory(layout, type, reset);#ifdef GPU_DEBUG_CONFIGGPU_DEBUG_IF(_config.get_dump_memory_pool()) {@@ -306,6 +285,12 @@ memory::ptr memory_pool::get_memory(const layout& layout,}#endifreturn mem;+ } else if (!layout.data_padding || is_dynamic) {+ // non-padded buffers. For dynamic shape, use non-padded pool even if it has padding because we will reset the buffer if it is reused+ return get_from_non_padded_pool(layout, prim_id, unique_id, network_id, restrictions, type, reset, is_dynamic);+ } else {+ // padded buffers+ return get_from_padded_pool(layout, prim_id, unique_id, network_id, restrictions, type);}}@@ -387,21 +372,6 @@ void memory_pool::clear_pool_for_network(uint32_t network_id) {}}#endif-- // free up _no_reusable_pool for this network- {- auto itr = _no_reusable_pool.begin();-- while (itr != _no_reusable_pool.end()) {- auto& record = itr->second;-- if (record._network_id == network_id) {- itr = _no_reusable_pool.erase(itr);- } else {- itr++;- }- }- }}memory_pool::memory_pool(engine& engine, const ExecutionConfig& config) : _engine(&engine), _config(config) {