move public backend headers to the public include directory (#8122)

* move public backend headers to the public include directory

* nix test

* spm : fix metal header

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
This commit is contained in:
slaren 2024-06-26 08:50:42 +02:00 committed by Georgi Gerganov
parent 0d93f02748
commit 22495bfe3a
No known key found for this signature in database
GPG key ID: BF970631944C16B7
18 changed files with 51 additions and 49 deletions

View file

@ -160,9 +160,9 @@ effectiveStdenv.mkDerivation (
};
postPatch = ''
substituteInPlace ./ggml-metal.m \
substituteInPlace ./ggml/src/ggml-metal.m \
--replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/bin/ggml-metal.metal\";"
substituteInPlace ./ggml-metal.m \
substituteInPlace ./ggml/src/ggml-metal.m \
--replace '[bundle pathForResource:@"default" ofType:@"metallib"];' "@\"$out/bin/default.metallib\";"
'';
@ -244,7 +244,7 @@ effectiveStdenv.mkDerivation (
# if they haven't been added yet.
postInstall = ''
mkdir -p $out/include
cp $src/llama.h $out/include/
cp $src/include/llama.h $out/include/
'';
# Define the shells here, but don't add in the inputsFrom to avoid recursion.

8
.github/labeler.yml vendored
View file

@ -2,25 +2,25 @@
Kompute:
- changed-files:
- any-glob-to-any-file:
- ggml/src/ggml-kompute.h
- ggml/include/ggml-kompute.h
- ggml/src/ggml-kompute.cpp
- README-kompute.md
Apple Metal:
- changed-files:
- any-glob-to-any-file:
- ggml/src/ggml-metal.h
- ggml/include/ggml-metal.h
- ggml/src/ggml-metal.cpp
- README-metal.md
SYCL:
- changed-files:
- any-glob-to-any-file:
- ggml/src/ggml-sycl.h
- ggml/include/ggml-sycl.h
- ggml/src/ggml-sycl.cpp
- README-sycl.md
Nvidia GPU:
- changed-files:
- any-glob-to-any-file:
- ggml/src/ggml-cuda.h
- ggml/include/ggml-cuda.h
- ggml/src/ggml-cuda/**
Vulkan:
- changed-files:

View file

@ -680,7 +680,7 @@ ggml/src/ggml-cuda/%.o: \
ggml/src/ggml-cuda.o: \
ggml/src/ggml-cuda.cu \
ggml/src/ggml-cuda.h \
ggml/include/ggml-cuda.h \
ggml/include/ggml.h \
ggml/include/ggml-backend.h \
ggml/src/ggml-backend-impl.h \
@ -716,7 +716,7 @@ endif
ggml/src/ggml-vulkan.o: \
ggml/src/ggml-vulkan.cpp \
ggml/src/ggml-vulkan.h
ggml/include/ggml-vulkan.h
$(CXX) $(CXXFLAGS) -c $< -o $@
endif # GGML_VULKAN
@ -764,7 +764,7 @@ endif # GGML_CUDA_NO_PEER_COPY
ggml/src/ggml-cuda.o: \
ggml/src/ggml-cuda.cu \
ggml/src/ggml-cuda.h \
ggml/include/ggml-cuda.h \
ggml/include/ggml.h \
ggml/include/ggml-backend.h \
ggml/src/ggml-backend-impl.h \
@ -796,7 +796,7 @@ endif # GGML_METAL
ifdef GGML_METAL
ggml/src/ggml-metal.o: \
ggml/src/ggml-metal.m \
ggml/src/ggml-metal.h \
ggml/include/ggml-metal.h \
ggml/include/ggml.h
$(CC) $(CFLAGS) -c $< -o $@
@ -957,7 +957,7 @@ ggml/src/ggml-quants.o: \
ggml/src/ggml-blas.o: \
ggml/src/ggml-blas.cpp \
ggml/src/ggml-blas.h
ggml/include/ggml-blas.h
$(CXX) $(CXXFLAGS) -c $< -o $@
ifndef GGML_NO_LLAMAFILE
@ -971,7 +971,7 @@ endif # GGML_NO_LLAMAFILE
ifdef GGML_RPC
ggml/src/ggml-rpc.o: \
ggml/src/ggml-rpc.cpp \
ggml/src/ggml-rpc.h
ggml/include/ggml-rpc.h
$(CXX) $(CXXFLAGS) -c $< -o $@
endif # GGML_RPC
@ -999,8 +999,8 @@ src/llama.o: \
src/llama.cpp \
src/unicode.h \
include/llama.h \
ggml/src/ggml-cuda.h \
ggml/src/ggml-metal.h \
ggml/include/ggml-cuda.h \
ggml/include/ggml-metal.h \
ggml/include/ggml.h \
ggml/include/ggml-alloc.h \
ggml/include/ggml-backend.h

View file

@ -8,7 +8,9 @@
#include "ggml.h"
#include "ggml-backend.h"
#include "ggml-sycl/presets.hpp"
#define GGML_SYCL_NAME "SYCL"
#define GGML_SYCL_MAX_DEVICES 48
#ifdef __cplusplus
extern "C" {

View file

@ -47,7 +47,7 @@ if (GGML_METAL)
find_library(METALKIT_FRAMEWORK MetalKit REQUIRED)
message(STATUS "Metal framework found")
set(GGML_HEADERS_METAL ggml-metal.h)
set(GGML_HEADERS_METAL ../include/ggml-metal.h)
set(GGML_SOURCES_METAL ggml-metal.m)
list(APPEND GGML_CDEF_PUBLIC GGML_USE_METAL)
@ -225,7 +225,7 @@ if (GGML_BLAS)
add_compile_definitions(GGML_BLAS_USE_MKL)
endif()
set(GGML_HEADERS_BLAS ggml-blas.h)
set(GGML_HEADERS_BLAS ../include/ggml-blas.h)
set(GGML_SOURCES_BLAS ggml-blas.cpp)
set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} ${BLAS_LIBRARIES})
@ -271,7 +271,7 @@ if (GGML_CUDA)
enable_language(CUDA)
file(GLOB GGML_HEADERS_CUDA "ggml-cuda/*.cuh")
list(APPEND GGML_HEADERS_CUDA "ggml-cuda.h")
list(APPEND GGML_HEADERS_CUDA "../include/ggml-cuda.h")
file(GLOB GGML_SOURCES_CUDA "ggml-cuda/*.cu")
list(APPEND GGML_SOURCES_CUDA "ggml-cuda.cu")
@ -396,7 +396,7 @@ if (GGML_HIPBLAS)
message(STATUS "HIP and hipBLAS found")
file(GLOB GGML_HEADERS_ROCM "ggml-cuda/*.cuh")
list(APPEND GGML_HEADERS_ROCM "ggml-cuda.h")
list(APPEND GGML_HEADERS_ROCM "../include/ggml-cuda.h")
file(GLOB GGML_SOURCES_ROCM "ggml-cuda/*.cu")
list(APPEND GGML_SOURCES_ROCM "ggml-cuda.cu")
@ -489,7 +489,7 @@ if (GGML_SYCL)
endif()
file(GLOB GGML_HEADERS_SYCL "ggml-sycl/*.hpp")
list(APPEND GGML_HEADERS_SYCL "ggml-sycl.h")
list(APPEND GGML_HEADERS_SYCL "../include/ggml-sycl.h")
file(GLOB GGML_SOURCES_SYCL "ggml-sycl/*.cpp")
list(APPEND GGML_SOURCES_SYCL "ggml-sycl.cpp")
@ -517,7 +517,7 @@ if (GGML_RPC)
set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} ws2_32)
endif()
set(GGML_HEADERS_RPC ggml-rpc.h)
set(GGML_HEADERS_RPC ../include/ggml-rpc.h)
set(GGML_SOURCES_RPC ggml-rpc.cpp)
endif()
@ -527,7 +527,7 @@ if (GGML_VULKAN)
if (Vulkan_FOUND)
message(STATUS "Vulkan found")
set(GGML_HEADERS_VULKAN ggml-vulkan.h)
set(GGML_HEADERS_VULKAN ../include/ggml-vulkan.h)
set(GGML_SOURCES_VULKAN ggml-vulkan.cpp)
list(APPEND GGML_CDEF_PUBLIC GGML_USE_VULKAN)
@ -713,7 +713,7 @@ if (GGML_KOMPUTE)
# Add the stamp to the main sources to ensure dependency tracking
set(GGML_SOURCES_KOMPUTE ggml-kompute.cpp ${CMAKE_CURRENT_BINARY_DIR}/ggml-kompute.stamp)
set(GGML_HEADERS_KOMPUTE ggml-kompute.h ${CMAKE_CURRENT_BINARY_DIR}/ggml-kompute.stamp)
set(GGML_HEADERS_KOMPUTE ../include/ggml-kompute.h ${CMAKE_CURRENT_BINARY_DIR}/ggml-kompute.stamp)
list(APPEND GGML_CDEF_PUBLIC GGML_USE_KOMPUTE)
@ -1155,8 +1155,9 @@ if (EMSCRIPTEN)
endif()
target_compile_definitions(ggml PUBLIC ${GGML_CDEF_PUBLIC})
target_include_directories(ggml PUBLIC . ../include ${GGML_EXTRA_INCLUDES})
target_compile_features (ggml PUBLIC c_std_11) # don't bump
target_include_directories(ggml PUBLIC ../include)
target_include_directories(ggml PRIVATE . ${GGML_EXTRA_INCLUDES})
target_compile_features (ggml PRIVATE c_std_11) # don't bump
target_link_libraries(ggml PRIVATE Threads::Threads ${GGML_EXTRA_LIBS})

View file

@ -37,6 +37,7 @@
#include "ggml-backend-impl.h"
#include "ggml-sycl/backend.hpp"
#include "ggml-sycl/presets.hpp"
bool ggml_sycl_loaded(void);
void ggml_sycl_free_data(struct ggml_tensor * tensor);

View file

@ -17,6 +17,7 @@
#include <iostream>
#include "dpct/helper.hpp"
#include "ggml-sycl.h"
#include "presets.hpp"
#define GGML_COMMON_DECL_SYCL

View file

@ -15,8 +15,6 @@
#define GGML_SYCL_MAX_STREAMS 8
#define GGML_SYCL_MAX_BUFFERS 256
#define GGML_SYCL_MAX_DEVICES 48
#define GGML_SYCL_NAME "SYCL"
#define WARP_SIZE 32
#define MATRIX_ROW_PADDING 512 // last row of quant. matrices is a multiple of this to avoid out-of-bounds memory accesses

View file

@ -107,24 +107,24 @@ if [ -f $SRC_LLAMA/ggml-src.patch ]; then
# src/ggml-common.h -> ggml/src/ggml-common.h
# src/ggml-cuda/* -> ggml/src/ggml-cuda/
# src/ggml-cuda.cu -> ggml/src/ggml-cuda.cu
# src/ggml-cuda.h -> ggml/src/ggml-cuda.h
# src/ggml-impl.h -> ggml/src/ggml-impl.h
# src/ggml-kompute.cpp -> ggml/src/ggml-kompute.cpp
# src/ggml-kompute.h -> ggml/src/ggml-kompute.h
# src/ggml-metal.h -> ggml/src/ggml-metal.h
# src/ggml-metal.m -> ggml/src/ggml-metal.m
# src/ggml-quants.c -> ggml/src/ggml-quants.c
# src/ggml-quants.h -> ggml/src/ggml-quants.h
# src/ggml-rpc.cpp -> ggml/src/ggml-rpc.cpp
# src/ggml-rpc.h -> ggml/src/ggml-rpc.h
# src/ggml-sycl.cpp -> ggml/src/ggml-sycl.cpp
# src/ggml-sycl.h -> ggml/src/ggml-sycl.h
# src/ggml-vulkan.cpp -> ggml/src/ggml-vulkan.cpp
# src/ggml-vulkan.h -> ggml/src/ggml-vulkan.h
#
# include/ggml/ggml.h -> ggml/include/ggml.h
# include/ggml/ggml-alloc.h -> ggml/include/ggml-alloc.h
# include/ggml/ggml-backend.h -> ggml/include/ggml-backend.h
# include/ggml-cuda.h -> ggml/include/ggml-cuda.h
# include/ggml-kompute.h -> ggml/include/ggml-kompute.h
# include/ggml-metal.h -> ggml/include/ggml-metal.h
# include/ggml-rpc.h -> ggml/include/ggml-rpc.h
# include/ggml-sycl.h -> ggml/include/ggml-sycl.h
# include/ggml-vulkan.h -> ggml/include/ggml-vulkan.h
#
# tests/test-opt.cpp -> tests/test-opt.cpp
# tests/test-grad0.cpp -> tests/test-grad0.cpp
@ -146,20 +146,20 @@ if [ -f $SRC_LLAMA/ggml-src.patch ]; then
-e 's/src\/ggml-common\.h/ggml/src/ggml-common.h/g' \
-e 's/src\/ggml-cuda\//ggml-cuda\//g' \
-e 's/src\/ggml-cuda\.cu/ggml/src/ggml-cuda.cu/g' \
-e 's/src\/ggml-cuda\.h/ggml/src/ggml-cuda.h/g' \
-e 's/src\/ggml-impl\.h/ggml/src/ggml-impl.h/g' \
-e 's/src\/ggml-kompute\.cpp/ggml/src/ggml-kompute.cpp/g' \
-e 's/src\/ggml-kompute\.h/ggml/src/ggml-kompute.h/g' \
-e 's/src\/ggml-metal\.h/ggml/src/ggml-metal.h/g' \
-e 's/src\/ggml-metal\.m/ggml/src/ggml-metal.m/g' \
-e 's/src\/ggml-quants\.c/ggml/src/ggml-quants.c/g' \
-e 's/src\/ggml-quants\.h/ggml/src/ggml-quants.h/g' \
-e 's/src\/ggml-rpc\.cpp/ggml/src/ggml-rpc.cpp/g' \
-e 's/src\/ggml-rpc\.h/ggml/src/ggml-rpc.h/g' \
-e 's/src\/ggml-sycl\.cpp/ggml/src/ggml-sycl.cpp/g' \
-e 's/src\/ggml-sycl\.h/ggml/src/ggml-sycl.h/g' \
-e 's/src\/ggml-vulkan\.cpp/ggml/src/ggml-vulkan.cpp/g' \
-e 's/src\/ggml-vulkan\.h/ggml/src/ggml-vulkan.h/g' \
-e 's/include\/ggml-cuda\.h/ggml/include/ggml-cuda.h/g' \
-e 's/include\/ggml-kompute\.h/ggml/include/ggml-kompute.h/g' \
-e 's/include\/ggml-metal\.h/ggml/include/ggml-metal.h/g' \
-e 's/include\/ggml-rpc\.h/ggml/include/ggml-rpc.h/g' \
-e 's/include\/ggml-sycl\.h/ggml/include/ggml-sycl.h/g' \
-e 's/include\/ggml-vulkan\.h/ggml/include/ggml-vulkan.h/g' \
-e 's/include\/ggml\/ggml\.h/ggml/include/ggml.h/g' \
-e 's/include\/ggml\/ggml-alloc\.h/ggml/include/ggml-alloc.h/g' \
-e 's/include\/ggml\/ggml-backend\.h/ggml/include/ggml-backend.h/g' \

View file

@ -11,25 +11,25 @@ cp -rpv ../ggml/src/ggml-backend.c ./ggml/src/ggml-backend.c
cp -rpv ../ggml/src/ggml-common.h ./ggml/src/ggml-common.h
cp -rpv ../ggml/src/ggml-cuda/* ./ggml/src/ggml-cuda/
cp -rpv ../ggml/src/ggml-cuda.cu ./ggml/src/ggml-cuda.cu
cp -rpv ../ggml/src/ggml-cuda.h ./ggml/src/ggml-cuda.h
cp -rpv ../ggml/src/ggml-impl.h ./ggml/src/ggml-impl.h
cp -rpv ../ggml/src/ggml-kompute.cpp ./ggml/src/ggml-kompute.cpp
cp -rpv ../ggml/src/ggml-kompute.h ./ggml/src/ggml-kompute.h
cp -rpv ../ggml/src/ggml-metal.h ./ggml/src/ggml-metal.h
cp -rpv ../ggml/src/ggml-metal.m ./ggml/src/ggml-metal.m
cp -rpv ../ggml/src/ggml-metal.metal ./ggml/src/ggml-metal.metal
cp -rpv ../ggml/src/ggml-quants.c ./ggml/src/ggml-quants.c
cp -rpv ../ggml/src/ggml-quants.h ./ggml/src/ggml-quants.h
cp -rpv ../ggml/src/ggml-rpc.cpp ./ggml/src/ggml-rpc.cpp
cp -rpv ../ggml/src/ggml-rpc.h ./ggml/src/ggml-rpc.h
cp -rpv ../ggml/src/ggml-sycl.cpp ./ggml/src/ggml-sycl.cpp
cp -rpv ../ggml/src/ggml-sycl.h ./ggml/src/ggml-sycl.h
cp -rpv ../ggml/src/ggml-vulkan.cpp ./ggml/src/ggml-vulkan.cpp
cp -rpv ../ggml/src/ggml-vulkan.h ./ggml/src/ggml-vulkan.h
cp -rpv ../ggml/include/ggml.h ./ggml/include/ggml.h
cp -rpv ../ggml/include/ggml-alloc.h ./ggml/include/ggml-alloc.h
cp -rpv ../ggml/include/ggml-backend.h ./ggml/include/ggml-backend.h
cp -rpv ../ggml/include/ggml-cuda.h ./ggml/include/ggml-cuda.h
cp -rpv ../ggml/include/ggml-kompute.h ./ggml/include/ggml-kompute.h
cp -rpv ../ggml/include/ggml-metal.h ./ggml/include/ggml-metal.h
cp -rpv ../ggml/include/ggml-rpc.h ./ggml/include/ggml-rpc.h
cp -rpv ../ggml/include/ggml-sycl.h ./ggml/include/ggml-sycl.h
cp -rpv ../ggml/include/ggml-vulkan.h ./ggml/include/ggml-vulkan.h
cp -rpv ../ggml/tests/test-opt.cpp ./tests/test-opt.cpp
cp -rpv ../ggml/tests/test-grad0.cpp ./tests/test-grad0.cpp

View file

@ -1 +1 @@
../ggml/src/ggml-metal.h
../ggml/include/ggml-metal.h

View file

@ -1,7 +1,6 @@
#include <ggml.h>
#include <ggml-alloc.h>
#include <ggml-backend.h>
#include <ggml-backend-impl.h>
#include <algorithm>
#include <array>