Skip to content

[ONNX] Fix numpy method to return the correct type#136162

Closed
justinchuby wants to merge 6 commits intopytorch:mainfrom
justinchuby:justinchu/onnx-tensor-numpy
Closed

[ONNX] Fix numpy method to return the correct type#136162
justinchuby wants to merge 6 commits intopytorch:mainfrom
justinchuby:justinchu/onnx-tensor-numpy

Conversation

@justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Sep 16, 2024

Previous implementation of the numpy() method returns fp64 when the tensor is fp32. This is unexpected but seems to be caused by calling __array__(dtype=None) on the numpy array. I updated the implementation to implement the numpy() method explicitly and added tests to guard the behavior.

This needs to be cherry-picked into torch 2.5

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 16, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/136162

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit fa7bc39 with merge base 0aa41eb (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the release notes: onnx torch.onnx related changes that should show up in the release notes label Sep 16, 2024
@justinchuby justinchuby requested a review from xadupre September 16, 2024 19:29
@justinchuby justinchuby added module: onnx Related to torch.onnx topic: bug fixes topic category labels Sep 16, 2024
Copy link

@gramalingam gramalingam left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@justinchuby justinchuby added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 17, 2024
@justinchuby
Copy link
Collaborator Author

@pytorchbot merge -i

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: trunk / linux-focal-cuda12.4-py3.10-gcc9-experimental-split-build-test / test (default, 4, 5, linux.4xlarge.nvidia.gpu)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

justinchuby added a commit to justinchuby/pytorch that referenced this pull request Sep 17, 2024
Previous implementation of the `numpy()` method returns `fp64` when the tensor is `fp32`. This is unexpected but seems to be caused by calling `__array__(dtype=None)` on the numpy array. I updated the implementation to implement the `numpy()` method explicitly and added tests to guard the behavior.

This needs to be cherry-picked into torch 2.5
Pull Request resolved: pytorch#136162
Approved by: https://github.com/gramalingam, https://github.com/xadupre

(cherry picked from commit 67b14ce)
justinchuby added a commit to justinchuby/torch-onnx that referenced this pull request Sep 18, 2024
justinchuby added a commit to justinchuby/torch-onnx that referenced this pull request Sep 18, 2024
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
Previous implementation of the `numpy()` method returns `fp64` when the tensor is `fp32`. This is unexpected but seems to be caused by calling `__array__(dtype=None)` on the numpy array. I updated the implementation to implement the `numpy()` method explicitly and added tests to guard the behavior.

This needs to be cherry-picked into torch 2.5
Pull Request resolved: pytorch#136162
Approved by: https://github.com/gramalingam, https://github.com/xadupre
kit1980 pushed a commit that referenced this pull request Sep 20, 2024
[ONNX] Fix numpy method to return the correct type (#136162)

Previous implementation of the `numpy()` method returns `fp64` when the tensor is `fp32`. This is unexpected but seems to be caused by calling `__array__(dtype=None)` on the numpy array. I updated the implementation to implement the `numpy()` method explicitly and added tests to guard the behavior.

This needs to be cherry-picked into torch 2.5
Pull Request resolved: #136162
Approved by: https://github.com/gramalingam, https://github.com/xadupre

(cherry picked from commit 67b14ce)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged module: onnx Related to torch.onnx open source release notes: onnx torch.onnx related changes that should show up in the release notes topic: bug fixes topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants