[GPU] Fixed invalid access to input layout in impl map (#12533)
This commit is contained in:
parent
5c83f7d6b1
commit
9ec5d258fc
@ -8,6 +8,7 @@
|
|||||||
#include "bucketize_inst.hpp"
|
#include "bucketize_inst.hpp"
|
||||||
#include "json_object.h"
|
#include "json_object.h"
|
||||||
#include "primitive_type_base.h"
|
#include "primitive_type_base.h"
|
||||||
|
#include "to_string_utils.h"
|
||||||
|
|
||||||
namespace cldnn {
|
namespace cldnn {
|
||||||
|
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "to_string_utils.h"
|
|
||||||
#include "kernel_selector_helper.h"
|
#include "kernel_selector_helper.h"
|
||||||
#include "activation_inst.h"
|
|
||||||
|
|
||||||
namespace cldnn {
|
namespace cldnn {
|
||||||
|
|
||||||
@ -50,10 +48,6 @@ struct typed_program_node;
|
|||||||
template <typename primitive_kind>
|
template <typename primitive_kind>
|
||||||
struct implementation_key {
|
struct implementation_key {
|
||||||
typedef std::tuple<data_types, format::type> type;
|
typedef std::tuple<data_types, format::type> type;
|
||||||
type operator()(const typed_program_node<primitive_kind>& 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) {
|
type operator()(const layout& proposed_layout) {
|
||||||
return std::make_tuple(proposed_layout.data_type, proposed_layout.format);
|
return std::make_tuple(proposed_layout.data_type, proposed_layout.format);
|
||||||
}
|
}
|
||||||
@ -62,77 +56,66 @@ struct implementation_key {
|
|||||||
template <>
|
template <>
|
||||||
struct implementation_key<permute> {
|
struct implementation_key<permute> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<permute>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<shape_of> {
|
struct implementation_key<shape_of> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<shape_of>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<reorder> {
|
struct implementation_key<reorder> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<reorder>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<generic_layer> {
|
struct implementation_key<generic_layer> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<generic_layer>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<custom_gpu_primitive> {
|
struct implementation_key<custom_gpu_primitive> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<custom_gpu_primitive>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<reshape> {
|
struct implementation_key<reshape> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<reshape>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<data> {
|
struct implementation_key<data> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<data>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<mutable_data> {
|
struct implementation_key<mutable_data> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<mutable_data>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<input_layout> {
|
struct implementation_key<input_layout> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<input_layout>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<prior_box> {
|
struct implementation_key<prior_box> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<prior_box>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct implementation_key<loop> {
|
struct implementation_key<loop> {
|
||||||
typedef int32_t type;
|
typedef int32_t type;
|
||||||
type operator()(const typed_program_node<loop>&) { return -1; }
|
|
||||||
type operator()(const layout&) { return -1; }
|
type operator()(const layout&) { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -151,7 +134,8 @@ public:
|
|||||||
using map_type = singleton_map<impl_types, std::pair<std::set<key_type>, factory_type>>;
|
using map_type = singleton_map<impl_types, std::pair<std::set<key_type>, factory_type>>;
|
||||||
|
|
||||||
static factory_type get(const kernel_impl_params& impl_params, impl_types preferred_impl_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()) {
|
for (auto& kv : map_type::instance()) {
|
||||||
impl_types impl_type = kv.first;
|
impl_types impl_type = kv.first;
|
||||||
if ((preferred_impl_type & impl_type) != impl_type)
|
if ((preferred_impl_type & impl_type) != impl_type)
|
||||||
@ -162,23 +146,20 @@ public:
|
|||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::stringstream target_impl_type_ss;
|
OPENVINO_ASSERT(false, "[GPU] implementation_map for ", typeid(primitive_kind).name(),
|
||||||
target_impl_type_ss << preferred_impl_type;
|
" could not find any implementation to match key: ", get_key_name(key),
|
||||||
throw std::runtime_error(std::string("implementation_map for ") + typeid(primitive_kind).name() +
|
", impl_type: ", preferred_impl_type, ", node_id: ", impl_params.desc->id);
|
||||||
" 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if for a given engine and type there exist an implementation
|
// check if for a given engine and type there exist an implementation
|
||||||
static bool check(const typed_program_node<primitive_kind>& primitive, const kernel_impl_params& impl_params) {
|
static bool check(const kernel_impl_params& impl_params, impl_types target_impl_type) {
|
||||||
impl_types target_impl_type = primitive.get_preferred_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()(impl_params.input_layouts[0]);
|
auto key = key_builder()(input_layout);
|
||||||
return check_key(target_impl_type, key);
|
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
|
// 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_kind>& primitive, const kernel_impl_params& impl_params) {
|
static bool check_io_eq(const kernel_impl_params& impl_params, impl_types target_impl_type) {
|
||||||
impl_types target_impl_type = primitive.get_preferred_impl_type();
|
|
||||||
auto key = key_builder()(impl_params.output_layout);
|
auto key = key_builder()(impl_params.output_layout);
|
||||||
return check_key(target_impl_type, key);
|
return check_key(target_impl_type, key);
|
||||||
}
|
}
|
||||||
@ -202,9 +183,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void add(impl_types impl_type, factory_type factory, std::set<key_type> keys) {
|
static void add(impl_types impl_type, factory_type factory, std::set<key_type> keys) {
|
||||||
if (impl_type == impl_types::any) {
|
OPENVINO_ASSERT(impl_type != impl_types::any, "[GPU] Can't register impl with type any");
|
||||||
throw std::runtime_error("[CLDNN] Can't register impl with type any");
|
|
||||||
}
|
|
||||||
map_type::instance().insert({impl_type, {keys, factory}});
|
map_type::instance().insert({impl_type, {keys, factory}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,17 +22,12 @@ template <class PType>
|
|||||||
struct primitive_type_base : primitive_type {
|
struct primitive_type_base : primitive_type {
|
||||||
std::shared_ptr<cldnn::program_node> create_node(program& program,
|
std::shared_ptr<cldnn::program_node> create_node(program& program,
|
||||||
const std::shared_ptr<primitive> prim) const override {
|
const std::shared_ptr<primitive> prim) const override {
|
||||||
if (prim->type != this)
|
OPENVINO_ASSERT(prim->type == this, "[GPU] primitive_type_base::create_node: primitive type mismatch");
|
||||||
throw std::invalid_argument("primitive_type_base::create_node: primitive type mismatch");
|
|
||||||
|
|
||||||
return std::make_shared<typed_program_node<PType>>(std::static_pointer_cast<PType>(prim), program);
|
return std::make_shared<typed_program_node<PType>>(std::static_pointer_cast<PType>(prim), program);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<cldnn::primitive_inst> create_instance(network& network,
|
std::shared_ptr<cldnn::primitive_inst> create_instance(network& network, const cldnn::program_node& node) const override {
|
||||||
const cldnn::program_node& node) const override {
|
OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::create_instance: primitive type mismatch");
|
||||||
if (node.type() != this)
|
|
||||||
throw std::invalid_argument("primitive_type_base::create_instance: primitive type mismatch");
|
|
||||||
|
|
||||||
return std::make_shared<typed_primitive_inst<PType>>(network, node);
|
return std::make_shared<typed_primitive_inst<PType>>(network, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,11 +37,9 @@ struct primitive_type_base : primitive_type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<primitive_impl> choose_impl(const cldnn::program_node& node, const kernel_impl_params& runtime_params) const override {
|
std::unique_ptr<primitive_impl> choose_impl(const cldnn::program_node& node, const kernel_impl_params& runtime_params) const override {
|
||||||
if (node.type() != this)
|
OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::choose_impl: primitive type mismatch");
|
||||||
throw std::invalid_argument("primitive_type_base::choose_impl: primitive type mismatch");
|
|
||||||
auto factory = implementation_map<PType>::get(runtime_params, node.get_preferred_impl_type());
|
auto factory = implementation_map<PType>::get(runtime_params, node.get_preferred_impl_type());
|
||||||
auto impl = std::unique_ptr<primitive_impl>(factory(node, runtime_params));
|
return std::unique_ptr<primitive_impl>(factory(node, runtime_params));
|
||||||
return impl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool does_an_implementation_exist(const cldnn::program_node& node) const override {
|
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 {
|
bool does_an_implementation_exist(const cldnn::program_node& node, const kernel_impl_params& impl_param) const override {
|
||||||
if (node.type() != this)
|
OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::does_an_implementation_exist: primitive type mismatch");
|
||||||
throw std::invalid_argument("primitive_type_base::does_an_implementation_exist: primitive type mismatch");
|
return implementation_map<PType>::check(impl_param, node.get_preferred_impl_type());
|
||||||
|
|
||||||
return implementation_map<PType>::check(node, impl_param);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool does_possible_implementation_exist(const cldnn::program_node& node) const override {
|
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 {
|
bool does_possible_implementation_exist(const cldnn::program_node& node, const kernel_impl_params& impl_param) const override {
|
||||||
if (node.type() != this)
|
OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::does_possible_implementation_exist: primitive type mismatch");
|
||||||
throw std::invalid_argument("primitive_type_base::does_possible_implementation_exist: primitive type mismatch");
|
return implementation_map<PType>::check_io_eq(impl_param, node.get_preferred_impl_type());
|
||||||
return implementation_map<PType>::check_io_eq(node, impl_param);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cldnn::layout calc_output_layout(const cldnn::program_node& node, const kernel_impl_params& impl_param) const override {
|
cldnn::layout calc_output_layout(const cldnn::program_node& node, const kernel_impl_params& impl_param) const override {
|
||||||
if (node.type() != this)
|
OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::calc_output_layout: primitive type mismatch");
|
||||||
throw std::invalid_argument("primitive_type_base::calc_output_layout: primitive type mismatch");
|
|
||||||
|
|
||||||
return typed_primitive_inst<PType>::calc_output_layout(node, impl_param);
|
return typed_primitive_inst<PType>::calc_output_layout(node, impl_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string to_string(const cldnn::program_node& node) const override {
|
std::string to_string(const cldnn::program_node& node) const override {
|
||||||
if (node.type() != this)
|
OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::to_string: primitive type mismatch");
|
||||||
throw std::invalid_argument("primitive_type_base::to_string: primitive type mismatch");
|
|
||||||
|
|
||||||
return typed_primitive_inst<PType>::to_string(node);
|
return typed_primitive_inst<PType>::to_string(node);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "primitive_type_base.h"
|
#include "primitive_type_base.h"
|
||||||
#include "intel_gpu/runtime/error_handler.hpp"
|
#include "intel_gpu/runtime/error_handler.hpp"
|
||||||
#include "json_object.h"
|
#include "json_object.h"
|
||||||
|
#include "to_string_utils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user