diff --git a/src/plugins/intel_gpu/src/graph/bucketize.cpp b/src/plugins/intel_gpu/src/graph/bucketize.cpp index 55dfacd310f..1ffab6fbb49 100644 --- a/src/plugins/intel_gpu/src/graph/bucketize.cpp +++ b/src/plugins/intel_gpu/src/graph/bucketize.cpp @@ -8,6 +8,7 @@ #include "bucketize_inst.hpp" #include "json_object.h" #include "primitive_type_base.h" +#include "to_string_utils.h" namespace cldnn { diff --git a/src/plugins/intel_gpu/src/graph/impls/implementation_map.hpp b/src/plugins/intel_gpu/src/graph/impls/implementation_map.hpp index c36b1df7427..14912294d39 100644 --- a/src/plugins/intel_gpu/src/graph/impls/implementation_map.hpp +++ b/src/plugins/intel_gpu/src/graph/impls/implementation_map.hpp @@ -10,9 +10,7 @@ #include #include #include -#include "to_string_utils.h" #include "kernel_selector_helper.h" -#include "activation_inst.h" namespace cldnn { @@ -50,10 +48,6 @@ struct typed_program_node; template struct implementation_key { typedef std::tuple type; - type operator()(const typed_program_node& primitive) { - return std::make_tuple(primitive.get_dependency(0).get_output_layout().data_type, - primitive.get_dependency(0).get_output_layout().format); - } type operator()(const layout& proposed_layout) { return std::make_tuple(proposed_layout.data_type, proposed_layout.format); } @@ -62,77 +56,66 @@ struct implementation_key { template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; template <> struct implementation_key { typedef int32_t type; - type operator()(const typed_program_node&) { return -1; } type operator()(const layout&) { return -1; } }; @@ -151,7 +134,8 @@ public: using map_type = singleton_map, factory_type>>; static factory_type get(const kernel_impl_params& impl_params, impl_types preferred_impl_type) { - auto key = key_builder()(impl_params.input_layouts[0]); + auto input_layout = !impl_params.input_layouts.empty() ? impl_params.input_layouts[0] : layout{ov::PartialShape{}, data_types::f32, format::any}; + auto key = key_builder()(input_layout); for (auto& kv : map_type::instance()) { impl_types impl_type = kv.first; if ((preferred_impl_type & impl_type) != impl_type) @@ -162,23 +146,20 @@ public: return factory; } } - std::stringstream target_impl_type_ss; - target_impl_type_ss << preferred_impl_type; - throw std::runtime_error(std::string("implementation_map for ") + typeid(primitive_kind).name() + - " could not find any implementation to match key: " + - get_key_name(key) + ", impl_type: " + target_impl_type_ss.str() + ", node_id: " + impl_params.desc->id); + OPENVINO_ASSERT(false, "[GPU] implementation_map for ", typeid(primitive_kind).name(), + " could not find any implementation to match key: ", get_key_name(key), + ", impl_type: ", preferred_impl_type, ", node_id: ", impl_params.desc->id); } // check if for a given engine and type there exist an implementation - static bool check(const typed_program_node& primitive, const kernel_impl_params& impl_params) { - impl_types target_impl_type = primitive.get_preferred_impl_type(); - auto key = key_builder()(impl_params.input_layouts[0]); + static bool check(const kernel_impl_params& impl_params, impl_types target_impl_type) { + auto input_layout = !impl_params.input_layouts.empty() ? impl_params.input_layouts[0] : layout{ov::PartialShape{}, data_types::f32, format::any}; + auto key = key_builder()(input_layout); return check_key(target_impl_type, key); } // check if there exists a kernel implementation of a primitive with output set it primitive's output layout - static bool check_io_eq(const typed_program_node& primitive, const kernel_impl_params& impl_params) { - impl_types target_impl_type = primitive.get_preferred_impl_type(); + static bool check_io_eq(const kernel_impl_params& impl_params, impl_types target_impl_type) { auto key = key_builder()(impl_params.output_layout); return check_key(target_impl_type, key); } @@ -202,9 +183,7 @@ public: } static void add(impl_types impl_type, factory_type factory, std::set keys) { - if (impl_type == impl_types::any) { - throw std::runtime_error("[CLDNN] Can't register impl with type any"); - } + OPENVINO_ASSERT(impl_type != impl_types::any, "[GPU] Can't register impl with type any"); map_type::instance().insert({impl_type, {keys, factory}}); } diff --git a/src/plugins/intel_gpu/src/graph/include/primitive_type_base.h b/src/plugins/intel_gpu/src/graph/include/primitive_type_base.h index da9824192ed..2bb653aab6e 100644 --- a/src/plugins/intel_gpu/src/graph/include/primitive_type_base.h +++ b/src/plugins/intel_gpu/src/graph/include/primitive_type_base.h @@ -22,17 +22,12 @@ template struct primitive_type_base : primitive_type { std::shared_ptr create_node(program& program, const std::shared_ptr prim) const override { - if (prim->type != this) - throw std::invalid_argument("primitive_type_base::create_node: primitive type mismatch"); - + OPENVINO_ASSERT(prim->type == this, "[GPU] primitive_type_base::create_node: primitive type mismatch"); return std::make_shared>(std::static_pointer_cast(prim), program); } - std::shared_ptr create_instance(network& network, - const cldnn::program_node& node) const override { - if (node.type() != this) - throw std::invalid_argument("primitive_type_base::create_instance: primitive type mismatch"); - + std::shared_ptr create_instance(network& network, const cldnn::program_node& node) const override { + OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::create_instance: primitive type mismatch"); return std::make_shared>(network, node); } @@ -42,11 +37,9 @@ struct primitive_type_base : primitive_type { } std::unique_ptr choose_impl(const cldnn::program_node& node, const kernel_impl_params& runtime_params) const override { - if (node.type() != this) - throw std::invalid_argument("primitive_type_base::choose_impl: primitive type mismatch"); + OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::choose_impl: primitive type mismatch"); auto factory = implementation_map::get(runtime_params, node.get_preferred_impl_type()); - auto impl = std::unique_ptr(factory(node, runtime_params)); - return impl; + return std::unique_ptr(factory(node, runtime_params)); } bool does_an_implementation_exist(const cldnn::program_node& node) const override { @@ -54,10 +47,8 @@ struct primitive_type_base : primitive_type { } bool does_an_implementation_exist(const cldnn::program_node& node, const kernel_impl_params& impl_param) const override { - if (node.type() != this) - throw std::invalid_argument("primitive_type_base::does_an_implementation_exist: primitive type mismatch"); - - return implementation_map::check(node, impl_param); + OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::does_an_implementation_exist: primitive type mismatch"); + return implementation_map::check(impl_param, node.get_preferred_impl_type()); } bool does_possible_implementation_exist(const cldnn::program_node& node) const override { @@ -65,22 +56,17 @@ struct primitive_type_base : primitive_type { } bool does_possible_implementation_exist(const cldnn::program_node& node, const kernel_impl_params& impl_param) const override { - if (node.type() != this) - throw std::invalid_argument("primitive_type_base::does_possible_implementation_exist: primitive type mismatch"); - return implementation_map::check_io_eq(node, impl_param); + OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::does_possible_implementation_exist: primitive type mismatch"); + return implementation_map::check_io_eq(impl_param, node.get_preferred_impl_type()); } cldnn::layout calc_output_layout(const cldnn::program_node& node, const kernel_impl_params& impl_param) const override { - if (node.type() != this) - throw std::invalid_argument("primitive_type_base::calc_output_layout: primitive type mismatch"); - + OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::calc_output_layout: primitive type mismatch"); return typed_primitive_inst::calc_output_layout(node, impl_param); } std::string to_string(const cldnn::program_node& node) const override { - if (node.type() != this) - throw std::invalid_argument("primitive_type_base::to_string: primitive type mismatch"); - + OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::to_string: primitive type mismatch"); return typed_primitive_inst::to_string(node); } }; diff --git a/src/plugins/intel_gpu/src/graph/shape_of.cpp b/src/plugins/intel_gpu/src/graph/shape_of.cpp index 994243a89cc..e3f0239da44 100644 --- a/src/plugins/intel_gpu/src/graph/shape_of.cpp +++ b/src/plugins/intel_gpu/src/graph/shape_of.cpp @@ -6,6 +6,7 @@ #include "primitive_type_base.h" #include "intel_gpu/runtime/error_handler.hpp" #include "json_object.h" +#include "to_string_utils.h" #include #include