From 0ba48adb4c9952acab9f3e6f8f42ae4411663520 Mon Sep 17 00:00:00 2001 From: "Durandin, Pavel" Date: Fri, 28 Nov 2025 19:18:06 +0400 Subject: [PATCH 1/6] [GPU] Clean oneDNN cache --- samples/cpp/benchmark_app/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 7f90d31707f3be..047ba7f27df81d 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -1414,6 +1414,9 @@ int main(int argc, char* argv[]) { } } + // release static oneDNN cache used for inference + compiledModel.release_memory(); + slog::info << "Throughput: " << double_to_string(fps) << " FPS" << slog::endl; } catch (const std::exception& ex) { From e29dd005749962d031819ada1bf672778230d0dc Mon Sep 17 00:00:00 2001 From: "Durandin, Pavel" Date: Fri, 5 Dec 2025 11:45:21 +0400 Subject: [PATCH 2/6] [GPU] Clean oneDNN cache --- samples/cpp/benchmark_app/main.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 047ba7f27df81d..1f54e5aecdb4d2 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -329,6 +329,27 @@ void fuse_mean_scale(ov::preprocess::PrePostProcessor& preproc, const benchmark_ } } // namespace +/** + * Sentry class to ensure the resource releasing from CompiledModel. + * Release static oneDNN cache used for inference with release_memory + * method. To be called once at the end of inference + */ +class model_sentry { +public: + model_sentry(ov::CompiledModel& compiledModel) : + my_model(compiledModel) {} + + ~model_sentry() { + if (my_model) { + my_model.release_memory(); + } + } + +private: + ov::CompiledModel& my_model; +}; + + /** * @brief The entry point of the benchmark application */ @@ -337,6 +358,8 @@ int main(int argc, char* argv[]) { try { ov::CompiledModel compiledModel; + model_sentry releaser(compiledModel); + // ----------------- 1. Parsing and validating input arguments // ------------------------------------------------- next_step(); @@ -1414,9 +1437,6 @@ int main(int argc, char* argv[]) { } } - // release static oneDNN cache used for inference - compiledModel.release_memory(); - slog::info << "Throughput: " << double_to_string(fps) << " FPS" << slog::endl; } catch (const std::exception& ex) { From 405785cef582223b2bd51dd7f3bf68398ccc2939 Mon Sep 17 00:00:00 2001 From: "Durandin, Pavel" Date: Fri, 5 Dec 2025 12:07:54 +0400 Subject: [PATCH 3/6] [GPU] Clean oneDNN cache --- samples/cpp/benchmark_app/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 1f54e5aecdb4d2..4184b16aeacf23 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -331,22 +331,22 @@ void fuse_mean_scale(ov::preprocess::PrePostProcessor& preproc, const benchmark_ /** * Sentry class to ensure the resource releasing from CompiledModel. - * Release static oneDNN cache used for inference with release_memory - * method. To be called once at the end of inference + * Release static global oneDNN cache used for inference with release_memory + * method. To be called once at the end of inference. */ class model_sentry { public: model_sentry(ov::CompiledModel& compiledModel) : - my_model(compiledModel) {} + _model(compiledModel) {} ~model_sentry() { - if (my_model) { - my_model.release_memory(); + if (_model) { + _model.release_memory(); } } private: - ov::CompiledModel& my_model; + ov::CompiledModel _model; }; From eee7dc5dbdc7a3713bc0a1109552f0985d364474 Mon Sep 17 00:00:00 2001 From: "Durandin, Pavel" Date: Fri, 5 Dec 2025 12:40:24 +0400 Subject: [PATCH 4/6] [GPU] Clean oneDNN cache --- samples/cpp/benchmark_app/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 4184b16aeacf23..fc769bf6c23383 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -336,8 +336,7 @@ void fuse_mean_scale(ov::preprocess::PrePostProcessor& preproc, const benchmark_ */ class model_sentry { public: - model_sentry(ov::CompiledModel& compiledModel) : - _model(compiledModel) {} + model_sentry(ov::CompiledModel& compiledModel) : _model(compiledModel) {} ~model_sentry() { if (_model) { From 674cae9703aca4f5c2ee90cea100d5f5e95401d6 Mon Sep 17 00:00:00 2001 From: "Durandin, Pavel" Date: Fri, 5 Dec 2025 13:06:52 +0400 Subject: [PATCH 5/6] [GPU] Clean oneDNN cache --- samples/cpp/benchmark_app/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index fc769bf6c23383..bb012779c9dcdd 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -348,7 +348,6 @@ class model_sentry { ov::CompiledModel _model; }; - /** * @brief The entry point of the benchmark application */ From 572803243e5915a5dfa918ec3d1e7aa00ea09564 Mon Sep 17 00:00:00 2001 From: "Durandin, Pavel" Date: Fri, 5 Dec 2025 13:24:24 +0400 Subject: [PATCH 6/6] [GPU] Clean oneDNN cache --- samples/cpp/benchmark_app/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index bb012779c9dcdd..05ba4a540773ca 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -334,11 +334,11 @@ void fuse_mean_scale(ov::preprocess::PrePostProcessor& preproc, const benchmark_ * Release static global oneDNN cache used for inference with release_memory * method. To be called once at the end of inference. */ -class model_sentry { +class ModelSentry { public: - model_sentry(ov::CompiledModel& compiledModel) : _model(compiledModel) {} + ModelSentry(ov::CompiledModel& compiledModel) : _model(compiledModel) {} - ~model_sentry() { + ~ModelSentry() { if (_model) { _model.release_memory(); } @@ -356,7 +356,7 @@ int main(int argc, char* argv[]) { try { ov::CompiledModel compiledModel; - model_sentry releaser(compiledModel); + ModelSentry releaser(compiledModel); // ----------------- 1. Parsing and validating input arguments // -------------------------------------------------