From 64d5317d19fb3f2551607c27dcf34c0a8c015d08 Mon Sep 17 00:00:00 2001 From: Holger Badorreck Date: Tue, 28 Feb 2023 10:07:46 +0100 Subject: [PATCH] hint to generate needed file for mliap pytorch example --- examples/mliap/mliap_pytorch_Ta06A.py | 6 +++++- examples/mliap/mliap_pytorch_Ta06A_kokkos.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/mliap/mliap_pytorch_Ta06A.py b/examples/mliap/mliap_pytorch_Ta06A.py index c4387e21a3..589c9661b8 100644 --- a/examples/mliap/mliap_pytorch_Ta06A.py +++ b/examples/mliap/mliap_pytorch_Ta06A.py @@ -94,8 +94,12 @@ lmp.commands_string(before_loading) # Define the model however you like. In this example # we load it from disk: +import os import torch -model = torch.load('Ta06A.mliap.pytorch.model.pt') +torch_model = 'Ta06A.mliap.pytorch.model.pt' +if not os.path.exists(torch_model): + raise FileNotFoundError(f"Generate {torch_model} with convert_mliap_Ta06A.py") +model = torch.load(torch_model) # Connect the PyTorch model to the mliap pair style. lammps.mliap.load_model(model) diff --git a/examples/mliap/mliap_pytorch_Ta06A_kokkos.py b/examples/mliap/mliap_pytorch_Ta06A_kokkos.py index da0d3fcaff..f0d2b9bf3e 100644 --- a/examples/mliap/mliap_pytorch_Ta06A_kokkos.py +++ b/examples/mliap/mliap_pytorch_Ta06A_kokkos.py @@ -94,8 +94,12 @@ lmp.commands_string(before_loading) # Define the model however you like. In this example # we load it from disk: +import os import torch -model = torch.load('Ta06A.mliap.pytorch.model.pt') +torch_model = 'Ta06A.mliap.pytorch.model.pt' +if not os.path.exists(torch_model): + raise FileNotFoundError(f"Generate {torch_model} with convert_mliap_Ta06A.py") +model = torch.load(torch_model) # Connect the PyTorch model to the mliap pair style. lammps.mliap.load_model_kokkos(model)