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 Aug 1, 2024
1 parent bda44ec commit 08e4836
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 0 deletions.
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 @@ -1238,3 +1240,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 @@ -37,3 +39,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 @@ -19160,3 +19162,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 08e4836

Please sign in to comment.