Skip to content

Commit 6e13cc2

Browse files
committed
update: alternative to work with gemma lib
1 parent 6356fcd commit 6e13cc2

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "vendor/gemma.cpp"]
22
path = vendor/gemma.cpp
33
url = https://github.com/google/gemma.cpp
4+
[submodule "vendor/pybind11"]
5+
path = vendor/pybind11
6+
url = https://github.com/pybind/pybind11.git

CMakeLists.txt

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
1-
# Previous content...
2-
3-
# Fetch pybind11
4-
FetchContent_Declare(
5-
pybind11
6-
GIT_REPOSITORY https://github.com/pybind/pybind11.git
7-
GIT_TAG v2.6.1 # Use the latest version or the version you prefer
8-
)
9-
FetchContent_MakeAvailable(pybind11)
10-
11-
# Pybind11 module
12-
pybind11_add_module(gemma_bindings bindings.cc)
13-
target_link_libraries(gemma_bindings PRIVATE libgemma)
1+
cmake_minimum_required(VERSION 3.11) # or whatever minimum version you require
2+
3+
include(FetchContent)
4+
5+
project(gemma_cpp_python)
6+
7+
set(CMAKE_CXX_STANDARD 17)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
10+
11+
FetchContent_Declare(sentencepiece GIT_REPOSITORY https://github.com/google/sentencepiece GIT_TAG 53de76561cfc149d3c01037f0595669ad32a5e7c)
12+
FetchContent_MakeAvailable(sentencepiece)
13+
14+
FetchContent_Declare(gemma GIT_REPOSITORY https://github.com/google/gemma.cpp GIT_TAG origin/main)
15+
FetchContent_MakeAvailable(gemma)
16+
17+
18+
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG da250571a45826b21eebbddc1e50d0c1137dee5f)
19+
FetchContent_MakeAvailable(highway)
20+
21+
add_subdirectory(vendor/pybind11)
22+
#add_subdirectory(vendor/gemma.cpp)
23+
24+
# Create the Python module
25+
pybind11_add_module(gemma_cpp src/pygemma.cpp)
26+
27+
target_link_libraries(gemma_cpp PRIVATE libgemma hwy hwy_contrib sentencepiece)
28+
29+
# Link against libgemma.a and any other necessary libraries
30+
# After linking, try to include the directories. Adjust this if necessary.
31+
FetchContent_GetProperties(gemma)
32+
FetchContent_GetProperties(sentencepiece)
33+
target_include_directories(gemma_cpp PRIVATE ${gemma_SOURCE_DIR})
34+
target_include_directories(gemma_cpp PRIVATE ${sentencepiece_SOURCE_DIR})
35+
36+

vendor/pybind11

Submodule pybind11 added at 8b48ff8

0 commit comments

Comments
 (0)