Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into remove-shared-inherit…
Browse files Browse the repository at this point in the history
…ance
  • Loading branch information
vmoens committed Jan 17, 2024
2 parents 7e29bd5 + a9234fc commit 7639c79
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tensordict/_td.py
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,11 @@ def _populate(
self._is_memmap = True
self._is_shared = False # since they are mutually exclusive
self._device = torch.device("cpu")
else:
dest._is_memmap = True
dest._is_shared = False # since they are mutually exclusive
dest._device = torch.device("cpu")

dest._is_locked = True
return dest

Expand Down
1 change: 1 addition & 0 deletions test/test_tensorclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,7 @@ class MyClass:
assert isinstance(cmemmap.x, MemoryMappedTensor)
assert isinstance(cmemmap.y.x, MemoryMappedTensor)
assert cmemmap.z == "foo"
assert cmemmap.is_memmap()


class TestNesting:
Expand Down
2 changes: 2 additions & 0 deletions test/test_tensordict.py
Original file line number Diff line number Diff line change
Expand Up @@ -2857,6 +2857,7 @@ def test_memmap_like(self, td_name, device, use_dir, tmpdir, num_threads):
for key in td.keys(True):
assert td[key] is not tdmemmap[key]
assert (tdmemmap == 0).all()
assert tdmemmap.is_memmap()

def test_memmap_prefix(self, td_name, device, tmp_path):
if td_name == "memmap_td":
Expand Down Expand Up @@ -6167,6 +6168,7 @@ def test_memmap_like(self, tmpdir):
)
tdm = td.memmap_like(prefix=tmpdir)
assert tdm.names == ["a", "b", "c", "d"]
assert tdm.is_memmap()

def test_memmap_td(self):
td = self.memmap_td("cpu")
Expand Down

0 comments on commit 7639c79

Please sign in to comment.