Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
vmoens committed Nov 25, 2024
2 parents 24c1573 + 8756de7 commit bdf178c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 2 additions & 3 deletions tensordict/nn/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ def _maybe_make_param(tensor):


def _maybe_make_param_or_buffer(tensor):
if (
isinstance(tensor, (Tensor, ftdim.Tensor))
and not isinstance(tensor, (nn.Parameter, Buffer))
if isinstance(tensor, (Tensor, ftdim.Tensor)) and not isinstance(
tensor, (nn.Parameter, Buffer)
):
if not tensor.requires_grad and not is_batchedtensor(tensor):
# convert all non-parameters to buffers
Expand Down
8 changes: 3 additions & 5 deletions tensordict/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@
try:
from torch.compiler import assume_constant_result, is_compiling
except ImportError: # torch 2.0
from torch._dynamo import (
assume_constant_result,
is_compiling,
)
from torch._dynamo import assume_constant_result, is_compiling

if TYPE_CHECKING:
from tensordict.tensordict import TensorDictBase
Expand Down Expand Up @@ -2825,7 +2822,8 @@ def _is_dataclass(obj):
if isinstance(obj, type) and not isinstance(obj, GenericAlias)
else type(obj)
)
return hasattr(cls, _FIELDS)
# return hasattr(cls, _FIELDS)
return getattr(cls, _FIELDS, None) is not None


def _is_list_tensor_compatible(t) -> Tuple[bool, tuple | None, type | None]:
Expand Down

0 comments on commit bdf178c

Please sign in to comment.