Skip to content

Commit

Permalink
fixed LoadTorchMLP CPU issue in torch_mlp.py
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnbera authored Apr 7, 2024
1 parent 2ee0960 commit a43484d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lanfactory/trainers/torch_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,11 @@ def __init__(self, model_file_path=None, network_config=None, input_dim=None):
input_shape=self.input_dim,
generative_model_id=None,
)
self.net.load_state_dict(torch.load(self.model_file_path))
# self.net.load_state_dict(torch.load(self.model_file_path))
if torch.cuda.is_available() == False:
self.net.load_state_dict(torch.load(self.model_file_path, map_location=torch.device('cpu')))
else:
self.net.load_state_dict(torch.load(self.model_file_path))
self.net.to(self.dev)
self.net.eval()

Expand Down Expand Up @@ -768,7 +772,11 @@ def __init__(self, model_file_path=None, network_config=None, input_dim=None):
input_shape=self.input_dim,
generative_model_id=None,
)
self.net.load_state_dict(torch.load(self.model_file_path))
# self.net.load_state_dict(torch.load(self.model_file_path))
if torch.cuda.is_available() == False:
self.net.load_state_dict(torch.load(self.model_file_path, map_location=torch.device('cpu')))
else:
self.net.load_state_dict(torch.load(self.model_file_path))
self.net.to(self.dev)

# AF-TODO: Seemingly LoadTorchMLPInfer is still not callable !
Expand Down

0 comments on commit a43484d

Please sign in to comment.