Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPU]: Added ROIAlignRotated basic impl. #23844

Merged
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
4a5775b
[Op]: Added definition of ROIAlignedRotated.
pkowalc1 Mar 14, 2024
e0c13d1
[Op]:[ROIAlignRotated]: Fixed tests code style.
pkowalc1 Mar 14, 2024
e713a7b
[Op]:[ROIAlignRotated]: Fixerd codestyle.
pkowalc1 Mar 14, 2024
fb113e6
[Op][ROIAlignRotated]: Removed form opset14_tbl, to disable failing c…
pkowalc1 Mar 14, 2024
b09db55
Merge branch 'master' into roi_align_rotated_operator_def
pkowalc1 Mar 15, 2024
f5e31b9
Merge branch 'master' into roi_align_rotated_operator_def
pkowalc1 Mar 15, 2024
77a4223
[Op]:[ROIAlign]: Refactoring, introduced ROIAlignBase.
pkowalc1 Mar 15, 2024
5943fa8
Update src/core/shape_inference/include/roi_align_shape_utils.hpp
pkowalc1 Mar 15, 2024
eb7720d
Update src/core/shape_inference/include/roi_align_shape_inference.hpp
pkowalc1 Mar 15, 2024
ce5dcc6
Update src/core/tests/type_prop/roi_align.cpp
pkowalc1 Mar 15, 2024
014f931
Update src/core/src/op/roi_align_rotated.cpp
pkowalc1 Mar 15, 2024
d3a3c57
[Op][ROIAlignRotated]: Review comments.
pkowalc1 Mar 15, 2024
7b56861
[Op]:[ROIAlignRotated]: code sytle fixes.
pkowalc1 Mar 15, 2024
0756ecf
[Op]:{ROIAlign]: Fixed code style.
pkowalc1 Mar 15, 2024
9008667
[Op]:[ROIAlignRotated]: Fixed code style.
pkowalc1 Mar 15, 2024
ac066f7
[Op]:[ROIAlign]: Fixed code style.
pkowalc1 Mar 15, 2024
e0e78a3
[Op]:[ROIAlign]: Fixed type bug.
pkowalc1 Mar 15, 2024
190cc6b
[Op]:[ROIAlignBase]: Fixed naming convention.
pkowalc1 Mar 15, 2024
af1b95e
[Op][ROIAlignRotated]: Temporary removed new op from tests, since now…
pkowalc1 Mar 15, 2024
ee705be
Merge branch 'master' into roi_align_rotated_operator_def
pkowalc1 Mar 15, 2024
38206ee
[Op]:[ROIAlign]: Review fixes.
pkowalc1 Mar 15, 2024
5e369cc
Merge branch 'roi_align_rotated_operator_def' of https://github.com/p…
pkowalc1 Mar 15, 2024
074a209
[Op][ROIAlign]: Fixed code style.
pkowalc1 Mar 18, 2024
995c542
[Op]:[ROIAlign]: Fixed crash in template plugin tests
pkowalc1 Mar 18, 2024
2b4aec4
Merge branch 'master' into roi_align_rotated_operator_def
pkowalc1 Mar 18, 2024
c2a1228
Merge branch 'master' into roi_align_rotated_operator_def
pkowalc1 Mar 19, 2024
4b831c5
Merge branch 'master' into roi_align_rotated_operator_def
pkowalc1 Mar 19, 2024
4ecbfa7
[Op][ROIAlignRotated]: Changed size of second dim of roi input due to…
pkowalc1 Mar 20, 2024
242d91f
Merge branch 'roi_align_rotated_operator_def' of https://github.com/p…
pkowalc1 Mar 20, 2024
fbe71f8
Merge branch 'master' into roi_align_rotated_operator_def
pkowalc1 Mar 20, 2024
dc2600a
Merge branch 'master' into roi_align_rotated_operator_def
pkowalc1 Mar 20, 2024
456b71b
[Op][ROIAlignRotated]: Adding Implementation. WIP.
pkowalc1 Mar 21, 2024
bd0bb00
[Op][ROIAlignRotated]: WIP, fixed a bug and added more test cases
pkowalc1 Mar 22, 2024
1483b8d
[Op][ROIAlignRotated]: Added more tests and refactoring
pkowalc1 Mar 25, 2024
75186a3
[Op][ROIAlignRotated]: Tests refactoring, changed test cases names.
pkowalc1 Mar 25, 2024
8a19209
[Op][ROIAlign]: Refactoring of reference impl.
pkowalc1 Mar 25, 2024
ec02c6c
[Op][ROIAlign]: Fixed code style.
pkowalc1 Mar 25, 2024
7e78b9c
[frontend]: Added mmdepoy.ROIAlignRotated with test.
pkowalc1 Mar 27, 2024
3f067ae
[ROIAlignRotated]: Added ROIAlignRotated simple impl.
pkowalc1 Apr 3, 2024
6f30a18
Merge branch 'master' into roi_align_rotated_intel_cpu_plugin_impl
pkowalc1 Apr 29, 2024
3f44778
[onnx_test]: Added missing space.
pkowalc1 Apr 30, 2024
7c07606
Merge branch 'master' into roi_align_rotated_intel_cpu_plugin_impl
pkowalc1 May 8, 2024
047237b
[frontend][roi_align_rotated]: Fixed code afer bad reslution of merge…
pkowalc1 May 8, 2024
7d88f29
[frontend]: Fixing code after bad resolution of merge conflict.
pkowalc1 May 8, 2024
5e8aa9a
[cpu_plugin][cmake]: Added comment.
pkowalc1 May 9, 2024
7fa0b88
[test]: Fixed opset tets.
pkowalc1 May 9, 2024
cfd0104
[conformance_test]: Added generate function for ROIAlignRotated.
pkowalc1 May 9, 2024
0f1d0bc
Merge branch 'master' into roi_align_rotated_intel_cpu_plugin_impl
pkowalc1 May 9, 2024
848af5a
[cpu_plugin][ROIAlignRotated]: Fxies due to review.
pkowalc1 May 9, 2024
947862c
Merge branch 'master' into roi_align_rotated_intel_cpu_plugin_impl
pkowalc1 May 10, 2024
a7de6e2
[cpu_plugin]: Added support for ROIAlignRotated by adding evaluate me…
pkowalc1 May 13, 2024
44d34fa
Merge branch 'roi_align_rotated_intel_cpu_plugin_impl' of https://git…
pkowalc1 May 13, 2024
fe8159b
[cpu_plugin]: CMakelists.txt: Removed not needed new line.
pkowalc1 May 13, 2024
aca6338
Merge branch 'master' into roi_align_rotated_intel_cpu_plugin_impl
pkowalc1 May 14, 2024
42a534b
Review fix: src/core/src/op/roi_align_rotated.cpp
pkowalc1 May 14, 2024
f6dd302
Review fix: Update src/core/src/op/roi_align_rotated.cpp
pkowalc1 May 14, 2024
5624e0a
Merge branch 'master' into roi_align_rotated_intel_cpu_plugin_impl
pkowalc1 May 14, 2024
328dabf
[opset]: Fixed error after merge conflict resolution.
pkowalc1 May 14, 2024
6ad51f3
Merge branch 'roi_align_rotated_intel_cpu_plugin_impl' of https://git…
pkowalc1 May 14, 2024
33960ed
Revert "[cpu_plugin]: Added support for ROIAlignRotated by adding eva…
pkowalc1 May 14, 2024
a9a6316
Merge branch 'master' into roi_align_rotated_intel_cpu_plugin_impl
pkowalc1 May 14, 2024
c68e148
Merge branch 'master' into roi_align_rotated_intel_cpu_plugin_impl
pkowalc1 May 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/core/include/openvino/op/roi_align_rotated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class OPENVINO_API ROIAlignRotated : public util::ROIAlignBase {
const float spatial_scale,
const bool clockwise_mode);

bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override;
bool has_evaluate() const override;
void validate_and_infer_types() override;
bool visit_attributes(AttributeVisitor& visitor) override;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
Expand Down
1 change: 1 addition & 0 deletions src/core/include/openvino/opsets/opset14_tbl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,4 @@ _OPENVINO_OP_REG(FakeConvert, ov::op::v13)
// New operations added in opset14
_OPENVINO_OP_REG(ConvertPromoteTypes, ov::op::v14)
_OPENVINO_OP_REG(Inverse, ov::op::v14)
_OPENVINO_OP_REG(ROIAlignRotated, ov::op::v14)
78 changes: 78 additions & 0 deletions src/core/src/op/roi_align_rotated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,52 @@

#include "openvino/op/roi_align_rotated.hpp"

#include "element_visitor.hpp"
#include "itt.hpp"
#include "openvino/reference/roi_align.hpp"
#include "utils.hpp"

namespace ov {
namespace op {
namespace v14 {

namespace helpers {
struct Evaluate : element::NoAction<bool> {
using element::NoAction<bool>::visit;

template <element::Type_t ET>
static result_type visit(const Tensor& input,
const Tensor& rois,
const Tensor& batch_indices,
Tensor& out,
int pooled_h,
int pooled_w,
int sampling_ratio,
float spatial_scale,
bool clockwise_mode) {
using T = fundamental_type_for<ET>;
const auto batch_indices_vec_scaled_up = ov::get_tensor_data_as<int64_t>(batch_indices);
pkowalc1 marked this conversation as resolved.
Show resolved Hide resolved
ov::reference::roi_align<T, ov::reference::roi_policy::ROIAlignRotatedOpDefPolicy>(
input.data<const T>(),
rois.data<const T>(),
batch_indices_vec_scaled_up.data(),
out.data<T>(),
input.get_shape(),
rois.get_shape(),
batch_indices.get_shape(),
out.get_shape(),
pkowalc1 marked this conversation as resolved.
Show resolved Hide resolved
pooled_h,
pooled_w,
sampling_ratio,
spatial_scale,
ov::op::v3::ROIAlign::PoolingMode::AVG,
ov::op::v9::ROIAlign::AlignedMode::ASYMMETRIC,
clockwise_mode);
return true;
}
};
} // namespace helpers

ROIAlignRotated::ROIAlignRotated(const Output<Node>& input,
const Output<Node>& rois,
const Output<Node>& batch_indices,
Expand Down Expand Up @@ -49,6 +90,43 @@ std::shared_ptr<Node> ROIAlignRotated::clone_with_new_inputs(const OutputVector&
get_spatial_scale(),
get_clockwise_mode());
}

bool ROIAlignRotated::evaluate(TensorVector& outputs, const TensorVector& inputs) const {
pkowalc1 marked this conversation as resolved.
Show resolved Hide resolved
OPENVINO_ASSERT(outputs.size() == 1);
OPENVINO_ASSERT(inputs.size() == 3);

using namespace ov::element;
return IF_TYPE_OF_CONVERT_TENSORS(v14_ROIAlignRotated_evaluate,
this,
outputs,
inputs,
OV_PP_ET_LIST(bf16, f16, f32, f64),
pkowalc1 marked this conversation as resolved.
Show resolved Hide resolved
helpers::Evaluate,
inputs[0].get_element_type(),
inputs[0],
inputs[1],
inputs[2],
outputs[0],
get_pooled_h(),
get_pooled_w(),
get_sampling_ratio(),
get_spatial_scale(),
get_clockwise_mode());
return true;
}

bool ROIAlignRotated::has_evaluate() const {
OV_OP_SCOPE(v14_ROIAlignRotated_has_evaluate);
switch (get_input_element_type(0)) {
case element::bf16:
case element::f16:
case element::f32:
case element::f64:
return true;
default:
return false;
}
}
} // namespace v14
} // namespace op
} // namespace ov
4 changes: 2 additions & 2 deletions src/core/tests/opset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ INSTANTIATE_TEST_SUITE_P(opset,
OpsetTestParams{ov::get_opset11, 177},
OpsetTestParams{ov::get_opset12, 178},
OpsetTestParams{ov::get_opset13, 186},
OpsetTestParams{ov::get_opset14, 188},
OpsetTestParams{ov::get_opset15, 5}),
OpsetTestParams{ov::get_opset14, 189},
OpsetTestParams{ov::get_opset15, 4}),
OpsetTestNameGenerator{});

