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

[Pytorch fronted]: Added support for Search Sorted op #26976

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
187f1c4
[Spec]: Added initial specification of Searchsorted op
pkowalc1 Oct 2, 2024
ccb2134
[op]: S[SearchSorted]: Added new op definition with tests.
pkowalc1 Oct 3, 2024
ef5d369
Merge branch 'master' into search_sorted_op_def
mlukasze Oct 4, 2024
c87ed2f
[unittest]:[SearchSorted]: Fix Windows warnings.
pkowalc1 Oct 4, 2024
5987b73
Update src/core/include/openvino/op/search_sorted.hpp
pkowalc1 Oct 7, 2024
ddee155
Update src/core/shape_inference/include/search_sorted_shape_inference…
pkowalc1 Oct 7, 2024
58cfcdd
Update src/core/shape_inference/include/search_sorted_shape_inference…
pkowalc1 Oct 7, 2024
7663026
Update src/core/include/openvino/op/search_sorted.hpp
pkowalc1 Oct 7, 2024
60984a6
[SortedSearch]: Fixed validation due to review and added more unittests.
pkowalc1 Oct 8, 2024
420b709
[attributes_test]: Added test for SearchSorted op.
pkowalc1 Oct 8, 2024
60eff69
[SearchSorted]: Fixed code style.
pkowalc1 Oct 8, 2024
a33b7f9
Removed search_sorted.rst in order to not block PR contiaining the de…
pkowalc1 Oct 8, 2024
cd3873d
Removed search_sorted.rst in order to not block PR contiaining the de…
pkowalc1 Oct 8, 2024
6b80399
Merge branch 'master' into search_sorted_op_def
pkowalc1 Oct 8, 2024
f7b82e0
[ref]: Added SearchSorted ref impl.
pkowalc1 Oct 8, 2024
cb6531a
[Spec]: Added initial specification of Searchsorted op
pkowalc1 Oct 2, 2024
80b6c25
[op]: S[SearchSorted]: Added new op definition with tests.
pkowalc1 Oct 3, 2024
cf87e7a
Revert "[NPUW] Add initial unpack and partitioning unit tests on NPUW…
ababushk Oct 2, 2024
4778d91
[coverity, core] Fix unchecked return value in bound evaluate (#26768)
praasz Oct 2, 2024
669d921
[OV JS] Add TS definition for AnyMap (#26711)
almilosz Oct 2, 2024
ae194d1
[NPU] Add documentation for batching on NPU plugin (#26865)
pereanub Oct 2, 2024
0b05df1
NPUW: Fix nullptr reference parameter in rearrange_to_proto (#26869)
AsyaPronina Oct 2, 2024
738a52b
single-image-test: added accuracy workaround for computing CPU refere…
beleiuandrei Oct 2, 2024
1939b8f
[GPU] Support large N FC optimization for dynamic quantization case (…
andrew-k-park Oct 3, 2024
07ad6db
[PT FE][GHA] Run PT FE layer tests on Ubuntu 24.04 with Python 3.12 a…
rkazants Oct 3, 2024
94aff1e
[GPU] Fix double jit constants (#26893)
p-durandin Oct 3, 2024
ea85a2f
NPUW: Bring back unpack and partitioning unit tests for NPUW (#26885)
AsyaPronina Oct 3, 2024
ad0b980
[TF FE]: Support complex tensors for ExpandDims operation (#26892)
hub-bla Oct 3, 2024
f6ba78f
[GPU] Extract debug code from network::execute() (#26888)
vladimir-paramuzov Oct 3, 2024
0ac600b
[GPU] Fix unit tests ph4 (#26879)
p-durandin Oct 3, 2024
ca60a93
[GPU] Adjust usm_host memory usage for InferRequest tensors (#26896)
sshlyapn Oct 3, 2024
d3fc978
[GPU] Fix empty oneDnn users (#26900)
p-durandin Oct 3, 2024
1d98baa
[unittest]:[SearchSorted]: Fix Windows warnings.
pkowalc1 Oct 4, 2024
be1c9b4
Update src/core/include/openvino/op/search_sorted.hpp
pkowalc1 Oct 7, 2024
6f9bec3
Update src/core/shape_inference/include/search_sorted_shape_inference…
pkowalc1 Oct 7, 2024
c041426
Update src/core/shape_inference/include/search_sorted_shape_inference…
pkowalc1 Oct 7, 2024
32e9285
Update src/core/include/openvino/op/search_sorted.hpp
pkowalc1 Oct 7, 2024
25aa185
[SortedSearch]: Fixed validation due to review and added more unittests.
pkowalc1 Oct 8, 2024
5990ba9
[attributes_test]: Added test for SearchSorted op.
pkowalc1 Oct 8, 2024
39cdc36
[SearchSorted]: Fixed code style.
pkowalc1 Oct 8, 2024
954f211
Removed search_sorted.rst in order to not block PR contiaining the de…
pkowalc1 Oct 8, 2024
580c4ab
Removed search_sorted.rst in order to not block PR contiaining the de…
pkowalc1 Oct 8, 2024
6bb89b2
[TF FE][Keras] Use latest Keras for TF FE validation and adopt tests …
rkazants Oct 7, 2024
1dd4c67
[core] Convert reference use intrinsic implementation for ChromeOS (…
praasz Oct 7, 2024
f3d747b
Fix ov RTTI (#26895)
itikhono Oct 7, 2024
70be606
[PT FE] Fix torchaudio dependency for MacOS x86 (#26913)
rkazants Oct 7, 2024
83ec200
Docs Add Category to Coveo search engine (#26932)
akopytko Oct 7, 2024
5aa918c
[DOCS] Fixing references to Node.js methods (#26933)
sgolebiewski-intel Oct 7, 2024
f3f6c3f
[GHA] Don't update latest available artifacts link when copy failed (…
akladiev Oct 7, 2024
08db8b6
[GPU] network code cleanup (#26908)
vladimir-paramuzov Oct 7, 2024
8843e65
[DOCS] technical adjustments for the build mstr (#26883)
kblaszczak-intel Oct 7, 2024
d3ac6e0
[NPUW] Better utilize threads on compilation (#26864)
smirnov-alexey Oct 7, 2024
4ae2598
Eliminate nop Convert at the beginning of the MOC pipeline (#26872)
itikhono Oct 7, 2024
f173059
[PT FE] Fix Bitwise translators with 3 inputs (#26930)
rkazants Oct 7, 2024
d6c3a8f
List decompositions for torch.export (#26878)
mvafin Oct 7, 2024
53d8c6d
[DOCS] release notes one more adjustment (#26876)
kblaszczak-intel Oct 8, 2024
7b9c698
[PT FE] Remove explicit optimum deps from validation (#26948)
rkazants Oct 8, 2024
b8f9ee5
Update h5py requirement from <3.12.0,>=3.1.0 to >=3.1.0,<3.13.0 in /s…
dependabot[bot] Oct 8, 2024
46ed119
[ref]: Added SearchSorted ref impl.
pkowalc1 Oct 8, 2024
17b6e6f
Merge branch 'search_sorted_ref_impl' of https://github.com/pkowalc1/…
pkowalc1 Oct 9, 2024
394e474
Merge branch 'master' into search_sorted_ref_impl
pkowalc1 Oct 9, 2024
ae6a83d
[SearchSorted]: Fixed codestyle.
pkowalc1 Oct 9, 2024
2ed58e1
[Pytorch fronted]: Added support for SearchSorted op.
pkowalc1 Oct 9, 2024
f138792
Fixed code style.
pkowalc1 Oct 9, 2024
ed5d4d8
[SearchSorted]: Fixed Windows error.
pkowalc1 Oct 9, 2024
c9bb4b1
Update src/plugins/template/tests/functional/op_reference/search_sort…
pkowalc1 Oct 10, 2024
f4b0601
[Pytorch fronted]: Added support for SearchSorted op.
pkowalc1 Oct 9, 2024
bc4c902
Merge branch 'add_search_sorted_op_to_pytroch_frontend' of https://gi…
pkowalc1 Oct 10, 2024
5c20b4c
[SearchSorted]: Added to opset15_tbl.hpp
pkowalc1 Oct 10, 2024
5a9d440
[tests]: Fixed opset test fail.
pkowalc1 Oct 10, 2024
106c5c3
[ConformanceTests]: Added test for SearchSorted.
pkowalc1 Oct 10, 2024
df1a322
[ConformanceTests]: Fixed compilation error.
pkowalc1 Oct 10, 2024
16a4032
[Pytorch fronted]: Added support for SearchSorted op.
pkowalc1 Oct 9, 2024
a36442a
Merge branch 'add_search_sorted_op_to_pytroch_frontend' of https://gi…
pkowalc1 Oct 11, 2024
2f10f4e
Merge branch 'master' into add_search_sorted_op_to_pytroch_frontend
pkowalc1 Oct 11, 2024
3782d0f
[pytroch]: Added support for types promotion for pytroch.
pkowalc1 Oct 11, 2024
dc92c5c
Merge branch 'add_search_sorted_op_to_pytroch_frontend' of https://gi…
pkowalc1 Oct 11, 2024
3b056b7
[pytroch]: SearchSorted: minor naming fix.
pkowalc1 Oct 11, 2024
4cee5bd
[pytorch]: SearchSorted: review fixes.
pkowalc1 Oct 17, 2024
9765fa3
[pytorch]: SearchSorted unittests: added malicios test cases for conv…
pkowalc1 Oct 17, 2024
9b782f3
Merge branch 'master' into add_search_sorted_op_to_pytroch_frontend
mmikolajcz Oct 18, 2024
6b9e286
TEMPORARY COMMIT TO TEST CI
pkowalc1 Oct 18, 2024
8b4824c
Merge branch 'add_search_sorted_op_to_pytroch_frontend' of https://gi…
pkowalc1 Oct 18, 2024
71ee38a
Revert "TEMPORARY COMMIT TO TEST CI"
pkowalc1 Oct 21, 2024
b179570
Merge branch 'master' into add_search_sorted_op_to_pytroch_frontend
mvafin Oct 21, 2024
d61f3dd
Merge branch 'master' into add_search_sorted_op_to_pytroch_frontend
pkowalc1 Oct 23, 2024
fbc8f32
[Pytorch frontend]: SearchSorted test: fixed fail on cpu plugin.
pkowalc1 Oct 24, 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
34 changes: 34 additions & 0 deletions src/frontends/pytorch/src/op/search_sorted.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2018-2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/op/search_sorted.hpp"

#include "openvino/frontend/pytorch/node_context.hpp"
#include "utils.hpp"

namespace ov {
namespace frontend {
namespace pytorch {
namespace op {

using namespace ov::op;

OutputVector translate_search_sorted(const NodeContext& context) {
num_inputs_check(context, 2, 5);
Output<Node> sorted;
Output<Node> values;
std::tie(sorted, values) = get_inputs_with_promoted_types(context, 0, 1);
const bool out_int32 = context.const_input<bool>(2);
PYTORCH_OP_CONVERSION_CHECK(out_int32 == false, "aten::searchsorted(out_int32=true) unsupported");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it not just the output type of the operation? Can it be supported by just inserting Convert to i32?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a part of aten::searchsorted API and it is(that flag) not supported at the moment as it is not needed.

const bool right_mode = context.const_input<bool>(3);
PYTORCH_OP_CONVERSION_CHECK(context.input_is_none(4), "aten::searchsorted(side) unsupported");
PYTORCH_OP_CONVERSION_CHECK(context.input_is_none(5), "aten::searchsorted(out) unsupported");
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Same can be said about out_i32 which is just a Convert to i32

Copy link
Contributor Author

@pkowalc1 pkowalc1 Oct 22, 2024

Choose a reason for hiding this comment

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

The task was to add minimal version that supports some roblox model - not a full scale op. out_i32 parameter and out parameter are not used in that model and as such are omitted. If needed - they can be always enabled later with proper testing etc.

The original deadline for enabling this minimal version is today(22 Oct 2024). This PR has been in review for 2 weeks now - if you don't see any issues for minimal version which is now in this PR, please pass it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm supporting this approach
Please create a list of leftovers/improvements we could pickup in a scope of next release. For this one let's focus on specific request to deliver it on time.

Copy link
Contributor

Choose a reason for hiding this comment

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

That is fine, just please ensure we have a ticket for improved support

Copy link
Contributor

Choose a reason for hiding this comment

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

PYTORCH_OP_CONVERSION_CHECK(context.input_is_none(6), "aten::searchsorted(sorter) unsupported");
auto op = context.mark_node(std::make_shared<ov::op::v15::SearchSorted>(sorted, values, right_mode));
return {op};
};
} // namespace op
} // namespace pytorch
} // namespace frontend
} // namespace ov
2 changes: 2 additions & 0 deletions src/frontends/pytorch/src/op_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ OP_CONVERTER(translate_reshape_fx);
OP_CONVERTER(translate_rsub_fx);
OP_CONVERTER(translate_scalar_tensor_fx);
OP_CONVERTER(translate_scaled_dot_product_attention_fx);
OP_CONVERTER(translate_search_sorted);
OP_CONVERTER(translate_select_scatter_fx);
OP_CONVERTER(translate_slice_fx);
OP_CONVERTER(translate_slice_scatter_fx);
Expand Down Expand Up @@ -617,6 +618,7 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_ts() {
{"aten::rsqrt", op::optional_out<op::translate_rsqrt, 1>},
{"aten::rsqrt_", op::inplace_op<op::translate_rsqrt>},
{"aten::rsub", op::translate_rsub},
{"aten::searchsorted", op::translate_search_sorted},
{"aten::ScalarImplicit", op::skip_node},
{"aten::scaled_dot_product_attention", op::translate_scaled_dot_product_attention},
{"aten::scatter", op::translate_scatter},
Expand Down
47 changes: 47 additions & 0 deletions tests/layer_tests/pytorch_tests/test_search_sorted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest

from pytorch_layer_test_class import PytorchLayerTest
import numpy as np


class TestSearchSorted(PytorchLayerTest):
def _prepare_input(self):
return (np.array(self.sorted).astype(self.sorted_type),np.array(self.values).astype(self.values_type))

def create_model(self, right_mode):
import torch

class aten_searchsorted(torch.nn.Module):
def __init__(self, right_mode):
super(aten_searchsorted, self).__init__()
self.right_mode = right_mode

def forward(self, sorted, values):
return torch.searchsorted(sorted, values, right=self.right_mode)

ref_net = None

return aten_searchsorted(right_mode), ref_net, "aten::searchsorted"

@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.parametrize(("sorted", "values"), [
([[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]], [[3, 6, 9], [3, 6, 9]]),
([1, 3, 5, 7, 9], [[3, 6, 9],[0, 5, 20]]),
([4091, 4092], [[4091, 4092]]), # fp16 cannot exactly represent 4091 number
([1.23, 2.99], [[1.355, 2.9991]])
])
@pytest.mark.parametrize("right_mode", [False, True])
@pytest.mark.parametrize("sorted_type", [np.float32, np.float16, np.int8])
@pytest.mark.parametrize("values_type", [np.float16, np.int32, np.int64])
def test_searchsorted(self, sorted, values, right_mode, sorted_type, values_type, ie_device, precision, ir_version):
self.sorted = sorted
self.values = values
self.sorted_type = sorted_type
self.values_type = values_type
if ie_device == "CPU" and sorted_type == np.float16 and sorted == [4091, 4092]:
pytest.skip(reason="CPU plugin on defult converts fp16 to fp32, if that happens the test will fail for those malicious values")
self._test(*self.create_model(right_mode), ie_device, precision, ir_version)
Loading