Skip to content

Commit

Permalink
[Versioning] python 3.8 compatibility fix
Browse files Browse the repository at this point in the history
ghstack-source-id: ba7e9325c4125892522ee63253c148ed34adac7c
Pull Request resolved: #1127
  • Loading branch information
vmoens committed Dec 4, 2024
1 parent 4949efa commit d7529ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tensordict/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from collections.abc import KeysView
from contextlib import nullcontext
from copy import copy
from dataclasses import _FIELDS, GenericAlias
from functools import wraps
from importlib import import_module
from numbers import Number
Expand Down Expand Up @@ -75,6 +74,18 @@
if TYPE_CHECKING:
from tensordict.tensordict import TensorDictBase

try:
from dataclasses import _FIELDS, GenericAlias
except ImportError:
# python < 3.9
from dataclasses import _FIELDS

class GenericAlias:
"""Placeholder."""

...


try:
try:
from torch._C._functorch import ( # @manual=fbcode//caffe2:torch
Expand Down
8 changes: 8 additions & 0 deletions test/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import argparse

import pytest


def test_imports():
from tensordict import TensorDict # noqa: F401
from tensordict.nn import TensorDictModule # noqa: F401


if __name__ == "__main__":
args, unknown = argparse.ArgumentParser().parse_known_args()
pytest.main([__file__, "--capture", "no", "--exitfirst"] + unknown)

1 comment on commit d7529ab

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'CPU Benchmark Results'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: d7529ab Previous: 4949efa Ratio
benchmarks/common/common_ops_test.py::test_membership_stacked_nested_last 76228.74186915864 iter/sec (stddev: 0.0000010751476528878366) 228124.4633398589 iter/sec (stddev: 3.8364644730810283e-7) 2.99
benchmarks/common/common_ops_test.py::test_membership_stacked_nested_leaf_last 77415.87604345194 iter/sec (stddev: 7.591631172255536e-7) 233952.65195419357 iter/sec (stddev: 3.7395055968007894e-7) 3.02

This comment was automatically generated by workflow using github-action-benchmark.

CC: @vmoens

Please sign in to comment.