From 2f3ea040108723be50a354f6bbddedd4b9a94669 Mon Sep 17 00:00:00 2001 From: mike dupont Date: Wed, 6 Dec 2023 07:20:19 -0500 Subject: [PATCH] starting boost --- CMakeLists.txt | 41 ++++++++++++++++++++++++++++++++++++ examples/main/CMakeLists.txt | 5 +++-- print.hpp | 25 ++++++++++++---------- 3 files changed, 58 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b8462d8a..50a31ce18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,45 @@ cmake_minimum_required(VERSION 3.13) # for add_link_options project("llama.cpp" C CXX) +find_package (Python3 COMPONENTS Interpreter Development) + + +if (Python3_Interpreter_FOUND) + if (UNIX AND NOT APPLE) + if (PYTHON_VERSION_MAJOR EQUAL 3) + FIND_PACKAGE(Boost COMPONENTS python${PYTHON_VERSION_SUFFIX}) +# FIND_PACKAGE(PythonInterp 3) +# FIND_PACKAGE(PythonLibs 3 REQUIRED) + else() + FIND_PACKAGE(Boost COMPONENTS python) + # FIND_PACKAGE(PythonInterp) + # FIND_PACKAGE(PythonLibs REQUIRED) + endif() + else() + if (PYTHON_VERSION_MAJOR EQUAL 3) + FIND_PACKAGE(Boost COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + FIND_PACKAGE(PythonInterp 3) + FIND_PACKAGE(PythonLibs 3 REQUIRED) + else() + FIND_PACKAGE(Boost COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + FIND_PACKAGE(PythonInterp) + FIND_PACKAGE(PythonLibs REQUIRED) + endif() + endif() +else() + message("Python not found") +endif() + +message(STATUS "PYTHON_LIBRARIES = ${Python3_LIBRARIES}") +message(STATUS "PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}") +message(STATUS "PYTHON_INCLUDE_DIRS = ${Python3_INCLUDE_DIRS}") +message(STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}") + +ENABLE_TESTING() +INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS}) +LINK_LIBRARIES(${Boost_LIBRARIES} ${Python3_LIBRARIES}) # Deprecated but so convenient! + +#PYTHON_ADD_MODULE(plugin_python plugin_python.cpp) +Python3_add_library(plugin_python MODULE plugin_python.cpp) if (NOT MSVC) set(cuda_flags -Wno-pedantic) @@ -692,6 +732,7 @@ add_library(ggml OBJECT ggml.cpp ggml.h print.hpp + plugin_python.cpp ggml-internal.hpp llama-internal.hpp ggml-alloc.cpp diff --git a/examples/main/CMakeLists.txt b/examples/main/CMakeLists.txt index d532980b7..366dcf6ae 100644 --- a/examples/main/CMakeLists.txt +++ b/examples/main/CMakeLists.txt @@ -1,5 +1,6 @@ set(TARGET main) add_executable(${TARGET} main.cpp) install(TARGETS ${TARGET} RUNTIME) -target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT}) -target_compile_features(${TARGET} PRIVATE cxx_std_11) +target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) +target_compile_features(${TARGET} PRIVATE cxx_std_20) + diff --git a/print.hpp b/print.hpp index b9a75fbff..50ef78ef2 100644 --- a/print.hpp +++ b/print.hpp @@ -527,27 +527,30 @@ constexpr auto get_value_type_name(const T t) noexcept return t.value_type; } +int call_python(); + // // A generic function to print out the fields of any object template void print_fields(const T& t) { - refl::runtime::debug(std::cout, t); - constexpr auto type = refl::reflect(); + //refl::runtime::debug(std::cout, t); + //constexpr auto type = refl::reflect(); - constexpr auto membertype = refl::member_list(); + //constexpr auto membertype = refl::member_list(); - constexpr auto members = get_members(type); - std::cout << "DEBUG Type: " << type.name.c_str() << "\n"; - std::cout << "DEBUG Type2: " << typeid(membertype).name() << "\n"; - std::cout << "DEBUG Type3: " << typeid(members).name() << "\n"; - refl::util::for_each(members, [&](auto member) { + call_python(); + //constexpr auto members = get_members(type); + //std::cout << "DEBUG Type: " << type.name.c_str() << "\n"; + // std::cout << "DEBUG Type2: " << typeid(membertype).name() << "\n"; + // std::cout << "DEBUG Type3: " << typeid(members).name() << "\n"; + // refl::util::for_each(members, [&](auto member) { //using member_t = decltype(member::value_type); //typename type3 = member::value_type; //typename trait::remove_qualifiers_t::value_type>; //constexpr auto type2 = refl::reflect(type3); //std::cout << "Auto:" << foo <<"\n"; - std::cout << "Auto:" << member.name <<"\n"; + // std::cout << "Auto:" << member.name <<"\n"; //std::cout << "DEBUG Type2: " << typeid(member_t).name() << "\n"; //std::cout << "DEBUG Type2: " << type2.name.c_str() << "\n"; - }); - std::cout << "\n"; + // }); + // std::cout << "\n"; }