Skip to content

Commit 86bf038

Browse files
authored
[Ref][Core][Opset13] NMSRotated-13 core shell and reference implementation (openvinotoolkit#19907)
* nms_r_init * Add tests * Update nms refs * Update onnx import * Add nms rotated utils * Remove soft sigma and align constructors * Fix typo * Style apply * Add namespace for iou * Update opset comment * Revert cpu changes * onnx test cleanup * Update input types validation * Align shape_infer boxes * Test update * Fix warning * Temporary evaluate support for tests * Add counterclockwise support * Remove box_encoding attr * Fix clockwise box idx * More tests * Update opset test * Update boxes shape validation * Type prop tests * HostTensor to ov Tensor migration * Update output_type set get output_type_attr * Move setters and getters to cpp * Add visitor test * Cleanup * Remove temp eval * Headers adjustment * use float for division * Fix ref tests run * Tests and style code refactor * Move type check into box_last_dim * Update visitor test namespace * Check input type loop * Remove nms_rotated namespace and rename ref function * avoid copies in filling output tensor * Update shape var name * remove static from riou func * Update nms_rot utils * Move nms rot util to ov reference namespace * use std::cos and std:::sin * Update struct name * Explain usage of postprocessing * Update element type desc in error message * Add more comments * Adjust rotated util float types * Fix name conflicts and warnings * Update opset test ops number * Move int input check to the loop * Short box_def_size init * Move remove static_output from shape_infer params * Align float zero * Update third-party-programs * Fix TensorIt for CI * Add op check test
1 parent 77e043d commit 86bf038

File tree

20 files changed

+2075
-7
lines changed

20 files changed

+2075
-7
lines changed

licensing/third-party-programs.txt

+207
Original file line numberDiff line numberDiff line change
@@ -1666,3 +1666,210 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16661666
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16671667
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16681668
SOFTWARE.
1669+
1670+
-------------------------------------------------------------
1671+
1672+
31. Detectron2 (https://github.com/facebookresearch/detectron2)
1673+
1674+
Apache License
1675+
Version 2.0, January 2004
1676+
http://www.apache.org/licenses/
1677+
1678+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1679+
1680+
1. Definitions.
1681+
1682+
"License" shall mean the terms and conditions for use, reproduction,
1683+
and distribution as defined by Sections 1 through 9 of this document.
1684+
1685+
"Licensor" shall mean the copyright owner or entity authorized by
1686+
the copyright owner that is granting the License.
1687+
1688+
"Legal Entity" shall mean the union of the acting entity and all
1689+
other entities that control, are controlled by, or are under common
1690+
control with that entity. For the purposes of this definition,
1691+
"control" means (i) the power, direct or indirect, to cause the
1692+
direction or management of such entity, whether by contract or
1693+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
1694+
outstanding shares, or (iii) beneficial ownership of such entity.
1695+
1696+
"You" (or "Your") shall mean an individual or Legal Entity
1697+
exercising permissions granted by this License.
1698+
1699+
"Source" form shall mean the preferred form for making modifications,
1700+
including but not limited to software source code, documentation
1701+
source, and configuration files.
1702+
1703+
"Object" form shall mean any form resulting from mechanical
1704+
transformation or translation of a Source form, including but
1705+
not limited to compiled object code, generated documentation,
1706+
and conversions to other media types.
1707+
1708+
"Work" shall mean the work of authorship, whether in Source or
1709+
Object form, made available under the License, as indicated by a
1710+
copyright notice that is included in or attached to the work
1711+
(an example is provided in the Appendix below).
1712+
1713+
"Derivative Works" shall mean any work, whether in Source or Object
1714+
form, that is based on (or derived from) the Work and for which the
1715+
editorial revisions, annotations, elaborations, or other modifications
1716+
represent, as a whole, an original work of authorship. For the purposes
1717+
of this License, Derivative Works shall not include works that remain
1718+
separable from, or merely link (or bind by name) to the interfaces of,
1719+
the Work and Derivative Works thereof.
1720+
1721+
"Contribution" shall mean any work of authorship, including
1722+
the original version of the Work and any modifications or additions
1723+
to that Work or Derivative Works thereof, that is intentionally
1724+
submitted to Licensor for inclusion in the Work by the copyright owner
1725+
or by an individual or Legal Entity authorized to submit on behalf of
1726+
the copyright owner. For the purposes of this definition, "submitted"
1727+
means any form of electronic, verbal, or written communication sent
1728+
to the Licensor or its representatives, including but not limited to
1729+
communication on electronic mailing lists, source code control systems,
1730+
and issue tracking systems that are managed by, or on behalf of, the
1731+
Licensor for the purpose of discussing and improving the Work, but
1732+
excluding communication that is conspicuously marked or otherwise
1733+
designated in writing by the copyright owner as "Not a Contribution."
1734+
1735+
"Contributor" shall mean Licensor and any individual or Legal Entity
1736+
on behalf of whom a Contribution has been received by Licensor and
1737+
subsequently incorporated within the Work.
1738+
1739+
2. Grant of Copyright License. Subject to the terms and conditions of
1740+
this License, each Contributor hereby grants to You a perpetual,
1741+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1742+
copyright license to reproduce, prepare Derivative Works of,
1743+
publicly display, publicly perform, sublicense, and distribute the
1744+
Work and such Derivative Works in Source or Object form.
1745+
1746+
3. Grant of Patent License. Subject to the terms and conditions of
1747+
this License, each Contributor hereby grants to You a perpetual,
1748+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1749+
(except as stated in this section) patent license to make, have made,
1750+
use, offer to sell, sell, import, and otherwise transfer the Work,
1751+
where such license applies only to those patent claims licensable
1752+
by such Contributor that are necessarily infringed by their
1753+
Contribution(s) alone or by combination of their Contribution(s)
1754+
with the Work to which such Contribution(s) was submitted. If You
1755+
institute patent litigation against any entity (including a
1756+
cross-claim or counterclaim in a lawsuit) alleging that the Work
1757+
or a Contribution incorporated within the Work constitutes direct
1758+
or contributory patent infringement, then any patent licenses
1759+
granted to You under this License for that Work shall terminate
1760+
as of the date such litigation is filed.
1761+
1762+
4. Redistribution. You may reproduce and distribute copies of the
1763+
Work or Derivative Works thereof in any medium, with or without
1764+
modifications, and in Source or Object form, provided that You
1765+
meet the following conditions:
1766+
1767+
(a) You must give any other recipients of the Work or
1768+
Derivative Works a copy of this License; and
1769+
1770+
(b) You must cause any modified files to carry prominent notices
1771+
stating that You changed the files; and
1772+
1773+
(c) You must retain, in the Source form of any Derivative Works
1774+
that You distribute, all copyright, patent, trademark, and
1775+
attribution notices from the Source form of the Work,
1776+
excluding those notices that do not pertain to any part of
1777+
the Derivative Works; and
1778+
1779+
(d) If the Work includes a "NOTICE" text file as part of its
1780+
distribution, then any Derivative Works that You distribute must
1781+
include a readable copy of the attribution notices contained
1782+
within such NOTICE file, excluding those notices that do not
1783+
pertain to any part of the Derivative Works, in at least one
1784+
of the following places: within a NOTICE text file distributed
1785+
as part of the Derivative Works; within the Source form or
1786+
documentation, if provided along with the Derivative Works; or,
1787+
within a display generated by the Derivative Works, if and
1788+
wherever such third-party notices normally appear. The contents
1789+
of the NOTICE file are for informational purposes only and
1790+
do not modify the License. You may add Your own attribution
1791+
notices within Derivative Works that You distribute, alongside
1792+
or as an addendum to the NOTICE text from the Work, provided
1793+
that such additional attribution notices cannot be construed
1794+
as modifying the License.
1795+
1796+
You may add Your own copyright statement to Your modifications and
1797+
may provide additional or different license terms and conditions
1798+
for use, reproduction, or distribution of Your modifications, or
1799+
for any such Derivative Works as a whole, provided Your use,
1800+
reproduction, and distribution of the Work otherwise complies with
1801+
the conditions stated in this License.
1802+
1803+
5. Submission of Contributions. Unless You explicitly state otherwise,
1804+
any Contribution intentionally submitted for inclusion in the Work
1805+
by You to the Licensor shall be under the terms and conditions of
1806+
this License, without any additional terms or conditions.
1807+
Notwithstanding the above, nothing herein shall supersede or modify
1808+
the terms of any separate license agreement you may have executed
1809+
with Licensor regarding such Contributions.
1810+
1811+
6. Trademarks. This License does not grant permission to use the trade
1812+
names, trademarks, service marks, or product names of the Licensor,
1813+
except as required for reasonable and customary use in describing the
1814+
origin of the Work and reproducing the content of the NOTICE file.
1815+
1816+
7. Disclaimer of Warranty. Unless required by applicable law or
1817+
agreed to in writing, Licensor provides the Work (and each
1818+
Contributor provides its Contributions) on an "AS IS" BASIS,
1819+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1820+
implied, including, without limitation, any warranties or conditions
1821+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
1822+
PARTICULAR PURPOSE. You are solely responsible for determining the
1823+
appropriateness of using or redistributing the Work and assume any
1824+
risks associated with Your exercise of permissions under this License.
1825+
1826+
8. Limitation of Liability. In no event and under no legal theory,
1827+
whether in tort (including negligence), contract, or otherwise,
1828+
unless required by applicable law (such as deliberate and grossly
1829+
negligent acts) or agreed to in writing, shall any Contributor be
1830+
liable to You for damages, including any direct, indirect, special,
1831+
incidental, or consequential damages of any character arising as a
1832+
result of this License or out of the use or inability to use the
1833+
Work (including but not limited to damages for loss of goodwill,
1834+
work stoppage, computer failure or malfunction, or any and all
1835+
other commercial damages or losses), even if such Contributor
1836+
has been advised of the possibility of such damages.
1837+
1838+
9. Accepting Warranty or Additional Liability. While redistributing
1839+
the Work or Derivative Works thereof, You may choose to offer,
1840+
and charge a fee for, acceptance of support, warranty, indemnity,
1841+
or other liability obligations and/or rights consistent with this
1842+
License. However, in accepting such obligations, You may act only
1843+
on Your own behalf and on Your sole responsibility, not on behalf
1844+
of any other Contributor, and only if You agree to indemnify,
1845+
defend, and hold each Contributor harmless for any liability
1846+
incurred by, or claims asserted against, such Contributor by reason
1847+
of your accepting any such warranty or additional liability.
1848+
1849+
END OF TERMS AND CONDITIONS
1850+
1851+
APPENDIX: How to apply the Apache License to your work.
1852+
1853+
To apply the Apache License to your work, attach the following
1854+
boilerplate notice, with the fields enclosed by brackets "[]"
1855+
replaced with your own identifying information. (Don't include
1856+
the brackets!) The text should be enclosed in the appropriate
1857+
comment syntax for the file format. We also recommend that a
1858+
file or class name and description of purpose be included on the
1859+
same "printed page" as the copyright notice for easier
1860+
identification within third-party archives.
1861+
1862+
Copyright [yyyy] [name of copyright owner]
1863+
1864+
1865+
Licensed under the Apache License, Version 2.0 (the "License");
1866+
you may not use this file except in compliance with the License.
1867+
You may obtain a copy of the License at
1868+
1869+
http://www.apache.org/licenses/LICENSE-2.0
1870+
1871+
Unless required by applicable law or agreed to in writing, software
1872+
distributed under the License is distributed on an "AS IS" BASIS,
1873+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1874+
See the License for the specific language governing permissions and
1875+
limitations under the License.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (C) 2018-2023 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
5+
#pragma once
6+
7+
#include "openvino/op/op.hpp"
8+
9+
namespace ov {
10+
namespace op {
11+
12+
namespace v13 {
13+
/// \brief NMSRotated operation
14+
///
15+
class OPENVINO_API NMSRotated : public Op {
16+
public:
17+
OPENVINO_OP("NMSRotated", "opset13", op::Op);
18+
19+
NMSRotated() = default;
20+
21+
/// \brief Constructs a NMSRotated operation.
22+
///
23+
/// \param boxes Node containing the coordinates of the bounding boxes
24+
/// \param scores Node containing the scores of the bounding boxes
25+
/// \param max_output_boxes_per_class Node containing maximum number of boxes to be
26+
/// selected per class
27+
/// \param iou_threshold Node containing intersection over union threshold
28+
/// \param score_threshold Node containing minimum score threshold
29+
/// \param sort_result_descending Specifies whether it is necessary to sort selected
30+
/// boxes across batches
31+
/// \param output_type Specifies the output type of the first and third output
32+
/// \param clockwise Specifies the direction of the rotation
33+
NMSRotated(const Output<Node>& boxes,
34+
const Output<Node>& scores,
35+
const Output<Node>& max_output_boxes_per_class,
36+
const Output<Node>& iou_threshold,
37+
const Output<Node>& score_threshold,
38+
const bool sort_result_descending = true,
39+
const ov::element::Type& output_type = ov::element::i64,
40+
const bool clockwise = true);
41+
42+
bool visit_attributes(AttributeVisitor& visitor) override;
43+
void validate_and_infer_types() override;
44+
45+
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
46+
47+
bool get_sort_result_descending() const;
48+
void set_sort_result_descending(const bool sort_result_descending);
49+
50+
element::Type get_output_type_attr() const;
51+
void set_output_type_attr(const element::Type& output_type);
52+
53+
bool get_clockwise() const;
54+
void set_clockwise(const bool clockwise);
55+
56+
protected:
57+
bool m_sort_result_descending = true;
58+
ov::element::Type m_output_type = ov::element::i64;
59+
bool m_clockwise = true;
60+
};
61+
} // namespace v13
62+
} // namespace op
63+
64+
} // namespace ov

src/core/include/openvino/op/ops.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
#include "openvino/op/multiply.hpp"
111111
#include "openvino/op/mvn.hpp"
112112
#include "openvino/op/negative.hpp"
113+
#include "openvino/op/nms_rotated.hpp"
113114
#include "openvino/op/non_max_suppression.hpp"
114115
#include "openvino/op/non_zero.hpp"
115116
#include "openvino/op/normalize_l2.hpp"

src/core/include/openvino/opsets/opset13_tbl.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,4 @@ _OPENVINO_OP_REG(ScatterElementsUpdate, ov::op::v12)
210210

211211
// New operations added in opset13
212212
_OPENVINO_OP_REG(BitwiseNot, ov::op::v13)
213+
_OPENVINO_OP_REG(NMSRotated, ov::op::v13)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (C) 2018-2023 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
5+
#pragma once
6+
7+
#include "openvino/core/shape.hpp"
8+
#include "openvino/reference/non_max_suppression.hpp"
9+
10+
namespace ov {
11+
namespace reference {
12+
13+
void nms_rotated(const float* boxes_data,
14+
const Shape& boxes_data_shape,
15+
const float* scores_data,
16+
const Shape& scores_data_shape,
17+
int64_t max_output_boxes_per_class,
18+
float iou_threshold,
19+
float score_threshold,
20+
float soft_nms_sigma,
21+
int64_t* selected_indices,
22+
const Shape& selected_indices_shape,
23+
float* selected_scores,
24+
const Shape& selected_scores_shape,
25+
int64_t* valid_outputs,
26+
bool sort_result_descending,
27+
bool clockwise = true);
28+
29+
constexpr auto nms_rotated_postprocessing = ov::reference::nms_postprocessing;
30+
31+
} // namespace reference
32+
} // namespace ov

0 commit comments

Comments
 (0)