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] check the reorder adding condition via get_preferred_formats in loop (#31187)
Sungeun Kim13fb8b688a93
diff --git a/src/plugins/intel_gpu/src/graph/impls/common/loop.cpp b/src/plugins/intel_gpu/src/graph/impls/common/loop.cppindex ada8d22bbcb..2d7b6417e39 100644--- a/src/plugins/intel_gpu/src/graph/impls/common/loop.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/common/loop.cpp@@ -2,6 +2,7 @@// SPDX-License-Identifier: Apache-2.0//#include "intel_gpu/graph/kernel_impl_params.hpp"+#include "loop.hpp"#include "loop_inst.h"#include "registry/implementation_map.hpp"#include "register.hpp"@@ -304,6 +305,11 @@ private:std::vector<cldnn::loop::backedge_mapping> _back_edges;};+std::unique_ptr<primitive_impl> LoopImplementationManager::create_impl(const program_node& node, const kernel_impl_params& params) const {+ assert(node.is_type<loop>());+ return loop_impl::create(static_cast<const loop_node&>(node), params);+}+namespace detail {attach_loop_common::attach_loop_common() {implementation_map<loop>::add(impl_types::common,diff --git a/src/plugins/intel_gpu/src/graph/impls/common/loop.hpp b/src/plugins/intel_gpu/src/graph/impls/common/loop.hppnew file mode 100644index 00000000000..be945487059--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/common/loop.hpp@@ -0,0 +1,36 @@+// Copyright (C) 2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "registry/implementation_manager.hpp"+#include "program_node.h"++#include <memory>++namespace cldnn {++namespace common {++struct LoopImplementationManager : public ImplementationManager {+ OV_GPU_PRIMITIVE_IMPL("common::loop")+ LoopImplementationManager(shape_types shape_type, ValidateFunc vf = nullptr) : ImplementationManager(impl_types::common, shape_type, vf) {}++ std::unique_ptr<primitive_impl> create_impl(const program_node& node, const kernel_impl_params& params) const override;++ in_out_fmts_t query_formats(const program_node& node) const override {+ std::vector<format::type> in_fmts(node.get_dependencies().size(), format::any);+ std::vector<format::type> out_fmts(node.get_outputs_count(), format::any);++ for (size_t i = 0; i < node.get_dependencies().size(); i++) {+ size_t in_rank = node.get_input_layout(i).get_rank();+ in_fmts[i] = format::get_default_format(in_rank);+ }+ size_t out_rank = node.get_output_layout().get_rank();+ out_fmts[0] = format::get_default_format(out_rank);++ return {in_fmts, out_fmts};+ }+};++} // namespace common+} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/registry/loop_impls.cpp b/src/plugins/intel_gpu/src/graph/registry/loop_impls.cppnew file mode 100644index 00000000000..ec92b335c55--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/registry/loop_impls.cpp@@ -0,0 +1,27 @@+// Copyright (C) 2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "registry.hpp"+#include "intel_gpu/primitives/loop.hpp"+#include "primitive_inst.h"++#if OV_GPU_WITH_COMMON+ #include "impls/common/loop.hpp"+#endif+++namespace ov::intel_gpu {++using namespace cldnn;++const std::vector<std::shared_ptr<cldnn::ImplementationManager>>& Registry<loop>::get_implementations() {+ static const std::vector<std::shared_ptr<ImplementationManager>> impls = {+ OV_GPU_CREATE_INSTANCE_COMMON(common::LoopImplementationManager, shape_types::static_shape)+ OV_GPU_CREATE_INSTANCE_COMMON(common::LoopImplementationManager, shape_types::dynamic_shape)+ };++ return impls;+}++} // namespace ov::intel_gpudiff --git a/src/plugins/intel_gpu/src/graph/registry/registry.hpp b/src/plugins/intel_gpu/src/graph/registry/registry.hppindex 1a57a1ed1ac..44f070f95cc 100644--- a/src/plugins/intel_gpu/src/graph/registry/registry.hpp+++ b/src/plugins/intel_gpu/src/graph/registry/registry.hpp@@ -79,8 +79,10 @@#endif#if OV_GPU_WITH_COMMON-# define OV_GPU_GET_INSTANCE_COMMON(prim, ...) EXPAND(GET_INSTANCE(prim, cldnn::impl_types::common, __VA_ARGS__))+# define OV_GPU_CREATE_INSTANCE_COMMON(...) EXPAND(CREATE_INSTANCE(__VA_ARGS__))+# define OV_GPU_GET_INSTANCE_COMMON(prim, ...) EXPAND(SELECT(COUNT(__VA_ARGS__), prim, impl_types::ocl, __VA_ARGS__))#else+# define OV_GPU_CREATE_INSTANCE_COMMON(...)# define OV_GPU_GET_INSTANCE_COMMON(...)#endif@@ -138,6 +140,7 @@ REGISTER_IMPLS(gather);REGISTER_IMPLS(gather_nd);REGISTER_IMPLS(gemm);REGISTER_IMPLS(group_normalization);+REGISTER_IMPLS(loop);REGISTER_IMPLS(lora);REGISTER_IMPLS(lstm_cell);REGISTER_IMPLS(lstm_seq);@@ -162,7 +165,6 @@ REGISTER_IMPLS(col2im);REGISTER_DEFAULT_IMPLS(assign, CPU_S, CPU_D);REGISTER_DEFAULT_IMPLS(read_value, CPU_S, CPU_D);REGISTER_DEFAULT_IMPLS(condition, COMMON_S, COMMON_D);-REGISTER_DEFAULT_IMPLS(loop, COMMON_S, COMMON_D);REGISTER_DEFAULT_IMPLS(input_layout, COMMON_S, COMMON_D);REGISTER_DEFAULT_IMPLS(non_max_suppression_gather, CPU_S);REGISTER_DEFAULT_IMPLS(proposal, CPU_S, CPU_D);diff --git a/src/plugins/intel_gpu/tests/unit/module_tests/impls_registry_test.cpp b/src/plugins/intel_gpu/tests/unit/module_tests/impls_registry_test.cppindex 9e9655ce4e3..28b563a7509 100644--- a/src/plugins/intel_gpu/tests/unit/module_tests/impls_registry_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/module_tests/impls_registry_test.cpp@@ -43,7 +43,6 @@#include "intel_gpu/primitives/grn.hpp"#include "intel_gpu/primitives/group_normalization.hpp"#include "intel_gpu/primitives/kv_cache.hpp"-#include "intel_gpu/primitives/loop.hpp"#include "intel_gpu/primitives/matrix_nms.hpp"#include "intel_gpu/primitives/multiclass_nms.hpp"#include "intel_gpu/primitives/multinomial.hpp"@@ -145,7 +144,6 @@ TEST(registry_test, no_null_impls) {cldnn::assign,cldnn::read_value,cldnn::condition,- cldnn::loop,cldnn::input_layout,cldnn::non_max_suppression_gather,cldnn::proposal,