Repository navigation
[PyOV] Fix from_torchvision with a torch.Tensor input_example on NumPy 2 - #38938
Open
Somay-kousis wants to merge 2 commits into
Open
Somay-kousis wants to merge 2 commits into
Somay-kousis wants to merge 2 commits into
Conversation
Signed-off-by: Somay-kousis <somaykaush@gmail.com>
Signed-off-by: Somay-kousis <somaykaush@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details:
PreprocessConverter.from_torchvision(model, transform, input_example=torch.rand(1, 3, H, W))raisesValueError: Unable to avoid copy while creating an array as requested.on NumPy 2. The docstring liststorch.Tensoras a supportedinput_example.np.ndarrayandPIL.Imageexamples work, and nothing changes for them._get_shape_layout_from_datareads the shape withnp.array(input_example, copy=False). NumPy 2 changedcopy=Falsefrom "copy only if needed" to "never copy", andtorch.Tensor.__array__takes nocopyargument, so NumPy raises. The bindings allownumpy<2.6.0.np.asarray(input_example), which is the NumPy 1 meaning ofcopy=False(NumPy's error message suggests the same replacement). Only.shapeis used.test_torch_tensor_input_exampleintests/layer_tests/py_frontend_tests/test_torchvision_preprocessor.py: atorch.Tensorexample withNormalize, compared against the torch model. The existing tests only passPIL.Imageexamples.Tickets:
AI Assistance:
torchvision_preprocessing.py:test_torch_tensor_input_example: passes. With master's file it fails with theValueErrorabove.test_torchvision_preprocessor.py: 15 passed, 14 skipped (the existing ARM skips for Ticket 114816).np.ndarray,PIL.Imageandtorch.Tensorexamples: all three build the model.