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] fix of memory statistic test (#29790)
Michal Miotk73d6a3c05791
diff --git a/src/plugins/intel_gpu/src/runtime/engine.cpp b/src/plugins/intel_gpu/src/runtime/engine.cppindex 73bceb8bea8..7df246f4120 100644--- a/src/plugins/intel_gpu/src/runtime/engine.cpp+++ b/src/plugins/intel_gpu/src/runtime/engine.cpp@@ -216,11 +216,9 @@ std::map<std::string, uint64_t> engine::get_memory_statistics() const {const auto add_stat = [&](allocation_type type) {auto idx = static_cast<size_t>(type);auto value = _memory_usage_data[idx].load();- if (value != 0) {- std::ostringstream oss;- oss << type;- statistics[oss.str()] = value;- }+ std::ostringstream oss;+ oss << type;+ statistics[oss.str()] = value;};add_stat(allocation_type::unknown);diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cppindex 4c674dda24e..1c0dab8f436 100644--- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp@@ -491,10 +491,7 @@ TEST_P(OVGetMetricPropsTest_GPU_MEMORY_STATISTICS_DEFAULT, GetMetricAndPrintNoThASSERT_FALSE(p.empty());std::cout << "Memory Statistics: " << std::endl;- for (auto&& kv : p) {- ASSERT_NE(kv.second, 0);- std::cout << kv.first << ": " << kv.second << " bytes" << std::endl;- }+ ASSERT_TRUE(std::any_of(p.begin(), p.end(), [](const auto& p){return !p.second;}));OV_ASSERT_PROPERTY_SUPPORTED(ov::intel_gpu::memory_statistics);}@@ -515,9 +512,7 @@ TEST_P(OVGetMetricPropsTest_GPU_MEMORY_STATISTICS_MULTIPLE_NETWORKS, GetMetricAnOV_ASSERT_NO_THROW(t1 = ie.get_property(target_device, ov::intel_gpu::memory_statistics));ASSERT_FALSE(t1.empty());- for (auto&& kv : t1) {- ASSERT_NE(kv.second, 0);- }+ ASSERT_TRUE(std::any_of(t1.begin(), t1.end(), [](const auto& p){return !p.second;}));auto exec_net2 = ie.compile_model(simpleNetwork, target_device);@@ -525,7 +520,6 @@ TEST_P(OVGetMetricPropsTest_GPU_MEMORY_STATISTICS_MULTIPLE_NETWORKS, GetMetricAnASSERT_FALSE(t2.empty());for (auto&& kv : t2) {- ASSERT_NE(kv.second, 0);auto iter = t1.find(kv.first);if (iter != t1.end()) {ASSERT_EQ(kv.second, t1[kv.first] * 2);@@ -546,7 +540,10 @@ TEST_P(OVGetMetricPropsTest_GPU_MEMORY_STATISTICS_CHECK_VALUES, GetMetricAndPrinstd::map<std::string, uint64_t> t1;OV_ASSERT_NO_THROW(t1 = ie.get_property(target_device, ov::intel_gpu::memory_statistics));- ASSERT_TRUE(t1.empty());+ ASSERT_FALSE(t1.empty());+ for (const auto& kv : t1) {+ ASSERT_EQ(kv.second, 0);+ }{auto exec_net1 = ie.compile_model(simpleNetwork, target_device);@@ -555,9 +552,7 @@ TEST_P(OVGetMetricPropsTest_GPU_MEMORY_STATISTICS_CHECK_VALUES, GetMetricAndPrinOV_ASSERT_NO_THROW(t2 = ie.get_property(target_device, ov::intel_gpu::memory_statistics));ASSERT_FALSE(t2.empty());- for (auto&& kv : t2) {- ASSERT_NE(kv.second, 0);- }+ ASSERT_TRUE(std::any_of(t2.begin(), t2.end(), [](const auto& p){return !p.second;}));{auto exec_net2 = ie.compile_model(actualNetwork, target_device);@@ -565,16 +560,13 @@ TEST_P(OVGetMetricPropsTest_GPU_MEMORY_STATISTICS_CHECK_VALUES, GetMetricAndPrinOV_ASSERT_NO_THROW(t3 = ie.get_property(target_device, ov::intel_gpu::memory_statistics));ASSERT_FALSE(t3.empty());- for (auto&& kv : t3) {- ASSERT_NE(kv.second, 0);- }+ ASSERT_TRUE(std::any_of(t3.begin(), t3.end(), [](const auto& p){return !p.second;}));}std::map<std::string, uint64_t> t4;OV_ASSERT_NO_THROW(t4 = ie.get_property(target_device, ov::intel_gpu::memory_statistics));ASSERT_FALSE(t4.empty());for (auto&& kv : t4) {- ASSERT_NE(kv.second, 0);if (kv.first.find("_cur") != std::string::npos) {auto iter = t2.find(kv.first);if (iter != t2.end()) {@@ -588,9 +580,7 @@ TEST_P(OVGetMetricPropsTest_GPU_MEMORY_STATISTICS_CHECK_VALUES, GetMetricAndPrinASSERT_FALSE(t5.empty());for (auto&& kv : t5) {- if (kv.first.find("_cur") != std::string::npos) {- ASSERT_EQ(kv.second, 0);- }+ ASSERT_EQ(kv.second, 0);}OV_ASSERT_PROPERTY_SUPPORTED(ov::intel_gpu::memory_statistics);@@ -620,9 +610,7 @@ TEST_P(OVGetMetricPropsTest_GPU_MEMORY_STATISTICS_MULTI_THREADS, GetMetricAndPriOV_ASSERT_NO_THROW(t1 = ie.get_property(target_device, ov::intel_gpu::memory_statistics));ASSERT_FALSE(t1.empty());- for (auto&& kv : t1) {- ASSERT_NE(kv.second, 0);- }+ ASSERT_TRUE(std::any_of(t1.begin(), t1.end(), [](const auto& p){return !p.second;}));for (auto& thread : threads) {thread = std::thread([&]() {@@ -641,7 +629,6 @@ TEST_P(OVGetMetricPropsTest_GPU_MEMORY_STATISTICS_MULTI_THREADS, GetMetricAndPriASSERT_FALSE(t2.empty());for (auto&& kv : t2) {- ASSERT_NE(kv.second, 0);auto iter = t1.find(kv.first);if (iter != t1.end()) {ASSERT_EQ(kv.second, t1[kv.first] * 3);