From f7d3a7ea6550f5d42623a26d6db692408f9f9061 Mon Sep 17 00:00:00 2001 From: straile Date: Fri, 11 Oct 2024 12:12:38 +0200 Subject: [PATCH] fix: function stubs for compilation without AI surrogate --- README.md | 10 +++++++--- src/Chemistry/SurrogateModels/AI_functions.hpp | 15 +++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 23d873e9a..b9040d6b3 100644 --- a/README.md +++ b/README.md @@ -99,8 +99,9 @@ following available options: - **POET_PREPROCESS_BENCHS**=*boolean* - enables the preprocessing of predefined models/benchmarks. Defaults to *ON*. - **USE_AI_SURROGATE**=*boolean* - includes the functions of the AI - surrogate model. This relies on the presence of a Python environment - where Keras is installed. + surrogate model. When active, CMake relies on `find_package()` to find + an a implementation of `Threads` and a Python environment where Numpy + and Keras need to be installed. Defaults to _OFF_. ### Example: Build from scratch @@ -235,7 +236,10 @@ mpirun -n 4 ./poet --dht --dht-snaps=2 barite_het_rt.R barite_het.rds output ### Example: Preparing Environment and Running with AI surrogate -To run the AI surrogate, you need to install the R package `keras3`. The +To run the AI surrogate, you need to have a Keras installed in your Python environment. +The implementation in POET is agnostic to the exact Keras version, but If you use a +pretrained model, the model file must match your Keras version. Using Keras 3 with +`.keras` model files is recommended. recomenden compilation process of POET remains the same as shown above. In the following code block, the installation process on the Turing Cluster is diff --git a/src/Chemistry/SurrogateModels/AI_functions.hpp b/src/Chemistry/SurrogateModels/AI_functions.hpp index 7873715c0..284a27d3b 100644 --- a/src/Chemistry/SurrogateModels/AI_functions.hpp +++ b/src/Chemistry/SurrogateModels/AI_functions.hpp @@ -14,13 +14,15 @@ #ifndef AI_FUNCTIONS_H #define AI_FUNCTIONS_H +#include +#include + // PhreeqC definition of pi clashes with Eigen macros so we have to temporarily undef it #pragma push_macro("pi") #undef pi #include #pragma pop_macro("pi") -#include namespace poet { // Define an aligned allocator for std::vector @@ -48,8 +50,6 @@ int Python_Keras_load_model(std::string model_file_path); std::vector Python_Keras_predict(std::vector> x, int batch_size); -void Python_Keras_train(std::vector> x, std::vector> y, int batch_size); - int Python_Keras_training_thread(EigenModel* Eigen_model, std::mutex* Eigen_model_mutex, TrainingData* training_data_buffer, @@ -68,21 +68,16 @@ std::vector Eigen_predict(const EigenModel& model, std::vector Python_Keras_predict(std::vector>, int){return {};} -inline void Python_Keras_train(vector>, vector>, int){} inline int Python_Keras_training_thread(EigenModel*, std::mutex*, TrainingData*, std::mutex*, std::condition_variable*, bool*, int, int, int, bool){return {};} inline void Python_Keras_set_weights_as_Eigen(EigenModel&){} -inline EigenModel transform_weights(const std::vector>>){return {};} -inline std::vector>> Python_Keras_get_weights(){return {};} inline std::vector Eigen_predict(const EigenModel&, std::vector>, int){return {};} - - #endif - } // namespace poet + #endif // AI_FUNCTIONS_HPP \ No newline at end of file