[GPU] Refactor primitive_impl::create methods and kernel selector (#13748)
* [GPU] Refactor impls factory method * [GPU] Return unique_ptr from impls factory * [GPU] implemented get_kernel_params for most of ocl impls * [GPU] Common create impl * [GPU] Fixes after rebase * [GPU] Codestyle fixes * [GPU] handle optimized out prims in common create * [GPU] Fix exception type in region yolo tests * [GPU] Resolve ambiguity of make_unique on windows * [GPU] Multiclass NMS * [GPU] Fixes after rebase
This commit is contained in:
1 parent
55a45a4d1a
commit
fcef6220b0
113 files changed
+1161
-1874
No files matched your search
@@ -47,7 +47,9 @@ struct condition_impl : typed_primitive_impl<condition> {
|
||||
return ev;
|
||||
}
|
||||
|
||||
static primitive_impl* create(const condition_node& arg, const kernel_impl_params&) { return new condition_impl(arg); }
|
||||
static std::unique_ptr<primitive_impl> create(const condition_node& arg, const kernel_impl_params&) {
|
||||
return make_unique<condition_impl>(arg);
|
||||
}
|
||||
|
||||
void init_kernels(const kernels_cache&) override {}
|
||||
|
||||
|
||||
@@ -185,7 +185,9 @@ struct loop_impl : typed_primitive_impl<loop> {
|
||||
return ev;
|
||||
}
|
||||
|
||||
static primitive_impl* create(const loop_node& arg, const kernel_impl_params&) { return new loop_impl(arg); }
|
||||
static std::unique_ptr<primitive_impl> create(const loop_node& arg, const kernel_impl_params&) {
|
||||
return make_unique<loop_impl>(arg);
|
||||
}
|
||||
|
||||
private:
|
||||
primitive_id _node_id;
|
||||
|
||||
@@ -45,15 +45,17 @@ public:
|
||||
|
||||
bool validate(const primitive_inst&) const override { return true; }
|
||||
|
||||
static primitive_impl* create_data(const data_node& data, const kernel_impl_params&) { return new wait_for_events_impl(data); }
|
||||
|
||||
static primitive_impl* create_input_layout(const input_layout_node& input, const kernel_impl_params&) {
|
||||
return new wait_for_events_impl(input);
|
||||
static std::unique_ptr<primitive_impl> create_data(const data_node& data, const kernel_impl_params&) {
|
||||
return make_unique<wait_for_events_impl>(data);
|
||||
}
|
||||
|
||||
static primitive_impl* create_prior_box(const prior_box_node& prior_box, const kernel_impl_params&) {
|
||||
static std::unique_ptr<primitive_impl> create_input_layout(const input_layout_node& input, const kernel_impl_params&) {
|
||||
return make_unique<wait_for_events_impl>(input);
|
||||
}
|
||||
|
||||
static std::unique_ptr<primitive_impl> create_prior_box(const prior_box_node& prior_box, const kernel_impl_params&) {
|
||||
// This primitive is being executed on CPU during network compilation.
|
||||
return new wait_for_events_impl(prior_box);
|
||||
return make_unique<wait_for_events_impl>(prior_box);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ struct assign_impl : public typed_primitive_impl<assign> {
|
||||
void init_kernels(const kernels_cache&) override {}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const assign_node& arg, const kernel_impl_params& impl_param) {
|
||||
return new assign_impl{};
|
||||
static std::unique_ptr<primitive_impl> create(const assign_node& arg, const kernel_impl_params& impl_param) {
|
||||
return make_unique<assign_impl>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -855,7 +855,9 @@ public:
|
||||
|
||||
void init_kernels(const kernels_cache&) override {}
|
||||
|
||||
static primitive_impl* create(const detection_output_node& arg, const kernel_impl_params&) { return new detection_output_impl(arg); }
|
||||
static std::unique_ptr<primitive_impl> create(const detection_output_node& arg, const kernel_impl_params&) {
|
||||
return make_unique<detection_output_impl>(arg);
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -405,8 +405,8 @@ struct non_max_suppression_impl : typed_primitive_impl<non_max_suppression> {
|
||||
return ev;
|
||||
}
|
||||
|
||||
static primitive_impl* create(const non_max_suppression_node&, const kernel_impl_params&) {
|
||||
return new non_max_suppression_impl();
|
||||
static std::unique_ptr<primitive_impl> create(const non_max_suppression_node&, const kernel_impl_params&) {
|
||||
return make_unique<non_max_suppression_impl>();
|
||||
}
|
||||
void init_kernels(const kernels_cache&) override {}
|
||||
};
|
||||
|
||||
@@ -432,7 +432,7 @@ struct proposal_impl : typed_primitive_impl<proposal> {
|
||||
|
||||
void init_kernels(const kernels_cache&) override {}
|
||||
|
||||
static primitive_impl* create(const proposal_node& arg, const kernel_impl_params& impl_param) {
|
||||
static std::unique_ptr<primitive_impl> create(const proposal_node& arg, const kernel_impl_params& impl_param) {
|
||||
const layout& l = impl_param.input_layouts[2];
|
||||
const size_t count = l.feature() == 1 ? static_cast<size_t>(l.batch()) : static_cast<size_t>(l.feature());
|
||||
|
||||
@@ -444,7 +444,7 @@ struct proposal_impl : typed_primitive_impl<proposal> {
|
||||
CLDNN_ERROR_MESSAGE(arg.id(), "image_info must have either 3, 4 or 6 items");
|
||||
}
|
||||
|
||||
return new proposal_impl(arg);
|
||||
return make_unique<proposal_impl>(arg);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ struct read_value_impl : public typed_primitive_impl<read_value> {
|
||||
void init_kernels(const kernels_cache&) override {}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const read_value_node& arg, const kernel_impl_params& impl_param) {
|
||||
return new read_value_impl{};
|
||||
static std::unique_ptr<primitive_impl> create(const read_value_node& arg, const kernel_impl_params& impl_param) {
|
||||
return make_unique<read_value_impl>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ class implementation_map {
|
||||
public:
|
||||
using key_builder = implementation_key<primitive_kind>;
|
||||
using key_type = typename key_builder::type;
|
||||
using factory_type = std::function<primitive_impl*(const typed_program_node<primitive_kind>&, const kernel_impl_params&)>;
|
||||
using factory_type = std::function<std::unique_ptr<primitive_impl>(const typed_program_node<primitive_kind>&, const kernel_impl_params&)>;
|
||||
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) {
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct activation_impl : typed_primitive_impl_ocl<activation> {
|
||||
using parent = typed_primitive_impl_ocl<activation>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::activation_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::activation_params, kernel_selector::activation_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -58,41 +60,26 @@ struct activation_impl : typed_primitive_impl_ocl<activation> {
|
||||
ib >> _is_parameterized;
|
||||
}
|
||||
|
||||
static primitive_impl* create(const activation_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto activation_params = get_default_params<kernel_selector::activation_params>(impl_param);
|
||||
auto activation_optional_params =
|
||||
get_default_optional_params<kernel_selector::activation_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<activation>();
|
||||
auto params = get_default_params<kernel_selector::activation_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::activation_optional_params>(impl_param.get_program());
|
||||
|
||||
convert_new_activation_func(prim, activation_params.activations);
|
||||
convert_new_activation_func(primitive, params.activations);
|
||||
|
||||
if (arg.is_parameterized()) {
|
||||
bool is_parameterized = !primitive->additional_params_input.empty();
|
||||
if (is_parameterized) {
|
||||
const auto& slope_layout = impl_param.input_layouts[1];
|
||||
const auto& output_layout = impl_param.output_layout;
|
||||
|
||||
const auto params_num =
|
||||
kernel_selector::GetActivationAdditionalParamsNumber(activation_params.activations[0].function);
|
||||
const auto params_num = kernel_selector::GetActivationAdditionalParamsNumber(params.activations[0].function);
|
||||
|
||||
CLDNN_ERROR_LESS_THAN(arg.id(),
|
||||
"Slope layout size count",
|
||||
slope_layout.count(),
|
||||
"output_layout.feature() * params_num",
|
||||
static_cast<size_t>(output_layout.feature() * params_num),
|
||||
"Error - not enough data inside additional params buffer");
|
||||
OPENVINO_ASSERT(slope_layout.count() >= static_cast<size_t>(output_layout.feature() * params_num), "[GPU] Invalid slope size in ", primitive->id);
|
||||
|
||||
activation_params.inputActivationParams.push_back(convert_data_tensor(slope_layout));
|
||||
params.inputActivationParams.push_back(convert_data_tensor(slope_layout));
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::activation_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(activation_params, activation_optional_params);
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto activation = new activation_impl(arg, best_kernels[0]);
|
||||
|
||||
return activation;
|
||||
return {params, optional_params};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -102,7 +89,7 @@ private:
|
||||
namespace detail {
|
||||
|
||||
attach_activation_impl::attach_activation_impl() {
|
||||
implementation_map<activation>::add(impl_types::ocl, activation_impl::create, {
|
||||
implementation_map<activation>::add(impl_types::ocl, typed_primitive_impl_ocl<activation>::create<activation_impl>, {
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f16, format::yxfb),
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
@@ -169,4 +156,4 @@ attach_activation_impl::attach_activation_impl() {
|
||||
} // namespace ocl
|
||||
} // namespace cldnn
|
||||
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::activation_impl, cldnn::object_type::ACTIVATION_IMPL)
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::activation_impl, cldnn::object_type::ACTIVATION_IMPL)
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct adaptive_pooling_impl : public typed_primitive_impl_ocl<adaptive_pooling> {
|
||||
using parent = typed_primitive_impl_ocl<adaptive_pooling>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::adaptive_pooling_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::adaptive_pooling_params, kernel_selector::adaptive_pooling_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -36,11 +38,11 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const adaptive_pooling_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<adaptive_pooling>();
|
||||
auto params = get_default_params<kernel_selector::adaptive_pooling_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::adaptive_pooling_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::adaptive_pooling_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto& primitive = arg.get_primitive();
|
||||
if (primitive->mode == adaptive_pooling_mode::average) {
|
||||
params.mode = kernel_selector::PoolType::AVG;
|
||||
} else {
|
||||
@@ -55,22 +57,13 @@ public:
|
||||
params.poolIndexElementType = kernel_selector::Datatype::INT64;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw std::runtime_error{"Not supported index element type"};
|
||||
default: OPENVINO_ASSERT(false, "[GPU] Not supported index element type");
|
||||
}
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.output_indices().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(2)));
|
||||
}
|
||||
|
||||
const auto& kernel_selector = kernel_selector::adaptive_pooling_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"best_kernels.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new adaptive_pooling_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -93,7 +86,7 @@ attach_adaptive_pooling_impl::attach_adaptive_pooling_impl() {
|
||||
format::bs_fs_zyx_bsv32_fsv16
|
||||
};
|
||||
|
||||
implementation_map<adaptive_pooling>::add(impl_types::ocl, adaptive_pooling_impl::create, types, formats);
|
||||
implementation_map<adaptive_pooling>::add(impl_types::ocl, typed_primitive_impl_ocl<adaptive_pooling>::create<adaptive_pooling_impl>, types, formats);
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace ocl
|
||||
|
||||
@@ -39,6 +39,8 @@ static inline kernel_selector::argm_axis GetArgMaxMinAxis(int64_t axis, size_t r
|
||||
struct arg_max_min_impl : typed_primitive_impl_ocl<arg_max_min> {
|
||||
using parent = typed_primitive_impl_ocl<arg_max_min>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::arg_max_min_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::arg_max_min_params, kernel_selector::arg_max_min_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -58,8 +60,8 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const arg_max_min_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static std::unique_ptr<primitive_impl> create(const arg_max_min_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<arg_max_min>();
|
||||
const auto& axis = primitive->axis;
|
||||
const auto& top_k = primitive->top_k;
|
||||
const auto& mode = primitive->mode;
|
||||
@@ -69,7 +71,7 @@ public:
|
||||
|
||||
auto argm_params = get_default_params<kernel_selector::arg_max_min_params>(impl_param);
|
||||
auto argm_optional_params =
|
||||
get_default_optional_params<kernel_selector::arg_max_min_optional_params>(arg.get_program());
|
||||
get_default_optional_params<kernel_selector::arg_max_min_optional_params>(impl_param.get_program());
|
||||
|
||||
argm_params.outputs_num = outputs_num;
|
||||
argm_params.topK = top_k;
|
||||
@@ -98,17 +100,9 @@ public:
|
||||
argm_params.values_first = values_first;
|
||||
|
||||
auto& kernel_selector = kernel_selector::arg_max_min_kernel_selector::Instance();
|
||||
auto best_kernel = kernel_selector.get_best_kernel(argm_params, argm_optional_params);
|
||||
|
||||
kernel_selector::KernelsData best_kernels = kernel_selector.GetBestKernels(argm_params, argm_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto conv = new arg_max_min_impl(arg, best_kernels[0]);
|
||||
|
||||
return conv;
|
||||
return make_unique<arg_max_min_impl>(arg, best_kernel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct average_unpooling_impl : typed_primitive_impl_ocl<average_unpooling> {
|
||||
using parent = typed_primitive_impl_ocl<average_unpooling>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::average_unpooling_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::average_unpooling_params, kernel_selector::average_unpooling_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -30,13 +32,10 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const average_unpooling_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto primitive = arg.get_primitive();
|
||||
auto average_unpooling_params = get_default_params<kernel_selector::average_unpooling_params>(impl_param);
|
||||
auto average_unpooling_optional_params =
|
||||
get_default_optional_params<kernel_selector::average_unpooling_optional_params>(arg.get_program());
|
||||
auto& params = average_unpooling_params;
|
||||
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<average_unpooling>();
|
||||
auto params = get_default_params<kernel_selector::average_unpooling_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::average_unpooling_optional_params>(impl_param.get_program());
|
||||
auto stride = primitive->stride;
|
||||
|
||||
params.unpoolSize = {
|
||||
@@ -46,24 +45,14 @@ public:
|
||||
|
||||
params.unpoolStride = {(uint32_t)stride.spatial[0], (uint32_t)stride.spatial[1]};
|
||||
|
||||
auto& kernel_selector = kernel_selector::average_unpooling_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(average_unpooling_params, average_unpooling_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto average_unpool = new average_unpooling_impl(arg, best_kernels[0]);
|
||||
|
||||
return average_unpool;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_average_unpooling_impl::attach_average_unpooling_impl() {
|
||||
implementation_map<average_unpooling>::add(impl_types::ocl, average_unpooling_impl::create, {
|
||||
implementation_map<average_unpooling>::add(impl_types::ocl, typed_primitive_impl_ocl<average_unpooling>::create<average_unpooling_impl>, {
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f16, format::yxfb),
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace ocl {
|
||||
struct batch_to_space_impl : typed_primitive_impl_ocl<batch_to_space> {
|
||||
using parent = typed_primitive_impl_ocl<batch_to_space>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::batch_to_space_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::batch_to_space_params, kernel_selector::batch_to_space_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -26,35 +28,23 @@ struct batch_to_space_impl : typed_primitive_impl_ocl<batch_to_space> {
|
||||
return make_unique<batch_to_space_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const batch_to_space_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto primitive = arg.get_primitive();
|
||||
auto batch_to_space_params = get_default_params<kernel_selector::batch_to_space_params>(impl_param);
|
||||
auto batch_to_space_optional_params =
|
||||
get_default_optional_params<kernel_selector::batch_to_space_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<batch_to_space>();
|
||||
auto params = get_default_params<kernel_selector::batch_to_space_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::batch_to_space_optional_params>(impl_param.get_program());
|
||||
|
||||
batch_to_space_params.block_shape = convert_dim_vector(primitive->block_shape);
|
||||
batch_to_space_params.crops_begin = convert_dim_vector(primitive->crops_begin);
|
||||
batch_to_space_params.crops_end = convert_dim_vector(primitive->crops_end);
|
||||
params.block_shape = convert_dim_vector(primitive->block_shape);
|
||||
params.crops_begin = convert_dim_vector(primitive->crops_begin);
|
||||
params.crops_end = convert_dim_vector(primitive->crops_end);
|
||||
|
||||
auto& kernel_selector = kernel_selector::batch_to_space_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(batch_to_space_params, batch_to_space_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto batch_to_space = new batch_to_space_impl(arg, best_kernels[0]);
|
||||
|
||||
return batch_to_space;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_batch_to_space_impl::attach_batch_to_space_impl() {
|
||||
implementation_map<batch_to_space>::add(impl_types::ocl, batch_to_space_impl::create, {
|
||||
implementation_map<batch_to_space>::add(impl_types::ocl, typed_primitive_impl_ocl<batch_to_space>::create<batch_to_space_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::u8, format::bfyx),
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace ocl {
|
||||
struct binary_convolution_impl : typed_primitive_impl_ocl<binary_convolution> {
|
||||
using parent = typed_primitive_impl_ocl<binary_convolution>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::binary_convolution_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::binary_convolution_params, kernel_selector::binary_convolution_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -85,8 +87,8 @@ public:
|
||||
ib >> _split;
|
||||
}
|
||||
|
||||
static primitive_impl* create(const binary_convolution_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<binary_convolution>();
|
||||
const auto& weights_layout = (*impl_param.weights_layout).convert_to_weights_layout(false);
|
||||
const auto& weights_size = weights_layout.get_tensor();
|
||||
|
||||
@@ -96,21 +98,15 @@ public:
|
||||
const auto& dilation = primitive->dilation;
|
||||
const auto& pad = primitive->pad;
|
||||
|
||||
const auto depthwise_separable_opt = arg.get_depthwise_sep_opt();
|
||||
const auto actual_split = depthwise_separable_opt ? (decltype(split))1 : split;
|
||||
auto params = get_weights_bias_default_params<kernel_selector::binary_convolution_params>(impl_param, split);
|
||||
auto optional_params = get_default_weights_bias_optional_params<kernel_selector::binary_convolution_optional_params>(impl_param.get_program());
|
||||
|
||||
assert(impl_param.output_layout.feature() / primitive->split() == weights_layout.batch());
|
||||
|
||||
auto conv_params = get_weights_bias_default_params<kernel_selector::binary_convolution_params>(impl_param, actual_split);
|
||||
auto conv_optional_params = get_default_weights_bias_optional_params<kernel_selector::binary_convolution_optional_params>(
|
||||
arg.get_program());
|
||||
|
||||
conv_params.pad_value = primitive->pad_value;
|
||||
conv_params.out_dt = to_data_type(*primitive->output_data_type);
|
||||
conv_params.depthwise_separable_opt = depthwise_separable_opt;
|
||||
conv_params.split = static_cast<uint32_t>(split);
|
||||
conv_params.groups = static_cast<uint32_t>(groups);
|
||||
conv_params.filterSize = {
|
||||
params.pad_value = primitive->pad_value;
|
||||
params.out_dt = to_data_type(*primitive->output_data_type);
|
||||
params.depthwise_separable_opt = false;
|
||||
params.split = static_cast<uint32_t>(split);
|
||||
params.groups = static_cast<uint32_t>(groups);
|
||||
params.filterSize = {
|
||||
(uint32_t)weights_size.spatial[0],
|
||||
(uint32_t)weights_size.spatial[1],
|
||||
(uint32_t)weights_size.spatial[2],
|
||||
@@ -119,38 +115,27 @@ public:
|
||||
uint32_t pad_z = std::max<std::ptrdiff_t>(pad.size() >= 3 ? pad[pad.size() - 3] : 0, 0);
|
||||
uint32_t pad_y = std::max<std::ptrdiff_t>(pad.size() >= 2 ? pad[pad.size() - 2] : 0, 0);
|
||||
uint32_t pad_x = std::max<std::ptrdiff_t>(pad.size() >= 1 ? pad[pad.size() - 1] : 0, 0);
|
||||
conv_params.padding = {pad_x, pad_y, pad_z};
|
||||
params.padding = {pad_x, pad_y, pad_z};
|
||||
|
||||
uint32_t stride_z = stride.size() >= 3 ? stride[stride.size() - 3] : 1;
|
||||
uint32_t stride_y = stride.size() >= 2 ? stride[stride.size() - 2] : 1;
|
||||
uint32_t stride_x = stride.size() >= 1 ? stride[stride.size() - 1] : 1;
|
||||
conv_params.stride = {stride_x, stride_y, stride_z};
|
||||
params.stride = {stride_x, stride_y, stride_z};
|
||||
|
||||
uint32_t dilation_z = dilation.size() >= 3 ? dilation[dilation.size() - 3] : 1;
|
||||
uint32_t dilation_y = dilation.size() >= 2 ? dilation[dilation.size() - 2] : 1;
|
||||
uint32_t dilation_x = dilation.size() >= 1 ? dilation[dilation.size() - 1] : 1;
|
||||
conv_params.dilation = {dilation_x, dilation_y, dilation_z};
|
||||
params.dilation = {dilation_x, dilation_y, dilation_z};
|
||||
|
||||
auto& kernel_selector = kernel_selector::binary_convolution_kernel_selector::Instance();
|
||||
|
||||
const auto& tuning_config = arg.get_program().get_options().get<build_option_type::tuning_config>();
|
||||
const auto& tuning_config = impl_param.get_program().get_options().get<build_option_type::tuning_config>();
|
||||
|
||||
if (tuning_config->config.mode == tuning_mode::tuning_tune_and_cache ||
|
||||
tuning_config->config.mode == tuning_mode::tuning_retune_and_cache) {
|
||||
conv_optional_params.tuningParams.runner =
|
||||
std::make_shared<gpu::kernel_runner>(arg.get_program().get_engine(), arg.get_program().get_id(), true);
|
||||
optional_params.tuningParams.runner =
|
||||
std::make_shared<gpu::kernel_runner>(impl_param.get_program().get_engine(), impl_param.get_program().get_id(), true);
|
||||
}
|
||||
|
||||
kernel_selector::KernelsData best_kernels = kernel_selector.GetBestKernels(conv_params, conv_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto conv = new binary_convolution_impl(arg, best_kernels[0]);
|
||||
|
||||
return conv;
|
||||
return {params, optional_params};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -160,7 +145,7 @@ private:
|
||||
namespace detail {
|
||||
|
||||
attach_binary_convolution_impl::attach_binary_convolution_impl() {
|
||||
implementation_map<binary_convolution>::add(impl_types::ocl, binary_convolution_impl::create, {
|
||||
implementation_map<binary_convolution>::add(impl_types::ocl, typed_primitive_impl_ocl<binary_convolution>::create<binary_convolution_impl>, {
|
||||
std::make_tuple(data_types::bin, format::b_fs_yx_32fp),
|
||||
});
|
||||
}
|
||||
@@ -169,4 +154,4 @@ attach_binary_convolution_impl::attach_binary_convolution_impl() {
|
||||
} // namespace ocl
|
||||
} // namespace cldnn
|
||||
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::binary_convolution_impl, cldnn::object_type::BINARY_CONVOLUTION_IMPL)
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::binary_convolution_impl, cldnn::object_type::BINARY_CONVOLUTION_IMPL)
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct border_impl : typed_primitive_impl_ocl<border> {
|
||||
using parent = typed_primitive_impl_ocl<border>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::border_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::border_params, kernel_selector::border_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -24,56 +26,44 @@ struct border_impl : typed_primitive_impl_ocl<border> {
|
||||
return make_unique<border_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const border_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto desc = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<border>();
|
||||
auto params = get_default_params<kernel_selector::border_params>(impl_param, 1);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::border_optional_params>(impl_param.get_program());
|
||||
|
||||
auto b_params = get_default_params<kernel_selector::border_params>(impl_param, 1);
|
||||
auto b_optional_params =
|
||||
get_default_optional_params<kernel_selector::border_optional_params>(arg.get_program());
|
||||
format pads_format = format::adjust_to_rank(format::bfyx, impl_param.get_input_layout(0).get_rank());
|
||||
std::vector<tensor::value_type> pads_begin(primitive->pads_begin.begin(), primitive->pads_begin.end());
|
||||
std::vector<tensor::value_type> pads_end(primitive->pads_end.begin(), primitive->pads_end.end());
|
||||
|
||||
format pads_format = format::adjust_to_rank(format::bfyx, arg.get_input_layouts().front().get_rank());
|
||||
std::vector<tensor::value_type> pads_begin(desc->pads_begin.begin(), desc->pads_begin.end());
|
||||
std::vector<tensor::value_type> pads_end(desc->pads_end.begin(), desc->pads_end.end());
|
||||
params.lt_sizes = convert_dim_vector(tensor(pads_format, pads_begin, 0));
|
||||
params.rb_sizes = convert_dim_vector(tensor(pads_format, pads_end, 0));
|
||||
params.border_value = primitive->pad_value;
|
||||
|
||||
b_params.lt_sizes = convert_dim_vector(tensor(pads_format, pads_begin, 0));
|
||||
b_params.rb_sizes = convert_dim_vector(tensor(pads_format, pads_end, 0));
|
||||
b_params.border_value = desc->pad_value;
|
||||
|
||||
switch (desc->pad_mode) {
|
||||
switch (primitive->pad_mode) {
|
||||
case ov::op::PadMode::CONSTANT:
|
||||
b_params.b_type = kernel_selector::border_type::CONSTANT;
|
||||
params.b_type = kernel_selector::border_type::CONSTANT;
|
||||
break;
|
||||
case ov::op::PadMode::EDGE:
|
||||
b_params.b_type = kernel_selector::border_type::EDGE;
|
||||
params.b_type = kernel_selector::border_type::EDGE;
|
||||
break;
|
||||
case ov::op::PadMode::SYMMETRIC:
|
||||
b_params.b_type = kernel_selector::border_type::MIRROR;
|
||||
params.b_type = kernel_selector::border_type::MIRROR;
|
||||
break;
|
||||
case ov::op::PadMode::REFLECT:
|
||||
b_params.b_type = kernel_selector::border_type::MIRROR_101;
|
||||
params.b_type = kernel_selector::border_type::MIRROR_101;
|
||||
break;
|
||||
default:
|
||||
assert(
|
||||
false &&
|
||||
"Encountered unhandled enum case: PadMode during translation to kernel selector enumeration.");
|
||||
OPENVINO_ASSERT(false, "[GPU] Encountered unhandled enum case: PadMode during translation to kernel selector enumeration.");
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::border_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(b_params, b_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new border_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_border_impl::attach_border_impl() {
|
||||
implementation_map<border>::add(impl_types::ocl, border_impl::create, {
|
||||
implementation_map<border>::add(impl_types::ocl, typed_primitive_impl_ocl<border>::create<border_impl>, {
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f16, format::yxfb),
|
||||
std::make_tuple(data_types::i32, format::yxfb),
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct broadcast_impl : typed_primitive_impl_ocl<broadcast> {
|
||||
using parent = typed_primitive_impl_ocl<broadcast>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::broadcast_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::broadcast_params, kernel_selector::broadcast_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -24,11 +26,10 @@ struct broadcast_impl : typed_primitive_impl_ocl<broadcast> {
|
||||
return make_unique<broadcast_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const broadcast_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
auto bc_params = get_default_params<kernel_selector::broadcast_params>(impl_param, 1);
|
||||
auto bc_optional_params =
|
||||
get_default_optional_params<kernel_selector::broadcast_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<broadcast>();
|
||||
auto params = get_default_params<kernel_selector::broadcast_params>(impl_param, 1);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::broadcast_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto format = impl_param.output_layout.format;
|
||||
size_t max_axes_num = format.dimension();
|
||||
@@ -40,30 +41,22 @@ struct broadcast_impl : typed_primitive_impl_ocl<broadcast> {
|
||||
// bfyx, bfzyx format
|
||||
for (size_t i = 0; i < max_axes_num; ++i) {
|
||||
if (std::find(broadcast_axes.begin(), broadcast_axes.end(), i) != broadcast_axes.end()) {
|
||||
bc_params.input_order.push_back(index);
|
||||
params.input_order.push_back(index);
|
||||
++index;
|
||||
} else {
|
||||
bc_params.input_order.push_back(input_index);
|
||||
params.input_order.push_back(input_index);
|
||||
++input_index;
|
||||
}
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::broadcast_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(bc_params, bc_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new broadcast_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_broadcast_impl::attach_broadcast_impl() {
|
||||
implementation_map<broadcast>::add(impl_types::ocl, broadcast_impl::create, {
|
||||
implementation_map<broadcast>::add(impl_types::ocl, typed_primitive_impl_ocl<broadcast>::create<broadcast_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::i8, format::bfyx),
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace ocl {
|
||||
struct bucketize_impl : typed_primitive_impl_ocl<bucketize> {
|
||||
using parent = typed_primitive_impl_ocl<bucketize>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::bucketize_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::bucketize_params, kernel_selector::bucketize_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -21,24 +23,15 @@ struct bucketize_impl : typed_primitive_impl_ocl<bucketize> {
|
||||
return make_unique<bucketize_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const bucketize_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<bucketize>();
|
||||
auto params = get_default_params<kernel_selector::bucketize_params>(impl_param);
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::bucketize_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::bucketize_optional_params>(impl_param.get_program());
|
||||
|
||||
auto primitive = arg.get_primitive();
|
||||
params.with_right_bound = primitive->with_right_bound;
|
||||
params.inputs.push_back(convert_data_tensor(arg.buckets().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
|
||||
const auto& kernel_selector = kernel_selector::bucketize_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new bucketize_impl(arg, best_kernels.front());
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -70,7 +63,7 @@ attach_bucketize_impl::attach_bucketize_impl() {
|
||||
keys.emplace(t, f);
|
||||
}
|
||||
}
|
||||
implementation_map<bucketize>::add(impl_types::ocl, bucketize_impl::create, keys);
|
||||
implementation_map<bucketize>::add(impl_types::ocl, typed_primitive_impl_ocl<bucketize>::create<bucketize_impl>, keys);
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ kernel_selector::concat_axis convert_axis(int64_t axis, size_t rank) {
|
||||
struct concatenation_impl : typed_primitive_impl_ocl<concatenation> {
|
||||
using parent = typed_primitive_impl_ocl<concatenation>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::concatenation_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::concatenation_params, kernel_selector::concatenation_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -95,34 +97,23 @@ public:
|
||||
ib >> _can_be_optimized;
|
||||
}
|
||||
|
||||
static primitive_impl* create(const concatenation_node& arg, const kernel_impl_params& impl_param) {
|
||||
if (arg.can_be_optimized()) {
|
||||
return new concatenation_impl(arg, {});
|
||||
}
|
||||
const auto& primitive = arg.get_primitive();
|
||||
auto concat_params = get_default_params<kernel_selector::concatenation_params>(impl_param);
|
||||
auto concat_optional_params = get_default_optional_params<kernel_selector::concatenation_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<concatenation>();
|
||||
auto params = get_default_params<kernel_selector::concatenation_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::concatenation_optional_params>(impl_param.get_program());
|
||||
auto axis = primitive->axis;
|
||||
|
||||
concat_params.inputs.resize(arg.inputs_count());
|
||||
for (size_t i = 0; i < arg.inputs_count(); ++i) {
|
||||
auto inputs_count = primitive->input.size();
|
||||
params.inputs.resize(inputs_count);
|
||||
for (size_t i = 0; i < inputs_count; ++i) {
|
||||
const layout& input_layout = impl_param.input_layouts[i];
|
||||
concat_params.inputs[i] = convert_data_tensor(input_layout);
|
||||
params.inputs[i] = convert_data_tensor(input_layout);
|
||||
}
|
||||
|
||||
concat_params.axis = convert_axis(axis, impl_param.output_layout.get_rank());
|
||||
concat_optional_params.kernelPerInput = true;
|
||||
params.axis = convert_axis(axis, impl_param.output_layout.get_rank());
|
||||
optional_params.kernelPerInput = true;
|
||||
|
||||
auto& kernel_selector = kernel_selector::concatenation_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(concat_params, concat_optional_params);
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto concat = new concatenation_impl(arg, best_kernels[0]);
|
||||
|
||||
return concat;
|
||||
return {params, optional_params};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -132,7 +123,7 @@ private:
|
||||
namespace detail {
|
||||
|
||||
attach_concatenation_impl::attach_concatenation_impl() {
|
||||
implementation_map<concatenation>::add(impl_types::ocl, concatenation_impl::create, {
|
||||
implementation_map<concatenation>::add(impl_types::ocl, typed_primitive_impl_ocl<concatenation>::create<concatenation_impl>, {
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f16, format::yxfb),
|
||||
std::make_tuple(data_types::i8, format::yxfb),
|
||||
@@ -210,4 +201,4 @@ attach_concatenation_impl::attach_concatenation_impl() {
|
||||
} // namespace ocl
|
||||
} // namespace cldnn
|
||||
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::concatenation_impl, cldnn::object_type::CONCATENATION_IMPL)
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::concatenation_impl, cldnn::object_type::CONCATENATION_IMPL)
|
||||
@@ -19,6 +19,8 @@ namespace ocl {
|
||||
struct convert_color_impl : typed_primitive_impl_ocl<convert_color> {
|
||||
using parent = typed_primitive_impl_ocl<convert_color>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::convert_color_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::convert_color_params, kernel_selector::convert_color_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -33,39 +35,28 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const convert_color_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<convert_color>();
|
||||
|
||||
auto convert_color_params = get_default_params<kernel_selector::convert_color_params>(impl_param);
|
||||
auto convert_color_optional_params =
|
||||
get_default_optional_params<kernel_selector::convert_color_optional_params>(arg.get_program());
|
||||
auto params = get_default_params<kernel_selector::convert_color_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::convert_color_optional_params>(impl_param.get_program());
|
||||
|
||||
for (size_t i = 1; i < impl_param.input_layouts.size(); ++i) {
|
||||
convert_color_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));
|
||||
}
|
||||
|
||||
convert_color_params.input_color_format = static_cast<kernel_selector::color_format>(primitive->input_color_format);
|
||||
convert_color_params.output_color_format = static_cast<kernel_selector::color_format>(primitive->output_color_format);
|
||||
convert_color_params.mem_type = static_cast<kernel_selector::memory_type>(primitive->mem_type);
|
||||
params.input_color_format = static_cast<kernel_selector::color_format>(primitive->input_color_format);
|
||||
params.output_color_format = static_cast<kernel_selector::color_format>(primitive->output_color_format);
|
||||
params.mem_type = static_cast<kernel_selector::memory_type>(primitive->mem_type);
|
||||
|
||||
auto& kernel_selector = kernel_selector::convert_color_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(convert_color_params, convert_color_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto convert_color = new convert_color_impl(arg, best_kernels[0]);
|
||||
|
||||
return convert_color;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_convert_color_impl::attach_convert_color_impl() {
|
||||
implementation_map<convert_color>::add(impl_types::ocl, convert_color_impl::create, {
|
||||
implementation_map<convert_color>::add(impl_types::ocl, typed_primitive_impl_ocl<convert_color>::create<convert_color_impl>, {
|
||||
std::make_tuple(data_types::f32, format::nv12),
|
||||
std::make_tuple(data_types::f16, format::nv12),
|
||||
std::make_tuple(data_types::u8, format::nv12),
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace ocl {
|
||||
struct convolution_impl : typed_primitive_impl_ocl<convolution> {
|
||||
using parent = typed_primitive_impl_ocl<convolution>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::convolution_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::convolution_params, kernel_selector::convolution_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -94,8 +96,8 @@ public:
|
||||
ib >> _depthwise_sep_opt;
|
||||
}
|
||||
|
||||
static primitive_impl* create(const convolution_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static std::unique_ptr<primitive_impl> create(const convolution_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<convolution>();
|
||||
|
||||
const auto &split = primitive->split();
|
||||
auto stride = primitive->stride;
|
||||
@@ -108,7 +110,7 @@ public:
|
||||
auto conv_params = get_weight_bias_zero_point_default_params<kernel_selector::convolution_params>(
|
||||
impl_param, split, 1, primitive->grouped_weights_shape);
|
||||
auto conv_optional_params =
|
||||
get_default_weights_bias_optional_params<kernel_selector::convolution_optional_params>(arg.get_program());
|
||||
get_default_weights_bias_optional_params<kernel_selector::convolution_optional_params>(impl_param.get_program());
|
||||
|
||||
if (primitive->deformable_mode) {
|
||||
conv_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
@@ -181,15 +183,9 @@ public:
|
||||
std::make_shared<gpu::kernel_runner>(arg.get_program().get_engine(), arg.get_program().get_id(), true, true);
|
||||
}
|
||||
|
||||
kernel_selector::KernelsData best_kernels = kernel_selector.GetBestKernels(conv_params, conv_optional_params);
|
||||
auto best_kernel = kernel_selector.get_best_kernel(conv_params, conv_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with these arguments");
|
||||
auto conv = new convolution_impl(arg, best_kernels[0]);
|
||||
|
||||
return conv;
|
||||
return make_unique<convolution_impl>(arg, best_kernel);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -285,4 +281,4 @@ attach_convolution_impl::attach_convolution_impl() {
|
||||
} // namespace ocl
|
||||
} // namespace cldnn
|
||||
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::convolution_impl, cldnn::object_type::CONVOLUTION_IMPL)
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::convolution_impl, cldnn::object_type::CONVOLUTION_IMPL)
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct crop_impl : typed_primitive_impl_ocl<crop> {
|
||||
using parent = typed_primitive_impl_ocl<crop>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::eltwise_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::eltwise_params, kernel_selector::eltwise_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -54,25 +56,14 @@ public:
|
||||
ib >> _can_be_optimized;
|
||||
}
|
||||
|
||||
static primitive_impl* create(const crop_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto ew_params = get_default_params<kernel_selector::eltwise_params>(impl_param, 1);
|
||||
auto ew_optional_params = get_default_optional_params<kernel_selector::eltwise_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<crop>();
|
||||
auto params = get_default_params<kernel_selector::eltwise_params>(impl_param, 1);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::eltwise_optional_params>(impl_param.get_program());
|
||||
|
||||
ew_params.operations.push_back(
|
||||
{{kernel_selector::eltwise_params::InputType::Buffer(0)}, kernel_selector::eltwise_mode::ASSIGN});
|
||||
ew_params.inputs[0] = convert_data_tensor(impl_param.get_input_layout(), 1, impl_param.input_offsets[0]);
|
||||
|
||||
auto& kernel_selector = kernel_selector::eltwise_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(ew_params, ew_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto crop = new crop_impl(arg, best_kernels[0]);
|
||||
|
||||
return crop;
|
||||
params.operations.push_back({{kernel_selector::eltwise_params::InputType::Buffer(0)}, kernel_selector::eltwise_mode::ASSIGN});
|
||||
params.inputs[0] = convert_data_tensor(impl_param.get_input_layout(), 1, impl_param.input_offsets[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -82,7 +73,7 @@ private:
|
||||
namespace detail {
|
||||
|
||||
attach_crop_impl::attach_crop_impl() {
|
||||
implementation_map<crop>::add(impl_types::ocl, crop_impl::create, {
|
||||
implementation_map<crop>::add(impl_types::ocl, typed_primitive_impl_ocl<crop>::create<crop_impl>, {
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f16, format::yxfb),
|
||||
std::make_tuple(data_types::i64, format::yxfb),
|
||||
@@ -166,4 +157,4 @@ attach_crop_impl::attach_crop_impl() {
|
||||
} // namespace ocl
|
||||
} // namespace cldnn
|
||||
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::crop_impl, cldnn::object_type::CROP_IMPL)
|
||||
BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::crop_impl, cldnn::object_type::CROP_IMPL)
|
||||
@@ -20,6 +20,8 @@ namespace ocl {
|
||||
struct ctc_greedy_decoder_impl : typed_primitive_impl_ocl<ctc_greedy_decoder> {
|
||||
using parent = typed_primitive_impl_ocl<ctc_greedy_decoder>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::ctc_greedy_decoder_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::ctc_greedy_decoder_params, kernel_selector::ctc_greedy_decoder_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -27,42 +29,28 @@ struct ctc_greedy_decoder_impl : typed_primitive_impl_ocl<ctc_greedy_decoder> {
|
||||
return make_unique<ctc_greedy_decoder_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const ctc_greedy_decoder_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto prim = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<ctc_greedy_decoder>();
|
||||
auto params = get_default_params<kernel_selector::ctc_greedy_decoder_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::ctc_greedy_decoder_optional_params>(impl_param.get_program());
|
||||
|
||||
auto ctc_gd_params = get_default_params<kernel_selector::ctc_greedy_decoder_params>(impl_param);
|
||||
auto ctc_gd_optional_params = get_default_optional_params<kernel_selector::ctc_greedy_decoder_optional_params>(arg.get_program());
|
||||
auto has_second_output = !primitive->second_output.empty();
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
params.merge_repeated = primitive->ctc_merge_repeated;
|
||||
params.blank_index = primitive->blank_index;
|
||||
params.outputs_num = has_second_output ? 2 : 1;
|
||||
|
||||
ctc_gd_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
ctc_gd_params.merge_repeated = prim->ctc_merge_repeated;
|
||||
ctc_gd_params.blank_index = prim->blank_index;
|
||||
ctc_gd_params.outputs_num = arg.has_second_output() ? 2 : 1;
|
||||
|
||||
if (ctc_gd_params.outputs_num == 2) {
|
||||
const auto& second_output_layout = impl_param.input_layouts[1];
|
||||
ctc_gd_params.inputs.push_back(convert_data_tensor(second_output_layout));
|
||||
if (params.outputs_num == 2) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::ctc_greedy_decoder_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(
|
||||
ctc_gd_params, ctc_gd_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto grn = new ctc_greedy_decoder_impl(arg, best_kernels[0]);
|
||||
|
||||
return grn;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_ctc_greedy_decoder_impl::attach_ctc_greedy_decoder_impl() {
|
||||
implementation_map<ctc_greedy_decoder>::add(impl_types::ocl, ctc_greedy_decoder_impl::create, {
|
||||
implementation_map<ctc_greedy_decoder>::add(impl_types::ocl, typed_primitive_impl_ocl<ctc_greedy_decoder>::create<ctc_greedy_decoder_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace ocl {
|
||||
struct ctc_loss_impl : typed_primitive_impl_ocl<ctc_loss> {
|
||||
using parent = typed_primitive_impl_ocl<ctc_loss>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::ctc_loss_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::ctc_loss_params, kernel_selector::ctc_loss_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -21,28 +23,18 @@ struct ctc_loss_impl : typed_primitive_impl_ocl<ctc_loss> {
|
||||
return make_unique<ctc_loss_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const ctc_loss_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto params = get_default_params<kernel_selector::ctc_loss_params>(impl_param);
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::ctc_loss_optional_params>(arg.get_program());
|
||||
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<ctc_loss>();
|
||||
auto params = get_default_params<kernel_selector::ctc_loss_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::ctc_loss_optional_params>(impl_param.get_program());
|
||||
|
||||
params.preprocess_collapse_repeated = primitive->preprocess_collapse_repeated;
|
||||
params.ctc_merge_repeated = primitive->ctc_merge_repeated;
|
||||
params.unique = primitive->unique;
|
||||
for (size_t i = 1; i < impl_param.input_layouts.size(); ++i) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));
|
||||
}
|
||||
|
||||
const auto& kernel_selector = kernel_selector::ctc_loss_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new ctc_loss_impl(arg, best_kernels.front());
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -58,7 +50,7 @@ attach_ctc_loss_impl::attach_ctc_loss_impl() {
|
||||
format::bs_fs_yx_bsv32_fsv32,
|
||||
format::bs_fs_yx_bsv32_fsv16};
|
||||
|
||||
implementation_map<ctc_loss>::add(impl_types::ocl, ctc_loss_impl::create, types, formats);
|
||||
implementation_map<ctc_loss>::add(impl_types::ocl, typed_primitive_impl_ocl<ctc_loss>::create<ctc_loss_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -50,6 +50,8 @@ kernel_selector::cum_sum_axis convert_axis(int64_t axis, size_t rank) {
|
||||
struct cum_sum_impl : typed_primitive_impl_ocl<cum_sum> {
|
||||
using parent = typed_primitive_impl_ocl<cum_sum>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::cum_sum_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::cum_sum_params, kernel_selector::cum_sum_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -58,36 +60,23 @@ struct cum_sum_impl : typed_primitive_impl_ocl<cum_sum> {
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const cum_sum_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<cum_sum>();
|
||||
auto params = get_default_params<kernel_selector::cum_sum_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::cum_sum_optional_params>(impl_param.get_program());
|
||||
|
||||
auto cum_sum_params = get_default_params<kernel_selector::cum_sum_params>(impl_param);
|
||||
auto cum_sum_optional_params =
|
||||
get_default_optional_params<kernel_selector::cum_sum_optional_params>(arg.get_program());
|
||||
|
||||
size_t rank = arg.get_output_layout().get_rank();
|
||||
cum_sum_params.axis = convert_axis(prim->axis, rank);
|
||||
cum_sum_params.exclusive = arg.get_primitive()->exclusive;
|
||||
cum_sum_params.reverse = arg.get_primitive()->reverse;
|
||||
|
||||
auto& kernel_selector = kernel_selector::cum_sum_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(cum_sum_params, cum_sum_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto cum_sum = new cum_sum_impl(arg, best_kernels[0]);
|
||||
|
||||
return cum_sum;
|
||||
size_t rank = impl_param.output_layout.get_rank();
|
||||
params.axis = convert_axis(primitive->axis, rank);
|
||||
params.exclusive = primitive->exclusive;
|
||||
params.reverse = primitive->reverse;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_cum_sum_impl::attach_cum_sum_impl() {
|
||||
implementation_map<cum_sum>::add(impl_types::ocl, cum_sum_impl::create, {
|
||||
implementation_map<cum_sum>::add(impl_types::ocl, typed_primitive_impl_ocl<cum_sum>::create<cum_sum_impl>, {
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
std::make_tuple(data_types::i32, format::bfzyx),
|
||||
std::make_tuple(data_types::i32, format::bfwzyx),
|
||||
|
||||
@@ -226,7 +226,7 @@ static std::string get_jit_constant(const custom_gpu_primitive_node& outer, cons
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
static primitive_impl* create(const custom_gpu_primitive_node& arg, const kernel_impl_params& impl_param) {
|
||||
static std::unique_ptr<primitive_impl> create(const custom_gpu_primitive_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto primitive = arg.get_primitive().get();
|
||||
|
||||
auto cl_kernel = std::make_shared<kernel_selector::cl_kernel_data>();
|
||||
@@ -245,7 +245,7 @@ static primitive_impl* create(const custom_gpu_primitive_node& arg, const kernel
|
||||
cl_kernel->params.arguments.push_back(get_arg(p));
|
||||
}
|
||||
|
||||
return new custom_gpu_primitive_impl(arg, cl_kernel);
|
||||
return cldnn::make_unique<custom_gpu_primitive_impl>(arg, cl_kernel);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct deconvolution_impl : typed_primitive_impl_ocl<deconvolution> {
|
||||
using parent = typed_primitive_impl_ocl<deconvolution>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::deconvolution_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::deconvolution_params, kernel_selector::deconvolution_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -32,6 +34,7 @@ struct deconvolution_impl : typed_primitive_impl_ocl<deconvolution> {
|
||||
|
||||
deconvolution_impl(const deconvolution_node& arg, const kernel_selector::kernel_data& kd) : parent(arg, kd) {
|
||||
set_node_params(arg);
|
||||
this->can_reuse_memory = kd.can_reuse_memory;
|
||||
}
|
||||
|
||||
void set_node_params(const program_node& arg) override {
|
||||
@@ -82,8 +85,8 @@ protected:
|
||||
uint32_t get_groups() const override { return _groups; }
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const deconvolution_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<deconvolution>();
|
||||
const auto& split = primitive->split();
|
||||
const auto& stride = primitive->stride;
|
||||
const ov::Strides dilation(impl_param.output_layout.get_spatial_rank(), 1);
|
||||
@@ -92,16 +95,15 @@ public:
|
||||
const auto& pad = primitive->pad;
|
||||
const auto& groups = primitive->groups;
|
||||
|
||||
auto deconv_params = get_weights_bias_default_params<kernel_selector::deconvolution_params>(
|
||||
auto params = get_weights_bias_default_params<kernel_selector::deconvolution_params>(
|
||||
impl_param,
|
||||
(groups > 1) ? 1 : actual_split,
|
||||
1,
|
||||
primitive->grouped_weights_shape);
|
||||
auto deconv_optional_params =
|
||||
get_default_weights_bias_optional_params<kernel_selector::deconvolution_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_weights_bias_optional_params<kernel_selector::deconvolution_optional_params>(impl_param.get_program());
|
||||
|
||||
deconv_params.split = split;
|
||||
deconv_params.groups = groups;
|
||||
params.split = split;
|
||||
params.groups = groups;
|
||||
|
||||
const auto weights_idx = 1 + 0;
|
||||
const auto& weights_layout = impl_param.input_layouts[weights_idx].convert_to_weights_layout(primitive->grouped_weights_shape);
|
||||
@@ -109,34 +111,24 @@ public:
|
||||
uint32_t ky = weights_layout.spatial(1);
|
||||
uint32_t kz = weights_layout.spatial(2);
|
||||
|
||||
deconv_params.filterSize = { kx, ky, kz };
|
||||
params.filterSize = { kx, ky, kz };
|
||||
|
||||
uint32_t pad_z = std::max<std::ptrdiff_t>(pad.size() >= 3 ? pad[pad.size() - 3] : 0, 0);
|
||||
uint32_t pad_y = std::max<std::ptrdiff_t>(pad.size() >= 2 ? pad[pad.size() - 2] : 0, 0);
|
||||
uint32_t pad_x = std::max<std::ptrdiff_t>(pad.size() >= 1 ? pad[pad.size() - 1] : 0, 0);
|
||||
deconv_params.padding = {pad_x, pad_y, pad_z};
|
||||
params.padding = {pad_x, pad_y, pad_z};
|
||||
|
||||
uint32_t stride_z = stride.size() >= 3 ? stride[stride.size() - 3] : 1;
|
||||
uint32_t stride_y = stride.size() >= 2 ? stride[stride.size() - 2] : 1;
|
||||
uint32_t stride_x = stride.size() >= 1 ? stride[stride.size() - 1] : 1;
|
||||
deconv_params.stride = {stride_x, stride_y, stride_z};
|
||||
params.stride = {stride_x, stride_y, stride_z};
|
||||
|
||||
uint32_t dilation_z = dilation.size() >= 3 ? dilation[dilation.size() - 3] : 1;
|
||||
uint32_t dilation_y = dilation.size() >= 2 ? dilation[dilation.size() - 2] : 1;
|
||||
uint32_t dilation_x = dilation.size() >= 1 ? dilation[dilation.size() - 1] : 1;
|
||||
deconv_params.dilation = {dilation_x, dilation_y, dilation_z};
|
||||
params.dilation = {dilation_x, dilation_y, dilation_z};
|
||||
|
||||
auto& kernel_selector = kernel_selector::deconvolution_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(deconv_params, deconv_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with these arguments");
|
||||
auto deconv = new deconvolution_impl(arg, best_kernels[0]);
|
||||
deconv->can_reuse_memory = best_kernels[0].can_reuse_memory;
|
||||
|
||||
return deconv;
|
||||
return {params, optional_params};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -168,7 +160,7 @@ attach_deconvolution_impl::attach_deconvolution_impl() {
|
||||
format::bs_fs_zyx_bsv32_fsv16,
|
||||
};
|
||||
|
||||
implementation_map<deconvolution>::add(impl_types::ocl, deconvolution_impl::create, types, formats);
|
||||
implementation_map<deconvolution>::add(impl_types::ocl, typed_primitive_impl_ocl<deconvolution>::create<deconvolution_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct deformable_conv_impl : typed_primitive_impl_ocl<deformable_conv> {
|
||||
using parent = typed_primitive_impl_ocl<deformable_conv>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::deformable_conv_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::convolution_params, kernel_selector::convolution_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -68,44 +70,31 @@ protected:
|
||||
uint32_t get_groups() const override { return _groups; }
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const deformable_conv_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<deformable_conv>();
|
||||
const auto& split = primitive->split();
|
||||
const auto& groups = primitive->groups;
|
||||
|
||||
const auto depthwise_separable_opt = arg.get_depthwise_sep_opt();
|
||||
const auto actual_split = depthwise_separable_opt ? (decltype(split))1 : split;
|
||||
|
||||
auto conv_params = get_weights_bias_default_params<kernel_selector::convolution_params>(
|
||||
auto params = get_weights_bias_default_params<kernel_selector::convolution_params>(
|
||||
impl_param,
|
||||
(groups > 1 && !depthwise_separable_opt) ? groups : actual_split,
|
||||
groups > 1 ? groups : split,
|
||||
groups);
|
||||
auto conv_optional_params =
|
||||
get_default_weights_bias_optional_params<kernel_selector::convolution_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_weights_bias_optional_params<kernel_selector::convolution_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto weight_idx = 1 + 0;
|
||||
const auto& weights_layout = impl_param.input_layouts[weight_idx].convert_to_weights_layout(false);
|
||||
const auto& weights_size = weights_layout.get_tensor();
|
||||
|
||||
conv_params.depthwise_separable_opt = depthwise_separable_opt;
|
||||
conv_params.split = split;
|
||||
conv_params.groups = groups;
|
||||
conv_params.filterSize = {
|
||||
params.depthwise_separable_opt = false;
|
||||
params.split = split;
|
||||
params.groups = groups;
|
||||
params.filterSize = {
|
||||
(uint32_t)weights_size.spatial[0],
|
||||
(uint32_t)weights_size.spatial[1],
|
||||
(uint32_t)weights_size.spatial[2],
|
||||
};
|
||||
|
||||
auto& kernel_selector = kernel_selector::deformable_conv_kernel_selector::Instance();
|
||||
kernel_selector::KernelsData best_kernels = kernel_selector.GetBestKernels(conv_params, conv_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with these arguments");
|
||||
auto conv = new deformable_conv_impl(arg, best_kernels[0]);
|
||||
|
||||
return conv;
|
||||
return {params, optional_params};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -116,6 +105,8 @@ private:
|
||||
struct deformable_interp_impl : typed_primitive_impl_ocl<deformable_interp> {
|
||||
using parent = typed_primitive_impl_ocl<deformable_interp>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::deformable_interp_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::convolution_params, kernel_selector::convolution_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -129,11 +120,11 @@ protected:
|
||||
uint32_t get_groups() const override { return 1; }
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const deformable_interp_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<deformable_interp>();
|
||||
const auto input_idx = 0;
|
||||
const auto trans_idx = 1;
|
||||
const auto mask_idx = 2;
|
||||
const auto& primitive = arg.get_primitive();
|
||||
const auto& input_layout = impl_param.input_layouts[input_idx];
|
||||
const auto& kernel_size = primitive->kernel_size;
|
||||
|
||||
@@ -143,66 +134,55 @@ public:
|
||||
const auto& groups = primitive->groups;
|
||||
const auto& deformable_groups = primitive->deformable_groups;
|
||||
|
||||
auto conv_params = get_default_params<kernel_selector::convolution_params>(impl_param, groups);
|
||||
auto conv_optional_params =
|
||||
get_default_optional_params<kernel_selector::convolution_optional_params>(arg.get_program());
|
||||
auto params = get_default_params<kernel_selector::convolution_params>(impl_param, groups);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::convolution_optional_params>(impl_param.get_program());
|
||||
|
||||
// It's not really needed, just initialize fields of params
|
||||
auto weights_layout = layout(input_layout.data_type, input_layout.format, kernel_size);
|
||||
conv_params.weights = convert_weights_tensor(weights_layout);
|
||||
params.weights = convert_weights_tensor(weights_layout);
|
||||
|
||||
conv_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[trans_idx]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[trans_idx]));
|
||||
if (primitive->input.size() == 3) {
|
||||
conv_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[mask_idx]));
|
||||
conv_params.deformable_mask_enabled = true;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[mask_idx]));
|
||||
params.deformable_mask_enabled = true;
|
||||
}
|
||||
conv_params.bilinear_interpolation_pad = primitive->bilinear_interpolation_pad;
|
||||
conv_params.deformable_groups = deformable_groups;
|
||||
params.bilinear_interpolation_pad = primitive->bilinear_interpolation_pad;
|
||||
params.deformable_groups = deformable_groups;
|
||||
|
||||
uint32_t pad_z = std::max<std::ptrdiff_t>(pad.size() >= 3 ? pad[pad.size() - 3] : 0, 0);
|
||||
uint32_t pad_y = std::max<std::ptrdiff_t>(pad.size() >= 2 ? pad[pad.size() - 2] : 0, 0);
|
||||
uint32_t pad_x = std::max<std::ptrdiff_t>(pad.size() >= 1 ? pad[pad.size() - 1] : 0, 0);
|
||||
|
||||
conv_params.padding = {pad_x, pad_y, pad_z};
|
||||
params.padding = {pad_x, pad_y, pad_z};
|
||||
|
||||
uint32_t stride_z = stride.size() >= 3 ? stride[stride.size() - 3] : 1;
|
||||
uint32_t stride_y = stride.size() >= 2 ? stride[stride.size() - 2] : 1;
|
||||
uint32_t stride_x = stride.size() >= 1 ? stride[stride.size() - 1] : 1;
|
||||
conv_params.stride = {stride_x, stride_y, stride_z};
|
||||
params.stride = {stride_x, stride_y, stride_z};
|
||||
|
||||
uint32_t dilation_z = dilation.size() >= 3 ? dilation[dilation.size() - 3] : 1;
|
||||
uint32_t dilation_y = dilation.size() >= 2 ? dilation[dilation.size() - 2] : 1;
|
||||
uint32_t dilation_x = dilation.size() >= 1 ? dilation[dilation.size() - 1] : 1;
|
||||
conv_params.dilation = {dilation_x, dilation_y, dilation_z};
|
||||
params.dilation = {dilation_x, dilation_y, dilation_z};
|
||||
|
||||
conv_params.kernelSize = { (uint32_t)kernel_size.spatial[0],
|
||||
(uint32_t)kernel_size.spatial[1],
|
||||
(uint32_t)kernel_size.spatial[2] };
|
||||
|
||||
auto& kernel_selector = kernel_selector::deformable_interp_kernel_selector::Instance();
|
||||
kernel_selector::KernelsData best_kernels = kernel_selector.GetBestKernels(conv_params, conv_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with these arguments");
|
||||
auto conv = new deformable_interp_impl(arg, best_kernels[0]);
|
||||
|
||||
return conv;
|
||||
params.kernelSize = { (uint32_t)kernel_size.spatial[0],
|
||||
(uint32_t)kernel_size.spatial[1],
|
||||
(uint32_t)kernel_size.spatial[2] };
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_deformable_conv_impl::attach_deformable_conv_impl() {
|
||||
implementation_map<deformable_conv>::add(impl_types::ocl, deformable_conv_impl::create, {
|
||||
implementation_map<deformable_conv>::add(impl_types::ocl, typed_primitive_impl_ocl<deformable_conv>::create<deformable_conv_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
});
|
||||
}
|
||||
|
||||
attach_deformable_interp_impl::attach_deformable_interp_impl() {
|
||||
implementation_map<deformable_interp>::add(impl_types::ocl, deformable_interp_impl::create, {
|
||||
implementation_map<deformable_interp>::add(impl_types::ocl, typed_primitive_impl_ocl<deformable_interp>::create<deformable_interp_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
});
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct depth_to_space_impl : typed_primitive_impl_ocl<depth_to_space> {
|
||||
using parent = typed_primitive_impl_ocl<depth_to_space>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::depth_to_space_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::depth_to_space_params, kernel_selector::depth_to_space_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -25,29 +27,15 @@ struct depth_to_space_impl : typed_primitive_impl_ocl<depth_to_space> {
|
||||
return make_unique<depth_to_space_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const depth_to_space_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<depth_to_space>();
|
||||
auto params = get_default_params<kernel_selector::depth_to_space_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::depth_to_space_optional_params>(impl_param.get_program());
|
||||
|
||||
auto depth_to_space_params = get_default_params<kernel_selector::depth_to_space_params>(impl_param);
|
||||
auto depth_to_space_optional_params =
|
||||
get_default_optional_params<kernel_selector::depth_to_space_optional_params>(arg.get_program());
|
||||
|
||||
depth_to_space_params.block_size = prim->block_size;
|
||||
depth_to_space_params.mode = prim->mode == depth_to_space_mode::blocks_first ? kernel_selector::depth_to_space_mode::BLOCKS_FIRST
|
||||
: kernel_selector::depth_to_space_mode::DEPTH_FIRST;
|
||||
|
||||
auto& kernel_selector = kernel_selector::depth_to_space_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(depth_to_space_params, depth_to_space_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto depth_to_space = new depth_to_space_impl(arg, best_kernels[0]);
|
||||
|
||||
return depth_to_space;
|
||||
params.block_size = primitive->block_size;
|
||||
params.mode = primitive->mode == depth_to_space_mode::blocks_first ? kernel_selector::depth_to_space_mode::BLOCKS_FIRST
|
||||
: kernel_selector::depth_to_space_mode::DEPTH_FIRST;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -69,7 +57,7 @@ attach_depth_to_space_impl::attach_depth_to_space_impl() {
|
||||
format::bs_fs_yx_bsv32_fsv16,
|
||||
format::bs_fs_yx_bsv32_fsv32,
|
||||
};
|
||||
implementation_map<depth_to_space>::add(impl_types::ocl, depth_to_space_impl::create, dt, fmt);
|
||||
implementation_map<depth_to_space>::add(impl_types::ocl, typed_primitive_impl_ocl<depth_to_space>::create<depth_to_space_impl>, dt, fmt);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct detection_output_impl : typed_primitive_impl_ocl<detection_output> {
|
||||
using parent = typed_primitive_impl_ocl<detection_output>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::detection_output_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::detection_output_params, kernel_selector::detection_output_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -24,10 +26,26 @@ struct detection_output_impl : typed_primitive_impl_ocl<detection_output> {
|
||||
return make_unique<detection_output_impl>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
static void set_detection_output_specific_params(kernel_selector::detection_output_params::DedicatedParams& detectOutParams,
|
||||
const detection_output_node& arg) {
|
||||
auto primitive = arg.get_primitive();
|
||||
protected:
|
||||
bool optimized_out(detection_output_inst& instance) const override {
|
||||
/// purpose: To optimize out detection_output for perf measurement.
|
||||
/// how-to: update nms_threshold to '-100' from ir file.
|
||||
return (instance.argument->nms_threshold < -1);
|
||||
}
|
||||
|
||||
public:
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<detection_output>();
|
||||
auto params = get_default_params<kernel_selector::detection_output_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::detection_output_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto confidence_idx = 1;
|
||||
const auto prior_box_idx = 2;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[confidence_idx]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[prior_box_idx]));
|
||||
|
||||
auto confidence_layout = impl_param.get_input_layout(1);
|
||||
auto& detectOutParams = params.detectOutParams;
|
||||
detectOutParams.keep_top_k = primitive->keep_top_k;
|
||||
detectOutParams.num_classes = primitive->num_classes;
|
||||
detectOutParams.top_k = primitive->top_k;
|
||||
@@ -46,42 +64,12 @@ private:
|
||||
detectOutParams.decrease_label_id = primitive->decrease_label_id;
|
||||
detectOutParams.clip_before_nms = primitive->clip_before_nms;
|
||||
detectOutParams.clip_after_nms = primitive->clip_after_nms;
|
||||
detectOutParams.conf_size_x = arg.confidence().get_output_layout().get_padded_dims()[2];
|
||||
detectOutParams.conf_size_y = arg.confidence().get_output_layout().get_padded_dims()[3];
|
||||
detectOutParams.conf_padding_x = arg.confidence().get_output_layout().data_padding.lower_size().spatial[0];
|
||||
detectOutParams.conf_padding_y = arg.confidence().get_output_layout().data_padding.lower_size().spatial[1];
|
||||
}
|
||||
detectOutParams.conf_size_x = confidence_layout.get_padded_dims()[2];
|
||||
detectOutParams.conf_size_y = confidence_layout.get_padded_dims()[3];
|
||||
detectOutParams.conf_padding_x = confidence_layout.data_padding.lower_size().spatial[0];
|
||||
detectOutParams.conf_padding_y = confidence_layout.data_padding.lower_size().spatial[1];
|
||||
|
||||
protected:
|
||||
bool optimized_out(detection_output_inst& instance) const override {
|
||||
/// purpose: To optimize out detection_output for perf measurement.
|
||||
/// how-to: update nms_threshold to '-100' from ir file.
|
||||
return (instance.argument->nms_threshold < -1);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const detection_output_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto detect_out_params = get_default_params<kernel_selector::detection_output_params>(impl_param);
|
||||
auto detect_out_optional_params =
|
||||
get_default_optional_params<kernel_selector::detection_output_optional_params>(arg.get_program());
|
||||
|
||||
const auto confidence_idx = 1;
|
||||
const auto prior_box_idx = 2;
|
||||
detect_out_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[confidence_idx]));
|
||||
detect_out_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[prior_box_idx]));
|
||||
set_detection_output_specific_params(detect_out_params.detectOutParams, arg);
|
||||
|
||||
auto& kernel_selector = kernel_selector::detection_output_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(detect_out_params, detect_out_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto detection_output = new detection_output_impl(arg, best_kernels[0]);
|
||||
|
||||
return detection_output;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -97,7 +85,7 @@ attach_detection_output_impl::attach_detection_output_impl() {
|
||||
format::bs_fs_yx_bsv16_fsv32,
|
||||
format::bs_fs_zyx_bsv16_fsv32,
|
||||
};
|
||||
implementation_map<detection_output>::add(impl_types::ocl, detection_output_impl::create, dt, fmt);
|
||||
implementation_map<detection_output>::add(impl_types::ocl, typed_primitive_impl_ocl<detection_output>::create<detection_output_impl>, dt, fmt);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
|
||||
struct dft_impl : typed_primitive_impl_ocl<dft> {
|
||||
using typed_primitive_impl_ocl::typed_primitive_impl_ocl;
|
||||
using kernel_selector_t = kernel_selector::dft_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::dft_params, kernel_selector::dft_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -24,9 +26,9 @@ struct dft_impl : typed_primitive_impl_ocl<dft> {
|
||||
return make_unique<dft_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const dft_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto params = get_default_params<kernel_selector::dft_params>(impl_param);
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto primitive = impl_param.typed_desc<dft>();
|
||||
auto params = get_default_params<kernel_selector::dft_params>(impl_param);
|
||||
params.axes = primitive->axes;
|
||||
|
||||
if (primitive->signal_size.empty()) {
|
||||
@@ -68,17 +70,8 @@ struct dft_impl : typed_primitive_impl_ocl<dft> {
|
||||
}
|
||||
}
|
||||
|
||||
auto optional_params = get_default_optional_params<kernel_selector::dft_optional_params>(arg.get_program());
|
||||
|
||||
auto& kernel_selector = kernel_selector::dft_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new dft_impl{arg, best_kernels.front()};
|
||||
auto optional_params = get_default_optional_params<kernel_selector::dft_optional_params>(impl_param.get_program());
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -105,7 +98,7 @@ attach_dft_impl::attach_dft_impl() {
|
||||
// 6d
|
||||
format::bfwzyx,
|
||||
};
|
||||
implementation_map<dft>::add(impl_types::ocl, dft_impl::create, types, formats);
|
||||
implementation_map<dft>::add(impl_types::ocl, typed_primitive_impl_ocl<dft>::create<dft_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct eltwise_impl : typed_primitive_impl_ocl<eltwise> {
|
||||
using parent = typed_primitive_impl_ocl<eltwise>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::eltwise_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::eltwise_params, kernel_selector::eltwise_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -31,34 +33,32 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const eltwise_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<eltwise>();
|
||||
auto inputs_count = primitive->input.size();
|
||||
|
||||
auto ew_params = get_default_params<kernel_selector::eltwise_params>(impl_param);
|
||||
auto ew_optional_params =
|
||||
get_default_optional_params<kernel_selector::eltwise_optional_params>(arg.get_program());
|
||||
auto params = get_default_params<kernel_selector::eltwise_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::eltwise_optional_params>(impl_param.get_program());
|
||||
|
||||
for (size_t i = 1; i < arg.inputs_count(); i++) {
|
||||
ew_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i]));
|
||||
for (size_t i = 1; i < inputs_count; i++) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i]));
|
||||
}
|
||||
|
||||
params.operations.push_back({{kernel_selector::eltwise_params::InputType::Buffer(0), kernel_selector::eltwise_params::InputType::Buffer(1)},
|
||||
convert_to_eltwise_mode(primitive->mode)});
|
||||
|
||||
ew_params.operations.push_back({{kernel_selector::eltwise_params::InputType::Buffer(0),
|
||||
kernel_selector::eltwise_params::InputType::Buffer(1)},
|
||||
convert_to_eltwise_mode(primitive->mode)});
|
||||
|
||||
for (uint32_t i = 2; i < static_cast<uint32_t>(arg.inputs_count()); i++) {
|
||||
ew_params.operations.push_back({{kernel_selector::eltwise_params::InputType::Intermediate(i - 2),
|
||||
kernel_selector::eltwise_params::InputType::Buffer(i)},
|
||||
convert_to_eltwise_mode(primitive->mode)});
|
||||
for (uint32_t i = 2; i < static_cast<uint32_t>(inputs_count); i++) {
|
||||
params.operations.push_back({{kernel_selector::eltwise_params::InputType::Intermediate(i - 2),
|
||||
kernel_selector::eltwise_params::InputType::Buffer(i)},
|
||||
convert_to_eltwise_mode(primitive->mode)});
|
||||
}
|
||||
|
||||
if (primitive->mode == eltwise_mode::sum) {
|
||||
ew_params.coefficients = primitive->coefficients;
|
||||
params.coefficients = primitive->coefficients;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ew_params.inputs.size(); i++) {
|
||||
if (!ew_params.inputs[i].SameDims(ew_params.outputs[0])) {
|
||||
for (size_t i = 0; i < params.inputs.size(); i++) {
|
||||
if (!params.inputs[i].SameDims(params.outputs[0])) {
|
||||
std::vector<int32_t> input_size = impl_param.input_layouts[i].get_tensor().raw.vector();
|
||||
std::vector<int32_t> output_size = impl_param.output_layout.get_tensor().raw.vector();
|
||||
bool broadcast = false;
|
||||
@@ -67,10 +67,10 @@ public:
|
||||
broadcast = true;
|
||||
}
|
||||
if (broadcast) {
|
||||
ew_params.broadcast = true;
|
||||
params.broadcast = true;
|
||||
break;
|
||||
} else {
|
||||
ew_params.layoutBased = true;
|
||||
params.layoutBased = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -79,53 +79,43 @@ public:
|
||||
// stride
|
||||
if (!primitive->stride.empty()) {
|
||||
const auto& stride = primitive->stride;
|
||||
ew_params.stride.resize(stride.size());
|
||||
params.stride.resize(stride.size());
|
||||
for (size_t i = 0; i < primitive->stride.size(); i++) {
|
||||
ew_params.stride[i] = {(uint32_t)stride[i].spatial[0],
|
||||
(uint32_t)stride[i].spatial[1],
|
||||
(uint32_t)stride[i].spatial[2]};
|
||||
params.stride[i] = {(uint32_t)stride[i].spatial[0],
|
||||
(uint32_t)stride[i].spatial[1],
|
||||
(uint32_t)stride[i].spatial[2]};
|
||||
}
|
||||
}
|
||||
|
||||
// check if strides are the same
|
||||
if (!ew_params.stride.empty()) {
|
||||
const auto& stride = ew_params.stride[0];
|
||||
for (size_t i = 1; i < ew_params.stride.size(); i++) {
|
||||
if (stride.x != ew_params.stride[i].x || stride.y != ew_params.stride[i].y)
|
||||
ew_params.layoutBased = true;
|
||||
if (!params.stride.empty()) {
|
||||
const auto& stride = params.stride[0];
|
||||
for (size_t i = 1; i < params.stride.size(); i++) {
|
||||
if (stride.x != params.stride[i].x || stride.y != params.stride[i].y)
|
||||
params.layoutBased = true;
|
||||
}
|
||||
} else if (!ew_params.inputs[0].SameDimsSizes(ew_params.inputs[1])) {
|
||||
ew_params.broadcast = true;
|
||||
} else if (!params.inputs[0].SameDimsSizes(params.inputs[1])) {
|
||||
params.broadcast = true;
|
||||
}
|
||||
|
||||
// TODO [LOW PRECISION]: check if this parameter's really needed. Maybe data types are enough
|
||||
bool quantization = true;
|
||||
for (size_t i = 0; i < arg.inputs_count(); i++) {
|
||||
for (size_t i = 0; i < inputs_count; i++) {
|
||||
if (impl_param.input_layouts[i].data_type != data_types::u8 &&
|
||||
impl_param.input_layouts[i].data_type != data_types::i8) {
|
||||
quantization = false;
|
||||
}
|
||||
}
|
||||
ew_params.int8_quantization = quantization;
|
||||
params.int8_quantization = quantization;
|
||||
|
||||
auto& kernel_selector = kernel_selector::eltwise_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(ew_params, ew_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto eltwise = new eltwise_impl(arg, best_kernels[0]);
|
||||
|
||||
return eltwise;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_eltwise_impl::attach_eltwise_impl() {
|
||||
implementation_map<eltwise>::add(impl_types::ocl, eltwise_impl::create, {
|
||||
implementation_map<eltwise>::add(impl_types::ocl, typed_primitive_impl_ocl<eltwise>::create<eltwise_impl>, {
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f16, format::yxfb),
|
||||
std::make_tuple(data_types::i8, format::yxfb),
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct embedding_bag_impl : typed_primitive_impl_ocl<embedding_bag> {
|
||||
using parent = typed_primitive_impl_ocl<embedding_bag>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::embedding_bag_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::embedding_bag_params, kernel_selector::embedding_bag_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -25,52 +27,39 @@ struct embedding_bag_impl : typed_primitive_impl_ocl<embedding_bag> {
|
||||
return make_unique<embedding_bag_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const embedding_bag_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
auto embedding_bag_params = get_default_params<kernel_selector::embedding_bag_params>(impl_param);
|
||||
auto embedding_bag_optional_params =
|
||||
get_default_optional_params<kernel_selector::embedding_bag_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<embedding_bag>();
|
||||
auto params = get_default_params<kernel_selector::embedding_bag_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::embedding_bag_optional_params>(impl_param.get_program());
|
||||
|
||||
auto inputs_count = impl_param.input_layouts.size();
|
||||
|
||||
switch (primitive->type) {
|
||||
case embedding_bag::packed_sum:
|
||||
embedding_bag_params.type = kernel_selector::EmbeddingBagType::PACKED_SUM;
|
||||
params.type = kernel_selector::EmbeddingBagType::PACKED_SUM;
|
||||
break;
|
||||
case embedding_bag::offsets_sum:
|
||||
embedding_bag_params.type = kernel_selector::EmbeddingBagType::OFFSETS_SUM;
|
||||
params.type = kernel_selector::EmbeddingBagType::OFFSETS_SUM;
|
||||
break;
|
||||
case embedding_bag::segments_sum:
|
||||
embedding_bag_params.type = kernel_selector::EmbeddingBagType::SEGMENTS_SUM;
|
||||
break;
|
||||
default:
|
||||
CLDNN_ERROR_MESSAGE(arg.id(), "Unknown EmbeddingBag type");
|
||||
params.type = kernel_selector::EmbeddingBagType::SEGMENTS_SUM;
|
||||
break;
|
||||
default: OPENVINO_ASSERT(false, "[GPU] Unknown embedding_bag type in primitive ", primitive->id);
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < arg.inputs_count(); i++) {
|
||||
embedding_bag_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i]));
|
||||
for (size_t i = 1; i < inputs_count; i++) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i]));
|
||||
}
|
||||
|
||||
embedding_bag_params.default_index = arg.get_primitive()->default_index;
|
||||
|
||||
auto& kernel_selector = kernel_selector::embedding_bag_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(embedding_bag_params, embedding_bag_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto embedding_bag = new embedding_bag_impl(arg, best_kernels[0]);
|
||||
|
||||
return embedding_bag;
|
||||
params.default_index = primitive->default_index;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_embedding_bag_impl::attach_embedding_bag_impl() {
|
||||
implementation_map<embedding_bag>::add(impl_types::ocl, embedding_bag_impl::create, {
|
||||
implementation_map<embedding_bag>::add(impl_types::ocl, typed_primitive_impl_ocl<embedding_bag>::create<embedding_bag_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
});
|
||||
|
||||
+16
-27
@@ -15,6 +15,9 @@ struct experimental_detectron_detection_output_impl
|
||||
: public typed_primitive_impl_ocl<experimental_detectron_detection_output> {
|
||||
using parent = typed_primitive_impl_ocl<experimental_detectron_detection_output>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::experimental_detectron_detection_output_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::experimental_detectron_detection_output_params,
|
||||
kernel_selector::experimental_detectron_detection_output_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -33,13 +36,10 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const experimental_detectron_detection_output_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<experimental_detectron_detection_output>();
|
||||
auto params = get_default_params<kernel_selector::experimental_detectron_detection_output_params>(impl_param);
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::experimental_detectron_detection_output_optional_params>(
|
||||
arg.get_program());
|
||||
|
||||
const auto& primitive = arg.get_primitive();
|
||||
auto optional_params = get_default_optional_params<kernel_selector::experimental_detectron_detection_output_optional_params>(impl_param.get_program());
|
||||
|
||||
params.score_threshold = primitive->score_threshold;
|
||||
params.nms_threshold = primitive->nms_threshold;
|
||||
@@ -50,39 +50,28 @@ public:
|
||||
params.class_agnostic_box_regression = primitive->class_agnostic_box_regression;
|
||||
params.deltas_weights = primitive->deltas_weights;
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.deltas().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(arg.scores().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(arg.image_size_info().get_output_layout()));
|
||||
for (size_t i = 1; i < impl_param.input_layouts.size(); i++) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));
|
||||
}
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.output_classes_node().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(arg.output_scores_node().get_output_layout()));
|
||||
|
||||
const auto& kernel_selector =
|
||||
kernel_selector::experimental_detectron_detection_output_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"best_kernels.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new experimental_detectron_detection_output_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
attach_experimental_detectron_detection_output_impl::attach_experimental_detectron_detection_output_impl() {
|
||||
const std::vector<data_types> types {data_types::f16, data_types::f32};
|
||||
const std::vector<format::type> formats = {format::bfyx,
|
||||
const std::vector<data_types> types {data_types::f16, data_types::f32};
|
||||
const std::vector<format::type> formats = {format::bfyx,
|
||||
format::b_fs_yx_fsv16,
|
||||
format::b_fs_yx_fsv32,
|
||||
format::bs_fs_yx_bsv16_fsv16,
|
||||
format::bs_fs_yx_bsv32_fsv32,
|
||||
format::bs_fs_yx_bsv32_fsv16};
|
||||
|
||||
implementation_map<experimental_detectron_detection_output>::add(
|
||||
impl_types::ocl, experimental_detectron_detection_output_impl::create,
|
||||
types, formats);
|
||||
implementation_map<experimental_detectron_detection_output>::add(
|
||||
impl_types::ocl,
|
||||
typed_primitive_impl_ocl<experimental_detectron_detection_output>::create<experimental_detectron_detection_output_impl>,
|
||||
types, formats);
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace ocl
|
||||
|
||||
+15
-21
@@ -16,6 +16,9 @@ struct experimental_detectron_generate_proposals_single_image_impl
|
||||
: public typed_primitive_impl_ocl<experimental_detectron_generate_proposals_single_image> {
|
||||
using parent = typed_primitive_impl_ocl<experimental_detectron_generate_proposals_single_image>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::experimental_detectron_generate_proposals_single_image_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::experimental_detectron_generate_proposals_single_image_params,
|
||||
kernel_selector::experimental_detectron_generate_proposals_single_image_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -39,33 +42,22 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const experimental_detectron_generate_proposals_single_image_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<experimental_detectron_generate_proposals_single_image>();
|
||||
auto params = get_default_params<kernel_selector::experimental_detectron_generate_proposals_single_image_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<
|
||||
kernel_selector::experimental_detectron_generate_proposals_single_image_optional_params>(arg.get_program());
|
||||
|
||||
const auto& primitive = arg.get_primitive();
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::experimental_detectron_generate_proposals_single_image_optional_params>(impl_param.get_program());
|
||||
|
||||
params.min_size = primitive->min_size;
|
||||
params.nms_threshold = primitive->nms_threshold;
|
||||
params.pre_nms_count = primitive->pre_nms_count;
|
||||
params.post_nms_count = primitive->post_nms_count;
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.anchors().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(arg.deltas().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(arg.scores().get_output_layout()));
|
||||
for (size_t i = 1; i < impl_param.input_layouts.size(); i++) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));
|
||||
}
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.output_roi_scores_node().get_output_layout()));
|
||||
|
||||
const auto& kernel_selector = kernel_selector::experimental_detectron_generate_proposals_single_image_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"best_kernels.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new experimental_detectron_generate_proposals_single_image_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -82,8 +74,10 @@ attach_experimental_detectron_generate_proposals_single_image_impl::attach_exper
|
||||
format::bs_fs_yx_bsv32_fsv32
|
||||
};
|
||||
|
||||
implementation_map<experimental_detectron_generate_proposals_single_image>::add(impl_types::ocl,
|
||||
experimental_detectron_generate_proposals_single_image_impl::create, types, formats);
|
||||
implementation_map<experimental_detectron_generate_proposals_single_image>::add(
|
||||
impl_types::ocl,
|
||||
typed_primitive_impl_ocl<experimental_detectron_generate_proposals_single_image>::create<experimental_detectron_generate_proposals_single_image_impl>,
|
||||
types, formats);
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace ocl
|
||||
|
||||
+14
-21
@@ -21,6 +21,9 @@ struct experimental_detectron_prior_grid_generator_impl
|
||||
: typed_primitive_impl_ocl<experimental_detectron_prior_grid_generator> {
|
||||
using parent = typed_primitive_impl_ocl<experimental_detectron_prior_grid_generator>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::experimental_detectron_prior_grid_generator_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::experimental_detectron_prior_grid_generator_params,
|
||||
kernel_selector::experimental_detectron_prior_grid_generator_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -28,30 +31,20 @@ struct experimental_detectron_prior_grid_generator_impl
|
||||
return make_unique<experimental_detectron_prior_grid_generator_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const experimental_detectron_prior_grid_generator_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<experimental_detectron_prior_grid_generator>();
|
||||
auto params = get_default_params<kernel_selector::experimental_detectron_prior_grid_generator_params>(impl_param);
|
||||
auto primPtr = arg.get_primitive();
|
||||
auto& prim = *primPtr;
|
||||
|
||||
params.flatten = prim.flatten;
|
||||
params.layer_height = prim.h ? prim.h : prim.featmap_height;
|
||||
params.layer_width = prim.w ? prim.w : prim.featmap_width;
|
||||
params.step_x = prim.stride_x ? prim.stride_x : static_cast<float>(prim.image_width) / params.layer_width;
|
||||
params.step_y = prim.stride_y ? prim.stride_y : static_cast<float>(prim.image_height) / params.layer_height;
|
||||
params.flatten = primitive->flatten;
|
||||
params.layer_height = primitive->h ? primitive->h : primitive->featmap_height;
|
||||
params.layer_width = primitive->w ? primitive->w : primitive->featmap_width;
|
||||
params.step_x = primitive->stride_x ? primitive->stride_x : static_cast<float>(primitive->image_width) / params.layer_width;
|
||||
params.step_y = primitive->stride_y ? primitive->stride_y : static_cast<float>(primitive->image_height) / params.layer_height;
|
||||
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::experimental_detectron_prior_grid_generator_optional_params>(
|
||||
arg.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::experimental_detectron_prior_grid_generator_optional_params>(
|
||||
impl_param.get_program());
|
||||
|
||||
auto& kernel_selector = kernel_selector::experimental_detectron_prior_grid_generator_instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new experimental_detectron_prior_grid_generator_impl{arg, best_kernels.front()};
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,7 +53,7 @@ namespace detail {
|
||||
attach_experimental_detectron_prior_grid_generator_impl::attach_experimental_detectron_prior_grid_generator_impl() {
|
||||
implementation_map<experimental_detectron_prior_grid_generator>::add(
|
||||
impl_types::ocl,
|
||||
experimental_detectron_prior_grid_generator_impl::create,
|
||||
typed_primitive_impl_ocl<experimental_detectron_prior_grid_generator>::create<experimental_detectron_prior_grid_generator_impl>,
|
||||
{
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
|
||||
+16
-22
@@ -15,6 +15,9 @@ namespace ocl {
|
||||
struct experimental_detectron_roi_feature_extractor_impl : public typed_primitive_impl_ocl<experimental_detectron_roi_feature_extractor> {
|
||||
using parent = typed_primitive_impl_ocl<experimental_detectron_roi_feature_extractor>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::experimental_detectron_roi_feature_extractor_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::experimental_detectron_roi_feature_extractor_params,
|
||||
kernel_selector::experimental_detectron_roi_feature_extractor_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -41,22 +44,15 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const experimental_detectron_roi_feature_extractor_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
const auto output_layout = impl_param.output_layout;
|
||||
const auto padding_filling_value = output_layout.data_padding.filling_value();
|
||||
CLDNN_ERROR_NOT_EQUAL(arg.id(),
|
||||
"experimental_detectron_roi_feature_extractor padding filling value",
|
||||
padding_filling_value,
|
||||
"padding mode",
|
||||
0.0f,
|
||||
"Unknown padding mode in experimental_detectron_roi_feature_extractor.");
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<experimental_detectron_roi_feature_extractor>();
|
||||
auto params = get_default_params<kernel_selector::experimental_detectron_roi_feature_extractor_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::experimental_detectron_roi_feature_extractor_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::experimental_detectron_roi_feature_extractor_optional_params>(
|
||||
impl_param.get_program());
|
||||
|
||||
size_t number_of_inputs = primitive->input_size() - 1;
|
||||
for (std::size_t i = 1; i < number_of_inputs; i++) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));
|
||||
}
|
||||
|
||||
params.output_dim = primitive->output_dim;
|
||||
@@ -67,21 +63,19 @@ public:
|
||||
params.aligned = primitive->aligned;
|
||||
params.number_of_inputs = number_of_inputs;
|
||||
|
||||
auto& kernel_selector = kernel_selector::experimental_detectron_roi_feature_extractor_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(), "best_kernels.empty()", best_kernels.empty(), "Cannot find a proper kernel with this arguments");
|
||||
return new experimental_detectron_roi_feature_extractor_impl(arg, best_kernels.front());
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
attach_experimental_detectron_roi_feature_extractor_impl::attach_experimental_detectron_roi_feature_extractor_impl() {
|
||||
implementation_map<experimental_detectron_roi_feature_extractor>::add(impl_types::ocl,
|
||||
experimental_detectron_roi_feature_extractor_impl::create, {
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::f32, format::bfyx)
|
||||
});
|
||||
implementation_map<experimental_detectron_roi_feature_extractor>::add(
|
||||
impl_types::ocl,
|
||||
typed_primitive_impl_ocl<experimental_detectron_roi_feature_extractor>::create<experimental_detectron_roi_feature_extractor_impl>,
|
||||
{
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::f32, format::bfyx)
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace ocl {
|
||||
struct experimental_detectron_topk_rois_impl : typed_primitive_impl_ocl<experimental_detectron_topk_rois> {
|
||||
using parent = typed_primitive_impl_ocl<experimental_detectron_topk_rois>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::experimental_detectron_topk_rois_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::experimental_detectron_topk_roi_params,
|
||||
kernel_selector::experimental_detectron_topk_roi_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -23,20 +26,13 @@ struct experimental_detectron_topk_rois_impl : typed_primitive_impl_ocl<experime
|
||||
return make_unique<experimental_detectron_topk_rois_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl *create(const experimental_detectron_topk_rois_node &arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<experimental_detectron_topk_rois>();
|
||||
auto params = get_default_params<kernel_selector::experimental_detectron_topk_roi_params>(impl_param);
|
||||
const auto& experimental_detectron_topk_rois_kernel_selector =
|
||||
kernel_selector::experimental_detectron_topk_rois_kernel_selector::Instance();
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
params.max_rois = primitive->max_rois;
|
||||
auto best_kernels = experimental_detectron_topk_rois_kernel_selector.GetBestKernels(params,
|
||||
kernel_selector::experimental_detectron_topk_roi_optional_params());
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
return new experimental_detectron_topk_rois_impl(arg, best_kernels[0]);
|
||||
|
||||
return {params, {}};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,10 +46,11 @@ attach_experimental_detectron_topk_rois_impl::attach_experimental_detectron_topk
|
||||
format::bs_fs_yx_bsv16_fsv16,
|
||||
format::bs_fs_yx_bsv32_fsv16,
|
||||
format::bs_fs_yx_bsv32_fsv32};
|
||||
implementation_map<experimental_detectron_topk_rois>::add(impl_types::ocl,
|
||||
experimental_detectron_topk_rois_impl::create,
|
||||
types,
|
||||
formats);
|
||||
implementation_map<experimental_detectron_topk_rois>::add(
|
||||
impl_types::ocl,
|
||||
typed_primitive_impl_ocl<experimental_detectron_topk_rois>::create<experimental_detectron_topk_rois_impl>,
|
||||
types,
|
||||
formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct extract_image_patches_impl : typed_primitive_impl_ocl<extract_image_patches> {
|
||||
using parent = typed_primitive_impl_ocl<extract_image_patches>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::extract_image_patches_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::extract_image_patches_params, kernel_selector::extract_image_patches_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -24,36 +26,24 @@ struct extract_image_patches_impl : typed_primitive_impl_ocl<extract_image_patch
|
||||
return make_unique<extract_image_patches_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const extract_image_patches_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<extract_image_patches>();
|
||||
auto params = get_default_params<kernel_selector::extract_image_patches_params>(impl_param);
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::extract_image_patches_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::extract_image_patches_optional_params>(impl_param.get_program());
|
||||
|
||||
params.sizes = prim->sizes;
|
||||
params.strides = prim->strides;
|
||||
params.rates = prim->rates;
|
||||
params.auto_pad = prim->auto_pad;
|
||||
params.sizes = primitive->sizes;
|
||||
params.strides = primitive->strides;
|
||||
params.rates = primitive->rates;
|
||||
params.auto_pad = primitive->auto_pad;
|
||||
|
||||
auto& kernel_selector = kernel_selector::extract_image_patches_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto extract_image_patches = new extract_image_patches_impl(arg, best_kernels[0]);
|
||||
|
||||
return extract_image_patches;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_extract_image_patches_impl::attach_extract_image_patches_impl() {
|
||||
implementation_map<extract_image_patches>::add(impl_types::ocl, extract_image_patches_impl::create, {
|
||||
implementation_map<extract_image_patches>::add(impl_types::ocl, typed_primitive_impl_ocl<extract_image_patches>::create<extract_image_patches_impl>, {
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
std::make_tuple(data_types::i64, format::bfyx),
|
||||
std::make_tuple(data_types::i8, format::bfyx),
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace ocl {
|
||||
struct eye_impl : typed_primitive_impl_ocl<eye> {
|
||||
using parent = typed_primitive_impl_ocl<eye>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::eye_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::eye_params, kernel_selector::eye_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -28,22 +30,14 @@ struct eye_impl : typed_primitive_impl_ocl<eye> {
|
||||
return make_unique<eye_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const eye_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<eye>();
|
||||
auto params = get_default_params<kernel_selector::eye_params>(impl_param);
|
||||
auto op_params = get_default_optional_params<kernel_selector::eye_optional_params>(arg.get_program());
|
||||
auto op_params = get_default_optional_params<kernel_selector::eye_optional_params>(impl_param.get_program());
|
||||
|
||||
auto primitive = arg.get_primitive();
|
||||
params.diagonal_index = primitive->shift;
|
||||
|
||||
auto& kernel_selector = kernel_selector::eye_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, op_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new eye_impl(arg, best_kernels[0]);
|
||||
return {params, {}};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -72,7 +66,7 @@ attach_eye_impl::attach_eye_impl() {
|
||||
format::bs_fs_zyx_bsv32_fsv32,
|
||||
format::bs_fs_zyx_bsv32_fsv16,
|
||||
};
|
||||
implementation_map<eye>::add(impl_types::ocl, eye_impl::create, types, formats);
|
||||
implementation_map<eye>::add(impl_types::ocl, typed_primitive_impl_ocl<eye>::create<eye_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace ocl {
|
||||
struct fully_connected_impl : typed_primitive_impl_ocl<fully_connected> {
|
||||
using parent = typed_primitive_impl_ocl<fully_connected>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::fully_connected_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::fully_connected_params, kernel_selector::fully_connected_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -43,8 +45,8 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const fully_connected_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<fully_connected>();
|
||||
|
||||
auto get_fc_input_layouts = [primitive](const std::vector<layout>& input_layouts) {
|
||||
auto reshape_to_2d = [](const ov::PartialShape& shape, int64_t feature) {
|
||||
@@ -97,46 +99,33 @@ public:
|
||||
|
||||
updated_impl_param.output_layout = get_fc_output_layout(input_layouts, impl_param.output_layout);
|
||||
|
||||
auto fc_params = get_weights_bias_default_params<kernel_selector::fully_connected_params>(updated_impl_param);
|
||||
auto fc_optional_params =
|
||||
get_default_weights_bias_optional_params<kernel_selector::fully_connected_optional_params>(
|
||||
arg.get_program());
|
||||
fc_optional_params.allowInputReordering = true;
|
||||
const auto& progam = impl_param.get_program();
|
||||
auto params = get_weights_bias_default_params<kernel_selector::fully_connected_params>(updated_impl_param);
|
||||
auto optional_params = get_default_weights_bias_optional_params<kernel_selector::fully_connected_optional_params>(progam);
|
||||
optional_params.allowInputReordering = true;
|
||||
|
||||
if (primitive->input_size != 3)
|
||||
fc_params.outputs = { fc_params.outputs[0].FlattenFeatureAndSpatials() };
|
||||
params.outputs = { params.outputs[0].FlattenFeatureAndSpatials() };
|
||||
|
||||
bool is_quantized = true;
|
||||
for (auto& input : impl_param.input_layouts)
|
||||
is_quantized &= data_type_traits::is_quantized(input.data_type);
|
||||
|
||||
if (is_quantized) {
|
||||
fc_params.quantization = kernel_selector::QuantizationType::SYMMETRIC;
|
||||
params.quantization = kernel_selector::QuantizationType::SYMMETRIC;
|
||||
} else {
|
||||
fc_params.quantization = kernel_selector::QuantizationType::NONE;
|
||||
params.quantization = kernel_selector::QuantizationType::NONE;
|
||||
}
|
||||
|
||||
fc_optional_params.tuningParams.runner =
|
||||
std::make_shared<gpu::kernel_runner>(arg.get_program().get_engine(), arg.get_program().get_id(), true);
|
||||
|
||||
auto& kernel_selector = kernel_selector::fully_connected_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(fc_params, fc_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto fc = new fully_connected_impl(arg, best_kernels[0]);
|
||||
|
||||
return fc;
|
||||
optional_params.tuningParams.runner = std::make_shared<gpu::kernel_runner>(progam.get_engine(), progam.get_id(), true);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_fully_connected_impl::attach_fully_connected_impl() {
|
||||
implementation_map<fully_connected>::add(impl_types::ocl, fully_connected_impl::create, {
|
||||
implementation_map<fully_connected>::add(impl_types::ocl, typed_primitive_impl_ocl<fully_connected>::create<fully_connected_impl>, {
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f16, format::yxfb),
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
|
||||
@@ -62,6 +62,8 @@ static kernel_selector::gather_axis convert_axis(int64_t axis, size_t rank) {
|
||||
struct gather_impl : typed_primitive_impl_ocl<gather> {
|
||||
using parent = typed_primitive_impl_ocl<gather>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::gather_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::gather_params, kernel_selector::gather_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -70,37 +72,25 @@ struct gather_impl : typed_primitive_impl_ocl<gather> {
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const gather_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto gather_params = get_default_params<kernel_selector::gather_params>(impl_param);
|
||||
auto gather_optional_params =
|
||||
get_default_optional_params<kernel_selector::gather_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<gather>();
|
||||
auto params = get_default_params<kernel_selector::gather_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::gather_optional_params>(impl_param.get_program());
|
||||
|
||||
auto input_layout = impl_param.input_layouts[0];
|
||||
gather_params.axis = convert_axis(prim->axis, input_layout.get_rank());
|
||||
gather_params.batch_dim = size_t(prim->batch_dim);
|
||||
gather_params.support_neg_ind = prim->support_neg_ind;
|
||||
auto input_layout = impl_param.get_input_layout(0);
|
||||
params.axis = convert_axis(primitive->axis, input_layout.get_rank());
|
||||
params.batch_dim = size_t(primitive->batch_dim);
|
||||
params.support_neg_ind = primitive->support_neg_ind;
|
||||
|
||||
gather_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
|
||||
auto& kernel_selector = kernel_selector::gather_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(gather_params, gather_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto gather = new gather_impl(arg, best_kernels[0]);
|
||||
|
||||
return gather;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_gather_impl::attach_gather_impl() {
|
||||
implementation_map<gather>::add(impl_types::ocl, gather_impl::create, {
|
||||
implementation_map<gather>::add(impl_types::ocl, typed_primitive_impl_ocl<gather>::create<gather_impl>, {
|
||||
std::make_tuple(data_types::f32, format::fyxb),
|
||||
std::make_tuple(data_types::f16, format::fyxb),
|
||||
std::make_tuple(data_types::i32, format::fyxb),
|
||||
|
||||
@@ -49,6 +49,8 @@ static inline kernel_selector::gather_elements_axis convert_axis(int64_t axis, s
|
||||
struct gather_elements_impl : typed_primitive_impl_ocl<gather_elements> {
|
||||
using parent = typed_primitive_impl_ocl<gather_elements>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::gather_elements_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::gather_elements_params, kernel_selector::gather_elements_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -56,36 +58,23 @@ struct gather_elements_impl : typed_primitive_impl_ocl<gather_elements> {
|
||||
return make_unique<gather_elements_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const gather_elements_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto gather_elements_params = get_default_params<kernel_selector::gather_elements_params>(impl_param);
|
||||
auto gather_elements_optional_params =
|
||||
get_default_optional_params<kernel_selector::gather_elements_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<gather_elements>();
|
||||
auto params = get_default_params<kernel_selector::gather_elements_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::gather_elements_optional_params>(impl_param.get_program());
|
||||
|
||||
size_t rank = arg.get_output_layout().get_rank();
|
||||
gather_elements_params.axis = convert_axis(prim->axis, rank);
|
||||
size_t rank = impl_param.output_layout.get_rank();
|
||||
params.axis = convert_axis(primitive->axis, rank);
|
||||
|
||||
gather_elements_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
|
||||
auto& kernel_selector = kernel_selector::gather_elements_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(gather_elements_params, gather_elements_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto gather_elements = new gather_elements_impl(arg, best_kernels[0]);
|
||||
|
||||
return gather_elements;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_gather_elements_impl::attach_gather_elements_impl() {
|
||||
implementation_map<gather_elements>::add(impl_types::ocl, gather_elements_impl::create, {
|
||||
implementation_map<gather_elements>::add(impl_types::ocl, typed_primitive_impl_ocl<gather_elements>::create<gather_elements_impl>, {
|
||||
std::make_tuple(data_types::i8, format::bfyx),
|
||||
std::make_tuple(data_types::u8, format::bfyx),
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct gather_nd_impl : typed_primitive_impl_ocl<gather_nd> {
|
||||
using parent = typed_primitive_impl_ocl<gather_nd>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::gather_nd_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::gather_nd_params, kernel_selector::gather_nd_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -24,36 +26,24 @@ struct gather_nd_impl : typed_primitive_impl_ocl<gather_nd> {
|
||||
return make_unique<gather_nd_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const gather_nd_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto gather_nd_params = get_default_params<kernel_selector::gather_nd_params>(impl_param);
|
||||
auto gather_nd_optional_params =
|
||||
get_default_optional_params<kernel_selector::gather_nd_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<gather_nd>();
|
||||
auto params = get_default_params<kernel_selector::gather_nd_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::gather_nd_optional_params>(impl_param.get_program());
|
||||
|
||||
gather_nd_params.indices_rank = prim->indices_rank;
|
||||
gather_nd_params.batch_dims = prim->batch_dims;
|
||||
gather_nd_params.batch_merged_output = prim->batch_merged_output;
|
||||
params.indices_rank = primitive->indices_rank;
|
||||
params.batch_dims = primitive->batch_dims;
|
||||
params.batch_merged_output = primitive->batch_merged_output;
|
||||
|
||||
gather_nd_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
|
||||
auto& kernel_selector = kernel_selector::gather_nd_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(gather_nd_params, gather_nd_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto gather_nd = new gather_nd_impl(arg, best_kernels[0]);
|
||||
|
||||
return gather_nd;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_gather_nd_impl::attach_gather_nd_impl() {
|
||||
implementation_map<gather_nd>::add(impl_types::ocl, gather_nd_impl::create, {
|
||||
implementation_map<gather_nd>::add(impl_types::ocl, typed_primitive_impl_ocl<gather_nd>::create<gather_nd_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct gather_tree_impl : typed_primitive_impl_ocl<gather_tree> {
|
||||
using parent = typed_primitive_impl_ocl<gather_tree>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::gather_tree_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::gather_tree_params, kernel_selector::gather_tree_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -24,26 +26,18 @@ struct gather_tree_impl : typed_primitive_impl_ocl<gather_tree> {
|
||||
return make_unique<gather_tree_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const gather_tree_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto desc = arg.get_primitive();
|
||||
auto b_params = get_default_params<kernel_selector::gather_tree_params>(impl_param, 1);
|
||||
auto b_optional_params = get_default_optional_params<kernel_selector::gather_tree_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<gather_tree>();
|
||||
auto params = get_default_params<kernel_selector::gather_tree_params>(impl_param, 1);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::gather_tree_optional_params>(impl_param.get_program());
|
||||
|
||||
for (size_t i = 1; i < arg.get_dependencies().size(); i++) {
|
||||
b_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i], 1));
|
||||
for (size_t i = 1; i < impl_param.input_layouts.size(); i++) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i), 1));
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::gather_tree_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(b_params, b_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new gather_tree_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
attach_gather_tree_impl::attach_gather_tree_impl() {
|
||||
auto types = {data_types::i32, data_types::f32};
|
||||
@@ -62,7 +56,7 @@ attach_gather_tree_impl::attach_gather_tree_impl() {
|
||||
format::bs_fs_yx_bsv32_fsv32,
|
||||
};
|
||||
|
||||
implementation_map<gather_tree>::add(impl_types::ocl, gather_tree_impl::create, types, formats);
|
||||
implementation_map<gather_tree>::add(impl_types::ocl, typed_primitive_impl_ocl<gather_tree>::create<gather_tree_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct gemm_impl : typed_primitive_impl_ocl<gemm> {
|
||||
using parent = typed_primitive_impl_ocl<gemm>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::gemm_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::gemm_params, kernel_selector::gemm_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -25,9 +27,9 @@ struct gemm_impl : typed_primitive_impl_ocl<gemm> {
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const gemm_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto desc = arg.get_primitive();
|
||||
auto get_gemm_input_layouts = [desc](const std::vector<layout>& input_layouts, const layout& output_layout) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<gemm>();
|
||||
auto get_gemm_input_layouts = [primitive](const std::vector<layout>& input_layouts, const layout& output_layout) {
|
||||
auto get_updated_input_shape = [&](const ov::Shape& input_shape, size_t input_rank, bool transpose, bool first_input) {
|
||||
ov::Shape updated_input_shape;
|
||||
|
||||
@@ -54,8 +56,8 @@ public:
|
||||
auto input0_shape = input_layouts[0].get_shape();
|
||||
auto input1_shape = input_layouts[1].get_shape();
|
||||
|
||||
auto updated_input0_shape = get_updated_input_shape(input0_shape, desc->input_rank, desc->transpose_input0, true);
|
||||
auto updated_input1_shape = get_updated_input_shape(input1_shape, desc->weight_rank, desc->transpose_input1, false);
|
||||
auto updated_input0_shape = get_updated_input_shape(input0_shape, primitive->input_rank, primitive->transpose_input0, true);
|
||||
auto updated_input1_shape = get_updated_input_shape(input1_shape, primitive->weight_rank, primitive->transpose_input1, false);
|
||||
|
||||
std::vector<layout> layouts = input_layouts;
|
||||
layouts[0].set_partial_shape(updated_input0_shape);
|
||||
@@ -63,22 +65,22 @@ public:
|
||||
|
||||
if (input_layouts.size() == 3) {
|
||||
auto bias_shape = input_layouts[2].get_shape();
|
||||
auto updated_bias_shape = get_updated_input_shape(bias_shape, desc->weight_rank, desc->transpose_input1, false);
|
||||
auto updated_bias_shape = get_updated_input_shape(bias_shape, primitive->weight_rank, primitive->transpose_input1, false);
|
||||
layouts[2].set_partial_shape(updated_bias_shape);
|
||||
}
|
||||
|
||||
return layouts;
|
||||
};
|
||||
|
||||
auto get_gemm_output_layout = [desc](const std::vector<layout>& input_layouts, const layout& output_layout) {
|
||||
auto get_gemm_output_layout = [primitive](const std::vector<layout>& input_layouts, const layout& output_layout) {
|
||||
auto updated_output_layout = output_layout;
|
||||
auto output_rank = output_layout.get_shape().size();
|
||||
if (output_rank < 4) {
|
||||
const auto& input0_layout = input_layouts[0];
|
||||
const auto& input1_layout = input_layouts[1];
|
||||
|
||||
auto M = !desc->transpose_input0 ? input0_layout.spatial(1) : input0_layout.spatial(0);
|
||||
auto N = !desc->transpose_input1 ? input1_layout.spatial(0) : input1_layout.spatial(1);
|
||||
auto M = !primitive->transpose_input0 ? input0_layout.spatial(1) : input0_layout.spatial(0);
|
||||
auto N = !primitive->transpose_input1 ? input1_layout.spatial(0) : input1_layout.spatial(1);
|
||||
|
||||
auto output_shape = input0_layout.get_shape();
|
||||
for (const auto& input_layout : input_layouts) {
|
||||
@@ -103,40 +105,30 @@ public:
|
||||
const auto input_layouts = get_gemm_input_layouts(impl_param.input_layouts, impl_param.output_layout);
|
||||
const auto output_layout = get_gemm_output_layout(input_layouts, impl_param.output_layout);
|
||||
|
||||
auto gemm_params = get_default_params<kernel_selector::gemm_params>(impl_param, 1);
|
||||
auto gemm_optional_params =
|
||||
get_default_optional_params<kernel_selector::gemm_optional_params>(arg.get_program());
|
||||
auto params = get_default_params<kernel_selector::gemm_params>(impl_param, 1);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::gemm_optional_params>(impl_param.get_program());
|
||||
|
||||
gemm_params.inputs.clear();
|
||||
for (size_t i = 0; i < desc->input_size(); ++i) {
|
||||
gemm_params.inputs.push_back(convert_data_tensor(input_layouts[i]));
|
||||
params.inputs.clear();
|
||||
for (size_t i = 0; i < primitive->input_size(); ++i) {
|
||||
params.inputs.push_back(convert_data_tensor(input_layouts[i]));
|
||||
}
|
||||
gemm_params.outputs[0] = convert_data_tensor(output_layout);
|
||||
params.outputs[0] = convert_data_tensor(output_layout);
|
||||
|
||||
gemm_params.alpha = desc->alpha;
|
||||
gemm_params.beta = desc->beta;
|
||||
gemm_params.transpose_input0 = desc->transpose_input0;
|
||||
gemm_params.transpose_input1 = desc->transpose_input1;
|
||||
params.alpha = primitive->alpha;
|
||||
params.beta = primitive->beta;
|
||||
params.transpose_input0 = primitive->transpose_input0;
|
||||
params.transpose_input1 = primitive->transpose_input1;
|
||||
|
||||
bool is_quantized = true;
|
||||
for (auto& input : impl_param.input_layouts)
|
||||
is_quantized &= data_type_traits::is_quantized(input.data_type);
|
||||
|
||||
if (is_quantized) {
|
||||
gemm_params.quantization = kernel_selector::QuantizationType::SYMMETRIC;
|
||||
params.quantization = kernel_selector::QuantizationType::SYMMETRIC;
|
||||
} else {
|
||||
gemm_params.quantization = kernel_selector::QuantizationType::NONE;
|
||||
params.quantization = kernel_selector::QuantizationType::NONE;
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::gemm_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(gemm_params, gemm_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new gemm_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -166,7 +158,7 @@ attach_gemm_impl::attach_gemm_impl() {
|
||||
format::bfwzyx,
|
||||
};
|
||||
|
||||
implementation_map<gemm>::add(impl_types::ocl, gemm_impl::create, types, formats);
|
||||
implementation_map<gemm>::add(impl_types::ocl, typed_primitive_impl_ocl<gemm>::create<gemm_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -17,6 +17,8 @@ struct generate_proposals_impl
|
||||
: public typed_primitive_impl_ocl<generate_proposals> {
|
||||
using parent = typed_primitive_impl_ocl<generate_proposals>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::generate_proposals_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::generate_proposals_params, kernel_selector::generate_proposals_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -33,12 +35,10 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const generate_proposals_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<generate_proposals>();
|
||||
auto params = get_default_params<kernel_selector::generate_proposals_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<
|
||||
kernel_selector::generate_proposals_optional_params>(arg.get_program());
|
||||
|
||||
const auto& primitive = arg.get_primitive();
|
||||
auto optional_params = get_default_optional_params<kernel_selector::generate_proposals_optional_params>(impl_param.get_program());
|
||||
|
||||
params.min_size = primitive->min_size;
|
||||
params.nms_threshold = primitive->nms_threshold;
|
||||
@@ -46,32 +46,20 @@ public:
|
||||
params.post_nms_count = primitive->post_nms_count;
|
||||
params.normalized = primitive->normalized;
|
||||
params.nms_eta = primitive->nms_eta;
|
||||
params.roi_num_type = primitive->roi_num_type == cldnn::data_types::i32 ?
|
||||
kernel_selector::Datatype::INT32 : kernel_selector::Datatype::INT64;
|
||||
params.roi_num_type = primitive->roi_num_type == cldnn::data_types::i32 ? kernel_selector::Datatype::INT32 : kernel_selector::Datatype::INT64;
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.anchors().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(arg.deltas().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(arg.scores().get_output_layout()));
|
||||
for (size_t i = 1; i < impl_param.input_layouts.size(); i++) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));
|
||||
}
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.output_rois_scores_node().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(arg.output_rois_nums_node().get_output_layout()));
|
||||
|
||||
const auto& kernel_selector = kernel_selector::generate_proposals_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"best_kernels.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new generate_proposals_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
attach_generate_proposals_impl::attach_generate_proposals_impl() {
|
||||
implementation_map<generate_proposals>::add(impl_types::ocl,
|
||||
generate_proposals_impl::create, {
|
||||
typed_primitive_impl_ocl<generate_proposals>::create<generate_proposals_impl>, {
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::b_fs_yx_fsv16),
|
||||
std::make_tuple(data_types::f16, format::b_fs_yx_fsv32),
|
||||
|
||||
@@ -119,11 +119,11 @@ struct generic_layer_cpu : typed_primitive_impl<generic_layer> {
|
||||
void init_kernels(const kernels_cache&) override {}
|
||||
};
|
||||
|
||||
static primitive_impl* create(const generic_layer_node& arg, const kernel_impl_params&) {
|
||||
static std::unique_ptr<primitive_impl> create(const generic_layer_node& arg, const kernel_impl_params&) {
|
||||
if (arg.get_primitive()->generic_params.engine == kernel_selector::generic_kernel_params::Engine::GPU) {
|
||||
return new generic_layer_impl(arg);
|
||||
return make_unique<generic_layer_impl>(arg);
|
||||
} else {
|
||||
return new generic_layer_cpu(arg);
|
||||
return make_unique<generic_layer_cpu>(arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ kernel_selector::grid_sample_params::PaddingMode from(GridSampleOp::PaddingMode
|
||||
struct grid_sample_impl : public typed_primitive_impl_ocl<grid_sample> {
|
||||
using parent = typed_primitive_impl_ocl<grid_sample>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::grid_sample_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::grid_sample_params, kernel_selector::grid_sample_optional_params>;
|
||||
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -49,28 +52,19 @@ struct grid_sample_impl : public typed_primitive_impl_ocl<grid_sample> {
|
||||
return make_unique<grid_sample_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const grid_sample_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<grid_sample>();
|
||||
auto params = get_default_params<kernel_selector::grid_sample_params>(impl_param);
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::grid_sample_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::grid_sample_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto grid_layout = impl_param.get_input_layout(1);
|
||||
params.inputs.push_back(convert_data_tensor(grid_layout));
|
||||
|
||||
const auto primitive = impl_param.typed_desc<grid_sample>();
|
||||
params.align_corners = primitive->attributes.align_corners;
|
||||
params.interpolation_mode = from(primitive->attributes.mode);
|
||||
params.padding_mode = from(primitive->attributes.padding_mode);
|
||||
|
||||
const auto& kernel_selector = kernel_selector::grid_sample_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new grid_sample_impl(arg, best_kernels.front());
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -86,7 +80,7 @@ attach_grid_sample_impl::attach_grid_sample_impl() {
|
||||
format::bs_fs_yx_bsv32_fsv32,
|
||||
format::bs_fs_yx_bsv32_fsv16};
|
||||
|
||||
implementation_map<grid_sample>::add(impl_types::ocl, grid_sample_impl::create, types, formats);
|
||||
implementation_map<grid_sample>::add(impl_types::ocl, typed_primitive_impl_ocl<grid_sample>::create<grid_sample_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace ocl {
|
||||
struct grn_impl : typed_primitive_impl_ocl<grn> {
|
||||
using parent = typed_primitive_impl_ocl<grn>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::grn_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::grn_params, kernel_selector::grn_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -28,31 +30,21 @@ struct grn_impl : typed_primitive_impl_ocl<grn> {
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const grn_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto grn_params = get_default_params<kernel_selector::grn_params>(impl_param);
|
||||
auto grn_optional_params = get_default_optional_params<kernel_selector::grn_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<grn>();
|
||||
auto params = get_default_params<kernel_selector::grn_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::grn_optional_params>(impl_param.get_program());
|
||||
|
||||
grn_params.bias = prim->bias;
|
||||
params.bias = primitive->bias;
|
||||
|
||||
auto& kernel_selector = kernel_selector::grn_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(grn_params, grn_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto grn = new grn_impl(arg, best_kernels[0]);
|
||||
|
||||
return grn;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_grn_impl::attach_grn_impl() {
|
||||
implementation_map<grn>::add(impl_types::ocl, grn_impl::create, {
|
||||
implementation_map<grn>::add(impl_types::ocl, typed_primitive_impl_ocl<grn>::create<grn_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
});
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct lrn_impl : typed_primitive_impl_ocl<lrn> {
|
||||
using parent = typed_primitive_impl_ocl<lrn>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::lrn_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::lrn_params, kernel_selector::lrn_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -23,38 +25,28 @@ struct lrn_impl : typed_primitive_impl_ocl<lrn> {
|
||||
return make_unique<lrn_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const lrn_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
auto lrn_params = get_default_params<kernel_selector::lrn_params>(impl_param);
|
||||
auto lrn_optional_params = get_default_optional_params<kernel_selector::lrn_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<lrn>();
|
||||
auto params = get_default_params<kernel_selector::lrn_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::lrn_optional_params>(impl_param.get_program());
|
||||
|
||||
lrn_params.alpha = primitive->alpha;
|
||||
lrn_params.beta = primitive->beta;
|
||||
lrn_params.k = primitive->k;
|
||||
lrn_params.localSize = primitive->size;
|
||||
lrn_params.divMode = kernel_selector::kernel_divider_mode::FIXED;
|
||||
lrn_params.normMode = primitive->norm_region == lrn_norm_region_within_channel
|
||||
params.alpha = primitive->alpha;
|
||||
params.beta = primitive->beta;
|
||||
params.k = primitive->k;
|
||||
params.localSize = primitive->size;
|
||||
params.divMode = kernel_selector::kernel_divider_mode::FIXED;
|
||||
params.normMode = primitive->norm_region == lrn_norm_region_within_channel
|
||||
? kernel_selector::lrn_mode::WITHIN_CHANNEL
|
||||
: kernel_selector::lrn_mode::ACROSS_CHANNEL;
|
||||
|
||||
auto& kernel_selector = kernel_selector::lrn_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(lrn_params, lrn_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto lrn = new lrn_impl(arg, best_kernels[0]);
|
||||
|
||||
return lrn;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_lrn_impl::attach_lrn_impl() {
|
||||
implementation_map<lrn>::add(impl_types::ocl, lrn_impl::create, {
|
||||
implementation_map<lrn>::add(impl_types::ocl, typed_primitive_impl_ocl<lrn>::create<lrn_impl>, {
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f16, format::yxfb),
|
||||
std::make_tuple(data_types::u8, format::yxfb),
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct lstm_dynamic_input_impl : typed_primitive_impl_ocl<lstm_dynamic_input> {
|
||||
using parent = typed_primitive_impl_ocl<lstm_dynamic_input>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::lstm_dynamic_input_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::lstm_dynamic_input_params, kernel_selector::lstm_dynamic_input_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -36,49 +38,37 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const lstm_dynamic_input_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto dlstm_input_params = get_default_params<kernel_selector::lstm_dynamic_input_params>(impl_param);
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<lstm_dynamic_input>();
|
||||
auto params = get_default_params<kernel_selector::lstm_dynamic_input_params>(impl_param);
|
||||
|
||||
const auto dyn_len_idx = 1;
|
||||
const auto weights_idx = 2;
|
||||
const auto bias_idx = 3;
|
||||
|
||||
const auto& weights_layout = impl_param.input_layouts[weights_idx];
|
||||
dlstm_input_params.weights = convert_weights_tensor(weights_layout);
|
||||
const auto& weights_layout = impl_param.get_input_layout(weights_idx);
|
||||
params.weights = convert_weights_tensor(weights_layout);
|
||||
|
||||
if (arg.bias_term()) {
|
||||
const auto& bias_layout = impl_param.input_layouts[bias_idx];
|
||||
dlstm_input_params.bias.push_back(convert_data_tensor(bias_layout));
|
||||
auto has_bias = !primitive->bias.empty();
|
||||
if (has_bias) {
|
||||
const auto& bias_layout = impl_param.get_input_layout(bias_idx);
|
||||
params.bias.push_back(convert_data_tensor(bias_layout));
|
||||
}
|
||||
|
||||
// dyn length
|
||||
const auto& dyn_length_tensor = impl_param.input_layouts[dyn_len_idx];
|
||||
dlstm_input_params.inputs.push_back(convert_data_tensor(dyn_length_tensor));
|
||||
params.inputs.push_back(convert_data_tensor(dyn_length_tensor));
|
||||
|
||||
dlstm_input_params.direction = arg.direction();
|
||||
params.direction = weights_layout.feature();
|
||||
|
||||
// finially get best kernel
|
||||
auto lstm_dynamic_optional_params =
|
||||
get_default_weights_bias_optional_params<kernel_selector::lstm_dynamic_input_optional_params>(arg.get_program());
|
||||
|
||||
auto& kernel_selector = kernel_selector::lstm_dynamic_input_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(dlstm_input_params, lstm_dynamic_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto lstm_dynamic = new lstm_dynamic_input_impl(arg, best_kernels[0]);
|
||||
|
||||
return lstm_dynamic;
|
||||
auto optional_params = get_default_weights_bias_optional_params<kernel_selector::lstm_dynamic_input_optional_params>(impl_param.get_program());
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_lstm_dynamic_input_impl::attach_lstm_dynamic_input_impl() {
|
||||
implementation_map<lstm_dynamic_input>::add(impl_types::ocl, lstm_dynamic_input_impl::create, {
|
||||
implementation_map<lstm_dynamic_input>::add(impl_types::ocl, typed_primitive_impl_ocl<lstm_dynamic_input>::create<lstm_dynamic_input_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
});
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct lstm_dynamic_timeloop_impl : typed_primitive_impl_ocl<lstm_dynamic_timeloop> {
|
||||
using parent = typed_primitive_impl_ocl<lstm_dynamic_timeloop>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::lstm_dynamic_timeloop_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::lstm_dynamic_timeloop_params, kernel_selector::lstm_dynamic_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -41,7 +43,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const lstm_dynamic_timeloop_node& arg, const kernel_impl_params& impl_param) {
|
||||
static std::unique_ptr<primitive_impl> create(const lstm_dynamic_timeloop_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto dlstm_timeloop_params = get_default_params<kernel_selector::lstm_dynamic_timeloop_params>(impl_param);
|
||||
|
||||
// dyn length
|
||||
@@ -76,19 +78,12 @@ public:
|
||||
|
||||
// finially get best kernel
|
||||
auto dlstm_timeloop_optional_params =
|
||||
get_default_optional_params<kernel_selector::lstm_dynamic_optional_params>(arg.get_program());
|
||||
get_default_optional_params<kernel_selector::lstm_dynamic_optional_params>(impl_param.get_program());
|
||||
|
||||
auto& kernel_selector = kernel_selector::lstm_dynamic_timeloop_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(dlstm_timeloop_params, dlstm_timeloop_optional_params);
|
||||
auto best_kernel = kernel_selector.get_best_kernel(dlstm_timeloop_params, dlstm_timeloop_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto lstm_dynamic = new lstm_dynamic_timeloop_impl(arg, best_kernels[0]);
|
||||
|
||||
return lstm_dynamic;
|
||||
return make_unique<lstm_dynamic_timeloop_impl>(arg, best_kernel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct lstm_elt_impl : typed_primitive_impl_ocl<lstm_elt> {
|
||||
using parent = typed_primitive_impl_ocl<lstm_elt>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::lstm_elt_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::lstm_elt_params, kernel_selector::lstm_elt_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -36,7 +38,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const lstm_elt_node& arg, const kernel_impl_params& impl_param) {
|
||||
static std::unique_ptr<primitive_impl> create(const lstm_elt_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto lstm_elt_params = get_default_params<kernel_selector::lstm_elt_params>(impl_param);
|
||||
auto lstm_elt_optional_params =
|
||||
@@ -80,16 +82,9 @@ public:
|
||||
lstm_elt_params.direction = arg.direction();
|
||||
|
||||
auto& kernel_selector = kernel_selector::lstm_elt_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(lstm_elt_params, lstm_elt_optional_params);
|
||||
auto best_kernel = kernel_selector.get_best_kernel(lstm_elt_params, lstm_elt_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto lstm_elt = new lstm_elt_impl(arg, best_kernels[0]);
|
||||
|
||||
return lstm_elt;
|
||||
return make_unique<lstm_elt_impl>(arg, best_kernel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct lstm_gemm_impl : typed_primitive_impl_ocl<lstm_gemm> {
|
||||
using parent = typed_primitive_impl_ocl<lstm_gemm>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::lstm_gemm_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::lstm_gemm_params, kernel_selector::lstm_gemm_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -39,7 +41,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const lstm_gemm_node& arg, const kernel_impl_params& impl_param) {
|
||||
static std::unique_ptr<primitive_impl> create(const lstm_gemm_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto input_idx = 0;
|
||||
const auto weight_idx = 1;
|
||||
const auto recurrent_idx = 2;
|
||||
@@ -78,19 +80,12 @@ public:
|
||||
}
|
||||
|
||||
auto lstm_gemm_optional_params =
|
||||
get_default_optional_params<kernel_selector::lstm_gemm_optional_params>(arg.get_program());
|
||||
get_default_optional_params<kernel_selector::lstm_gemm_optional_params>(impl_param.get_program());
|
||||
|
||||
auto& kernel_selector = kernel_selector::lstm_gemm_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(lstm_gemm_params, lstm_gemm_optional_params);
|
||||
auto best_kernel = kernel_selector.get_best_kernel(lstm_gemm_params, lstm_gemm_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto lstm_gemm = new lstm_gemm_impl(arg, best_kernels[0]);
|
||||
|
||||
return lstm_gemm;
|
||||
return make_unique<lstm_gemm_impl>(arg, best_kernel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ kernel_selector::matrix_nms_params::sort_result_type from(matrix_nms::sort_resul
|
||||
struct matrix_nms_impl : typed_primitive_impl_ocl<matrix_nms> {
|
||||
using parent = typed_primitive_impl_ocl<matrix_nms>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::matrix_nms_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::matrix_nms_params, kernel_selector::matrix_nms_optional_params>;
|
||||
|
||||
std::unique_ptr<primitive_impl> clone() const override {
|
||||
return make_unique<matrix_nms_impl>(*this);
|
||||
@@ -58,10 +60,10 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const matrix_nms_node& node, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<matrix_nms>();
|
||||
auto params = get_default_params<kernel_selector::matrix_nms_params>(impl_param);
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::matrix_nms_optional_params>(node.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::matrix_nms_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto& scores_layout = impl_param.get_input_layout(1);
|
||||
const auto& second_output_layout = impl_param.get_input_layout(2);
|
||||
@@ -71,7 +73,6 @@ public:
|
||||
params.inputs.push_back(convert_data_tensor(second_output_layout));
|
||||
params.inputs.push_back(convert_data_tensor(third_output_layout));
|
||||
|
||||
const auto& primitive = node.get_primitive();
|
||||
params.sort_type = from(primitive->attribs.sort_type);
|
||||
params.sort_result_across_batch = primitive->attribs.sort_result_across_batch;
|
||||
params.score_threshold = primitive->attribs.score_threshold;
|
||||
@@ -83,17 +84,7 @@ public:
|
||||
params.post_threshold = primitive->attribs.post_threshold;
|
||||
params.normalized = primitive->attribs.normalized;
|
||||
|
||||
auto& kernel_selector = kernel_selector::matrix_nms_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(node.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this nodeuments");
|
||||
|
||||
auto matrix_nms_node = new matrix_nms_impl(node, best_kernels[0]);
|
||||
|
||||
return matrix_nms_node;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -109,7 +100,7 @@ attach_matrix_nms_impl::attach_matrix_nms_impl() {
|
||||
format::bs_fs_yx_bsv32_fsv16,
|
||||
format::bs_fs_yx_bsv32_fsv32};
|
||||
|
||||
implementation_map<matrix_nms>::add(impl_types::ocl, matrix_nms_impl::create, types, formats);
|
||||
implementation_map<matrix_nms>::add(impl_types::ocl, typed_primitive_impl_ocl<matrix_nms>::create<matrix_nms_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -45,11 +45,13 @@ kernel_selector::Datatype get_indices_output_type(const data_types indices_outpu
|
||||
}
|
||||
return kernel_selector::Datatype::INT32;
|
||||
}
|
||||
}; // namespace
|
||||
} // namespace
|
||||
|
||||
struct multiclass_nms_impl : public typed_primitive_impl_ocl<multiclass_nms> {
|
||||
using parent = typed_primitive_impl_ocl<multiclass_nms>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::multiclass_nms_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::multiclass_nms_params, kernel_selector::multiclass_nms_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -66,12 +68,12 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const multiclass_nms_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<multiclass_nms>();
|
||||
auto params = get_default_params<kernel_selector::multiclass_nms_params>(impl_param);
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::multiclass_nms_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::multiclass_nms_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto& attrs = arg.get_primitive()->attrs;
|
||||
const auto& attrs = primitive->attrs;
|
||||
|
||||
params.sort_result_type = get_sort_result_type(attrs.sort_result);
|
||||
params.sort_result_across_batch = attrs.sort_result_across_batch;
|
||||
@@ -83,26 +85,15 @@ public:
|
||||
params.background_class = attrs.background_class;
|
||||
params.normalized = attrs.normalized;
|
||||
params.nms_eta = attrs.nms_eta;
|
||||
params.has_roisnum = arg.has_roisnum();
|
||||
params.has_roisnum = primitive->has_roisnum;
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.scores().get_output_layout()));
|
||||
size_t extra_inputs_num = primitive->has_roisnum ? 4 : 3;
|
||||
|
||||
if (arg.has_roisnum()) {
|
||||
params.inputs.push_back(convert_data_tensor(arg.roisnum().get_output_layout()));
|
||||
for (size_t i = 0; i < extra_inputs_num; i++) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1 + i)));
|
||||
}
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.output_selected_indices().get_output_layout()));
|
||||
params.inputs.push_back(convert_data_tensor(arg.output_selected_num().get_output_layout()));
|
||||
|
||||
const auto& kernel_selector = kernel_selector::multiclass_nms_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"best_kernels.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new multiclass_nms_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,7 +110,7 @@ attach_multiclass_nms_impl::attach_multiclass_nms_impl() {
|
||||
format::bs_fs_yx_bsv32_fsv32,
|
||||
};
|
||||
|
||||
implementation_map<multiclass_nms>::add(impl_types::ocl, multiclass_nms_impl::create, types, formats);
|
||||
implementation_map<multiclass_nms>::add(impl_types::ocl, typed_primitive_impl_ocl<multiclass_nms>::create<multiclass_nms_impl>, types, formats);
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace ocl
|
||||
|
||||
@@ -20,7 +20,9 @@ struct mutable_data_impl : public typed_primitive_impl_ocl<mutable_data> {
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(mutable_data_node const& arg, const kernel_impl_params&) { return new mutable_data_impl(arg, {}); }
|
||||
static std::unique_ptr<primitive_impl> create(mutable_data_node const& arg, const kernel_impl_params&) {
|
||||
return make_unique<mutable_data_impl>(arg, kernel_selector::kernel_data{});
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace ocl {
|
||||
struct mvn_impl : typed_primitive_impl_ocl<mvn> {
|
||||
using parent = typed_primitive_impl_ocl<mvn>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::mvn_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::mvn_params, kernel_selector::mvn_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -27,38 +29,26 @@ struct mvn_impl : typed_primitive_impl_ocl<mvn> {
|
||||
return make_unique<mvn_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const mvn_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto mvn_params = get_default_params<kernel_selector::mvn_params>(impl_param);
|
||||
auto mvn_optional_params = get_default_optional_params<kernel_selector::mvn_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<mvn>();
|
||||
auto params = get_default_params<kernel_selector::mvn_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::mvn_optional_params>(impl_param.get_program());
|
||||
|
||||
mvn_params.mvnMode = prim->across_channels ? kernel_selector::mvn_mode::ACROSS_CHANNELS
|
||||
: kernel_selector::mvn_mode::WITHIN_CHANNELS;
|
||||
mvn_params.mvnNormalizeVariance = prim->normalize_variance;
|
||||
mvn_params.epsilon = prim->epsilon;
|
||||
params.mvnMode = primitive->across_channels ? kernel_selector::mvn_mode::ACROSS_CHANNELS
|
||||
: kernel_selector::mvn_mode::WITHIN_CHANNELS;
|
||||
params.mvnNormalizeVariance = primitive->normalize_variance;
|
||||
params.epsilon = primitive->epsilon;
|
||||
|
||||
mvn_params.mvnEpsMode = prim->eps_inside_sqrt ? kernel_selector::mvn_eps_mode::INSIDE_SQRT
|
||||
: kernel_selector::mvn_eps_mode::OUTSIDE_SQRT;
|
||||
|
||||
auto& kernel_selector = kernel_selector::mvn_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(mvn_params, mvn_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto mvn = new mvn_impl(arg, best_kernels[0]);
|
||||
|
||||
return mvn;
|
||||
params.mvnEpsMode = primitive->eps_inside_sqrt ? kernel_selector::mvn_eps_mode::INSIDE_SQRT
|
||||
: kernel_selector::mvn_eps_mode::OUTSIDE_SQRT;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_mvn_impl::attach_mvn_impl() {
|
||||
implementation_map<mvn>::add(impl_types::ocl, mvn_impl::create, {
|
||||
implementation_map<mvn>::add(impl_types::ocl, typed_primitive_impl_ocl<mvn>::create<mvn_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::u8, format::bfyx),
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace ocl {
|
||||
struct non_max_suppression_impl : typed_primitive_impl_ocl<non_max_suppression> {
|
||||
using parent = typed_primitive_impl_ocl<non_max_suppression>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::non_max_suppression_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::non_max_suppression_params, kernel_selector::non_max_suppression_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -55,11 +57,11 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const non_max_suppression_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static std::unique_ptr<primitive_impl> create(const non_max_suppression_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<non_max_suppression>();
|
||||
auto params = get_default_params<kernel_selector::non_max_suppression_params>(impl_param);
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::non_max_suppression_optional_params>(arg.get_program());
|
||||
get_default_optional_params<kernel_selector::non_max_suppression_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto input_scores_idx = 1;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[input_scores_idx]));
|
||||
@@ -133,16 +135,9 @@ public:
|
||||
params.box_encoding = primitive->center_point_box ? kernel_selector::BoxEncodingType::BOX_ENCODING_CENTER
|
||||
: kernel_selector::BoxEncodingType::BOX_ENCODING_CORNER;
|
||||
auto& kernel_selector = kernel_selector::non_max_suppression_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
auto best_kernel = kernel_selector.get_best_kernel(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto non_max_suppression_node = new non_max_suppression_impl(arg, best_kernels[0]);
|
||||
|
||||
return non_max_suppression_node;
|
||||
return make_unique<non_max_suppression_impl>(arg, best_kernel);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace ocl {
|
||||
struct count_nonzero_impl : typed_primitive_impl_ocl<count_nonzero> {
|
||||
using parent = typed_primitive_impl_ocl<count_nonzero>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::count_nonzero_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::count_nonzero_params, kernel_selector::count_nonzero_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -27,25 +29,18 @@ struct count_nonzero_impl : typed_primitive_impl_ocl<count_nonzero> {
|
||||
return make_unique<count_nonzero_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const count_nonzero_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto nonzero_params = get_default_params<kernel_selector::count_nonzero_params>(impl_param);
|
||||
auto nonzero_optional_params =
|
||||
get_default_optional_params<kernel_selector::count_nonzero_optional_params>(arg.get_program());
|
||||
|
||||
auto& kernel_selector = kernel_selector::count_nonzero_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(nonzero_params, nonzero_optional_params);
|
||||
|
||||
OPENVINO_ASSERT(!best_kernels.empty(), "Cannot find a proper kernel for ", arg.id());
|
||||
|
||||
auto count_nonzero = new count_nonzero_impl(arg, best_kernels[0]);
|
||||
|
||||
return count_nonzero;
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
auto params = get_default_params<kernel_selector::count_nonzero_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::count_nonzero_optional_params>(impl_param.get_program());
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
struct gather_nonzero_impl : typed_primitive_impl_ocl<gather_nonzero> {
|
||||
using parent = typed_primitive_impl_ocl<gather_nonzero>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::gather_nonzero_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::gather_nonzero_params, kernel_selector::gather_nonzero_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -53,30 +48,20 @@ struct gather_nonzero_impl : typed_primitive_impl_ocl<gather_nonzero> {
|
||||
return make_unique<gather_nonzero_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const gather_nonzero_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto nonzero_params = get_default_params<kernel_selector::gather_nonzero_params>(impl_param);
|
||||
auto nonzero_optional_params =
|
||||
get_default_optional_params<kernel_selector::gather_nonzero_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
auto params = get_default_params<kernel_selector::gather_nonzero_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::gather_nonzero_optional_params>(impl_param.get_program());
|
||||
|
||||
nonzero_params.inputs.push_back(convert_data_tensor(arg.input(1).get_output_layout()));
|
||||
nonzero_params.ov_input_rank = impl_param.get_input_layout().get_shape().size();
|
||||
|
||||
auto& kernel_selector = kernel_selector::gather_nonzero_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(nonzero_params, nonzero_optional_params);
|
||||
|
||||
OPENVINO_ASSERT(!best_kernels.empty(), "Cannot find a proper kernel for ", arg.id());
|
||||
|
||||
auto gather_nonzero = new gather_nonzero_impl(arg, best_kernels[0]);
|
||||
|
||||
return gather_nonzero;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
params.ov_input_rank = impl_param.get_input_layout().get_shape().size();
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_count_nonzero_impl::attach_count_nonzero_impl() {
|
||||
implementation_map<count_nonzero>::add(impl_types::ocl, count_nonzero_impl::create, {
|
||||
implementation_map<count_nonzero>::add(impl_types::ocl, typed_primitive_impl_ocl<count_nonzero>::create<count_nonzero_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
@@ -98,7 +83,7 @@ attach_count_nonzero_impl::attach_count_nonzero_impl() {
|
||||
}
|
||||
|
||||
attach_gather_nonzero_impl::attach_gather_nonzero_impl() {
|
||||
implementation_map<gather_nonzero>::add(impl_types::ocl, gather_nonzero_impl::create, {
|
||||
implementation_map<gather_nonzero>::add(impl_types::ocl, typed_primitive_impl_ocl<gather_nonzero>::create<gather_nonzero_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace ocl {
|
||||
struct normalize_impl : typed_primitive_impl_ocl<normalize> {
|
||||
using parent = typed_primitive_impl_ocl<normalize>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::normalize_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::normalize_params, kernel_selector::normalize_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -35,34 +37,22 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const normalize_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto norm_params = get_default_params<kernel_selector::normalize_params>(impl_param);
|
||||
auto norm_optional_params =
|
||||
get_default_optional_params<kernel_selector::normalize_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<normalize>();
|
||||
auto params = get_default_params<kernel_selector::normalize_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::normalize_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto& scale_layout = impl_param.input_layouts[1];
|
||||
auto scale_layout = impl_param.get_input_layout(1);
|
||||
|
||||
norm_params.normMode = prim->across_spatial ? kernel_selector::normalize_mode::ACROSS_SPATIAL
|
||||
: kernel_selector::normalize_mode::WITHIN_SPATIAL;
|
||||
norm_params.epsilon = prim->epsilon;
|
||||
params.normMode = primitive->across_spatial ? kernel_selector::normalize_mode::ACROSS_SPATIAL
|
||||
: kernel_selector::normalize_mode::WITHIN_SPATIAL;
|
||||
params.epsilon = primitive->epsilon;
|
||||
if (format::is_simple_data_format(scale_layout.format)) {
|
||||
norm_params.scaleTable = convert_data_tensor(scale_layout).FlattenFeatureAndSpatials();
|
||||
params.scaleTable = convert_data_tensor(scale_layout).FlattenFeatureAndSpatials();
|
||||
} else {
|
||||
norm_params.scaleTable = convert_data_tensor(scale_layout);
|
||||
params.scaleTable = convert_data_tensor(scale_layout);
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::normalize_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(norm_params, norm_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto lrn = new normalize_impl(arg, best_kernels[0]);
|
||||
|
||||
return lrn;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -80,7 +70,7 @@ attach_normalize_impl::attach_normalize_impl() {
|
||||
format::bs_fs_yx_bsv32_fsv32,
|
||||
format::bs_fs_yx_bsv32_fsv16,
|
||||
};
|
||||
implementation_map<normalize>::add(impl_types::ocl, normalize_impl::create, types, formats);
|
||||
implementation_map<normalize>::add(impl_types::ocl, typed_primitive_impl_ocl<normalize>::create<normalize_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct one_hot_impl : typed_primitive_impl_ocl<one_hot> {
|
||||
using parent = typed_primitive_impl_ocl<one_hot>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::one_hot_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::one_hot_params, kernel_selector::one_hot_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -25,36 +27,26 @@ struct one_hot_impl : typed_primitive_impl_ocl<one_hot> {
|
||||
return make_unique<one_hot_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const one_hot_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto oh_params = get_default_params<kernel_selector::one_hot_params>(impl_param, 1);
|
||||
auto oh_optional_params =
|
||||
get_default_optional_params<kernel_selector::one_hot_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<one_hot>();
|
||||
auto params = get_default_params<kernel_selector::one_hot_params>(impl_param, 1);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::one_hot_optional_params>(impl_param.get_program());
|
||||
|
||||
oh_params.one_hot_axis = prim->one_hot_axis;
|
||||
oh_params.on_value = prim->on_value;
|
||||
oh_params.off_value = prim->off_value;
|
||||
params.one_hot_axis = primitive->one_hot_axis;
|
||||
params.on_value = primitive->on_value;
|
||||
params.off_value = primitive->off_value;
|
||||
|
||||
auto output_sizes = impl_param.output_layout.get_dims();
|
||||
|
||||
oh_params.one_hot_limit = output_sizes[oh_params.one_hot_axis];
|
||||
|
||||
auto& kernel_selector = kernel_selector::one_hot_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(oh_params, oh_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with these arguments");
|
||||
|
||||
return new one_hot_impl(arg, best_kernels[0]);
|
||||
params.one_hot_limit = output_sizes[params.one_hot_axis];
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_one_hot_impl::attach_one_hot_impl() {
|
||||
implementation_map<one_hot>::add(impl_types::ocl, one_hot_impl::create, {
|
||||
implementation_map<one_hot>::add(impl_types::ocl, typed_primitive_impl_ocl<one_hot>::create<one_hot_impl>, {
|
||||
std::make_tuple(data_types::i8, format::bfyx),
|
||||
std::make_tuple(data_types::u8, format::bfyx),
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
|
||||
@@ -45,6 +45,8 @@ inline std::vector<uint16_t> convert_permute_order(const std::vector<uint16_t>&
|
||||
struct permute_impl : typed_primitive_impl_ocl<permute> {
|
||||
using parent = typed_primitive_impl_ocl<permute>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::permute_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::permute_params, kernel_selector::permute_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -52,33 +54,23 @@ struct permute_impl : typed_primitive_impl_ocl<permute> {
|
||||
return make_unique<permute_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const permute_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto permute_params = get_default_params<kernel_selector::permute_params>(impl_param);
|
||||
auto permute_optional_params =
|
||||
get_default_optional_params<kernel_selector::permute_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<permute>();
|
||||
auto params = get_default_params<kernel_selector::permute_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::permute_optional_params>(impl_param.get_program());
|
||||
|
||||
auto in_rank = impl_param.input_layouts[0].get_rank();
|
||||
auto permute_order = convert_permute_order(prim->permute_order, in_rank);
|
||||
permute_params.order = permute_order;
|
||||
auto& kernel_selector = kernel_selector::permute_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(permute_params, permute_optional_params);
|
||||
auto in_rank = impl_param.get_input_layout(0).get_rank();
|
||||
auto permute_order = convert_permute_order(primitive->permute_order, in_rank);
|
||||
params.order = permute_order;
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto permute = new permute_impl(arg, best_kernels[0]);
|
||||
|
||||
return permute;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_permute_impl::attach_permute_impl() {
|
||||
implementation_map<permute>::add(impl_types::ocl, permute_impl::create, {});
|
||||
implementation_map<permute>::add(impl_types::ocl, typed_primitive_impl_ocl<permute>::create<permute_impl>, {});
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -16,16 +16,6 @@ namespace cldnn {
|
||||
namespace ocl {
|
||||
|
||||
namespace {
|
||||
void validate_args(const pooling_node& arg) {
|
||||
auto input_rank = arg.input().get_output_layout().get_spatial_rank();
|
||||
auto output_rank = arg.get_output_layout().get_spatial_rank();
|
||||
auto stride_rank = std::max(arg.get_primitive()->stride.size(), static_cast<size_t>(2));
|
||||
auto window_rank = std::max(arg.get_primitive()->size.size(), static_cast<size_t>(2));
|
||||
|
||||
CLDNN_ERROR_NOT_EQUAL(arg.id(), "input dimensions", input_rank, "output dimensions", output_rank, "");
|
||||
CLDNN_ERROR_NOT_EQUAL(arg.id(), "stride dimensions", stride_rank, "output dimensions", output_rank, "");
|
||||
CLDNN_ERROR_NOT_EQUAL(arg.id(), "window dimensions", window_rank, "output dimensions", output_rank, "");
|
||||
}
|
||||
|
||||
kernel_selector::pool_type cldnn_2_pool_type(pooling_mode mode) {
|
||||
switch (mode) {
|
||||
@@ -58,6 +48,8 @@ kernel_selector::kernel_divider_mode cldnn_2_kernel_divider_mode(pooling_mode mo
|
||||
struct pooling_impl : typed_primitive_impl_ocl<pooling> {
|
||||
using parent = typed_primitive_impl_ocl<pooling>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::pooling_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::pooling_params, kernel_selector::pooling_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -72,28 +64,26 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const pooling_node& arg, const kernel_impl_params& impl_param) {
|
||||
validate_args(arg);
|
||||
const auto primitive = arg.get_primitive();
|
||||
auto pool_params = get_default_params<kernel_selector::pooling_params>(impl_param);
|
||||
auto pool_optional_params =
|
||||
get_default_optional_params<kernel_selector::pooling_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<pooling>();
|
||||
auto params = get_default_params<kernel_selector::pooling_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::pooling_optional_params>(impl_param.get_program());
|
||||
|
||||
pool_params.maxPoolOpset8Features = primitive->maxPoolOpset8Features;
|
||||
if (pool_params.maxPoolOpset8Features) {
|
||||
params.maxPoolOpset8Features = primitive->maxPoolOpset8Features;
|
||||
if (params.maxPoolOpset8Features) {
|
||||
switch (primitive->index_element_type) {
|
||||
case cldnn::data_types::i32: {
|
||||
pool_params.poolIndexElementType = kernel_selector::Datatype::INT32;
|
||||
params.poolIndexElementType = kernel_selector::Datatype::INT32;
|
||||
break;
|
||||
}
|
||||
case cldnn::data_types::i64: {
|
||||
pool_params.poolIndexElementType = kernel_selector::Datatype::INT64;
|
||||
params.poolIndexElementType = kernel_selector::Datatype::INT64;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw std::runtime_error{"Not supported index element type"};
|
||||
}
|
||||
pool_params.poolAxis = primitive->axis;
|
||||
params.poolAxis = primitive->axis;
|
||||
}
|
||||
|
||||
const auto& input_layout = impl_param.input_layouts[0];
|
||||
@@ -132,7 +122,7 @@ public:
|
||||
pads_begin.resize(std::max<size_t>(2, pads_begin.size()), 0);
|
||||
pads_end.resize(std::max<size_t>(2, pads_end.size()), 0);
|
||||
|
||||
auto& pp = pool_params;
|
||||
auto& pp = params;
|
||||
|
||||
pp.poolType = cldnn_2_pool_type(primitive->mode);
|
||||
pp.remainderAction = primitive->rounding_type == ov::op::RoundingType::CEIL ? kernel_selector::pool_remainder::CEIL
|
||||
@@ -171,17 +161,7 @@ public:
|
||||
uint32_t dilation_x = dilation.size() >= 1 ? dilation[dilation.size() - 1] : 1;
|
||||
pp.poolDilation = {dilation_x, dilation_y, dilation_z};
|
||||
|
||||
auto& kernel_selector = kernel_selector::pooling_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(pool_params, pool_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto pool = new pooling_impl(arg, best_kernels[0]);
|
||||
|
||||
return pool;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -219,7 +199,7 @@ attach_pooling_impl::attach_pooling_impl() {
|
||||
keys.emplace(data_types::f16, format::fs_b_yx_fsv32);
|
||||
keys.emplace(data_types::f32, format::fs_b_yx_fsv32);
|
||||
|
||||
implementation_map<pooling>::add(impl_types::ocl, pooling_impl::create, keys);
|
||||
implementation_map<pooling>::add(impl_types::ocl, typed_primitive_impl_ocl<pooling>::create<pooling_impl>, keys);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -83,6 +83,18 @@ struct typed_primitive_impl_ocl : public typed_primitive_impl<PType> {
|
||||
ib >> _kernel_args;
|
||||
}
|
||||
|
||||
template<typename ImplType>
|
||||
static std::unique_ptr<primitive_impl> create(const typed_program_node<PType>& arg, const kernel_impl_params& impl_param) {
|
||||
if (arg.can_be_optimized()) {
|
||||
return make_unique<ImplType>(arg, kernel_selector::kernel_data{});
|
||||
}
|
||||
auto kernel_params = ImplType::get_kernel_params(impl_param);
|
||||
auto& kernel_selector = ImplType::kernel_selector_t::Instance();
|
||||
auto best_kernel = kernel_selector.get_best_kernel(kernel_params.first, kernel_params.second);
|
||||
|
||||
return make_unique<ImplType>(arg, best_kernel);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool optimized_out(typed_primitive_inst<PType>&) const { return false; }
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct prior_box_impl : typed_primitive_impl_ocl<prior_box> {
|
||||
using parent = typed_primitive_impl_ocl<prior_box>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::prior_box_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::prior_box_params, kernel_selector::prior_box_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -25,10 +27,9 @@ struct prior_box_impl : typed_primitive_impl_ocl<prior_box> {
|
||||
return make_unique<prior_box_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const prior_box_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<prior_box>();
|
||||
auto params = get_default_params<kernel_selector::prior_box_params>(impl_param);
|
||||
const auto& kernel_selector = kernel_selector::prior_box_kernel_selector::Instance();
|
||||
const auto& primitive = arg.get_primitive();
|
||||
|
||||
const auto width = primitive->output_size.spatial[0];
|
||||
const auto height = primitive->output_size.spatial[1];
|
||||
@@ -76,13 +77,8 @@ struct prior_box_impl : typed_primitive_impl_ocl<prior_box> {
|
||||
const auto output_shape = impl_param.output_layout.get_shape();
|
||||
params.num_priors_4 = output_shape[1] / (params.width * params.height);
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, kernel_selector::prior_box_optional_params());
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
return new prior_box_impl(arg, best_kernels[0]);
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
return {params, {}};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -96,7 +92,7 @@ attach_prior_box_impl::attach_prior_box_impl() {
|
||||
format::bs_fs_yx_bsv16_fsv16,
|
||||
format::bs_fs_yx_bsv32_fsv16,
|
||||
format::bs_fs_yx_bsv32_fsv32};
|
||||
implementation_map<prior_box>::add(impl_types::ocl, prior_box_impl::create, types, formats);
|
||||
implementation_map<prior_box>::add(impl_types::ocl, typed_primitive_impl_ocl<prior_box>::create<prior_box_impl>, types, formats);
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct pyramid_roi_align_impl : typed_primitive_impl_ocl<pyramid_roi_align> {
|
||||
using parent = typed_primitive_impl_ocl<pyramid_roi_align>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::PyramidROIAlign_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::PyramidROIAlign_params, kernel_selector::PyramidROIAlign_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -25,48 +27,39 @@ struct pyramid_roi_align_impl : typed_primitive_impl_ocl<pyramid_roi_align> {
|
||||
return make_unique<pyramid_roi_align_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const pyramid_roi_align_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto prim = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<pyramid_roi_align>();
|
||||
auto params = get_default_params<kernel_selector::PyramidROIAlign_params>(impl_param, 1);
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::PyramidROIAlign_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::PyramidROIAlign_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto P2_idx = 1;
|
||||
const auto P3_idx = 2;
|
||||
const auto P4_idx = 3;
|
||||
const auto P5_idx = 4;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[P2_idx]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[P3_idx]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[P4_idx]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[P5_idx]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(P2_idx)));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(P3_idx)));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(P4_idx)));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(P5_idx)));
|
||||
|
||||
params.sampling_ratio_x = prim->sampling_ratio;
|
||||
params.sampling_ratio_y = prim->sampling_ratio;
|
||||
params.sampling_ratio_x = primitive->sampling_ratio;
|
||||
params.sampling_ratio_y = primitive->sampling_ratio;
|
||||
|
||||
auto first_layer_scale = prim->pyramid_scales[0];
|
||||
auto image_size_x = impl_param.input_layouts[P2_idx].spatial(0) * first_layer_scale;
|
||||
auto image_size_y = impl_param.input_layouts[P2_idx].spatial(1) * first_layer_scale;
|
||||
auto first_layer_scale = primitive->pyramid_scales[0];
|
||||
auto image_size_x = impl_param.get_input_layout(P2_idx).spatial(0) * first_layer_scale;
|
||||
auto image_size_y = impl_param.get_input_layout(P2_idx).spatial(1) * first_layer_scale;
|
||||
params.image_size_x = image_size_x;
|
||||
params.image_size_y = image_size_y;
|
||||
|
||||
params.pyramid_starting_level = prim->pyramid_starting_level;
|
||||
params.pyramid_starting_level = primitive->pyramid_starting_level;
|
||||
|
||||
auto& kernel_selector = kernel_selector::PyramidROIAlign_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new pyramid_roi_align_impl(arg, best_kernels[0]);
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_pyramid_roi_align_impl::attach_pyramid_roi_align_impl() {
|
||||
implementation_map<pyramid_roi_align>::add(impl_types::ocl, pyramid_roi_align_impl::create, {
|
||||
implementation_map<pyramid_roi_align>::add(impl_types::ocl, typed_primitive_impl_ocl<pyramid_roi_align>::create<pyramid_roi_align_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f32, format::byxf),
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct quantize_impl : typed_primitive_impl_ocl<quantize> {
|
||||
using parent = typed_primitive_impl_ocl<quantize>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::quantize_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::quantize_params, kernel_selector::quantize_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -45,10 +47,10 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const quantize_node& arg, const kernel_impl_params& impl_param) {
|
||||
static std::unique_ptr<primitive_impl> create(const quantize_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto quantize_params = get_default_params<kernel_selector::quantize_params>(impl_param);
|
||||
auto quantize_optional_params =
|
||||
get_default_optional_params<kernel_selector::quantize_optional_params>(arg.get_program());
|
||||
get_default_optional_params<kernel_selector::quantize_optional_params>(impl_param.get_program());
|
||||
|
||||
quantize_params.levels = arg.get_levels();
|
||||
quantize_params.packed_binary_output = arg.get_packed_binary_output();
|
||||
@@ -83,16 +85,9 @@ public:
|
||||
quantize_params.outputs = { convert_data_tensor(output_layout) };
|
||||
|
||||
auto& kernel_selector = kernel_selector::quantize_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(quantize_params, quantize_optional_params);
|
||||
auto best_kernel = kernel_selector.get_best_kernel(quantize_params, quantize_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto quantize = new quantize_impl(arg, best_kernels[0]);
|
||||
|
||||
return quantize;
|
||||
return make_unique<quantize_impl>(arg, best_kernel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct random_uniform_impl : typed_primitive_impl_ocl<random_uniform> {
|
||||
using parent = typed_primitive_impl_ocl<random_uniform>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::random_uniform_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::random_uniform_params, kernel_selector::random_uniform_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -23,29 +25,22 @@ struct random_uniform_impl : typed_primitive_impl_ocl<random_uniform> {
|
||||
return make_unique<random_uniform_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl *create(const random_uniform_node &arg, const kernel_impl_params& impl_param) {
|
||||
const auto &primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<random_uniform>();
|
||||
auto params = get_default_params<kernel_selector::random_uniform_params>(impl_param);
|
||||
auto &random_uniform_kernel_selector =
|
||||
kernel_selector::random_uniform_kernel_selector::Instance();
|
||||
params.global_seed = primitive->global_seed;
|
||||
params.op_seed = primitive->op_seed;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[2]));
|
||||
auto best_kernels = random_uniform_kernel_selector.GetBestKernels(params,
|
||||
kernel_selector::random_uniform_optional_params());
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
return new random_uniform_impl(arg, best_kernels[0]);
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(2)));
|
||||
|
||||
return {params, {}};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_random_uniform_impl::attach_random_uniform_impl() {
|
||||
implementation_map<random_uniform>::add(impl_types::ocl, random_uniform_impl::create, {
|
||||
implementation_map<random_uniform>::add(impl_types::ocl, typed_primitive_impl_ocl<random_uniform>::create<random_uniform_impl>, {
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfzyx),
|
||||
std::make_tuple(data_types::f16, format::bfwzyx),
|
||||
|
||||
@@ -14,7 +14,10 @@ namespace cldnn {
|
||||
namespace ocl {
|
||||
|
||||
struct range_impl : typed_primitive_impl_ocl<range> {
|
||||
using typed_primitive_impl_ocl::typed_primitive_impl_ocl;
|
||||
using parent = typed_primitive_impl_ocl<range>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::range_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::range_params, kernel_selector::range_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -22,22 +25,14 @@ struct range_impl : typed_primitive_impl_ocl<range> {
|
||||
return make_unique<range_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const range_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<range>();
|
||||
auto params = get_default_params<kernel_selector::range_params>(impl_param);
|
||||
for (int i : {1, 2})
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i]));
|
||||
auto optional_params =
|
||||
get_default_optional_params<kernel_selector::range_optional_params>(arg.get_program());
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));
|
||||
auto optional_params = get_default_optional_params<kernel_selector::range_optional_params>(impl_param.get_program());
|
||||
|
||||
auto& kernel_selector = kernel_selector::range_instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new range_impl{arg, best_kernels.front()};
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,7 +41,7 @@ namespace detail {
|
||||
attach_range_impl::attach_range_impl() {
|
||||
implementation_map<range>::add(
|
||||
impl_types::ocl,
|
||||
range_impl::create,
|
||||
typed_primitive_impl_ocl<range>::create<range_impl>,
|
||||
{
|
||||
std::make_tuple(data_types::u8, format::bfyx),
|
||||
std::make_tuple(data_types::i8, format::bfyx),
|
||||
|
||||
@@ -69,6 +69,8 @@ kernel_selector::reduce_mode cldnn_2_reduce_mode(reduce_mode mode) {
|
||||
struct reduce_impl : typed_primitive_impl_ocl<reduce> {
|
||||
using parent = typed_primitive_impl_ocl<reduce>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::reduce_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::reduce_params, kernel_selector::reduce_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -76,32 +78,23 @@ struct reduce_impl : typed_primitive_impl_ocl<reduce> {
|
||||
return make_unique<reduce_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const reduce_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto reduce_params = get_default_params<kernel_selector::reduce_params>(impl_param);
|
||||
auto reduce_optional_params = get_default_optional_params<kernel_selector::reduce_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<reduce>();
|
||||
auto params = get_default_params<kernel_selector::reduce_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::reduce_optional_params>(impl_param.get_program());
|
||||
|
||||
reduce_params.reduceAxes = convert_axes(prim->axes, arg.get_output_layout().get_rank());
|
||||
reduce_params.keepDims = prim->keep_dims;
|
||||
reduce_params.reduceMode = cldnn_2_reduce_mode(prim->mode);
|
||||
params.reduceAxes = convert_axes(primitive->axes, impl_param.output_layout.get_rank());
|
||||
params.keepDims = primitive->keep_dims;
|
||||
params.reduceMode = cldnn_2_reduce_mode(primitive->mode);
|
||||
|
||||
auto& kernel_selector = kernel_selector::reduce_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(reduce_params, reduce_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(), "Best_kernel.empty()", best_kernels.empty(), "Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto reduce = new reduce_impl(arg, best_kernels[0]);
|
||||
reduce->can_reuse_memory = best_kernels[0].can_reuse_memory;
|
||||
|
||||
return reduce;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_reduce_impl::attach_reduce_impl() {
|
||||
implementation_map<reduce>::add(impl_types::ocl, reduce_impl::create, {
|
||||
implementation_map<reduce>::add(impl_types::ocl, typed_primitive_impl_ocl<reduce>::create<reduce_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct region_yolo_impl : typed_primitive_impl_ocl<region_yolo> {
|
||||
using parent = typed_primitive_impl_ocl<region_yolo>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::region_yolo_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::region_yolo_params, kernel_selector::region_yolo_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -23,36 +25,25 @@ struct region_yolo_impl : typed_primitive_impl_ocl<region_yolo> {
|
||||
return make_unique<region_yolo_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const region_yolo_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto ry_params = get_default_params<kernel_selector::region_yolo_params>(impl_param);
|
||||
auto ry_optional_params =
|
||||
get_default_optional_params<kernel_selector::region_yolo_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<region_yolo>();
|
||||
auto params = get_default_params<kernel_selector::region_yolo_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::region_yolo_optional_params>(impl_param.get_program());
|
||||
|
||||
const auto& primitive = arg.get_primitive();
|
||||
ry_params.coords = primitive->coords;
|
||||
ry_params.classes = primitive->classes;
|
||||
ry_params.num = primitive->num;
|
||||
ry_params.do_softmax = primitive->do_softmax;
|
||||
ry_params.mask_size = primitive->mask_size;
|
||||
params.coords = primitive->coords;
|
||||
params.classes = primitive->classes;
|
||||
params.num = primitive->num;
|
||||
params.do_softmax = primitive->do_softmax;
|
||||
params.mask_size = primitive->mask_size;
|
||||
|
||||
auto& kernel_selector = kernel_selector::region_yolo_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(ry_params, ry_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto region_yolo_node = new region_yolo_impl(arg, best_kernels[0]);
|
||||
|
||||
return region_yolo_node;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_region_yolo_impl::attach_region_yolo_impl() {
|
||||
implementation_map<region_yolo>::add(impl_types::ocl, region_yolo_impl::create, {
|
||||
implementation_map<region_yolo>::add(impl_types::ocl, typed_primitive_impl_ocl<region_yolo>::create<region_yolo_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::f32, format::byxf),
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct reorder_impl : typed_primitive_impl_ocl<reorder> {
|
||||
using parent = typed_primitive_impl_ocl<reorder>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::reorder_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::reorder_params, kernel_selector::reorder_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -72,76 +74,65 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const reorder_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<reorder>();
|
||||
auto&& output_layout = impl_param.output_layout;
|
||||
auto reorder_params = get_default_params<kernel_selector::reorder_params>(impl_param);
|
||||
auto reorder_optional_params =
|
||||
get_default_optional_params<kernel_selector::reorder_optional_params>(arg.get_program());
|
||||
auto params = get_default_params<kernel_selector::reorder_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::reorder_optional_params>(impl_param.get_program());
|
||||
|
||||
for (size_t i = 1; i < arg.inputs_count(); i++) {
|
||||
reorder_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[i]));
|
||||
auto inputs_count = primitive->input.size();
|
||||
bool has_mean = !primitive->mean.empty();
|
||||
for (size_t i = 1; i < inputs_count; i++) {
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));
|
||||
}
|
||||
if (impl_param.output_layout.data_padding) {
|
||||
reorder_params.has_padded_output = true;
|
||||
params.has_padded_output = true;
|
||||
}
|
||||
|
||||
if (arg.has_mean()) {
|
||||
if (impl_param.input_layouts[0].format == cldnn::format::nv12) {
|
||||
const auto& mean_layout = arg.mean_nv12().get_output_layout();
|
||||
reorder_params.mean = convert_data_tensor(mean_layout);
|
||||
reorder_params.mode = kernel_selector::mean_subtruct_mode::IN_BUFFER;
|
||||
if (has_mean) {
|
||||
if (impl_param.get_input_layout(0).format == cldnn::format::nv12) {
|
||||
const auto& mean_layout = impl_param.get_input_layout(2);
|
||||
params.mean = convert_data_tensor(mean_layout);
|
||||
params.mode = kernel_selector::mean_subtruct_mode::IN_BUFFER;
|
||||
} else {
|
||||
const auto mean_idx = 1;
|
||||
const auto& mean_layout = impl_param.input_layouts[mean_idx];
|
||||
reorder_params.mean = convert_data_tensor(mean_layout);
|
||||
reorder_params.mode = kernel_selector::mean_subtruct_mode::IN_BUFFER;
|
||||
const auto& mean_layout = impl_param.get_input_layout(mean_idx);
|
||||
params.mean = convert_data_tensor(mean_layout);
|
||||
params.mode = kernel_selector::mean_subtruct_mode::IN_BUFFER;
|
||||
}
|
||||
} else if (prim->subtract_per_feature.empty() == false) {
|
||||
reorder_params.mode = kernel_selector::mean_subtruct_mode::INSIDE_PARAMS;
|
||||
reorder_params.meanValues = prim->subtract_per_feature;
|
||||
} else if (primitive->subtract_per_feature.empty() == false) {
|
||||
params.mode = kernel_selector::mean_subtruct_mode::INSIDE_PARAMS;
|
||||
params.meanValues = primitive->subtract_per_feature;
|
||||
} else {
|
||||
reorder_params.mode = kernel_selector::mean_subtruct_mode::NONE;
|
||||
params.mode = kernel_selector::mean_subtruct_mode::NONE;
|
||||
}
|
||||
|
||||
if (reorder_params.mode != kernel_selector::mean_subtruct_mode::NONE) {
|
||||
switch (prim->mean_mode) {
|
||||
if (params.mode != kernel_selector::mean_subtruct_mode::NONE) {
|
||||
switch (primitive->mean_mode) {
|
||||
case reorder_mean_mode::none:
|
||||
reorder_params.mean_op = kernel_selector::mean_op::NONE;
|
||||
params.mean_op = kernel_selector::mean_op::NONE;
|
||||
break;
|
||||
case reorder_mean_mode::mul:
|
||||
reorder_params.mean_op = kernel_selector::mean_op::MUL;
|
||||
params.mean_op = kernel_selector::mean_op::MUL;
|
||||
break;
|
||||
case reorder_mean_mode::subtract:
|
||||
reorder_params.mean_op = kernel_selector::mean_op::SUB;
|
||||
params.mean_op = kernel_selector::mean_op::SUB;
|
||||
break;
|
||||
case reorder_mean_mode::div:
|
||||
reorder_params.mean_op = kernel_selector::mean_op::DIV;
|
||||
params.mean_op = kernel_selector::mean_op::DIV;
|
||||
break;
|
||||
default:
|
||||
throw std::out_of_range(arg.id() + ": unsupported mean_mode value.");
|
||||
default: OPENVINO_ASSERT(false, "[GPU] Unsupported mean_mode value in primitive ", primitive->id);
|
||||
}
|
||||
}
|
||||
|
||||
if (output_layout.format == format::winograd_2x3_s1_data) {
|
||||
reorder_params.winograd_input_offset_x = 0;
|
||||
reorder_params.winograd_input_offset_y = 0;
|
||||
reorder_params.winograd_nr_tiles_x = ceil_div(output_layout.spatial(0), 4);
|
||||
params.winograd_input_offset_x = 0;
|
||||
params.winograd_input_offset_y = 0;
|
||||
params.winograd_nr_tiles_x = ceil_div(output_layout.spatial(0), 4);
|
||||
}
|
||||
|
||||
reorder_params.winograd = impl_param.input_layouts[0].format.is_winograd() || output_layout.format.is_winograd();
|
||||
|
||||
auto& kernel_selector = kernel_selector::reorder_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(reorder_params, reorder_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto reorder = new reorder_impl(arg, best_kernels[0]);
|
||||
|
||||
return reorder;
|
||||
params.winograd = impl_param.input_layouts[0].format.is_winograd() || output_layout.format.is_winograd();
|
||||
return {params, optional_params};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -152,7 +143,7 @@ private:
|
||||
namespace detail {
|
||||
|
||||
attach_reorder_impl::attach_reorder_impl() {
|
||||
implementation_map<reorder>::add(impl_types::ocl, reorder_impl::create, {});
|
||||
implementation_map<reorder>::add(impl_types::ocl, typed_primitive_impl_ocl<reorder>::create<reorder_impl>, {});
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct reorg_yolo_impl : typed_primitive_impl_ocl<reorg_yolo> {
|
||||
using parent = typed_primitive_impl_ocl<reorg_yolo>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::reorg_yolo_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::reorg_yolo_params, kernel_selector::reorg_yolo_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -23,25 +25,13 @@ struct reorg_yolo_impl : typed_primitive_impl_ocl<reorg_yolo> {
|
||||
return make_unique<reorg_yolo_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const reorg_yolo_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
auto ry_params = get_default_params<kernel_selector::reorg_yolo_params>(impl_param);
|
||||
auto ry_optional_params =
|
||||
get_default_optional_params<kernel_selector::reorg_yolo_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<reorg_yolo>();
|
||||
auto params = get_default_params<kernel_selector::reorg_yolo_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::reorg_yolo_optional_params>(impl_param.get_program());
|
||||
|
||||
ry_params.stride = primitive->stride;
|
||||
|
||||
auto& kernel_selector = kernel_selector::reorg_yolo_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(ry_params, ry_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto reorg_yolo_node = new reorg_yolo_impl(arg, best_kernels[0]);
|
||||
|
||||
return reorg_yolo_node;
|
||||
params.stride = primitive->stride;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,7 +50,7 @@ attach_reorg_yolo_impl::attach_reorg_yolo_impl() {
|
||||
format::bs_fs_yx_bsv32_fsv32,
|
||||
};
|
||||
|
||||
implementation_map<reorg_yolo>::add(impl_types::ocl, reorg_yolo_impl::create, types, formats);
|
||||
implementation_map<reorg_yolo>::add(impl_types::ocl, typed_primitive_impl_ocl<reorg_yolo>::create<reorg_yolo_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -128,6 +128,8 @@ inline kernel_selector::interpolate_axis convert_axis(int64_t axis, size_t rank)
|
||||
struct resample_impl : typed_primitive_impl_ocl<resample> {
|
||||
using parent = typed_primitive_impl_ocl<resample>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::resample_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::resample_params, kernel_selector::resample_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -135,22 +137,21 @@ struct resample_impl : typed_primitive_impl_ocl<resample> {
|
||||
return make_unique<resample_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const resample_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = arg.get_primitive();
|
||||
auto us_params = get_default_params<kernel_selector::resample_params>(impl_param);
|
||||
auto us_optional_params =
|
||||
get_default_optional_params<kernel_selector::resample_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<resample>();
|
||||
auto params = get_default_params<kernel_selector::resample_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::resample_optional_params>(impl_param.get_program());
|
||||
|
||||
size_t dimsNum = impl_param.output_layout.get_rank();
|
||||
us_params.resampleType = convert_to_sample_type(primitive->operation_type);
|
||||
us_params.nearestMode = convert_to_nearest_mode(primitive->round_mode);
|
||||
us_params.coordTransMode = convert_to_coord_transform_mode(primitive->coord_trans_mode);
|
||||
us_params.shapeCalculationMode = convert_to_shape_calculation_mode(primitive->shape_calc_mode);
|
||||
us_params.antialias = primitive->antialias;
|
||||
us_params.cube_coeff = primitive->cube_coeff;
|
||||
params.resampleType = convert_to_sample_type(primitive->operation_type);
|
||||
params.nearestMode = convert_to_nearest_mode(primitive->round_mode);
|
||||
params.coordTransMode = convert_to_coord_transform_mode(primitive->coord_trans_mode);
|
||||
params.shapeCalculationMode = convert_to_shape_calculation_mode(primitive->shape_calc_mode);
|
||||
params.antialias = primitive->antialias;
|
||||
params.cube_coeff = primitive->cube_coeff;
|
||||
|
||||
us_params.pads_begin = convert_pads(primitive->pads_begin, dimsNum);
|
||||
us_params.pads_end = convert_pads(primitive->pads_end, dimsNum);
|
||||
params.pads_begin = convert_pads(primitive->pads_begin, dimsNum);
|
||||
params.pads_end = convert_pads(primitive->pads_end, dimsNum);
|
||||
|
||||
auto scales = primitive->scales;
|
||||
bool scales_calc_mod = primitive->shape_calc_mode == resample::InterpolateOp::ShapeCalcMode::SCALES;
|
||||
@@ -161,20 +162,10 @@ struct resample_impl : typed_primitive_impl_ocl<resample> {
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < scales.size(); ++i) {
|
||||
us_params.axesAndScales[convert_axis(primitive->axes[i], dimsNum)] = scales[i];
|
||||
params.axesAndScales[convert_axis(primitive->axes[i], dimsNum)] = scales[i];
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::resample_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(us_params, us_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto resample = new resample_impl(arg, best_kernels[0]);
|
||||
|
||||
return resample;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -210,7 +201,7 @@ attach_resample_impl::attach_resample_impl() {
|
||||
keys.emplace(data_types::f16, format::yxfb);
|
||||
keys.emplace(data_types::f16, format::fs_b_yx_fsv32);
|
||||
|
||||
implementation_map<resample>::add(impl_types::ocl, resample_impl::create, keys);
|
||||
implementation_map<resample>::add(impl_types::ocl, typed_primitive_impl_ocl<resample>::create<resample_impl>, keys);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct reshape_impl : public typed_primitive_impl_ocl<reshape> {
|
||||
using parent = typed_primitive_impl_ocl<reshape>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::reshape_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::reshape_params, kernel_selector::reshape_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -23,33 +25,18 @@ struct reshape_impl : public typed_primitive_impl_ocl<reshape> {
|
||||
return make_unique<reshape_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(reshape_node const& arg, const kernel_impl_params& impl_param) {
|
||||
if (arg.can_be_optimized()) {
|
||||
return new reshape_impl(arg, {});
|
||||
}
|
||||
auto reorder_params = get_default_params<kernel_selector::reshape_params>(impl_param);
|
||||
auto reorder_optional_params =
|
||||
get_default_optional_params<kernel_selector::reshape_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
auto params = get_default_params<kernel_selector::reshape_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::reshape_optional_params>(impl_param.get_program());
|
||||
|
||||
auto& kernel_selector = kernel_selector::reshape_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(reorder_params, reorder_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto reshape = new reshape_impl(arg, best_kernels[0]);
|
||||
|
||||
return reshape;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_reshape_impl::attach_reshape_impl() {
|
||||
implementation_map<reshape>::add(impl_types::ocl, reshape_impl::create, {});
|
||||
implementation_map<reshape>::add(impl_types::ocl, typed_primitive_impl_ocl<reshape>::create<reshape_impl>, {});
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct reverse_impl : typed_primitive_impl_ocl<reverse> {
|
||||
using parent = typed_primitive_impl_ocl<reverse>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::reverse_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::reverse_params, kernel_selector::reverse_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -25,27 +27,15 @@ struct reverse_impl : typed_primitive_impl_ocl<reverse> {
|
||||
return make_unique<reverse_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const reverse_node& arg, const kernel_impl_params& impl_param) {
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<reverse>();
|
||||
auto params = get_default_params<kernel_selector::reverse_params>(impl_param);
|
||||
const auto optional_params =
|
||||
get_default_optional_params<kernel_selector::reverse_optional_params>(arg.get_program());
|
||||
auto optional_params = get_default_optional_params<kernel_selector::reverse_optional_params>(impl_param.get_program());
|
||||
|
||||
params.inputs.push_back(convert_data_tensor(arg.input(1).get_output_layout()));
|
||||
params.reverseMode = arg.get_primitive()->mode == reverse_mode::index ? kernel_selector::reverse_mode::index
|
||||
: kernel_selector::reverse_mode::mask;
|
||||
|
||||
const auto& kernel_selector = kernel_selector::reverse_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(params, optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto reverse = new reverse_impl(arg, best_kernels[0]);
|
||||
|
||||
return reverse;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
params.reverseMode = primitive->mode == reverse_mode::index ? kernel_selector::reverse_mode::index
|
||||
: kernel_selector::reverse_mode::mask;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -78,7 +68,7 @@ attach_reverse_impl::attach_reverse_impl() {
|
||||
keys.emplace(t, f);
|
||||
}
|
||||
}
|
||||
implementation_map<reverse>::add(impl_types::ocl, reverse_impl::create, keys);
|
||||
implementation_map<reverse>::add(impl_types::ocl, typed_primitive_impl_ocl<reverse>::create<reverse_impl>, keys);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct reverse_sequence_impl : typed_primitive_impl_ocl<reverse_sequence> {
|
||||
using parent = typed_primitive_impl_ocl<reverse_sequence>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::reverse_sequence_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::reverse_sequence_params, kernel_selector::reverse_sequence_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -24,36 +26,24 @@ struct reverse_sequence_impl : typed_primitive_impl_ocl<reverse_sequence> {
|
||||
return make_unique<reverse_sequence_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const reverse_sequence_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto reverse_sequence_params = get_default_params<kernel_selector::reverse_sequence_params>(impl_param);
|
||||
auto reverse_sequence_optional_params =
|
||||
get_default_optional_params<kernel_selector::reverse_sequence_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<reverse_sequence>();
|
||||
auto params = get_default_params<kernel_selector::reverse_sequence_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::reverse_sequence_optional_params>(impl_param.get_program());
|
||||
|
||||
reverse_sequence_params.seq_axis = prim->seq_axis;
|
||||
reverse_sequence_params.batch_axis = prim->batch_axis;
|
||||
params.seq_axis = primitive->seq_axis;
|
||||
params.batch_axis = primitive->batch_axis;
|
||||
|
||||
reverse_sequence_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
|
||||
auto& kernel_selector = kernel_selector::reverse_sequence_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(reverse_sequence_params, reverse_sequence_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto reverse_sequence = new reverse_sequence_impl(arg, best_kernels[0]);
|
||||
|
||||
return reverse_sequence;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_reverse_sequence_impl::attach_reverse_sequence_impl() {
|
||||
implementation_map<reverse_sequence>::add(impl_types::ocl, reverse_sequence_impl::create, {
|
||||
implementation_map<reverse_sequence>::add(impl_types::ocl, typed_primitive_impl_ocl<reverse_sequence>::create<reverse_sequence_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
|
||||
@@ -40,6 +40,8 @@ kernel_selector::roi_aligned_mode from(roi_align::AlignedMode mode) {
|
||||
struct roi_align_impl : typed_primitive_impl_ocl<roi_align> {
|
||||
using parent = typed_primitive_impl_ocl<roi_align>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::roi_align_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::roi_align_params, kernel_selector::roi_align_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -57,48 +59,23 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const roi_align_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& input_layout = impl_param.input_layouts[0];
|
||||
const auto& output_layout = impl_param.output_layout;
|
||||
const auto& rois_layout = impl_param.input_layouts[1];
|
||||
const auto& batches_layout = impl_param.input_layouts[2];
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<roi_align>();
|
||||
const auto& input_layout = impl_param.get_input_layout(0);
|
||||
const auto& rois_layout = impl_param.get_input_layout(1);
|
||||
const auto& batches_layout = impl_param.get_input_layout(2);
|
||||
|
||||
const auto padding_filling_value = output_layout.data_padding.filling_value();
|
||||
auto params = get_default_params<kernel_selector::roi_align_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::roi_align_optional_params>(impl_param.get_program());
|
||||
|
||||
CLDNN_ERROR_NOT_EQUAL(arg.id(),
|
||||
"roi_align padding filling value",
|
||||
padding_filling_value,
|
||||
"padding mode",
|
||||
0.0f,
|
||||
"Unknown padding mode in roi_align.");
|
||||
CLDNN_ERROR_NOT_PROPER_FORMAT(arg.id(),
|
||||
"Input_layout.format",
|
||||
input_layout.format.value,
|
||||
"output_layout.format",
|
||||
output_layout.format);
|
||||
auto roi_align_params = get_default_params<kernel_selector::roi_align_params>(impl_param);
|
||||
auto roi_align_optional_params =
|
||||
get_default_optional_params<kernel_selector::roi_align_optional_params>(arg.get_program());
|
||||
params.inputs.push_back(convert_data_tensor(rois_layout));
|
||||
params.inputs.push_back(convert_data_tensor(batches_layout));
|
||||
params.pooling_mode = from(primitive->pooling_mode);
|
||||
params.aligned_mode = from(primitive->aligned_mode);
|
||||
params.sampling_ratio = primitive->sampling_ratio;
|
||||
params.spatial_scale = primitive->spatial_scale;
|
||||
|
||||
roi_align_params.inputs.push_back(convert_data_tensor(rois_layout));
|
||||
roi_align_params.inputs.push_back(convert_data_tensor(batches_layout));
|
||||
roi_align_params.pooling_mode = from(primitive->pooling_mode);
|
||||
roi_align_params.aligned_mode = from(primitive->aligned_mode);
|
||||
roi_align_params.sampling_ratio = primitive->sampling_ratio;
|
||||
roi_align_params.spatial_scale = primitive->spatial_scale;
|
||||
|
||||
auto& kernel_selector = kernel_selector::roi_align_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(roi_align_params, roi_align_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto roi_align = new roi_align_impl(arg, best_kernels[0]);
|
||||
|
||||
return roi_align;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -114,7 +91,7 @@ attach_roi_align_impl::attach_roi_align_impl() {
|
||||
format::bs_fs_yx_bsv32_fsv16,
|
||||
format::bs_fs_yx_bsv32_fsv32};
|
||||
|
||||
implementation_map<roi_align>::add(impl_types::ocl, roi_align_impl::create, types, formats);
|
||||
implementation_map<roi_align>::add(impl_types::ocl, typed_primitive_impl_ocl<roi_align>::create<roi_align_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -36,6 +36,8 @@ kernel_selector::pool_type cldnn_2_pool_type(pooling_mode mode) {
|
||||
struct roi_pooling_impl : typed_primitive_impl_ocl<roi_pooling> {
|
||||
using parent = typed_primitive_impl_ocl<roi_pooling>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::roi_pooling_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::roi_pooling_params, kernel_selector::roi_pooling_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -61,55 +63,30 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const roi_pooling_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& input_layout = impl_param.input_layouts[0];
|
||||
const auto& output_layout = impl_param.output_layout;
|
||||
const auto& rois_layout = impl_param.input_layouts[1];
|
||||
const auto& primitive = arg.get_primitive();
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<roi_pooling>();
|
||||
const auto& input_layout = impl_param.get_input_layout(0);
|
||||
const auto& rois_layout = impl_param.get_input_layout(1);
|
||||
|
||||
const auto padding_filling_value = output_layout.data_padding.filling_value();
|
||||
auto params = get_default_params<kernel_selector::roi_pooling_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::roi_pooling_optional_params>(impl_param.get_program());
|
||||
|
||||
CLDNN_ERROR_NOT_EQUAL(arg.id(),
|
||||
"roi_pooling padding filling value",
|
||||
padding_filling_value,
|
||||
"padding mode",
|
||||
0.0f,
|
||||
"Unknown padding mode in roi_pooling.");
|
||||
CLDNN_ERROR_NOT_PROPER_FORMAT(arg.id(),
|
||||
"Input_layout.format",
|
||||
input_layout.format.value,
|
||||
"output_layout.format",
|
||||
output_layout.format);
|
||||
auto roi_params = get_default_params<kernel_selector::roi_pooling_params>(impl_param);
|
||||
auto roi_optional_params =
|
||||
get_default_optional_params<kernel_selector::roi_pooling_optional_params>(arg.get_program());
|
||||
|
||||
roi_params.inputs.push_back(convert_data_tensor(rois_layout));
|
||||
params.inputs.push_back(convert_data_tensor(rois_layout));
|
||||
if (primitive->mode == pooling_mode::deformable_bilinear && !primitive->no_trans)
|
||||
roi_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[2]));
|
||||
roi_params.mode = cldnn_2_pool_type(primitive->mode);
|
||||
roi_params.position_sensitive = primitive->position_sensitive;
|
||||
roi_params.pooled_width = primitive->pooled_width;
|
||||
roi_params.pooled_height = primitive->pooled_height;
|
||||
roi_params.spatial_scale = primitive->spatial_scale;
|
||||
roi_params.spatial_bins_x = primitive->spatial_bins_x;
|
||||
roi_params.spatial_bins_y = primitive->spatial_bins_y;
|
||||
roi_params.trans_std = primitive->trans_std;
|
||||
roi_params.no_trans = primitive->no_trans;
|
||||
roi_params.part_size = primitive->part_size;
|
||||
roi_params.group_size = primitive->group_size;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(2)));
|
||||
params.mode = cldnn_2_pool_type(primitive->mode);
|
||||
params.position_sensitive = primitive->position_sensitive;
|
||||
params.pooled_width = primitive->pooled_width;
|
||||
params.pooled_height = primitive->pooled_height;
|
||||
params.spatial_scale = primitive->spatial_scale;
|
||||
params.spatial_bins_x = primitive->spatial_bins_x;
|
||||
params.spatial_bins_y = primitive->spatial_bins_y;
|
||||
params.trans_std = primitive->trans_std;
|
||||
params.no_trans = primitive->no_trans;
|
||||
params.part_size = primitive->part_size;
|
||||
params.group_size = primitive->group_size;
|
||||
|
||||
auto& kernel_selector = kernel_selector::roi_pooling_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(roi_params, roi_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto roi_pool = new roi_pooling_impl(arg, best_kernels[0]);
|
||||
|
||||
return roi_pool;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -125,7 +102,7 @@ attach_roi_pooling_impl::attach_roi_pooling_impl() {
|
||||
|
||||
auto types = {data_types::f16, data_types::f32};
|
||||
|
||||
implementation_map<roi_pooling>::add(impl_types::ocl, roi_pooling_impl::create, types, formats);
|
||||
implementation_map<roi_pooling>::add(impl_types::ocl, typed_primitive_impl_ocl<roi_pooling>::create<roi_pooling_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace ocl {
|
||||
struct roll_impl : typed_primitive_impl_ocl<roll> {
|
||||
using parent = typed_primitive_impl_ocl<roll>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::roll_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::roll_params, kernel_selector::roll_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -20,23 +22,14 @@ struct roll_impl : typed_primitive_impl_ocl<roll> {
|
||||
return make_unique<roll_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const roll_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto roll_params = get_default_params<kernel_selector::roll_params>(impl_param);
|
||||
auto roll_optional_params =
|
||||
get_default_optional_params<kernel_selector::roll_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<roll>();
|
||||
auto params = get_default_params<kernel_selector::roll_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::roll_optional_params>(impl_param.get_program());
|
||||
|
||||
auto primitive = arg.get_primitive();
|
||||
roll_params.shift = convert_dim_vector(primitive->shift);
|
||||
params.shift = convert_dim_vector(primitive->shift);
|
||||
|
||||
const auto& kernel_selector = kernel_selector::roll_kernel_selector::Instance();
|
||||
const auto best_kernels = kernel_selector.GetBestKernels(roll_params, roll_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new roll_impl(arg, best_kernels.front());
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,7 +61,7 @@ attach_roll_impl::attach_roll_impl() {
|
||||
keys.emplace(t, f);
|
||||
}
|
||||
}
|
||||
implementation_map<roll>::add(impl_types::ocl, roll_impl::create, keys);
|
||||
implementation_map<roll>::add(impl_types::ocl, typed_primitive_impl_ocl<roll>::create<roll_impl>, keys);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -16,8 +16,7 @@ namespace cldnn {
|
||||
namespace ocl {
|
||||
|
||||
namespace {
|
||||
kernel_selector::scatter_update_axis convert_axis(int64_t axis, const scatter_elements_update_node& arg) {
|
||||
auto rank = arg.input(0).get_output_layout().get_rank();
|
||||
kernel_selector::scatter_update_axis convert_axis(int64_t axis, size_t rank) {
|
||||
if (axis < 0) {
|
||||
axis += rank;
|
||||
}
|
||||
@@ -36,7 +35,7 @@ kernel_selector::scatter_update_axis convert_axis(int64_t axis, const scatter_el
|
||||
case 3: return kernel_selector::scatter_update_axis::Y;
|
||||
case 4: return kernel_selector::scatter_update_axis::Z;
|
||||
case 5: return kernel_selector::scatter_update_axis::W;
|
||||
default: CLDNN_ERROR_MESSAGE(arg.id(), "Unsupported Axis");
|
||||
default: OPENVINO_ASSERT(false, "[GPU] Unsupported scatter update axis");
|
||||
}
|
||||
return kernel_selector::scatter_update_axis::X;
|
||||
}
|
||||
@@ -45,6 +44,8 @@ kernel_selector::scatter_update_axis convert_axis(int64_t axis, const scatter_el
|
||||
struct scatter_elements_update_impl : typed_primitive_impl_ocl<scatter_elements_update> {
|
||||
using parent = typed_primitive_impl_ocl<scatter_elements_update>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::scatter_elements_update_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::scatter_elements_update_params, kernel_selector::scatter_elements_update_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -52,29 +53,16 @@ struct scatter_elements_update_impl : typed_primitive_impl_ocl<scatter_elements_
|
||||
return make_unique<scatter_elements_update_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const scatter_elements_update_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto scatter_elements_update_params = get_default_params<kernel_selector::scatter_elements_update_params>(impl_param);
|
||||
auto scatter_elements_update_optional_params =
|
||||
get_default_optional_params<kernel_selector::scatter_elements_update_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<scatter_elements_update>();
|
||||
auto params = get_default_params<kernel_selector::scatter_elements_update_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::scatter_elements_update_optional_params>(impl_param.get_program());
|
||||
|
||||
scatter_elements_update_params.axis = convert_axis(prim->axis, arg);
|
||||
params.axis = convert_axis(primitive->axis, impl_param.get_input_layout(0).get_rank());
|
||||
|
||||
scatter_elements_update_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
scatter_elements_update_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[2]));
|
||||
|
||||
auto& kernel_selector = kernel_selector::scatter_elements_update_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(scatter_elements_update_params, scatter_elements_update_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto scatter_elements_update = new scatter_elements_update_impl(arg, best_kernels[0]);
|
||||
|
||||
return scatter_elements_update;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(2)));
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -100,7 +88,11 @@ attach_scatter_elements_update_impl::attach_scatter_elements_update_impl() {
|
||||
format::bfwzyx
|
||||
};
|
||||
|
||||
implementation_map<scatter_elements_update>::add(impl_types::ocl, scatter_elements_update_impl::create, types, formats);
|
||||
implementation_map<scatter_elements_update>::add(
|
||||
impl_types::ocl,
|
||||
typed_primitive_impl_ocl<scatter_elements_update>::create<scatter_elements_update_impl>,
|
||||
types,
|
||||
formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct scatter_nd_update_impl : typed_primitive_impl_ocl<scatter_nd_update> {
|
||||
using parent = typed_primitive_impl_ocl<scatter_nd_update>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::scatter_nd_update_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::scatter_nd_update_params, kernel_selector::scatter_nd_update_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -25,35 +27,24 @@ struct scatter_nd_update_impl : typed_primitive_impl_ocl<scatter_nd_update> {
|
||||
return make_unique<scatter_nd_update_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const scatter_nd_update_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto scatter_nd_update_params = get_default_params<kernel_selector::scatter_nd_update_params>(impl_param);
|
||||
auto scatter_nd_update_optional_params =
|
||||
get_default_optional_params<kernel_selector::scatter_nd_update_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<scatter_nd_update>();
|
||||
auto params = get_default_params<kernel_selector::scatter_nd_update_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::scatter_nd_update_optional_params>(impl_param.get_program());
|
||||
|
||||
scatter_nd_update_params.indices_rank = arg.get_primitive()->indices_rank;
|
||||
params.indices_rank = primitive->indices_rank;
|
||||
|
||||
scatter_nd_update_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
scatter_nd_update_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[2]));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(2)));
|
||||
|
||||
auto& kernel_selector = kernel_selector::scatter_nd_update_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(scatter_nd_update_params, scatter_nd_update_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto scatter_nd_update = new scatter_nd_update_impl(arg, best_kernels[0]);
|
||||
|
||||
return scatter_nd_update;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_scatter_nd_update_impl::attach_scatter_nd_update_impl() {
|
||||
implementation_map<scatter_nd_update>::add(impl_types::ocl, scatter_nd_update_impl::create, {
|
||||
implementation_map<scatter_nd_update>::add(impl_types::ocl, typed_primitive_impl_ocl<scatter_nd_update>::create<scatter_nd_update_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::i32, format::bfyx),
|
||||
|
||||
@@ -15,8 +15,7 @@ using namespace cldnn;
|
||||
namespace cldnn {
|
||||
namespace ocl {
|
||||
namespace {
|
||||
kernel_selector::scatter_update_axis convert_axis(int64_t axis, const scatter_update_node& arg) {
|
||||
auto rank = arg.input(0).get_output_layout().get_rank();
|
||||
kernel_selector::scatter_update_axis convert_axis(int64_t axis, size_t rank) {
|
||||
if (axis < 0) {
|
||||
axis += rank;
|
||||
}
|
||||
@@ -35,7 +34,7 @@ kernel_selector::scatter_update_axis convert_axis(int64_t axis, const scatter_up
|
||||
case 3: return kernel_selector::scatter_update_axis::Y;
|
||||
case 4: return kernel_selector::scatter_update_axis::Z;
|
||||
case 5: return kernel_selector::scatter_update_axis::W;
|
||||
default: CLDNN_ERROR_MESSAGE(arg.id(), "Unsupported Axis");
|
||||
default: OPENVINO_ASSERT(false, "[GPU] Unsupported scatter update axis");
|
||||
}
|
||||
return kernel_selector::scatter_update_axis::X;
|
||||
}
|
||||
@@ -44,6 +43,8 @@ kernel_selector::scatter_update_axis convert_axis(int64_t axis, const scatter_up
|
||||
struct scatter_update_impl : typed_primitive_impl_ocl<scatter_update> {
|
||||
using parent = typed_primitive_impl_ocl<scatter_update>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::scatter_update_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::scatter_update_params, kernel_selector::scatter_update_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -52,27 +53,16 @@ struct scatter_update_impl : typed_primitive_impl_ocl<scatter_update> {
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const scatter_update_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto scatter_update_params = get_default_params<kernel_selector::scatter_update_params>(impl_param);
|
||||
auto scatter_update_optional_params =
|
||||
get_default_optional_params<kernel_selector::scatter_update_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<scatter_update>();
|
||||
auto params = get_default_params<kernel_selector::scatter_update_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::scatter_update_optional_params>(impl_param.get_program());
|
||||
|
||||
scatter_update_params.axis = convert_axis(arg.get_primitive()->axis, arg);
|
||||
params.axis = convert_axis(primitive->axis, impl_param.get_input_layout(0).get_rank());
|
||||
|
||||
scatter_update_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[1]));
|
||||
scatter_update_params.inputs.push_back(convert_data_tensor(impl_param.input_layouts[2]));
|
||||
|
||||
auto& kernel_selector = kernel_selector::scatter_update_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(scatter_update_params, scatter_update_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto scatter_update = new scatter_update_impl(arg, best_kernels[0]);
|
||||
|
||||
return scatter_update;
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(1)));
|
||||
params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(2)));
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -97,7 +87,7 @@ attach_scatter_update_impl::attach_scatter_update_impl() {
|
||||
format::bfwzyx
|
||||
};
|
||||
|
||||
implementation_map<scatter_update>::add(impl_types::ocl, scatter_update_impl::create, types, formats);
|
||||
implementation_map<scatter_update>::add(impl_types::ocl, typed_primitive_impl_ocl<scatter_update>::create<scatter_update_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct select_impl : typed_primitive_impl_ocl<select> {
|
||||
using parent = typed_primitive_impl_ocl<select>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::select_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::select_params, kernel_selector::select_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -23,11 +25,10 @@ struct select_impl : typed_primitive_impl_ocl<select> {
|
||||
return make_unique<select_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const select_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto select_params = get_default_params<kernel_selector::select_params>(impl_param);
|
||||
auto select_optional_params =
|
||||
get_default_optional_params<kernel_selector::select_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<select>();
|
||||
auto params = get_default_params<kernel_selector::select_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::select_optional_params>(impl_param.get_program());
|
||||
|
||||
std::vector<layout> layouts = impl_param.input_layouts;
|
||||
auto o_layout = impl_param.output_layout;
|
||||
@@ -56,28 +57,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < arg.inputs_count(); i++) {
|
||||
select_params.inputs.push_back(convert_data_tensor(layouts[i]));
|
||||
for (size_t i = 1; i < layouts.size(); i++) {
|
||||
params.inputs.push_back(convert_data_tensor(layouts[i]));
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::select_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(select_params, select_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto select = new select_impl(arg, best_kernels[0]);
|
||||
|
||||
return select;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_select_impl::attach_select_impl() {
|
||||
implementation_map<select>::add(impl_types::ocl, select_impl::create, {
|
||||
implementation_map<select>::add(impl_types::ocl, typed_primitive_impl_ocl<select>::create<select_impl>, {
|
||||
std::make_tuple(data_types::f32, format::yxfb),
|
||||
std::make_tuple(data_types::f16, format::yxfb),
|
||||
std::make_tuple(data_types::i8, format::yxfb),
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace ocl {
|
||||
struct shape_of_impl : typed_primitive_impl_ocl<shape_of> {
|
||||
using parent = typed_primitive_impl_ocl<shape_of>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::shape_of_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::shape_of_params, kernel_selector::shape_of_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -23,32 +25,22 @@ struct shape_of_impl : typed_primitive_impl_ocl<shape_of> {
|
||||
return make_unique<shape_of_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const shape_of_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto shape_of_params = get_default_params<kernel_selector::shape_of_params>(impl_param);
|
||||
auto shape_of_optional_params =
|
||||
get_default_optional_params<kernel_selector::shape_of_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
auto params = get_default_params<kernel_selector::shape_of_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::shape_of_optional_params>(impl_param.get_program());
|
||||
|
||||
auto input_layout = impl_param.input_layouts[0];
|
||||
shape_of_params.input_rank = input_layout.get_rank();
|
||||
shape_of_params.input_dims = input_layout.get_dims();
|
||||
auto input_layout = impl_param.get_input_layout(0);
|
||||
params.input_rank = input_layout.get_rank();
|
||||
params.input_dims = input_layout.get_dims();
|
||||
|
||||
auto& kernel_selector = kernel_selector::shape_of_instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(shape_of_params, shape_of_optional_params);
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto shape_of = new shape_of_impl(arg, best_kernels[0]);
|
||||
|
||||
return shape_of;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_shape_of_impl::attach_shape_of_impl() {
|
||||
implementation_map<shape_of>::add(impl_types::ocl, shape_of_impl::create, {});
|
||||
implementation_map<shape_of>::add(impl_types::ocl, typed_primitive_impl_ocl<shape_of>::create<shape_of_impl>, {});
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct shuffle_channels_impl : typed_primitive_impl_ocl<shuffle_channels> {
|
||||
using parent = typed_primitive_impl_ocl<shuffle_channels>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::shuffle_channels_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::shuffle_channels_params, kernel_selector::shuffle_channels_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -25,40 +27,28 @@ struct shuffle_channels_impl : typed_primitive_impl_ocl<shuffle_channels> {
|
||||
return make_unique<shuffle_channels_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const shuffle_channels_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto shuffle_channels_params = get_default_params<kernel_selector::shuffle_channels_params>(impl_param);
|
||||
auto shuffle_channels_optional_params =
|
||||
get_default_optional_params<kernel_selector::shuffle_channels_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<shuffle_channels>();
|
||||
auto params = get_default_params<kernel_selector::shuffle_channels_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::shuffle_channels_optional_params>(impl_param.get_program());
|
||||
|
||||
const int32_t number_of_dims = 4;
|
||||
int32_t axis = prim->axis;
|
||||
int32_t axis = primitive->axis;
|
||||
|
||||
if (axis < 0)
|
||||
axis += number_of_dims;
|
||||
|
||||
shuffle_channels_params.group = prim->group;
|
||||
shuffle_channels_params.axis = axis;
|
||||
params.group = primitive->group;
|
||||
params.axis = axis;
|
||||
|
||||
auto& kernel_selector = kernel_selector::shuffle_channels_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(shuffle_channels_params, shuffle_channels_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto shuffle_channels = new shuffle_channels_impl(arg, best_kernels[0]);
|
||||
|
||||
return shuffle_channels;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_shuffle_channels_impl::attach_shuffle_channels_impl() {
|
||||
implementation_map<shuffle_channels>::add(impl_types::ocl, shuffle_channels_impl::create, {
|
||||
implementation_map<shuffle_channels>::add(impl_types::ocl, typed_primitive_impl_ocl<shuffle_channels>::create<shuffle_channels_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::u8, format::bfyx),
|
||||
|
||||
@@ -58,6 +58,8 @@ std::vector<std::int32_t> extractShape(kernel_selector::Tensor::DataTensor& tens
|
||||
struct slice_impl : typed_primitive_impl_ocl<slice> {
|
||||
using parent = typed_primitive_impl_ocl<slice>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::slice_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::slice_params, kernel_selector::slice_optional_params>;
|
||||
|
||||
enum InputIndices {
|
||||
kData,
|
||||
@@ -74,7 +76,7 @@ struct slice_impl : typed_primitive_impl_ocl<slice> {
|
||||
return make_unique<slice_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const slice_node& arg, const kernel_impl_params& impl_param) {
|
||||
static std::unique_ptr<primitive_impl> create(const slice_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto params = get_default_params<kernel_selector::slice_params>(impl_param);
|
||||
auto op_params = get_default_optional_params<kernel_selector::slice_optional_params>(arg.get_program());
|
||||
const auto& inputs = arg.get_dependencies();
|
||||
@@ -105,12 +107,9 @@ struct slice_impl : typed_primitive_impl_ocl<slice> {
|
||||
params.step = std::move(selected_step);
|
||||
auto &kernel_selector =
|
||||
kernel_selector::slice_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, op_params);
|
||||
auto best_kernel = kernel_selector.get_best_kernel(params, op_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(), "Best_kernel.empty()", best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
return new slice_impl(arg, best_kernels[0]);
|
||||
return make_unique<slice_impl>(arg, best_kernel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ static inline kernel_selector::softmax_dim get_softmax_dim(int64_t axis, size_t
|
||||
struct softmax_impl : typed_primitive_impl_ocl<softmax> {
|
||||
using parent = typed_primitive_impl_ocl<softmax>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::softmax_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::softmax_params, kernel_selector::softmax_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -45,26 +47,15 @@ struct softmax_impl : typed_primitive_impl_ocl<softmax> {
|
||||
return make_unique<softmax_impl>(*this);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const softmax_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto primitive = arg.get_primitive();
|
||||
auto sm_params = get_default_params<kernel_selector::softmax_params>(impl_param);
|
||||
auto sm_optional_params =
|
||||
get_default_optional_params<kernel_selector::softmax_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<softmax>();
|
||||
auto params = get_default_params<kernel_selector::softmax_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::softmax_optional_params>(impl_param.get_program());
|
||||
|
||||
size_t rank = arg.get_output_layout().get_rank();
|
||||
sm_params.dim = get_softmax_dim(primitive->dimension, rank);
|
||||
size_t rank = impl_param.output_layout.get_rank();
|
||||
params.dim = get_softmax_dim(primitive->dimension, rank);
|
||||
|
||||
auto& kernel_selector = kernel_selector::softmax_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(sm_params, sm_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto softmax_node = new softmax_impl(arg, best_kernels[0]);
|
||||
|
||||
return softmax_node;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -79,7 +70,7 @@ attach_softmax_impl::attach_softmax_impl() {
|
||||
format::bfzyx
|
||||
};
|
||||
|
||||
implementation_map<softmax>::add(impl_types::ocl, softmax_impl::create, types, formats);
|
||||
implementation_map<softmax>::add(impl_types::ocl, typed_primitive_impl_ocl<softmax>::create<softmax_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace ocl {
|
||||
struct space_to_batch_impl : typed_primitive_impl_ocl<space_to_batch> {
|
||||
using parent = typed_primitive_impl_ocl<space_to_batch>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::space_to_batch_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::space_to_batch_params, kernel_selector::space_to_batch_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -26,35 +28,23 @@ struct space_to_batch_impl : typed_primitive_impl_ocl<space_to_batch> {
|
||||
return make_unique<space_to_batch_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const space_to_batch_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto primitive = arg.get_primitive();
|
||||
auto space_to_batch_params = get_default_params<kernel_selector::space_to_batch_params>(impl_param);
|
||||
auto space_to_batch_optional_params =
|
||||
get_default_optional_params<kernel_selector::space_to_batch_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<space_to_batch>();
|
||||
auto params = get_default_params<kernel_selector::space_to_batch_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::space_to_batch_optional_params>(impl_param.get_program());
|
||||
|
||||
space_to_batch_params.block_shape = convert_dim_vector(primitive->block_shape);
|
||||
space_to_batch_params.pads_begin = convert_dim_vector(primitive->pads_begin);
|
||||
space_to_batch_params.pads_end = convert_dim_vector(primitive->pads_end);
|
||||
params.block_shape = convert_dim_vector(primitive->block_shape);
|
||||
params.pads_begin = convert_dim_vector(primitive->pads_begin);
|
||||
params.pads_end = convert_dim_vector(primitive->pads_end);
|
||||
|
||||
auto& kernel_selector = kernel_selector::space_to_batch_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(space_to_batch_params, space_to_batch_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto space_to_batch = new space_to_batch_impl(arg, best_kernels[0]);
|
||||
|
||||
return space_to_batch;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_space_to_batch_impl::attach_space_to_batch_impl() {
|
||||
implementation_map<space_to_batch>::add(impl_types::ocl, space_to_batch_impl::create, {
|
||||
implementation_map<space_to_batch>::add(impl_types::ocl, typed_primitive_impl_ocl<space_to_batch>::create<space_to_batch_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfyx),
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::u8, format::bfyx),
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace ocl {
|
||||
struct space_to_depth_impl : typed_primitive_impl_ocl<space_to_depth> {
|
||||
using parent = typed_primitive_impl_ocl<space_to_depth>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::space_to_depth_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::space_to_depth_params, kernel_selector::space_to_depth_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -24,37 +26,25 @@ struct space_to_depth_impl : typed_primitive_impl_ocl<space_to_depth> {
|
||||
return make_unique<space_to_depth_impl>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const space_to_depth_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = arg.get_primitive();
|
||||
auto space_to_depth_params = get_default_params<kernel_selector::space_to_depth_params>(impl_param);
|
||||
auto space_to_depth_optional_params =
|
||||
get_default_optional_params<kernel_selector::space_to_depth_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<space_to_depth>();
|
||||
auto params = get_default_params<kernel_selector::space_to_depth_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::space_to_depth_optional_params>(impl_param.get_program());
|
||||
|
||||
space_to_depth_params.depth_mode = (prim->mode == space_to_depth::blocks_first) ?
|
||||
kernel_selector::SpaceToDepthMode::BLOCKS_FIRST :
|
||||
kernel_selector::SpaceToDepthMode::DEPTH_FIRST;
|
||||
params.depth_mode = (primitive->mode == space_to_depth::blocks_first) ?
|
||||
kernel_selector::SpaceToDepthMode::BLOCKS_FIRST :
|
||||
kernel_selector::SpaceToDepthMode::DEPTH_FIRST;
|
||||
|
||||
space_to_depth_params.block_size = prim->block_size;
|
||||
params.block_size = primitive->block_size;
|
||||
|
||||
auto& kernel_selector = kernel_selector::space_to_depth_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(space_to_depth_params, space_to_depth_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto space_to_depth = new space_to_depth_impl(arg, best_kernels[0]);
|
||||
|
||||
return space_to_depth;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
attach_space_to_depth_impl::attach_space_to_depth_impl() {
|
||||
implementation_map<space_to_depth>::add(impl_types::ocl, space_to_depth_impl::create, {
|
||||
implementation_map<space_to_depth>::add(impl_types::ocl, typed_primitive_impl_ocl<space_to_depth>::create<space_to_depth_impl>, {
|
||||
std::make_tuple(data_types::f32, format::bfzyx),
|
||||
std::make_tuple(data_types::f16, format::bfzyx),
|
||||
std::make_tuple(data_types::u8, format::bfzyx),
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace ocl {
|
||||
struct strided_slice_impl : typed_primitive_impl_ocl<strided_slice> {
|
||||
using parent = typed_primitive_impl_ocl<strided_slice>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::strided_slice_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::strided_slice_params, kernel_selector::strided_slice_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -56,10 +58,10 @@ struct strided_slice_impl : typed_primitive_impl_ocl<strided_slice> {
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const strided_slice_node& arg, const kernel_impl_params& impl_param) {
|
||||
static std::unique_ptr<primitive_impl> create(const strided_slice_node& arg, const kernel_impl_params& impl_param) {
|
||||
const auto& prim = impl_param.typed_desc<strided_slice>();
|
||||
auto params = get_default_params<kernel_selector::strided_slice_params>(impl_param);
|
||||
auto op_params = get_default_optional_params<kernel_selector::strided_slice_optional_params>(arg.get_program());
|
||||
auto op_params = get_default_optional_params<kernel_selector::strided_slice_optional_params>(impl_param.get_program());
|
||||
const size_t dims_num = params.inputs[0].Dimentions();
|
||||
|
||||
// Getting data from constant inputs. There are 3 args: Begin, End, Stride
|
||||
@@ -133,16 +135,9 @@ public:
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::strided_slice_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(params, op_params);
|
||||
auto best_kernel = kernel_selector.get_best_kernel(params, op_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto strided_slice = new strided_slice_impl(arg, best_kernels[0]);
|
||||
|
||||
return strided_slice;
|
||||
return make_unique<strided_slice_impl>(arg, best_kernel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ocl {
|
||||
struct tile_impl : typed_primitive_impl_ocl<tile> {
|
||||
using parent = typed_primitive_impl_ocl<tile>;
|
||||
using parent::parent;
|
||||
using kernel_selector_t = kernel_selector::tile_kernel_selector;
|
||||
using kernel_params_t = std::pair<kernel_selector::tile_params, kernel_selector::tile_optional_params>;
|
||||
|
||||
DECLARE_OBJECT_TYPE_SERIALIZATION
|
||||
|
||||
@@ -26,12 +28,12 @@ struct tile_impl : typed_primitive_impl_ocl<tile> {
|
||||
}
|
||||
|
||||
public:
|
||||
static primitive_impl* create(const tile_node& arg, const kernel_impl_params& impl_param) {
|
||||
auto tile_params = get_default_params<kernel_selector::tile_params>(impl_param);
|
||||
auto tile_optional_params =
|
||||
get_default_optional_params<kernel_selector::tile_optional_params>(arg.get_program());
|
||||
static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) {
|
||||
const auto& primitive = impl_param.typed_desc<tile>();
|
||||
auto params = get_default_params<kernel_selector::tile_params>(impl_param);
|
||||
auto optional_params = get_default_optional_params<kernel_selector::tile_optional_params>(impl_param.get_program());
|
||||
|
||||
auto repeats = impl_param.typed_desc<tile>()->repeats;
|
||||
auto repeats = primitive->repeats;
|
||||
auto in_layout = impl_param.get_input_layout(0);
|
||||
auto in_shape = in_layout.get_partial_shape();
|
||||
|
||||
@@ -39,20 +41,10 @@ public:
|
||||
if (in_shape.size() < repeats.size()) {
|
||||
in_shape.insert(in_shape.begin(), repeats.size() - in_shape.size(), 1);
|
||||
in_layout.set_partial_shape(in_shape);
|
||||
tile_params.inputs[0] = convert_data_tensor(in_layout);
|
||||
params.inputs[0] = convert_data_tensor(in_layout);
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::tile_kernel_selector::Instance();
|
||||
auto best_kernels = kernel_selector.GetBestKernels(tile_params, tile_optional_params);
|
||||
|
||||
CLDNN_ERROR_BOOL(arg.id(),
|
||||
"Best_kernel.empty()",
|
||||
best_kernels.empty(),
|
||||
"Cannot find a proper kernel with this arguments");
|
||||
|
||||
auto tile = new tile_impl(arg, best_kernels[0]);
|
||||
|
||||
return tile;
|
||||
return {params, optional_params};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -77,7 +69,7 @@ attach_tile_impl::attach_tile_impl() {
|
||||
format::bs_fs_zyx_bsv32_fsv16
|
||||
};
|
||||
|
||||
implementation_map<tile>::add(impl_types::ocl, tile_impl::create, types, formats);
|
||||
implementation_map<tile>::add(impl_types::ocl, typed_primitive_impl_ocl<tile>::create<tile_impl>, types, formats);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -104,17 +104,17 @@ public:
|
||||
_prim = dnnl::concat(_pd, prim_cache);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const concatenation_node& arg, const kernel_impl_params& impl_params) {
|
||||
static std::unique_ptr<primitive_impl> create(const concatenation_node& arg, const kernel_impl_params& impl_params) {
|
||||
auto& engine = impl_params.prog->get_engine();
|
||||
if (arg.can_be_optimized())
|
||||
return new concatenation_onednn(engine);
|
||||
return make_unique<concatenation_onednn>(engine);
|
||||
auto prim = impl_params.typed_desc<concatenation>();
|
||||
auto desc = get_concatenation_descriptor(impl_params, prim->axis, impl_params.prog->get_engine());
|
||||
auto attr = arg.get_onednn_primitive_attributes();
|
||||
|
||||
std::shared_ptr<void> dummy = nullptr;
|
||||
|
||||
return new concatenation_onednn(engine, dummy, attr, *desc);
|
||||
return cldnn::make_unique<concatenation_onednn>(engine, dummy, attr, *desc);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -208,13 +208,13 @@ public:
|
||||
_prim = dnnl::primitive(_pd, prim_cache);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const convolution_node& arg, const kernel_impl_params& impl_params) {
|
||||
static std::unique_ptr<primitive_impl> create(const convolution_node& arg, const kernel_impl_params& impl_params) {
|
||||
auto& engine = impl_params.prog->get_engine();
|
||||
auto desc = get_convolution_descriptor(impl_params);
|
||||
auto attr = get_primitive_attributes(arg);
|
||||
dnnl::primitive_desc prim_desc{&desc->data, attr.get(), engine.get_onednn_engine(), nullptr};
|
||||
|
||||
return new convolution_onednn(engine, desc, attr, prim_desc, get_weights_reorder(impl_params, prim_desc, arg.get_transposed()));
|
||||
return cldnn::make_unique<convolution_onednn>(engine, desc, attr, prim_desc, get_weights_reorder(impl_params, prim_desc, arg.get_transposed()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -127,13 +127,13 @@ public:
|
||||
_prim = dnnl::primitive(_pd, prim_cache);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const deconvolution_node& arg, const kernel_impl_params& impl_params) {
|
||||
static std::unique_ptr<primitive_impl> create(const deconvolution_node& arg, const kernel_impl_params& impl_params) {
|
||||
auto& engine = impl_params.prog->get_engine();
|
||||
auto desc = get_deconvolution_descriptor(impl_params);
|
||||
auto attr = get_primitive_attributes(arg);
|
||||
dnnl::primitive_desc prim_desc{&desc->data, attr.get(), engine.get_onednn_engine(), nullptr};
|
||||
|
||||
return new deconvolution_onednn(engine, desc, attr, prim_desc, get_weights_reorder(impl_params, prim_desc));
|
||||
return cldnn::make_unique<deconvolution_onednn>(engine, desc, attr, prim_desc, get_weights_reorder(impl_params, prim_desc));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -189,13 +189,13 @@ public:
|
||||
_prim = dnnl::primitive(_pd, prim_cache);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const fully_connected_node& arg, const kernel_impl_params& impl_params) {
|
||||
static std::unique_ptr<primitive_impl> create(const fully_connected_node& arg, const kernel_impl_params& impl_params) {
|
||||
auto& engine = impl_params.prog->get_engine();
|
||||
auto desc = get_fully_connected_descriptor(impl_params);
|
||||
auto attr = arg.get_onednn_primitive_attributes();
|
||||
dnnl::primitive_desc prim_desc{&desc->data, attr.get(), engine.get_onednn_engine(), nullptr};
|
||||
|
||||
return new fully_connected_onednn(engine, desc, attr, prim_desc, get_weights_reorder(impl_params, prim_desc));
|
||||
return cldnn::make_unique<fully_connected_onednn>(engine, desc, attr, prim_desc, get_weights_reorder(impl_params, prim_desc));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -232,13 +232,13 @@ public:
|
||||
_prim = dnnl::primitive(_pd, prim_cache);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const gemm_node& arg, const kernel_impl_params& impl_params) {
|
||||
static std::unique_ptr<primitive_impl> create(const gemm_node& arg, const kernel_impl_params& impl_params) {
|
||||
auto& engine = impl_params.prog->get_engine();
|
||||
auto desc = get_gemm_descriptor(impl_params);
|
||||
auto attr = arg.get_onednn_primitive_attributes();
|
||||
dnnl::primitive_desc prim_desc{&desc->data, attr.get(), engine.get_onednn_engine(), nullptr};
|
||||
|
||||
return new gemm_onednn(engine, desc, attr, prim_desc);
|
||||
return cldnn::make_unique<gemm_onednn>(engine, desc, attr, prim_desc);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -87,13 +87,13 @@ public:
|
||||
_prim = dnnl::primitive(_pd, prim_cache);
|
||||
}
|
||||
|
||||
static primitive_impl* create(const pooling_node& arg, const kernel_impl_params& impl_params) {
|
||||
static std::unique_ptr<primitive_impl> create(const pooling_node& arg, const kernel_impl_params& impl_params) {
|
||||
auto& engine = impl_params.prog->get_engine();
|
||||
auto desc = get_pooling_descriptor(impl_params);
|
||||
auto attr = arg.get_onednn_primitive_attributes();
|
||||
dnnl::primitive_desc prim_desc{&desc->data, attr.get(), engine.get_onednn_engine(), nullptr};
|
||||
|
||||
return new pooling_onednn(engine, desc, attr, prim_desc);
|
||||
return cldnn::make_unique<pooling_onednn>(engine, desc, attr, prim_desc);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loaded 100 of 113 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user