Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
RudolfWeeber committed Aug 12, 2024
1 parent 29e5f2f commit 319a352
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 89 deletions.
60 changes: 39 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -605,27 +605,45 @@ if(ESPRESSO_BUILD_WITH_METATENSOR)
# expression from `metatensor_torch`
find_package(Torch REQUIRED)

# cmake-format: off
set(METATENSOR_URL_BASE "https://github.com/lab-cosmo/metatensor/releases/download")
set(METATENSOR_CORE_VERSION "0.1.8")

include(FetchContent)
FetchContent_Declare(
metatensor
URL "${METATENSOR_URL_BASE}/metatensor-core-v${METATENSOR_CORE_VERSION}/metatensor-core-cxx-${METATENSOR_CORE_VERSION}.tar.gz"
URL_HASH SHA1=3ed389770e5ec6dbb8cbc9ed88f84d6809b552ef
)

# workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/21146
if(NOT DEFINED metatensor_SOURCE_DIR OR NOT EXISTS "${metatensor_SOURCE_DIR}")
message(STATUS "Fetching metatensor v${METATENSOR_CORE_VERSION} from github")
FetchContent_Populate(metatensor)
endif()
# cmake-format: on

set(BUILD_SHARED_LIBS on CACHE BOOL "")
set(METATENSOR_INSTALL_BOTH_STATIC_SHARED off CACHE BOOL "")
add_subdirectory("${metatensor_SOURCE_DIR}")
# # cmake-format: off
# set(METATENSOR_URL_BASE "https://github.com/lab-cosmo/metatensor/releases/download")
# set(METATENSOR_CORE_VERSION "0.1.8")
# set(METATENSOR_TORCH_VERSION "0.5.3")
#
# include(FetchContent)
# set(BUILD_SHARED_LIBS on CACHE BOOL "")
# FetchContent_Declare(
# metatensor
# URL "${METATENSOR_URL_BASE}/metatensor-core-v${METATENSOR_CORE_VERSION}/metatensor-core-cxx-${METATENSOR_CORE_VERSION}.tar.gz"
# URL_HASH SHA1=3ed389770e5ec6dbb8cbc9ed88f84d6809b552ef
# )
# set(BUILD_SHARED_LIBS on CACHE BOOL "")
#
# # workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/21146
# if(NOT DEFINED metatensor_SOURCE_DIR OR NOT EXISTS "${metatensor_SOURCE_DIR}")
# message(STATUS "Fetching metatensor v${METATENSOR_CORE_VERSION} from github")
# FetchContent_Populate(metatensor)
# endif()
# set(BUILD_SHARED_LIBS on CACHE BOOL "")
#
# FetchContent_Declare(
# metatensor_torch
# URL "${METATENSOR_URL_BASE}/metatensor-torch-v${METATENSOR_TORCH_VERSION}/metatensor-torch-cxx-${METATENSOR_TORCH_VERSION}.tar.gz"
# )
# set(BUILD_SHARED_LIBS on CACHE BOOL "")
# if(NOT DEFINED metatensor_torch_SOURCE_DIR OR NOT EXISTS "${metatensor_torch_SOURCE_DIR}")
# message(STATUS "Fetching metatensor torch v${METATENSOR_CORE_VERSION} from github")
# FetchContent_Populate(metatensor_torch)
# endif()
# # cmake-format: on
# set(BUILD_SHARED_LIBS on CACHE BOOL "")
#
# set(METATENSOR_INSTALL_BOTH_STATIC_SHARED on CACHE BOOL "")
# add_subdirectory("${metatensor_SOURCE_DIR}")
# add_subdirectory("${metatensor_torch_SOURCE_DIR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
find_package(metatensor)
find_package(metatensor_torch)
endif()

#
Expand Down
6 changes: 6 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ if(ESPRESSO_BUILD_WITH_CUDA)
install(TARGETS espresso_cuda
LIBRARY DESTINATION ${ESPRESSO_INSTALL_PYTHON}/espressomd)
endif()
if(ESPRESSO_BUILD_WITH_METATENSOR)
target_link_libraries(espresso_core PUBLIC "${TORCH_LIBRARIES}")
target_link_libraries(espresso_core PUBLIC metatensor::shared)
target_link_libraries(espresso_core PUBLIC metatensor_torch)
endif()

install(TARGETS espresso_core
LIBRARY DESTINATION ${ESPRESSO_INSTALL_PYTHON}/espressomd)
Expand Down Expand Up @@ -111,6 +116,7 @@ add_subdirectory(immersed_boundary)
add_subdirectory(integrators)
add_subdirectory(io)
add_subdirectory(lb)
add_subdirectory(ml_metatensor)
add_subdirectory(magnetostatics)
add_subdirectory(nonbonded_interactions)
add_subdirectory(object-in-fluid)
Expand Down
3 changes: 2 additions & 1 deletion src/core/ml_metatensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

#target_sources(espresso_core PRIVATE bonded_interaction_data.cpp)
target_sources(espresso_core PRIVATE stub.cpp)
target_sources(espresso_core PRIVATE load_model.cpp)
65 changes: 0 additions & 65 deletions src/core/ml_metatensor/load_model.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/core/ml_metatensor/stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@

#include <metatensor/torch.hpp>
#include <metatensor/torch/atomistic.hpp>
torch::Tensor test_tensor{};

#endif

0 comments on commit 319a352

Please sign in to comment.