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 authored Aug 4, 2024
1 parent 18297b4 commit 5fb2681
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 5fb2681

Please sign in to comment.