From 4f0cb201b680af976b3bfe70612a91f8ce11ed1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=A4fe?= Date: Wed, 19 Jun 2024 17:21:55 +0200 Subject: [PATCH] Try restricting compilation to ARM64. --- ggml/include/ggml-alloc.h | 4 ++++ ggml/include/ggml-backend.h | 4 ++++ ggml/src/ggml-alloc.c | 4 ++++ ggml/src/ggml-backend.c | 4 ++++ ggml/src/ggml-metal.m | 4 ++++ ggml/src/ggml-quants.c | 4 ++++ ggml/src/ggml-quants.h | 4 ++++ ggml/src/ggml.c | 4 ++++ ggml/src/llamafile/sgemm.cpp | 4 ++++ include/llama.h | 4 ++++ src/llama.cpp | 4 ++++ src/unicode-data.cpp | 4 ++++ src/unicode-data.h | 4 ++++ src/unicode.cpp | 4 ++++ src/unicode.h | 4 ++++ 15 files changed, 60 insertions(+) diff --git a/ggml/include/ggml-alloc.h b/ggml/include/ggml-alloc.h index 434c13b34a929c..f5d5cf8c8d2c9d 100644 --- a/ggml/include/ggml-alloc.h +++ b/ggml/include/ggml-alloc.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #include "ggml.h" @@ -74,3 +76,5 @@ GGML_API struct ggml_backend_buffer * ggml_backend_alloc_ctx_tensors(struct ggml #ifdef __cplusplus } #endif + +#endif \ No newline at end of file diff --git a/ggml/include/ggml-backend.h b/ggml/include/ggml-backend.h index 5f3f1e286990e4..a280682fb79e22 100644 --- a/ggml/include/ggml-backend.h +++ b/ggml/include/ggml-backend.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #include "ggml.h" @@ -236,3 +238,5 @@ extern "C" { #ifdef __cplusplus } #endif + +#endif \ No newline at end of file diff --git a/ggml/src/ggml-alloc.c b/ggml/src/ggml-alloc.c index e176b883e38c50..cbcbbaa6351858 100644 --- a/ggml/src/ggml-alloc.c +++ b/ggml/src/ggml-alloc.c @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #include "ggml-alloc.h" #include "ggml-backend-impl.h" #include "ggml.h" @@ -1040,3 +1042,5 @@ ggml_backend_buffer_t ggml_backend_alloc_ctx_tensors_from_buft(struct ggml_conte ggml_backend_buffer_t ggml_backend_alloc_ctx_tensors(struct ggml_context * ctx, ggml_backend_t backend) { return ggml_backend_alloc_ctx_tensors_from_buft(ctx, ggml_backend_get_default_buffer_type(backend)); } + +#endif \ No newline at end of file diff --git a/ggml/src/ggml-backend.c b/ggml/src/ggml-backend.c index d39cfed8886f42..2803e235a6dc2b 100644 --- a/ggml/src/ggml-backend.c +++ b/ggml/src/ggml-backend.c @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #include "ggml-backend-impl.h" #include "ggml-alloc.h" #include "ggml-impl.h" @@ -2232,3 +2234,5 @@ bool ggml_backend_compare_graph_backend(ggml_backend_t backend1, ggml_backend_t return true; } + +#endif \ No newline at end of file diff --git a/ggml/src/ggml-metal.m b/ggml/src/ggml-metal.m index 6a906fbf79a58a..93d0e51a504f60 100644 --- a/ggml/src/ggml-metal.m +++ b/ggml/src/ggml-metal.m @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #import "ggml-metal.h" #import "ggml-backend-impl.h" @@ -3267,3 +3269,5 @@ GGML_CALL ggml_backend_t ggml_backend_reg_metal_init(const char * params, void * GGML_UNUSED(params); GGML_UNUSED(user_data); } + +#endif \ No newline at end of file diff --git a/ggml/src/ggml-quants.c b/ggml/src/ggml-quants.c index 47418597c00d8f..5cc9bec777aa2a 100644 --- a/ggml/src/ggml-quants.c +++ b/ggml/src/ggml-quants.c @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #define GGML_COMMON_IMPL_C #include "ggml-common.h" @@ -14858,3 +14860,5 @@ bool ggml_validate_row_data(enum ggml_type type, const void * data, size_t nbyte return true; } + +#endif \ No newline at end of file diff --git a/ggml/src/ggml-quants.h b/ggml/src/ggml-quants.h index 88b1f3269646d8..c30125887eae63 100644 --- a/ggml/src/ggml-quants.h +++ b/ggml/src/ggml-quants.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #define GGML_COMMON_DECL_C @@ -130,3 +132,5 @@ void iq3xs_free_impl(int grid_size); #ifdef __cplusplus } #endif + +#endif diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index dbb3a3ebe1cca4..d6770f8febd2a3 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnings on Windows #define _USE_MATH_DEFINES // For M_PI on MSVC @@ -22042,3 +22044,5 @@ int ggml_cpu_has_matmul_int8(void) { } //////////////////////////////////////////////////////////////////////////////// + +#endif diff --git a/ggml/src/llamafile/sgemm.cpp b/ggml/src/llamafile/sgemm.cpp index 6626ceb26213f2..a5cfc33140378f 100644 --- a/ggml/src/llamafile/sgemm.cpp +++ b/ggml/src/llamafile/sgemm.cpp @@ -1,3 +1,5 @@ +#if defined(__arm64__) + // Copyright 2024 Mozilla Foundation // // Permission is hereby granted, free of charge, to any person obtaining @@ -1025,3 +1027,5 @@ bool llamafile_sgemm(int64_t m, int64_t n, int64_t k, const void *A, int64_t lda (void)Btype; (void)Ctype; } + +#endif \ No newline at end of file diff --git a/include/llama.h b/include/llama.h index e68cd807e63bde..96ca61d2f9b064 100644 --- a/include/llama.h +++ b/include/llama.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #ifndef LLAMA_H #define LLAMA_H @@ -1231,3 +1233,5 @@ llama_token llama_sample_token_with_rng(struct llama_context * ctx, llama_token_ #endif // LLAMA_API_INTERNAL #endif // LLAMA_H + +#endif \ No newline at end of file diff --git a/src/llama.cpp b/src/llama.cpp index 40c5e8e8d4b3be..f5fee906f66cf8 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #include "llama-impl.h" #include "llama-vocab.h" #include "llama-grammar.h" @@ -19209,3 +19211,5 @@ void llama_log_callback_default(ggml_log_level level, const char * text, void * fputs(text, stderr); fflush(stderr); } + +#endif \ No newline at end of file diff --git a/src/unicode-data.cpp b/src/unicode-data.cpp index 02bdf782380fe7..bed427306ceb43 100644 --- a/src/unicode-data.cpp +++ b/src/unicode-data.cpp @@ -1,3 +1,5 @@ +#if defined(__arm64__) + // generated with scripts/gen-unicode-data.py #include "unicode-data.h" @@ -7030,3 +7032,5 @@ const std::vector unicode_ranges_nfd = { // start, last, nfd {0x02FA1C, 0x02FA1C, 0x009F3B}, {0x02FA1D, 0x02FA1D, 0x02A600}, }; + +#endif diff --git a/src/unicode-data.h b/src/unicode-data.h index e27fe1770710a3..1199bac807dc9e 100644 --- a/src/unicode-data.h +++ b/src/unicode-data.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #include @@ -18,3 +20,5 @@ extern const std::unordered_set unicode_set_whitespace; extern const std::unordered_map unicode_map_lowercase; extern const std::unordered_map unicode_map_uppercase; extern const std::vector unicode_ranges_nfd; + +#endif \ No newline at end of file diff --git a/src/unicode.cpp b/src/unicode.cpp index 46650bff06d15e..09671bcf2aaa40 100644 --- a/src/unicode.cpp +++ b/src/unicode.cpp @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #if defined(_MSC_VER) #define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING #endif @@ -816,3 +818,5 @@ std::vector unicode_regex_split(const std::string & text, const std return unicode_byte_encoding_process(bpe_words); } + +#endif \ No newline at end of file diff --git a/src/unicode.h b/src/unicode.h index 008532a242ab8d..7f7d619923fa90 100644 --- a/src/unicode.h +++ b/src/unicode.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #include @@ -65,3 +67,5 @@ uint8_t unicode_utf8_to_byte(const std::string & utf8); uint32_t unicode_tolower(uint32_t cp); std::vector unicode_regex_split(const std::string & text, const std::vector & regex_exprs); + +#endif \ No newline at end of file