Skip to content

Commit ed055e3

Browse files
TroyGardenfacebook-github-bot
authored andcommitted
adding tensordict into targets to avoid package issue (#2593)
Summary: to avoid test failures like the following: https://www.internalfb.com/diff/D65103519?dst_version_fbid=450279051096758 {F1967377517} Differential Revision: D66465376
1 parent ef94338 commit ed055e3

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

torchrec/distributed/embedding.py

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@
9696
except OSError:
9797
pass
9898

99+
try:
100+
from tensordict import TensorDict
101+
except ImportError:
102+
103+
class TensorDict:
104+
pass
105+
106+
99107
logger: logging.Logger = logging.getLogger(__name__)
100108

101109

torchrec/distributed/embeddingbag.py

+7
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@
9999
except OSError:
100100
pass
101101

102+
try:
103+
from tensordict import TensorDict
104+
except ImportError:
105+
106+
class TensorDict:
107+
pass
108+
102109

103110
def _pin_and_move(tensor: torch.Tensor, device: torch.device) -> torch.Tensor:
104111
return (

torchrec/modules/embedding_modules.py

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
from torchrec.sparse.jagged_tensor import JaggedTensor, KeyedJaggedTensor, KeyedTensor
2222

2323

24+
try:
25+
from tensordict import TensorDict
26+
except ImportError:
27+
28+
class TensorDict:
29+
pass
30+
31+
2432
@torch.fx.wrap
2533
def reorder_inverse_indices(
2634
inverse_indices: Optional[Tuple[List[str], torch.Tensor]],

torchrec/sparse/jagged_tensor.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@
4949

5050
# OSS
5151
try:
52-
pass
52+
from tensordict import TensorDict
5353
except ImportError:
54-
pass
54+
55+
class TensorDict:
56+
pass
57+
5558

5659
logger: logging.Logger = logging.getLogger()
5760

0 commit comments

Comments
 (0)