@genai-fi/nanogpt 0.7.3 → 0.8.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.
Files changed (197) hide show
  1. package/dist/Generator.d.ts +25 -2
  2. package/dist/Generator.js +152 -49
  3. package/dist/{RealDiv-Dy0p8Bvo.js → RealDiv-D_q39E3A.js} +13 -13
  4. package/dist/{Reshape-DvudQDvJ.js → Reshape-41YpQqEo.js} +1 -1
  5. package/dist/{Reshape-DH5srBP0.js → Reshape-Bh_jzKzV.js} +5 -5
  6. package/dist/TeachableLLM.d.ts +6 -6
  7. package/dist/TeachableLLM.js +33 -31
  8. package/dist/Trainer.d.ts +13 -2
  9. package/dist/Trainer.js +21 -12
  10. package/dist/{axis_util-BzbKo31C.js → axis_util-Did9235A.js} +3 -3
  11. package/dist/backend.js +2 -2
  12. package/dist/{backend_util-TE7aTPhZ.js → backend_util-yC3YH1jo.js} +58 -58
  13. package/dist/{broadcast_to-CdbwV-Dj.js → broadcast_to-CUvOdOT5.js} +2 -2
  14. package/dist/checks/appendCache.d.ts +1 -0
  15. package/dist/checks/appendCache.js +22 -0
  16. package/dist/checks/attentionMask.d.ts +1 -0
  17. package/dist/checks/attentionMask.js +37 -0
  18. package/dist/checks/check.d.ts +9 -0
  19. package/dist/checks/check.js +20 -0
  20. package/dist/checks/gelu.d.ts +1 -0
  21. package/dist/checks/gelu.js +18 -0
  22. package/dist/checks/index.d.ts +19 -0
  23. package/dist/checks/index.js +21 -0
  24. package/dist/checks/normRMS.d.ts +1 -0
  25. package/dist/checks/normRMS.js +16 -0
  26. package/dist/checks/normRMSGrad.d.ts +1 -0
  27. package/dist/checks/normRMSGrad.js +12 -0
  28. package/dist/checks/qkv.d.ts +1 -0
  29. package/dist/checks/qkv.js +25 -0
  30. package/dist/checks/rope.d.ts +1 -0
  31. package/dist/checks/rope.js +21 -0
  32. package/dist/{concat-CsxrgovM.js → concat-pHiVqR3L.js} +1 -1
  33. package/dist/{dataset-CtdBYwjo.js → dataset-DPPl-iLT.js} +9 -9
  34. package/dist/{dropout-DYs5QFGQ.js → dropout-CcKSfOYE.js} +18 -18
  35. package/dist/exports_initializers-DKk7-bsx.js +16 -0
  36. package/dist/{gather-CMMy2KEG.js → gather-CPg6ZlQA.js} +1 -1
  37. package/dist/{gelu-C-dPj6Ku.js → gelu-BkcmEEyD.js} +1 -1
  38. package/dist/{gpgpu_math-DGNLNL4I.js → gpgpu_math-D_ODOLix.js} +26 -26
  39. package/dist/{index-BoWRt-10.js → index-DdmHGZjq.js} +659 -650
  40. package/dist/{index-CLthM0TO.js → index-evZ57wr4.js} +185 -185
  41. package/dist/{kernel_funcs_utils-BYKWV8Aa.js → kernel_funcs_utils-CDfFpUab.js} +21 -21
  42. package/dist/layers/BaseLayer.d.ts +8 -13
  43. package/dist/layers/BaseLayer.js +25 -13
  44. package/dist/layers/CausalSelfAttention.d.ts +3 -2
  45. package/dist/layers/CausalSelfAttention.js +28 -28
  46. package/dist/layers/MLP.d.ts +3 -2
  47. package/dist/layers/MLP.js +16 -20
  48. package/dist/layers/PositionEmbedding.d.ts +9 -0
  49. package/dist/layers/PositionEmbedding.js +45 -0
  50. package/dist/layers/RMSNorm.d.ts +3 -2
  51. package/dist/layers/RMSNorm.js +6 -6
  52. package/dist/layers/RoPECache.d.ts +1 -1
  53. package/dist/layers/RoPECache.js +4 -4
  54. package/dist/layers/TiedEmbedding.d.ts +3 -2
  55. package/dist/layers/TiedEmbedding.js +29 -7
  56. package/dist/layers/TransformerBlock.d.ts +3 -2
  57. package/dist/layers/TransformerBlock.js +1 -1
  58. package/dist/loader/load.d.ts +2 -2
  59. package/dist/loader/loadHF.d.ts +2 -2
  60. package/dist/loader/loadTransformers.d.ts +4 -2
  61. package/dist/loader/loadTransformers.js +10 -9
  62. package/dist/loader/newZipLoad.d.ts +2 -2
  63. package/dist/loader/oldZipLoad.d.ts +2 -2
  64. package/dist/loader/oldZipLoad.js +44 -51
  65. package/dist/loader/save.d.ts +8 -0
  66. package/dist/loader/save.js +62 -0
  67. package/dist/{log_sum_exp-DbjkV734.js → log_sum_exp-C8yFJfZz.js} +45 -24
  68. package/dist/main.d.ts +6 -4
  69. package/dist/main.js +24 -18
  70. package/dist/{mat_mul-8m8pfdcx.js → mat_mul-Dpy2mMRu.js} +1 -1
  71. package/dist/mod-CbibJi3D.js +27 -0
  72. package/dist/models/NanoGPTV1.d.ts +15 -0
  73. package/dist/models/NanoGPTV1.js +71 -0
  74. package/dist/{config.d.ts → models/config.d.ts} +1 -0
  75. package/dist/{config.js → models/config.js} +1 -0
  76. package/dist/models/factory.d.ts +3 -0
  77. package/dist/models/factory.js +14 -0
  78. package/dist/models/model.d.ts +26 -0
  79. package/dist/models/model.js +70 -0
  80. package/dist/{mulmat_packed_gpu-VSekgsNv.js → mulmat_packed_gpu-q_Gmwyld.js} +1 -1
  81. package/dist/{ones-Dj0SDhHf.js → ones-BAqVh-eA.js} +2 -2
  82. package/dist/ops/adamAdjust.js +1 -1
  83. package/dist/ops/adamMoments.js +1 -1
  84. package/dist/ops/appendCache.js +3 -3
  85. package/dist/ops/attentionMask.js +1 -1
  86. package/dist/ops/cpu/adamAdjust.js +9 -9
  87. package/dist/ops/cpu/adamMoments.js +2 -2
  88. package/dist/ops/cpu/appendCache.js +2 -2
  89. package/dist/ops/cpu/attentionMask.js +5 -5
  90. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  91. package/dist/ops/cpu/gatherSub.js +5 -5
  92. package/dist/ops/cpu/gelu.js +1 -1
  93. package/dist/ops/cpu/matMulGelu.js +2 -2
  94. package/dist/ops/cpu/matMulMul.js +1 -1
  95. package/dist/ops/cpu/mulDropout.js +1 -1
  96. package/dist/ops/cpu/normRMS.js +1 -1
  97. package/dist/ops/cpu/qkv.js +3 -3
  98. package/dist/ops/cpu/rope.js +5 -5
  99. package/dist/ops/cpu/scatterSub.js +7 -7
  100. package/dist/ops/fusedSoftmax.js +1 -1
  101. package/dist/ops/gatherSub.js +1 -1
  102. package/dist/ops/gelu.js +2 -2
  103. package/dist/ops/grads/attentionMask.js +1 -1
  104. package/dist/ops/grads/fusedSoftmax.js +2 -2
  105. package/dist/ops/grads/gelu.js +2 -2
  106. package/dist/ops/grads/matMulGelu.js +1 -1
  107. package/dist/ops/grads/normRMS.js +1 -1
  108. package/dist/ops/grads/qkv.js +1 -1
  109. package/dist/ops/grads/rope.js +1 -1
  110. package/dist/ops/matMulGelu.js +1 -1
  111. package/dist/ops/matMulMul.js +1 -1
  112. package/dist/ops/mulDrop.js +1 -1
  113. package/dist/ops/normRMS.js +1 -1
  114. package/dist/ops/qkv.js +1 -1
  115. package/dist/ops/rope.js +4 -4
  116. package/dist/ops/scatterSub.js +1 -1
  117. package/dist/ops/webgl/adamAdjust.js +2 -2
  118. package/dist/ops/webgl/adamMoments.js +1 -1
  119. package/dist/ops/webgl/appendCache.js +1 -1
  120. package/dist/ops/webgl/attentionMask.js +1 -1
  121. package/dist/ops/webgl/fusedSoftmax.js +4 -4
  122. package/dist/ops/webgl/gatherSub.js +1 -1
  123. package/dist/ops/webgl/gelu.js +2 -2
  124. package/dist/ops/webgl/log.js +3 -3
  125. package/dist/ops/webgl/matMulGelu.js +10 -10
  126. package/dist/ops/webgl/matMulMul.js +1 -1
  127. package/dist/ops/webgl/mulDropout.js +1 -1
  128. package/dist/ops/webgl/normRMS.js +2 -2
  129. package/dist/ops/webgl/qkv.js +1 -1
  130. package/dist/ops/webgl/rope.js +1 -1
  131. package/dist/ops/webgl/scatterSub.js +1 -1
  132. package/dist/ops/webgpu/adamAdjust.js +3 -3
  133. package/dist/ops/webgpu/adamMoments.js +3 -3
  134. package/dist/ops/webgpu/appendCache.js +3 -3
  135. package/dist/ops/webgpu/attentionMask.js +3 -3
  136. package/dist/ops/webgpu/gatherSub.js +3 -3
  137. package/dist/ops/webgpu/gelu.js +3 -3
  138. package/dist/ops/webgpu/normRMS.js +2 -2
  139. package/dist/ops/webgpu/normRMSGrad.js +5 -5
  140. package/dist/ops/webgpu/qkv.js +3 -3
  141. package/dist/ops/webgpu/rope.js +3 -3
  142. package/dist/ops/webgpu/scatterSub.js +3 -3
  143. package/dist/ops/webgpu/utils/reductions.js +4 -4
  144. package/dist/ops-542ai2vG.js +1525 -0
  145. package/dist/{random_width-sZORGo5k.js → random_width-DKGeiFuR.js} +1471 -1538
  146. package/dist/{range-CRuAh-gd.js → range-BcUvLuf5.js} +1 -1
  147. package/dist/{reciprocal-BvGAyKyu.js → reciprocal-DhDWSKiD.js} +1 -1
  148. package/dist/{register_all_kernels-BwDSRN-f.js → register_all_kernels-Do9VvZmo.js} +2488 -2534
  149. package/dist/{max-Ddnnb5xe.js → relu-B1AXs7p5.js} +6 -6
  150. package/dist/{reshape-CdBq1WJ6.js → reshape-WeJkT3ja.js} +1 -1
  151. package/dist/{scatter_nd_util-DUstGbU1.js → scatter_nd_util-B7yDhiQr.js} +1 -1
  152. package/dist/{selu_util-BJEXVvjX.js → selu_util-BgUO9gHY.js} +125 -146
  153. package/dist/{shared-wS99K7_n.js → shared-CZiWmQCI.js} +1 -1
  154. package/dist/{shared-B8ztnyEk.js → shared-V6D_md-c.js} +72 -72
  155. package/dist/{sin-BeA3tsEd.js → sin-CPxad7Am.js} +1 -1
  156. package/dist/{slice-BiOsknYS.js → slice-B7jXtPnp.js} +1 -1
  157. package/dist/{softmax-Bv_6lyMX.js → softmax-BfsyI4As.js} +1 -1
  158. package/dist/{split-B-dikLRw.js → split-BPxr8_8m.js} +1 -1
  159. package/dist/{stack-B17UN2nn.js → stack-BNwLzE43.js} +1 -1
  160. package/dist/{sum-66ew2byf.js → sum-ByFINZgi.js} +3 -3
  161. package/dist/{tensor-JwS7ZYY6.js → tensor-DbqgIV9B.js} +1 -1
  162. package/dist/tensor1d-CtJq5BOv.js +27 -0
  163. package/dist/{tensor2d-wxPAnDQy.js → tensor2d-CObBWBkW.js} +1 -1
  164. package/dist/tensor3d-BOukqWwr.js +30 -0
  165. package/dist/tensor4d-DLtk7Nxh.js +30 -0
  166. package/dist/training/Adam.js +2 -2
  167. package/dist/training/AdamExt.js +1 -1
  168. package/dist/training/DatasetBuilder.js +2 -2
  169. package/dist/training/Evaluator.d.ts +2 -2
  170. package/dist/training/FullTrainer.d.ts +3 -3
  171. package/dist/training/FullTrainer.js +61 -69
  172. package/dist/training/Trainer.d.ts +15 -3
  173. package/dist/training/Trainer.js +39 -47
  174. package/dist/training/sparseCrossEntropy.js +12 -13
  175. package/dist/utilities/arrayClose.d.ts +1 -1
  176. package/dist/utilities/arrayClose.js +16 -7
  177. package/dist/utilities/dummy.d.ts +4 -4
  178. package/dist/utilities/dummy.js +13 -13
  179. package/dist/utilities/multinomialCPU.js +2 -2
  180. package/dist/utilities/parameters.d.ts +1 -1
  181. package/dist/utilities/performance.js +1 -1
  182. package/dist/utilities/profile.js +1 -1
  183. package/dist/utilities/safetensors.js +2 -2
  184. package/dist/utilities/weights.js +2 -2
  185. package/dist/{variable-BuddVFLa.js → variable-DPFOJyRG.js} +1 -1
  186. package/dist/{webgpu_program-PFzf1hAQ.js → webgpu_program-Dhk9R5aG.js} +1 -1
  187. package/dist/{webgpu_util-D____QpY.js → webgpu_util-BqGnZg8t.js} +27 -27
  188. package/dist/{zeros--BdLQ3oG.js → zeros-Dnwix0p4.js} +1 -1
  189. package/package.json +2 -3
  190. package/dist/NanoGPTModel.d.ts +0 -52
  191. package/dist/NanoGPTModel.js +0 -203
  192. package/dist/TiedEmbedding-BxOerUmB.js +0 -43
  193. package/dist/ops-BFGCx8Ri.js +0 -1202
  194. package/dist/utilities/generate.d.ts +0 -3
  195. package/dist/utilities/generate.js +0 -22
  196. package/dist/utilities/save.d.ts +0 -9
  197. package/dist/utilities/save.js +0 -61
@@ -1,7 +1,7 @@
1
- import { ag as S, T as h, ac as N, d as v, ah as o, ai as p, aj as g, l as k, t as y } from "./index-BoWRt-10.js";
1
+ import { ak as S, T as h, ag as k, d as v, al as o, am as p, an as g, n as N, t as y } from "./index-DdmHGZjq.js";
2
2
  import { s as R } from "./index-C4L8Cm77.js";
3
- import { s as $ } from "./stack-B17UN2nn.js";
4
- import { t as B } from "./tensor-JwS7ZYY6.js";
3
+ import { s as $ } from "./stack-BNwLzE43.js";
4
+ import { t as B } from "./tensor-DbqgIV9B.js";
5
5
  /**
6
6
  * @license
7
7
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -75,7 +75,7 @@ function I(s) {
75
75
  }
76
76
  function c(s) {
77
77
  let t = !1;
78
- if (N().get("IS_BROWSER"))
78
+ if (k().get("IS_BROWSER"))
79
79
  t = s instanceof TextDecoder;
80
80
  else {
81
81
  const { StringDecoder: e } = require("string_decoder");
@@ -381,7 +381,7 @@ class i {
381
381
  * throw an `Error`.
382
382
  */
383
383
  handleErrors(t) {
384
- return new j(this, t);
384
+ return new Z(this, t);
385
385
  }