class MyOpOld : public ov::op::Op {
Expand Down
5 changes: 3 additions & 2 deletions src/frontends/onnx/tests/onnx_import.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6617,8 +6617,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_mish_activation) {
}

OPENVINO_TEST(${BACKEND_NAME}, onnx_model_mmdeploy_roi_align_rotated) {
if (std::string("${BACKEND_NAME}") != std::string("INTERPRETER")) {
return; //< Skip this test for non-INTERPRETER backends, since op is not yet implemented on those backends.
if (!(std::string("${BACKEND_NAME}") == std::string("INTERPRETER") ||
std::string("${BACKEND_NAME}") == std::string("IE_CPU"))) {
return; //< Skip this test for not-yet-implemented on those backends.
}

auto model = convert_model("mmdeploy_roi_align_rotated.onnx");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,19 @@ std::shared_ptr<ov::Model> generate(const std::shared_ptr<ov::op::v9::ROIAlign>&
return std::make_shared<ov::Model>(results, params, "ROIAlignGraph");
}

std::shared_ptr<ov::Model> generate(const std::shared_ptr<ov::op::v14::ROIAlignRotated>& node) {
ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{{1, 1, 16, 16}})};
const auto coords = std::make_shared<ov::op::v0::Constant>(
ov::element::f32,
ov::Shape{1, static_cast<size_t>(node->get_rois_input_second_dim_size())},
std::vector<float>(node->get_rois_input_second_dim_size(), 0));
const auto roisIdx =
std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{1}, std::vector<int32_t>{0});
auto new_node = std::make_shared<ov::op::v14::ROIAlignRotated>(params.at(0), coords, roisIdx, 2, 2, 2, 1, true);
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(new_node)};
return std::make_shared<ov::Model>(results, params, "ROIAlignRotatedGraph");
}

std::shared_ptr<ov::Model> generate(const std::shared_ptr<ov::op::v0::ROIPooling> &node) {
ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{{1, 3, 8, 8}}),
std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{{1, 5}})};
Expand Down
Loading