You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: py/torch_tensorrt/dynamo/conversion/converter_utils.py
+33-30
Original file line number
Diff line number
Diff line change
@@ -590,42 +590,45 @@ def to_numpy(
590
590
Returns:
591
591
A Numpy array or None, if the input was None.
592
592
"""
593
-
output=None
593
+
withunset_fake_temporarily():
594
+
output=None
594
595
595
-
ifvalueisNoneorisinstance(value, np.ndarray):
596
-
output=value
596
+
ifvalueisNoneorisinstance(value, np.ndarray):
597
+
output=value
597
598
598
-
elifisinstance(value, torch.Tensor):
599
-
ifvalue.is_quantized:
600
-
value=value.dequantize()
601
-
elifvalue.dtype==torch.bfloat16:
602
-
# TODO: Remove when numpy has a BF16 type
603
-
_LOGGER.warning(
604
-
"Requested a conversion of bfloat16 tensor from torch to numpy which isn't supported. Casting this tensor to FP32 precision currently. Please use to_torch() API for better data representation",
605
-
)
606
-
value=value.to(torch.float)
607
-
608
-
output=value.cpu().detach().contiguous().numpy()
599
+
elifisinstance(value, torch.Tensor):
600
+
ifvalue.is_quantized:
601
+
value=value.dequantize()
602
+
elifvalue.dtype==torch.bfloat16:
603
+
# TODO: Remove when numpy has a BF16 type
604
+
_LOGGER.warning(
605
+
"Requested a conversion of bfloat16 tensor from torch to numpy which isn't supported. Casting this tensor to FP32 precision currently. Please use to_torch() API for better data representation",
0 commit comments