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

[Feature] Replaced device_safe() with device #485

Merged
merged 6 commits into from
Sep 23, 2022

Conversation

ordinskiy
Copy link
Contributor

@ordinskiy ordinskiy commented Sep 23, 2022

device_safe() was removed from TensorDict classes. It was replaced with device, which no longer throws an exception when _device is None.

Description

  • device_safe() method was removed from all TensorDict classes.
  • TensorDict.device property no longer throws an exception and returns None if self._device is None.
  • SavedTensorDict implicitly copies device of the source dictionary, unless device is provided explicitly.

Motivation and Context

close #455

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

`device_safe()` was removed from `TensorDict` classes. It was replaced with `device`, which no longer throws an exception when `_device` is `None`.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 23, 2022
@ordinskiy
Copy link
Contributor Author

Failed CI reports next error:

AttributeError: module 'functorch._C' has no attribute 'is_batchedtensor'

There is no direct connection between changes in this pull request with this functionality. I don't see related open issues either. What is the the procedure in this case?

@vmoens
Copy link
Contributor

vmoens commented Sep 23, 2022

Failed CI reports next error:

AttributeError: module 'functorch._C' has no attribute 'is_batchedtensor'

There is no direct connection between changes in this pull request with this functionality. I don't see related open issues either. What is the the procedure in this case?

you can just merge main, this has just been fixed

# Conflicts:
#	torchrl/data/tensordict/tensordict.py
`device_safe()` was removed from `TensorDict` classes. It was replaced with `device`, which no longer throws an exception when `_device` is `None`.
Test no longer expects the error. It verifies that `device` of the dictionary is `None` when not set.
@vmoens vmoens added bc breaking backward compatibility breaking change quality code quality labels Sep 23, 2022
Copy link
Contributor

@vmoens vmoens left a comment

Choose a reason for hiding this comment

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

Wonderful! Thanks a million for this
Just a small comment in the call to the device property, having a docstring there would be a great plus

@vmoens vmoens merged commit b049144 into pytorch:main Sep 23, 2022
@ordinskiy ordinskiy deleted the remove_device_safe branch September 23, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bc breaking backward compatibility breaking change CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. quality code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Removing TensorDict.device_safe() in favour of TensorDict.device
3 participants