Skip to content

Commit

Permalink
contrib: lazy import of torch_complex
Browse files Browse the repository at this point in the history
  • Loading branch information
boeddeker committed Jun 13, 2024
1 parent 2e454d2 commit 94c1f18
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions padertorch/contrib/cb/complex.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import numpy as np
import torch
import torch_complex
from torch_complex import ComplexTensor

__all__ = {
'ComplexTensor',
}


Expand All @@ -19,8 +16,11 @@ def is_torch(obj):
>>> is_torch(ComplexTensor(np.zeros(3)))
True
"""
if torch.is_tensor(obj) or isinstance(obj, ComplexTensor):
if torch.is_tensor(obj):
return True
else:
return False
if type(obj).__name__ == 'ComplexTensor':
from torch_complex import ComplexTensor
if isinstance(obj, ComplexTensor):
return True
return False

0 comments on commit 94c1f18

Please sign in to comment.