@genai-fi/nanogpt 1.1.0 → 1.1.2

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.
@@ -1,6 +1,6 @@
1
1
  import { Fs as e, Ii as t } from "../../dist-Da20xy8E.js";
2
- import { s as n } from "../../webgpu_program-B0PokuRJ.js";
3
- import { c as r, i } from "../../webgpu_util-DfODg6XI.js";
2
+ import { c as n, i as r } from "../../webgpu_util-DfODg6XI.js";
3
+ import { s as i } from "../../webgpu_program-B0PokuRJ.js";
4
4
  //#region lib/ops/webgpu/adamAdjust.ts
5
5
  var a = class {
6
6
  variableNames = ["moments", "value"];
@@ -19,11 +19,11 @@ var a = class {
19
19
  variableComponents = [2, 1];
20
20
  useWeightDecay;
21
21
  constructor(e, t) {
22
- this.outputShape = e, this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize), this.useWeightDecay = t, t && (this.uniforms += ", weightDecay: f32");
22
+ this.outputShape = e, this.dispatchLayout = n(this.outputShape), this.dispatch = r(this.dispatchLayout, this.outputShape, this.workgroupSize), this.useWeightDecay = t, t && (this.uniforms += ", weightDecay: f32");
23
23
  }
24
24
  getUserCode() {
25
25
  return `
26
- ${n("index")} {
26
+ ${i("index")} {
27
27
  if (index < uniforms.size) {
28
28
  let moments: vec2<f32> = moments[index];
29
29
  let value: f32 = value[index];
@@ -1,6 +1,6 @@
1
1
  import { Fs as e, Ii as t } from "../../dist-Da20xy8E.js";
2
- import { s as n } from "../../webgpu_program-B0PokuRJ.js";
3
- import { c as r, i } from "../../webgpu_util-DfODg6XI.js";
2
+ import { c as n, i as r } from "../../webgpu_util-DfODg6XI.js";
3
+ import { s as i } from "../../webgpu_program-B0PokuRJ.js";
4
4
  //#region lib/ops/webgpu/adamMoments.ts
5
5
  var a = class {
6
6
  variableNames = [
@@ -26,7 +26,7 @@ var a = class {
26
26
  1
27
27
  ];
28
28
  constructor(e) {
29
- this.outputShape = e, this.dispatchLayout = r(this.outputShape.slice(0, -1)), this.dispatch = i(this.dispatchLayout, this.outputShape.slice(0, -1), this.workgroupSize, [
29
+ this.outputShape = e, this.dispatchLayout = n(this.outputShape.slice(0, -1)), this.dispatch = r(this.dispatchLayout, this.outputShape.slice(0, -1), this.workgroupSize, [
30
30
  1,
31
31
  1,
32
32
  1
@@ -34,7 +34,7 @@ var a = class {
34
34
  }
35
35
  getUserCode() {
36
36
  return `
37
- ${n("index")} {
37
+ ${i("index")} {
38
38
  if (index < uniforms.size) {
39
39
  let m: vec2<f32> = moments[index];
40
40
 
@@ -1,7 +1,7 @@
1
1
  import { Fs as e, Ii as t } from "../../dist-Da20xy8E.js";
2
2
  import { isPackedTensor as n } from "../../utilities/packed.js";
3
- import { s as r } from "../../webgpu_program-B0PokuRJ.js";
4
- import { c as i, i as a } from "../../webgpu_util-DfODg6XI.js";
3
+ import { c as r, i } from "../../webgpu_util-DfODg6XI.js";
4
+ import { s as a } from "../../webgpu_program-B0PokuRJ.js";
5
5
  //#region lib/ops/webgpu/appendCache.ts
6
6
  var o = class {
7
7
  variableNames = ["cache", "item"];
@@ -16,19 +16,19 @@ var o = class {
16
16
  ];
17
17
  size = !0;
18
18
  uniforms = "cacheT: i32";
19
- constructor(e, t, n, r, o) {
19
+ constructor(e, t, n, a, o) {
20
20
  let s = Math.min(n + 1, o);
21
21
  this.shaderKey = `AppendCache_${s}`, this.outputShape = [
22
22
  e,
23
23
  t,
24
24
  s,
25
- r
26
- ], this.dispatchLayout = i(this.outputShape), this.dispatch = a(this.dispatchLayout, this.outputShape, this.workgroupSize);
25
+ a
26
+ ], this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize);
27
27
  }
28
28
  getUserCode() {
29
29
  let e = this.outputShape[2];
30
30
  return `
31
- ${r("index")} {
31
+ ${a("index")} {
32
32
  if (index < uniforms.size) {
33
33
  let coords = getCoordsFromIndex(index); // [b, h, t, d]
34
34
  let b = coords[0];
@@ -68,19 +68,19 @@ var o = class {
68
68
  ];
69
69
  size = !0;
70
70
  uniforms = "cacheT: i32";
71
- constructor(e, t, n, r, o) {
71
+ constructor(e, t, n, a, o) {
72
72
  let s = Math.min(n + 1, o);
73
73
  this.shaderKey = `AppendCache_${s}`, this.outputShape = [
74
74
  e,
75
75
  t,
76
76
  s,
77
- r
78
- ], this.dispatchLayout = i(this.outputShape), this.dispatch = a(this.dispatchLayout, this.outputShape, this.workgroupSize);
77
+ a
78
+ ], this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize);
79
79
  }
80
80
  getUserCode() {
81
81
  let e = this.outputShape[2];
82
82
  return `
83
- ${r("index")} {
83
+ ${a("index")} {
84
84
  if (index < uniforms.size) {
85
85
  let coords = getCoordsFromIndex(index); // [b, h, t, d]
86
86
  let b = coords[0];
@@ -1,5 +1,5 @@
1
- import { s as e } from "../../webgpu_program-B0PokuRJ.js";
2
- import { c as t, i as n } from "../../webgpu_util-DfODg6XI.js";
1
+ import { c as e, i as t } from "../../webgpu_util-DfODg6XI.js";
2
+ import { s as n } from "../../webgpu_program-B0PokuRJ.js";
3
3
  //#region lib/ops/webgpu/attentionMask32_program.ts
4
4
  var r = class {
5
5
  variableNames = ["q", "k"];
@@ -18,17 +18,17 @@ var r = class {
18
18
  nh;
19
19
  T1;
20
20
  T2;
21
- constructor(e, r, i, a, o) {
21
+ constructor(n, r, i, a, o) {
22
22
  if (this.shaderKey = `AttentionMask_${o}`, this.outputShape = [
23
- e,
23
+ n,
24
24
  r,
25
25
  i,
26
26
  a
27
- ], this.hs = o, this.nh = r, this.T1 = i, this.T2 = a, this.dispatchLayout = t(this.outputShape), this.dispatch = n(this.dispatchLayout, this.outputShape, this.workgroupSize), o % 4 != 0) throw Error("Head size must be a multiple of 4 for AttentionMaskProgram");
27
+ ], this.hs = o, this.nh = r, this.T1 = i, this.T2 = a, this.dispatchLayout = e(this.outputShape), this.dispatch = t(this.dispatchLayout, this.outputShape, this.workgroupSize), o % 4 != 0) throw Error("Head size must be a multiple of 4 for AttentionMaskProgram");
28
28
  }
29
29
  getUserCode() {
30
30
  return `
31
- ${e("index")} {
31
+ ${n("index")} {
32
32
 
33
33
  let coords = getCoordsFromIndex(index);
34
34
  let b = coords[0];
@@ -1,7 +1,7 @@
1
1
  import { Ii as e, nc as t, oc as n } from "../../dist-Da20xy8E.js";
2
2
  import { n as r, t as i } from "../../concat_util-CWzvQQlK.js";
3
- import { s as a } from "../../webgpu_program-B0PokuRJ.js";
4
- import { c as o, i as s } from "../../webgpu_util-DfODg6XI.js";
3
+ import { c as a, i as o } from "../../webgpu_util-DfODg6XI.js";
4
+ import { s } from "../../webgpu_program-B0PokuRJ.js";
5
5
  import { t as c } from "../../Reshape-CwxdaU8n.js";
6
6
  //#region lib/ops/webgpu/concat16.ts
7
7
  var l = class {
@@ -20,7 +20,7 @@ var l = class {
20
20
  size = !0;
21
21
  offsetLength;
22
22
  constructor(e) {
23
- this.outputShape = r(e, 1), this.variableNames = e.map((e, t) => `T${t}`), this.dispatchLayout = o(this.outputShape), this.dispatch = s(this.dispatchLayout, this.outputShape, this.workgroupSize, [
23
+ this.outputShape = r(e, 1), this.variableNames = e.map((e, t) => `T${t}`), this.dispatchLayout = a(this.outputShape), this.dispatch = o(this.dispatchLayout, this.outputShape, this.workgroupSize, [
24
24
  this.workPerThread,
25
25
  1,
26
26
  1
@@ -37,7 +37,7 @@ var l = class {
37
37
  e.push(`else { result[getIndexFromCoords2D(coords, uniforms.outShape)] = T${t}[getIndexFromCoords2D(vec2<i32>(yR, yC - uniforms.offset${n}), uniforms.t${t}Shape)]; }`);
38
38
  } else e.push("result[getIndexFromCoords2D(coords, uniforms.outShape)] = T0[getIndexFromCoords2D(vec2<i32>(yR, yC), uniforms.t0Shape)];");
39
39
  return `
40
- ${a("index")} {
40
+ ${s("index")} {
41
41
  for(var i = 0; i < ${this.workPerThread}; i = i + 1) {
42
42
  let flatIndex = index * ${this.workPerThread} + i;
43
43
  if(flatIndex < uniforms.size) {
@@ -1,6 +1,6 @@
1
1
  import { Ii as e } from "../../dist-Da20xy8E.js";
2
- import { s as t } from "../../webgpu_program-B0PokuRJ.js";
3
- import { c as n, i as r } from "../../webgpu_util-DfODg6XI.js";
2
+ import { c as t, i as n } from "../../webgpu_util-DfODg6XI.js";
3
+ import { s as r } from "../../webgpu_program-B0PokuRJ.js";
4
4
  //#region lib/ops/webgpu/dropout16.ts
5
5
  var i = class {
6
6
  variableNames = ["x"];
@@ -16,7 +16,7 @@ var i = class {
16
16
  size = !0;
17
17
  uniforms = "dropout: f32, seed: f32";
18
18
  constructor(e) {
19
- this.shaderKey = "Dropout16", this.outputShape = e, this.dispatchLayout = n(this.outputShape), this.dispatch = r(this.dispatchLayout, this.outputShape, this.workgroupSize);
19
+ this.shaderKey = "Dropout16", this.outputShape = e, this.dispatchLayout = t(this.outputShape), this.dispatch = n(this.dispatchLayout, this.outputShape, this.workgroupSize);
20
20
  }
21
21
  getUserCode() {
22
22
  return `
@@ -27,7 +27,7 @@ var i = class {
27
27
  return vec2<f32>(fract(sin(uniforms.seed + x1) * 43758.5453123), fract(sin(uniforms.seed + x2) * 43758.5453123));
28
28
  }
29
29
 
30
- ${t("index")} {
30
+ ${r("index")} {
31
31
  if (index < uniforms.size) {
32
32
  let coords = getCoordsFromIndex(index);
33
33
  let values = unpack2x16float(u32(x[index]));
@@ -1,6 +1,6 @@
1
1
  import { Fs as e, Ii as t } from "../../dist-Da20xy8E.js";
2
- import { s as n } from "../../webgpu_program-B0PokuRJ.js";
3
- import { c as r, i } from "../../webgpu_util-DfODg6XI.js";
2
+ import { c as n, i as r } from "../../webgpu_util-DfODg6XI.js";
3
+ import { s as i } from "../../webgpu_program-B0PokuRJ.js";
4
4
  //#region lib/ops/webgpu/gatherSub.ts
5
5
  var a = class {
6
6
  variableNames = [
@@ -19,11 +19,11 @@ var a = class {
19
19
  ];
20
20
  size = !0;
21
21
  constructor(e) {
22
- this.outputShape = [e], this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize);
22
+ this.outputShape = [e], this.dispatchLayout = n(this.outputShape), this.dispatch = r(this.dispatchLayout, this.outputShape, this.workgroupSize);
23
23
  }
24
24
  getUserCode() {
25
25
  return `
26
- ${n("index")} {
26
+ ${i("index")} {
27
27
  if (index < uniforms.size) {
28
28
  let idx = i32(labels[index]);
29
29
  let val = values[index];
@@ -1,7 +1,7 @@
1
1
  import { Ii as e } from "../../dist-Da20xy8E.js";
2
2
  import { isPackedTensor as t } from "../../utilities/packed.js";
3
- import { s as n } from "../../webgpu_program-B0PokuRJ.js";
4
- import { c as r, i } from "../../webgpu_util-DfODg6XI.js";
3
+ import { c as n, i as r } from "../../webgpu_util-DfODg6XI.js";
4
+ import { s as i } from "../../webgpu_program-B0PokuRJ.js";
5
5
  //#region lib/ops/webgpu/gelu.ts
6
6
  var a = .7978845608028654, o = .044715, s = class {
7
7
  outputShape;
@@ -16,7 +16,7 @@ var a = .7978845608028654, o = .044715, s = class {
16
16
  128,
17
17
  1,
18
18
  1
19
- ], this.outputShape = e, this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "unary_gelu";
19
+ ], this.outputShape = e, this.dispatchLayout = n(this.outputShape), this.dispatch = r(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "unary_gelu";
20
20
  }
21
21
  getUserCode() {
22
22
  return `
@@ -32,7 +32,7 @@ var a = .7978845608028654, o = .044715, s = class {
32
32
  inner = 0.5 * (1.0 + inner);
33
33
  return x * inner;
34
34
  }
35
- ${n("index")} {
35
+ ${i("index")} {
36
36
  if (index < uniforms.size) {
37
37
  let a = getAByOutputIndex(index);
38
38
  setOutputAtIndex(index, unaryOperation(a));
@@ -63,7 +63,7 @@ var l = class {
63
63
  ];
64
64
  size = !0;
65
65
  constructor(e) {
66
- this.outputShape = e, this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize);
66
+ this.outputShape = e, this.dispatchLayout = n(this.outputShape), this.dispatch = r(this.dispatchLayout, this.outputShape, this.workgroupSize);
67
67
  }
68
68
  getUserCode() {
69
69
  return `
@@ -81,7 +81,7 @@ var l = class {
81
81
  let dgelu = 0.5 * (1.0 + t) + 0.5 * X * sech2 * du_dx;
82
82
  return dy *dgelu;
83
83
  }
84
- ${n("index")} {
84
+ ${i("index")} {
85
85
  if (index < uniforms.size) {
86
86
  let X = unpack2x16float(u32(x[index]));
87
87
  let DY = unpack2x16float(u32(dy[index]));
@@ -106,7 +106,7 @@ var l = class {
106
106
  ];
107
107
  size = !0;
108
108
  constructor(e) {
109
- this.outputShape = e, this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize);
109
+ this.outputShape = e, this.dispatchLayout = n(this.outputShape), this.dispatch = r(this.dispatchLayout, this.outputShape, this.workgroupSize);
110
110
  }
111
111
  getUserCode() {
112
112
  return `
@@ -124,7 +124,7 @@ var l = class {
124
124
  let dgelu = 0.5 * (1.0 + t) + 0.5 * X * sech2 * du_dx;
125
125
  return dy *dgelu;
126
126
  }
127
- ${n("index")} {
127
+ ${i("index")} {
128
128
  if (index < uniforms.size) {
129
129
  let X = getXByOutputIndex(index);
130
130
  let DY = getDyByOutputIndex(index);
@@ -3,8 +3,8 @@ import { isPackedTensor as r } from "../../utilities/packed.js";
3
3
  import { reshape16 as i } from "../reshape16.js";
4
4
  import { sum16 as a } from "../sum16.js";
5
5
  import { r as o, t as s } from "../../pack16-BhuXNUS7.js";
6
- import { s as c } from "../../webgpu_program-B0PokuRJ.js";
7
- import { c as l } from "../../webgpu_util-DfODg6XI.js";
6
+ import { c } from "../../webgpu_util-DfODg6XI.js";
7
+ import { s as l } from "../../webgpu_program-B0PokuRJ.js";
8
8
  import { slice16 as u } from "../slice16.js";
9
9
  import { createReduceInfo as d } from "./utils/reductions.js";
10
10
  //#region lib/ops/webgpu/normRMSGrad.ts
@@ -30,7 +30,7 @@ var f = class {
30
30
  packed = !1;
31
31
  outputComponent;
32
32
  constructor(e, t = 4, n = !1) {
33
- if (this.packed = n, this.shaderKey = `RMSNormGrad_${t}`, this.rowsPerWorkgroup = t, this.inputShape = [e.batchSize, e.inSize], this.outputShape = [e.batchSize + e.batchSize / this.rowsPerWorkgroup, e.inSize], this.dispatchLayout = l(this.outputShape), this.dispatch = [
33
+ if (this.packed = n, this.shaderKey = `RMSNormGrad_${t}`, this.rowsPerWorkgroup = t, this.inputShape = [e.batchSize, e.inSize], this.outputShape = [e.batchSize + e.batchSize / this.rowsPerWorkgroup, e.inSize], this.dispatchLayout = c(this.outputShape), this.dispatch = [
34
34
  e.batchSize / this.rowsPerWorkgroup,
35
35
  1,
36
36
  1
@@ -49,7 +49,7 @@ var f = class {
49
49
 
50
50
  ${n}
51
51
 
52
- ${c("index")} {
52
+ ${l("index")} {
53
53
  // One workgroup per row (batch).
54
54
  let Length = uniforms.reduceSize;
55
55
  let BatchSize = uniforms.batchSize;
@@ -121,7 +121,7 @@ var f = class {
121
121
  packed = !1;
122
122
  outputComponent;
123
123
  constructor(e, t = !1) {
124
- this.packed = t, this.shaderKey = "RMSNormGrad_NoGamma", this.inputShape = [e.batchSize, e.inSize], this.outputShape = [e.batchSize, e.inSize], this.dispatchLayout = l(this.outputShape), this.dispatch = [
124
+ this.packed = t, this.shaderKey = "RMSNormGrad_NoGamma", this.inputShape = [e.batchSize, e.inSize], this.outputShape = [e.batchSize, e.inSize], this.dispatchLayout = c(this.outputShape), this.dispatch = [
125
125
  e.batchSize,
126
126
  1,
127
127
  1
@@ -138,7 +138,7 @@ var f = class {
138
138
 
139
139
  ${t}
140
140
 
141
- ${c("index")} {
141
+ ${l("index")} {
142
142
  // One workgroup per row (batch).
143
143
  let Length = uniforms.reduceSize;
144
144
  let BatchSize = uniforms.batchSize;
@@ -1,5 +1,5 @@
1
- import { s as e } from "../../webgpu_program-B0PokuRJ.js";
2
- import { c as t, i as n } from "../../webgpu_util-DfODg6XI.js";
1
+ import { c as e, i as t } from "../../webgpu_util-DfODg6XI.js";
2
+ import { s as n } from "../../webgpu_program-B0PokuRJ.js";
3
3
  //#region lib/ops/webgpu/pack16_program.ts
4
4
  var r = class {
5
5
  outputShape;
@@ -17,15 +17,15 @@ var r = class {
17
17
  outputComponent = 4;
18
18
  scaling = !1;
19
19
  padding = 0;
20
- constructor(e, r = 0) {
21
- if (e[e.length - 1] % 2 != 0 && r === 0) throw Error("Last dimension of output shape must be even to use Pack16.");
20
+ constructor(n, r = 0) {
21
+ if (n[n.length - 1] % 2 != 0 && r === 0) throw Error("Last dimension of output shape must be even to use Pack16.");
22
22
  if (r % 4 != 0) throw Error("Padding must be a multiple of 4 to use Pack16.");
23
- if (this.outputShape = [...e.slice(0, -1), e[e.length - 1]], r > 0) {
23
+ if (this.outputShape = [...n.slice(0, -1), n[n.length - 1]], r > 0) {
24
24
  this.shaderKey += `_Padded${r}`, this.padding = r;
25
25
  for (let e = this.outputShape.length - 2; e < this.outputShape.length; e++) this.outputShape[e] % this.padding !== 0 && (this.outputShape[e] += this.padding - this.outputShape[e] % this.padding);
26
26
  this.outputComponent = 1;
27
27
  }
28
- this.outputShape[this.outputShape.length - 1] /= 2, this.outputShape[this.outputShape.length - 1] % this.outputComponent !== 0 && (this.outputComponent = 1), this.dispatchLayout = t(this.outputShape), this.dispatch = n(this.dispatchLayout, this.outputShape, this.workgroupSize, [
28
+ this.outputShape[this.outputShape.length - 1] /= 2, this.outputShape[this.outputShape.length - 1] % this.outputComponent !== 0 && (this.outputComponent = 1), this.dispatchLayout = e(this.outputShape), this.dispatch = t(this.dispatchLayout, this.outputShape, this.workgroupSize, [
29
29
  this.outputComponent,
30
30
  1,
31
31
  1
@@ -36,26 +36,26 @@ var r = class {
36
36
  }
37
37
  getUserCode() {
38
38
  if (this.padding > 0 && this.outputComponent === 1) {
39
- let t = this.outputShape.length;
39
+ let e = this.outputShape.length;
40
40
  return `
41
- ${e("index")} {
41
+ ${n("index")} {
42
42
  if (index < uniforms.size) {
43
43
  var coords = getCoordsFromIndex(index);
44
- coords[${t} - 1] = coords[${t} - 1] * 2;
45
- let row = coords[${t} - 2];
46
- let col = coords[${t} - 1];
47
- let width = uniforms.xShape[${t} - 1];
48
- let height = uniforms.xShape[${t} - 2];
44
+ coords[${e} - 1] = coords[${e} - 1] * 2;
45
+ let row = coords[${e} - 2];
46
+ let col = coords[${e} - 1];
47
+ let width = uniforms.xShape[${e} - 1];
48
+ let height = uniforms.xShape[${e} - 2];
49
49
 
50
50
  var value1 = 0.0f;
51
51
  if (col < width && row < height) {
52
- let baseInputIndex = getIndexFromCoords${t}D(coords, uniforms.xShape);
52
+ let baseInputIndex = getIndexFromCoords${e}D(coords, uniforms.xShape);
53
53
  value1 = x[baseInputIndex] ${this.scaling ? "* uniforms.scaling" : ""};
54
54
  }
55
55
  var value2 = 0.0f;
56
56
  if (col + 1 < width && row < height) {
57
- coords[${t} - 1] = coords[${t} - 1] + 1;
58
- let baseInputIndex = getIndexFromCoords${t}D(coords, uniforms.xShape);
57
+ coords[${e} - 1] = coords[${e} - 1] + 1;
58
+ let baseInputIndex = getIndexFromCoords${e}D(coords, uniforms.xShape);
59
59
  value2 = x[baseInputIndex] ${this.scaling ? "* uniforms.scaling" : ""};
60
60
  }
61
61
  let packed = i32(pack2x16float(vec2<f32>(value1, value2)));
@@ -64,7 +64,7 @@ var r = class {
64
64
  }`;
65
65
  }
66
66
  return this.outputComponent === 1 ? `
67
- ${e("index")} {
67
+ ${n("index")} {
68
68
  if (index < uniforms.size) {
69
69
  let baseInputIndex = index * 2;
70
70
  let x1 = x[baseInputIndex] ${this.scaling ? "* uniforms.scaling" : ""};
@@ -73,7 +73,7 @@ var r = class {
73
73
  result[index] = packed;
74
74
  }
75
75
  }` : `
76
- ${e("index")} {
76
+ ${n("index")} {
77
77
  if (index < uniforms.size) {
78
78
  let baseInputIndex = index * 2;
79
79
  let x1 = x[baseInputIndex] ${this.scaling ? "* uniforms.scaling" : ""};
@@ -1,7 +1,7 @@
1
1
  import { Fs as e, Ii as t } from "../../dist-Da20xy8E.js";
2
2
  import { isPackedTensor as n } from "../../utilities/packed.js";
3
- import { s as r } from "../../webgpu_program-B0PokuRJ.js";
4
- import { c as i, i as a } from "../../webgpu_util-DfODg6XI.js";
3
+ import { c as r, i } from "../../webgpu_util-DfODg6XI.js";
4
+ import { s as a } from "../../webgpu_program-B0PokuRJ.js";
5
5
  //#region lib/ops/webgpu/rope.ts
6
6
  var o = class {
7
7
  variableNames = [
@@ -20,18 +20,18 @@ var o = class {
20
20
  ];
21
21
  size = !0;
22
22
  uniforms = "pastLen: i32";
23
- constructor(e, t, n, r) {
24
- this.shaderKey = `Rope_${r}`, this.outputShape = [
23
+ constructor(e, t, n, a) {
24
+ this.shaderKey = `Rope_${a}`, this.outputShape = [
25
25
  e,
26
26
  t,
27
27
  n,
28
- r
29
- ], this.dispatchLayout = i(this.outputShape), this.dispatch = a(this.dispatchLayout, this.outputShape, this.workgroupSize);
28
+ a
29
+ ], this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize);
30
30
  }
31
31
  getUserCode() {
32
32
  let e = this.outputShape[3];
33
33
  return `
34
- ${r("index")} {
34
+ ${a("index")} {
35
35
  if (index < uniforms.size) {
36
36
  let coords = getCoordsFromIndex(index); // [b, h, t, d]
37
37
  let b = coords[0];
@@ -92,17 +92,17 @@ var o = class {
92
92
  ];
93
93
  size = !0;
94
94
  uniforms = "pastLen: i32";
95
- constructor(e, t, n, r) {
96
- this.shaderKey = `Rope_${r}`, this.outputShape = [
95
+ constructor(e, t, n, a) {
96
+ this.shaderKey = `Rope_${a}`, this.outputShape = [
97
97
  e,
98
98
  t,
99
99
  n,
100
- r / 2
101
- ], this.dispatchLayout = i(this.outputShape), this.dispatch = a(this.dispatchLayout, this.outputShape, this.workgroupSize);
100
+ a / 2
101
+ ], this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize);
102
102
  }
103
103
  getUserCode() {
104
104
  return `
105
- ${r("index")} {
105
+ ${a("index")} {
106
106
  if (index < uniforms.size) {
107
107
  let coords = getCoordsFromIndex(index); // [b, h, t, d]
108
108
  let b = coords[0];
@@ -1,6 +1,6 @@
1
1
  import { Fs as e, Ii as t } from "../../dist-Da20xy8E.js";
2
- import { s as n } from "../../webgpu_program-B0PokuRJ.js";
3
- import { c as r, i } from "../../webgpu_util-DfODg6XI.js";
2
+ import { c as n, i as r } from "../../webgpu_util-DfODg6XI.js";
3
+ import { s as i } from "../../webgpu_program-B0PokuRJ.js";
4
4
  //#region lib/ops/webgpu/scatterSub.ts
5
5
  var a = class {
6
6
  variableNames = [
@@ -19,11 +19,11 @@ var a = class {
19
19
  ];
20
20
  size = !0;
21
21
  constructor(e, t) {
22
- this.outputShape = [e, t], this.dispatchLayout = r(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize);
22
+ this.outputShape = [e, t], this.dispatchLayout = n(this.outputShape), this.dispatch = r(this.dispatchLayout, this.outputShape, this.workgroupSize);
23
23
  }
24
24
  getUserCode() {
25
25
  return `
26
- ${n("index")} {
26
+ ${i("index")} {
27
27
  if (index < uniforms.size) {
28
28
  let coords = getCoordsFromIndex(index); // [batch, depth]
29
29
  let idx = i32(labels[coords[0]]);
@@ -1,7 +1,7 @@
1
1
  import { Ii as e, oc as t } from "../../dist-Da20xy8E.js";
2
2
  import { a as n, t as r } from "../../slice_util-Dve4TkDn.js";
3
- import { i, o as a, s as o } from "../../webgpu_program-B0PokuRJ.js";
4
- import { c as s, i as c } from "../../webgpu_util-DfODg6XI.js";
3
+ import { c as i, i as a } from "../../webgpu_util-DfODg6XI.js";
4
+ import { i as o, o as s, s as c } from "../../webgpu_program-B0PokuRJ.js";
5
5
  //#region lib/ops/webgpu/slice16.ts
6
6
  function l(e) {
7
7
  switch (e) {
@@ -29,16 +29,16 @@ var u = class {
29
29
  start;
30
30
  size = !0;
31
31
  constructor(e, t) {
32
- this.outputShape = t, this.rank = t.length, this.dispatchLayout = s(this.outputShape), this.dispatch = c(this.dispatchLayout, this.outputShape, this.workgroupSize, [
32
+ this.outputShape = t, this.rank = t.length, this.dispatchLayout = i(this.outputShape), this.dispatch = a(this.dispatchLayout, this.outputShape, this.workgroupSize, [
33
33
  this.workPerThread,
34
34
  1,
35
35
  1
36
- ]), this.start = e, this.uniforms = `start : ${i(e.length)}, `, this.shaderKey = "slice";
36
+ ]), this.start = e, this.uniforms = `start : ${o(e.length)}, `, this.shaderKey = "slice";
37
37
  }
38
38
  getUserCode() {
39
- let e = i(this.rank), t;
40
- return t = this.start.length === 1 ? this.outputShape.map(() => "sourceLoc = uniforms.start + coords;") : this.outputShape.map((e, t) => `sourceLoc.${d[t]} = uniforms.start.${a(t)} + coords.${d[t]};`), `
41
- ${o("index")} {
39
+ let e = o(this.rank), t;
40
+ return t = this.start.length === 1 ? this.outputShape.map(() => "sourceLoc = uniforms.start + coords;") : this.outputShape.map((e, t) => `sourceLoc.${d[t]} = uniforms.start.${s(t)} + coords.${d[t]};`), `
41
+ ${c("index")} {
42
42
  if (index < uniforms.size) {
43
43
  var sourceLoc : ${e};
44
44
  let coords = getCoordsFromIndex(index);
@@ -1,5 +1,5 @@
1
- import { s as e } from "../../webgpu_program-B0PokuRJ.js";
2
- import { c as t } from "../../webgpu_util-DfODg6XI.js";
1
+ import { c as e } from "../../webgpu_util-DfODg6XI.js";
2
+ import { s as t } from "../../webgpu_program-B0PokuRJ.js";
3
3
  //#region lib/ops/webgpu/softmax16_program.ts
4
4
  var n = class {
5
5
  variableNames = ["logits"];
@@ -8,8 +8,8 @@ var n = class {
8
8
  dispatchLayout;
9
9
  dispatch;
10
10
  workgroupSize;
11
- constructor(e) {
12
- this.outputShape = e, this.dispatchLayout = t(this.outputShape), this.dispatch = [
11
+ constructor(t) {
12
+ this.outputShape = t, this.dispatchLayout = e(this.outputShape), this.dispatch = [
13
13
  this.outputShape[0],
14
14
  1,
15
15
  1
@@ -31,7 +31,7 @@ var n = class {
31
31
  return `
32
32
  var<workgroup> buf : array<f32, ${this.workgroupSize[0]}>;
33
33
  const blockSize = ${this.workgroupSize[0]};
34
- ${e("index")} {
34
+ ${t("index")} {
35
35
  let row = index / blockSize;
36
36
  let tid = i32(localId.x);
37
37
  let cols = uniforms.outShape[1];
@@ -1,5 +1,5 @@
1
- import { s as e } from "../../webgpu_program-B0PokuRJ.js";
2
- import { c as t } from "../../webgpu_util-DfODg6XI.js";
1
+ import { c as e } from "../../webgpu_util-DfODg6XI.js";
2
+ import { s as t } from "../../webgpu_program-B0PokuRJ.js";
3
3
  //#region lib/ops/webgpu/softmax16_subgroup_program.ts
4
4
  var n = class {
5
5
  variableNames = ["logits"];
@@ -12,8 +12,8 @@ var n = class {
12
12
  maxSubgroupSize;
13
13
  subgroups = !0;
14
14
  subgroupBuiltins = !1;
15
- constructor(e, n, r) {
16
- this.minSubgroupSize = n, this.maxSubgroupSize = r, this.outputShape = e, this.dispatchLayout = t(this.outputShape), this.dispatch = [
15
+ constructor(t, n, r) {
16
+ this.minSubgroupSize = n, this.maxSubgroupSize = r, this.outputShape = t, this.dispatchLayout = e(this.outputShape), this.dispatch = [
17
17
  this.outputShape[0],
18
18
  1,
19
19
  1
@@ -28,11 +28,11 @@ var n = class {
28
28
  ]), this.shaderKey = "softmax16subgroup";
29
29
  }
30
30
  getUserCode() {
31
- let t = this.maxSubgroupSize !== this.minSubgroupSize;
31
+ let e = this.maxSubgroupSize !== this.minSubgroupSize;
32
32
  return `
33
- ${t ? `var<workgroup> bestValues : array<f32, ${this.workgroupSize[0]}>;` : ""}
33
+ ${e ? `var<workgroup> bestValues : array<f32, ${this.workgroupSize[0]}>;` : ""}
34
34
  const blockSize = ${this.workgroupSize[0]};
35
- ${e("index")} {
35
+ ${t("index")} {
36
36
  let row = index / blockSize;
37
37
  let tid = i32(localId.x);
38
38
  let cols = uniforms.outShape[1];
@@ -45,7 +45,7 @@ var n = class {
45
45
  }
46
46
 
47
47
  threadMax = subgroupMax(threadMax);
48
- ${t ? "\n let lane = localId.x % subgroupSize;\n if (lane == 0) {\n bestValues[localId.x / subgroupSize] = threadMax;\n }\n workgroupBarrier();\n let numSubgroups = blockSize / subgroupSize;\n threadMax = select(-3.402823e+38f, bestValues[lane], lane < numSubgroups);\n threadMax = subgroupMax(threadMax);\n workgroupBarrier(); \n " : ""}
48
+ ${e ? "\n let lane = localId.x % subgroupSize;\n if (lane == 0) {\n bestValues[localId.x / subgroupSize] = threadMax;\n }\n workgroupBarrier();\n let numSubgroups = blockSize / subgroupSize;\n threadMax = select(-3.402823e+38f, bestValues[lane], lane < numSubgroups);\n threadMax = subgroupMax(threadMax);\n workgroupBarrier(); \n " : ""}
49
49
 
50
50
  var threadSum = 0.0f;
51
51
  for (var col = tid; col < cols; col += blockSize) {
@@ -55,9 +55,9 @@ var n = class {
55
55
  }
56
56
 
57
57
  threadSum = subgroupAdd(threadSum);
58
- ${t ? "\n if (lane == 0) {\n bestValues[localId.x / subgroupSize] = threadSum;\n }\n workgroupBarrier();\n threadSum = select(0.0f, bestValues[lane], lane < numSubgroups);\n threadSum = subgroupAdd(threadSum); \n " : ""}
58
+ ${e ? "\n if (lane == 0) {\n bestValues[localId.x / subgroupSize] = threadSum;\n }\n workgroupBarrier();\n threadSum = select(0.0f, bestValues[lane], lane < numSubgroups);\n threadSum = subgroupAdd(threadSum); \n " : ""}
59
59
 
60
- for (var col = tid; col < cols; col += ${t ? "i32(subgroupSize)" : "blockSize"}) {
60
+ for (var col = tid; col < cols; col += ${e ? "i32(subgroupSize)" : "blockSize"}) {
61
61
  let value = unpack2x16float(u32(logits[rowIdx + col]));
62
62
  let valuePair: vec2<f32> = exp(value - threadMax) / threadSum;
63
63
  result[rowIdx + col] = i32(pack2x16float(valuePair));