@lgrammel/ds4-provider 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -0
- package/binding.gyp +75 -0
- package/dist/ds4-language-model.d.ts +71 -0
- package/dist/ds4-language-model.d.ts.map +1 -0
- package/dist/ds4-language-model.js +888 -0
- package/dist/ds4-language-model.js.map +1 -0
- package/dist/ds4-provider.d.ts +13 -0
- package/dist/ds4-provider.d.ts.map +1 -0
- package/dist/ds4-provider.js +20 -0
- package/dist/ds4-provider.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/native-binding.d.ts +42 -0
- package/dist/native-binding.d.ts.map +1 -0
- package/dist/native-binding.js +157 -0
- package/dist/native-binding.js.map +1 -0
- package/ds4/LICENSE +22 -0
- package/ds4/ds4.c +18268 -0
- package/ds4/ds4.h +196 -0
- package/ds4/ds4_gpu.h +804 -0
- package/ds4/ds4_metal.m +14657 -0
- package/ds4/metal/argsort.metal +266 -0
- package/ds4/metal/bin.metal +192 -0
- package/ds4/metal/concat.metal +62 -0
- package/ds4/metal/cpy.metal +57 -0
- package/ds4/metal/dense.metal +1121 -0
- package/ds4/metal/dsv4_hc.metal +861 -0
- package/ds4/metal/dsv4_kv.metal +227 -0
- package/ds4/metal/dsv4_misc.metal +1088 -0
- package/ds4/metal/dsv4_rope.metal +155 -0
- package/ds4/metal/flash_attn.metal +1426 -0
- package/ds4/metal/get_rows.metal +54 -0
- package/ds4/metal/glu.metal +36 -0
- package/ds4/metal/moe.metal +1737 -0
- package/ds4/metal/norm.metal +153 -0
- package/ds4/metal/repeat.metal +52 -0
- package/ds4/metal/set_rows.metal +55 -0
- package/ds4/metal/softmax.metal +241 -0
- package/ds4/metal/sum_rows.metal +102 -0
- package/ds4/metal/unary.metal +312 -0
- package/native/binding.cpp +621 -0
- package/package.json +66 -0
- package/scripts/postinstall.cjs +13 -0
- package/scripts/vendor-ds4.cjs +67 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const { execSync } = require("node:child_process");
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
|
|
5
|
+
const packageRoot = path.join(__dirname, "..");
|
|
6
|
+
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
7
|
+
const ds4Path = path.join(packageRoot, "ds4");
|
|
8
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
9
|
+
const { repo, commit } = packageJson.ds4 ?? {};
|
|
10
|
+
|
|
11
|
+
if (!repo || !commit) {
|
|
12
|
+
console.error("ERROR: ds4.repo and ds4.commit must be set in package.json");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function run(command, options = {}) {
|
|
17
|
+
execSync(command, {
|
|
18
|
+
cwd: packageRoot,
|
|
19
|
+
stdio: "inherit",
|
|
20
|
+
...options,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isStandaloneGitCheckout() {
|
|
25
|
+
return fs.existsSync(path.join(ds4Path, ".git"));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function hasVendoredSource() {
|
|
29
|
+
return fs.existsSync(path.join(ds4Path, "ds4.c")) &&
|
|
30
|
+
fs.existsSync(path.join(ds4Path, "ds4.h")) &&
|
|
31
|
+
fs.existsSync(path.join(ds4Path, "metal"));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getCurrentCommit() {
|
|
35
|
+
if (!isStandaloneGitCheckout()) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
return execSync("git rev-parse HEAD", {
|
|
41
|
+
cwd: ds4Path,
|
|
42
|
+
encoding: "utf8",
|
|
43
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
44
|
+
}).trim();
|
|
45
|
+
} catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!fs.existsSync(ds4Path)) {
|
|
51
|
+
run(`git clone --depth 1 ${repo} ds4`);
|
|
52
|
+
} else if (!isStandaloneGitCheckout()) {
|
|
53
|
+
if (!hasVendoredSource()) {
|
|
54
|
+
console.error(`ERROR: ${ds4Path} exists but does not contain DS4 sources`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
console.log("Using existing vendored ds4 source directory");
|
|
59
|
+
process.exit(0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (getCurrentCommit() !== commit) {
|
|
63
|
+
run(`git fetch --depth 1 origin ${commit}`, { cwd: ds4Path });
|
|
64
|
+
run(`git checkout --detach ${commit}`, { cwd: ds4Path });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log(`Vendored ds4 at ${commit}`);
|