Skip to content

Commit

Permalink
Use main ggml repo (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
saharNooby committed Apr 29, 2023
1 parent 1198892 commit 06dac0f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
cmake ..
cmake --build . --config Release
- name: Test
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON -DRWKV_AVX2=OFF -DRWKV_FMA=OFF ..
cmake -DRWKV_AVX2=OFF -DRWKV_FMA=OFF ..
cmake --build . --config Release
- name: Test
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -DBUILD_SHARED_LIBS=ON ${{ matrix.defines }}
cmake .. ${{ matrix.defines }}
cmake --build . --config Release
- name: Check AVX512F support
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "ggml"]
path = ggml
url = https://github.com/saharNooby/ggml
branch = master-2023-04-29
url = https://github.com/ggerganov/ggml
branch = master
38 changes: 15 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.12) # Don't bump this version for no reason
cmake_minimum_required(VERSION 3.12)

project("rwkv.cpp" C CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand All @@ -10,23 +11,12 @@ endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

if (EMSCRIPTEN)
set(BUILD_SHARED_LIBS_DEFAULT OFF)

option(RWKV_WASM_SINGLE_FILE "rwkv: embed WASM inside the generated rwkv.js" ON)
else()
if (MINGW)
set(BUILD_SHARED_LIBS_DEFAULT OFF)
else()
set(BUILD_SHARED_LIBS_DEFAULT ON)
endif()
endif()

#
# Option list
#

# General
option(RWKV_BUILD_SHARED_LIBRARY "rwkv: build as a shared library" ON)
option(RWKV_STATIC "rwkv: static link libraries" OFF)
option(RWKV_NATIVE "rwkv: enable -march=native flag" OFF)
option(RWKV_LTO "rwkv: enable link time optimization" OFF)
Expand Down Expand Up @@ -54,26 +44,25 @@ option(RWKV_OPENBLAS "rwkv: use OpenBLAS"
# Compile flags
#

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED true)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED true)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

if (NOT MSVC)
if (RWKV_SANITIZE_THREAD)
message(STATUS "Using RWKV_SANITIZE_THREAD")
add_compile_options(-fsanitize=thread)
link_libraries(-fsanitize=thread)
endif()

if (RWKV_SANITIZE_ADDRESS)
message(STATUS "Using RWKV_SANITIZE_ADDRESS")
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
link_libraries(-fsanitize=address)
endif()

if (RWKV_SANITIZE_UNDEFINED)
message(STATUS "Using RWKV_SANITIZE_UNDEFINED")
add_compile_options(-fsanitize=undefined)
link_libraries(-fsanitize=undefined)
endif()
Expand Down Expand Up @@ -127,6 +116,7 @@ if (RWKV_ALL_WARNINGS)
-Wpedantic
-Wcast-qual
-Wno-unused-function
-Wno-multichar
)
else()
# TODO [llama.cpp]: msvc
Expand Down Expand Up @@ -201,9 +191,7 @@ elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$")
endif()
if (RWKV_AVX512)
add_compile_options(-mavx512f)
# add_compile_options(-mavx512cd)
# add_compile_options(-mavx512dq)
# add_compile_options(-mavx512bw)
add_compile_options(-mavx512bw)
endif()
endif()
else()
Expand All @@ -221,17 +209,21 @@ endif()

add_subdirectory(ggml)

if (BUILD_SHARED_LIBS)
if (RWKV_BUILD_SHARED_LIBRARY)
set_target_properties(ggml PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()

add_library(rwkv rwkv.cpp rwkv.h)
if (RWKV_BUILD_SHARED_LIBRARY)
add_library(rwkv SHARED rwkv.cpp rwkv.h)
else()
add_library(rwkv rwkv.cpp rwkv.h)
endif()

target_include_directories(rwkv PUBLIC .)
target_compile_features(rwkv PUBLIC cxx_std_11) # Don't bump
target_compile_features(rwkv PUBLIC cxx_std_11)
target_link_libraries(rwkv PRIVATE ggml ${RWKV_EXTRA_LIBS})

if (BUILD_SHARED_LIBS)
if (RWKV_BUILD_SHARED_LIBRARY)
set_target_properties(rwkv PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(rwkv PRIVATE RWKV_SHARED RWKV_BUILD)
endif()
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ On Windows: to check whether your CPU supports AVX2 or AVX-512, [use CPU-Z](http
**Requirements**: [CMake](https://cmake.org/download/) or [CMake from anaconda](https://anaconda.org/conda-forge/cmake), MSVC compiler.

```commandline
cmake -DBUILD_SHARED_LIBS=ON .
cmake .
cmake --build . --config Release
```

Expand All @@ -66,11 +66,11 @@ If everything went OK, `bin\Release\rwkv.dll` file should appear.
**Requirements**: CMake (Linux: `sudo apt install cmake`, MacOS: `brew install cmake`, anaconoda: [cmake package](https://anaconda.org/conda-forge/cmake)).

```commandline
cmake -DBUILD_SHARED_LIBS=ON .
cmake .
cmake --build . --config Release
```

**Anaconda & M1 users**: please verify that `CMAKE_SYSTEM_PROCESSOR: arm64` after running `cmake -DBUILD_SHARED_LIBS=ON .` — if it detects `x86_64`, edit the `CMakeLists.txt` file under the `# Compile flags` to add `set(CMAKE_SYSTEM_PROCESSOR "arm64")`.
**Anaconda & M1 users**: please verify that `CMAKE_SYSTEM_PROCESSOR: arm64` after running `cmake .` — if it detects `x86_64`, edit the `CMakeLists.txt` file under the `# Compile flags` to add `set(CMAKE_SYSTEM_PROCESSOR "arm64")`.

If everything went OK, `librwkv.so` (Linux) or `librwkv.dylib` (MacOS) file should appear in the base repo folder.

Expand Down
2 changes: 1 addition & 1 deletion ggml

0 comments on commit 06dac0f

Please sign in to comment.