forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GPU] Implement ExperimentalDetectronGenerateProposalsSingleImage-6 (o…
…penvinotoolkit#11616) * Add single layer tests for GPU * Add GPU primitive for ExperimentalDetectronGenerateProposalsSingleImage * Add kernel for ExperimentalDetectronGenerateProposalsSingleImage * Add unit test * rename abbreviation edgpsi to the full name experimental_detectron_generate_proposal_single_image * Add f16 support to operation * Add f16 support to the unit test * Add notification about the second output in primitive Co-authored-by: Oleksii Khovan <[email protected]>
- Loading branch information
1 parent
8886d0f
commit 91ab69e
Showing
16 changed files
with
1,314 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...u/include/intel_gpu/primitives/experimental_detectron_generate_proposals_single_image.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (C) 2022 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
#pragma once | ||
#include "primitive.hpp" | ||
#include <vector> | ||
|
||
namespace cldnn { | ||
/// @addtogroup cpp_api C++ API | ||
/// @{ | ||
/// @addtogroup cpp_topology Network Topology | ||
/// @{ | ||
/// @addtogroup cpp_primitives Primitives | ||
/// @{ | ||
|
||
/// @brief experimental detectron generate proposals single image | ||
struct experimental_detectron_generate_proposals_single_image | ||
: public primitive_base<experimental_detectron_generate_proposals_single_image> { | ||
CLDNN_DECLARE_PRIMITIVE(experimental_detectron_generate_proposals_single_image) | ||
|
||
/// @brief Constructs experimental_detectron_generate_proposals_single_image primitive | ||
/// @param id This primitive id | ||
/// @param input_im_info image size info | ||
/// @param input_anchors anchors | ||
/// @param input_deltas deltas for anchors | ||
/// @param input_scores proposal scores | ||
/// @param output_roi_scores ROI scores | ||
/// @param min_size minimum box width and height | ||
/// @param nms_threshold threshold to be used in NonMaxSuppression stage | ||
/// @param pre_nms_count number of top-n proposals before NMS | ||
/// @param post_nms_count number of top-n proposals after NMS | ||
experimental_detectron_generate_proposals_single_image(const primitive_id& id, | ||
const primitive_id& input_im_info, | ||
const primitive_id& input_anchors, | ||
const primitive_id& input_deltas, | ||
const primitive_id& input_scores, | ||
const primitive_id& output_roi_scores, | ||
float min_size, | ||
float nms_threshold, | ||
int64_t pre_nms_count, | ||
int64_t post_nms_count, | ||
const primitive_id& ext_prim_id = "", | ||
const padding& output_padding = {}) : | ||
primitive_base{id, {input_im_info, input_anchors, input_deltas, input_scores, output_roi_scores}, ext_prim_id, output_padding}, | ||
output_roi_scores{output_roi_scores}, | ||
min_size{min_size}, | ||
nms_threshold{nms_threshold}, | ||
pre_nms_count{pre_nms_count}, | ||
post_nms_count{post_nms_count} {} | ||
|
||
primitive_id output_roi_scores; | ||
float min_size; | ||
float nms_threshold; | ||
int64_t pre_nms_count; | ||
int64_t post_nms_count; | ||
|
||
protected: | ||
std::vector<std::reference_wrapper<const primitive_id>> get_dependencies() const override { | ||
std::vector<std::reference_wrapper<const primitive_id>> ret; | ||
if (!output_roi_scores.empty()) | ||
ret.push_back(output_roi_scores); | ||
return ret; | ||
} | ||
}; | ||
/// @} | ||
/// @} | ||
/// @} | ||
} // namespace cldnn |
43 changes: 43 additions & 0 deletions
43
src/plugins/intel_gpu/src/graph/experimental_detectron_generate_proposal_single_image.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (C) 2022 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "experimental_detectron_generate_proposals_single_image_inst.hpp" | ||
#include "primitive_type_base.h" | ||
#include "intel_gpu/runtime/error_handler.hpp" | ||
#include "json_object.h" | ||
#include <string> | ||
|
||
namespace cldnn { | ||
primitive_type_id experimental_detectron_generate_proposals_single_image::type_id() { | ||
static primitive_type_base<experimental_detectron_generate_proposals_single_image> instance; | ||
return &instance; | ||
} | ||
|
||
layout experimental_detectron_generate_proposals_single_image_inst::calc_output_layout( | ||
const experimental_detectron_generate_proposals_single_image_node& node) { | ||
const layout data_layout = node.input().get_output_layout(); | ||
auto desc = node.get_primitive(); | ||
|
||
return layout(data_layout.data_type, format::bfyx, {static_cast<int>(desc->post_nms_count), 4, 1, 1}); | ||
} | ||
|
||
std::string experimental_detectron_generate_proposals_single_image_inst::to_string( | ||
const experimental_detectron_generate_proposals_single_image_node& node) { | ||
auto desc = node.get_primitive(); | ||
|
||
std::stringstream primitive_description; | ||
|
||
json_composite ed_info; | ||
ed_info.add("min_size", desc->min_size); | ||
ed_info.add("nms_threshold", desc->nms_threshold); | ||
ed_info.add("pre_nms_count", desc->pre_nms_count); | ||
ed_info.add("post_nms_count", desc->post_nms_count); | ||
|
||
auto node_info = node.desc_to_json(); | ||
node_info->add("experimental_detectron_generate_proposals_single_image_info", ed_info); | ||
node_info->dump(primitive_description); | ||
|
||
return primitive_description.str(); | ||
} | ||
} // namespace cldnn |
80 changes: 80 additions & 0 deletions
80
.../intel_gpu/src/graph/impls/ocl/experimental_detectron_generate_proposals_single_image.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright (C) 2022 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "experimental_detectron_generate_proposals_single_image_inst.hpp" | ||
#include "primitive_base.hpp" | ||
#include "impls/implementation_map.hpp" | ||
#include "kernel_selector_helper.h" | ||
#include "edgpsi/experimental_detectron_generate_proposals_single_image_kernel_selector.h" | ||
#include "edgpsi/experimental_detectron_generate_proposals_single_image_kernel_ref.h" | ||
|
||
|
||
namespace cldnn { | ||
namespace ocl { | ||
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; | ||
|
||
std::unique_ptr<primitive_impl> clone() const override { | ||
return make_unique<experimental_detectron_generate_proposals_single_image_impl>(*this); | ||
} | ||
|
||
protected: | ||
kernel_arguments_data get_arguments(typed_primitive_inst<experimental_detectron_generate_proposals_single_image>& instance, int32_t) const override { | ||
kernel_arguments_data args; | ||
const auto num_inputs = instance.inputs_memory_count(); | ||
for (size_t i = 0; i < num_inputs; ++i) { | ||
args.inputs.push_back(instance.input_memory_ptr(i)); | ||
} | ||
|
||
args.outputs.push_back(instance.output_memory_ptr()); | ||
//TODO: Future improvement: To add second output parameter only when it's needed | ||
args.inputs.push_back(instance.output_roi_scores_memory()); | ||
|
||
return args; | ||
} | ||
|
||
public: | ||
static primitive_impl* create(const experimental_detectron_generate_proposals_single_image_node& arg) { | ||
auto params = get_default_params<kernel_selector::experimental_detectron_generate_proposals_single_image_params>(arg); | ||
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(); | ||
|
||
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())); | ||
|
||
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]); | ||
} | ||
}; | ||
|
||
namespace detail { | ||
attach_experimental_detectron_generate_proposals_single_image_impl::attach_experimental_detectron_generate_proposals_single_image_impl() { | ||
implementation_map<experimental_detectron_generate_proposals_single_image>::add(impl_types::ocl, | ||
experimental_detectron_generate_proposals_single_image_impl::create, { | ||
std::make_tuple(data_types::f16, format::bfyx), | ||
std::make_tuple(data_types::f32, format::bfyx) | ||
}); | ||
} | ||
} // namespace detail | ||
} // namespace ocl | ||
} // namespace cldnn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...tel_gpu/src/graph/include/experimental_detectron_generate_proposals_single_image_inst.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (C) 2022 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
#pragma once | ||
#include "intel_gpu/primitives/experimental_detectron_generate_proposals_single_image.hpp" | ||
#include "primitive_inst.h" | ||
|
||
namespace cldnn { | ||
template <> | ||
struct typed_program_node<experimental_detectron_generate_proposals_single_image> | ||
: public typed_program_node_base<experimental_detectron_generate_proposals_single_image> { | ||
using parent = typed_program_node_base<experimental_detectron_generate_proposals_single_image>; | ||
|
||
public: | ||
using parent::parent; | ||
|
||
program_node& input() const { return get_dependency(0); } | ||
|
||
program_node& anchors() const { return get_dependency(1); } | ||
program_node& deltas() const { return get_dependency(2); } | ||
program_node& scores() const { return get_dependency(3); } | ||
|
||
program_node& output_roi_scores_node() const { return get_dependency(4); } | ||
}; | ||
|
||
using experimental_detectron_generate_proposals_single_image_node = typed_program_node<experimental_detectron_generate_proposals_single_image>; | ||
|
||
template <> | ||
class typed_primitive_inst<experimental_detectron_generate_proposals_single_image> | ||
: public typed_primitive_inst_base<experimental_detectron_generate_proposals_single_image> { | ||
using parent = typed_primitive_inst_base<experimental_detectron_generate_proposals_single_image>; | ||
|
||
public: | ||
static layout calc_output_layout(const experimental_detectron_generate_proposals_single_image_node& node); | ||
static std::string to_string(const experimental_detectron_generate_proposals_single_image_node& node); | ||
|
||
typed_primitive_inst(network& network, const experimental_detectron_generate_proposals_single_image_node& node) | ||
: parent(network, node) | ||
{} | ||
|
||
memory::ptr output_roi_scores_memory() const { return dep_memory_ptr(4); } | ||
}; | ||
|
||
using experimental_detectron_generate_proposals_single_image_inst = typed_primitive_inst<experimental_detectron_generate_proposals_single_image>; | ||
|
||
} // namespace cldnn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.