Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
vmoens committed Dec 3, 2024
1 parent 608f247 commit e9d59f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tensordict/nn/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import weakref
from concurrent.futures import Future, ThreadPoolExecutor
from contextlib import nullcontext
from copy import copy
from functools import wraps
from typing import Any, Callable, Dict, Iterator, List, OrderedDict, Sequence, Type
Expand Down Expand Up @@ -171,7 +172,11 @@ def new_func(_self, *args, **kwargs):
if _self.is_locked:
# if the root (TensorDictParams) is locked, we still want to raise an exception
raise RuntimeError(_LOCK_ERROR)
with _self._param_td.unlock_():
with (
_self._param_td.unlock_()
if _self._param_td.is_locked
else nullcontext()
):
meth = getattr(_self._param_td, name)
out = meth(*args, **kwargs)
_self._reset_params()
Expand Down

0 comments on commit e9d59f4

Please sign in to comment.