Skip to content

Commit da43c59

Browse files
authored
fix autocast overhead issue (#1217)
1 parent febdb6c commit da43c59

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

intel_extension_for_pytorch/cpu/autocast/_autocast_mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, device_type : str,
2727
else:
2828
raise RuntimeError('User specified autocast device_type must be \'cuda\' or \'cpu\'')
2929
self._cache_enabled = torch.is_autocast_cache_enabled()
30-
if torch.cuda.amp.common.amp_definitely_not_available() and self.device == 'cuda':
30+
if enabled and self.device == 'cuda' and torch.cuda.amp.common.amp_definitely_not_available():
3131
warnings.warn('User provided device_type of \'cuda\', but CUDA is not available. Disabling')
3232
enabled = False
3333
if dtype is not None:

0 commit comments

Comments
 (0)