386
386
  // TODO(soergel): Implement reduce() etc.
387
387
  /**
@@ -708,7 +708,7 @@ class K extends i {
708
708
  return { value: r, done: !1 };
709
709
  }
710
710
  }
711
- class j extends i {
711
+ class Z extends i {
712
712
  constructor(t, e) {
713
713
  super(), this.upstream = t, this.handler = e, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 });
714
714
  }
@@ -745,7 +745,7 @@ class w extends i {
745
745
  return { value: r, done: !1 };
746
746
  }
747
747
  }
748
- class Z extends i {
748
+ class j extends i {
749
749
  constructor() {
750
750
  super(), this.outputQueue = new f(), this.lastRead = Promise.resolve({ value: null, done: !1 });
751
751
  }
@@ -759,7 +759,7 @@ class Z extends i {
759
759
  return { value: this.outputQueue.shift(), done: !1 };
760
760
  }
761
761
  }
762
- class tt extends Z {
762
+ class tt extends j {
763
763
  constructor(t, e) {
764
764
  super(), this.upstream = t, this.transform = e;
765
765
  }
@@ -930,7 +930,7 @@ class T {
930
930
  */
931
931
  batch(t, e = !0) {
932
932
  const r = this;
933
- k(t > 0, () => `batchSize needs to be positive, but it is
933
+ N(t > 0, () => `batchSize needs to be positive, but it is
934
934
  ${t}`);
935
935
  let n;
936
936
  return this.size === 1 / 0 || this.size == null ? n = this.size : e ? n = Math.ceil(this.size / t) : n = Math.floor(this.size / t), u(async () => (await r.iterator()).columnMajorBatch(t, e, st), n);
@@ -1,5 +1,5 @@
1
- import { B as l, C as h, E as m, ak as p, F as c, al as d, ab as g, l as u, T as V, n as v, o as N, a as w } from "./index-BoWRt-10.js";
2
- import { s as f } from "./index-C4L8Cm77.js";
1
+ import { C as l, D as h, E as m, ao as p, M as c, ap as f, af as g, n as u, T as V, o as v, q as N, a as w } from "./index-DdmHGZjq.js";
2
+ import { s as d } from "./index-C4L8Cm77.js";
3
3
  /**
4
4
  * @license
5
5
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -16,11 +16,11 @@ import { s as f } from "./index-C4L8Cm77.js";
16
16
  * limitations under the License.
17
17
  * =============================================================================
18
18
  */
19
- function b(r) {
19
+ function x(r) {
20
20
  const e = { x: h(r, "x", "floor", "float32") };
21
21
  return m.runKernel(p, e);
22
22
  }
23
- const x = /* @__PURE__ */ l({ floor_: b });
23
+ const b = /* @__PURE__ */ l({ floor_: x });
24
24
  /**
25
25
  * @license
26
26
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -41,7 +41,7 @@ class T {
41
41
  constructor(t, e, s, n, o) {
42
42
  this.mean = t, this.stdDev = e, this.dtype = s, this.nextVal = NaN, this.truncated = n, this.truncated && (this.upper = this.mean + this.stdDev * 2, this.lower = this.mean - this.stdDev * 2);
43
43
  const a = o || Math.random();
44
- this.random = f.alea(a.toString());
44
+ this.random = d.alea(a.toString());
45
45
  }
46
46
  /** Returns next sample from a Gaussian distribution. */
47
47
  nextValue() {
@@ -69,11 +69,11 @@ class T {
69
69
  return t <= this.upper && t >= this.lower;
70
70
  }
71
71
  }
72
- class $ {
72
+ class M {
73
73
  constructor(t = 0, e = 1, s, n) {
74
74
  if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = t, this.range = e - t, this.dtype = s, n == null && (n = Math.random()), typeof n == "number" && (n = n.toString()), !this.canReturnFloat() && this.range <= 1)
75
75
  throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);
76
- this.random = f.alea(n);
76
+ this.random = d.alea(n);
77
77
  }
78
78
  convertValue(t) {
79
79
  return this.canReturnFloat() ? t : Math.round(t);
@@ -98,15 +98,15 @@ class $ {
98
98
  * limitations under the License.
99
99
  * =============================================================================
100
100
  */
101
- function y(r, t = 0, e = 1, s, n) {
101
+ function $(r, t = 0, e = 1, s, n) {
102
102
  if (c(r), s != null && s === "bool")
103
103
  throw new Error(`Unsupported data type ${s}`);
104
- const o = new T(t, e, s, !1, n), a = d(r, s);
104
+ const o = new T(t, e, s, !1, n), a = f(r, s);
105
105
  for (let i = 0; i < a.values.length; i++)
106
106
  a.values[i] = o.nextValue();
107
107
  return a.toTensor();
108
108
  }
109
- const _ = /* @__PURE__ */ l({ randomNormal_: y });
109
+ const _ = /* @__PURE__ */ l({ randomNormal_: $ });
110
110
  /**
111
111
  * @license
112
112
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -123,14 +123,14 @@ const _ = /* @__PURE__ */ l({ randomNormal_: y });
123
123
  * limitations under the License.
124
124
  * =============================================================================
125
125
  */
126
- function M(r, t = 0, e = 1, s = "float32", n) {
126
+ function y(r, t = 0, e = 1, s = "float32", n) {
127
127
  c(r);
128
- const o = d(r, s), a = new $(t, e, null, n);
128
+ const o = f(r, s), a = new M(t, e, null, n);
129
129
  for (let i = 0; i < o.values.length; i++)
130
130
  o.values[i] = a.nextValue();
131
131
  return o.toTensor();
132
132
  }
133
- const D = /* @__PURE__ */ l({ randomUniform_: M });
133
+ const D = /* @__PURE__ */ l({ randomUniform_: y });
134
134
  /**
135
135
  * @license
136
136
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -176,18 +176,18 @@ function E(r, t) {
176
176
  * limitations under the License.
177
177
  * =============================================================================
178
178
  */
179
- function F(r, t, e, s) {
179
+ function R(r, t, e, s) {
180
180
  const n = h(r, "x", "dropout");
181
181
  if (u(n.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${n.dtype} tensor instead.`), u(t >= 0 && t < 1, () => `rate must be a float in the range [0, 1), but got ${t}.`), t === 0)
