[GPU] Fixed reordered memory cache not to contain original weight memory (#19465)
* Fixed reordered memory cache not to contain original weight memory * Applied review comment * Applied review comment
This commit is contained in:
parent
36b9de1f25
commit
e8f1df495c
@ -149,7 +149,14 @@ public:
|
|||||||
|
|
||||||
memory::ptr weights_memory() const {
|
memory::ptr weights_memory() const {
|
||||||
if (is_dynamic()) {
|
if (is_dynamic()) {
|
||||||
auto weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout);
|
memory::ptr weights_mem = nullptr;
|
||||||
|
auto weights_layout = *_impl_params->weights_layout;
|
||||||
|
auto weights_idx = node->get_deform_conv_dep_offset() + 1;
|
||||||
|
if (weights_layout.compatible(get_node().get_input_layout(weights_idx))) {
|
||||||
|
weights_mem = dep_memory_ptr(weights_idx);
|
||||||
|
} else {
|
||||||
|
weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout);
|
||||||
|
}
|
||||||
OPENVINO_ASSERT(weights_mem != nullptr, "[GPU] Can't find proper weights memory buffer in cache");
|
OPENVINO_ASSERT(weights_mem != nullptr, "[GPU] Can't find proper weights memory buffer in cache");
|
||||||
return weights_mem;
|
return weights_mem;
|
||||||
} else { // all weights are in one buffer
|
} else { // all weights are in one buffer
|
||||||
|
@ -81,7 +81,14 @@ public:
|
|||||||
|
|
||||||
memory::ptr weights_memory() const {
|
memory::ptr weights_memory() const {
|
||||||
if (is_dynamic()) {
|
if (is_dynamic()) {
|
||||||
auto weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout);
|
memory::ptr weights_mem = nullptr;
|
||||||
|
auto weights_layout = *_impl_params->weights_layout;
|
||||||
|
size_t weights_idx = 1;
|
||||||
|
if (weights_layout.compatible(get_node().get_input_layout(weights_idx))) {
|
||||||
|
weights_mem = dep_memory_ptr(weights_idx);
|
||||||
|
} else {
|
||||||
|
weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout);
|
||||||
|
}
|
||||||
OPENVINO_ASSERT(weights_mem != nullptr, "[GPU] Can't find proper weights memory buffer in cache");
|
OPENVINO_ASSERT(weights_mem != nullptr, "[GPU] Can't find proper weights memory buffer in cache");
|
||||||
return weights_mem;
|
return weights_mem;
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,7 +54,15 @@ public:
|
|||||||
|
|
||||||
memory::ptr weights_memory() const {
|
memory::ptr weights_memory() const {
|
||||||
if (is_dynamic()) {
|
if (is_dynamic()) {
|
||||||
auto weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout);
|
memory::ptr weights_mem = nullptr;
|
||||||
|
auto weights_layout = *_impl_params->weights_layout;
|
||||||
|
size_t weights_idx = 1;
|
||||||
|
if (weights_layout.compatible(get_node().get_input_layout(weights_idx))) {
|
||||||
|
weights_mem = dep_memory_ptr(weights_idx);
|
||||||
|
} else {
|
||||||
|
weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout);
|
||||||
|
}
|
||||||
|
|
||||||
OPENVINO_ASSERT(weights_mem != nullptr, "[GPU] Can't find proper weights memory buffer in cache");
|
OPENVINO_ASSERT(weights_mem != nullptr, "[GPU] Can't find proper weights memory buffer in cache");
|
||||||
return weights_mem;
|
return weights_mem;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1137,7 +1137,6 @@ event::ptr primitive_inst::update_weights() {
|
|||||||
if (!reorder_kernel_params) {
|
if (!reorder_kernel_params) {
|
||||||
// If kernel doesn't says that it doesn't require weights reorder, but weights were reordered previously, then
|
// If kernel doesn't says that it doesn't require weights reorder, but weights were reordered previously, then
|
||||||
// incorrect memory buffer may be assigned, so reset cached weights for such case
|
// incorrect memory buffer may be assigned, so reset cached weights for such case
|
||||||
_reordered_weights_cache.add(original_layout, original_weights_memory);
|
|
||||||
_impl_params->weights_layout = optional_layout(original_layout);
|
_impl_params->weights_layout = optional_layout(original_layout);
|
||||||
} else {
|
} else {
|
||||||
auto expected_layout = reorder_kernel_params->get_output_layout();
|
auto expected_layout = reorder_kernel_params->get_output_layout();
|
||||||
@ -1153,7 +1152,6 @@ event::ptr primitive_inst::update_weights() {
|
|||||||
GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(true);
|
GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(true);
|
||||||
GPU_DEBUG_TRACE_DETAIL << id() << ": reinterpret original weights memory from " << original_layout.to_short_string()
|
GPU_DEBUG_TRACE_DETAIL << id() << ": reinterpret original weights memory from " << original_layout.to_short_string()
|
||||||
<< " to " << expected_layout.to_short_string() << std::endl;
|
<< " to " << expected_layout.to_short_string() << std::endl;
|
||||||
_reordered_weights_cache.add(expected_layout, engine.reinterpret_buffer(*original_weights_memory, expected_layout));
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(false);
|
GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(false);
|
||||||
@ -1186,7 +1184,7 @@ event::ptr primitive_inst::update_weights() {
|
|||||||
memory::ptr weights_memory = nullptr;
|
memory::ptr weights_memory = nullptr;
|
||||||
if (_reordered_weights_cache.is_full()) {
|
if (_reordered_weights_cache.is_full()) {
|
||||||
weights_memory = _reordered_weights_cache.get_lru_element().second;
|
weights_memory = _reordered_weights_cache.get_lru_element().second;
|
||||||
can_reuse = weights_memory->size() <= expected_layout.bytes_count() && (weights_memory->buffer_ptr() != original_weights_memory->buffer_ptr());
|
can_reuse = weights_memory->size() <= expected_layout.bytes_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can_reuse) {
|
if (can_reuse) {
|
||||||
|
Loading…
Reference in New Issue
Block a user