Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions kornia/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def is_autocast_enabled(both: bool = True) -> bool:
Returns:
Return a Bool,
will always return False for a torch without support, otherwise will be: if both is True
`torch.is_autocast_enabled() or torch.is_autocast_cpu_enabled()`. If both is False will return just
`torch.is_autocast_enabled() or torch.is_autocast_enabled('cpu')`. If both is False will return just
`torch.is_autocast_enabled()`.
"""
if TYPE_CHECKING:
Expand All @@ -316,7 +316,10 @@ def is_autocast_enabled(both: bool = True) -> bool:
return False

if both:
return torch.is_autocast_enabled() or torch.is_autocast_cpu_enabled()
if torch_version_ge(2, 4):
return torch.is_autocast_enabled() or torch.is_autocast_enabled("cpu")
else:
return torch.is_autocast_enabled() or torch.is_autocast_cpu_enabled()

return torch.is_autocast_enabled()

Expand Down