Skip to content

Commit eb9a37d

Browse files
authored
[Minor] Warning when loading memmap storage on uninitialized td (#961)
1 parent 040165c commit eb9a37d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

torchrl/data/replay_buffers/storages.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import abc
77
import os
8+
import warnings
89
from collections import OrderedDict
910
from copy import copy
1011
from typing import Any, Dict, Sequence, Union
@@ -333,6 +334,11 @@ def load_state_dict(self, state_dict):
333334
self._storage.load_state_dict(_storage)
334335
self._storage.memmap_()
335336
elif self._storage is None:
337+
warnings.warn(
338+
"Loading the storage on an uninitialized TensorDict."
339+
"It is preferable to load a storage onto a"
340+
"pre-allocated one whenever possible."
341+
)
336342
self._storage = TensorDict({}, []).load_state_dict(_storage)
337343
self._storage.memmap_()
338344
else:

0 commit comments

Comments
 (0)