Skip to content

Commit

Permalink
Update (base update)
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
vmoens committed Nov 25, 2024
1 parent 037f5a3 commit 8756de7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 2 additions & 4 deletions tensordict/nn/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,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))
and tensor.dtype in (torch.float, torch.double, torch.half)
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
10 changes: 4 additions & 6 deletions tensordict/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@
except ImportError:
_has_funcdim = False
try:
from torch.compiler import assume_constant_result, is_dynamo_compiling
from torch.compiler import assume_constant_result
except ImportError: # torch 2.0
from torch._dynamo import (
assume_constant_result,
is_compiling as is_dynamo_compiling,
)
from torch._dynamo import assume_constant_result

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 8756de7

Please sign in to comment.