Skip to content

Commit bb75c17

Browse files
committedFeb 27, 2023
MAINT: address review comments
1 parent c04f04f commit bb75c17

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed
 

‎torch_np/_detail/implementations.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ def _flatten(tensor, order="C"):
612612
if order != "C":
613613
raise NotImplementedError
614614
# return a copy
615-
result = tensor.ravel().clone()
615+
result = tensor.flatten()
616616
return result
617617

618618

@@ -645,10 +645,9 @@ def round(tensor, decimals=0):
645645

646646

647647
def imag(tensor):
648-
try:
648+
if tensor.is_complex():
649649
result = tensor.imag
650-
except RuntimeError:
651-
# RuntimeError: imag is not implemented for tensors with non-complex dtypes.
650+
else:
652651
result = torch.zeros_like(tensor)
653652
return result
654653

0 commit comments

Comments
 (0)
Please sign in to comment.