Skip to content

Commit ab1faa0

Browse files
authored
Support Tensor as input for make_tuple (#84)
1 parent 313c9b0 commit ab1faa0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

torchsparse/utils/helpers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,10 @@ def make_tuple(inputs, dimension=3):
256256
elif isinstance(inputs, tuple):
257257
assert len(inputs) == dimension, 'Input length and dimension mismatch'
258258
return inputs
259+
elif isinstance(inputs, torch.Tensor):
260+
inputs = inputs.squeeze()
261+
shape = inputs.shape
262+
assert len(shape) == 1 and shape[0] == dimension, 'Input length and dimension mismatch'
263+
if inputs.is_cuda:
264+
inputs = inputs.cpu()
265+
return tuple((t.item() for t in inputs))

0 commit comments

Comments
 (0)