Skip to content

Commit

Permalink
Fix assignment of str-typed value to device attribute
Browse files Browse the repository at this point in the history
The `device` property is defined via the method
```
@Property
def device(self) -> torch.device:
    return self._device
```
which indicates that the `_device` attribute should only have the `torch.device` datatype, whereas the current implementation allows assigning a `str` value via the `_init_shape(...)` method, which has a parameter `device` typed as `str | Device`.
  • Loading branch information
khwstolle authored and vmoens committed Nov 8, 2023
1 parent ec304fd commit 4f216a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tensordict/memmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def _init_shape(
dtype: torch.dtype,
transfer_ownership: bool,
):
self._device = device
self._device = torch.device(device)
self._shape = shape
self._shape_indexed = None
self.np_shape = tuple(self._shape)
Expand Down

0 comments on commit 4f216a3

Please sign in to comment.