@genai-fi/nanogpt 0.10.2 → 0.11.0
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.d.ts +10 -5
- package/dist/Generator.js +11760 -146
- package/dist/{RealDiv-zz7FpkKX.js → RealDiv-Ds-jvL09.js} +28 -30
- package/dist/Reshape-Cd6e-Otn.js +14 -0
- package/dist/{Reshape-CHdUjC72.js → Reshape-Ct266DEk.js} +21 -23
- package/dist/TeachableLLM.d.ts +4 -3
- package/dist/TeachableLLM.js +15 -16
- package/dist/Trainer.d.ts +2 -2
- package/dist/Trainer.js +6 -6
- package/dist/{axis_util-BsIr9ZNu.js → axis_util-DofAuy0p.js} +1 -1
- package/dist/backend.js +2 -2
- package/dist/{backend_util-B1XRLuq9.js → backend_util-C7NWHpv7.js} +72 -73
- package/dist/{backend_webgpu-CqpfEImu.js → backend_webgpu-B0Vls736.js} +52 -54
- package/dist/broadcast_to-DDaNMbX7.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 +11 -12
- package/dist/checks/rope.js +2 -2
- package/dist/clip_by_value-Dn5tzexi.js +12 -0
- package/dist/complex-DClmWqJt.js +11 -0
- package/dist/concat-C6X3AAlQ.js +17 -0
- package/dist/{concat_util-iBYIyuQe.js → concat_util-CHsJFZJJ.js} +1 -1
- package/dist/{dataset-D2P7rHAw.js → dataset-DcjWqUVQ.js} +135 -137
- package/dist/dropout-OxuaJz6z.js +92 -0
- package/dist/expand_dims-BzfJK2uc.js +11 -0
- package/dist/{exports_initializers-CZSUJoVE.js → exports_initializers-eS9QJ6ut.js} +1 -1
- package/dist/floor-DIb-lN_u.js +9 -0
- package/dist/gather-BcO5UQNJ.js +9 -0
- package/dist/{gelu-Bmhopi0J.js → gelu-DqTbCx5x.js} +10 -11
- package/dist/{gpgpu_math-DsCcikas.js → gpgpu_math-CJcbnKPC.js} +841 -1015
- package/dist/index-D0RBWjq8.js +3520 -0
- package/dist/{index-DRyE072i.js → index-Dj5TkmPY.js} +330 -331
- package/dist/{kernel_funcs_utils-CWfOAPGO.js → kernel_funcs_utils-CSaumNDs.js} +132 -134
- package/dist/layers/BaseLayer.js +15 -16
- 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 +21 -22
- package/dist/log_sum_exp-VLZgbFAH.js +39 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.js +49 -50
- package/dist/{matMul16-fEAJ4smh.js → matMul16-cDxwemKj.js} +14 -15
- package/dist/matMulGelu-B2s_80-H.js +163 -0
- package/dist/mat_mul-DxpNTCRz.js +11 -0
- package/dist/mod-PrOKlFxH.js +11 -0
- package/dist/models/NanoGPTV1.js +2 -2
- package/dist/models/model.js +13 -14
- package/dist/ones-BX_wEgzB.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 +12 -13
- package/dist/ops/cpu/adamMoments.js +6 -7
- package/dist/ops/cpu/appendCache.js +7 -8
- package/dist/ops/cpu/attentionMask.js +11 -11
- package/dist/ops/cpu/fusedSoftmax.js +10 -11
- package/dist/ops/cpu/gatherSub.js +10 -11
- package/dist/ops/cpu/gelu.js +14 -15
- 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 +11 -12
- package/dist/ops/cpu/qkv.js +8 -9
- package/dist/ops/cpu/rope.js +9 -10
- package/dist/ops/cpu/scatterSub.js +14 -16
- 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 +10 -11
- 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 +8 -9
- package/dist/ops/grads/normRMS.js +9 -10
- 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 +16 -18
- 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 +5 -6
- package/dist/ops/webgl/fusedSoftmax.js +6 -8
- 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 +15 -16
- package/dist/ops/webgl/matMulGelu.js +7 -111
- package/dist/ops/webgl/matMulMul.js +14 -15
- package/dist/ops/webgl/mulDropout.js +8 -9
- package/dist/ops/webgl/normRMS.js +7 -8
- 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 +10 -12
- package/dist/ops/webgpu/attentionMask32_program.js +2 -2
- package/dist/ops/webgpu/concat16.js +12 -14
- package/dist/ops/webgpu/gatherSub.js +9 -11
- 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 +7 -8
- package/dist/ops/webgpu/normRMS.js +17 -19
- 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 +13 -15
- 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 +8 -9
- package/dist/ops/webgpu/sum16.js +19 -21
- 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-FJapAPfm.js +476 -0
- package/dist/pack16-k4jq6aMX.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 +15 -16
- package/dist/{random_width-BVV9HveY.js → random_width-UGQn4OWb.js} +2506 -2761
- package/dist/range-CuGvVN2c.js +10 -0
- package/dist/relu-Cf80uA2p.js +9 -0
- package/dist/reshape-CkjKPPqB.js +9 -0
- package/dist/resize_nearest_neighbor-DB8k9KN_.js +175 -0
- package/dist/rope-BmZmp9uP.js +24 -0
- package/dist/{scatter_nd_util-C7zXRT_h.js → scatter_nd_util-BY22Cc-C.js} +1 -1
- package/dist/selu_util-BuLbmbrl.js +44 -0
- package/dist/{shared-CHhxz-O5.js → shared-B7USJZgw.js} +1 -1
- package/dist/{shared-D2NP_CpY.js → shared-BQboIImQ.js} +379 -381
- package/dist/slice-Aqy7KbJh.js +12 -0
- package/dist/{slice_util-DyjSAD0u.js → slice_util-D8CQRenR.js} +7 -7
- package/dist/{softmax-C9JQEtnO.js → softmax-faLoUZVT.js} +4 -5
- package/dist/split-BNz5jcGc.js +9 -0
- package/dist/squeeze--YMgaAAf.js +10 -0
- package/dist/stack-WJK22CFn.js +11 -0
- package/dist/step-dXR33iOg.js +261 -0
- package/dist/sum-BdplSvq_.js +11 -0
- package/dist/{tensor-0r5yOo2R.js → tensor-BQqrDvpx.js} +1 -1
- package/dist/tensor1d-LxP9asMm.js +11 -0
- package/dist/{tensor2d-CSB4KOb0.js → tensor2d-BN1sSfQO.js} +6 -7
- package/dist/{tensor4d-D7bLqGqz.js → tensor4d-DVwr7pLF.js} +6 -7
- package/dist/{tfjs_backend-CNkSTL0c.js → tfjs_backend-Vi4JfLzT.js} +256 -265
- package/dist/tile-CvN_LyVr.js +11 -0
- package/dist/tokeniser/BaseTokeniser.d.ts +27 -0
- package/dist/tokeniser/BaseTokeniser.js +94 -0
- package/dist/tokeniser/CharTokeniser.d.ts +4 -3
- package/dist/tokeniser/CharTokeniser.js +46 -32
- package/dist/tokeniser/bpe.d.ts +4 -3
- package/dist/tokeniser/bpe.js +60 -45
- package/dist/tokeniser/type.d.ts +11 -0
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.d.ts +2 -2
- package/dist/training/DatasetBuilder.js +32 -36
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.d.ts +3 -3
- package/dist/training/Trainer.js +2 -2
- package/dist/training/sparseCrossEntropy.js +5 -5
- package/dist/transpose-JawVKyZy.js +36 -0
- package/dist/unsorted_segment_sum-LAbmE9G4.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 -745
- 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-DzfrwYuP.js → variable-DQ9yYgEU.js} +1 -1
- package/dist/{webgpu_program-DzaQiqel.js → webgpu_program-CAE4RICo.js} +177 -171
- package/dist/{webgpu_util-0_ubCEHJ.js → webgpu_util-BdovYhXr.js} +34 -35
- package/dist/zeros-DeiE2zTa.js +13 -0
- package/dist/zeros_like-BAz3iKru.js +721 -0
- package/package.json +4 -2
- package/dist/Reshape-CDVLyVfz.js +0 -16
- package/dist/broadcast_to-B0ChcDaz.js +0 -30
- package/dist/complex-BBiRlsVq.js +0 -13
- package/dist/concat-DmBLPVGC.js +0 -19
- package/dist/dropout-B1x1kYMa.js +0 -99
- package/dist/expand_dims-ouvfxQ1n.js +0 -13
- package/dist/gather-CH9sdacz.js +0 -10
- package/dist/index-D6Q1lPZO.js +0 -2157
- package/dist/log_sum_exp-D3ftBNY5.js +0 -41
- package/dist/mat_mul-C59XWcJd.js +0 -12
- package/dist/mod-DESSvHIU.js +0 -12
- package/dist/mulmat_packed_gpu-Coh6qbJk.js +0 -55
- package/dist/ones-jU9jlQvM.js +0 -15
- package/dist/ops-BFDtP6th.js +0 -645
- package/dist/pack16-CmVZs6af.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 -12
- package/dist/patches/tape.d.ts +0 -12
- package/dist/patches/tape.js +0 -5
- package/dist/range-ZZZD60Fx.js +0 -11
- package/dist/reciprocal-CrYlsAGD.js +0 -10
- package/dist/register_all_kernels-nvj2k7OC.js +0 -12307
- package/dist/relu-BYDneVPn.js +0 -10
- package/dist/reshape-CaPQzFvz.js +0 -10
- package/dist/rope-s4W2XO9B.js +0 -32
- package/dist/selu_util-BGPXmd4B.js +0 -303
- package/dist/sin-Djs4aQiu.js +0 -16
- package/dist/slice-DvovR5wq.js +0 -13
- package/dist/split-DBck65sX.js +0 -10
- package/dist/squeeze-C00Ipm_7.js +0 -11
- package/dist/stack-ChnHwRpX.js +0 -13
- package/dist/sum-ywRJj3Zr.js +0 -12
- package/dist/tensor-CzmOBsdf.js +0 -909
- package/dist/tensor1d-BlUT89BP.js +0 -12
- package/dist/tensor_util-DfwaWayG.js +0 -523
- package/dist/tile-CR074jmp.js +0 -13
- package/dist/transpose-DH4gmHvu.js +0 -38
- package/dist/zeros-DBFVbpv5.js +0 -14
|
@@ -1,15 +1,94 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { u as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { $ as B, V as K, aQ as G, a8 as W, aJ as z, aR as V, ab as N, aK as F, ak as S } from "./index-D0RBWjq8.js";
|
|
2
|
+
import { u as O, f as Y } from "./gpgpu_math-CJcbnKPC.js";
|
|
3
|
+
import { f as v } from "./backend_util-C7NWHpv7.js";
|
|
4
|
+
function H(t, e) {
|
|
5
|
+
return ["x", "y", "z", "w", "u", "v"].slice(0, e).map((s) => `${t}.${s}`);
|
|
6
|
+
}
|
|
7
|
+
function Z(t, e) {
|
|
8
|
+
return e === 1 ? [t] : H(t, e);
|
|
9
|
+
}
|
|
10
|
+
function pe(t, e) {
|
|
11
|
+
if (t === 1)
|
|
12
|
+
return "rc";
|
|
13
|
+
let s = "";
|
|
14
|
+
for (let r = 0; r < t; r++)
|
|
15
|
+
s += e[r], r < t - 1 && (s += ",");
|
|
16
|
+
return s;
|
|
17
|
+
}
|
|
18
|
+
class q {
|
|
19
|
+
constructor(e, s) {
|
|
20
|
+
this.variableNames = ["A"], this.outputShape = e, this.enableShapeUniforms = O(this.outputShape.length), this.userCode = `
|
|
21
|
+
float unaryOperation(float x) {
|
|
22
|
+
${s}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void main() {
|
|
26
|
+
float x = getAAtOutCoords();
|
|
27
|
+
float y = unaryOperation(x);
|
|
28
|
+
|
|
29
|
+
setOutput(y);
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const T = "if (isnan(x)) return x;", M = "return x;", de = "return abs(x);", j = "return (x >= 0.0) ? x : (exp(x) - 1.0);", J = T + `
|
|
35
|
+
return (x < 0.0) ? 0.0 : x;
|
|
36
|
+
`, Q = T + `
|
|
37
|
+
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
38
|
+
`, he = "return x;", X = "return 1.0 / (1.0 + exp(-1.0 * x));";
|
|
39
|
+
const ee = "return x;", te = `
|
|
40
|
+
vec4 result;
|
|
41
|
+
|
|
42
|
+
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
|
|
43
|
+
result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
|
|
44
|
+
result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
|
|
45
|
+
result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
`, se = `
|
|
49
|
+
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
50
|
+
bvec4 isNaN = isnan(x);
|
|
51
|
+
|
|
52
|
+
result.r = isNaN.r ? x.r : result.r;
|
|
53
|
+
result.g = isNaN.g ? x.g : result.g;
|
|
54
|
+
result.b = isNaN.b ? x.b : result.b;
|
|
55
|
+
result.a = isNaN.a ? x.a : result.a;
|
|
56
|
+
|
|
57
|
+
return result;
|
|
58
|
+
`, ae = `
|
|
59
|
+
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
60
|
+
bvec4 isNaN = isnan(x);
|
|
61
|
+
|
|
62
|
+
result.r = isNaN.r ? x.r : result.r;
|
|
63
|
+
result.g = isNaN.g ? x.g : result.g;
|
|
64
|
+
result.b = isNaN.b ? x.b : result.b;
|
|
65
|
+
result.a = isNaN.a ? x.a : result.a;
|
|
66
|
+
|
|
67
|
+
return result;
|
|
68
|
+
`, re = "return 1.0 / (1.0 + exp(-1.0 * x));";
|
|
69
|
+
class ne {
|
|
70
|
+
constructor(e, s) {
|
|
71
|
+
this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e, this.enableShapeUniforms = O(this.outputShape.length), this.userCode = `
|
|
72
|
+
vec4 unaryOperation(vec4 x) {
|
|
73
|
+
${s}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void main() {
|
|
77
|
+
vec4 x = getAAtOutCoords();
|
|
78
|
+
vec4 y = unaryOperation(x);
|
|
79
|
+
|
|
80
|
+
setOutput(y);
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const fe = `
|
|
7
86
|
if (isnan(a)) return a;
|
|
8
87
|
if (isnan(b)) return b;
|
|
9
88
|
`;
|
|
10
89
|
class b {
|
|
11
90
|
constructor(e, s, r) {
|
|
12
|
-
this.variableNames = ["A", "B"], this.outputShape = B(s, r), this.enableShapeUniforms =
|
|
91
|
+
this.variableNames = ["A", "B"], this.outputShape = B(s, r), this.enableShapeUniforms = O(this.outputShape.length), this.userCode = `
|
|
13
92
|
float binaryOperation(float a, float b) {
|
|
14
93
|
${e}
|
|
15
94
|
}
|
|
@@ -22,20 +101,6 @@ class b {
|
|
|
22
101
|
`;
|
|
23
102
|
}
|
|
24
103
|
}
|
|
25
|
-
function Y(t, e) {
|
|
26
|
-
return ["x", "y", "z", "w", "u", "v"].slice(0, e).map((s) => `${t}.${s}`);
|
|
27
|
-
}
|
|
28
|
-
function Z(t, e) {
|
|
29
|
-
return e === 1 ? [t] : Y(t, e);
|
|
30
|
-
}
|
|
31
|
-
function fe(t, e) {
|
|
32
|
-
if (t === 1)
|
|
33
|
-
return "rc";
|
|
34
|
-
let s = "";
|
|
35
|
-
for (let r = 0; r < t; r++)
|
|
36
|
-
s += e[r], r < t - 1 && (s += ",");
|
|
37
|
-
return s;
|
|
38
|
-
}
|
|
39
104
|
const xe = `
|
|
40
105
|
result.r = isNaN.r ? NAN : result.r;
|
|
41
106
|
result.g = isNaN.g ? NAN : result.g;
|
|
@@ -46,7 +111,7 @@ class E {
|
|
|
46
111
|
constructor(e, s, r, u = !1) {
|
|
47
112
|
this.variableNames = ["A", "B"], this.supportsBroadcasting = !0, this.packedInputs = !0, this.packedOutput = !0, this.outputShape = B(s, r);
|
|
48
113
|
const n = this.outputShape.length;
|
|
49
|
-
this.enableShapeUniforms =
|
|
114
|
+
this.enableShapeUniforms = O(n);
|
|
50
115
|
let o = "";
|
|
51
116
|
if (u)
|
|
52
117
|
if (n === 0 || K(this.outputShape) === 1)
|
|
@@ -56,7 +121,7 @@ class E {
|
|
|
56
121
|
result.w = 0.;
|
|
57
122
|
`;
|
|
58
123
|
else if (o = `
|
|
59
|
-
${
|
|
124
|
+
${Y(n)} coords = getOutputCoords();
|
|
60
125
|
`, n === 1)
|
|
61
126
|
this.enableShapeUniforms ? o += `
|
|
62
127
|
result.y = (coords + 1) >= outShape ? 0. : result.y;
|
|
@@ -109,126 +174,59 @@ function P(t) {
|
|
|
109
174
|
return s.incRef(r.dataId), { dataId: r.dataId, shape: r.shape, dtype: r.dtype };
|
|
110
175
|
}
|
|
111
176
|
const ge = {
|
|
112
|
-
kernelName:
|
|
177
|
+
kernelName: G,
|
|
113
178
|
backendName: "webgl",
|
|
114
179
|
kernelFunc: P
|
|
115
180
|
};
|
|
116
|
-
function
|
|
181
|
+
function L(t) {
|
|
117
182
|
const { inputs: e, backend: s } = t, { real: r, imag: u } = e, n = s.makeTensorInfo(r.shape, "complex64"), o = s.texData.get(n.dataId), i = P({ inputs: { x: r }, backend: s }), a = P({ inputs: { x: u }, backend: s });
|
|
118
183
|
return o.complexTensorInfos = { real: i, imag: a }, n;
|
|
119
184
|
}
|
|
120
185
|
const me = {
|
|
121
|
-
kernelName:
|
|
186
|
+
kernelName: W,
|
|
122
187
|
backendName: "webgl",
|
|
123
|
-
kernelFunc:
|
|
188
|
+
kernelFunc: L
|
|
124
189
|
};
|
|
125
|
-
const
|
|
190
|
+
const w = "return (a < 0.) ? b * a : a;", R = `
|
|
126
191
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
127
192
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
128
193
|
`;
|
|
129
|
-
function
|
|
130
|
-
const { inputs: e, backend: s, attrs: r } = t, { x: u } = e, { alpha: n } = r, o = s.makeTensorInfo([], "float32",
|
|
194
|
+
function oe(t) {
|
|
195
|
+
const { inputs: e, backend: s, attrs: r } = t, { x: u } = e, { alpha: n } = r, o = s.makeTensorInfo([], "float32", V(n, "float32")), i = N().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new E(R, u.shape, o.shape) : new b(w, u.shape, o.shape), a = s.runWebGLProgram(i, [u, o], "float32");
|
|
131
196
|
return s.disposeIntermediateTensorInfo(o), a;
|
|
132
197
|
}
|
|
133
198
|
const be = {
|
|
134
|
-
kernelName:
|
|
199
|
+
kernelName: z,
|
|
135
200
|
backendName: "webgl",
|
|
136
|
-
kernelFunc:
|
|
201
|
+
kernelFunc: oe
|
|
137
202
|
};
|
|
138
|
-
const
|
|
203
|
+
const k = "return (a < 0.) ? b * a : a;", $ = `
|
|
139
204
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
140
205
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
141
206
|
`;
|
|
142
|
-
function
|
|
143
|
-
const { inputs: e, backend: s } = t, { x: r, alpha: u } = e, n =
|
|
207
|
+
function ue(t) {
|
|
208
|
+
const { inputs: e, backend: s } = t, { x: r, alpha: u } = e, n = N().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new E($, r.shape, u.shape) : new b(k, r.shape, u.shape);
|
|
144
209
|
return s.runWebGLProgram(n, [r, u], "float32");
|
|
145
210
|
}
|
|
146
211
|
const Ne = {
|
|
147
|
-
kernelName:
|
|
212
|
+
kernelName: F,
|
|
148
213
|
backendName: "webgl",
|
|
149
|
-
kernelFunc:
|
|
214
|
+
kernelFunc: ue
|
|
150
215
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
this.variableNames = ["A"], this.outputShape = e, this.enableShapeUniforms = N(this.outputShape.length), this.userCode = `
|
|
154
|
-
float unaryOperation(float x) {
|
|
155
|
-
${s}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
void main() {
|
|
159
|
-
float x = getAAtOutCoords();
|
|
160
|
-
float y = unaryOperation(x);
|
|
161
|
-
|
|
162
|
-
setOutput(y);
|
|
163
|
-
}
|
|
164
|
-
`;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const U = "if (isnan(x)) return x;", X = "return x;", Oe = "return abs(x);", J = "return (x >= 0.0) ? x : (exp(x) - 1.0);", Q = U + `
|
|
168
|
-
return (x < 0.0) ? 0.0 : x;
|
|
169
|
-
`, ee = U + `
|
|
170
|
-
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
171
|
-
`, ye = "return x;", te = "return 1.0 / (1.0 + exp(-1.0 * x));";
|
|
172
|
-
const se = "return x;", ae = `
|
|
173
|
-
vec4 result;
|
|
174
|
-
|
|
175
|
-
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
|
|
176
|
-
result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
|
|
177
|
-
result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
|
|
178
|
-
result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
|
|
179
|
-
|
|
180
|
-
return result;
|
|
181
|
-
`, re = `
|
|
182
|
-
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
183
|
-
bvec4 isNaN = isnan(x);
|
|
184
|
-
|
|
185
|
-
result.r = isNaN.r ? x.r : result.r;
|
|
186
|
-
result.g = isNaN.g ? x.g : result.g;
|
|
187
|
-
result.b = isNaN.b ? x.b : result.b;
|
|
188
|
-
result.a = isNaN.a ? x.a : result.a;
|
|
189
|
-
|
|
190
|
-
return result;
|
|
191
|
-
`, ne = `
|
|
192
|
-
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
193
|
-
bvec4 isNaN = isnan(x);
|
|
194
|
-
|
|
195
|
-
result.r = isNaN.r ? x.r : result.r;
|
|
196
|
-
result.g = isNaN.g ? x.g : result.g;
|
|
197
|
-
result.b = isNaN.b ? x.b : result.b;
|
|
198
|
-
result.a = isNaN.a ? x.a : result.a;
|
|
199
|
-
|
|
200
|
-
return result;
|
|
201
|
-
`, oe = "return 1.0 / (1.0 + exp(-1.0 * x));";
|
|
202
|
-
class ue {
|
|
203
|
-
constructor(e, s) {
|
|
204
|
-
this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e, this.enableShapeUniforms = N(this.outputShape.length), this.userCode = `
|
|
205
|
-
vec4 unaryOperation(vec4 x) {
|
|
206
|
-
${s}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
void main() {
|
|
210
|
-
vec4 x = getAAtOutCoords();
|
|
211
|
-
vec4 y = unaryOperation(x);
|
|
212
|
-
|
|
213
|
-
setOutput(y);
|
|
214
|
-
}
|
|
215
|
-
`;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
const Ie = "if (isnan(x)) return x;";
|
|
219
|
-
function Ae({ opSnippet: t, packedOpSnippet: e, cpuKernelImpl: s, dtype: r }) {
|
|
216
|
+
const Oe = "if (isnan(x)) return x;";
|
|
217
|
+
function ye({ opSnippet: t, packedOpSnippet: e, cpuKernelImpl: s, dtype: r }) {
|
|
220
218
|
return ({ inputs: u, backend: n }) => {
|
|
221
219
|
const { x: o } = u, i = n, a = r || o.dtype;
|
|
222
220
|
if (i.shouldExecuteOnCPU([o]) && s != null) {
|
|
223
221
|
const d = i.texData.get(o.dataId), y = s(d.values, a);
|
|
224
222
|
return i.makeTensorInfo(o.shape, a, y);
|
|
225
223
|
}
|
|
226
|
-
const c =
|
|
224
|
+
const c = N().getBool("WEBGL_PACK_UNARY_OPERATIONS") && e != null;
|
|
227
225
|
let l;
|
|
228
|
-
return c ? l = new
|
|
226
|
+
return c ? l = new ne(o.shape, e) : l = new q(o.shape, t), i.runWebGLProgram(l, [o], a);
|
|
229
227
|
};
|
|
230
228
|
}
|
|
231
|
-
function
|
|
229
|
+
function Ie({ opSnippet: t, packedOpSnippet: e, checkOutOfBounds: s = !1, supportsComplex: r = !1, cpuKernelImpl: u, dtype: n }) {
|
|
232
230
|
return ({ inputs: o, backend: i }) => {
|
|
233
231
|
const { a, b: c } = o, l = i;
|
|
234
232
|
if (r && a.dtype === "complex64") {
|
|
@@ -236,7 +234,7 @@ function Ce({ opSnippet: t, packedOpSnippet: e, checkOutOfBounds: s = !1, suppor
|
|
|
236
234
|
[h.complexTensorInfos.real, f.complexTensorInfos.real],
|
|
237
235
|
[h.complexTensorInfos.imag, f.complexTensorInfos.imag]
|
|
238
236
|
].map((C) => {
|
|
239
|
-
const [p, x] = C,
|
|
237
|
+
const [p, x] = C, U = {
|
|
240
238
|
dataId: p.dataId,
|
|
241
239
|
dtype: p.dtype,
|
|
242
240
|
shape: a.shape
|
|
@@ -245,8 +243,8 @@ function Ce({ opSnippet: t, packedOpSnippet: e, checkOutOfBounds: s = !1, suppor
|
|
|
245
243
|
dtype: x.dtype,
|
|
246
244
|
shape: c.shape
|
|
247
245
|
}, D = new b(t, a.shape, c.shape);
|
|
248
|
-
return l.runWebGLProgram(D, [
|
|
249
|
-
}), A =
|
|
246
|
+
return l.runWebGLProgram(D, [U, _], S(p.dtype, x.dtype));
|
|
247
|
+
}), A = L({ inputs: { real: g, imag: m }, backend: l });
|
|
250
248
|
return l.disposeIntermediateTensorInfo(g), l.disposeIntermediateTensorInfo(m), A;
|
|
251
249
|
}
|
|
252
250
|
const d = n || S(a.dtype, c.dtype);
|
|
@@ -260,49 +258,49 @@ function Ce({ opSnippet: t, packedOpSnippet: e, checkOutOfBounds: s = !1, suppor
|
|
|
260
258
|
) : f, [A, C] = u(a.shape, c.shape, g, m, d), p = l.makeTensorInfo(C, d), x = l.texData.get(p.dataId);
|
|
261
259
|
return x.values = A, p;
|
|
262
260
|
}
|
|
263
|
-
const y =
|
|
261
|
+
const y = N().getBool("WEBGL_PACK_BINARY_OPERATIONS") && e != null;
|
|
264
262
|
let I;
|
|
265
263
|
return y ? I = new E(e, a.shape, c.shape, s) : I = new b(t, a.shape, c.shape), l.runWebGLProgram(I, [a, c], d);
|
|
266
264
|
};
|
|
267
265
|
}
|
|
268
|
-
function
|
|
266
|
+
function Ae(t, e = !1) {
|
|
269
267
|
if (t === "linear")
|
|
270
|
-
return e ?
|
|
268
|
+
return e ? ee : M;
|
|
271
269
|
if (t === "relu")
|
|
272
|
-
return e ?
|
|
270
|
+
return e ? se : J;
|
|
273
271
|
if (t === "elu")
|
|
274
|
-
return e ?
|
|
272
|
+
return e ? te : j;
|
|
275
273
|
if (t === "relu6")
|
|
276
|
-
return e ?
|
|
274
|
+
return e ? ae : Q;
|
|
277
275
|
if (t === "prelu")
|
|
278
|
-
return e ?
|
|
276
|
+
return e ? $ : k;
|
|
279
277
|
if (t === "leakyrelu")
|
|
280
|
-
return e ?
|
|
278
|
+
return e ? R : w;
|
|
281
279
|
if (t === "sigmoid")
|
|
282
|
-
return e ?
|
|
280
|
+
return e ? re : X;
|
|
283
281
|
throw new Error(`Activation ${t} has not been implemented for the WebGL backend.`);
|
|
284
282
|
}
|
|
285
283
|
export {
|
|
286
|
-
|
|
284
|
+
de as A,
|
|
287
285
|
E as B,
|
|
288
|
-
|
|
289
|
-
|
|
286
|
+
T as C,
|
|
287
|
+
ne as U,
|
|
290
288
|
Z as a,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
289
|
+
Ie as b,
|
|
290
|
+
pe as c,
|
|
291
|
+
he as d,
|
|
292
|
+
q as e,
|
|
293
|
+
L as f,
|
|
294
|
+
H as g,
|
|
297
295
|
b as h,
|
|
298
296
|
P as i,
|
|
299
|
-
|
|
297
|
+
fe as j,
|
|
300
298
|
xe as k,
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
Oe as l,
|
|
300
|
+
Ae as m,
|
|
303
301
|
me as n,
|
|
304
302
|
ge as o,
|
|
305
303
|
be as p,
|
|
306
304
|
Ne as q,
|
|
307
|
-
|
|
305
|
+
ye as u
|
|
308
306
|
};
|
package/dist/layers/BaseLayer.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { v as
|
|
3
|
-
|
|
4
|
-
class F {
|
|
1
|
+
import { x as p, a4 as g, a2 as v, e as o, a5 as _ } from "../index-D0RBWjq8.js";
|
|
2
|
+
import { v as V } from "../variable-DQ9yYgEU.js";
|
|
3
|
+
class T {
|
|
5
4
|
parent;
|
|
6
5
|
config;
|
|
7
6
|
_variables = /* @__PURE__ */ new Map();
|
|
@@ -52,9 +51,9 @@ class F {
|
|
|
52
51
|
const e = this._variables.get(t);
|
|
53
52
|
if (!e && r)
|
|
54
53
|
for (const i of this.children) {
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
54
|
+
const a = i.getVariable(t, !0);
|
|
55
|
+
if (a)
|
|
56
|
+
return a;
|
|
58
57
|
}
|
|
59
58
|
if (!e)
|
|
60
59
|
throw new Error(`Variable ${t} not found`);
|
|
@@ -80,7 +79,7 @@ class F {
|
|
|
80
79
|
const i = t.get(e)?.[0];
|
|
81
80
|
if (!i)
|
|
82
81
|
throw new Error(`Weights for ${e} not found`);
|
|
83
|
-
r ? r.assign(i) : this._variables.set(e,
|
|
82
|
+
r ? r.assign(i) : this._variables.set(e, V(i, this._trainable));
|
|
84
83
|
}), this.children.forEach((r) => {
|
|
85
84
|
r.loadWeights(t);
|
|
86
85
|
});
|
|
@@ -98,7 +97,7 @@ class F {
|
|
|
98
97
|
call(t, ...r) {
|
|
99
98
|
this.build();
|
|
100
99
|
const e = this.forward(t, ...r);
|
|
101
|
-
if (t.training && e instanceof
|
|
100
|
+
if (t.training && e instanceof g) {
|
|
102
101
|
const i = this.dropout(e);
|
|
103
102
|
return i !== e && e.dispose(), i;
|
|
104
103
|
} else
|
|
@@ -108,22 +107,22 @@ class F {
|
|
|
108
107
|
return this.build(), this.checkpointingFn(t, ...r);
|
|
109
108
|
}
|
|
110
109
|
checkpointingFn(t, ...r) {
|
|
111
|
-
const e = this.trainableVariables,
|
|
112
|
-
const l =
|
|
110
|
+
const e = this.trainableVariables, a = v((...s) => {
|
|
111
|
+
const l = s[s.length - 1], n = s.slice(0, r.length), h = this.forward(t, ...n);
|
|
113
112
|
return l(n), { value: h, gradFunc: (c, f) => {
|
|
114
113
|
const u = o().state.activeTape;
|
|
115
114
|
o().state.activeTape = [];
|
|
116
|
-
const b =
|
|
115
|
+
const b = _((...d) => this.forward(t, ...d.slice(0, n.length)))([...f, ...e], c);
|
|
117
116
|
return o().state.activeTape = u, b;
|
|
118
117
|
} };
|
|
119
118
|
})(...r, ...e);
|
|
120
119
|
if (t.training) {
|
|
121
|
-
const
|
|
122
|
-
return
|
|
120
|
+
const s = this.dropout(a);
|
|
121
|
+
return s !== a && a.dispose(), s;
|
|
123
122
|
} else
|
|
124
|
-
return
|
|
123
|
+
return a;
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
export {
|
|
128
|
-
|
|
127
|
+
T as default
|
|
129
128
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { attentionMask as P } from "../ops/attentionMask.js";
|
|
2
2
|
import _ from "./BaseLayer.js";
|
|
3
|
-
import { r as k } from "../rope-
|
|
3
|
+
import { r as k } from "../rope-BmZmp9uP.js";
|
|
4
4
|
import { appendCache as b } from "../ops/appendCache.js";
|
|
5
|
-
import { k as u, t as S } from "../index-
|
|
5
|
+
import { k as u, t as S } from "../index-D0RBWjq8.js";
|
|
6
6
|
import { softmax16 as C } from "../ops/softmax16.js";
|
|
7
|
-
import { b as R } from "../matMul16-
|
|
8
|
-
import { p as V } from "../pack16-
|
|
7
|
+
import { b as R } from "../matMul16-cDxwemKj.js";
|
|
8
|
+
import { p as V } from "../pack16-k4jq6aMX.js";
|
|
9
9
|
import { transpose16 as J } from "../ops/transpose16.js";
|
|
10
10
|
import { dot16 as L } from "../ops/dot16.js";
|
|
11
11
|
import { reshape16 as N } from "../ops/reshape16.js";
|
|
12
12
|
import { isPackedTensor as l } from "../utilities/packed.js";
|
|
13
13
|
import { qkv as j } from "../ops/qkv.js";
|
|
14
|
-
import { v as T } from "../variable-
|
|
15
|
-
import { r as v, d as y } from "../dropout-
|
|
14
|
+
import { v as T } from "../variable-DQ9yYgEU.js";
|
|
15
|
+
import { r as v, d as y } from "../dropout-OxuaJz6z.js";
|
|
16
16
|
class X extends _ {
|
|
17
17
|
divisor;
|
|
18
18
|
index;
|
package/dist/layers/MLP.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as p } from "../index-
|
|
1
|
+
import { t as p } from "../index-D0RBWjq8.js";
|
|
2
2
|
import u from "./BaseLayer.js";
|
|
3
|
-
import { c, b as M } from "../matMul16-
|
|
3
|
+
import { c, b as M } from "../matMul16-cDxwemKj.js";
|
|
4
4
|
import { reshape16 as o } from "../ops/reshape16.js";
|
|
5
|
-
import { v as d } from "../variable-
|
|
6
|
-
import { r as h, d as b } from "../dropout-
|
|
5
|
+
import { v as d } from "../variable-DQ9yYgEU.js";
|
|
6
|
+
import { r as h, d as b } from "../dropout-OxuaJz6z.js";
|
|
7
7
|
class O extends u {
|
|
8
8
|
index;
|
|
9
9
|
hiddenUnits;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as c,
|
|
1
|
+
import { t as c, al as u, b as i } from "../index-D0RBWjq8.js";
|
|
2
2
|
import f from "./BaseLayer.js";
|
|
3
|
-
import { E as g, D as h } from "../random_width-
|
|
4
|
-
import { r as
|
|
5
|
-
import { m as
|
|
6
|
-
import { r as w } from "../range-
|
|
3
|
+
import { E as g, D as h } from "../random_width-UGQn4OWb.js";
|
|
4
|
+
import { r as l } from "../exports_initializers-eS9QJ6ut.js";
|
|
5
|
+
import { m as b } from "../mod-PrOKlFxH.js";
|
|
6
|
+
import { r as w } from "../range-CuGvVN2c.js";
|
|
7
7
|
function E(t) {
|
|
8
8
|
return new h(t);
|
|
9
9
|
}
|
|
@@ -20,13 +20,13 @@ class q extends f {
|
|
|
20
20
|
inputDim: this.config.blockSize,
|
|
21
21
|
outputDim: this.config.nEmbed,
|
|
22
22
|
name: n,
|
|
23
|
-
embeddingsInitializer:
|
|
23
|
+
embeddingsInitializer: l({ mean: 0, stddev: 0.02 })
|
|
24
24
|
}), this.drop = E({ rate: this.config.dropout });
|
|
25
25
|
}
|
|
26
26
|
forward(o, n) {
|
|
27
27
|
const r = o.cache?.[0]?.length ?? 0;
|
|
28
28
|
return c(() => {
|
|
29
|
-
const [, s] = n.shape, e = this.config.blockSize, a = w(0, s, 1, "int32"), m =
|
|
29
|
+
const [, s] = n.shape, e = this.config.blockSize, a = w(0, s, 1, "int32"), m = b(u(a, i(r, "int32")), i(e, "int32")), d = this.wpe.apply(m), p = n.add(d);
|
|
30
30
|
return this.drop.apply(p, { training: o.training });
|
|
31
31
|
});
|
|
32
32
|
}
|
package/dist/layers/RMSNorm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as s } from "../index-
|
|
1
|
+
import { t as s } from "../index-D0RBWjq8.js";
|
|
2
2
|
import e from "./BaseLayer.js";
|
|
3
3
|
import { normRMS as a } from "../ops/normRMS.js";
|
|
4
|
-
import { v as i } from "../variable-
|
|
5
|
-
import { o as m } from "../ones-
|
|
4
|
+
import { v as i } from "../variable-DQ9yYgEU.js";
|
|
5
|
+
import { o as m } from "../ones-BX_wEgzB.js";
|
|
6
6
|
class l extends e {
|
|
7
7
|
GAMMA;
|
|
8
8
|
constructor(r, t = "", o) {
|
package/dist/layers/RoPECache.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { b as n, p as
|
|
2
|
-
import { r as
|
|
3
|
-
import { c as
|
|
4
|
-
import { r as h } from "../range-
|
|
5
|
-
class
|
|
1
|
+
import { l as a, b as n, p as c, t as p, k as r } from "../index-D0RBWjq8.js";
|
|
2
|
+
import { r as l } from "../zeros_like-BAz3iKru.js";
|
|
3
|
+
import { c as f, s as m } from "../unsorted_segment_sum-LAbmE9G4.js";
|
|
4
|
+
import { r as h } from "../range-CuGvVN2c.js";
|
|
5
|
+
class D {
|
|
6
6
|
constructor(s) {
|
|
7
7
|
this.config = s;
|
|
8
8
|
const i = this.config.nEmbed / this.config.nHead;
|
|
9
9
|
if (this.rotaryDim = i, this.rotaryDim % 2 !== 0)
|
|
10
10
|
throw new Error("rotaryDim must be even");
|
|
11
11
|
this.ropeBase = 1e4;
|
|
12
|
-
const o = h(0, this.rotaryDim, 2, "float32"), e = o
|
|
13
|
-
this.ropeInvFreq =
|
|
12
|
+
const o = h(0, this.rotaryDim, 2, "float32"), e = a(o, n(this.rotaryDim, "float32")), t = c(n(this.ropeBase, "float32"), e);
|
|
13
|
+
this.ropeInvFreq = l(t), e.dispose(), t.dispose(), o.dispose(), this.config.useRope === !1 ? (this.ropeCos = null, this.ropeSin = null, this.ropeNegSin = null, this.ropeCacheLen = 0) : p(() => {
|
|
14
14
|
this.ensureRopeCache(this.config.blockSize * 4);
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -29,7 +29,7 @@ class g {
|
|
|
29
29
|
if (s <= this.ropeCacheLen) return;
|
|
30
30
|
this.ropeCos && this.ropeCos.dispose(), this.ropeSin && this.ropeSin.dispose();
|
|
31
31
|
const i = Math.max(s, this.ropeCacheLen + this.config.blockSize * 4), e = h(0, i, 1, "float32").expandDims(1).mul(this.ropeInvFreq.expandDims(0));
|
|
32
|
-
this.ropeCos = r(
|
|
32
|
+
this.ropeCos = r(f(e).expandDims(-1)), this.ropeSin = r(m(e).expandDims(-1)), this.ropeNegSin = r(this.ropeSin.neg()), this.ropeCacheLen = i;
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
getCos() {
|
|
@@ -46,5 +46,5 @@ class g {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
export {
|
|
49
|
-
|
|
49
|
+
D as default
|
|
50
50
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "../random_width-
|
|
2
|
-
import "../index-
|
|
3
|
-
import { r as s } from "../exports_initializers-
|
|
1
|
+
import "../random_width-UGQn4OWb.js";
|
|
2
|
+
import "../index-D0RBWjq8.js";
|
|
3
|
+
import { r as s } from "../exports_initializers-eS9QJ6ut.js";
|
|
4
4
|
import a from "./BaseLayer.js";
|
|
5
5
|
import { dot16 as o } from "../ops/dot16.js";
|
|
6
6
|
import { isPackedTensor as r } from "../utilities/packed.js";
|
|
7
|
-
import { p as m } from "../pack16-
|
|
7
|
+
import { p as m } from "../pack16-k4jq6aMX.js";
|
|
8
8
|
import { transpose16 as d } from "../ops/transpose16.js";
|
|
9
|
-
import { v as p } from "../variable-
|
|
10
|
-
import { g as h } from "../gather-
|
|
9
|
+
import { v as p } from "../variable-DQ9yYgEU.js";
|
|
10
|
+
import { g as h } from "../gather-BcO5UQNJ.js";
|
|
11
11
|
class g extends a {
|
|
12
12
|
vocabSize;
|
|
13
13
|
embedDim;
|
|
@@ -2,7 +2,7 @@ import p from "./CausalSelfAttention.js";
|
|
|
2
2
|
import m from "./MLP.js";
|
|
3
3
|
import d from "./RMSNorm.js";
|
|
4
4
|
import h from "./BaseLayer.js";
|
|
5
|
-
import { k as n, t as u } from "../index-
|
|
5
|
+
import { k as n, t as u } from "../index-D0RBWjq8.js";
|
|
6
6
|
import { add16 as l } from "../ops/add16.js";
|
|
7
7
|
class g extends h {
|
|
8
8
|
ln1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import l from "../tokeniser/CharTokeniser.js";
|
|
2
2
|
import c from "../tokeniser/bpe.js";
|
|
3
3
|
import { load_safetensors as b } from "../utilities/safetensors.js";
|
|
4
|
-
import {
|
|
4
|
+
import { aa as y } from "../index-D0RBWjq8.js";
|
|
5
5
|
import { dummyPassAsync as u } from "../utilities/dummy.js";
|
|
6
6
|
import _ from "../models/factory.js";
|
|
7
7
|
async function L(e, a, r, t) {
|