182
182
  return r instanceof V ? n.clone() : n;
183
- const o = E(n, e), a = 1 - t, i = v(x(N(D(o, 0, 1, "float32", s), a)), a);
183
+ const o = E(n, e), a = 1 - t, i = v(b(N(D(o, 0, 1, "float32", s), a)), a);
184
184
  return w(n, i);
185
185
  }
186
- const G = /* @__PURE__ */ l({ dropout_: F });
186
+ const q = /* @__PURE__ */ l({ dropout_: R });
187
187
  export {
188
188
  T as M,
189
189
  D as a,
190
- G as d,
191
- x as f,
190
+ q as d,
191
+ b as f,
192
192
  _ as r
193
193
  };
@@ -0,0 +1,16 @@
1
+ import { R as o } from "./random_width-DKGeiFuR.js";
2
+ /**
3
+ * @license
4
+ * Copyright 2018 Google LLC
5
+ *
6
+ * Use of this source code is governed by an MIT-style
7
+ * license that can be found in the LICENSE file or at
8
+ * https://opensource.org/licenses/MIT.
9
+ * =============================================================================
10
+ */
11
+ function m(r) {
12
+ return new o(r);
13
+ }
14
+ export {
15
+ m as r
16
+ };
@@ -1,4 +1,4 @@
1
- import { B as g, C as t, E as h, G as p } from "./index-BoWRt-10.js";
1
+ import { C as g, D as t, E as h, G as p } from "./index-DdmHGZjq.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -1,4 +1,4 @@
1
- import { i as t, e as n } from "./index-BoWRt-10.js";
1
+ import { i as t, e as n } from "./index-DdmHGZjq.js";
2
2
  import "./ops/cpu/gelu.js";
