Skip to content

[spec][ref][cpu][gpu]: Added OneHot v16#31901

Merged
pkowalc1 merged 48 commits intoopenvinotoolkit:masterfrom
pkowalc1:fix_one_hot_negative_indicies_with_new_op_ver
Sep 16, 2025
Merged

[spec][ref][cpu][gpu]: Added OneHot v16#31901
pkowalc1 merged 48 commits intoopenvinotoolkit:masterfrom
pkowalc1:fix_one_hot_negative_indicies_with_new_op_ver

Conversation

@pkowalc1
Copy link
Copy Markdown
Contributor

@pkowalc1 pkowalc1 commented Aug 28, 2025

Added OneHot v16 operator with with new attribute: negative_indices_mode, with two modes:

  • ignore_negative, which behaves exactly as the OneHot-1
  • normalize, which is aimed to support onnx.OneHot-11 op.

Added support of this new op to reference, CPU and GPU implementations, ONNX fronteds, etc. Added new tests/fixed existing.

Tickets:

@pkowalc1 pkowalc1 added the WIP work in progress label Aug 28, 2025
@pkowalc1 pkowalc1 requested review from a team as code owners August 28, 2025 13:54
@pkowalc1 pkowalc1 requested review from kblaszczak-intel and removed request for a team August 28, 2025 13:54
@github-actions github-actions bot added category: Core OpenVINO Core (aka ngraph) category: GPU OpenVINO GPU plugin labels Aug 28, 2025
@pkowalc1 pkowalc1 requested a review from a team as a code owner September 4, 2025 07:56
@pkowalc1 pkowalc1 requested review from CuriousPanCake and removed request for a team September 4, 2025 07:56
@github-actions github-actions bot added the category: transformations OpenVINO Runtime library - Transformations label Sep 4, 2025
@pkowalc1 pkowalc1 changed the title [WIP][spec][ref][cpu][gpu]: Added OneHot v16 [spec][ref][cpu][gpu]: Added OneHot v16 Sep 5, 2025
@pkowalc1 pkowalc1 removed the WIP work in progress label Sep 5, 2025
Copy link
Copy Markdown
Contributor

@mitruska mitruska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code for new operation LGTM. Approved conditionally if the ConvertOneHot16To1 transformation will be fixed and tested in a following PR (or removed from this one). The place and need of the downgrade transformation call should be consulted with NPU plugin, as GPU and CPU is updated.
cc: @openvinotoolkit/openvino-npu-maintainers

#include "openvino/op/one_hot.hpp"
#include "openvino/pass/pattern/op/wrap_type.hpp"

ov::pass::ConvertOneHot16To1::ConvertOneHot16To1() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ConvertOneHot16To1 transformation seems to be not tested and never called, (or registered in common transformations like):

REGISTER_PASS(manager, ConvertMaxPool14ToMaxPool8)
REGISTER_PASS(manager, ConvertMaxPool8ToMaxPool1)

But as GPU and CPU plugin is already updated it is likely needed for NPU only.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I have removed that transformation and I will add it in following pr.

Copy link
Copy Markdown
Contributor

@Lyamin-Roman Lyamin-Roman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPU part LGTM

Copy link
Copy Markdown
Contributor

@praasz praasz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for core part

Comment on lines +52 to +53
private:
friend void inline resolve_axis(OneHotBase* op);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general friends has been removed in ops (looks like missed for this op). It can be removed also as we got get_axis and it can be used in shape inference functions.

Comment on lines +10 to +12
namespace ov {
namespace op {
namespace util {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is new file

Suggested change
namespace ov {
namespace op {
namespace util {
namespace ov::op::util {

Comment on lines +10 to +12
namespace ov {
namespace op {
namespace util {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AS new file added:

Suggested change
namespace ov {
namespace op {
namespace util {
namespace ov::op::util {

Comment on lines +2955 to +2956
template <typename TOpFunc>
void OneHotConstantFoldingGenericTest(const TOpFunc& op_func) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <typename TOpFunc>
void OneHotConstantFoldingGenericTest(const TOpFunc& op_func) {
template <typename TOneHot>
void OneHotConstantFoldingGenericTest(const TOneHot& one_hot_op) {

?

Comment on lines +37 to +39
if (none_of(op->get_type_info(),
op::v1::OneHot::get_type_info_static(),
op::v16::OneHot::get_type_info_static())) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check if base class is one hot?

@praasz praasz added this to the 2025.4 milestone Sep 12, 2025
pkowalc1 and others added 5 commits September 15, 2025 10:02
…convert_one_hot_v16_to_v1.cpp

Co-authored-by: Katarzyna Mitrus <katarzyna.mitrus@intel.com>
Co-authored-by: Pawel Raasz <pawel.raasz@intel.com>
…convert_one_hot_v16_to_v1.cpp

Co-authored-by: Pawel Raasz <pawel.raasz@intel.com>
@github-actions github-actions bot removed the category: transformations OpenVINO Runtime library - Transformations label Sep 15, 2025
@pkowalc1 pkowalc1 added this pull request to the merge queue Sep 16, 2025
Merged via the queue into openvinotoolkit:master with commit c3ec20d Sep 16, 2025
221 of 223 checks passed
@pkowalc1 pkowalc1 deleted the fix_one_hot_negative_indicies_with_new_op_ver branch September 16, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: Core OpenVINO Core (aka ngraph) category: CPP API OpenVINO CPP API bindings category: CPU OpenVINO CPU plugin category: docs OpenVINO documentation category: GPU OpenVINO GPU plugin category: IE Tests OpenVINO Test: plugins and common category: ONNX FE OpenVINO ONNX FrontEnd category: TEMPLATE OpenVINO Template plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants