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-aarch64.c b/ggml/src/ggml-aarch64.c index 26535b1c432ba6..56ea5b2f3a2244 100644 --- a/ggml/src/ggml-aarch64.c +++ b/ggml/src/ggml-aarch64.c @@ -1,3 +1,5 @@ +#if defined(__arm64__) + // SPDX-FileCopyrightText: Copyright 2024 Arm Ltd. #define GGML_COMMON_IMPL_C #include "ggml-common.h" @@ -2191,3 +2193,5 @@ void ggml_gemm_q4_0_8x8_q8_0(int n, float * restrict s, size_t bs, const void * } #endif } + +#endif \ No newline at end of file diff --git a/ggml/src/ggml-aarch64.h b/ggml/src/ggml-aarch64.h index 517babaf1691bb..a7e6c65fb537d2 100644 --- a/ggml/src/ggml-aarch64.h +++ b/ggml/src/ggml-aarch64.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + // SPDX-FileCopyrightText: Copyright 2024 Arm Ltd. #pragma once @@ -37,3 +39,4 @@ void ggml_gemm_q4_0_8x8_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const vo } #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-blas.cpp b/ggml/src/ggml-blas.cpp index a37aa407282b94..7d4f24c4c09d17 100644 --- a/ggml/src/ggml-blas.cpp +++ b/ggml/src/ggml-blas.cpp @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #include "ggml-blas.h" #include "ggml-backend-impl.h" @@ -366,3 +368,5 @@ void ggml_backend_blas_set_n_threads(ggml_backend_t backend_blas, int n_threads) ggml_backend_blas_context * ctx = (ggml_backend_blas_context *)backend_blas->context; ctx->n_threads = n_threads; } + +#endif \ No newline at end of file diff --git a/ggml/src/ggml-cann.cpp b/ggml/src/ggml-cann.cpp index 9bf7e332a7e06e..d69564a34ab9ac 100644 --- a/ggml/src/ggml-cann.cpp +++ b/ggml/src/ggml-cann.cpp @@ -1,3 +1,5 @@ +#if defined(__arm64__) + /* * Copyright (c) 2023-2024 The ggml authors * @@ -2021,3 +2023,5 @@ GGML_CALL int ggml_backend_cann_reg_devices() { } return device_count; } + +#endif \ No newline at end of file diff --git a/ggml/src/ggml-common.h b/ggml/src/ggml-common.h index fafd5fa7ae000d..16de4fb4af0a60 100644 --- a/ggml/src/ggml-common.h +++ b/ggml/src/ggml-common.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #ifndef GGML_COMMON_DECL #if defined(GGML_COMMON_DECL_C) @@ -1827,3 +1829,5 @@ GGML_TABLE_END() #endif // GGML_COMMON_IMPL #endif // GGML_COMMON_IMPL + +#endif \ No newline at end of file diff --git a/ggml/src/ggml-impl.h b/ggml/src/ggml-impl.h index a2c8dbec0824f0..747985ea783559 100644 --- a/ggml/src/ggml-impl.h +++ b/ggml/src/ggml-impl.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #include "ggml.h" @@ -653,3 +655,5 @@ size_t ggml_hash_find_or_insert( struct ggml_hash_set hash_set, struct ggml #ifdef __cplusplus } #endif + +#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-grammar.cpp b/src/llama-grammar.cpp index bd9322e2fab09b..812ef363b5bc5d 100644 --- a/src/llama-grammar.cpp +++ b/src/llama-grammar.cpp @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #include "llama-grammar.h" #include "llama-vocab.h" @@ -537,3 +539,5 @@ void llama_grammar_accept_token_impl(struct llama_grammar * grammar, const struc smpl->t_sample_us += ggml_time_us() - t_start_sample_us; } + +#endif \ No newline at end of file diff --git a/src/llama-grammar.h b/src/llama-grammar.h index 8e578e09f8c2dc..f6e334fec7bd2b 100644 --- a/src/llama-grammar.h +++ b/src/llama-grammar.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #include "llama-impl.h" @@ -39,3 +41,5 @@ void llama_grammar_accept_token_impl( const struct llama_vocab * vocab, const struct llama_sampling * smpl, llama_token token); + +#endif \ No newline at end of file diff --git a/src/llama-impl.h b/src/llama-impl.h index dcc8c1c15a1b1e..fc911a03e53021 100644 --- a/src/llama-impl.h +++ b/src/llama-impl.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #define LLAMA_API_INTERNAL @@ -24,3 +26,5 @@ void llama_log_callback_default(ggml_log_level level, const char * text, void * #define LLAMA_LOG_INFO(...) llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__) #define LLAMA_LOG_WARN(...) llama_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__) #define LLAMA_LOG_ERROR(...) llama_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__) + +#endif \ No newline at end of file diff --git a/src/llama-sampling.cpp b/src/llama-sampling.cpp index 8910f6d6542e91..76fdf3811dea49 100644 --- a/src/llama-sampling.cpp +++ b/src/llama-sampling.cpp @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #include "llama-sampling.h" #include @@ -633,3 +635,5 @@ llama_token llama_sample_token_with_rng_impl(struct llama_sampling * smpl, llama llama_token llama_sample_token_impl(struct llama_sampling * smpl, llama_token_data_array * candidates) { return llama_sample_token_with_rng_impl(smpl, candidates, smpl->rng); } + +#endif \ No newline at end of file diff --git a/src/llama-sampling.h b/src/llama-sampling.h index f7f8e3ef706bc8..1965e847a5d073 100644 --- a/src/llama-sampling.h +++ b/src/llama-sampling.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #include "llama-impl.h" @@ -54,3 +56,4 @@ llama_token llama_sample_token_greedy_impl (struct llama_sampling * smpl, ll llama_token llama_sample_token_with_rng_impl (struct llama_sampling * smpl, llama_token_data_array * candidates, std::mt19937 & rng); llama_token llama_sample_token_impl (struct llama_sampling * smpl, llama_token_data_array * candidates); +#endif \ No newline at end of file diff --git a/src/llama-vocab.cpp b/src/llama-vocab.cpp index c482b36899a1cc..2a2562e5815872 100644 --- a/src/llama-vocab.cpp +++ b/src/llama-vocab.cpp @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #include "llama-vocab.h" #include "unicode.h" @@ -1719,3 +1721,5 @@ int32_t llama_detokenize_impl( return total <= text_len_max ? total : -total; } + +#endif \ No newline at end of file diff --git a/src/llama-vocab.h b/src/llama-vocab.h index 30b565d55dad5b..911bbedffe4065 100644 --- a/src/llama-vocab.h +++ b/src/llama-vocab.h @@ -1,3 +1,5 @@ +#if defined(__arm64__) + #pragma once #include "llama-impl.h" @@ -128,3 +130,5 @@ int32_t llama_detokenize_impl( int32_t text_len_max, bool remove_special, bool unparse_special); + +#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