3
3
  import "./ops/webgl/gelu.js";
4
4
  const a = {
@@ -1,6 +1,6 @@
1
- import { aA as z, ac as v, aB as oe, aC as ie, aD as ae, l as F, aE as me, aF as J, a1 as B, aG as I, ab as T, j as E, aH as H, aI as $e, aJ as Y, aa as Te } from "./index-BoWRt-10.js";
1
+ import { aD as z, ag as v, aE as oe, aF as ie, aG as ae, n as F, aH as me, aI as J, a3 as B, aJ as I, af as T, j as E, aK as H, aL as $e, aM as Y, ae as Te } from "./index-DdmHGZjq.js";
2
2
  import "./index-Tf7vU29b.js";
3
- import { b as Se } from "./backend_util-TE7aTPhZ.js";
3
+ import { b as Se } from "./backend_util-yC3YH1jo.js";
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -104,7 +104,7 @@ async function ge(e, t) {
104
104
  const n = t.fetchFunc == null ? v().platform.fetch : t.fetchFunc, r = e.map((f) => n(f, t.requestInit, { isBinary: !0 })), s = (t.onProgress == null ? await Promise.all(r) : await Z(r, t.onProgress, 0, 0.5)).map((f) => f.arrayBuffer());
105
105
  return t.onProgress == null ? await Promise.all(s) : await Z(s, t.onProgress, 0.5, 1);
106
106
  }
107
- function Ae(e, t) {
107
+ function _e(e, t) {
108
108
  var n;
109
109
  const r = t.fetchFunc == null ? v().platform.fetch : t.fetchFunc;
110
110
  let o = 0, i;
@@ -140,7 +140,7 @@ function Ae(e, t) {
140
140
  * limitations under the License.
141
141
  * =============================================================================
142
142
  */
143
- const _e = "application/octet-stream", Ne = "application/json";
143
+ const Ae = "application/octet-stream", Ne = "application/json";
144
144
  class q {
145
145
  constructor(t, n) {
146
146
  if (this.DEFAULT_METHOD = "POST", n == null && (n = {}), this.weightPathPrefix = n.weightPathPrefix, this.weightUrlConverter = n.weightUrlConverter, n.fetchFunc != null ? (F(typeof n.fetchFunc == "function", () => "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"), this.fetch = n.fetchFunc) : this.fetch = v().platform.fetch, F(t != null && t.length > 0, () => "URL path for http must not be null, undefined or empty."), Array.isArray(t) && F(t.length === 2, () => `URL paths for http must have a length of 2, (actual length is ${t.length}).`), this.path = t, n.requestInit != null && n.requestInit.body != null)
@@ -158,7 +158,7 @@ class q {
158
158
  }], o = ie(t, r);
159
159
  if (n.body.append("model.json", new Blob([JSON.stringify(o)], { type: Ne }), "model.json"), t.weightData != null) {
160
160
  const a = oe.join(t.weightData);
161
- n.body.append("model.weights.bin", new Blob([a], { type: _e }), "model.weights.bin");
161
+ n.body.append("model.weights.bin", new Blob([a], { type: Ae }), "model.weights.bin");
162
162
  }
163
163
  const i = await this.fetch(this.path, n);
164
164
  if (i.ok)
@@ -199,7 +199,7 @@ class q {
199
199
  return me(t, (n) => this.loadWeights(n));
200
200
  }
201
201
  async loadStream() {
202
- const t = await this.loadModelJSON(), n = await this.getWeightUrls(t.weightsManifest), r = J(t.weightsManifest), o = () => Ae(n, this.loadOptions);
202
+ const t = await this.loadModelJSON(), n = await this.getWeightUrls(t.weightsManifest), r = J(t.weightsManifest), o = () => _e(n, this.loadOptions);
203
203
  return Object.assign(Object.assign({}, t), { weightSpecs: r, getWeightStream: o });
204
204
  }
205
205
  async getWeightUrls(t) {
@@ -1683,7 +1683,7 @@ function M(e, t) {
1683
1683
  * limitations under the License.
1684
1684
  * =============================================================================
1685
1685
  */
1686
- const _ = {}, k = {
1686
+ const A = {}, k = {
1687
1687
  alpha: !1,
1688
1688
  antialias: !1,
1689
1689
  premultipliedAlpha: !1,
@@ -1693,18 +1693,18 @@ const _ = {}, k = {
1693
1693
  failIfMajorPerformanceCaveat: !0
1694
1694
  };
1695
1695
  function Mt(e, t) {
1696
- _[e] = t;
1696
+ A[e] = t;
1697
1697
  }
1698
- function A(e, t) {
1699
- if (!(e in _) || t != null) {
1698
+ function _(e, t) {
1699
+ if (!(e in A) || t != null) {
1700
1700
  const r = vt(e, t);
1701
1701
  if (r !== null)
1702
- _[e] = r;
1702
+ A[e] = r;
1703
1703
  else
1704
1704
  return console.log("Could not get context for WebGL version", e), null;
1705
1705
  }
1706
- const n = _[e];
1707
- return n == null || n.isContextLost() ? (delete _[e], A(e)) : (n.disable(n.DEPTH_TEST), n.disable(n.STENCIL_TEST), n.disable(n.BLEND), n.disable(n.DITHER), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SAMPLE_COVERAGE), n.enable(n.SCISSOR_TEST), n.enable(n.CULL_FACE), n.cullFace(n.BACK), _[e]);
1706
+ const n = A[e];
1707
+ return n == null || n.isContextLost() ? (delete A[e], _(e)) : (n.disable(n.DEPTH_TEST), n.disable(n.STENCIL_TEST), n.disable(n.BLEND), n.disable(n.DITHER), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SAMPLE_COVERAGE), n.enable(n.SCISSOR_TEST), n.enable(n.CULL_FACE), n.cullFace(n.BACK), A[e]);
1708
1708
  }
1709
1709
  function pt(e) {
1710
1710
  if (!v().getBool("IS_SAFARI") && typeof OffscreenCanvas < "u" && e === 2)
@@ -1718,7 +1718,7 @@ function vt(e, t) {
1718
1718
  throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");
1719
1719
  const n = t ?? pt(e);
1720
1720
  return n.addEventListener("webglcontextlost", (r) => {
1721
- r.preventDefault(), delete _[e];
1721
+ r.preventDefault(), delete A[e];
1722
1722
  }, !1), v().getBool("SOFTWARE_WEBGL_ENABLED") && (k.failIfMajorPerformanceCaveat = !1), e === 1 ? (
1723
1723
  // tslint:disable-next-line
1724
1724
  n.getContext("webgl", k) || n.getContext("experimental-webgl", k)
@@ -1913,7 +1913,7 @@ function Qt(e, t, n, r, o, i, a) {
1913
1913
  return s === -1 ? !1 : (m(e, () => e.bindBuffer(e.ARRAY_BUFFER, r)), m(e, () => e.vertexAttribPointer(s, o, e.FLOAT, !1, i, a)), m(e, () => e.enableVertexAttribArray(s)), !0);
1914
1914
  }
1915
1915
  function Ft(e, t, n) {
1916
- At(e, n), m(e, () => e.activeTexture(e.TEXTURE0 + n)), m(e, () => e.bindTexture(e.TEXTURE_2D, t));
1916
+ _t(e, n), m(e, () => e.activeTexture(e.TEXTURE0 + n)), m(e, () => e.bindTexture(e.TEXTURE_2D, t));
1917
1917
  }
1918
1918
  function en(e, t, n) {
1919
1919
  return C(e, () => e.getUniformLocation(t, n), 'uniform "' + n + '" not present in program.');
@@ -1955,7 +1955,7 @@ function C(e, t, n) {
1955
1955
  throw new Error(n);
1956
1956
  return r;
1957
1957
  }
1958
- function At(e, t) {
1958
+ function _t(e, t) {
1959
1959
  const n = e.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, r = t + e.TEXTURE0;
1960
1960
  if (r < e.TEXTURE0 || r > n) {
1961
1961
  const o = `[gl.TEXTURE0, gl.TEXTURE${n}]`;
@@ -2008,14 +2008,14 @@ function un(e, t) {
2008
2008
  let W, X;
2009
2009
  function ln(e) {
2010
2010
  if (W == null) {
2011
- const t = A(e);
2011
+ const t = _(e);
2012
2012
  W = t.getParameter(t.MAX_TEXTURE_SIZE);
2013
2013
  }
2014
2014
  return W;
2015
2015
  }
2016
2016
  function fn(e) {
2017
2017
  if (X == null) {
2018
- const t = A(e);
2018
+ const t = _(e);
2019
2019
  X = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);
2020
2020
  }
2021
2021
  return Math.min(16, X);
@@ -2024,7 +2024,7 @@ function hn(e) {
2024
2024
  if (e === 0)
2025
2025
  return 0;
2026
2026
  let t;
2027
- const n = A(e);
2027
+ const n = _(e);
2028
2028
  return g(n, "EXT_disjoint_timer_query_webgl2") && e === 2 ? t = 2 : g(n, "EXT_disjoint_timer_query") ? t = 1 : t = 0, t;
2029
2029
  }
2030
2030
  function g(e, t) {
@@ -2032,7 +2032,7 @@ function g(e, t) {
2032
2032
  }
2033
2033
  function dn(e) {
2034
2034
  try {
2035
- if (A(e) != null)
2035
+ if (_(e) != null)
2036
2036
  return !0;
2037
2037
  } catch (t) {
2038
2038
  return console.log("Error when getting WebGL context: ", t), !1;
@@ -2042,7 +2042,7 @@ function dn(e) {
2042
2042
  function xn(e) {
2043
2043
  if (e === 0)
2044
2044
  return !1;
2045
- const t = A(e);
2045
+ const t = _(e);
2046
2046
  if (e === 1) {
2047
2047
  if (!g(t, "OES_texture_float"))
2048
2048
  return !1;
@@ -2053,7 +2053,7 @@ function xn(e) {
2053
2053
  function pn(e) {
2054
2054
  if (e === 0)
2055
2055
  return !1;
2056
- const t = A(e);
2056
+ const t = _(e);
2057
2057
  if (e === 1) {
2058
2058
  if (!g(t, "OES_texture_float") || !g(t, "WEBGL_color_buffer_float"))
2059
2059
  return !1;
@@ -2063,7 +2063,7 @@ function pn(e) {
2063
2063
  const r = "EXT_color_buffer_half_float";
2064
2064
  if (g(t, r)) {
2065
2065
  const o = t.getExtension(r);
2066
- return _t(t, o);
2066
+ return At(t, o);
2067
2067
  }
2068
2068
  return !1;
2069
2069
  }
@@ -2077,7 +2077,7 @@ function G(e) {
2077
2077
  const a = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
2078
2078
  return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(n), e.deleteFramebuffer(i), a;
2079
2079
  }
2080
- function _t(e, t) {
2080
+ function At(e, t) {
2081
2081
  const n = de(e, t), r = e.createTexture();
2082
2082
  e.bindTexture(e.TEXTURE_2D, r), e.texImage2D(e.TEXTURE_2D, 0, n.internalFormatHalfFloat, 1, 1, 0, n.textureFormatFloat, n.textureTypeHalfFloat, null);
2083
2083
  const a = e.createFramebuffer();
@@ -2086,7 +2086,7 @@ function _t(e, t) {
2086
2086
  return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(r), e.deleteFramebuffer(a), s;
2087
2087
  }
2088
2088
  function vn(e) {
2089
- return e !== 2 ? !1 : A(e).fenceSync != null;
2089
+ return e !== 2 ? !1 : _(e).fenceSync != null;
2090
2090
  }
2091
2091
  function mn(e, t) {
2092
2092
  Array.isArray(e) || (e = [e]), e.forEach((n) => {
@@ -2314,7 +2314,7 @@ export {
2314
2314
  mt as A,
2315
2315
  kt as B,
2316
2316
  Vt as C,
2317
- A as D,
2317
+ _ as D,
2318
2318
  yt as E,
2319
2319
  Xt as F,
2320
2320
  g as G,