Skip to content

Commit

Permalink
fix: get_device should gracefully handle models without a device attr
Browse files Browse the repository at this point in the history
  • Loading branch information
chanind committed Aug 4, 2024
1 parent fd7b86c commit f0e596c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion linear_relational/lib/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_device(model: nn.Module) -> torch.device:
"""
Returns the device on which the model is running.
"""
if isinstance(model.device, torch.device):
if hasattr(model, "device") and isinstance(model.device, torch.device):
return model.device
return next(model.parameters()).device

Expand Down

0 comments on commit f0e596c

Please sign in to comment.