Skip to content

Commit

Permalink
Fix compiler check for adopt so it doesn't fail for torch >= 2 but le…
Browse files Browse the repository at this point in the history
…ss than recent with .is_compiling()
  • Loading branch information
rwightman committed Nov 13, 2024
1 parent 0b5264a commit e35ea73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion timm/optim/adopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def _get_scalar_dtype(is_fused=None):


def _is_compiling():
return torch.compiler.is_compiling() if hasattr(torch, 'compiler') else False
if hasattr(torch, 'compiler') and hasattr(torch.compiler, 'is_compiling'):
return torch.compiler.is_compiling()
else:
return False


def _get_value(x):
Expand Down

0 comments on commit e35ea73

Please sign in to comment.