From afb1d8cbe7ba7ebdb03960000ed1598901a45e99 Mon Sep 17 00:00:00 2001 From: RaulPPealez Date: Mon, 4 Sep 2023 15:53:08 +0200 Subject: [PATCH] Clone the module on TorchForceImpl initialization to avoid several contexts sharing the same model --- openmmapi/src/TorchForceImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmmapi/src/TorchForceImpl.cpp b/openmmapi/src/TorchForceImpl.cpp index 054bc846..61c9b5be 100644 --- a/openmmapi/src/TorchForceImpl.cpp +++ b/openmmapi/src/TorchForceImpl.cpp @@ -46,7 +46,7 @@ TorchForceImpl::~TorchForceImpl() { } void TorchForceImpl::initialize(ContextImpl& context) { - auto module = owner.getModule(); + auto module = owner.getModule().clone(); // Create the kernel. kernel = context.getPlatform().createKernel(CalcTorchForceKernel::Name(), context); kernel.getAs().initialize(context.getSystem(), owner, module);