Skip to content

Commit

Permalink
Try restricting compilation to ARM64.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMage committed Jul 24, 2024
1 parent bfbb11f commit 1790ed9
Show file tree
Hide file tree
Showing 28 changed files with 110 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ggml/include/ggml-alloc.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#include "ggml.h"
Expand Down Expand Up @@ -74,3 +76,5 @@ GGML_API struct ggml_backend_buffer * ggml_backend_alloc_ctx_tensors(struct ggml
#ifdef __cplusplus
}
#endif

#endif
4 changes: 4 additions & 0 deletions ggml/include/ggml-backend.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#include "ggml.h"
Expand Down Expand Up @@ -236,3 +238,5 @@ extern "C" {
#ifdef __cplusplus
}
#endif

#endif
4 changes: 4 additions & 0 deletions ggml/src/ggml-aarch64.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

// SPDX-FileCopyrightText: Copyright 2024 Arm Ltd.
#define GGML_COMMON_IMPL_C
#include "ggml-common.h"
Expand Down Expand Up @@ -2191,3 +2193,5 @@ void ggml_gemm_q4_0_8x8_q8_0(int n, float * restrict s, size_t bs, const void *
}
#endif
}

#endif
3 changes: 3 additions & 0 deletions ggml/src/ggml-aarch64.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

// SPDX-FileCopyrightText: Copyright 2024 Arm Ltd.
#pragma once

Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions ggml/src/ggml-alloc.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#include "ggml-alloc.h"
#include "ggml-backend-impl.h"
#include "ggml.h"
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions ggml/src/ggml-backend.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#include "ggml-backend-impl.h"
#include "ggml-alloc.h"
#include "ggml-impl.h"
Expand Down Expand Up @@ -2232,3 +2234,5 @@ bool ggml_backend_compare_graph_backend(ggml_backend_t backend1, ggml_backend_t

return true;
}

#endif
4 changes: 4 additions & 0 deletions ggml/src/ggml-blas.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#include "ggml-blas.h"
#include "ggml-backend-impl.h"

Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions ggml/src/ggml-cann.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

/*
* Copyright (c) 2023-2024 The ggml authors
*
Expand Down Expand Up @@ -2021,3 +2023,5 @@ GGML_CALL int ggml_backend_cann_reg_devices() {
}
return device_count;
}

#endif
4 changes: 4 additions & 0 deletions ggml/src/ggml-common.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#ifndef GGML_COMMON_DECL

#if defined(GGML_COMMON_DECL_C)
Expand Down Expand Up @@ -1827,3 +1829,5 @@ GGML_TABLE_END()

#endif // GGML_COMMON_IMPL
#endif // GGML_COMMON_IMPL

#endif
4 changes: 4 additions & 0 deletions ggml/src/ggml-impl.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#include "ggml.h"
Expand Down Expand Up @@ -653,3 +655,5 @@ size_t ggml_hash_find_or_insert( struct ggml_hash_set hash_set, struct ggml
#ifdef __cplusplus
}
#endif

#endif
4 changes: 4 additions & 0 deletions ggml/src/ggml-metal.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#import "ggml-metal.h"

#import "ggml-backend-impl.h"
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions ggml/src/ggml-quants.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#define GGML_COMMON_IMPL_C
#include "ggml-common.h"

Expand Down Expand Up @@ -14858,3 +14860,5 @@ bool ggml_validate_row_data(enum ggml_type type, const void * data, size_t nbyte

return true;
}

#endif
4 changes: 4 additions & 0 deletions ggml/src/ggml-quants.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#define GGML_COMMON_DECL_C
Expand Down Expand Up @@ -130,3 +132,5 @@ void iq3xs_free_impl(int grid_size);
#ifdef __cplusplus
}
#endif

#endif
4 changes: 4 additions & 0 deletions ggml/src/ggml.c
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -22042,3 +22044,5 @@ int ggml_cpu_has_matmul_int8(void) {
}

////////////////////////////////////////////////////////////////////////////////

#endif
4 changes: 4 additions & 0 deletions ggml/src/llamafile/sgemm.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

// Copyright 2024 Mozilla Foundation
//
// Permission is hereby granted, free of charge, to any person obtaining
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions include/llama.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#ifndef LLAMA_H
#define LLAMA_H

Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/llama-grammar.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#include "llama-grammar.h"

#include "llama-vocab.h"
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/llama-grammar.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#include "llama-impl.h"
Expand Down Expand Up @@ -39,3 +41,5 @@ void llama_grammar_accept_token_impl(
const struct llama_vocab * vocab,
const struct llama_sampling * smpl,
llama_token token);

#endif
4 changes: 4 additions & 0 deletions src/llama-impl.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#define LLAMA_API_INTERNAL
Expand All @@ -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
4 changes: 4 additions & 0 deletions src/llama-sampling.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#include "llama-sampling.h"

#include <algorithm>
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/llama-sampling.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#include "llama-impl.h"
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/llama-vocab.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#include "llama-vocab.h"

#include "unicode.h"
Expand Down Expand Up @@ -1719,3 +1721,5 @@ int32_t llama_detokenize_impl(

return total <= text_len_max ? total : -total;
}

#endif
4 changes: 4 additions & 0 deletions src/llama-vocab.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#include "llama-impl.h"
Expand Down Expand Up @@ -128,3 +130,5 @@ int32_t llama_detokenize_impl(
int32_t text_len_max,
bool remove_special,
bool unparse_special);

#endif
4 changes: 4 additions & 0 deletions src/llama.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#include "llama-impl.h"
#include "llama-vocab.h"
#include "llama-grammar.h"
Expand Down Expand Up @@ -19209,3 +19211,5 @@ void llama_log_callback_default(ggml_log_level level, const char * text, void *
fputs(text, stderr);
fflush(stderr);
}

#endif
4 changes: 4 additions & 0 deletions src/unicode-data.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

// generated with scripts/gen-unicode-data.py

#include "unicode-data.h"
Expand Down Expand Up @@ -7030,3 +7032,5 @@ const std::vector<range_nfd> unicode_ranges_nfd = { // start, last, nfd
{0x02FA1C, 0x02FA1C, 0x009F3B},
{0x02FA1D, 0x02FA1D, 0x02A600},
};

#endif
4 changes: 4 additions & 0 deletions src/unicode-data.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#include <cstdint>
Expand All @@ -18,3 +20,5 @@ extern const std::unordered_set<uint32_t> unicode_set_whitespace;
extern const std::unordered_map<uint32_t, uint32_t> unicode_map_lowercase;
extern const std::unordered_map<uint32_t, uint32_t> unicode_map_uppercase;
extern const std::vector<range_nfd> unicode_ranges_nfd;

#endif
4 changes: 4 additions & 0 deletions src/unicode.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#if defined(_MSC_VER)
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
#endif
Expand Down Expand Up @@ -816,3 +818,5 @@ std::vector<std::string> unicode_regex_split(const std::string & text, const std

return unicode_byte_encoding_process(bpe_words);
}

#endif
4 changes: 4 additions & 0 deletions src/unicode.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(__arm64__)

#pragma once

#include <cstdint>
Expand Down Expand Up @@ -65,3 +67,5 @@ uint8_t unicode_utf8_to_byte(const std::string & utf8);
uint32_t unicode_tolower(uint32_t cp);

std::vector<std::string> unicode_regex_split(const std::string & text, const std::vector<std::string> & regex_exprs);

#endif

0 comments on commit 1790ed9

Please sign in to comment.