Skip to content

Commit d4e27d5

Browse files
author
Vincent Moens
committed
[BugFix] Faster and safer non-tensor stack
ghstack-source-id: f6c61cd Pull Request resolved: #1232 (cherry picked from commit e23ce5c)
1 parent 554bf54 commit d4e27d5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tensordict/tensorclass.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3219,7 +3219,9 @@ def _stack_non_tensor(cls, list_of_non_tensor, dim=0, raise_if_non_unique=False)
32193219

32203220
ids = set()
32213221
firstdata = NO_DEFAULT
3222-
return_stack = False
3222+
return_stack = not capture_non_tensor_stack()
3223+
if return_stack:
3224+
return NonTensorStack(*list_of_non_tensor, stack_dim=dim)
32233225
for data in list_of_non_tensor:
32243226
if not isinstance(data, NonTensorData):
32253227
if raise_if_non_unique:

0 commit comments

Comments
 (0)