@genai-fi/nanogpt 0.18.0 → 0.19.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.
Files changed (252) hide show
  1. package/dist/Generator.js +30 -30
  2. package/dist/{RealDiv-ioj6Z-ox.js → RealDiv-CGwv0liw.js} +9 -9
  3. package/dist/{Reshape-BZC-ebeR.js → Reshape-BW__R4mZ.js} +7 -7
  4. package/dist/{Reshape-pwprEaej.js → Reshape-CPBkTIH2.js} +1 -1
  5. package/dist/TeachableLLM.js +17 -17
  6. package/dist/Trainer.js +97 -95
  7. package/dist/{axis_util-QWWgLjut.js → axis_util-GTVlo58H.js} +1 -1
  8. package/dist/backend.js +2 -2
  9. package/dist/{backend_util-qwSFfxYx.js → backend_util-GaFarB78.js} +21 -21
  10. package/dist/{backend_webgpu-DI2wXEC2.js → backend_webgpu-BqASlsbV.js} +8 -8
  11. package/dist/{broadcast_to-C_EJTVTZ.js → broadcast_to-eS93CCN_.js} +2 -2
  12. package/dist/checks/appendCache.js +2 -2
  13. package/dist/checks/attentionMask.js +5 -5
  14. package/dist/checks/gelu.js +2 -2
  15. package/dist/checks/matMulGelu.js +2 -2
  16. package/dist/checks/normRMS.js +6 -6
  17. package/dist/checks/normRMSGrad.js +3 -3
  18. package/dist/checks/packUnpack.js +6 -6
  19. package/dist/checks/qkv.js +2 -2
  20. package/dist/checks/rope.js +2 -2
  21. package/dist/{clip_by_value-CLAD4h_I.js → clip_by_value-DDA7rrcT.js} +1 -1
  22. package/dist/complex-DI35Q-gW.js +11 -0
  23. package/dist/{concat-Dqk7Xk7h.js → concat-CAQpCret.js} +5 -5
  24. package/dist/{concat_util-C1Mxe27t.js → concat_util-D18dJ4fD.js} +1 -1
  25. package/dist/{dataset-DlqAN81i.js → dataset-CGGp1z9P.js} +3 -3
  26. package/dist/{dropout_util-N0z8Os-K.js → dropout_util--NxWuYg2.js} +1 -1
  27. package/dist/{expand_dims-D0rBtgT1.js → expand_dims-Bkd1YD5x.js} +4 -4
  28. package/dist/{exports_initializers-DIOZQt_L.js → exports_initializers-CYzKLjN7.js} +1 -1
  29. package/dist/{floor-CymuCmTO.js → floor-BQtb-Azg.js} +1 -1
  30. package/dist/{gather-DEyjXNb1.js → gather-qIqEqaGn.js} +1 -1
  31. package/dist/{gelu-DpTCC3eB.js → gelu-B220X1Go.js} +1 -1
  32. package/dist/{gpgpu_math-3bCb5ooU.js → gpgpu_math-BwvV12df.js} +25 -25
  33. package/dist/{index-DSGwv2Yx.js → index-CUXkjxiT.js} +33 -33
  34. package/dist/{index-BQvB7LCC.js → index-CjOWnMXP.js} +15 -15
  35. package/dist/{kernel_funcs_utils-DGqzNlHT.js → kernel_funcs_utils-pq0CK9co.js} +6 -6
  36. package/dist/layers/BaseLayer.js +4 -4
  37. package/dist/layers/CausalSelfAttention.d.ts +1 -0
  38. package/dist/layers/CausalSelfAttention.js +14 -14
  39. package/dist/layers/LoRA.js +4 -4
  40. package/dist/layers/MLP.js +4 -4
  41. package/dist/layers/PositionEmbedding.js +5 -5
  42. package/dist/layers/RMSNorm.js +3 -3
  43. package/dist/layers/RoPECache.js +4 -4
  44. package/dist/layers/TiedEmbedding.js +6 -6
  45. package/dist/layers/TransformerBlock.d.ts +1 -0
  46. package/dist/layers/TransformerBlock.js +1 -1
  47. package/dist/layers/WeightStore.js +2 -2
  48. package/dist/loader/loadTransformers.js +9 -9
  49. package/dist/loader/oldZipLoad.js +9 -9
  50. package/dist/loader/save.js +38 -30
  51. package/dist/loader/types.d.ts +1 -0
  52. package/dist/main.js +9 -9
  53. package/dist/{matMul16-BIT70Vya.js → matMul16-BcVC_E62.js} +3 -3
  54. package/dist/{matMulGelu-CsZnh18H.js → matMulGelu-JNLZqKQp.js} +18 -18
  55. package/dist/mat_mul-DhG0Newp.js +11 -0
  56. package/dist/mod-CSdCpRjf.js +11 -0
  57. package/dist/models/NanoGPTV1.js +2 -2
  58. package/dist/models/NanoGPTV2.js +2 -2
  59. package/dist/models/model.d.ts +1 -0
  60. package/dist/models/model.js +9 -9
  61. package/dist/{not_equal-CkQKkKZy.js → not_equal-hurPF26l.js} +15 -15
  62. package/dist/{ones-DbVB5N58.js → ones-BytntneX.js} +3 -3
  63. package/dist/ops/adamAdjust.js +3 -3
  64. package/dist/ops/adamMoments.js +3 -3
  65. package/dist/ops/add16.js +1 -1
  66. package/dist/ops/appendCache.js +6 -6
  67. package/dist/ops/attentionMask.js +3 -3
  68. package/dist/ops/concat16.js +3 -3
  69. package/dist/ops/cpu/adamAdjust.js +9 -9
  70. package/dist/ops/cpu/adamMoments.js +5 -5
  71. package/dist/ops/cpu/appendCache.js +2 -2
  72. package/dist/ops/cpu/attentionMask.js +6 -6
  73. package/dist/ops/cpu/fusedSoftmax.js +4 -4
  74. package/dist/ops/cpu/gatherSub.js +5 -5
  75. package/dist/ops/cpu/gelu.js +4 -4
  76. package/dist/ops/cpu/matMul16.js +2 -2
  77. package/dist/ops/cpu/matMulGelu.js +7 -7
  78. package/dist/ops/cpu/matMulMul.js +2 -2
  79. package/dist/ops/cpu/mulDropout.js +5 -5
  80. package/dist/ops/cpu/normRMS.js +1 -1
  81. package/dist/ops/cpu/qkv.js +3 -3
  82. package/dist/ops/cpu/rope.js +5 -5
  83. package/dist/ops/cpu/scatterSub.js +5 -5
  84. package/dist/ops/dot16.js +2 -2
  85. package/dist/ops/dropout.js +6 -6
  86. package/dist/ops/dropout16.js +1 -1
  87. package/dist/ops/gatherSub.js +1 -1
  88. package/dist/ops/gelu.js +2 -2
  89. package/dist/ops/globalNorm.js +7 -7
  90. package/dist/ops/grads/add16.js +1 -1
  91. package/dist/ops/grads/attentionMask.js +2 -2
  92. package/dist/ops/grads/dropout16.js +1 -1
  93. package/dist/ops/grads/gelu.js +2 -2
  94. package/dist/ops/grads/matMul16.js +3 -3
  95. package/dist/ops/grads/matMulGelu.js +1 -1
  96. package/dist/ops/grads/mul16.js +1 -1
  97. package/dist/ops/grads/normRMS.js +7 -7
  98. package/dist/ops/grads/pack16.js +3 -3
  99. package/dist/ops/grads/qkv.js +11 -11
  100. package/dist/ops/grads/rope.js +2 -2
  101. package/dist/ops/grads/softmax16.js +1 -1
  102. package/dist/ops/grads/unpack16.js +2 -2
  103. package/dist/ops/matMul16.js +3 -3
  104. package/dist/ops/matMulGelu.js +6 -6
  105. package/dist/ops/matMulMul.js +3 -3
  106. package/dist/ops/mul16.js +1 -1
  107. package/dist/ops/mulDrop.js +3 -3
  108. package/dist/ops/normRMS.js +4 -4
  109. package/dist/ops/pack16.js +2 -2
  110. package/dist/ops/qkv.js +3 -3
  111. package/dist/ops/reshape16.js +6 -6
  112. package/dist/ops/rope.js +2 -2
  113. package/dist/ops/scatterSub.js +1 -1
  114. package/dist/ops/slice16.js +2 -2
  115. package/dist/ops/softmax16.js +1 -1
  116. package/dist/ops/sub16.js +1 -1
  117. package/dist/ops/sum16.js +6 -6
  118. package/dist/ops/transpose16.js +3 -3
  119. package/dist/ops/unpack16.js +2 -2
  120. package/dist/ops/webgl/adamAdjust.js +2 -2
  121. package/dist/ops/webgl/adamMoments.js +1 -1
  122. package/dist/ops/webgl/appendCache.js +1 -1
  123. package/dist/ops/webgl/attentionMask.js +1 -1
  124. package/dist/ops/webgl/dropout16.js +1 -1
  125. package/dist/ops/webgl/fusedSoftmax.js +7 -7
  126. package/dist/ops/webgl/gatherSub.js +3 -3
  127. package/dist/ops/webgl/gelu.js +2 -2
  128. package/dist/ops/webgl/log.js +3 -3
  129. package/dist/ops/webgl/matMul16.js +13 -13
  130. package/dist/ops/webgl/matMulGelu.js +4 -4
  131. package/dist/ops/webgl/matMulMul.js +2 -2
  132. package/dist/ops/webgl/mulDropout.js +1 -1
  133. package/dist/ops/webgl/normRMS.js +2 -2
  134. package/dist/ops/webgl/qkv.js +1 -1
  135. package/dist/ops/webgl/rope.js +1 -1
  136. package/dist/ops/webgl/scatterSub.js +2 -2
  137. package/dist/ops/webgpu/adamAdjust.js +3 -3
  138. package/dist/ops/webgpu/adamMoments.js +3 -3
  139. package/dist/ops/webgpu/add16.js +6 -6
  140. package/dist/ops/webgpu/appendCache.js +3 -3
  141. package/dist/ops/webgpu/attentionMask.js +2 -2
  142. package/dist/ops/webgpu/attentionMask32_program.js +2 -2
  143. package/dist/ops/webgpu/clipScale.js +7 -7
  144. package/dist/ops/webgpu/concat16.js +5 -5
  145. package/dist/ops/webgpu/dropout16.js +6 -6
  146. package/dist/ops/webgpu/gatherSub.js +3 -3
  147. package/dist/ops/webgpu/gelu.js +8 -8
  148. package/dist/ops/webgpu/matMul16.js +16 -16
  149. package/dist/ops/webgpu/matMul16_program.js +2 -2
  150. package/dist/ops/webgpu/mul16.js +5 -5
  151. package/dist/ops/webgpu/norm2.js +1 -1
  152. package/dist/ops/webgpu/normRMS.js +2 -2
  153. package/dist/ops/webgpu/normRMSGrad.js +4 -4
  154. package/dist/ops/webgpu/pack16.js +4 -4
  155. package/dist/ops/webgpu/pack16_program.js +2 -2
  156. package/dist/ops/webgpu/qkv.js +2 -2
  157. package/dist/ops/webgpu/rope.js +3 -3
  158. package/dist/ops/webgpu/scatterSub.js +3 -3
  159. package/dist/ops/webgpu/slice16.js +4 -4
  160. package/dist/ops/webgpu/softmax16.js +4 -4
  161. package/dist/ops/webgpu/softmax16_program.js +2 -2
  162. package/dist/ops/webgpu/softmax16_subgroup_program.js +2 -2
  163. package/dist/ops/webgpu/softmax16grad.js +4 -4
  164. package/dist/ops/webgpu/sub16.js +6 -6
  165. package/dist/ops/webgpu/sum16.js +3 -3
  166. package/dist/ops/webgpu/transpose16.js +8 -8
  167. package/dist/ops/webgpu/transpose16_program.js +2 -2
  168. package/dist/ops/webgpu/transpose16_shared_program.js +3 -3
  169. package/dist/ops/webgpu/unpack16.js +3 -3
  170. package/dist/ops/webgpu/utils/binary_op.js +3 -3
  171. package/dist/ops/webgpu/utils/reductions.js +5 -5
  172. package/dist/{ops-CURIZSVt.js → ops-CsXeTq1P.js} +100 -100
  173. package/dist/{pack16-WlOSOuZA.js → pack16-bqltoUlR.js} +2 -2
  174. package/dist/patches/webgpu_backend.js +6 -6
  175. package/dist/patches/webgpu_base.js +1 -1
  176. package/dist/patches/webgpu_program.js +2 -2
  177. package/dist/{random_normal-CIm8lk2-.js → random_normal-IBRrha8a.js} +1 -1
  178. package/dist/{random_width-B_fVXhGx.js → random_width-DN5ZtQkM.js} +131 -131
  179. package/dist/{range-BDxO73mk.js → range-C-CjF-LI.js} +1 -1
  180. package/dist/relu-J_X6MUzx.js +9 -0
  181. package/dist/{reshape-BIN71H3p.js → reshape-BDOuCSNW.js} +1 -1
  182. package/dist/{resize_nearest_neighbor-C6_0dAnK.js → resize_nearest_neighbor-BojqlfRe.js} +41 -41
  183. package/dist/{rope-CC5RjmKU.js → rope-DcrZM_e6.js} +5 -5
  184. package/dist/{scatter_nd_util-C-x73Cj6.js → scatter_nd_util-ByNJaL6I.js} +1 -1
  185. package/dist/{segment_util-4zuHV5IG.js → segment_util-Dasb2Zaf.js} +2 -2
  186. package/dist/{selu_util-BXdhy_W6.js → selu_util-BLhIqRkw.js} +5 -5
  187. package/dist/{shared-zTaJ5siv.js → shared-3agzAqQ_.js} +1 -1
  188. package/dist/{shared-DRWDyk9w.js → shared-CagdqkLh.js} +6 -6
  189. package/dist/slice-BzS11Qh0.js +12 -0
  190. package/dist/{slice_util-DPY56GzQ.js → slice_util-CC35pLmT.js} +5 -5
  191. package/dist/{softmax-BLGJqdwx.js → softmax-D4q1LJN7.js} +1 -1
  192. package/dist/split-C2Sj255c.js +9 -0
  193. package/dist/{squeeze-O_YWJpw_.js → squeeze-ho4wLUek.js} +2 -2
  194. package/dist/{stack-z6QE7kmP.js → stack-DudVrtmG.js} +1 -1
  195. package/dist/{step-DQY6_ABw.js → step-BTxPtq1r.js} +4 -4
  196. package/dist/{sum-D39FeU5h.js → sum-BpiwSWvg.js} +3 -3
  197. package/dist/{tensor-D8e0Gd7c.js → tensor-BWFldCso.js} +1 -1
  198. package/dist/{tensor1d-BMl0eZYV.js → tensor1d-LMGMIUlr.js} +1 -1
  199. package/dist/{tensor2d-DTtQ1QcT.js → tensor2d-BnXMKScO.js} +1 -1
  200. package/dist/{tensor4d-Dj4rDssL.js → tensor4d-C6UCG_u8.js} +1 -1
  201. package/dist/{tfjs_backend-Bk3PmK91.js → tfjs_backend-BGnG-ppu.js} +65 -65
  202. package/dist/{tile-CsWlVKKz.js → tile-CFy-xTO6.js} +1 -1
  203. package/dist/tokeniser/BaseTokeniser.d.ts +5 -1
  204. package/dist/tokeniser/BaseTokeniser.js +62 -53
  205. package/dist/tokeniser/type.d.ts +8 -0
  206. package/dist/training/AdamW.js +2 -2
  207. package/dist/training/BasicTrainer.d.ts +1 -0
  208. package/dist/training/BasicTrainer.js +95 -79
  209. package/dist/training/DatasetBuilder.d.ts +6 -2
  210. package/dist/training/DatasetBuilder.js +60 -41
  211. package/dist/training/Evaluator.d.ts +1 -2
  212. package/dist/training/Evaluator.js +21 -31
  213. package/dist/training/SFTTrainer.d.ts +3 -2
  214. package/dist/training/SFTTrainer.js +4 -3
  215. package/dist/training/orthoGrad.js +1 -1
  216. package/dist/training/sparseCrossEntropy.js +38 -38
  217. package/dist/training/tasks/ConversationTask.d.ts +4 -0
  218. package/dist/training/tasks/ConversationTask.js +7 -7
  219. package/dist/training/tasks/PretrainingTask.d.ts +4 -0
  220. package/dist/training/tasks/PretrainingTask.js +11 -7
  221. package/dist/training/tasks/StartSentenceTask.d.ts +4 -0
  222. package/dist/training/tasks/StartSentenceTask.js +5 -5
  223. package/dist/training/tasks/Task.d.ts +12 -0
  224. package/dist/training/tasks/Task.js +55 -31
  225. package/dist/training/types.d.ts +1 -0
  226. package/dist/training/validation.d.ts +1 -1
  227. package/dist/training/validation.js +33 -32
  228. package/dist/{transpose-Qxz-4os3.js → transpose-9kRxIXWR.js} +7 -7
  229. package/dist/{unsorted_segment_sum-BfFVV9Zm.js → unsorted_segment_sum-DJvk5xnh.js} +20 -20
  230. package/dist/utilities/dummy.js +6 -6
  231. package/dist/utilities/multinomialCPU.js +2 -2
  232. package/dist/utilities/packed.js +1 -1
  233. package/dist/utilities/performance.js +1 -1
  234. package/dist/utilities/profile.js +1 -1
  235. package/dist/utilities/safetensors.js +2 -2
  236. package/dist/utilities/sentences.js +5 -5
  237. package/dist/utilities/weights.js +2 -2
  238. package/dist/{variable-SSATClyt.js → variable-Ck482e3n.js} +1 -1
  239. package/dist/{webgpu_program-CbjdYLYk.js → webgpu_program-B4HmApL1.js} +1 -1
  240. package/dist/{webgpu_util-DuofJBMo.js → webgpu_util-DYlGSwOJ.js} +7 -7
  241. package/dist/{zeros-Bw0puq_w.js → zeros-DvZpK8s6.js} +2 -2
  242. package/dist/{zeros_like-rOHr54NY.js → zeros_like-CWjDdwr-.js} +69 -69
  243. package/package.json +1 -1
  244. package/dist/complex-3DpPEG9B.js +0 -11
  245. package/dist/mat_mul-DP86qZtZ.js +0 -11
  246. package/dist/mod-BXjLYwvM.js +0 -11
  247. package/dist/readers-17HLdxVM.js +0 -12
  248. package/dist/relu-DTvZKBsZ.js +0 -9
  249. package/dist/slice-BvItlgXu.js +0 -12
  250. package/dist/split-BN9LkEgS.js +0 -9
  251. package/dist/training/SFTDatasetBuilder.d.ts +0 -23
  252. package/dist/training/SFTDatasetBuilder.js +0 -85
