Skip to content

Commit

Permalink
Fix custom_tensor_utils for environments without spconv (quic#3538)
Browse files Browse the repository at this point in the history
Signed-off-by: Sai Chaitanya Gajula <quic_gsaichai@quicinc.com>
  • Loading branch information
quic-gsaichai authored Dec 2, 2024
1 parent 773293b commit a2769b5
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@
try:
import spconv.pytorch as spconv
except ImportError as e:
to_torch_tensor = None
to_custom_tensor = None
def to_torch_tensor(tensors):
""" placeholder in case spconv doesn't exist """
return tensors

def to_custom_tensor(tensors):
""" placeholder in case spconv doesn't exist """
return tensors
else:
from typing import List, Union, Tuple
import torch


def to_torch_tensor(original: Union[List, Tuple]) -> List[torch.Tensor]:
"""
Convert custom tensors to torch tensors
Expand Down Expand Up @@ -77,7 +81,6 @@ def to_custom_tensor(original: Union[List, Tuple], torch_tensors: List[torch.Ten
tensor = torch_tensor
if isinstance(orig, spconv.SparseConvTensor):
tensor = orig.replace_feature(torch_tensor)

outputs.append(tensor)

return outputs

0 comments on commit a2769b5

Please sign in to comment.