diff --git a/src/plugins/intel_gpu/src/graph/impls/common/loop.cpp b/src/plugins/intel_gpu/src/graph/impls/common/loop.cpp index ada8d22bbcb731..2d7b6417e3907b 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 @@ struct loop_impl : typed_primitive_impl { std::vector _back_edges; }; +std::unique_ptr LoopImplementationManager::create_impl(const program_node& node, const kernel_impl_params& params) const { + assert(node.is_type()); + return loop_impl::create(static_cast(node), params); +} + namespace detail { attach_loop_common::attach_loop_common() { implementation_map::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.hpp new file mode 100644 index 00000000000000..be94548705972f --- /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 + +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 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 in_fmts(node.get_dependencies().size(), format::any); + std::vector 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 cldnn diff --git a/src/plugins/intel_gpu/src/graph/registry/loop_impls.cpp b/src/plugins/intel_gpu/src/graph/registry/loop_impls.cpp new file mode 100644 index 00000000000000..ec92b335c55928 --- /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>& Registry::get_implementations() { + static const std::vector> 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_gpu diff --git a/src/plugins/intel_gpu/src/graph/registry/registry.hpp b/src/plugins/intel_gpu/src/graph/registry/registry.hpp index 1a57a1ed1ac970..44f070f95cc60b 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.cpp index 9e9655ce4e3c83..28b563a7509c99 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,