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] apply scales_port to save/load/hash/compare functions in resample (#31585)
Sungeun Kim25690e547f0c
diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/resample.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/resample.hppindex ca83812781c..17e68f635ab 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/resample.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/resample.hpp@@ -15,7 +15,7 @@ namespace cldnn {struct resample : public primitive_base<resample> {CLDNN_DECLARE_PRIMITIVE(resample)- resample() : primitive_base("", {}), scales_port(0) {}+ resample() : primitive_base("", {}) {}using InterpolateOp = ov::op::util::InterpolateBase;@@ -129,7 +129,7 @@ struct resample : public primitive_base<resample> {/// @param num_filter Input filter. Only used by bilinear sample_type.uint32_t num_filter = 0;/// @param num_filter Port number of scales.- uint32_t scales_port;+ uint32_t scales_port = 2;/// @param sizes Describing output shape for spatial axes.std::vector<int64_t> sizes;/// @param scales Scales of spatial axes, i.e. output_shape / input_shape@@ -156,6 +156,7 @@ struct resample : public primitive_base<resample> {size_t hash() const override {size_t seed = primitive::hash();seed = hash_combine(seed, num_filter);+ seed = hash_combine(seed, scales_port);seed = hash_range(seed, scales.begin(), scales.end());seed = hash_range(seed, axes.begin(), axes.end());seed = hash_range(seed, pads_begin.begin(), pads_begin.end());@@ -177,6 +178,7 @@ struct resample : public primitive_base<resample> {#define cmp_fields(name) name == rhs_casted.namereturn cmp_fields(num_filter) &&+ cmp_fields(scales_port) &&cmp_fields(sizes) &&cmp_fields(scales) &&cmp_fields(axes) &&@@ -195,6 +197,7 @@ struct resample : public primitive_base<resample> {primitive_base<resample>::save(ob);ob << output_size;ob << num_filter;+ ob << scales_port;ob << sizes;ob << scales;ob << axes;@@ -212,6 +215,7 @@ struct resample : public primitive_base<resample> {primitive_base<resample>::load(ib);ib >> output_size;ib >> num_filter;+ ib >> scales_port;ib >> sizes;ib >> scales;ib >> axes;diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/interpolate.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/interpolate.cppindex 41d7ba7c54f..bb6df585223 100644--- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/interpolate.cpp+++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/interpolate.cpp@@ -698,4 +698,63 @@ INSTANTIATE_TEST_SUITE_P(InterpolateNN5D_Layout_Test, InterpolateLayerGPUTest,::testing::Values(ov::element::f32),::testing::Values(true, false)),InterpolateLayerGPUTest::getTestCaseName);+++//+// Test cache save/load for Interpolate V4/V11+//+class InterpolateLayerCacheGPUTest : public InterpolateLayerGPUTest {+};++const std::vector<ShapeParams> shapeParams4D_Smoke_single = {+ ShapeParams{+ ov::op::v4::Interpolate::ShapeCalcMode::SCALES,+ InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}}},+ ov::test::utils::InputLayerType::CONSTANT,+ ov::test::utils::InputLayerType::PARAMETER,+ {{1.f, 1.f, 1.25f, 1.5f}},+ defaultAxes4D.front()+ }+};++const std::vector<std::vector<size_t>> pads4D_cache = {+ {0, 0, 0, 0},+};++const auto interpolateCasesNNCache_Smoke = ::testing::Combine(+ ::testing::Values(ov::op::v4::Interpolate::InterpolateMode::NEAREST),+ ::testing::Values(ov::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL),+ ::testing::Values(ov::op::v4::Interpolate::NearestMode::SIMPLE),+ ::testing::Values(false),+ ::testing::ValuesIn(pads4D_cache),+ ::testing::ValuesIn(pads4D_cache),+ ::testing::ValuesIn(cubeCoefs));++INSTANTIATE_TEST_SUITE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCacheGPUTest,+ ::testing::Combine(+ interpolateCasesNNCache_Smoke,+ ::testing::ValuesIn(shapeParams4D_Smoke_single),+ ::testing::Values(ov::element::f32),+ ::testing::Values(true, false)),+ InterpolateLayerCacheGPUTest::getTestCaseName);++TEST_P(InterpolateLayerCacheGPUTest, InferenceCache) {+ std::stringstream ss;+ ss << "gpu_model_cache_" << std::hash<std::string>{}(+ std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) ++ std::string(::testing::UnitTest::GetInstance()->current_test_info()->name()));+ std::string cacheDirName = ss.str();++ ov::test::utils::removeFilesWithExt(cacheDirName, "blob");+ ov::test::utils::removeFilesWithExt(cacheDirName, "cl_cache");+ ov::test::utils::removeDir(cacheDirName);+ core->set_property(ov::cache_dir(cacheDirName));+ compile_model();+ run();++ ov::test::utils::removeFilesWithExt(cacheDirName, "blob");+ ov::test::utils::removeFilesWithExt(cacheDirName, "cl_cache");+ ov::test::utils::removeDir(cacheDirName);+}+} // namespace