From 927bc26e039e6f074716cbc26b71226ff8901e8b Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Wed, 22 Mar 2023 10:05:33 -0400 Subject: [PATCH 1/2] Add a Package.swift for SwiftPM support --- .gitignore | 5 +++++ Package.swift | 20 ++++++++++++++++++++ llama.h | 2 +- spm-headers/llama.h | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Package.swift create mode 120000 spm-headers/llama.h diff --git a/.gitignore b/.gitignore index 3087b0ea5c598..a50bd8403c065 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ .vscode/ .DS_Store +.build/ build/ build-em/ build-debug/ @@ -25,3 +26,7 @@ compile_commands.json .envrc .direnv/ + +.venv +__pycache__ +.swiftpm diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000000000..de0b668048611 --- /dev/null +++ b/Package.swift @@ -0,0 +1,20 @@ +// swift-tools-version:5.3 + +import PackageDescription + +let package = Package( + name: "llama", + products: [ + .library(name: "llama", targets: ["llama"]), + ], + targets: [ + .target( + name: "llama", + path: ".", + exclude: ["main.cpp", "tests", "quantize.cpp"], + publicHeadersPath: "spm-headers", + cSettings: [.unsafeFlags(["-Wno-shorten-64-to-32"])] + ), + ], + cxxLanguageStandard: .cxx11 +) diff --git a/llama.h b/llama.h index 3df9ed1fdd82c..1afb2e0a31e28 100644 --- a/llama.h +++ b/llama.h @@ -117,7 +117,7 @@ extern "C" { // TODO: improve the last_n_tokens interface ? LLAMA_API llama_token llama_sample_top_p_top_k( - llama_context * ctx, + struct llama_context * ctx, const llama_token * last_n_tokens_data, int last_n_tokens_size, int top_k, diff --git a/spm-headers/llama.h b/spm-headers/llama.h new file mode 120000 index 0000000000000..9acceb980c264 --- /dev/null +++ b/spm-headers/llama.h @@ -0,0 +1 @@ +../llama.h \ No newline at end of file From d6aa749ccfd8dc6bb2f703a1d53cfe3adc637c07 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Thu, 23 Mar 2023 13:58:47 -0400 Subject: [PATCH 2/2] Swap from exclusions to allowlist --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index de0b668048611..79d13c82d9b87 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( .target( name: "llama", path: ".", - exclude: ["main.cpp", "tests", "quantize.cpp"], + sources: ["ggml.c", "llama.cpp"], publicHeadersPath: "spm-headers", cSettings: [.unsafeFlags(["-Wno-shorten-64-to-32"])] ),