Use main ggml repo (#45)

This commit is contained in:
Alex 2023-04-29 21:35:36 +05:00 committed by GitHub
parent 1198892888
commit 06dac0f80d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 32 deletions

View File

@ -76,7 +76,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
cmake ..
cmake --build . --config Release
- name: Test
@ -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
@ -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

4
.gitmodules vendored
View File

@ -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

View File

@ -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)
@ -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)
@ -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()
@ -127,6 +116,7 @@ if (RWKV_ALL_WARNINGS)
-Wpedantic
-Wcast-qual
-Wno-unused-function
-Wno-multichar
)
else()
# TODO [llama.cpp]: msvc
@ -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()
@ -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()

View File

@ -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
```
@ -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.

2
ggml

@ -1 +1 @@
Subproject commit a0687a3a3c4b31811219d7a61adfb66230b09201
Subproject commit b237714db49cc09b63a372aeb33ca83bc56b3977