@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
package/dist/ops/webgpu/rope.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { isPackedTensor as
|
|
2
|
-
import { e as
|
|
3
|
-
import { f as
|
|
4
|
-
import "../../index-
|
|
5
|
-
|
|
6
|
-
import { r as v } from "../../tensor_util-DfwaWayG.js";
|
|
7
|
-
class k {
|
|
1
|
+
import { isPackedTensor as y } from "../../utilities/packed.js";
|
|
2
|
+
import { e as c } from "../../webgpu_program-CAE4RICo.js";
|
|
3
|
+
import { f as x, c as l } from "../../webgpu_util-BdovYhXr.js";
|
|
4
|
+
import { h as w, a7 as b } from "../../index-D0RBWjq8.js";
|
|
5
|
+
class v {
|
|
8
6
|
variableNames = ["x", "sin", "cos"];
|
|
9
7
|
outputShape;
|
|
10
8
|
shaderKey = "Rope";
|
|
@@ -13,13 +11,13 @@ class k {
|
|
|
13
11
|
workgroupSize = [64, 1, 1];
|
|
14
12
|
size = !0;
|
|
15
13
|
uniforms = "pastLen: i32";
|
|
16
|
-
constructor(e,
|
|
17
|
-
this.shaderKey = `Rope_${t}`, this.outputShape = [e,
|
|
14
|
+
constructor(e, o, a, t) {
|
|
15
|
+
this.shaderKey = `Rope_${t}`, this.outputShape = [e, o, a, t], this.dispatchLayout = x(this.outputShape), this.dispatch = l(this.dispatchLayout, this.outputShape, this.workgroupSize);
|
|
18
16
|
}
|
|
19
17
|
getUserCode() {
|
|
20
18
|
const e = this.outputShape[3];
|
|
21
19
|
return `
|
|
22
|
-
${
|
|
20
|
+
${c("index")} {
|
|
23
21
|
if (index < uniforms.size) {
|
|
24
22
|
let coords = getCoordsFromIndex(index); // [b, h, t, d]
|
|
25
23
|
let b = coords[0];
|
|
@@ -64,7 +62,7 @@ class k {
|
|
|
64
62
|
`;
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
|
-
class
|
|
65
|
+
class k {
|
|
68
66
|
variableNames = ["x", "sin", "cos"];
|
|
69
67
|
outputShape;
|
|
70
68
|
shaderKey = "Rope";
|
|
@@ -73,12 +71,12 @@ class L {
|
|
|
73
71
|
workgroupSize = [64, 1, 1];
|
|
74
72
|
size = !0;
|
|
75
73
|
uniforms = "pastLen: i32";
|
|
76
|
-
constructor(e,
|
|
77
|
-
this.shaderKey = `Rope_${t}`, this.outputShape = [e,
|
|
74
|
+
constructor(e, o, a, t) {
|
|
75
|
+
this.shaderKey = `Rope_${t}`, this.outputShape = [e, o, a, t / 2], this.dispatchLayout = x(this.outputShape), this.dispatch = l(this.dispatchLayout, this.outputShape, this.workgroupSize);
|
|
78
76
|
}
|
|
79
77
|
getUserCode() {
|
|
80
78
|
return `
|
|
81
|
-
${
|
|
79
|
+
${c("index")} {
|
|
82
80
|
if (index < uniforms.size) {
|
|
83
81
|
let coords = getCoordsFromIndex(index); // [b, h, t, d]
|
|
84
82
|
let b = coords[0];
|
|
@@ -116,22 +114,22 @@ class L {
|
|
|
116
114
|
`;
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
|
-
function
|
|
120
|
-
const { x: e } = i.inputs, { pastLen:
|
|
121
|
-
if (b(
|
|
117
|
+
function L(i) {
|
|
118
|
+
const { x: e } = i.inputs, { pastLen: o, negSin: a, ropeCache: t } = i.attrs, m = i.backend, d = y(e), p = e.shape[0], h = e.shape[1], r = e.shape[2], n = d ? e.shape[3] * 2 : e.shape[3], s = a ? t.getNegSin() : t.getSin(), u = t.getCos();
|
|
119
|
+
if (b(s.shape, u.shape, "Error in Rope: "), s.shape[0] < r + o)
|
|
122
120
|
throw new Error(
|
|
123
|
-
`Sin tensor shape ${
|
|
121
|
+
`Sin tensor shape ${s.shape} is not compatible with seqLength ${r} and pastLen ${o}.`
|
|
124
122
|
);
|
|
125
|
-
if (
|
|
126
|
-
throw new Error(`Sin tensor shape ${
|
|
127
|
-
if (
|
|
128
|
-
throw new Error(`Sin tensor must be 3-dimensional, but got shape ${
|
|
129
|
-
const
|
|
130
|
-
return
|
|
123
|
+
if (s.shape[1] * 2 < n)
|
|
124
|
+
throw new Error(`Sin tensor shape ${s.shape} is not compatible with feature dimension ${n}.`);
|
|
125
|
+
if (s.shape.length !== 3)
|
|
126
|
+
throw new Error(`Sin tensor must be 3-dimensional, but got shape ${s.shape}.`);
|
|
127
|
+
const f = d ? new k(p, h, r, n) : new v(p, h, r, n), S = [{ type: "int32", data: [o] }], g = d ? "packedF16" : e.dtype;
|
|
128
|
+
return m.runWebGPUProgram(f, [e, s, u], g, S);
|
|
131
129
|
}
|
|
132
|
-
const
|
|
130
|
+
const P = {
|
|
133
131
|
kernelName: "Rope",
|
|
134
132
|
backendName: "webgpu",
|
|
135
|
-
kernelFunc:
|
|
133
|
+
kernelFunc: L
|
|
136
134
|
};
|
|
137
|
-
|
|
135
|
+
w(P);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { e as p } from "../../webgpu_program-
|
|
2
|
-
import { f as u, c as d } from "../../webgpu_util-
|
|
3
|
-
import "../../index-
|
|
4
|
-
import { j as s } from "../../tensor-CzmOBsdf.js";
|
|
5
|
-
import { r as h } from "../../tensor_util-DfwaWayG.js";
|
|
1
|
+
import { e as p } from "../../webgpu_program-CAE4RICo.js";
|
|
2
|
+
import { f as u, c as d } from "../../webgpu_util-BdovYhXr.js";
|
|
3
|
+
import { h, a7 as o } from "../../index-D0RBWjq8.js";
|
|
6
4
|
class b {
|
|
7
5
|
variableNames = ["labels", "softmaxProbs", "dy"];
|
|
8
6
|
outputShape;
|
|
@@ -28,11 +26,11 @@ class b {
|
|
|
28
26
|
`;
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
|
-
function f(
|
|
32
|
-
const { logits: t, labels: e, dy:
|
|
33
|
-
s
|
|
29
|
+
function f(a) {
|
|
30
|
+
const { logits: t, labels: e, dy: s } = a.inputs, c = a.backend, r = e.shape[0], i = t.shape[1];
|
|
31
|
+
o(s.shape, [r], "Error in EfficientScatterSub dy: "), o(t.shape, [r, i], "Error in EfficientScatterSub logits: "), o(e.shape, [r], "Error in EfficientScatterSub labels: ");
|
|
34
32
|
const n = new b(r, i);
|
|
35
|
-
return c.runWebGPUProgram(n, [e, t,
|
|
33
|
+
return c.runWebGPUProgram(n, [e, t, s], "float32");
|
|
36
34
|
}
|
|
37
35
|
const l = {
|
|
38
36
|
kernelName: "EfficientScatterSub",
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { b as
|
|
2
|
-
import { f
|
|
3
|
-
import "../../index-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { s as x } from "../../tensor-CzmOBsdf.js";
|
|
7
|
-
function b(o) {
|
|
1
|
+
import { b as u, c as m, e as l } from "../../webgpu_program-CAE4RICo.js";
|
|
2
|
+
import { f, c as g } from "../../webgpu_util-BdovYhXr.js";
|
|
3
|
+
import { h as S, V as k } from "../../index-D0RBWjq8.js";
|
|
4
|
+
import { p as y, a as $ } from "../../slice_util-D8CQRenR.js";
|
|
5
|
+
function x(o) {
|
|
8
6
|
switch (o) {
|
|
9
7
|
case 1:
|
|
10
8
|
return "1D";
|
|
@@ -17,7 +15,7 @@ function b(o) {
|
|
|
17
15
|
}
|
|
18
16
|
return "";
|
|
19
17
|
}
|
|
20
|
-
class
|
|
18
|
+
class b {
|
|
21
19
|
variableNames = ["source"];
|
|
22
20
|
uniforms;
|
|
23
21
|
outputShape;
|
|
@@ -30,42 +28,42 @@ class w {
|
|
|
30
28
|
start;
|
|
31
29
|
size = !0;
|
|
32
30
|
constructor(e, t) {
|
|
33
|
-
this.outputShape = t, this.rank = t.length, this.dispatchLayout =
|
|
31
|
+
this.outputShape = t, this.rank = t.length, this.dispatchLayout = f(this.outputShape), this.dispatch = g(this.dispatchLayout, this.outputShape, this.workgroupSize, [
|
|
34
32
|
this.workPerThread,
|
|
35
33
|
1,
|
|
36
34
|
1
|
|
37
|
-
]), this.start = e, this.uniforms = `start : ${
|
|
35
|
+
]), this.start = e, this.uniforms = `start : ${u(e.length)}, `, this.shaderKey = "slice";
|
|
38
36
|
}
|
|
39
37
|
getUserCode() {
|
|
40
|
-
const e =
|
|
38
|
+
const e = u(this.rank);
|
|
41
39
|
let t;
|
|
42
|
-
return this.start.length === 1 ? t = this.outputShape.map(() => "sourceLoc = uniforms.start + coords;") : t = this.outputShape.map((r, s) => `sourceLoc.${
|
|
40
|
+
return this.start.length === 1 ? t = this.outputShape.map(() => "sourceLoc = uniforms.start + coords;") : t = this.outputShape.map((r, s) => `sourceLoc.${c[s]} = uniforms.start.${m(s)} + coords.${c[s]};`), `
|
|
43
41
|
${l("index")} {
|
|
44
42
|
if (index < uniforms.size) {
|
|
45
43
|
var sourceLoc : ${e};
|
|
46
44
|
let coords = getCoordsFromIndex(index);
|
|
47
45
|
${t.join(`
|
|
48
46
|
`)}
|
|
49
|
-
result[index] = source[getIndexFromCoords${
|
|
47
|
+
result[index] = source[getIndexFromCoords${x(this.rank)}(sourceLoc, uniforms.sourceShape)];
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
`;
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
|
-
const
|
|
56
|
-
function
|
|
57
|
-
const { inputs: e, backend: t, attrs: n } = o, { x: r } = e, { begin: s, size:
|
|
58
|
-
if ($(r, i, a),
|
|
53
|
+
const c = ["x", "y", "z", "w", "u", "v"];
|
|
54
|
+
function w(o) {
|
|
55
|
+
const { inputs: e, backend: t, attrs: n } = o, { x: r } = e, { begin: s, size: p } = n, [i, a] = y(r, s, p);
|
|
56
|
+
if ($(r, i, a), k(a) === 0)
|
|
59
57
|
return t.makeTensorInfo(a, r.dtype, []);
|
|
60
|
-
const
|
|
61
|
-
return
|
|
58
|
+
const h = new b(i, a), d = [{ type: "int32", data: i }];
|
|
59
|
+
return t.runWebGPUProgram(h, [r], r.dtype, d);
|
|
62
60
|
}
|
|
63
|
-
const
|
|
61
|
+
const C = {
|
|
64
62
|
kernelName: "Slice16",
|
|
65
63
|
backendName: "webgpu",
|
|
66
|
-
kernelFunc:
|
|
64
|
+
kernelFunc: w
|
|
67
65
|
};
|
|
68
|
-
|
|
66
|
+
S(C);
|
|
69
67
|
export {
|
|
70
|
-
|
|
68
|
+
w as slice
|
|
71
69
|
};
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { reshape16 as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { r as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
n.
|
|
15
|
-
const t = S().makeTensorFromTensorInfo(n), g = h(t, o.shape);
|
|
16
|
-
return t.dispose(), g;
|
|
1
|
+
import { h, V as S, e as b } from "../../index-D0RBWjq8.js";
|
|
2
|
+
import { reshape16 as d } from "../reshape16.js";
|
|
3
|
+
import x from "./softmax16_program.js";
|
|
4
|
+
import k from "./softmax16_subgroup_program.js";
|
|
5
|
+
import l from "./utils/deviceInfo.js";
|
|
6
|
+
import { r as z } from "../../reshape-CkjKPPqB.js";
|
|
7
|
+
function F(a) {
|
|
8
|
+
const { inputs: t, backend: o, attrs: p } = a, { logits: e } = t, { dim: r } = p, m = o.subgroupMinSize, i = o.subgroupMaxSize, c = l(o).subgroupsSupported, s = z(e, [
|
|
9
|
+
S(e.shape) / e.shape[r],
|
|
10
|
+
e.shape[r]
|
|
11
|
+
]), u = c ? new k(s.shape, m, i) : new x(s.shape), f = o.runWebGPUProgram(u, [s], "packedF16");
|
|
12
|
+
s.dispose();
|
|
13
|
+
const n = b().makeTensorFromTensorInfo(f), g = d(n, e.shape);
|
|
14
|
+
return n.dispose(), g;
|
|
17
15
|
}
|
|
18
|
-
const
|
|
16
|
+
const I = {
|
|
19
17
|
kernelName: "Softmax16",
|
|
20
18
|
backendName: "webgpu",
|
|
21
|
-
kernelFunc:
|
|
19
|
+
kernelFunc: F
|
|
22
20
|
};
|
|
23
|
-
|
|
21
|
+
h(I);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e } from "../../webgpu_program-
|
|
2
|
-
import { f as o } from "../../webgpu_util-
|
|
1
|
+
import { e } from "../../webgpu_program-CAE4RICo.js";
|
|
2
|
+
import { f as o } from "../../webgpu_util-BdovYhXr.js";
|
|
3
3
|
class i {
|
|
4
4
|
variableNames = ["logits"];
|
|
5
5
|
outputShape;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as o } from "../../webgpu_program-
|
|
2
|
-
import { f as u } from "../../webgpu_util-
|
|
1
|
+
import { e as o } from "../../webgpu_program-CAE4RICo.js";
|
|
2
|
+
import { f as u } from "../../webgpu_util-BdovYhXr.js";
|
|
3
3
|
class i {
|
|
4
4
|
variableNames = ["logits"];
|
|
5
5
|
outputShape;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import { createReduceInfo as
|
|
1
|
+
import { h as p } from "../../index-D0RBWjq8.js";
|
|
2
|
+
import { createReduceInfo as m, reduce as l, ReduceProgram as i } from "./utils/reductions.js";
|
|
3
3
|
import { isPackedTensor as n } from "../../utilities/packed.js";
|
|
4
|
-
import
|
|
5
|
-
import { r as k } from "../../tensor_util-DfwaWayG.js";
|
|
4
|
+
import k from "./utils/deviceInfo.js";
|
|
6
5
|
class x extends i {
|
|
7
6
|
constructor(e, t) {
|
|
8
7
|
super(e, t, { reductionOp: "sum", elementwise: !0 }, !0), this.shaderKey = "SoftmaxGrad16", this.variableNames = ["dy", "softmaxOutput"], this.variableComponents = [1, 1];
|
|
@@ -24,15 +23,15 @@ class x extends i {
|
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
function b(o) {
|
|
27
|
-
const { dy: e, softmaxOutput: t } = o.inputs, r = o.backend, s =
|
|
26
|
+
const { dy: e, softmaxOutput: t } = o.inputs, r = o.backend, s = k(r), u = n(e), c = n(t);
|
|
28
27
|
if (!(u && c))
|
|
29
28
|
throw new Error("softmaxGradGPU: dy and softmaxOutput must be packed tensors");
|
|
30
|
-
const a = [e, t], f =
|
|
31
|
-
return
|
|
29
|
+
const a = [e, t], f = m(a, -1), d = new x(s, f);
|
|
30
|
+
return l(d, a, r);
|
|
32
31
|
}
|
|
33
32
|
const v = {
|
|
34
33
|
kernelName: "Softmax16Grad",
|
|
35
34
|
backendName: "webgpu",
|
|
36
35
|
kernelFunc: b
|
|
37
36
|
};
|
|
38
|
-
|
|
37
|
+
p(v);
|
package/dist/ops/webgpu/sub16.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import { BinaryOpProgram as
|
|
3
|
-
import { B as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return o.packed = !0, o;
|
|
1
|
+
import { h as t } from "../../index-D0RBWjq8.js";
|
|
2
|
+
import { BinaryOpProgram as s } from "./utils/binary_op.js";
|
|
3
|
+
import { B as p } from "../../binary_op_util-pKXltfxI.js";
|
|
4
|
+
function c(e) {
|
|
5
|
+
const { a: r, b: n } = e.inputs, o = e.backend, a = new s(p.SUB, r.shape, n.shape);
|
|
6
|
+
return o.runWebGPUProgram(a, [r, n], "packedF16");
|
|
8
7
|
}
|
|
9
|
-
const
|
|
8
|
+
const m = {
|
|
10
9
|
kernelName: "Sub16",
|
|
11
10
|
backendName: "webgpu",
|
|
12
11
|
kernelFunc: c
|
|
13
12
|
};
|
|
14
|
-
|
|
13
|
+
t(m);
|
package/dist/ops/webgpu/sum16.js
CHANGED
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
import { createReduceInfo as
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { isPackedTensor as
|
|
4
|
-
import { transpose16 as
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { p as w } from "../../tensor-CzmOBsdf.js";
|
|
9
|
-
import { a as D, b as K } from "../../axis_util-BsIr9ZNu.js";
|
|
1
|
+
import { createReduceInfo as h, reduce as g, ReduceProgram as x } from "./utils/reductions.js";
|
|
2
|
+
import { h as k, af as A } from "../../index-D0RBWjq8.js";
|
|
3
|
+
import { isPackedTensor as P } from "../../utilities/packed.js";
|
|
4
|
+
import { transpose16 as b } from "../transpose16.js";
|
|
5
|
+
import I from "./utils/deviceInfo.js";
|
|
6
|
+
import { s as w } from "../../sum-BdplSvq_.js";
|
|
7
|
+
import { a as D, b as K } from "../../axis_util-DofAuy0p.js";
|
|
10
8
|
class v extends x {
|
|
11
9
|
shaderKey = "sum16";
|
|
12
|
-
constructor(e,
|
|
10
|
+
constructor(e, t, o) {
|
|
13
11
|
super(
|
|
14
12
|
e,
|
|
15
|
-
|
|
13
|
+
t,
|
|
16
14
|
{
|
|
17
15
|
reductionOp: "sum",
|
|
18
16
|
elementwise: !1
|
|
19
17
|
},
|
|
20
|
-
|
|
21
|
-
),
|
|
18
|
+
o
|
|
19
|
+
), o && (this.shaderKey += "_packed");
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
22
|
function y(r) {
|
|
25
|
-
const { x: e } = r.inputs, { axis:
|
|
26
|
-
if (!
|
|
27
|
-
return
|
|
28
|
-
let n =
|
|
23
|
+
const { x: e } = r.inputs, { axis: t, keepDims: o } = r.attrs, a = r.backend, c = [], u = I(a), m = P(e);
|
|
24
|
+
if (!m)
|
|
25
|
+
return w(e, t, o);
|
|
26
|
+
let n = A(t ?? -1, e.shape);
|
|
29
27
|
const i = D(n, e.shape.length);
|
|
30
28
|
let s = e;
|
|
31
|
-
i != null && (s =
|
|
32
|
-
const
|
|
33
|
-
return
|
|
29
|
+
i != null && (s = b(e, i), n = K(n.length, s.shape.length), c.push(s));
|
|
30
|
+
const p = h([s], -1), f = new v(u, p, m), d = g(f, [s], a);
|
|
31
|
+
return c.forEach((l) => l.dispose()), d;
|
|
34
32
|
}
|
|
35
33
|
const N = {
|
|
36
34
|
kernelName: "Sum16",
|
|
37
35
|
backendName: "webgpu",
|
|
38
36
|
kernelFunc: y
|
|
39
37
|
};
|
|
40
|
-
|
|
38
|
+
k(N);
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import { isPackedTensor as d } from "../../utilities/packed.js";
|
|
2
|
-
import {
|
|
3
|
-
import { reshape16 as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const s = k().makeTensorFromTensorInfo(o), g = i(s, [
|
|
2
|
+
import { h as k, e as l } from "../../index-D0RBWjq8.js";
|
|
3
|
+
import { reshape16 as u } from "../reshape16.js";
|
|
4
|
+
import P from "./transpose16_shared_program.js";
|
|
5
|
+
import b from "./transpose16_program.js";
|
|
6
|
+
import { t as T } from "../../transpose-JawVKyZy.js";
|
|
7
|
+
function w(p) {
|
|
8
|
+
const { inputs: h, attrs: i } = p, { x: e } = h, { perm: r } = i, a = p.backend, m = d(e);
|
|
9
|
+
if (m && r[r.length - 1] !== e.shape.length - 1) {
|
|
10
|
+
const o = e.shape.length, c = o === 4 ? r.map((s) => s - 1).filter((s) => s >= 0) : r, t = o === 4 ? u(e, [e.shape[0] * e.shape[1], e.shape[2], e.shape[3]]) : e, f = new P(t.shape, c), n = a.runWebGPUProgram(f, [t], "packedF16");
|
|
11
|
+
if (o === 4) {
|
|
12
|
+
t.dispose();
|
|
13
|
+
const s = l().makeTensorFromTensorInfo(n), g = u(s, [
|
|
15
14
|
e.shape[0],
|
|
16
15
|
e.shape[1],
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
n.shape[1],
|
|
17
|
+
n.shape[2]
|
|
19
18
|
]);
|
|
20
19
|
return s.dispose(), g;
|
|
21
20
|
}
|
|
22
|
-
return
|
|
21
|
+
return n;
|
|
23
22
|
}
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
return
|
|
23
|
+
if (m) {
|
|
24
|
+
const o = new b(e.shape, r);
|
|
25
|
+
return a.runWebGPUProgram(o, [e], "packedF16");
|
|
27
26
|
} else
|
|
28
27
|
return T(e, r);
|
|
29
28
|
}
|
|
@@ -32,4 +31,4 @@ const F = {
|
|
|
32
31
|
backendName: "webgpu",
|
|
33
32
|
kernelFunc: w
|
|
34
33
|
};
|
|
35
|
-
|
|
34
|
+
k(F);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as a, c as i } from "../../webgpu_util-
|
|
2
|
-
import { b as h, e as d, c as n } from "../../webgpu_program-
|
|
1
|
+
import { f as a, c as i } from "../../webgpu_util-BdovYhXr.js";
|
|
2
|
+
import { b as h, e as d, c as n } from "../../webgpu_program-CAE4RICo.js";
|
|
3
3
|
function p(r) {
|
|
4
4
|
const e = r.length;
|
|
5
5
|
if (e > 6)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { c as a } from "../../webgpu_util-
|
|
2
|
-
import { e as
|
|
3
|
-
import "../../index-
|
|
4
|
-
|
|
5
|
-
class y {
|
|
1
|
+
import { c as a } from "../../webgpu_util-BdovYhXr.js";
|
|
2
|
+
import { e as l } from "../../webgpu_program-CAE4RICo.js";
|
|
3
|
+
import { y as p } from "../../index-D0RBWjq8.js";
|
|
4
|
+
class n {
|
|
6
5
|
variableNames = ["A"];
|
|
7
6
|
outputShape;
|
|
8
7
|
shaderKey;
|
|
@@ -12,22 +11,22 @@ class y {
|
|
|
12
11
|
// Nick: Reduce to 8x8
|
|
13
12
|
workgroupSize = [8, 8, 1];
|
|
14
13
|
constructor(t, o) {
|
|
15
|
-
const i = t.length, e = new Array(i),
|
|
16
|
-
|
|
17
|
-
for (let
|
|
18
|
-
e[
|
|
14
|
+
const i = t.length, e = new Array(i), r = t.slice();
|
|
15
|
+
r[r.length - 1] *= 2;
|
|
16
|
+
for (let u = 0; u < e.length; u++)
|
|
17
|
+
e[u] = r[o[u]];
|
|
19
18
|
e[e.length - 1] /= 2, this.outputShape = e, this.dispatchLayout = i === 2 ? { x: [0], y: [1] } : { x: [1], y: [2], z: [0] }, this.dispatch = a(this.dispatchLayout, this.outputShape, this.workgroupSize, [2, 1, 1]), this.shaderKey = `transposeShared16_${i}`;
|
|
20
19
|
}
|
|
21
20
|
getUserCode() {
|
|
22
21
|
const t = this.outputShape.length;
|
|
23
|
-
|
|
22
|
+
p(
|
|
24
23
|
this.workgroupSize[0] === this.workgroupSize[1],
|
|
25
24
|
() => `Must be a square tile, current tile shape is ${this.workgroupSize[0]} x ${this.workgroupSize[1]}`
|
|
26
25
|
);
|
|
27
26
|
const o = this.workgroupSize[0] * 2;
|
|
28
27
|
return `
|
|
29
28
|
var<workgroup> tile : array<array<f32, ${o + 1}>, ${o}>;
|
|
30
|
-
${
|
|
29
|
+
${l()} {
|
|
31
30
|
var x = i32(workgroupId.x) * ${o / 2} + i32(localId.x);
|
|
32
31
|
var y = i32(workgroupId.y) * ${o} + i32(localId.y);
|
|
33
32
|
let batch = ${t === 3 ? "i32(workgroupId.z)" : "0"};
|
|
@@ -67,5 +66,5 @@ class y {
|
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
export {
|
|
70
|
-
|
|
69
|
+
n as default
|
|
71
70
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { f as c, c as r } from "../../webgpu_util-
|
|
2
|
-
import { e as u } from "../../webgpu_program-
|
|
3
|
-
import "../../index-
|
|
4
|
-
import { r as p } from "../../tensor_util-DfwaWayG.js";
|
|
1
|
+
import { f as c, c as r } from "../../webgpu_util-BdovYhXr.js";
|
|
2
|
+
import { e as u } from "../../webgpu_program-CAE4RICo.js";
|
|
3
|
+
import { h as p } from "../../index-D0RBWjq8.js";
|
|
5
4
|
class l {
|
|
6
5
|
outputShape;
|
|
7
6
|
shaderKey = "Unpack16";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { f as s, c as n } from "../../../webgpu_util-
|
|
1
|
+
import { f as s, c as n } from "../../../webgpu_util-BdovYhXr.js";
|
|
2
2
|
import { g as p } from "../../../binary_op_util-pKXltfxI.js";
|
|
3
|
-
import { B as
|
|
4
|
-
import {
|
|
5
|
-
import { e as l } from "../../../webgpu_program-
|
|
6
|
-
|
|
7
|
-
class y {
|
|
3
|
+
import { B as b } from "../../../binary_op_util-pKXltfxI.js";
|
|
4
|
+
import { $ as u, ag as r } from "../../../index-D0RBWjq8.js";
|
|
5
|
+
import { e as l } from "../../../webgpu_program-CAE4RICo.js";
|
|
6
|
+
class x {
|
|
8
7
|
dispatch;
|
|
9
8
|
dispatchLayout;
|
|
10
9
|
outputComponent;
|
|
@@ -74,6 +73,6 @@ class y {
|
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
x as BinaryOpProgram,
|
|
77
|
+
b as BinaryOpType
|
|
79
78
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as a } from "../../../webgpu_program-
|
|
3
|
-
import { reshape16 as
|
|
4
|
-
import { f
|
|
5
|
-
import {
|
|
6
|
-
import { c as h } from "../../../axis_util-BsIr9ZNu.js";
|
|
1
|
+
import { af as l, V as c, e as S } from "../../../index-D0RBWjq8.js";
|
|
2
|
+
import { e as a } from "../../../webgpu_program-CAE4RICo.js";
|
|
3
|
+
import { reshape16 as b } from "../../reshape16.js";
|
|
4
|
+
import { f } from "../../../webgpu_util-BdovYhXr.js";
|
|
5
|
+
import { c as h } from "../../../axis_util-DofAuy0p.js";
|
|
7
6
|
function d(e, u, t, i) {
|
|
8
7
|
return e && !u ? `
|
|
9
8
|
bestValue = subgroupAdd(bestValue);
|
|
@@ -173,11 +172,11 @@ function x(e) {
|
|
|
173
172
|
}
|
|
174
173
|
`;
|
|
175
174
|
}
|
|
176
|
-
function
|
|
177
|
-
const t = e[0], n =
|
|
175
|
+
function L(e, u) {
|
|
176
|
+
const t = e[0], n = l(u, t.shape), [, r] = h(t.shape, n), o = c(r), p = c(t.shape) / o;
|
|
178
177
|
return { windowSize: o, inSize: o, batchSize: p, outSize: 1 };
|
|
179
178
|
}
|
|
180
|
-
class
|
|
179
|
+
class C {
|
|
181
180
|
outputShape;
|
|
182
181
|
shaderKey = "reduce16";
|
|
183
182
|
dispatchLayout;
|
|
@@ -198,7 +197,7 @@ class y {
|
|
|
198
197
|
constructor(u, t, i, n) {
|
|
199
198
|
this.params = i, this.inputShape = [t.batchSize, t.inSize], this.deviceInfo = u, this.packed = n;
|
|
200
199
|
const r = t.inSize % 64 === 0 ? 64 : 32;
|
|
201
|
-
u.subgroupsSupported ? (this.workgroupSize = [Math.min(r, u.subgroupMaxSize), 1, 1], this.subgroups = !0, u.variableSubgroups && (this.subgroupBuiltins = !0)) : this.workgroupSize[0] = r, this.outputShape = i.elementwise ? [t.batchSize, t.inSize] : [t.batchSize / 2], this.dispatchLayout =
|
|
200
|
+
u.subgroupsSupported ? (this.workgroupSize = [Math.min(r, u.subgroupMaxSize), 1, 1], this.subgroups = !0, u.variableSubgroups && (this.subgroupBuiltins = !0)) : this.workgroupSize[0] = r, this.outputShape = i.elementwise ? [t.batchSize, t.inSize] : [t.batchSize / 2], this.dispatchLayout = f(this.outputShape), this.dispatch = [i.elementwise ? t.batchSize : t.batchSize / 2, 1, 1], this.outputComponent = 1, this.variableComponents = [1], this.elementwise = i.elementwise === !0;
|
|
202
201
|
}
|
|
203
202
|
getWriteSnippet() {
|
|
204
203
|
return this.packed ? "result[outputIndex] = i32(pack2x16float(bestValue));" : "result[outputIndex] = bestValue;";
|
|
@@ -238,22 +237,15 @@ class y {
|
|
|
238
237
|
});
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
|
-
function
|
|
242
|
-
const i = u[0], r = [{ type: "int32", data: [e.inputShape[e.inputShape.length - 1]] }], o = t.runWebGPUProgram(
|
|
243
|
-
e,
|
|
244
|
-
u,
|
|
245
|
-
e.packed ? "int32" : "float32",
|
|
246
|
-
r
|
|
247
|
-
);
|
|
248
|
-
o.packed = e.packed ?? !1;
|
|
249
|
-
const s = l().makeTensorFromTensorInfo(o), p = S(
|
|
240
|
+
function y(e, u, t) {
|
|
241
|
+
const i = u[0], r = [{ type: "int32", data: [e.inputShape[e.inputShape.length - 1]] }], o = t.runWebGPUProgram(e, u, e.packed ? "packedF16" : "float32", r), s = S().makeTensorFromTensorInfo(o), p = b(
|
|
250
242
|
s,
|
|
251
243
|
e.elementwise ? i.shape : e.packed ? [...i.shape.slice(0, -2), i.shape[i.shape.length - 2] / 2] : [...i.shape.slice(0, -2), i.shape[i.shape.length - 2]]
|
|
252
244
|
);
|
|
253
245
|
return s.dispose(), p;
|
|
254
246
|
}
|
|
255
247
|
export {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
248
|
+
C as ReduceProgram,
|
|
249
|
+
L as createReduceInfo,
|
|
250
|
+
y as reduce
|
|
259
251
|
};
|