Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
vmoens committed Oct 17, 2024
1 parent cbfcd63 commit ad3c280
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions torchrl/objectives/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,18 @@ def __init__(self, network: nn.Module) -> None:

def __enter__(self) -> None:
if self.mode:
self.network.requires_grad_(False)
if is_dynamo_compiling():
self._params = TensorDict.from_module(self.network)
self._params.data.to_module(self.network)
else:
self.network.requires_grad_(False)

def __exit__(self, exc_type, exc_val, exc_tb) -> None:
if self.mode:
self.network.requires_grad_()
if is_dynamo_compiling():
self._params.to_module(self.network)
else:
self.network.requires_grad_()


class hold_out_params(_context_manager):
Expand Down

0 comments on commit ad3c280

Please sign in to comment.