@genai-fi/nanogpt 1.5.0 → 1.6.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/dist/{DatasetBuilder-DU1G1OKX.js → DatasetBuilder-DRDW8tcM.js} +85 -86
- package/dist/Generator-8IK28IWR.js +316 -0
- package/dist/{RealDiv-CSnvtN2E.js → RealDiv-Cl8k3YTx.js} +54 -62
- package/dist/{Reshape-BlylqwWy.js → Reshape-CKxKPKqi.js} +9 -12
- package/dist/Reshape-H5zZRgr9.js +16 -0
- package/dist/RoPECache-dYscFINl.js +722 -0
- package/dist/TeachableLLM.js +29 -34
- package/dist/api/beamer.js +5 -6
- package/dist/api/responses.js +11 -12
- package/dist/api/training.js +12 -14
- package/dist/axis_util-rF9RnwKE.js +37 -0
- package/dist/backend.js +5 -6
- package/dist/{backend_util-DAV0I34P.js → backend_util-Cpp0Gwlp.js} +180 -185
- package/dist/{binary_op_util-CrYk9LXL.js → binary_op_util-WY9YIl0q.js} +3 -7
- package/dist/broadcast_to-CGvLNiQ0.js +20 -0
- package/dist/checks/appendCache.js +7 -7
- package/dist/checks/attentionMask.js +9 -8
- package/dist/checks/check.js +1 -2
- package/dist/checks/gelu.js +6 -6
- package/dist/checks/index.js +24 -25
- package/dist/checks/matMulGelu.js +7 -7
- package/dist/checks/normRMS.js +14 -12
- package/dist/checks/normRMSGrad.js +9 -8
- package/dist/checks/packUnpack.js +7 -7
- package/dist/checks/qkv.js +1 -34
- package/dist/checks/rope.js +6 -6
- package/dist/checks/weights.js +1 -2
- package/dist/clip_by_value-D-UX9am5.js +13 -0
- package/dist/complex-Cl904TqN.js +13 -0
- package/dist/{complex_util-CkazZsaH.js → complex_util-BBlPAm-s.js} +1 -2
- package/dist/concat-Oip5acVY.js +14 -0
- package/dist/{concat_util-CWzvQQlK.js → concat_util-CY45Hf4F.js} +2 -3
- package/dist/data/docx.js +3 -4
- package/dist/data/pdf.js +11 -14
- package/dist/data/stream.js +1 -2
- package/dist/data/textLoader.js +16 -15
- package/dist/data-CV_i_H6B.js +11 -0
- package/dist/data.js +5 -12
- package/dist/dist-CMMLi-qO.js +2675 -0
- package/dist/{dist-BGVm64AY.js → dist-DeVH1nGn.js} +1465 -1573
- package/dist/{dist-CwK5S7Ls.js → dist-DyL7qSLJ.js} +2664 -2400
- package/dist/dropout16-CA31Ud5a.js +20 -0
- package/dist/dropout_util-SiFMbFXz.js +22 -0
- package/dist/{eventemitter3-D_qV3Lof.js → eventemitter3-wmfmOP_f.js} +2 -3
- package/dist/expand_dims-Dh3Fulyn.js +10 -0
- package/dist/floor-BwjmUb7X.js +8 -0
- package/dist/gather-B5Z1RFt5.js +14 -0
- package/dist/gatherSub-CRUfUzBa.js +22 -0
- package/dist/gelu-Xx9-ohH9.js +25 -0
- package/dist/{gpgpu_math-20tPK8LM.js → gpgpu_math-48m8q3jI.js} +265 -286
- package/dist/inference/Beamer.js +34 -27
- package/dist/inference/Generator.js +1 -273
- package/dist/inference/tokenisePrompt.js +5 -4
- package/dist/inference/types.d.ts +6 -0
- package/dist/inference/utilities.js +1 -2
- package/dist/{jszip.min-DKa1Rjyn.js → jszip.min-Btv48m44.js} +68 -64
- package/dist/{kernel_funcs_utils-ql8Y8qPn.js → kernel_funcs_utils-BYRpSfV_.js} +39 -42
- package/dist/layers/BaseLayer.js +9 -10
- package/dist/layers/GQA.js +45 -44
- package/dist/layers/HeadLayer.js +13 -13
- package/dist/layers/LoRA.js +17 -20
- package/dist/layers/MHA.d.ts +2 -2
- package/dist/layers/MHA.js +46 -45
- package/dist/layers/MLP.js +22 -21
- package/dist/layers/PositionEmbedding.js +14 -13
- package/dist/layers/RMSNorm.js +14 -13
- package/dist/layers/RoPECache.js +1 -338
- package/dist/layers/TiedEmbedding.js +15 -14
- package/dist/layers/TransformerBlock.d.ts +3 -9
- package/dist/layers/TransformerBlock.js +29 -30
- package/dist/layers/WeightStore.js +4 -5
- package/dist/layers-CFqEip3s.js +13 -0
- package/dist/layers.js +3 -11
- package/dist/loader/load.js +27 -24
- package/dist/loader/loadHF.js +3 -3
- package/dist/loader/loadTransformers.js +5 -6
- package/dist/loader/loadZipMeta.js +1 -2
- package/dist/loader/newZipLoad.js +1 -2
- package/dist/loader/oldZipLoad.js +8 -9
- package/dist/loader/save.js +15 -16
- package/dist/main.js +3281 -3463
- package/dist/{matMul16-CO1QhsRt.js → matMul16-tE26fnhf.js} +29 -27
- package/dist/{matMulGelu-CBoqTZM7.js → matMulGelu-ASUWlKqu.js} +33 -33
- package/dist/mat_mul-R9_DWmIT.js +16 -0
- package/dist/models/Llama.js +48 -49
- package/dist/models/NanoGPTV1.js +53 -54
- package/dist/models/NanoGPTV2.js +48 -49
- package/dist/models/Qwen3.js +48 -49
- package/dist/models/config.js +3 -8
- package/dist/models/factory.js +7 -8
- package/dist/models/model.d.ts +5 -7
- package/dist/models/model.js +1 -2
- package/dist/models-DyBpJJwM.js +13 -0
- package/dist/models.js +6 -14
- package/dist/mul16-C7sqgqik.js +41 -0
- package/dist/non_max_suppression_impl-B0H318rb.js +72 -0
- package/dist/not_equal-Bu3O8rh_.js +67 -0
- package/dist/one_hot-TEMPumJj.js +14 -0
- package/dist/ones-DpPXWa6A.js +13 -0
- package/dist/ops/adamAdjust.js +2 -3
- package/dist/ops/adamMoments.js +2 -3
- package/dist/ops/add16.js +2 -3
- package/dist/ops/appendCache.js +9 -8
- package/dist/ops/attentionMask.d.ts +1 -1
- package/dist/ops/attentionMask.js +8 -5
- package/dist/ops/concat16.js +5 -5
- package/dist/ops/cpu/adamAdjust.js +7 -8
- package/dist/ops/cpu/adamMoments.js +5 -5
- package/dist/ops/cpu/appendCache.js +3 -3
- package/dist/ops/cpu/attentionMask.js +12 -8
- package/dist/ops/cpu/fusedSoftmax.js +3 -3
- package/dist/ops/cpu/gatherSub.js +1 -12
- package/dist/ops/cpu/gelu.js +12 -13
- package/dist/ops/cpu/matMul16.js +7 -7
- package/dist/ops/cpu/matMulGelu.js +21 -18
- package/dist/ops/cpu/matMulMul.js +8 -9
- package/dist/ops/cpu/mulDropout.js +8 -9
- package/dist/ops/cpu/normRMS.js +12 -13
- package/dist/ops/cpu/qkv.js +14 -13
- package/dist/ops/cpu/rope.js +11 -8
- package/dist/ops/cpu/scatterSub.js +1 -12
- package/dist/ops/dot16.js +16 -17
- package/dist/ops/dropout.js +9 -8
- package/dist/ops/dropout16.js +1 -22
- package/dist/ops/gatherSub.js +3 -4
- package/dist/ops/gelu.js +1 -2
- package/dist/ops/globalNorm.js +10 -10
- package/dist/ops/grads/add16.js +16 -17
- package/dist/ops/grads/attentionMask.js +6 -7
- package/dist/ops/grads/dropout16.js +1 -1
- package/dist/ops/grads/gelu.js +1 -2
- package/dist/ops/grads/matMul16.js +1 -2
- package/dist/ops/grads/matMulGelu.js +6 -7
- package/dist/ops/grads/mul16.js +1 -1
- package/dist/ops/grads/normRMS.js +8 -9
- package/dist/ops/grads/pack16.js +1 -2
- package/dist/ops/grads/qkv.js +10 -10
- package/dist/ops/grads/rope.js +1 -2
- package/dist/ops/grads/silu.js +1 -2
- package/dist/ops/grads/softmax16.js +6 -7
- package/dist/ops/grads/unpack16.js +1 -2
- package/dist/ops/grads/utils.js +1 -2
- package/dist/ops/matMul16.d.ts +1 -1
- package/dist/ops/matMul16.js +1 -2
- package/dist/ops/matMulGelu.js +3 -4
- package/dist/ops/matMulMul.js +2 -3
- package/dist/ops/mul16.js +1 -43
- package/dist/ops/mulDrop.js +2 -3
- package/dist/ops/normRMS.js +2 -3
- package/dist/ops/pack16.js +1 -2
- package/dist/ops/qkv.js +2 -3
- package/dist/ops/reshape16.js +11 -11
- package/dist/ops/rope.js +1 -2
- package/dist/ops/scatterSub.js +3 -4
- package/dist/ops/silu.js +1 -2
- package/dist/ops/slice16.js +5 -5
- package/dist/ops/softmax16.js +3 -4
- package/dist/ops/sub16.js +3 -4
- package/dist/ops/sum16.js +3 -3
- package/dist/ops/transpose16.js +16 -15
- package/dist/ops/unpack16.js +1 -2
- package/dist/ops/webgl/adamAdjust.js +8 -9
- package/dist/ops/webgl/adamMoments.js +2 -3
- package/dist/ops/webgl/appendCache.js +2 -3
- package/dist/ops/webgl/attentionMask.js +2 -3
- package/dist/ops/webgl/dropout16.js +2 -3
- package/dist/ops/webgl/fusedSoftmax.js +13 -13
- package/dist/ops/webgl/gatherSub.js +2 -3
- package/dist/ops/webgl/gelu.js +11 -12
- package/dist/ops/webgl/log.js +10 -10
- package/dist/ops/webgl/matMul16.js +31 -24
- package/dist/ops/webgl/matMulGelu.js +1 -2
- package/dist/ops/webgl/matMulMul.js +3 -4
- package/dist/ops/webgl/mulDropout.js +2 -3
- package/dist/ops/webgl/normRMS.js +11 -10
- package/dist/ops/webgl/qkv.js +2 -3
- package/dist/ops/webgl/rope.js +4 -5
- package/dist/ops/webgl/scatterSub.js +2 -3
- package/dist/ops/webgpu/adamAdjust.js +13 -14
- package/dist/ops/webgpu/adamMoments.js +13 -14
- package/dist/ops/webgpu/add16.js +3 -4
- package/dist/ops/webgpu/appendCache.js +20 -21
- package/dist/ops/webgpu/attentionMask.js +18 -19
- package/dist/ops/webgpu/attentionMask32_program.js +7 -8
- package/dist/ops/webgpu/clipScale.js +11 -12
- package/dist/ops/webgpu/concat16.js +17 -18
- package/dist/ops/webgpu/dropout16.js +6 -7
- package/dist/ops/webgpu/gatherSub.js +11 -12
- package/dist/ops/webgpu/gelu.js +10 -11
- package/dist/ops/webgpu/index.js +17 -17
- package/dist/ops/webgpu/matMul16.js +74 -63
- package/dist/ops/webgpu/matMul16_program.d.ts +2 -1
- package/dist/ops/webgpu/matMul16_program.js +29 -21
- package/dist/ops/webgpu/mul16.js +3 -4
- package/dist/ops/webgpu/norm2.js +9 -10
- package/dist/ops/webgpu/normRMS.js +9 -10
- package/dist/ops/webgpu/normRMS16_program.js +1 -2
- package/dist/ops/webgpu/normRMS32_program.js +1 -2
- package/dist/ops/webgpu/normRMSGrad.js +30 -30
- package/dist/ops/webgpu/pack16.js +2 -3
- package/dist/ops/webgpu/pack16_program.js +3 -4
- package/dist/ops/webgpu/qkv.js +10 -11
- package/dist/ops/webgpu/rope.js +26 -27
- package/dist/ops/webgpu/scatterSub.js +12 -13
- package/dist/ops/webgpu/silu.js +10 -11
- package/dist/ops/webgpu/slice16.js +17 -18
- package/dist/ops/webgpu/softmax16.js +9 -9
- package/dist/ops/webgpu/softmax16_program.js +9 -10
- package/dist/ops/webgpu/softmax16_subgroup_program.js +11 -12
- package/dist/ops/webgpu/softmax16grad.js +8 -9
- package/dist/ops/webgpu/sub16.js +3 -4
- package/dist/ops/webgpu/sum16.js +16 -15
- package/dist/ops/webgpu/transpose16.js +13 -12
- package/dist/ops/webgpu/transpose16_program.js +3 -4
- package/dist/ops/webgpu/transpose16_shared_program.js +17 -18
- package/dist/ops/webgpu/unpack16.js +8 -9
- package/dist/ops/webgpu/utils/binary_op.js +20 -21
- package/dist/ops/webgpu/utils/deviceInfo.js +1 -2
- package/dist/ops/webgpu/utils/reductions.js +21 -20
- package/dist/ops-Be5ACU5R.js +13 -0
- package/dist/ops-C1UpdEYM.js +509 -0
- package/dist/{pack16-BhuXNUS7.js → pack16-BHO4t1-M.js} +14 -17
- package/dist/pad-Dy-1IP3A.js +13 -0
- package/dist/patches/webgpu_backend.js +18 -19
- package/dist/patches/webgpu_base.js +2 -3
- package/dist/patches/webgpu_program.js +21 -22
- package/dist/{pdf-Bzuk68Vy.js → pdf-CbnQ75VG.js} +380 -701
- package/dist/{picomatch-BO4HbNfo.js → picomatch--TW6gyBJ.js} +229 -291
- package/dist/qkv-BQfNPucX.js +42 -0
- package/dist/rand_util-_vCY93Uw.js +44 -0
- package/dist/random_normal-DUIT8kyC.js +11 -0
- package/dist/range-CYvQC3fW.js +13 -0
- package/dist/relu-C4XULT8A.js +8 -0
- package/dist/reshape-DJb1jgMt.js +8 -0
- package/dist/resize_nearest_neighbor-DAqcTYUe.js +188 -0
- package/dist/{chunk-CWhphoD1.js → rolldown-runtime-CwxnZyOB.js} +4 -5
- package/dist/{rope-BPu_uooz.js → rope-JjBVufF_.js} +6 -8
- package/dist/scatterSub-BOnqk-uY.js +27 -0
- package/dist/scatter_nd_util-BepMCpLY.js +34 -0
- package/dist/seedrandom-SHEGFK6H.js +282 -0
- package/dist/selu_util-DeOTf-sc.js +27 -0
- package/dist/shared-BIDMUBCs.js +1864 -0
- package/dist/{shared-CfTzpULd.js → shared-CX_iPI5K.js} +2 -3
- package/dist/silu-DsAE2cJ5.js +23 -0
- package/dist/slice-Dlb1FlzG.js +13 -0
- package/dist/{slice_util-Dve4TkDn.js → slice_util-BVgPRoij.js} +3 -4
- package/dist/softmax-Dpav_dWw.js +10 -0
- package/dist/split-DYnT8chz.js +11 -0
- package/dist/squeeze-B3XYGAlg.js +9 -0
- package/dist/stack-Dbbt9mIk.js +10 -0
- package/dist/step-DA-5DNu9.js +348 -0
- package/dist/{stream-BpAwcvHz.js → stream-BBe2apn4.js} +68 -88
- package/dist/sum-C8qNbFNp.js +13 -0
- package/dist/tensor-ALxWZfmz.js +7 -0
- package/dist/tensor1d-BHgkkhTE.js +9 -0
- package/dist/tensor2d-ARItvqVn.js +10 -0
- package/dist/tensor4d-D1zRBipJ.js +10 -0
- package/dist/tfjs_backend-CsXOum0h.js +685 -0
- package/dist/tile-DfyQ0KX-.js +10 -0
- package/dist/tokenise-DbS2Ea-T.js +14 -0
- package/dist/tokenise.js +6 -15
- package/dist/tokeniser/BaseTokeniser.js +5 -9
- package/dist/tokeniser/CharTokeniser.js +1 -2
- package/dist/tokeniser/bpe.js +19 -20
- package/dist/topk-BrU2pkrR.js +19 -0
- package/dist/training/AdamW.js +35 -31
- package/dist/training/BasicTrainer.js +56 -56
- package/dist/training/DatasetBuilder.js +1 -2
- package/dist/training/Evaluator.js +4 -4
- package/dist/training/LRScheduler.js +1 -2
- package/dist/training/PreTrainer.js +7 -8
- package/dist/training/SFTTrainer.js +7 -8
- package/dist/training/configure.js +16 -15
- package/dist/training/factory.js +1 -2
- package/dist/training/loss.js +1 -2
- package/dist/training/orthoGrad.js +2 -3
- package/dist/training/prepareData.js +18 -17
- package/dist/training/sparseCrossEntropy.js +38 -32
- package/dist/training/tasks/TokenStore.js +21 -22
- package/dist/training/tasks/tokenStream.js +1 -2
- package/dist/training/validateOptions.js +1 -2
- package/dist/training/validation.js +1 -2
- package/dist/transpose-BC-M_OoT.js +34 -0
- package/dist/unsorted_segment_sum-BelC7R-q.js +408 -0
- package/dist/utilities/arrayClose.js +5 -4
- package/dist/utilities/arrayShape.js +1 -2
- package/dist/utilities/datasetID.js +1 -2
- package/dist/utilities/dummy.js +15 -15
- package/dist/utilities/float16.js +10 -10
- package/dist/utilities/maxHeap.js +1 -2
- package/dist/utilities/multinomialCPU.d.ts +1 -2
- package/dist/utilities/multinomialCPU.js +6 -8
- package/dist/utilities/packed.js +2 -3
- package/dist/utilities/parameters.js +3 -4
- package/dist/utilities/performance.js +2 -3
- package/dist/utilities/profile.js +3 -4
- package/dist/utilities/random.js +1 -2
- package/dist/utilities/safetensors.js +14 -14
- package/dist/utilities/sentences.js +16 -13
- package/dist/utilities/tokenParse.js +1 -2
- package/dist/utilities/tokens.js +5 -6
- package/dist/utilities/topP.d.ts +1 -0
- package/dist/utilities/topP.js +20 -13
- package/dist/utilities/waitForModel.js +1 -2
- package/dist/utilities/weights.js +4 -4
- package/dist/utilities/yielder.js +1 -2
- package/dist/{v4-BK7K-jy_.js → v4-YCkfo8OR.js} +4 -7
- package/dist/{webgpu-IAn9VotJ.js → webgpu-BHX-uBym.js} +156 -163
- package/dist/{webgpu_program-B0PokuRJ.js → webgpu_program-DvkFqRlR.js} +28 -29
- package/dist/{webgpu_util-DfODg6XI.js → webgpu_util-5QTyovaf.js} +2 -3
- package/dist/zeros-hxKGkRfl.js +12 -0
- package/package.json +3 -3
- package/dist/Reshape-CwxdaU8n.js +0 -17
- package/dist/dist-Da20xy8E.js +0 -6375
- package/dist/gelu-B6637MKa.js +0 -27
- package/dist/selu_util-B_AFEfoz.js +0 -24
- package/dist/shared-24EoeHJl.js +0 -1314
- package/dist/silu-B6bvCgJ7.js +0 -25
- package/dist/tfjs_backend-h5weiy1O.js +0 -614
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { i as e } from "../../webgpu_util-5QTyovaf.js";
|
|
2
|
+
import { s as t } from "../../webgpu_program-DvkFqRlR.js";
|
|
3
|
+
import { yi as n } from "../../dist-CMMLi-qO.js";
|
|
4
|
+
// lib/ops/webgpu/transpose16_shared_program.ts
|
|
5
5
|
var r = class {
|
|
6
6
|
variableNames = ["A"];
|
|
7
7
|
outputShape;
|
|
@@ -13,8 +13,8 @@ var r = class {
|
|
|
13
13
|
8,
|
|
14
14
|
1
|
|
15
15
|
];
|
|
16
|
-
constructor(
|
|
17
|
-
let r =
|
|
16
|
+
constructor(t, n) {
|
|
17
|
+
let r = t.length, i = Array(r), a = t.slice();
|
|
18
18
|
a[a.length - 1] *= 2;
|
|
19
19
|
for (let e = 0; e < i.length; e++) i[e] = a[n[e]];
|
|
20
20
|
i[i.length - 1] /= 2, this.outputShape = i, this.dispatchLayout = r === 2 ? {
|
|
@@ -24,27 +24,27 @@ var r = class {
|
|
|
24
24
|
x: [1],
|
|
25
25
|
y: [2],
|
|
26
26
|
z: [0]
|
|
27
|
-
}, this.dispatch =
|
|
27
|
+
}, this.dispatch = e(this.dispatchLayout, this.outputShape, this.workgroupSize, [
|
|
28
28
|
2,
|
|
29
29
|
1,
|
|
30
30
|
1
|
|
31
31
|
]), this.shaderKey = `transposeShared16_${r}`;
|
|
32
32
|
}
|
|
33
33
|
getUserCode() {
|
|
34
|
-
let
|
|
35
|
-
|
|
34
|
+
let e = this.outputShape.length;
|
|
35
|
+
n(this.workgroupSize[0] === this.workgroupSize[1], () => `Must be a square tile, current tile shape is ${this.workgroupSize[0]} x ${this.workgroupSize[1]}`);
|
|
36
36
|
let r = this.workgroupSize[0] * 2;
|
|
37
37
|
return `
|
|
38
38
|
var<workgroup> tile : array<array<f32, ${r + 1}>, ${r}>;
|
|
39
|
-
${
|
|
39
|
+
${t()} {
|
|
40
40
|
var x = i32(workgroupId.x) * ${r / 2} + i32(localId.x);
|
|
41
41
|
var y = i32(workgroupId.y) * ${r} + i32(localId.y);
|
|
42
|
-
let batch = ${
|
|
43
|
-
let batchOffsetA = ${
|
|
44
|
-
let batchOffsetOut = ${
|
|
42
|
+
let batch = ${e === 3 ? "i32(workgroupId.z)" : "0"};
|
|
43
|
+
let batchOffsetA = ${e === 3 ? "batch * uniforms.aShapeStrides[0]" : "0"};
|
|
44
|
+
let batchOffsetOut = ${e === 3 ? "batch * uniforms.outShapeStrides[0]" : "0"};
|
|
45
45
|
|
|
46
|
-
let inputWidth = uniforms.outShape[${
|
|
47
|
-
let inputHeight = uniforms.outShape[${
|
|
46
|
+
let inputWidth = uniforms.outShape[${e === 3 ? "1" : "0"}] / 2; // Output height
|
|
47
|
+
let inputHeight = uniforms.outShape[${e === 3 ? "2" : "1"}] * 2; // Output width
|
|
48
48
|
if (x < inputWidth && y < inputHeight) {
|
|
49
49
|
let unpackedA = unpack2x16float(u32(A[batchOffsetA + y * inputWidth + x]));
|
|
50
50
|
tile[localId.y][localId.x * 2] = unpackedA.x;
|
|
@@ -59,8 +59,8 @@ var r = class {
|
|
|
59
59
|
}
|
|
60
60
|
workgroupBarrier();
|
|
61
61
|
|
|
62
|
-
let outputWidth = uniforms.outShape[${
|
|
63
|
-
let outputHeight = uniforms.outShape[${
|
|
62
|
+
let outputWidth = uniforms.outShape[${e === 3 ? "2" : "1"}]; // Output width
|
|
63
|
+
let outputHeight = uniforms.outShape[${e === 3 ? "1" : "0"}] * 2; // Output height
|
|
64
64
|
x = i32(workgroupId.y) * ${r / 2} + i32(localId.x);
|
|
65
65
|
y = i32(workgroupId.x) * ${r} + i32(localId.y);
|
|
66
66
|
if (x < outputWidth && y < outputHeight) {
|
|
@@ -75,5 +75,4 @@ var r = class {
|
|
|
75
75
|
`;
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
//#endregion
|
|
79
78
|
export { r as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { c as e, i as t } from "../../webgpu_util-5QTyovaf.js";
|
|
2
|
+
import { s as n } from "../../webgpu_program-DvkFqRlR.js";
|
|
3
|
+
import { xt as r } from "../../dist-CMMLi-qO.js";
|
|
4
|
+
// lib/ops/webgpu/unpack16.ts
|
|
5
5
|
var i = class {
|
|
6
6
|
outputShape;
|
|
7
7
|
shaderKey = "Unpack16";
|
|
@@ -18,8 +18,8 @@ var i = class {
|
|
|
18
18
|
outputComponent = 4;
|
|
19
19
|
variableComponents = [2];
|
|
20
20
|
scaling = !1;
|
|
21
|
-
constructor(
|
|
22
|
-
this.outputShape = [...
|
|
21
|
+
constructor(n) {
|
|
22
|
+
this.outputShape = [...n.slice(0, -1), n[n.length - 1] * 2], this.dispatchLayout = e(this.outputShape), this.dispatch = t(this.dispatchLayout, this.outputShape, this.workgroupSize, [
|
|
23
23
|
4,
|
|
24
24
|
1,
|
|
25
25
|
1
|
|
@@ -30,7 +30,7 @@ var i = class {
|
|
|
30
30
|
}
|
|
31
31
|
getUserCode() {
|
|
32
32
|
return `
|
|
33
|
-
${
|
|
33
|
+
${n("index")} {
|
|
34
34
|
let outIndex = index;
|
|
35
35
|
if (outIndex < uniforms.size) {
|
|
36
36
|
let xvec2 = x[index];
|
|
@@ -52,9 +52,8 @@ function a(e) {
|
|
|
52
52
|
}];
|
|
53
53
|
return r.runWebGPUProgram(a, [t], "float32", o ? s : void 0);
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
r({
|
|
56
56
|
kernelName: "Unpack16",
|
|
57
57
|
backendName: "webgpu",
|
|
58
58
|
kernelFunc: a
|
|
59
59
|
});
|
|
60
|
-
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { c as e, i as t } from "../../../webgpu_util-5QTyovaf.js";
|
|
2
|
+
import { n, t as r } from "../../../binary_op_util-WY9YIl0q.js";
|
|
3
|
+
import { C as i, Fi as a } from "../../../dist-CMMLi-qO.js";
|
|
4
|
+
import { s as o } from "../../../webgpu_program-DvkFqRlR.js";
|
|
5
|
+
// lib/ops/webgpu/utils/binary_op.ts
|
|
6
6
|
var s = class {
|
|
7
7
|
dispatch;
|
|
8
8
|
dispatchLayout;
|
|
@@ -14,17 +14,17 @@ var s = class {
|
|
|
14
14
|
variableNames = ["A", "B"];
|
|
15
15
|
workgroupSize;
|
|
16
16
|
variableComponents;
|
|
17
|
-
constructor(
|
|
18
|
-
this.outputShape =
|
|
19
|
-
let s =
|
|
17
|
+
constructor(n, r, o) {
|
|
18
|
+
this.outputShape = i(r, o), this.dispatchLayout = e(this.outputShape), this.op = n;
|
|
19
|
+
let s = r.length > 0 && r[r.length - 1] % 4 == 0, c = o.length > 0 && o[o.length - 1] % 4 == 0;
|
|
20
20
|
if (s && c) this.outputComponent = 4, this.variableComponents = [4, 4];
|
|
21
|
-
else if (s && (
|
|
21
|
+
else if (s && (a(o) || o[o.length - 1] === 1) || c && (a(r) || r[r.length - 1] === 1)) throw Error("Cannot broadcast 16-bit float binary ops with mixed vector sizes");
|
|
22
22
|
else throw Error("16-bit float binary ops require inner dimension to be multiple of 4");
|
|
23
|
-
this.shaderKey = `binary_${
|
|
23
|
+
this.shaderKey = `binary_${n}_${this.variableComponents}`, this.workgroupSize = [
|
|
24
24
|
128,
|
|
25
25
|
1,
|
|
26
26
|
1
|
|
27
|
-
], this.dispatch =
|
|
27
|
+
], this.dispatch = t(this.dispatchLayout, this.outputShape, this.workgroupSize, [
|
|
28
28
|
this.outputComponent,
|
|
29
29
|
1,
|
|
30
30
|
1
|
|
@@ -35,10 +35,10 @@ var s = class {
|
|
|
35
35
|
return `
|
|
36
36
|
${`
|
|
37
37
|
fn binaryOperation(a : ${e}, b : ${e}) -> ${e} {
|
|
38
|
-
${
|
|
38
|
+
${n(this.op, this.outputComponent === 4)}
|
|
39
39
|
};
|
|
40
40
|
`}
|
|
41
|
-
${
|
|
41
|
+
${o("index")} {
|
|
42
42
|
if (index < uniforms.size) {
|
|
43
43
|
let a = A[index];
|
|
44
44
|
let b = B[index];
|
|
@@ -86,14 +86,14 @@ var s = class {
|
|
|
86
86
|
variableNames = ["A", "B"];
|
|
87
87
|
workgroupSize;
|
|
88
88
|
variableComponents;
|
|
89
|
-
constructor(
|
|
90
|
-
if (this.outputShape =
|
|
89
|
+
constructor(n, r) {
|
|
90
|
+
if (this.outputShape = r, this.dispatchLayout = e(this.outputShape), this.op = n, r.length > 0 && r[r.length - 1] % 4 == 0) this.outputComponent = 4, this.variableComponents = [4, 1];
|
|
91
91
|
else throw Error("16-bit float binary ops require inner dimension to be multiple of 4");
|
|
92
|
-
this.shaderKey = `binary_scal_${
|
|
92
|
+
this.shaderKey = `binary_scal_${n}_${this.variableComponents}`, this.workgroupSize = [
|
|
93
93
|
128,
|
|
94
94
|
1,
|
|
95
95
|
1
|
|
96
|
-
], this.dispatch =
|
|
96
|
+
], this.dispatch = t(this.dispatchLayout, this.outputShape, this.workgroupSize, [
|
|
97
97
|
this.outputComponent,
|
|
98
98
|
1,
|
|
99
99
|
1
|
|
@@ -104,10 +104,10 @@ var s = class {
|
|
|
104
104
|
return `
|
|
105
105
|
${`
|
|
106
106
|
fn binaryOperation(a : ${e}, b : ${e}) -> ${e} {
|
|
107
|
-
${
|
|
107
|
+
${n(this.op, this.outputComponent === 4)}
|
|
108
108
|
};
|
|
109
109
|
`}
|
|
110
|
-
${
|
|
110
|
+
${o("index")} {
|
|
111
111
|
if (index < uniforms.size) {
|
|
112
112
|
let a = A[index];
|
|
113
113
|
let b = B[0];
|
|
@@ -137,5 +137,4 @@ var s = class {
|
|
|
137
137
|
`;
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
|
|
141
|
-
export { s as BinaryOpProgram, c as BinaryOpScalarProgram, o as BinaryOpType };
|
|
140
|
+
export { s as BinaryOpProgram, c as BinaryOpScalarProgram, r as BinaryOpType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// lib/ops/webgpu/utils/deviceInfo.ts
|
|
2
2
|
function e(e) {
|
|
3
3
|
let t = e.device.features.has("subgroups");
|
|
4
4
|
return {
|
|
@@ -7,5 +7,4 @@ function e(e) {
|
|
|
7
7
|
variableSubgroups: e.subgroupMinSize !== e.subgroupMaxSize && t
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { e as default };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { s } from "../../../webgpu_program-
|
|
5
|
-
|
|
1
|
+
import { H as e, Ui as t, qi as n } from "../../../dist-CMMLi-qO.js";
|
|
2
|
+
import { i as r } from "../../../axis_util-rF9RnwKE.js";
|
|
3
|
+
import { t as i } from "../../../zeros-hxKGkRfl.js";
|
|
4
|
+
import { s as a } from "../../../webgpu_program-DvkFqRlR.js";
|
|
5
|
+
import { reshape16 as o } from "../../reshape16.js";
|
|
6
|
+
import { c as s } from "../../../webgpu_util-5QTyovaf.js";
|
|
7
|
+
// lib/ops/webgpu/utils/reductions.ts
|
|
6
8
|
function c(e, t, n, r) {
|
|
7
9
|
return e && !t ? "\n bestValue = subgroupAdd(bestValue);\n " : e ? `
|
|
8
10
|
bestValue = subgroupAdd(bestValue);
|
|
@@ -50,7 +52,7 @@ function l(e) {
|
|
|
50
52
|
${n}
|
|
51
53
|
${e.utilityFunctions ?? ""}
|
|
52
54
|
|
|
53
|
-
${
|
|
55
|
+
${a("index")} {
|
|
54
56
|
let outputIndex = index / ${t};
|
|
55
57
|
let offset = outputIndex * uniforms.reduceSize;
|
|
56
58
|
var bestValue = 0.0f;
|
|
@@ -92,7 +94,7 @@ function u(e) {
|
|
|
92
94
|
${n}
|
|
93
95
|
${e.utilityFunctions ?? ""}
|
|
94
96
|
|
|
95
|
-
${
|
|
97
|
+
${a("index")} {
|
|
96
98
|
let outputIndex = index / ${t};
|
|
97
99
|
let offset1 = outputIndex * 2 * uniforms.reduceSize;
|
|
98
100
|
let offset2 = offset1 + uniforms.reduceSize;
|
|
@@ -139,7 +141,7 @@ function f(e) {
|
|
|
139
141
|
${n}
|
|
140
142
|
${e.utilityFunctions ?? ""}
|
|
141
143
|
|
|
142
|
-
${
|
|
144
|
+
${a("index")} {
|
|
143
145
|
let outputIndex = index / ${e.workgroupSizeX};
|
|
144
146
|
let offset = outputIndex * uniforms.reduceSize;
|
|
145
147
|
var bestValue = 0.0f;
|
|
@@ -165,8 +167,8 @@ function f(e) {
|
|
|
165
167
|
}
|
|
166
168
|
`;
|
|
167
169
|
}
|
|
168
|
-
function p(e,
|
|
169
|
-
let a = e[0], o =
|
|
170
|
+
function p(e, i) {
|
|
171
|
+
let a = e[0], o = t(i, a.shape), [, s] = r(a.shape, o), c = n(s), l = n(a.shape) / c;
|
|
170
172
|
return {
|
|
171
173
|
windowSize: c,
|
|
172
174
|
inSize: c,
|
|
@@ -205,7 +207,7 @@ var m = class {
|
|
|
205
207
|
Math.min(i, e.subgroupMaxSize),
|
|
206
208
|
1,
|
|
207
209
|
1
|
|
208
|
-
], this.subgroups = !0, e.variableSubgroups && (this.subgroupBuiltins = !0)) : this.workgroupSize[0] = i, this.outputShape = n.elementwise ? [t.batchSize, t.inSize] : r ? [t.outSize / 2] : [t.outSize], this.dispatchLayout =
|
|
210
|
+
], this.subgroups = !0, e.variableSubgroups && (this.subgroupBuiltins = !0)) : this.workgroupSize[0] = i, this.outputShape = n.elementwise ? [t.batchSize, t.inSize] : r ? [t.outSize / 2] : [t.outSize], this.dispatchLayout = s(this.outputShape), this.dispatch = [
|
|
209
211
|
n.elementwise ? t.batchSize : r ? t.batchSize / 2 : t.batchSize,
|
|
210
212
|
1,
|
|
211
213
|
1
|
|
@@ -248,16 +250,15 @@ var m = class {
|
|
|
248
250
|
});
|
|
249
251
|
}
|
|
250
252
|
};
|
|
251
|
-
function h(n, r,
|
|
252
|
-
let c =
|
|
253
|
+
function h(t, n, r, a, s) {
|
|
254
|
+
let c = n[0], l = [{
|
|
253
255
|
type: "int32",
|
|
254
|
-
data: [
|
|
255
|
-
}, ...
|
|
256
|
-
!s &&
|
|
257
|
-
let d =
|
|
258
|
-
if (
|
|
259
|
-
let p =
|
|
256
|
+
data: [t.inputShape[t.inputShape.length - 1]]
|
|
257
|
+
}, ...a ?? []], u = s;
|
|
258
|
+
!s && t.atomic && (u = i(t.outputShape, "int32"));
|
|
259
|
+
let d = r.runWebGPUProgram(t, n, t.packed ? "packedF16" : t.atomic ? "int32" : "float32", l, u), f = e().makeTensorFromTensorInfo(d);
|
|
260
|
+
if (t.outputShape.length === 1 && t.outputShape[0] <= 2) return f;
|
|
261
|
+
let p = o(f, t.elementwise ? c.shape : t.packed ? [...c.shape.slice(0, -2), c.shape[c.shape.length - 2] / 2] : [...c.shape.slice(0, -2), c.shape[c.shape.length - 2]]);
|
|
260
262
|
return f.dispose(), p;
|
|
261
263
|
}
|
|
262
|
-
//#endregion
|
|
263
264
|
export { m as ReduceProgram, p as createReduceInfo, h as reduce };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Q as e, Z as t, rt as n, st as r } from "./dist-CMMLi-qO.js";
|
|
2
|
+
// node_modules/@tensorflow/tfjs-core/dist/ops/mod.js
|
|
3
|
+
function i(t, i) {
|
|
4
|
+
let a = e(t, "a", "mod"), o = e(i, "b", "mod");
|
|
5
|
+
[a, o] = r(a, o);
|
|
6
|
+
let s = {
|
|
7
|
+
a,
|
|
8
|
+
b: o
|
|
9
|
+
};
|
|
10
|
+
return n.runKernel("Mod", s);
|
|
11
|
+
}
|
|
12
|
+
var a = /* @__PURE__ */ t({ mod_: i });
|
|
13
|
+
export { a as t };
|