Skip to content

Commit

Permalink
amend
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoens committed Nov 23, 2023
1 parent 0edf148 commit c55e28a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion tensordict/_td.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ def to_module(self, module, return_swap: bool = True, swap_dest=None, memo=None)
# is passed with to_module) but for the device it could be a problem.
if swap_dest is None:
swap = TensorDict({}, batch_size=[])
swap.clear_device_()
else:
swap = swap_dest
memo[id(module)] = swap
Expand Down Expand Up @@ -324,6 +323,7 @@ def to_module(self, module, return_swap: bool = True, swap_dest=None, memo=None)
_swap[key] = local_out
if return_swap:
if isinstance(swap, TensorDict):
# this is very ad-hoc but faster than calling _set_str every time
swap._tensordict.update(_swap)
else:
swap.update(_swap)
Expand Down
1 change: 0 additions & 1 deletion tensordict/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3125,7 +3125,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
return self.lock_()
if last_op == self.__class__.to_module.__name__:
if is_tensor_collection(out):
# with out.unlock_():
return self.to_module(*args, **kwargs, swap_dest=out)
else:
raise RuntimeError(
Expand Down

0 comments on commit c55e28a

Please sign in to comment.