2023-03-28 16:39:01 +00:00
|
|
|
// swift-tools-version:5.3
|
|
|
|
|
|
|
|
import PackageDescription
|
|
|
|
|
2023-09-09 09:12:10 +00:00
|
|
|
#if arch(arm) || arch(arm64)
|
|
|
|
let platforms: [SupportedPlatform]? = [
|
|
|
|
.macOS(.v11),
|
|
|
|
.iOS(.v14),
|
|
|
|
.watchOS(.v4),
|
|
|
|
.tvOS(.v14)
|
|
|
|
]
|
|
|
|
let exclude: [String] = []
|
2023-09-29 05:25:13 +00:00
|
|
|
let additionalSources: [String] = ["ggml-metal.m", "ggml-metal.metal"]
|
2023-09-09 09:12:10 +00:00
|
|
|
let additionalSettings: [CSetting] = [
|
|
|
|
.unsafeFlags(["-fno-objc-arc"]),
|
|
|
|
.define("GGML_SWIFT"),
|
|
|
|
.define("GGML_USE_METAL")
|
|
|
|
]
|
|
|
|
#else
|
|
|
|
let platforms: [SupportedPlatform]? = nil
|
|
|
|
let exclude: [String] = ["ggml-metal.metal"]
|
|
|
|
let additionalSources: [String] = []
|
|
|
|
let additionalSettings: [CSetting] = []
|
|
|
|
#endif
|
|
|
|
|
2023-03-28 16:39:01 +00:00
|
|
|
let package = Package(
|
|
|
|
name: "llama",
|
2023-09-09 09:12:10 +00:00
|
|
|
platforms: platforms,
|
2023-03-28 16:39:01 +00:00
|
|
|
products: [
|
|
|
|
.library(name: "llama", targets: ["llama"]),
|
|
|
|
],
|
|
|
|
targets: [
|
|
|
|
.target(
|
|
|
|
name: "llama",
|
|
|
|
path: ".",
|
2023-09-09 09:12:10 +00:00
|
|
|
exclude: exclude,
|
2023-09-03 06:21:05 +00:00
|
|
|
sources: [
|
|
|
|
"ggml.c",
|
|
|
|
"llama.cpp",
|
|
|
|
"ggml-alloc.c",
|
2023-09-09 09:12:10 +00:00
|
|
|
"k_quants.c",
|
|
|
|
] + additionalSources,
|
2023-03-28 16:39:01 +00:00
|
|
|
publicHeadersPath: "spm-headers",
|
2023-09-03 06:21:05 +00:00
|
|
|
cSettings: [
|
|
|
|
.unsafeFlags(["-Wno-shorten-64-to-32"]),
|
|
|
|
.define("GGML_USE_K_QUANTS"),
|
2023-09-29 05:25:13 +00:00
|
|
|
.define("GGML_USE_ACCELERATE"),
|
|
|
|
.define("ACCELERATE_NEW_LAPACK"),
|
2023-09-27 15:34:32 +00:00
|
|
|
.define("ACCELERATE_LAPACK_ILP64")
|
2023-09-09 09:12:10 +00:00
|
|
|
] + additionalSettings,
|
2023-04-05 10:44:24 +00:00
|
|
|
linkerSettings: [
|
|
|
|
.linkedFramework("Accelerate")
|
|
|
|
]
|
2023-09-09 09:12:10 +00:00
|
|
|
)
|
2023-03-28 16:39:01 +00:00
|
|
|
],
|
|
|
|
cxxLanguageStandard: .cxx11
|
|
|
|
)
|