@@ -1,69 +1,69 @@
1
- import { gatherSub as j } from "../ops/gatherSub.js";
1
+ import { gatherSub as $ } from "../ops/gatherSub.js";
2
2
  import { scatterSub as T } from "../ops/scatterSub.js";
3
- import { t as H, a1 as G, h as A, m as x, d as U, a2 as D, b as q, a3 as F } from "../index-DSGwv2Yx.js";
4
- import { m as J, l as K, a as E, n as N, w as O } from "../not_equal-CkQKkKZy.js";
5
- import { s as m } from "../sum-D39FeU5h.js";
6
- import { s as Q } from "../softmax-BLGJqdwx.js";
7
- function R(e, h, t, g, v, a = 0) {
8
- return H(() => {
9
- const S = e.shape[e.shape.length - 1], i = v || e.shape.slice(0, -1), l = i.reduce((n, p) => n * p, 1), f = e.shape.length > 2 ? e.reshape([l, S]) : e, b = h.shape.length > 1 ? h.reshape([l]).cast("int32") : h.cast("int32"), u = J(f, -1, !0), o = G(f, u), r = K(o, -1), d = j(r, b, o);
3
+ import { t as F, a1 as G, j as A, m as x, i as U, a2 as D, a as j, a3 as q } from "../index-CUXkjxiT.js";
4
+ import { m as J, l as K, a as E, n as N, w as O } from "../not_equal-hurPF26l.js";
5
+ import { s as m } from "../sum-BpiwSWvg.js";
6
+ import { s as Q } from "../softmax-D4q1LJN7.js";
7
+ function R(e, l, a, g, v, t = 0) {
8
+ return F(() => {
9
+ const S = e.shape[e.shape.length - 1], i = v || e.shape.slice(0, -1), f = i.reduce((c, d) => c * d, 1), h = e.shape.length > 2 ? e.reshape([f, S]) : e, y = l.shape.length > 1 ? l.reshape([f]).cast("int32") : l.cast("int32"), u = J(h, -1, !0), o = G(h, u), n = K(o, -1), p = $(n, y, o);
10
10
  let s;
11
- if (a > 0) {
12
- const n = G(r, E(o, -1));
13
- s = A(x(d, 1 - a), x(n, a));
11
+ if (t > 0) {
12
+ const c = G(n, E(o, -1));
13
+ s = A(x(p, 1 - t), x(c, t));
14
14
  } else
15
- s = d;
16
- if (t)
17
- if (s = x(s, t), g) {
18
- const n = m(t.reshape(i), -1);
19
- s = U(m(s.reshape(i), -1), n);
15
+ s = p;
16
+ if (a)
17
+ if (s = x(s, a), g) {
18
+ const c = m(a.reshape(i), -1);
19
+ s = U(m(s.reshape(i), -1), c);
20
20
  } else {
21
- const n = m(t);
22
- s = U(m(s), n);
21
+ const c = m(a);
22
+ s = U(m(s), c);
23
23
  }
24
24
  else
25
25
  g ? s = E(s.reshape(i), -1) : s = E(s);
26
26
  return s;
27
27
  });
28
28
  }
29
- function ts(e, h, t = 0) {
29
+ function as(e, l, a = 0) {
30
30
  return D(
31
31
  // @ts-expect-error Invalid params
32
- (a, S, i) => {
33
- const l = a.shape[a.shape.length - 1], f = a.shape.slice(0, -1), b = f.reduce((p, c) => p * c, 1), u = a.reshape([b, l]), o = S.reshape([b]).cast("int32");
34
- let r, d = null;
32
+ (t, S, i) => {
33
+ const f = t.shape[t.shape.length - 1], h = t.shape.slice(0, -1), y = h.reduce((d, r) => d * r, 1), u = t.reshape([y, f]), o = S.reshape([y]).cast("int32");
34
+ let n, p = null;
35
35
  if (e) {
36
- const p = q(-100, "int32"), c = N(o, p);
37
- d = c.cast("float32"), r = O(c, o, F(o));
36
+ const d = j(65535, "int32"), r = N(o, d);
37
+ p = r.cast("float32"), n = O(r, o, q(o)), d.dispose(), r.dispose();
38
38
  } else
39
- r = o;
39
+ n = o;
40
40
  const s = R(
41
41
  u,
42
- r,
43
- d || void 0,
42
+ n,
43
+ p || void 0,
44
+ l,
44
45
  h,
45
- f,
46
- t
46
+ a
47
47
  );
48
- return i(d ? [u, r, d] : [u, r]), u.dispose(), o.dispose(), { value: s, gradFunc: (p, c) => H(() => {
49
- const C = c[0], z = c[1], y = e ? c[2] : void 0, w = Q(C), P = y ? m(y) : q(C.shape[0], "float32"), I = p.div(P).broadcastTo([C.shape[0]]), M = y && e ? x(I, y) : I;
48
+ return i(p ? [u, n, p] : [u, n]), u.dispose(), o.dispose(), { value: s, gradFunc: (d, r) => F(() => {
49
+ const C = r[0], z = r[1], b = e ? r[2] : void 0, w = Q(C), H = b ? m(b) : j(C.shape[0], "float32"), I = d.div(H).broadcastTo([C.shape[0]]), M = b && e ? x(I, b) : I;
50
50
  let L;
51
- if (t > 0) {
52
- const W = t / l, $ = G(w, W);
51
+ if (a > 0) {
52
+ const V = a / f, W = G(w, V);
53
53
  L = T(
54
- $,
54
+ W,
55
55
  z,
56
- x(M, 1 - t)
56
+ x(M, 1 - a)
57
57
  );
58
58
  } else
59
59
  L = T(w, z, M);
60
- const V = F(S);
61
- return [L.reshape(a.shape), V];
60
+ const P = q(S);
61
+ return [L.reshape(t.shape), P];
62
62
  }) };
63
63
  }
64
64
  );
65
65
  }
66
66
  export {
67
- ts as createSoftmaxCrossEntropyWithGrad,
67
+ as as createSoftmaxCrossEntropyWithGrad,
68
68
  R as sparseSoftmaxCrossEntropy
69
69
  };
@@ -9,6 +9,10 @@ export default class ConversationTask extends Task {
9
9
  hasMoreConversations(): boolean;
10
10
  nextConversation(): Conversation[] | null;
11
11
  nextTokens(tokeniser: ITokeniser): number[] | null;
12
+ nextTokens(tokeniser: ITokeniser, masking: boolean): {
13
+ tokens: number[];
14
+ mask: boolean[];
15
+ } | null;
12
16
  shuffle(): void;
13
17
  estimateTokens(tokeniser: ITokeniser): Promise<number>;
14
18
  }
@@ -1,6 +1,6 @@
1
1
  import { Task as t } from "./Task.js";
2
- import { shuffle as s } from "../DatasetBuilder.js";
3
- class a extends t {
2
+ import { shuffle as i } from "../DatasetBuilder.js";
3
+ class f extends t {
4
4
  rawConvo;
5
5
  shuffledIndices = null;
6
6
  index = 0;
@@ -19,9 +19,9 @@ class a extends t {
19
19
  const n = this.rawConvo[this.shuffledIndices ? this.shuffledIndices[this.index] : this.index];
20
20
  return this.index++, n;
21
21
  }
22
- nextTokens(n) {
22
+ nextTokens(n, s) {
23
23
  const e = this.nextConversation();
24
- return e ? n.encodeConversation(e) : null;
24
+ return e ? n.encodeConversation(e, !1, s) : null;
25
25
  }
26
26
  shuffle() {
27
27
  if (!this.shuffledIndices) {
@@ -29,12 +29,12 @@ class a extends t {
29
29
  for (let n = 0; n < this.rawConvo.length; n++)
30
30
  this.shuffledIndices[n] = n;
31
31
  }
32
- s(this.shuffledIndices), this.index = 0;
32
+ i(this.shuffledIndices), this.index = 0;
33
33
  }
34
34
  async estimateTokens(n) {
35
- return (await n.encodeConversation(this.rawConvo[0])).length * this.length;
35
+ return n.encodeConversation(this.rawConvo[0]).length * this.length;
36
36
  }
37
37
  }
38
38
  export {
39
- a as default
39
+ f as default
40
40
  };
@@ -8,6 +8,10 @@ export default class PretrainingTask extends Task {
8
8
  hasMoreConversations(): boolean;
9
9
  nextConversation(): Conversation[] | null;
10
10
  nextTokens(tokeniser: ITokeniser): number[] | null;
11
+ nextTokens(tokeniser: ITokeniser, masking: boolean): {
12
+ tokens: number[];
13
+ mask: boolean[];
14
+ } | null;
11
15
  shuffle(): void;
12
16
  estimateTokens(tokeniser: ITokeniser): Promise<number>;
13
17
  }
@@ -1,5 +1,5 @@
1
- import { Task as n } from "./Task.js";
2
- class r extends n {
1
+ import { Task as r } from "./Task.js";
2
+ class h extends r {
3
3
  rawText;
4
4
  index = 0;
5
5
  get length() {
@@ -20,24 +20,28 @@ class r extends n {
20
20
  };
21
21
  return this.index++, [t];
22
22
  }
23
- nextTokens(t) {
23
+ nextTokens(t, n) {
24
24
  if (this.index >= this.rawText.length)
25
25
  return null;
26
26
  const e = t.encodeSequence(this.rawText[this.index]);
27
- return this.index++, e;
27
+ if (this.index++, n) {
28
+ const s = new Array(e.length).fill(!0);
29
+ return { tokens: e, mask: s };
30
+ }
31
+ return e;
28
32
  }
29
33
  shuffle() {
30
34
  this.index = 0;
31
35
  }
32
36
  async estimateTokens(t) {
33
- return (await t.encodeConversation([
37
+ return t.encodeConversation([
34
38
  {
35
39
  role: "assistant",
36
40
  content: this.rawText[0]
37
41
  }
38
- ])).length * this.length;
42
+ ]).length * this.length;
39
43
  }
40
44
  }
41
45
  export {
42
- r as default
46
+ h as default
43
47
  };
@@ -8,6 +8,10 @@ export default class StartSentenceTask extends Task {
8
8
  hasMoreConversations(): boolean;
9
9
  nextConversation(): Conversation[] | null;
10
10
  nextTokens(tokeniser: ITokeniser): number[] | null;
11
+ nextTokens(tokeniser: ITokeniser, masking: boolean): {
12
+ tokens: number[];
13
+ mask: boolean[];
14
+ } | null;
11
15
  shuffle(): void;
12
16
  private conversationFromString;
13
17
  estimateTokens(tokeniser: ITokeniser): Promise<number>;
@@ -1,5 +1,5 @@
1
- import { Task as e } from "./Task.js";
2
- class a extends e {
1
+ import { Task as r } from "./Task.js";
2
+ class a extends r {
3
3
  rawText;
4
4
  index = 0;
5
5
  get length() {
@@ -17,9 +17,9 @@ class a extends e {
17
17
  const t = this.rawText[this.index];
18
18
  return this.index++, this.conversationFromString(t);
19
19
  }
20
- nextTokens(t) {
21
- const n = this.nextConversation();
22
- return n ? t.encodeConversation(n) : null;
20
+ nextTokens(t, n) {
21
+ const e = this.nextConversation();
22
+ return e ? t.encodeConversation(e, !1, n) : null;
23
23
  }
24
24
  shuffle() {
25
25
  this.index = 0;
@@ -4,7 +4,19 @@ export declare abstract class Task {
4
4
  abstract hasMoreConversations(): boolean;
5
5
  abstract nextConversation(): Conversation[] | null;
6
6
  abstract nextTokens(tokeniser: ITokeniser): number[] | null;
7
+ abstract nextTokens(tokeniser: ITokeniser, masking: boolean): {
8
+ tokens: number[];
9
+ mask: boolean[];
10
+ } | null;
11
+ abstract nextTokens(tokeniser: ITokeniser, masking?: boolean): number[] | {
12
+ tokens: number[];
13
+ mask: boolean[];
14
+ } | null;
7
15
  abstract estimateTokens(tokeniser: ITokeniser): Promise<number>;
8
16
  abstract shuffle(): void;
9
17
  }
10
18
  export declare function tokensFromTasks(tasks: Task[], tokenizer: ITokeniser, cb?: (tokens: number) => void): Promise<Uint16Array>;
19
+ export declare function tokensFromTasks(tasks: Task[], tokenizer: ITokeniser, cb?: (tokens: number) => void, masking?: boolean): Promise<{
20
+ tokens: Uint16Array;
21
+ mask: Uint8Array;
22
+ }>;
@@ -1,44 +1,68 @@
1
- import { yieldIfNeeded as g } from "../../utilities/yielder.js";
2
- class y {
1
+ import { yieldIfNeeded as k } from "../../utilities/yielder.js";
2
+ class w {
3
3
  }
4
- function u(i, f, h, t, n) {
5
- for (const s of i) {
6
- const o = s.nextTokens(h);
7
- if (o) {
8
- t.total += o.length;
9
- const c = f[f.length - 1];
10
- if (t.offset + o.length > c.length) {
11
- const r = c.length - t.offset;
12
- c.set(o.slice(0, r), t.offset);
13
- const l = new Uint16Array(Math.floor(n * 0.1) + 100);
14
- l.set(o.slice(r), 0), f.push(l), t.offset = o.length - r;
4
+ function m(y, i, u, o, g, n) {
5
+ for (const a of y) {
6
+ const e = a.nextTokens(u, n ? !0 : void 0);
7
+ if (e) {
8
+ const f = Array.isArray(e) ? e : e.tokens;
9
+ o.total += f.length;
10
+ const c = i[i.length - 1], l = n ? n[n.length - 1] : null;
11
+ if (o.offset + f.length > c.length) {
12
+ const s = c.length - o.offset;
13
+ c.set(f.slice(0, s), o.offset);
14
+ const t = new Uint16Array(Math.floor(g * 0.1) + 100);
15
+ if (t.set(f.slice(s), 0), i.push(t), n && l && !Array.isArray(e)) {
16
+ l.set(
17
+ e.mask.slice(0, s).map((h) => h ? 1 : 0),
18
+ o.offset
19
+ );
20
+ const r = new Uint8Array(t.length);
21
+ r.set(
22
+ e.mask.slice(s).map((h) => h ? 1 : 0),
23
+ 0
24
+ ), n.push(r);
25
+ }
26
+ o.offset = f.length - s;
15
27
  } else
16
- c.set(o, t.offset), t.offset += o.length;
28
+ c.set(f, o.offset), l && !Array.isArray(e) && l.set(
29
+ e.mask.map((s) => s ? 1 : 0),
30
+ o.offset
31
+ ), o.offset += f.length;
17
32
  }
18
33
  }
19
34
  }
20
- async function d(i, f, h) {
21
- const t = Math.min(
22
- (await Promise.all(i.map((e) => e.estimateTokens(f)))).reduce((e, a) => e + a, 0),
23
- f.vocabSize * 1e4
24
- ), n = [new Uint16Array(t)], s = {
35
+ async function p(y, i, u, o) {
36
+ const g = Math.min(
37
+ (await Promise.all(y.map((t) => t.estimateTokens(i)))).reduce((t, r) => t + r, 0),
38
+ i.vocabSize * 1e4
39
+ ), n = [new Uint16Array(g)], a = o ? [new Uint8Array(g)] : null, e = {
25
40
  offset: 0,
26
41
  total: 0
27
42
  };
28
- let o = performance.now();
29
- for (; s.offset < t && (u(i, n, f, s, t), !i.every((e) => !e.hasMoreConversations())); )
30
- o = await g(o, h, s.total);
43
+ let f = performance.now();
44
+ for (; e.offset < g && (m(y, n, i, e, g, a || void 0), !y.every((t) => !t.hasMoreConversations())); )
45
+ f = await k(f, u, e.total);
31
46
  if (n.length === 1)
32
- return n[0].subarray(0, s.offset);
33
- const c = n.reduce((e, a) => e + a.length, 0) - (n[n.length - 1].length - s.offset), r = new Uint16Array(c);
34
- let l = 0;
35
- for (let e = 0; e < n.length; e++) {
36
- const a = n[e];
37
- e === n.length - 1 ? (r.set(a.subarray(0, s.offset), l), l += s.offset) : (r.set(a, l), l += a.length);
47
+ return a ? { tokens: n[0].subarray(0, e.offset), mask: a[0].subarray(0, e.offset) } : n[0].subarray(0, e.offset);
48
+ const c = n.reduce((t, r) => t + r.length, 0) - (n[n.length - 1].length - e.offset), l = new Uint16Array(c);
49
+ let s = 0;
50
+ for (let t = 0; t < n.length; t++) {
51
+ const r = n[t];
52
+ t === n.length - 1 ? (l.set(r.subarray(0, e.offset), s), s += e.offset) : (l.set(r, s), s += r.length);
38
53
  }
39
- return r;
54
+ if (a) {
55
+ const t = new Uint8Array(c);
56
+ s = 0;
57
+ for (let r = 0; r < a.length; r++) {
58
+ const h = a[r];
59
+ r === a.length - 1 ? (t.set(h.subarray(0, e.offset), s), s += e.offset) : (t.set(h, s), s += h.length);
60
+ }
61
+ return { tokens: l, mask: t };
62
+ }
63
+ return l;
40
64
  }
41
65
  export {
42
- y as Task,
43
- d as tokensFromTasks
66
+ w as Task,
67
+ p as tokensFromTasks
44
68
  };
@@ -61,6 +61,7 @@ export interface TrainingOptions extends Partial<AdamWOptimizerConfig> {
61
61
  labelSmoothing?: number;
62
62
  dropout?: number;
63
63
  layerDrop?: number;
64
+ debug?: boolean;
64
65
  onStep?: (log: TrainingLogEntry) => void;
65
66
  }
66
67
  export interface TrainingState {
@@ -2,7 +2,7 @@ import { ITokeniser, Task } from '../main';
2
2
  import { Tensor } from '@tensorflow/tfjs-core';
3
3
  import { Dataset } from '@tensorflow/tfjs-data';
4
4
  import { DatasetBuilder, DatasetState } from './DatasetBuilder';
5
- export declare function createTrainValidationSplit(tasks: Task[] | Uint16Array, tokeniser: ITokeniser, datasetBuilder: DatasetBuilder, batchSize: number, validationSplit?: number): Promise<{
5
+ export declare function createTrainValidationSplit(tasks: Task[] | Uint16Array, tokeniser: ITokeniser, datasetBuilder: DatasetBuilder, batchSize: number, validationSplit?: number, masking?: boolean): Promise<{
6
6
  trainDataset: Dataset<{
7
7
  xs: Tensor;
8
8
  ys: Tensor;
@@ -1,22 +1,22 @@
1
- import "../index-DSGwv2Yx.js";
2
- import "../random_width-B_fVXhGx.js";
3
- import "../zeros_like-rOHr54NY.js";
1
+ import "../index-CUXkjxiT.js";
2
+ import "../random_width-DN5ZtQkM.js";
3
+ import "../zeros_like-CWjDdwr-.js";
4
4
  import "../Generator.js";
5
5
  import "../index-Cp39cXWe.js";
6
- import "../dataset-DlqAN81i.js";
6
+ import "../dataset-CGGp1z9P.js";
7
7
  import "../ops/cpu/attentionMask.js";
8
8
  import "../ops/webgl/attentionMask.js";
9
9
  import "../ops/grads/attentionMask.js";
10
10
  import "../ops/cpu/rope.js";
11
11
  import "../ops/webgl/rope.js";
12
- import "../rope-CC5RjmKU.js";
12
+ import "../rope-DcrZM_e6.js";
13
13
  import "../ops/cpu/appendCache.js";
14
14
  import "../ops/webgl/appendCache.js";
15
15
  import "../ops/grads/softmax16.js";
16
- import "../matMul16-BIT70Vya.js";
16
+ import "../matMul16-BcVC_E62.js";
17
17
  import "../ops/webgl/matMul16.js";
18
18
  import "../ops/cpu/matMul16.js";
19
- import "../pack16-WlOSOuZA.js";
19
+ import "../pack16-bqltoUlR.js";
20
20
  import "../ops/transpose16.js";
21
21
  import "../ops/reshape16.js";
22
22
  import "../ops/cpu/qkv.js";
@@ -38,46 +38,47 @@ import "../ops/cpu/gatherSub.js";
38
38
  import "../ops/webgl/gatherSub.js";
39
39
  import "../ops/cpu/scatterSub.js";
40
40
  import "../ops/webgl/scatterSub.js";
41
- import { PAGE_FACTOR as m, shuffle as h } from "./DatasetBuilder.js";
42
- import { tokensFromTasks as k } from "./tasks/Task.js";
41
+ import { PAGE_FACTOR as a, shuffle as k } from "./DatasetBuilder.js";
43
42
  import "../papaparse.min-C0cScC2i.js";
43
+ import { tokensFromTasks as y } from "./tasks/Task.js";
44
44
  import "../ops/cpu/matMulGelu.js";
45
- import "../matMulGelu-CsZnh18H.js";
45
+ import "../matMulGelu-JNLZqKQp.js";
46
46
  import "../ops/grads/matMulGelu.js";
47
47
  import "../ops/cpu/gelu.js";
48
48
  import "../ops/webgl/gelu.js";
49
- import "../gelu-DpTCC3eB.js";
49
+ import "../gelu-B220X1Go.js";
50
50
  import "../ops/webgl/log.js";
51
51
  import "../checks/normRMS.js";
52
52
  import "../checks/normRMSGrad.js";
53
- async function dt(p, g, o, s, l = 0.1) {
54
- const i = p instanceof Uint16Array ? p : await k(p, g), r = /* @__PURE__ */ new Set();
55
- if (l > 0) {
56
- const t = Math.floor(i.length / (o.blockSize * m)), n = Math.max(1, Math.floor(t * l));
57
- for (; r.size < n; ) {
58
- const d = Math.floor(Math.random() * t);
59
- r.add(d);
53
+ async function Mt(n, x, o, l, c = 0.1, d) {
54
+ const r = n instanceof Uint16Array ? n : await y(n, x, void 0, d), i = r instanceof Uint16Array ? r : r.tokens, f = r instanceof Uint16Array ? void 0 : r.mask, m = /* @__PURE__ */ new Set();
55
+ if (c > 0) {
56
+ const t = Math.floor(i.length / (o.blockSize * a)), s = Math.max(1, Math.floor(t * c));
57
+ for (; m.size < s; ) {
58
+ const M = Math.floor(Math.random() * t);
59
+ m.add(M);
60
60
  }
61
61
  }
62
- const a = new Uint32Array(
63
- i.length - r.size * o.blockSize * m
64
- ), e = new Uint32Array(r.size * o.blockSize * m);
65
- let c = 0, f = 0;
62
+ const p = new Uint32Array(
63
+ i.length - m.size * o.blockSize * a
64
+ ), e = new Uint32Array(m.size * o.blockSize * a);
65
+ let h = 0, g = 0;
66
66
  for (let t = 0; t < i.length; t++) {
67
- const n = Math.floor(t / (o.blockSize * m));
68
- r.has(n) ? f < e.length && (e[f++] = t) : c < a.length && (a[c++] = t);
67
+ const s = Math.floor(t / (o.blockSize * a));
68
+ m.has(s) ? g < e.length && (e[g++] = t) : h < p.length && (p[h++] = t);
69
69
  }
70
- const { dataset: x, state: w } = await o.createTextDataset(
70
+ const { dataset: v, state: w } = await o.createTextDataset(
71
71
  i,
72
- s,
73
- h(a)
74
- ), { dataset: z, state: M } = await o.createTextDataset(
72
+ l,
73
+ k(p),
74
+ f || void 0
75
+ ), { dataset: z, state: A } = await o.createTextDataset(
75
76
  i,
76
- s,
77
- h(e)
77
+ l,
78
+ k(e)
78
79
  );
79
- return { trainDataset: x, validationDataset: z, size: i.length, validationState: M, trainState: w };
80
+ return { trainDataset: v, validationDataset: z, size: i.length, validationState: A, trainState: w };
80
81
  }
81
82
  export {
82
- dt as createTrainValidationSplit
83
+ Mt as createTrainValidationSplit
83
84
  };
@@ -1,5 +1,5 @@
1
- import { o as u, n as i, E as o, ao as $, ap as g, aq as m, v as l, t as x, ar as p } from "./index-DSGwv2Yx.js";
2
- import { c as k } from "./complex-3DpPEG9B.js";
1
+ import { o as u, q as i, E as o, ao as $, ap as g, aq as x, x as l, t as m, ar as p } from "./index-CUXkjxiT.js";
2
+ import { c as k } from "./complex-DI35Q-gW.js";
3
3
  function K(r) {
4
4
  const e = { input: i(r, "input", "imag") };
5
5
  return o.runKernel($, e);
@@ -12,25 +12,25 @@ function E(r) {
12
12
  const _ = /* @__PURE__ */ u({ neg_: E });
13
13
  function b(r) {
14
14
  const e = { input: i(r, "input", "real") };
15
- return o.runKernel(m, e);
15
+ return o.runKernel(x, e);
16
16
  }
17
17
  const d = /* @__PURE__ */ u({ real_: b });
18
- function v(r, t, e) {
18
+ function N(r, t, e) {
19
19
  const n = i(r, "x", "transpose");
20
20
  if (t == null && (t = n.shape.map((s, a) => a).reverse()), l(n.rank === t.length, () => `Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`), t.forEach((s) => {
21
21
  l(s >= 0 && s < n.rank, () => `All entries in 'perm' must be between 0 and ${n.rank - 1} but got ${t}`);
22
22
  }), n.rank <= 1)
23
23
  return n.clone();
24
24
  const f = { x: n }, c = { perm: t };
25
- return n.dtype === "complex64" ? x(() => {
25
+ return n.dtype === "complex64" ? m(() => {
26
26
  let s = d(n), a = h(n);
27
27
  return s = o.runKernel(p, { x: s }, c), a = o.runKernel(p, { x: a }, c), e && (a = _(a)), k(s, a);
28
28
  }) : o.runKernel(p, f, c);
29
29
  }
30
- const y = /* @__PURE__ */ u({ transpose_: v });
30
+ const v = /* @__PURE__ */ u({ transpose_: N });
31
31
  export {
32
32
  h as i,
33
33
  _ as n,
34
34
  d as r,
35
- y as t
35
+ v as t
36
36
  };
@@ -1,8 +1,8 @@
1
- import { o as h, n as c, E as d, bm as T, bn as q, bo as H, v as l, bp as P, J as _, bq as y, br as I, bs as W, bt as B, bu as A, bv as G, bw as L, bx as O, by as z, bz as F, z as M, _ as j, bA as J, bB as U, bC as V, a2 as Q, a1 as N, m as X, bD as Y, bE as Z, bF as R, bG as nn, bH as tn, bI as sn, bJ as en, bK as rn, bL as on, bM as an, bN as un, aE as cn, bO as ln } from "./index-DSGwv2Yx.js";
2
- import { k as C, c as g, m as D } from "./step-DQY6_ABw.js";
3
- import { r as b } from "./reshape-BIN71H3p.js";
4
- import { m as pn, b as hn, e as w } from "./not_equal-CkQKkKZy.js";
5
- import { s as K } from "./sum-D39FeU5h.js";
1
+ import { o as h, q as c, E as d, bm as T, bn as q, bo as H, x as l, bp as P, L as _, bq as y, br as B, bs as I, bt as W, bu as A, bv as L, bw as G, bx as O, by as z, bz as F, B as M, _ as j, bA as J, bB as U, bC as V, a2 as Q, a1 as N, m as X, bD as Y, bE as Z, bF as R, bG as nn, bH as tn, bI as sn, bJ as en, bK as rn, bL as on, bM as an, bN as un, aE as cn, bO as ln } from "./index-CUXkjxiT.js";
2
+ import { k as C, c as g, m as D } from "./step-BTxPtq1r.js";
3
+ import { r as b } from "./reshape-BDOuCSNW.js";
4
+ import { m as pn, b as hn, e as w } from "./not_equal-hurPF26l.js";
5
+ import { s as K } from "./sum-BpiwSWvg.js";
6
6
  function fn(s, n = null, t = !1) {
7
7
  const i = { x: c(s, "x", "all", "bool") }, o = { axis: n, keepDims: t };
8
8
  return d.runKernel(T, i, o);
@@ -37,7 +37,7 @@ function xn(s, n, t) {
37
37
  const e = c(s, "x", "batchToSpaceND"), i = n.reduce((r, a) => r * a);
38
38
  l(e.rank >= 1 + n.length, () => `input rank is ${e.rank} but should be > than blockShape.length ${n.length}`), l(t.length === n.length, () => `crops.length is ${t.length} but should be equal to blockShape.length ${n.length}`), l(e.shape[0] % i === 0, () => `input tensor batch is ${e.shape[0]} but is not divisible by the product of the elements of blockShape ${n.join(" * ")} === ${i}`);
39
39
  const o = { x: e }, p = { blockShape: n, crops: t };
40
- return d.runKernel(I, o, p);
40
+ return d.runKernel(B, o, p);
41
41
  }
42
42
  const ot = /* @__PURE__ */ h({ batchToSpaceND_: xn });
43
43
  function kn(s) {
@@ -57,7 +57,7 @@ function vn(s, n, t, e, i, o) {
57
57
  offset: m,
58
58
  mean: r,
59
59
  variance: a
60
- }, k = { varianceEpsilon: o }, $ = d.runKernel(W, x, k);
60
+ }, k = { varianceEpsilon: o }, $ = d.runKernel(I, x, k);
61
61
  return b($, p.shape);
62
62
  }
63
63
  const at = /* @__PURE__ */ h({ batchNorm_: vn });
@@ -67,7 +67,7 @@ function gn(s, n, t, e, i = "NHWC", o = [1, 1], p) {
67
67
  r.rank === 3 && (m = !0, u = b(r, [1, r.shape[0], r.shape[1], r.shape[2]])), l(u.rank === 4, () => `Error in conv2d: input must be rank 4, but got rank ${u.rank}.`), l(a.rank === 4, () => `Error in conv2d: filter must be rank 4, but got rank ${a.rank}.`), g("conv2d", e, p);
68
68
  const f = i === "NHWC" ? u.shape[3] : u.shape[1];
69
69
  l(f === a.shape[2], () => `Error in conv2d: depth of input (${f}) must match input depth for filter ${a.shape[2]}.`), l(C(t, o), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`), l(D(o), () => "Error in conv2D: Dilated rates should be larger than 0."), l(D(t), () => "Error in conv2D: Strides should be larger than 0.");
70
- const x = { x: u, filter: a }, k = { strides: t, pad: e, dataFormat: i, dilations: o, dimRoundingMode: p }, $ = d.runKernel(B, x, k);
70
+ const x = { x: u, filter: a }, k = { strides: t, pad: e, dataFormat: i, dilations: o, dimRoundingMode: p }, $ = d.runKernel(W, x, k);
71
71
  return m ? b($, [$.shape[1], $.shape[2], $.shape[3]]) : $;
72
72
  }
73
73
  const S = /* @__PURE__ */ h({ conv2d_: gn });
@@ -96,12 +96,12 @@ function Nn(s, n, t, e, i, o) {
96
96
  const ut = /* @__PURE__ */ h({ conv2dTranspose_: Nn });
97
97
  function _n(s) {
98
98
  const t = { x: c(s, "x", "cos", "float32") };
99
- return d.runKernel(G, t);
99
+ return d.runKernel(L, t);
100
100
  }
101
101
  const ct = /* @__PURE__ */ h({ cos_: _n });
102
102
  function wn(s) {
103
103
  const t = { x: c(s, "x", "cosh", "float32") };
104
- return d.runKernel(L, t);
104
+ return d.runKernel(G, t);
105
105
  }
106
106
  const lt = /* @__PURE__ */ h({ cosh_: wn });
107
107
  function Kn(s, n = 0, t = !1, e = !1) {
@@ -143,7 +143,7 @@ function yn(s) {
143
143
  return d.runKernel(V, t);
144
144
  }
145
145
  const mt = /* @__PURE__ */ h({ softplus_: yn });
146
- function In(s, n = -1) {
146
+ function Bn(s, n = -1) {
147
147
  const t = c(s, "logits", "logSoftmax");
148
148
  if (n === -1 && (n = t.rank - 1), n !== t.rank - 1)
149
149
  throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and axis was ${n}`);
@@ -155,20 +155,20 @@ function In(s, n = -1) {
155
155
  } };
156
156
  })(t);
157
157
  }
158
- const $t = /* @__PURE__ */ h({ logSoftmax_: In });
159
- function Wn(s) {
158
+ const $t = /* @__PURE__ */ h({ logSoftmax_: Bn });
159
+ function In(s) {
160
160
  const t = { x: c(s, "x", "logicalNot", "bool") };
161
161
  return d.runKernel(Y, t);
162
162
  }
163
- const bt = /* @__PURE__ */ h({ logicalNot_: Wn });
164
- function Bn(s, n, t, e, i) {
163
+ const bt = /* @__PURE__ */ h({ logicalNot_: In });
164
+ function Wn(s, n, t, e, i) {
165
165
  const o = c(s, "x", "maxPool"), p = 1;
166
166
  let r = o, a = !1;
167
167
  o.rank === 3 && (a = !0, r = b(o, [1, o.shape[0], o.shape[1], o.shape[2]])), l(r.rank === 4, () => `Error in maxPool: input must be rank 4 but got rank ${r.rank}.`), l(C(t, p), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${p}'`), g("maxPool", e, i);
168
168
  const u = { x: r }, m = { filterSize: n, strides: t, pad: e, dimRoundingMode: i }, f = d.runKernel(Z, u, m);
169
169
  return a ? b(f, [f.shape[1], f.shape[2], f.shape[3]]) : f;
170
170
  }
171
- const xt = /* @__PURE__ */ h({ maxPool_: Bn });
171
+ const xt = /* @__PURE__ */ h({ maxPool_: Wn });
172
172
  function An(s, n, t = 1, e = 0, i = "int32") {
173
173
  if (n < 2)
174
174
  throw new Error(`Error in oneHot: depth must be >=2, but it is ${n}`);
@@ -176,19 +176,19 @@ function An(s, n, t = 1, e = 0, i = "int32") {
176
176
  return d.runKernel(R, p, r);
177
177
  }
178
178
  const kt = /* @__PURE__ */ h({ oneHot_: An });
179
- function Gn(s) {
179
+ function Ln(s) {
180
180
  const t = { x: c(s, "x", "onesLike") };
181
181
  return d.runKernel(nn, t);
182
182
  }
183
- const vt = /* @__PURE__ */ h({ onesLike_: Gn });
184
- function Ln(s, n, t = 0) {
183
+ const vt = /* @__PURE__ */ h({ onesLike_: Ln });
184
+ function Gn(s, n, t = 0) {
185
185
  const e = c(s, "x", "pad");
186
186
  if (e.rank === 0)
187
187
  throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");
188
188
  const i = { paddings: n, constantValue: t }, o = { x: e };
189
189
  return d.runKernel(tn, o, i);
190
190
  }
191
- const gt = /* @__PURE__ */ h({ pad_: Ln });
191
+ const gt = /* @__PURE__ */ h({ pad_: Gn });
192
192
  function On(s, n, t) {
193
193
  const e = c(s, "x", "spaceToBatchND");
194
194
  l(e.rank >= 1 + n.length, () => `input rank ${e.rank} should be > than [blockShape] ${n.length}`), l(t.length === n.length, () => `paddings.shape[0] ${t.length} must be equal to [blockShape] ${n.length}`), l(e.shape.reduce((p, r, a) => a > 0 && a <= n.length ? p && (r + t[a - 1][0] + t[a - 1][1]) % n[a - 1] === 0 : p, !0), () => `input spatial dimensions ${e.shape.slice(1)} with paddings ${t.toString()} must be divisible by blockShapes ${n.toString()}`);