4 Star 3 Fork 1

Gitee 极速下载/ggml

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/ggerganov/ggml
克隆/下载
build.zig 4.65 KB
一键复制 编辑 原始数据 按行查看 历史
Emmanuel Durand 提交于 2024-06-05 04:41 . zig : fix build (#840)
const std = @import("std");
const builtin = @import("builtin");
// Zig Version: 0.11.0
// Zig Build Command: zig build
// Zig Run Command: zig build -h
// zig build run_gpt-j
// zig build run_mnist
// zig build run_magika
// zig build run_test-grad0
// zig build run_test-mul-mat0
// zig build run_test-mul-mat2
// zig build run_test-opt
// zig build run_test-vec1
// zig build run_test0
// zig build run_test1
// zig build run_test2
// zig build run_test3
// zig build run_zig_test0
// zig build run_zig_test1
// zig build run_zig_test2
// zig build run_zig_test3
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{
.name = "ggml",
.target = target,
.optimize = optimize,
});
lib.addIncludePath(b.path("./include"));
lib.addIncludePath(b.path("./include/ggml"));
lib.addCSourceFiles(.{ .files = &.{
"src/ggml.c",
"src/ggml-alloc.c",
"src/ggml-backend.c",
"src/ggml-quants.c",
}, .flags = &.{
"-std=c11",
"-D_GNU_SOURCE",
"-D_XOPEN_SOURCE=600",
} });
lib.linkLibC();
lib.linkLibCpp();
b.installArtifact(lib);
// examples
const examples = .{
"gpt-j",
"magika",
"mnist",
// "whisper",
};
inline for (examples) |name| {
const exe = b.addExecutable(.{
.name = name,
.target = target,
.optimize = optimize,
});
exe.addIncludePath(b.path("./include"));
exe.addIncludePath(b.path("./include/ggml"));
exe.addIncludePath(b.path("./examples"));
// exe.addIncludePath("./examples/whisper");
exe.addCSourceFiles(.{
.files = &.{
std.fmt.comptimePrint("examples/{s}/main.cpp", .{name}),
"examples/common.cpp",
"examples/common-ggml.cpp",
// "examples/whisper/whisper.cpp",
},
.flags = &.{"-std=c++11"},
});
exe.linkLibrary(lib);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| run_cmd.addArgs(args);
const run_step = b.step("run_" ++ name, "Run examples");
run_step.dependOn(&run_cmd.step);
}
// tests
const tests = if (builtin.target.cpu.arch == .x86_64) .{
// "test-blas0",
// "test-grad0",
"test-mul-mat0",
// "test-mul-mat1",
"test-mul-mat2",
// "test-opt",
// "test-svd0",
"test-vec0",
"test-vec1",
// "test-vec2",
"test0",
"test1",
"test2",
"test3",
} else .{
// "test-blas0",
// "test-grad0",
"test-mul-mat0",
// "test-mul-mat1",
"test-mul-mat2",
// "test-opt",
// "test-svd0",
// "test-vec0",
// "test-vec1",
// "test-vec2",
"test0",
"test1",
"test2",
"test3",
};
inline for (tests) |name| {
const exe = b.addExecutable(.{
.name = name,
.target = target,
.optimize = optimize,
});
exe.addIncludePath(b.path("./include"));
exe.addIncludePath(b.path("./include/ggml"));
exe.addCSourceFiles(.{ .files = &.{
std.fmt.comptimePrint("tests/{s}.c", .{name}),
}, .flags = &.{
"-std=c11",
} });
exe.linkLibrary(lib);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| run_cmd.addArgs(args);
const run_step = b.step("run_" ++ name, "Run tests");
run_step.dependOn(&run_cmd.step);
}
// zig_tests
const zig_tests = .{
"test0",
"test1",
"test2",
"test3",
};
inline for (zig_tests) |name| {
const exe = b.addExecutable(.{
.name = name,
.root_source_file = b.path(std.fmt.comptimePrint("tests/{s}.zig", .{name})),
.target = target,
.optimize = optimize,
});
exe.addIncludePath(b.path("./include"));
exe.addIncludePath(b.path("./include/ggml"));
exe.linkLibrary(lib);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| run_cmd.addArgs(args);
const run_step = b.step("run_zig_" ++ name, "Run zig_tests");
run_step.dependOn(&run_cmd.step);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/mirrors/ggml.git
[email protected]:mirrors/ggml.git
mirrors
ggml
ggml
master

搜索帮助