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

Early return in _recursive_build if obj is a Tensor #125639

Closed

Conversation

guilhermeleobas
Copy link
Collaborator

@guilhermeleobas guilhermeleobas commented May 6, 2024

[ghstack-poisoned]
Copy link

pytorch-bot bot commented May 6, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit bcc4944 with merge base f155ed6 (image):
💚 Looks good so far! There are no failures yet. 💚

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

guilhermeleobas added a commit that referenced this pull request May 6, 2024
Fix issue #125551

ghstack-source-id: e9c5b3ea6c5ac1f1a0f600b525cc616d5db494ae
Pull Request resolved: #125639
[ghstack-poisoned]
guilhermeleobas added a commit that referenced this pull request May 8, 2024
Fix issue #125551

ghstack-source-id: d97b6313d47645970b920f4d89587448f9627206
Pull Request resolved: #125639
@guilhermeleobas
Copy link
Collaborator Author

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Successfully rebased gh/guilhermeleobas/47/orig onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/125639)

pytorchmergebot pushed a commit that referenced this pull request May 8, 2024
Fix issue #125551

ghstack-source-id: b96192f2d7899b5ef87d28a517fe5c1ed374bfdb
Pull Request resolved: #125639
[ghstack-poisoned]
guilhermeleobas added a commit that referenced this pull request May 9, 2024
Fix issue #125551

ghstack-source-id: 36afabb145dcb395f42ab07b9b2fc8962b5b8ad7
Pull Request resolved: #125639
@guilhermeleobas guilhermeleobas changed the title Call "[()]" instead of "view(())" in _recursive_build Early return in _recursive_build if obj is a Tensor May 9, 2024
@guilhermeleobas guilhermeleobas marked this pull request as ready for review May 9, 2024 01:24
@ezyang
Copy link
Contributor

ezyang commented May 9, 2024

I'm pretty sure you have to clone this at minimum... look at the code above.

[ghstack-poisoned]
guilhermeleobas added a commit that referenced this pull request May 9, 2024
Fix issue #125551

ghstack-source-id: 604220601d859968bb71ea1dfaf9d2621509647e
Pull Request resolved: #125639
if isinstance(obj, Tensor) and obj.ndim <= 1:
return obj.detach().to(dtype=scalarType, device="cpu", copy=True).view(())
elif isinstance(obj, Tensor):
return obj.detach().to(dtype=scalarType, device="cpu", copy=True)
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 not sure you'll necessarily end up with the right shape without an appropriate view. Specifically:

>>> torch.tensor([torch.tensor(0)])
tensor([0])
>>> torch.tensor([torch.tensor([0])])
tensor([0])
>>> torch.tensor([torch.tensor([[0]])])
tensor([0])
>>> torch.tensor([torch.tensor([[[0]]])])
tensor([0])

[ghstack-poisoned]
guilhermeleobas added a commit that referenced this pull request May 16, 2024
Fix issue #125551

ghstack-source-id: 8c71e8298ab88284ec3d39ec426ec005aeab2180
Pull Request resolved: #125639
[ghstack-poisoned]
guilhermeleobas added a commit that referenced this pull request May 16, 2024
Fix issue #125551

ghstack-source-id: 2c57eb65418f6a8067cffe7469569bded902ec63
Pull Request resolved: #125639
@ezyang
Copy link
Contributor

ezyang commented May 17, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 17, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

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: dynamo open source topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants