diff --git a/Makefile b/Makefile index 4e4c080..dedb57f 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,8 @@ SHELL := /bin/bash f_release = build_release f_debug = build_debug -app_targets = main -test_targets = unit_tests_bayesnet unit_tests_platform +app_targets = example +test_targets = unit_tests_pywrap n_procs = -j 16 define ClearTests @@ -31,21 +31,6 @@ setup: ## Install dependencies for tests and coverage pip install gcovr; \ fi -dest ?= ${HOME}/bin -install: ## Copy binary files to bin folder - @echo "Destination folder: $(dest)" - make buildr - @echo ">>> Copying files to $(dest)" - @cp $(f_release)/src/Platform/b_main $(dest) - @cp $(f_release)/src/Platform/b_list $(dest) - @cp $(f_release)/src/Platform/b_manage $(dest) - @cp $(f_release)/src/Platform/b_best $(dest) - -dependency: ## Create a dependency graph diagram of the project (build/dependency.png) - @echo ">>> Creating dependency graph diagram of the project..."; - $(MAKE) debug - cd $(f_debug) && cmake .. --graphviz=dependency.dot && dot -Tpng dependency.dot -o dependency.png - buildd: ## Build the debug targets cmake --build $(f_debug) -t $(app_targets) $(n_procs) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8dab52..afb0379 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,9 @@ include_directories(${PyWrap_SOURCE_DIR}/lib/json/include) include_directories(${Python3_INCLUDE_DIRS}) include_directories(${TORCH_INCLUDE_DIRS}) -add_executable(main main.cc STree.cc SVC.cc RandomForest.cc PyClassifier.cc PyWrap.cc) -target_link_libraries(main ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::boost Boost::python Boost::numpy ArffFiles) +add_library(PyWrap SHARED PyWrap.cc STree.cc SVC.cc RandomForest.cc PyClassifier.cc) +target_link_libraries(PyWrap ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::boost Boost::python Boost::numpy ArffFiles) + +add_executable(example example.cc) +target_link_libraries(example PyWrap) \ No newline at end of file diff --git a/src/PyClassifier.cc b/src/PyClassifier.cc index 9106454..8fb9c02 100644 --- a/src/PyClassifier.cc +++ b/src/PyClassifier.cc @@ -1,5 +1,4 @@ #include "PyClassifier.h" -#include namespace pywrap { namespace bp = boost::python; namespace np = boost::python::numpy; @@ -7,7 +6,6 @@ namespace pywrap { { // This id allows to have more than one instance of the same module/class id = reinterpret_cast(this); - std::cout << "PyClassifier: Creating instance of " << module << " and class " << className << " id " << id << std::endl; pyWrap = PyWrap::GetInstance(); pyWrap->importClass(id, module, className); } @@ -40,7 +38,6 @@ namespace pywrap { PyClassifier& PyClassifier::fit(torch::Tensor& X, torch::Tensor& y, const std::vector& features, const std::string& className, std::map>& states) { if (!fitted && hyperparameters.size() > 0) { - std::cout << "PyClassifier: Setting hyperparameters" << std::endl; pyWrap->setHyperparameters(id, hyperparameters); } auto [Xn, yn] = tensors2numpy(X, y); diff --git a/src/PyWrap.cc b/src/PyWrap.cc index 483894f..0a131a2 100644 --- a/src/PyWrap.cc +++ b/src/PyWrap.cc @@ -3,7 +3,6 @@ #include "PyWrap.h" #include #include -#include #include #include @@ -117,7 +116,6 @@ namespace pywrap { void PyWrap::setHyperparameters(const clfId_t id, const json& hyperparameters) { // Set hyperparameters as attributes of the class - std::cout << "Building dictionary of arguments" << std::endl; PyObject* pValue; PyObject* instance = getClass(id); for (const auto& [key, value] : hyperparameters.items()) { diff --git a/src/main.cc b/src/example.cc similarity index 100% rename from src/main.cc rename to src/example.cc