-
Notifications
You must be signed in to change notification settings - Fork 19.6k
[OpenVINO Backend] update __getitem__ #21359
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
base: master
Are you sure you want to change the base?
[OpenVINO Backend] update __getitem__ #21359
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21359 +/- ##
==========================================
+ Coverage 82.70% 82.74% +0.04%
==========================================
Files 565 565
Lines 54894 54969 +75
Branches 8517 8534 +17
==========================================
+ Hits 45398 45484 +86
+ Misses 7415 7397 -18
- Partials 2081 2088 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
88938fd
to
5043d78
Compare
5043d78
to
91aa315
Compare
e7f4898
to
0ba9c10
Compare
d274a50
to
6ddb1b4
Compare
4a1d931
to
08aebcf
Compare
@Mohamed-Ashraf273, can you add your tests to sources as well? |
) | ||
if index_type != Type.i32: | ||
index = ov_opset.convert(index, Type.i32).output(0) | ||
shape_tensor = ov_opset.shape_of(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can specify output type to i32 then you don't need convert below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index = ov_opset.select( | ||
is_negative, adjusted_index, index | ||
).output(0) | ||
index_shape = index.get_partial_shape() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already computed above. Please clean-up your code properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I computed index_shape = index.get_partial_shape()
above to ensure it's less than or equal to 1
, else I would terminate early, the second computation, because the select
operation can change the shape of index
.
Based on this test case:
index_tensor = ops.convert_to_tensor(np.array(1, dtype=np.int32))
t = self.tensor[index_tensor]
n = self.np_tensor[ops.convert_to_numpy(index_tensor)]
self.assertEqual(t.shape, n.shape)
Fails due to the change of len(shape)
to 0
, and we need to unsqueeze
.
08aebcf
to
47c145c
Compare
@rkazants |
Hi @rkazants , |
Hi @rkazants ,
I've updated
__getitem__
usinggather_nd
as suggested, and I've avoided usingconvert_to_numpy
. Also, I've enabledvariables_test
.__getitem__
passed all tests aviable + I've tested it locally.Here are my test cases:
The PR is ready for review.