-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[PT FE] Support aten::take operation #29479
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?
Conversation
Please fix code style and add tests for aten::str and aten::Delete. |
Sir @mvafin, I will fix the code style but I am having issues writing tests for str
I have added the aten::str in the op_table.cpp, along with the function name |
Did you build openvino? It seems you are testing the release version of openvino, not the one you built. |
I have recognized the issue |
@mvafin I have updated the implementation and test file for aten::take and aten::delete so my model looks like this for aten::delete
please check |
for aten::Str, I'd like to confirm it's intended function should it mimic python's inbuilt str() function? the general function is to convert tensors into string representation my current implementation does not work, as it gives errors
according to docs, raw string constants aren’t directly supported in the OpenVINO opset - instead I found StringTensorUnpack - which can make break the string into three parts to make it usable for further operations |
@mvafin Please let me know your thoughts when you have a moment. Thank you. |
@vijaykr338 Openvino support string tensors if created inside the model. However we cannot return or accept strings as model inputs/outputs. What model are you testing this on? I think it might be very hard or even impossible to make such a model that will be using aten::str inside. As for delete, you are clearly not using aten::Delete inside the model code. I suspect that this operation is |
given such constraints, I think it would be wise to drop these 2 operations and focus on refining aten::Take instead for aten::str, I thought about using an encoding-decoding pipeline to convert the string data to numerical data then back to it which is basically openVINO tokenizers, but that simply wont work. similarly for aten::delete, I had another plan of making a 'mask' tensor with true and false values to filter out false indice elements from target tensor, but that wouldnt work either considering the constraints I think it's better for me to refine just the aten::take function |
Co-authored-by: Maxim Vafin <[email protected]>
@mvafin there seems to be some CI/CD issues, I checked the logs but they don't seem to be related to my implementation |
This PR will be closed in a week because of 2 weeks of no activity. |
build_jenkins |
@mlukasze the tests have completed, could you take a look? |
build_jenkins |
@mlukasze apologies for mentioning again, I believe that this PR can be merged now since all checks have passed successfully. |
auto input_shape = input.get_partial_shape(); | ||
if (input_shape.rank().is_static() && input_shape.rank().get_length() == 0) { | ||
FRONT_END_OP_CONVERSION_CHECK(false, "input tensor MUST be non-scalar"); | ||
} |
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.
auto input_shape = input.get_partial_shape(); | |
if (input_shape.rank().is_static() && input_shape.rank().get_length() == 0) { | |
FRONT_END_OP_CONVERSION_CHECK(false, "input tensor MUST be non-scalar"); | |
} |
Looking on how torch.take functions, scalar tensors should be allowed, for example:
torch.take(torch.tensor(5), torch.tensor(0)) -> tensor(5)
torch.take(torch.tensor(5), torch.tensor([0])) -> tensor([5])
Is there any reason for such check? I've modified test suite a bit and it seem that scalars should work correctly.
@pytest.mark.precommit_torch_export | ||
@pytest.mark.parametrize("input_shape", [(10,), (3, 4), (2, 3, 4)]) | ||
@pytest.mark.parametrize("indices_shape", [(5,), (2, 2), (3, 2)]) | ||
def test_take(self, input_shape, indices_shape, ie_device, precision, ir_version): |
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.
Please add test case for scenario with out. This would require few changes for whole class, you can refer to similar op: https://github.com/openvinotoolkit/openvino/blob/master/tests/layer_tests/pytorch_tests/test_take_along_dim.py#L51
This PR will be closed in a week because of 2 weeks of no activity. |
Co-authored-by: Mateusz Mikolajczyk <[email protected]>
Co-authored-by: Mateusz Mikolajczyk <[email protected]>
Co-authored-by: Mateusz Mikolajczyk <[email protected]>
Co-authored-by: Mateusz Mikolajczyk <[email protected]>
This PR will be closed in a week because of 2 weeks of no activity. |
Details:
I was able to implement aten::take and aten::Delete function,
but aten::str posed really high difficult, i was only able to partially implement the it
currently, my implementation works for constant tensors, but for dynamic tensors, it currently stores shape and dtype for later use in debugging.
I have another question, how do you write tests for functions which are not implemented in Aten library yet?
I was able to write test cases for aten::take by following examples existing pytest files in the PyTorch layer tests folder.
but when I did the same for Delete and str, they consistently gave error
this is my first contribution to openVINO, I would greatly appreciate any guidance or assistance.
Tickets: