starting boost

This commit is contained in:
mike dupont 2023-12-06 07:20:19 -05:00
parent 5ea96cc710
commit 2f3ea04010
3 changed files with 58 additions and 13 deletions

View file

@ -1,5 +1,45 @@
cmake_minimum_required(VERSION 3.13) # for add_link_options cmake_minimum_required(VERSION 3.13) # for add_link_options
project("llama.cpp" C CXX) 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) if (NOT MSVC)
set(cuda_flags -Wno-pedantic) set(cuda_flags -Wno-pedantic)
@ -692,6 +732,7 @@ add_library(ggml OBJECT
ggml.cpp ggml.cpp
ggml.h ggml.h
print.hpp print.hpp
plugin_python.cpp
ggml-internal.hpp ggml-internal.hpp
llama-internal.hpp llama-internal.hpp
ggml-alloc.cpp ggml-alloc.cpp

View file

@ -1,5 +1,6 @@
set(TARGET main) set(TARGET main)
add_executable(${TARGET} main.cpp) add_executable(${TARGET} main.cpp)
install(TARGETS ${TARGET} RUNTIME) install(TARGETS ${TARGET} RUNTIME)
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
target_compile_features(${TARGET} PRIVATE cxx_std_11) target_compile_features(${TARGET} PRIVATE cxx_std_20)

View file

@ -527,27 +527,30 @@ constexpr auto get_value_type_name(const T t) noexcept
return t.value_type; return t.value_type;
} }
int call_python();
// // A generic function to print out the fields of any object // // A generic function to print out the fields of any object
template<typename T> template<typename T>
void print_fields(const T& t) { void print_fields(const T& t) {
refl::runtime::debug(std::cout, t); //refl::runtime::debug(std::cout, t);
constexpr auto type = refl::reflect<T>(); //constexpr auto type = refl::reflect<T>();
constexpr auto membertype = refl::member_list<T>(); //constexpr auto membertype = refl::member_list<T>();
constexpr auto members = get_members(type); call_python();
std::cout << "DEBUG Type: " << type.name.c_str() << "\n"; //constexpr auto members = get_members(type);
std::cout << "DEBUG Type2: " << typeid(membertype).name() << "\n"; //std::cout << "DEBUG Type: " << type.name.c_str() << "\n";
std::cout << "DEBUG Type3: " << typeid(members).name() << "\n"; // std::cout << "DEBUG Type2: " << typeid(membertype).name() << "\n";
refl::util::for_each(members, [&](auto member) { // std::cout << "DEBUG Type3: " << typeid(members).name() << "\n";
// refl::util::for_each(members, [&](auto member) {
//using member_t = decltype(member::value_type); //using member_t = decltype(member::value_type);
//typename type3 = member::value_type; //typename type3 = member::value_type;
//typename trait::remove_qualifiers_t<member_t>::value_type>; //typename trait::remove_qualifiers_t<member_t>::value_type>;
//constexpr auto type2 = refl::reflect(type3); //constexpr auto type2 = refl::reflect(type3);
//std::cout << "Auto:" << foo <<"\n"; //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: " << typeid(member_t).name() << "\n";
//std::cout << "DEBUG Type2: " << type2.name.c_str() << "\n"; //std::cout << "DEBUG Type2: " << type2.name.c_str() << "\n";
}); // });
std::cout << "\n"; // std::cout << "\n";
} }