@genai-fi/nanogpt 0.10.1 → 0.10.3
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/dist/Generator.js +11761 -171
- package/dist/{RealDiv-DgA3z9oO.js → RealDiv-KAPDe8zB.js} +28 -30
- package/dist/Reshape-BYkmUnAv.js +14 -0
- package/dist/{Reshape-_kILl6tK.js → Reshape-Zt6eb7yh.js} +18 -20
- package/dist/TeachableLLM.js +10 -11
- package/dist/{axis_util-BvHEw88j.js → axis_util-BaG7mf5A.js} +3 -3
- package/dist/backend.js +2 -2
- package/dist/{backend_util-D-rUb2ty.js → backend_util-RCe-rHaj.js} +59 -60
- package/dist/{backend_webgpu-B0u2ndUn.js → backend_webgpu-DE3ACOLx.js} +45 -47
- package/dist/broadcast_to-B3eYlZm7.js +28 -0
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +3 -3
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/matMulGelu.js +7 -11
- package/dist/checks/normRMS.js +9 -9
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/packUnpack.js +2 -2
- package/dist/checks/qkv.js +12 -13
- package/dist/checks/rope.js +2 -2
- package/dist/clip_by_value-BnO7-a88.js +12 -0
- package/dist/complex-DjxcVmoX.js +11 -0
- package/dist/concat-BV8bt5H-.js +17 -0
- package/dist/{concat_util-DcJk7YHS.js → concat_util-DpW8mL_l.js} +1 -1
- package/dist/{dataset-0xP8GjwI.js → dataset-BcwmTGYc.js} +137 -139
- package/dist/dropout-BcvN9JYi.js +92 -0
- package/dist/expand_dims-DT4tEPwA.js +11 -0
- package/dist/{exports_initializers-xuidcwI4.js → exports_initializers-Hta_rEnm.js} +1 -1
- package/dist/floor-D5QdR_le.js +9 -0
- package/dist/gather-D3JcZUaI.js +9 -0
- package/dist/{gelu-CNLFZWea.js → gelu-CjNPL4OH.js} +10 -11
- package/dist/{gpgpu_math-DDVJCn6-.js → gpgpu_math-DAOmgtXR.js} +841 -1015
- package/dist/{index-CjOj7j-u.js → index-BwexR4lA.js} +262 -263
- package/dist/index-DOvlwCh-.js +3520 -0
- package/dist/{kernel_funcs_utils-Dg_-E44D.js → kernel_funcs_utils-CCzYdUZg.js} +129 -131
- package/dist/layers/BaseLayer.js +14 -15
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +4 -4
- package/dist/layers/PositionEmbedding.js +7 -7
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +9 -9
- package/dist/layers/TiedEmbedding.js +6 -6
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +13 -14
- package/dist/log_sum_exp-ngO0-4pK.js +39 -0
- package/dist/main.js +49 -50
- package/dist/{matMul16--R5hOwDG.js → matMul16-BWRSOCWB.js} +14 -15
- package/dist/matMulGelu-CzfgT6Wq.js +163 -0
- package/dist/mat_mul-SjpJRLyL.js +11 -0
- package/dist/mod-AnXEvvpo.js +11 -0
- package/dist/models/NanoGPTV1.js +2 -2
- package/dist/models/model.js +13 -14
- package/dist/ones-D2rT0xk2.js +14 -0
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.js +1 -1
- package/dist/ops/add16.js +1 -1
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/concat16.js +2 -2
- package/dist/ops/cpu/adamAdjust.js +13 -14
- package/dist/ops/cpu/adamMoments.js +6 -7
- package/dist/ops/cpu/appendCache.js +7 -8
- package/dist/ops/cpu/attentionMask.js +7 -7
- package/dist/ops/cpu/fusedSoftmax.js +10 -11
- package/dist/ops/cpu/gatherSub.js +9 -10
- package/dist/ops/cpu/gelu.js +9 -10
- package/dist/ops/cpu/matMul16.js +6 -7
- package/dist/ops/cpu/matMulGelu.js +5 -6
- package/dist/ops/cpu/matMulMul.js +3 -4
- package/dist/ops/cpu/mulDropout.js +3 -4
- package/dist/ops/cpu/normRMS.js +10 -11
- package/dist/ops/cpu/qkv.js +8 -9
- package/dist/ops/cpu/rope.js +5 -6
- package/dist/ops/cpu/scatterSub.js +17 -19
- package/dist/ops/dot16.js +2 -2
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/add16.js +11 -12
- package/dist/ops/grads/attentionMask.js +5 -6
- package/dist/ops/grads/gelu.js +3 -4
- package/dist/ops/grads/matMul16.js +4 -5
- package/dist/ops/grads/matMulGelu.js +9 -10
- package/dist/ops/grads/normRMS.js +7 -8
- package/dist/ops/grads/pack16.js +4 -5
- package/dist/ops/grads/qkv.js +17 -19
- package/dist/ops/grads/rope.js +3 -5
- package/dist/ops/grads/softmax16.js +3 -4
- package/dist/ops/grads/unpack16.js +3 -4
- package/dist/ops/grads/utils.d.ts +1 -0
- package/dist/ops/grads/utils.js +8 -4
- package/dist/ops/matMul16.js +3 -3
- package/dist/ops/matMulGelu.js +2 -2
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mul16.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/pack16.js +3 -4
- package/dist/ops/qkv.js +4 -8
- package/dist/ops/reshape16.js +14 -16
- package/dist/ops/rope.d.ts +1 -1
- package/dist/ops/rope.js +3 -8
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/slice16.js +2 -2
- package/dist/ops/softmax16.js +5 -8
- package/dist/ops/sub16.js +1 -1
- package/dist/ops/sum16.js +2 -2
- package/dist/ops/transpose16.js +23 -24
- package/dist/ops/unpack16.js +2 -2
- package/dist/ops/webgl/adamAdjust.js +2 -3
- package/dist/ops/webgl/adamMoments.js +1 -2
- package/dist/ops/webgl/appendCache.js +1 -2
- package/dist/ops/webgl/attentionMask.js +4 -5
- package/dist/ops/webgl/fusedSoftmax.js +4 -6
- package/dist/ops/webgl/gatherSub.js +6 -7
- package/dist/ops/webgl/gelu.js +2 -3
- package/dist/ops/webgl/log.js +11 -12
- package/dist/ops/webgl/matMul16.js +10 -11
- package/dist/ops/webgl/matMulGelu.js +7 -111
- package/dist/ops/webgl/matMulMul.js +9 -10
- package/dist/ops/webgl/mulDropout.js +8 -9
- package/dist/ops/webgl/normRMS.js +2 -3
- package/dist/ops/webgl/qkv.js +5 -6
- package/dist/ops/webgl/rope.js +7 -8
- package/dist/ops/webgl/scatterSub.js +5 -6
- package/dist/ops/webgpu/adamAdjust.js +10 -12
- package/dist/ops/webgpu/adamMoments.js +8 -10
- package/dist/ops/webgpu/add16.js +8 -9
- package/dist/ops/webgpu/appendCache.js +23 -25
- package/dist/ops/webgpu/attentionMask.js +8 -10
- package/dist/ops/webgpu/attentionMask32_program.js +2 -2
- package/dist/ops/webgpu/concat16.js +12 -14
- package/dist/ops/webgpu/gatherSub.js +11 -13
- package/dist/ops/webgpu/gelu.js +28 -29
- package/dist/ops/webgpu/matMul16.js +26 -28
- package/dist/ops/webgpu/matMul16_program.js +4 -5
- package/dist/ops/webgpu/mul16.js +9 -10
- package/dist/ops/webgpu/normRMS.js +15 -17
- package/dist/ops/webgpu/normRMSGrad.js +21 -28
- package/dist/ops/webgpu/pack16.js +12 -13
- package/dist/ops/webgpu/pack16_program.js +2 -2
- package/dist/ops/webgpu/qkv.js +16 -18
- package/dist/ops/webgpu/rope.js +25 -27
- package/dist/ops/webgpu/scatterSub.js +7 -9
- package/dist/ops/webgpu/slice16.js +21 -23
- package/dist/ops/webgpu/softmax16.js +17 -19
- package/dist/ops/webgpu/softmax16_program.js +2 -2
- package/dist/ops/webgpu/softmax16_subgroup_program.js +2 -2
- package/dist/ops/webgpu/softmax16grad.js +7 -8
- package/dist/ops/webgpu/sub16.js +7 -8
- package/dist/ops/webgpu/sum16.js +18 -20
- package/dist/ops/webgpu/transpose16.js +19 -20
- package/dist/ops/webgpu/transpose16_program.js +2 -2
- package/dist/ops/webgpu/transpose16_shared_program.js +11 -12
- package/dist/ops/webgpu/unpack16.js +3 -4
- package/dist/ops/webgpu/utils/binary_op.js +7 -8
- package/dist/ops/webgpu/utils/reductions.js +14 -22
- package/dist/ops-B5yanEdW.js +476 -0
- package/dist/pack16-nQ6JaLo-.js +39 -0
- package/dist/patches/webgpu_backend.js +19 -20
- package/dist/patches/webgpu_base.js +1 -1
- package/dist/patches/webgpu_program.js +21 -22
- package/dist/{random_width-DY6Kk2Dl.js → random_width-or-CEftb.js} +2506 -2761
- package/dist/range-BklejeeW.js +10 -0
- package/dist/relu-CP0ZcxWO.js +9 -0
- package/dist/reshape-ByE68wS9.js +9 -0
- package/dist/resize_nearest_neighbor-B19mCEg2.js +175 -0
- package/dist/rope-Ir4mTyD1.js +24 -0
- package/dist/{scatter_nd_util-5EL-8VAQ.js → scatter_nd_util-lvSiX8q4.js} +1 -1
- package/dist/selu_util-kbhpTdYD.js +44 -0
- package/dist/{shared-BRksrJb3.js → shared-DT1TkE6w.js} +1 -1
- package/dist/{shared-BuAXb4CI.js → shared-dntlHIDQ.js} +343 -345
- package/dist/slice-BfEGSH82.js +12 -0
- package/dist/{slice_util-DtEldBfK.js → slice_util-uTKwiEpW.js} +1 -1
- package/dist/{softmax-ZHVebtR1.js → softmax-CA5jFsLR.js} +4 -5
- package/dist/split-CVLc0w--.js +9 -0
- package/dist/squeeze-C7Z2srUo.js +10 -0
- package/dist/stack-Cf4n9h0N.js +11 -0
- package/dist/step-CINUs5QB.js +261 -0
- package/dist/sum-DWAtNGez.js +11 -0
- package/dist/tensor-DJoc7gJU.js +8 -0
- package/dist/tensor1d-D11P_7Dp.js +11 -0
- package/dist/{tensor2d-G4Ys2GxX.js → tensor2d-Bs9wZRc7.js} +6 -7
- package/dist/{tensor4d-B8roDgtc.js → tensor4d-BARPdTaS.js} +6 -7
- package/dist/{tfjs_backend-kNyO5L2d.js → tfjs_backend-y1cvNhLA.js} +244 -253
- package/dist/tile-mbfagpsB.js +11 -0
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +2 -2
- package/dist/training/sparseCrossEntropy.js +5 -5
- package/dist/transpose-ClWiBS_b.js +36 -0
- package/dist/unsorted_segment_sum-BDDhB_E6.js +277 -0
- package/dist/utilities/dummy.js +3 -3
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/packed.d.ts +1 -4
- package/dist/utilities/packed.js +10 -711
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/sentences.js +5 -5
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-Bhn5bHYv.js → variable-WawDEaAb.js} +1 -1
- package/dist/{webgpu_program-Cigz-7RF.js → webgpu_program-DuOXPQol.js} +178 -172
- package/dist/{webgpu_util-BBCnKm2X.js → webgpu_util-RxEF33Rj.js} +34 -35
- package/dist/zeros-KnWaWf-X.js +13 -0
- package/dist/zeros_like-DvE73F4e.js +721 -0
- package/package.json +4 -2
- package/dist/Reshape-CF6odzV4.js +0 -16
- package/dist/broadcast_to-CwF7XIeu.js +0 -30
- package/dist/complex-CSlYz-2T.js +0 -13
- package/dist/concat-BHlIJeyT.js +0 -19
- package/dist/dropout-C1pM3f11.js +0 -99
- package/dist/expand_dims-BPG4fwBP.js +0 -13
- package/dist/gather-DykLGqmW.js +0 -10
- package/dist/index-ZyQhjEPo.js +0 -2157
- package/dist/log_sum_exp-DWI-76TI.js +0 -41
- package/dist/mat_mul-DeAh4uTH.js +0 -12
- package/dist/mod-Gt1rMB4n.js +0 -12
- package/dist/mulmat_packed_gpu-BMFhLwta.js +0 -55
- package/dist/ones-CAMiP4I2.js +0 -15
- package/dist/ops-CNI3TwqM.js +0 -645
- package/dist/pack16-CFUqumar.js +0 -41
- package/dist/patches/PackedTensor.d.ts +0 -12
- package/dist/patches/PackedTensor.js +0 -11
- package/dist/patches/engine.d.ts +0 -261
- package/dist/patches/engine.js +0 -10
- package/dist/patches/tape.d.ts +0 -12
- package/dist/patches/tape.js +0 -5
- package/dist/range-BMS52eQi.js +0 -11
- package/dist/reciprocal-CTmshQ9J.js +0 -10
- package/dist/register_all_kernels-Bwu1PTuU.js +0 -12307
- package/dist/relu-yZ2-7WxU.js +0 -10
- package/dist/reshape-DevtBWtf.js +0 -10
- package/dist/rope-B5UUMsPi.js +0 -32
- package/dist/selu_util-D1w6yyTO.js +0 -303
- package/dist/sin-BGfy2HZo.js +0 -16
- package/dist/slice-D_gkkqZK.js +0 -13
- package/dist/split-DrfihRpZ.js +0 -10
- package/dist/squeeze-DZEpeblb.js +0 -11
- package/dist/stack-yOIAalTq.js +0 -13
- package/dist/sum-_fzj5ZTB.js +0 -12
- package/dist/tensor-DdQUJZlz.js +0 -909
- package/dist/tensor-f35l8Odg.js +0 -8
- package/dist/tensor1d-CeZuc-Rv.js +0 -12
- package/dist/tensor_util-DV-FP5Q3.js +0 -523
- package/dist/tile-BzyEiF-F.js +0 -13
- package/dist/transpose-DKELTqhe.js +0 -38
- package/dist/zeros-2gldETuK.js +0 -14
|
@@ -1,113 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { m as $ } from "../../mat_mul-DeAh4uTH.js";
|
|
6
|
-
import { s as A, a as U } from "../../tensor-DdQUJZlz.js";
|
|
7
|
-
const M = 0.7978845608028654, g = 0.044715, j = `
|
|
8
|
-
vec4 x3 = x * x * x;
|
|
9
|
-
vec4 inner = x + ${g} * x3;
|
|
10
|
-
inner = ${M} * inner;
|
|
11
|
-
inner = vec4(
|
|
12
|
-
abs(inner[0]) > 15.0 ? sign(inner[0]) : tanh(inner[0]),
|
|
13
|
-
abs(inner[1]) > 15.0 ? sign(inner[1]) : tanh(inner[1]),
|
|
14
|
-
abs(inner[2]) > 15.0 ? sign(inner[2]) : tanh(inner[2]),
|
|
15
|
-
abs(inner[3]) > 15.0 ? sign(inner[3]) : tanh(inner[3])
|
|
16
|
-
);
|
|
17
|
-
inner = 0.5 * (1.0 + inner);
|
|
18
|
-
vec4 result = x * inner;
|
|
19
|
-
return result;
|
|
20
|
-
`, q = `
|
|
21
|
-
vec4 a2 = a * a;
|
|
22
|
-
vec4 a3 = a2 * a;
|
|
23
|
-
vec4 u = ${M} * (a + ${g} * a3);
|
|
24
|
-
vec4 t = vec4(
|
|
25
|
-
abs(u[0]) > 15.0 ? sign(u[0]) : tanh(u[0]),
|
|
26
|
-
abs(u[1]) > 15.0 ? sign(u[1]) : tanh(u[1]),
|
|
27
|
-
abs(u[2]) > 15.0 ? sign(u[2]) : tanh(u[2]),
|
|
28
|
-
abs(u[3]) > 15.0 ? sign(u[3]) : tanh(u[3])
|
|
29
|
-
);
|
|
30
|
-
vec4 sech2 = 1.0 - t * t;
|
|
31
|
-
vec4 du_dx = ${M} * (1.0 + 3.0 * ${g} * a2);
|
|
32
|
-
vec4 dgelu = 0.5 * (1.0 + t) + 0.5 * a * sech2 * du_dx;
|
|
33
|
-
return dgelu * b;
|
|
34
|
-
`, se = 1e3;
|
|
35
|
-
function _({
|
|
36
|
-
a: e,
|
|
37
|
-
b: n,
|
|
38
|
-
transposeA: s,
|
|
39
|
-
transposeB: t,
|
|
40
|
-
backend: a,
|
|
41
|
-
activationSnippet: i,
|
|
42
|
-
multiplier: o
|
|
43
|
-
}) {
|
|
44
|
-
const r = e.shape.length, c = n.shape.length, u = s ? e.shape[r - 2] : e.shape[r - 1], p = t ? n.shape[c - 1] : n.shape[c - 2], h = s ? e.shape[r - 1] : e.shape[r - 2], l = t ? n.shape[c - 2] : n.shape[c - 1], w = e.shape.slice(0, -2), K = n.shape.slice(0, -2), m = A(w), d = A(K), T = N(e.shape.slice(0, -2), n.shape.slice(0, -2)).concat([h, l]);
|
|
45
|
-
U(
|
|
46
|
-
u === p,
|
|
47
|
-
() => `Error in matMul: inner shapes (${u}) and (${p}) of Tensors with shapes ${e.shape} and ${n.shape} and transposeA=${s} and transposeB=${t} must match.`
|
|
48
|
-
);
|
|
49
|
-
const v = s ? [m, u, h] : [m, h, u], x = t ? [d, l, p] : [d, p, l], S = f({ inputs: { x: e }, backend: a, attrs: { shape: v } }), b = f({ inputs: { x: n }, backend: a, attrs: { shape: x } }), D = [S, b], y = Math.max(m, d), L = i, B = O(e.dtype, n.dtype), F = new H(
|
|
50
|
-
v,
|
|
51
|
-
x,
|
|
52
|
-
[y, h, l],
|
|
53
|
-
s,
|
|
54
|
-
t,
|
|
55
|
-
!1,
|
|
56
|
-
L,
|
|
57
|
-
!!o,
|
|
58
|
-
!1
|
|
59
|
-
), G = [S, b];
|
|
60
|
-
o && G.push(o);
|
|
61
|
-
const k = a.runWebGLProgram(F, G, B), I = f({ inputs: { x: k }, backend: a, attrs: { shape: T } });
|
|
62
|
-
D.push(k);
|
|
63
|
-
for (const P of D)
|
|
64
|
-
a.disposeIntermediateTensorInfo(P);
|
|
65
|
-
return I;
|
|
66
|
-
}
|
|
67
|
-
function z(e) {
|
|
68
|
-
const { inputs: n, backend: s } = e, { x: t, kernel: a } = n;
|
|
69
|
-
if (t === void 0 || a === void 0)
|
|
70
|
-
throw new Error("BatchMatMul requires two input tensors.");
|
|
71
|
-
return _({
|
|
72
|
-
a: t,
|
|
73
|
-
b: a,
|
|
74
|
-
transposeA: !1,
|
|
75
|
-
transposeB: !1,
|
|
76
|
-
backend: s,
|
|
77
|
-
activationSnippet: j
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
const W = {
|
|
81
|
-
kernelName: "MatMulGelu",
|
|
82
|
-
backendName: "webgl",
|
|
83
|
-
kernelFunc: z
|
|
84
|
-
};
|
|
85
|
-
E(W);
|
|
86
|
-
function J(e) {
|
|
87
|
-
const { dy: n, x: s, kernel: t } = e.inputs, a = e.backend;
|
|
88
|
-
return R(() => {
|
|
89
|
-
const i = C().makeTensorFromTensorInfo(
|
|
90
|
-
_({
|
|
91
|
-
a: s,
|
|
92
|
-
b: t,
|
|
93
|
-
transposeA: !1,
|
|
94
|
-
transposeB: !1,
|
|
95
|
-
backend: a,
|
|
96
|
-
activationSnippet: q,
|
|
97
|
-
multiplier: n
|
|
98
|
-
})
|
|
99
|
-
), o = $(i, t, !1, !0), r = $(s, i, !0, !1);
|
|
100
|
-
return [o, r];
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
const Q = {
|
|
104
|
-
kernelName: "MatMulGeluGrad",
|
|
105
|
-
backendName: "webgl",
|
|
106
|
-
kernelFunc: J
|
|
107
|
-
};
|
|
108
|
-
E(Q);
|
|
1
|
+
import "../../index-DOvlwCh-.js";
|
|
2
|
+
import "../../Reshape-Zt6eb7yh.js";
|
|
3
|
+
import { a as m, b as o, c as p } from "../../matMulGelu-CzfgT6Wq.js";
|
|
4
|
+
import "../../mat_mul-SjpJRLyL.js";
|
|
109
5
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
6
|
+
m as MATMUL_SHARED_DIM_THRESHOLD,
|
|
7
|
+
o as batchMatMulGeluImpl,
|
|
8
|
+
p as batchMatMulKernel
|
|
113
9
|
};
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import {
|
|
3
|
-
import { r as c } from "../../tensor_util-DV-FP5Q3.js";
|
|
1
|
+
import { p as u } from "../../index-DOvlwCh-.js";
|
|
2
|
+
import { b as c } from "../../matMulGelu-CzfgT6Wq.js";
|
|
4
3
|
const p = `
|
|
5
4
|
return a * b;
|
|
6
5
|
`;
|
|
7
6
|
function M(r) {
|
|
8
|
-
const { inputs: n, backend:
|
|
7
|
+
const { inputs: n, backend: a, attrs: o } = r, { x: t, kernel: e, y: l } = n, { transposeA: s, transposeB: i } = o;
|
|
9
8
|
if (t === void 0 || e === void 0)
|
|
10
9
|
throw new Error("BatchMatMul requires two input tensors.");
|
|
11
|
-
return
|
|
10
|
+
return c({
|
|
12
11
|
a: t,
|
|
13
12
|
b: e,
|
|
14
|
-
transposeA:
|
|
15
|
-
transposeB:
|
|
16
|
-
backend:
|
|
13
|
+
transposeA: s,
|
|
14
|
+
transposeB: i,
|
|
15
|
+
backend: a,
|
|
17
16
|
activationSnippet: p,
|
|
18
|
-
multiplier:
|
|
17
|
+
multiplier: l
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
const m = {
|
|
@@ -23,7 +22,7 @@ const m = {
|
|
|
23
22
|
backendName: "webgl",
|
|
24
23
|
kernelFunc: M
|
|
25
24
|
};
|
|
26
|
-
|
|
25
|
+
u(m);
|
|
27
26
|
export {
|
|
28
27
|
M as batchMatMulKernel
|
|
29
28
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import { r as m } from "../../tensor_util-DV-FP5Q3.js";
|
|
1
|
+
import { p as m } from "../../index-DOvlwCh-.js";
|
|
3
2
|
class f {
|
|
4
3
|
variableNames = ["a", "b"];
|
|
5
4
|
outputShape;
|
|
@@ -8,8 +7,8 @@ class f {
|
|
|
8
7
|
{ name: "dropoutRate", type: "float" },
|
|
9
8
|
{ name: "seed", type: "float" }
|
|
10
9
|
];
|
|
11
|
-
constructor(
|
|
12
|
-
this.outputShape = [
|
|
10
|
+
constructor(t, r, o) {
|
|
11
|
+
this.outputShape = [t, r, o, o], this.userCode = `
|
|
13
12
|
float random(ivec4 coords) {
|
|
14
13
|
float x = float(coords.x * 4096 + coords.y * 256 + coords.z * 16 + coords.w);
|
|
15
14
|
return fract(sin(seed + x) * 43758.5453123);
|
|
@@ -27,16 +26,16 @@ class f {
|
|
|
27
26
|
`;
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
function
|
|
31
|
-
const { inputs:
|
|
29
|
+
function b(e) {
|
|
30
|
+
const { inputs: t, attrs: r } = e, { a: o, b: s } = t, { dropoutRate: a, seed: c } = r, n = e.backend, d = o.shape[0], u = o.shape[2], p = o.shape[1], l = new f(d, p, u);
|
|
32
31
|
return n.runWebGLProgram(l, [o, s], "float32", [
|
|
33
32
|
[a ?? 0],
|
|
34
33
|
[c ?? Math.random() * 1e4]
|
|
35
34
|
]);
|
|
36
35
|
}
|
|
37
|
-
const
|
|
36
|
+
const i = {
|
|
38
37
|
kernelName: "MulDropout",
|
|
39
38
|
backendName: "webgl",
|
|
40
|
-
kernelFunc:
|
|
39
|
+
kernelFunc: b
|
|
41
40
|
};
|
|
42
|
-
m(
|
|
41
|
+
m(i);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { e as G } from "../../index-
|
|
2
|
-
import {
|
|
3
|
-
import { s as x } from "../../sum-_fzj5ZTB.js";
|
|
1
|
+
import { p as g, e as G } from "../../index-DOvlwCh-.js";
|
|
2
|
+
import { s as x } from "../../sum-DWAtNGez.js";
|
|
4
3
|
class y {
|
|
5
4
|
variableNames = ["x", "meanSquare", "gamma"];
|
|
6
5
|
outputShape;
|
package/dist/ops/webgl/qkv.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
|
|
3
|
-
class m {
|
|
1
|
+
import { p as i } from "../../index-DOvlwCh-.js";
|
|
2
|
+
class l {
|
|
4
3
|
variableNames = ["x", "kernel"];
|
|
5
4
|
outputShape;
|
|
6
5
|
userCode;
|
|
@@ -31,8 +30,8 @@ class m {
|
|
|
31
30
|
`;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
function
|
|
35
|
-
const { x: e, kernel: t } = r.inputs, { heads: s } = r.attrs, o = r.backend, n = e.shape[0], c = e.shape[1], u = e.shape[2], a = new
|
|
33
|
+
function m(r) {
|
|
34
|
+
const { x: e, kernel: t } = r.inputs, { heads: s } = r.attrs, o = r.backend, n = e.shape[0], c = e.shape[1], u = e.shape[2], a = new l(n, s, c, u);
|
|
36
35
|
return [
|
|
37
36
|
o.runWebGLProgram(a, [e, t], "float32", [[0]]),
|
|
38
37
|
o.runWebGLProgram(a, [e, t], "float32", [[1]]),
|
|
@@ -42,6 +41,6 @@ function l(r) {
|
|
|
42
41
|
const d = {
|
|
43
42
|
kernelName: "QKV",
|
|
44
43
|
backendName: "webgl",
|
|
45
|
-
kernelFunc:
|
|
44
|
+
kernelFunc: m
|
|
46
45
|
};
|
|
47
46
|
i(d);
|
package/dist/ops/webgl/rope.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import { r as h } from "../../tensor_util-DV-FP5Q3.js";
|
|
1
|
+
import { p as h } from "../../index-DOvlwCh-.js";
|
|
3
2
|
class g {
|
|
4
3
|
variableNames = ["x", "sin", "cos"];
|
|
5
4
|
outputShape;
|
|
@@ -45,13 +44,13 @@ class g {
|
|
|
45
44
|
`;
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
|
-
function
|
|
49
|
-
const { x: t } = o.inputs, { pastLen: s, ropeCache: e, negSin: n } = o.attrs, a = n ? e.getNegSin() : e.getSin(), r = e.getCos(),
|
|
50
|
-
return
|
|
47
|
+
function f(o) {
|
|
48
|
+
const { x: t } = o.inputs, { pastLen: s, ropeCache: e, negSin: n } = o.attrs, a = n ? e.getNegSin() : e.getSin(), r = e.getCos(), d = o.backend, i = t.shape[0], c = t.shape[1], p = t.shape[2], u = t.shape[3], l = new g(i, c, p, u);
|
|
49
|
+
return d.runWebGLProgram(l, [t, a, r], "float32", [[s]]);
|
|
51
50
|
}
|
|
52
|
-
const
|
|
51
|
+
const m = {
|
|
53
52
|
kernelName: "Rope",
|
|
54
53
|
backendName: "webgl",
|
|
55
|
-
kernelFunc:
|
|
54
|
+
kernelFunc: f
|
|
56
55
|
};
|
|
57
|
-
h(
|
|
56
|
+
h(m);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import { r as i } from "../../tensor_util-DV-FP5Q3.js";
|
|
1
|
+
import { p as i } from "../../index-DOvlwCh-.js";
|
|
3
2
|
class u {
|
|
4
3
|
variableNames = ["labels", "softmaxProbs", "dy"];
|
|
5
4
|
outputShape;
|
|
6
5
|
userCode;
|
|
7
|
-
constructor(
|
|
8
|
-
this.outputShape = [
|
|
6
|
+
constructor(e, t) {
|
|
7
|
+
this.outputShape = [e, t], this.userCode = `
|
|
9
8
|
void main() {
|
|
10
9
|
ivec2 coords = getOutputCoords();
|
|
11
10
|
int index = int(getLabels(coords.x));
|
|
@@ -17,8 +16,8 @@ class u {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
function d(o) {
|
|
20
|
-
const { logits:
|
|
21
|
-
return s.runWebGLProgram(c, [
|
|
19
|
+
const { logits: e, labels: t, dy: r } = o.inputs, s = o.backend, n = t.shape[0], a = e.shape[1], c = new u(n, a);
|
|
20
|
+
return s.runWebGLProgram(c, [t, e, r], "float32");
|
|
22
21
|
}
|
|
23
22
|
const b = {
|
|
24
23
|
kernelName: "EfficientScatterSub",
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { e as p } from "../../webgpu_program-
|
|
2
|
-
import { f as d, c as l } from "../../webgpu_util-
|
|
3
|
-
import "../../index-
|
|
4
|
-
import { j as f } from "../../tensor-DdQUJZlz.js";
|
|
5
|
-
import { r as c } from "../../tensor_util-DV-FP5Q3.js";
|
|
1
|
+
import { e as p } from "../../webgpu_program-DuOXPQol.js";
|
|
2
|
+
import { f as d, c as l } from "../../webgpu_util-RxEF33Rj.js";
|
|
3
|
+
import { p as f, ab as c } from "../../index-DOvlwCh-.js";
|
|
6
4
|
class h {
|
|
7
5
|
variableNames = ["moments", "value"];
|
|
8
6
|
outputShape;
|
|
@@ -38,19 +36,19 @@ class h {
|
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
function v(t) {
|
|
41
|
-
const { moments: e, value: a } = t.inputs, { beta1: n, beta2:
|
|
42
|
-
|
|
43
|
-
const
|
|
39
|
+
const { moments: e, value: a } = t.inputs, { beta1: n, beta2: s, learningRate: o, epsilon: i } = t.attrs, r = t.backend;
|
|
40
|
+
c(e.shape, [...a.shape, 2], "Error in AdamAdjust: ");
|
|
41
|
+
const u = new h(a.shape), m = [
|
|
44
42
|
{ type: "float32", data: [1 / n] },
|
|
45
|
-
{ type: "float32", data: [1 /
|
|
46
|
-
{ type: "float32", data: [
|
|
43
|
+
{ type: "float32", data: [1 / s] },
|
|
44
|
+
{ type: "float32", data: [o] },
|
|
47
45
|
{ type: "float32", data: [i] }
|
|
48
46
|
];
|
|
49
|
-
return r.runWebGPUProgram(
|
|
47
|
+
return r.runWebGPUProgram(u, [e, a], "float32", m);
|
|
50
48
|
}
|
|
51
49
|
const b = {
|
|
52
50
|
kernelName: "AdamAdjust",
|
|
53
51
|
backendName: "webgpu",
|
|
54
52
|
kernelFunc: v
|
|
55
53
|
};
|
|
56
|
-
|
|
54
|
+
f(b);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { e as
|
|
2
|
-
import { f as
|
|
3
|
-
import "../../index-
|
|
4
|
-
import { j as f } from "../../tensor-DdQUJZlz.js";
|
|
5
|
-
import { r as c } from "../../tensor_util-DV-FP5Q3.js";
|
|
1
|
+
import { e as u } from "../../webgpu_program-DuOXPQol.js";
|
|
2
|
+
import { f as p, c as d } from "../../webgpu_util-RxEF33Rj.js";
|
|
3
|
+
import { p as c, ab as f } from "../../index-DOvlwCh-.js";
|
|
6
4
|
class l {
|
|
7
5
|
variableNames = ["moments", "gradient"];
|
|
8
6
|
outputShape;
|
|
@@ -15,7 +13,7 @@ class l {
|
|
|
15
13
|
outputComponent = 2;
|
|
16
14
|
variableComponents = [2, 1];
|
|
17
15
|
constructor(t) {
|
|
18
|
-
this.outputShape = t, this.dispatchLayout =
|
|
16
|
+
this.outputShape = t, this.dispatchLayout = p(this.outputShape.slice(0, -1)), this.dispatch = d(
|
|
19
17
|
this.dispatchLayout,
|
|
20
18
|
this.outputShape.slice(0, -1),
|
|
21
19
|
this.workgroupSize,
|
|
@@ -24,7 +22,7 @@ class l {
|
|
|
24
22
|
}
|
|
25
23
|
getUserCode() {
|
|
26
24
|
return `
|
|
27
|
-
${
|
|
25
|
+
${u("index")} {
|
|
28
26
|
if (index < uniforms.size) {
|
|
29
27
|
let m: vec2<f32> = moments[index];
|
|
30
28
|
|
|
@@ -41,7 +39,7 @@ class l {
|
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
function h(e) {
|
|
44
|
-
const { moments: t, gradient: a } = e.inputs, { beta1: n, beta2: o, lossScaling:
|
|
42
|
+
const { moments: t, gradient: a } = e.inputs, { beta1: n, beta2: o, lossScaling: s } = e.attrs, r = e.backend;
|
|
45
43
|
if (a.dtype !== "float32")
|
|
46
44
|
throw new Error(`Gradient must be float32, but got ${a.dtype}`);
|
|
47
45
|
if (f(t.shape, [...a.shape, 2], "Error in AdamMoments: "), n < 0 || n >= 1)
|
|
@@ -51,9 +49,9 @@ function h(e) {
|
|
|
51
49
|
const i = new l(t.shape), m = [
|
|
52
50
|
{ type: "float32", data: [n] },
|
|
53
51
|
{ type: "float32", data: [o] },
|
|
54
|
-
{ type: "float32", data: [1 /
|
|
52
|
+
{ type: "float32", data: [1 / s] }
|
|
55
53
|
];
|
|
56
|
-
return
|
|
54
|
+
return r.runWebGPUProgram(i, [t, a], "float32", m);
|
|
57
55
|
}
|
|
58
56
|
const g = {
|
|
59
57
|
kernelName: "AdamMoments",
|
package/dist/ops/webgpu/add16.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import "../../index-
|
|
1
|
+
import { p as t } from "../../index-DOvlwCh-.js";
|
|
2
2
|
import { BinaryOpProgram as p } from "./utils/binary_op.js";
|
|
3
|
-
import { B as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return o.packed = !0, o;
|
|
3
|
+
import { B as s } from "../../binary_op_util-pKXltfxI.js";
|
|
4
|
+
function c(e) {
|
|
5
|
+
const { a: r, b: n } = e.inputs, a = e.backend, o = new p(s.ADD, r.shape, n.shape);
|
|
6
|
+
return a.runWebGPUProgram(o, [r, n], "packedF16");
|
|
8
7
|
}
|
|
9
|
-
const
|
|
8
|
+
const m = {
|
|
10
9
|
kernelName: "Add16",
|
|
11
10
|
backendName: "webgpu",
|
|
12
|
-
kernelFunc:
|
|
11
|
+
kernelFunc: c
|
|
13
12
|
};
|
|
14
|
-
|
|
13
|
+
t(m);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { isPackedTensor as
|
|
2
|
-
import { e as
|
|
3
|
-
import { f as
|
|
4
|
-
import "../../index-
|
|
5
|
-
|
|
6
|
-
import { r as x } from "../../tensor_util-DV-FP5Q3.js";
|
|
7
|
-
class b {
|
|
1
|
+
import { isPackedTensor as T } from "../../utilities/packed.js";
|
|
2
|
+
import { e as p } from "../../webgpu_program-DuOXPQol.js";
|
|
3
|
+
import { f as d, c as u } from "../../webgpu_util-RxEF33Rj.js";
|
|
4
|
+
import { p as S, ab as g } from "../../index-DOvlwCh-.js";
|
|
5
|
+
class x {
|
|
8
6
|
variableNames = ["cache", "item"];
|
|
9
7
|
outputShape;
|
|
10
8
|
shaderKey = "AppendCache";
|
|
@@ -13,14 +11,14 @@ class b {
|
|
|
13
11
|
workgroupSize = [64, 1, 1];
|
|
14
12
|
size = !0;
|
|
15
13
|
uniforms = "cacheT: i32";
|
|
16
|
-
constructor(e, t,
|
|
17
|
-
const
|
|
18
|
-
this.shaderKey = `AppendCache_${
|
|
14
|
+
constructor(e, t, a, s, i) {
|
|
15
|
+
const o = Math.min(a + 1, i);
|
|
16
|
+
this.shaderKey = `AppendCache_${o}`, this.outputShape = [e, t, o, s], this.dispatchLayout = d(this.outputShape), this.dispatch = u(this.dispatchLayout, this.outputShape, this.workgroupSize);
|
|
19
17
|
}
|
|
20
18
|
getUserCode() {
|
|
21
19
|
const e = this.outputShape[2];
|
|
22
20
|
return `
|
|
23
|
-
${
|
|
21
|
+
${p("index")} {
|
|
24
22
|
if (index < uniforms.size) {
|
|
25
23
|
let coords = getCoordsFromIndex(index); // [b, h, t, d]
|
|
26
24
|
let b = coords[0];
|
|
@@ -48,7 +46,7 @@ class b {
|
|
|
48
46
|
`;
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
|
-
class
|
|
49
|
+
class b {
|
|
52
50
|
variableNames = ["cache", "item"];
|
|
53
51
|
outputShape;
|
|
54
52
|
shaderKey = "AppendCache";
|
|
@@ -57,14 +55,14 @@ class C {
|
|
|
57
55
|
workgroupSize = [64, 1, 1];
|
|
58
56
|
size = !0;
|
|
59
57
|
uniforms = "cacheT: i32";
|
|
60
|
-
constructor(e, t,
|
|
61
|
-
const
|
|
62
|
-
this.shaderKey = `AppendCache_${
|
|
58
|
+
constructor(e, t, a, s, i) {
|
|
59
|
+
const o = Math.min(a + 1, i);
|
|
60
|
+
this.shaderKey = `AppendCache_${o}`, this.outputShape = [e, t, o, s], this.dispatchLayout = d(this.outputShape), this.dispatch = u(this.dispatchLayout, this.outputShape, this.workgroupSize);
|
|
63
61
|
}
|
|
64
62
|
getUserCode() {
|
|
65
63
|
const e = this.outputShape[2];
|
|
66
64
|
return `
|
|
67
|
-
${
|
|
65
|
+
${p("index")} {
|
|
68
66
|
if (index < uniforms.size) {
|
|
69
67
|
let coords = getCoordsFromIndex(index); // [b, h, t, d]
|
|
70
68
|
let b = coords[0];
|
|
@@ -92,16 +90,16 @@ class C {
|
|
|
92
90
|
`;
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
|
-
function
|
|
96
|
-
const { cache: e, item: t } = r.inputs, { maxSize:
|
|
97
|
-
if (g(t.shape, [c, h, 1, t.shape[3]], "Error in AppendCache: "),
|
|
98
|
-
throw new Error(`Invalid pastLen value: ${
|
|
99
|
-
const
|
|
100
|
-
return
|
|
93
|
+
function C(r) {
|
|
94
|
+
const { cache: e, item: t } = r.inputs, { maxSize: a, pastLen: s } = r.attrs, i = r.backend, o = T(e), c = e.shape[0], n = e.shape[2], h = e.shape[1];
|
|
95
|
+
if (g(t.shape, [c, h, 1, t.shape[3]], "Error in AppendCache: "), s < 0 || s > a)
|
|
96
|
+
throw new Error(`Invalid pastLen value: ${s}. Must be in the range [0, ${a}].`);
|
|
97
|
+
const m = o ? new b(c, h, n, t.shape[3], a) : new x(c, h, n, t.shape[3], a), l = [{ type: "int32", data: [s] }], f = o ? "packedF16" : e.dtype;
|
|
98
|
+
return i.runWebGPUProgram(m, [e, t], f, l);
|
|
101
99
|
}
|
|
102
|
-
const
|
|
100
|
+
const v = {
|
|
103
101
|
kernelName: "AppendCache",
|
|
104
102
|
backendName: "webgpu",
|
|
105
|
-
kernelFunc:
|
|
103
|
+
kernelFunc: C
|
|
106
104
|
};
|
|
107
|
-
|
|
105
|
+
S(v);
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import { j as d } from "../../tensor-DdQUJZlz.js";
|
|
1
|
+
import { p as d, ab as b } from "../../index-DOvlwCh-.js";
|
|
3
2
|
import { isPackedTensor as p } from "../../utilities/packed.js";
|
|
4
|
-
import { b } from "../../matMul16
|
|
5
|
-
import
|
|
6
|
-
import { r as M } from "../../tensor_util-DV-FP5Q3.js";
|
|
3
|
+
import { b as l } from "../../matMul16-BWRSOCWB.js";
|
|
4
|
+
import M from "./attentionMask32_program.js";
|
|
7
5
|
function w(n) {
|
|
8
6
|
const { q: t, k: e } = n.inputs, { divisor: a, pastLen: o } = n.attrs, m = n.backend;
|
|
9
7
|
if (p(t) && p(e))
|
|
10
|
-
return
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
8
|
+
return l(t, e, !1, !0, { causalMask: !0, pastLen: o, scale: a });
|
|
9
|
+
const s = t.shape[0], k = t.shape[2], r = e.shape[2], i = t.shape[1], c = t.shape[3];
|
|
10
|
+
if (b(e.shape, [s, i, r, c], "Error in AttentionMask: "), a === 0)
|
|
13
11
|
throw new Error("Divisor must be non-zero in AttentionMask");
|
|
14
12
|
if (o < 0)
|
|
15
13
|
throw new Error("pastLen must be non-negative in AttentionMask");
|
|
16
|
-
const u = new
|
|
14
|
+
const u = new M(s, i, k, r, c), f = [
|
|
17
15
|
{ type: "float32", data: [a] },
|
|
18
16
|
{ type: "int32", data: [o] },
|
|
19
17
|
{ type: "float32", data: [Number.NEGATIVE_INFINITY] }
|
|
@@ -25,4 +23,4 @@ const A = {
|
|
|
25
23
|
backendName: "webgpu",
|
|
26
24
|
kernelFunc: w
|
|
27
25
|
};
|
|
28
|
-
|
|
26
|
+
d(A);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as r } from "../../webgpu_program-
|
|
2
|
-
import { f as a, c as u } from "../../webgpu_util-
|
|
1
|
+
import { e as r } from "../../webgpu_program-DuOXPQol.js";
|
|
2
|
+
import { f as a, c as u } from "../../webgpu_util-RxEF33Rj.js";
|
|
3
3
|
class p {
|
|
4
4
|
variableNames = ["q", "k"];
|
|
5
5
|
outputShape;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import { e as
|
|
3
|
-
import { f as
|
|
4
|
-
import { r as
|
|
5
|
-
import {
|
|
6
|
-
import { p as F, s as c } from "../../tensor-DdQUJZlz.js";
|
|
7
|
-
import { a as L, c as d } from "../../concat_util-DcJk7YHS.js";
|
|
1
|
+
import { p as x, af as I, h as c } from "../../index-DOvlwCh-.js";
|
|
2
|
+
import { e as D } from "../../webgpu_program-DuOXPQol.js";
|
|
3
|
+
import { f as $, c as F } from "../../webgpu_util-RxEF33Rj.js";
|
|
4
|
+
import { r as g } from "../../Reshape-BYkmUnAv.js";
|
|
5
|
+
import { a as L, c as d } from "../../concat_util-DpW8mL_l.js";
|
|
8
6
|
class T {
|
|
9
7
|
outputShape;
|
|
10
8
|
shaderKey;
|
|
@@ -21,7 +19,7 @@ class T {
|
|
|
21
19
|
t,
|
|
22
20
|
1
|
|
23
21
|
/* axis */
|
|
24
|
-
), this.variableNames = t.map((e, a) => `T${a}`), this.dispatchLayout =
|
|
22
|
+
), this.variableNames = t.map((e, a) => `T${a}`), this.dispatchLayout = $(this.outputShape), this.dispatch = F(this.dispatchLayout, this.outputShape, this.workgroupSize, [
|
|
25
23
|
this.workPerThread,
|
|
26
24
|
1,
|
|
27
25
|
1
|
|
@@ -49,7 +47,7 @@ class T {
|
|
|
49
47
|
"result[getIndexFromCoords2D(coords, uniforms.outShape)] = T0[getIndexFromCoords2D(vec2<i32>(yR, yC), uniforms.t0Shape)];"
|
|
50
48
|
);
|
|
51
49
|
return `
|
|
52
|
-
${
|
|
50
|
+
${D("index")} {
|
|
53
51
|
for(var i = 0; i < ${this.workPerThread}; i = i + 1) {
|
|
54
52
|
let flatIndex = index * ${this.workPerThread} + i;
|
|
55
53
|
if(flatIndex < uniforms.size) {
|
|
@@ -86,8 +84,8 @@ function m(n, t, e) {
|
|
|
86
84
|
}
|
|
87
85
|
const l = e.runWebGPUProgram(u, i, i[0].dtype, f);
|
|
88
86
|
i.forEach((o) => e.disposeData(o.dataId));
|
|
89
|
-
const
|
|
90
|
-
return e.disposeData(l.dataId),
|
|
87
|
+
const y = g({ inputs: { x: l }, backend: e, attrs: { shape: s } });
|
|
88
|
+
return e.disposeData(l.dataId), y;
|
|
91
89
|
}
|
|
92
90
|
function P(n, t, e) {
|
|
93
91
|
const a = d(
|
|
@@ -95,7 +93,7 @@ function P(n, t, e) {
|
|
|
95
93
|
t
|
|
96
94
|
);
|
|
97
95
|
return { tensors2D: n.map(
|
|
98
|
-
(s) =>
|
|
96
|
+
(s) => g({
|
|
99
97
|
inputs: { x: s },
|
|
100
98
|
backend: e,
|
|
101
99
|
attrs: {
|
|
@@ -105,7 +103,7 @@ function P(n, t, e) {
|
|
|
105
103
|
), outShape: a };
|
|
106
104
|
}
|
|
107
105
|
function w(n) {
|
|
108
|
-
const { inputs: t, backend: e, attrs: a } = n, { axis: i } = a, s =
|
|
106
|
+
const { inputs: t, backend: e, attrs: a } = n, { axis: i } = a, s = I(i, t[0].shape)[0], h = t.map((r) => r.shape);
|
|
109
107
|
L(h, s);
|
|
110
108
|
const u = d(
|
|
111
109
|
t.map((r) => r.shape),
|
|
@@ -121,7 +119,7 @@ const v = {
|
|
|
121
119
|
backendName: "webgpu",
|
|
122
120
|
kernelFunc: w
|
|
123
121
|
};
|
|
124
|
-
|
|
122
|
+
x(v);
|
|
125
123
|
export {
|
|
126
124
|
T as ConcatProgram,
|
|
127
125
|
v as concatConfig
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { e as u } from "../../webgpu_program-
|
|
2
|
-
import { f as
|
|
3
|
-
import "../../index-
|
|
4
|
-
import { j as s } from "../../tensor-DdQUJZlz.js";
|
|
5
|
-
import { r as c } from "../../tensor_util-DV-FP5Q3.js";
|
|
1
|
+
import { e as u } from "../../webgpu_program-DuOXPQol.js";
|
|
2
|
+
import { f as h, c as p } from "../../webgpu_util-RxEF33Rj.js";
|
|
3
|
+
import { p as c, ab as r } from "../../index-DOvlwCh-.js";
|
|
6
4
|
class l {
|
|
7
5
|
variableNames = ["labels", "logits", "values"];
|
|
8
6
|
outputShape;
|
|
@@ -11,8 +9,8 @@ class l {
|
|
|
11
9
|
dispatch;
|
|
12
10
|
workgroupSize = [64, 1, 1];
|
|
13
11
|
size = !0;
|
|
14
|
-
constructor(
|
|
15
|
-
this.outputShape = [
|
|
12
|
+
constructor(t) {
|
|
13
|
+
this.outputShape = [t], this.dispatchLayout = h(this.outputShape), this.dispatch = p(this.dispatchLayout, this.outputShape, this.workgroupSize);
|
|
16
14
|
}
|
|
17
15
|
getUserCode() {
|
|
18
16
|
return `
|
|
@@ -27,15 +25,15 @@ class l {
|
|
|
27
25
|
`;
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
|
-
function d(
|
|
31
|
-
const { logits:
|
|
32
|
-
s
|
|
28
|
+
function d(e) {
|
|
29
|
+
const { logits: t, labels: a, values: s } = e.inputs, o = e.backend, i = a.shape[0];
|
|
30
|
+
r(s.shape, [i], "Error in EfficientGatherSub: "), r(a.shape, [i], "Error in EfficientGatherSub: ");
|
|
33
31
|
const n = new l(i);
|
|
34
|
-
return o.runWebGPUProgram(n, [a,
|
|
32
|
+
return o.runWebGPUProgram(n, [a, t, s], "float32");
|
|
35
33
|
}
|
|
36
|
-
const
|
|
34
|
+
const b = {
|
|
37
35
|
kernelName: "EfficientGatherSub",
|
|
38
36
|
backendName: "webgpu",
|
|
39
37
|
kernelFunc: d
|
|
40
38
|
};
|
|
41
|
-
c(
|
|
39
|
+
c(b);
|