@genai-fi/nanogpt 0.19.1 → 0.20.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 (347) hide show
  1. package/dist/BaseTokeniser-DSg9zcYq.js +221 -0
  2. package/dist/DatasetBuilder-DgURD85T.js +712 -0
  3. package/dist/Generator.js +2 -11941
  4. package/dist/RealDiv-DBu0FQqT.js +362 -0
  5. package/dist/Reshape-CABOPB9d.js +94 -0
  6. package/dist/Reshape-DqO3r8BC.js +17 -0
  7. package/dist/TeachableLLM.d.ts +5 -5
  8. package/dist/TeachableLLM.js +2 -273
  9. package/dist/Trainer.js +2 -244
  10. package/dist/backend.js +12 -12
  11. package/dist/backend_util-Cg-roD1p.js +399 -0
  12. package/dist/binary_op_util-CrYk9LXL.js +103 -0
  13. package/dist/checks/appendCache.js +54 -21
  14. package/dist/checks/attentionMask.js +55 -36
  15. package/dist/checks/check.js +31 -19
  16. package/dist/checks/gelu.js +45 -17
  17. package/dist/checks/index.js +25 -25
  18. package/dist/checks/matMulGelu.js +83 -27
  19. package/dist/checks/normRMS.js +27 -15
  20. package/dist/checks/normRMSGrad.js +21 -11
  21. package/dist/checks/packUnpack.js +45 -17
  22. package/dist/checks/qkv.js +33 -33
  23. package/dist/checks/rope.js +29 -35
  24. package/dist/checks/weights.d.ts +1 -1
  25. package/dist/checks/weights.js +25 -29
  26. package/dist/chunk-BPntVaq0.js +23 -0
  27. package/dist/complex_util-CkazZsaH.js +60 -0
  28. package/dist/concat_util-CWDZCBlA.js +19 -0
  29. package/dist/data/docx.js +3044 -13
  30. package/dist/data/pdf.js +16 -13
  31. package/dist/data/textLoader.js +607 -112
  32. package/dist/dist-BewPQWjc.js +7572 -0
  33. package/dist/dist-DVmq73nz.js +8775 -0
  34. package/dist/dist-DXwIvKxl.js +896 -0
  35. package/dist/dist-VEU5mfO0.js +7545 -0
  36. package/dist/gelu-Bf1HW1RY.js +27 -0
  37. package/dist/gpgpu_math-DvLcCH6u.js +1612 -0
  38. package/dist/inference/types.js +0 -1
  39. package/dist/kernel_funcs_utils-HiXOOx3f.js +229 -0
  40. package/dist/layers/BaseLayer.d.ts +2 -2
  41. package/dist/layers/BaseLayer.js +75 -73
  42. package/dist/layers/CausalSelfAttention.d.ts +1 -1
  43. package/dist/layers/CausalSelfAttention.js +98 -85
  44. package/dist/layers/LoRA.js +47 -57
  45. package/dist/layers/MLP.d.ts +1 -1
  46. package/dist/layers/MLP.js +33 -43
  47. package/dist/layers/PositionEmbedding.d.ts +1 -1
  48. package/dist/layers/PositionEmbedding.js +26 -30
  49. package/dist/layers/RMSNorm.d.ts +1 -1
  50. package/dist/layers/RMSNorm.js +19 -21
  51. package/dist/layers/RoPECache.js +336 -49
  52. package/dist/layers/TiedEmbedding.d.ts +1 -1
  53. package/dist/layers/TiedEmbedding.js +30 -34
  54. package/dist/layers/TransformerBlock.d.ts +1 -1
  55. package/dist/layers/TransformerBlock.js +50 -39
  56. package/dist/layers/WeightStore.js +68 -75
  57. package/dist/loader/load.js +2 -68
  58. package/dist/loader/loadHF.d.ts +2 -2
  59. package/dist/loader/loadHF.js +2 -22
  60. package/dist/loader/loadTransformers.d.ts +1 -1
  61. package/dist/loader/loadTransformers.js +2 -44
  62. package/dist/loader/loadZipMeta.js +15 -15
  63. package/dist/loader/newZipLoad.js +2 -31
  64. package/dist/loader/oldZipLoad.d.ts +2 -2
  65. package/dist/loader/oldZipLoad.js +2 -80
  66. package/dist/loader/save.d.ts +5 -5
  67. package/dist/loader/save.js +2 -90
  68. package/dist/loader/types.d.ts +9 -8
  69. package/dist/loader/types.js +0 -1
  70. package/dist/main-CPjeMv0G.js +13500 -0
  71. package/dist/main.d.ts +1 -1
  72. package/dist/main.js +16 -109
  73. package/dist/matMul16-BNfZSnNM.js +81 -0
  74. package/dist/matMulGelu-CPTntosE.js +162 -0
  75. package/dist/models/NanoGPTV1.js +2 -99
  76. package/dist/models/NanoGPTV2.js +2 -90
  77. package/dist/models/config.js +34 -47
  78. package/dist/models/factory.d.ts +1 -1
  79. package/dist/models/factory.js +2 -16
  80. package/dist/models/model.d.ts +2 -2
  81. package/dist/models/model.js +2 -134
  82. package/dist/ops/adamAdjust.js +15 -6
  83. package/dist/ops/adamMoments.js +13 -6
  84. package/dist/ops/add16.js +9 -6
  85. package/dist/ops/appendCache.js +22 -19
  86. package/dist/ops/attentionMask.js +12 -6
  87. package/dist/ops/concat16.js +7 -8
  88. package/dist/ops/cpu/adamAdjust.js +15 -17
  89. package/dist/ops/cpu/adamMoments.js +15 -15
  90. package/dist/ops/cpu/appendCache.js +64 -22
  91. package/dist/ops/cpu/attentionMask.js +15 -21
  92. package/dist/ops/cpu/fusedSoftmax.js +21 -28
  93. package/dist/ops/cpu/gatherSub.js +11 -17
  94. package/dist/ops/cpu/gelu.js +34 -38
  95. package/dist/ops/cpu/matMul16.js +13 -14
  96. package/dist/ops/cpu/matMulGelu.js +39 -51
  97. package/dist/ops/cpu/matMulMul.js +19 -22
  98. package/dist/ops/cpu/mulDropout.js +19 -22
  99. package/dist/ops/cpu/normRMS.js +33 -37
  100. package/dist/ops/cpu/qkv.js +72 -40
  101. package/dist/ops/cpu/rope.js +79 -36
  102. package/dist/ops/cpu/scatterSub.js +11 -22
  103. package/dist/ops/dot16.js +28 -41
  104. package/dist/ops/dropout.js +10 -13
  105. package/dist/ops/dropout16.js +20 -23
  106. package/dist/ops/gatherSub.js +10 -6
  107. package/dist/ops/gelu.js +2 -8
  108. package/dist/ops/globalNorm.js +18 -12
  109. package/dist/ops/grads/add16.js +27 -26
  110. package/dist/ops/grads/attentionMask.js +26 -21
  111. package/dist/ops/grads/dropout16.js +0 -1
  112. package/dist/ops/grads/gelu.js +2 -5
  113. package/dist/ops/grads/matMul16.js +2 -9
  114. package/dist/ops/grads/matMulGelu.js +21 -16
  115. package/dist/ops/grads/mul16.js +0 -3
  116. package/dist/ops/grads/normRMS.js +34 -30
  117. package/dist/ops/grads/pack16.js +2 -6
  118. package/dist/ops/grads/qkv.js +44 -32
  119. package/dist/ops/grads/rope.js +2 -5
  120. package/dist/ops/grads/softmax16.js +21 -23
  121. package/dist/ops/grads/unpack16.js +2 -5
  122. package/dist/ops/grads/utils.js +9 -11
  123. package/dist/ops/matMul16.js +2 -13
  124. package/dist/ops/matMulGelu.js +16 -10
  125. package/dist/ops/matMulMul.js +13 -6
  126. package/dist/ops/mul16.js +42 -38
  127. package/dist/ops/mulDrop.js +12 -6
  128. package/dist/ops/normRMS.js +18 -15
  129. package/dist/ops/pack16.js +2 -5
  130. package/dist/ops/qkv.js +12 -6
  131. package/dist/ops/reshape16.js +31 -39
  132. package/dist/ops/rope.d.ts +1 -1
  133. package/dist/ops/rope.js +2 -7
  134. package/dist/ops/scatterSub.js +10 -6
  135. package/dist/ops/slice16.js +9 -7
  136. package/dist/ops/softmax16.js +7 -7
  137. package/dist/ops/sub16.js +9 -6
  138. package/dist/ops/sum16.js +12 -12
  139. package/dist/ops/transpose16.js +29 -37
  140. package/dist/ops/unpack16.js +2 -6
  141. package/dist/ops/webgl/adamAdjust.js +62 -29
  142. package/dist/ops/webgl/adamMoments.js +30 -26
  143. package/dist/ops/webgl/appendCache.js +30 -21
  144. package/dist/ops/webgl/attentionMask.js +43 -24
  145. package/dist/ops/webgl/dropout16.js +11 -10
  146. package/dist/ops/webgl/fusedSoftmax.js +69 -79
  147. package/dist/ops/webgl/gatherSub.js +27 -26
  148. package/dist/ops/webgl/gelu.js +32 -34
  149. package/dist/ops/webgl/log.js +14 -23
  150. package/dist/ops/webgl/matMul16.js +36 -44
  151. package/dist/ops/webgl/matMulGelu.js +2 -9
  152. package/dist/ops/webgl/matMulMul.js +23 -27
  153. package/dist/ops/webgl/mulDropout.js +31 -40
  154. package/dist/ops/webgl/normRMS.js +92 -71
  155. package/dist/ops/webgl/qkv.js +35 -27
  156. package/dist/ops/webgl/rope.js +37 -21
  157. package/dist/ops/webgl/scatterSub.js +27 -26
  158. package/dist/ops/webgpu/adamAdjust.js +59 -39
  159. package/dist/ops/webgpu/adamMoments.js +62 -46
  160. package/dist/ops/webgpu/add16.js +13 -12
  161. package/dist/ops/webgpu/appendCache.js +79 -54
  162. package/dist/ops/webgpu/attentionMask.js +41 -25
  163. package/dist/ops/webgpu/attentionMask32_program.js +34 -26
  164. package/dist/ops/webgpu/clipScale.js +44 -57
  165. package/dist/ops/webgpu/concat16.js +96 -111
  166. package/dist/ops/webgpu/dropout16.js +40 -32
  167. package/dist/ops/webgpu/gatherSub.js +43 -30
  168. package/dist/ops/webgpu/gelu.js +88 -82
  169. package/dist/ops/webgpu/index.js +16 -16
  170. package/dist/ops/webgpu/matMul16.js +69 -64
  171. package/dist/ops/webgpu/matMul16_program.js +152 -192
  172. package/dist/ops/webgpu/mul16.js +13 -12
  173. package/dist/ops/webgpu/norm2.js +45 -75
  174. package/dist/ops/webgpu/normRMS.js +25 -33
  175. package/dist/ops/webgpu/normRMS16_program.js +21 -18
  176. package/dist/ops/webgpu/normRMS32_program.js +21 -18
  177. package/dist/ops/webgpu/normRMSGrad.js +125 -184
  178. package/dist/ops/webgpu/pack16.js +20 -17
  179. package/dist/ops/webgpu/pack16_program.js +48 -47
  180. package/dist/ops/webgpu/qkv.js +63 -23
  181. package/dist/ops/webgpu/rope.js +85 -57
  182. package/dist/ops/webgpu/scatterSub.js +43 -30
  183. package/dist/ops/webgpu/slice16.js +66 -61
  184. package/dist/ops/webgpu/softmax16.js +17 -20
  185. package/dist/ops/webgpu/softmax16_program.js +34 -18
  186. package/dist/ops/webgpu/softmax16_subgroup_program.js +40 -45
  187. package/dist/ops/webgpu/softmax16grad.js +30 -36
  188. package/dist/ops/webgpu/sub16.js +13 -12
  189. package/dist/ops/webgpu/sum16.js +28 -37
  190. package/dist/ops/webgpu/transpose16.js +36 -33
  191. package/dist/ops/webgpu/transpose16_program.js +40 -39
  192. package/dist/ops/webgpu/transpose16_shared_program.js +53 -44
  193. package/dist/ops/webgpu/unpack16.js +49 -37
  194. package/dist/ops/webgpu/utils/binary_op.js +70 -68
  195. package/dist/ops/webgpu/utils/deviceInfo.d.ts +1 -1
  196. package/dist/ops/webgpu/utils/deviceInfo.js +10 -10
  197. package/dist/ops/webgpu/utils/reductions.js +136 -148
  198. package/dist/pack16-Ck-spx_F.js +39 -0
  199. package/dist/patches/webgpu_backend.d.ts +2 -2
  200. package/dist/patches/webgpu_backend.js +42 -55
  201. package/dist/patches/webgpu_base.js +21 -33
  202. package/dist/patches/webgpu_program.js +213 -320
  203. package/dist/pdf-UoDqCYzz.js +16726 -0
  204. package/dist/picomatch-3tUnMMbd.js +1063 -0
  205. package/dist/rope-CbeGlsV8.js +25 -0
  206. package/dist/selu_util-zkAx5doH.js +24 -0
  207. package/dist/shared-D1coEFea.js +1314 -0
  208. package/dist/shared-DOgWaqvL.js +5 -0
  209. package/dist/slice_util-Dgb3ANWI.js +208 -0
  210. package/dist/tfjs_backend-BjuQ5FqB.js +614 -0
  211. package/dist/tokeniser/BaseTokeniser.js +2 -124
  212. package/dist/tokeniser/CharTokeniser.js +91 -106
  213. package/dist/tokeniser/bpe.js +163 -166
  214. package/dist/tokeniser/messages.js +0 -1
  215. package/dist/tokeniser/type.js +0 -1
  216. package/dist/training/AdamW.js +127 -137
  217. package/dist/training/BasicTrainer.d.ts +1 -1
  218. package/dist/training/BasicTrainer.js +264 -264
  219. package/dist/training/DatasetBuilder.js +2 -86
  220. package/dist/training/Evaluator.d.ts +1 -1
  221. package/dist/training/Evaluator.js +47 -38
  222. package/dist/training/LRScheduler.js +37 -33
  223. package/dist/training/PreTrainer.d.ts +2 -2
  224. package/dist/training/PreTrainer.js +21 -19
  225. package/dist/training/SFTTrainer.d.ts +2 -2
  226. package/dist/training/SFTTrainer.js +23 -21
  227. package/dist/training/loss.js +17 -22
  228. package/dist/training/orthoGrad.js +9 -9
  229. package/dist/training/sparseCrossEntropy.js +45 -67
  230. package/dist/training/tasks/ConversationTask.d.ts +1 -1
  231. package/dist/training/tasks/ConversationTask.js +36 -38
  232. package/dist/training/tasks/PretrainingTask.d.ts +1 -1
  233. package/dist/training/tasks/PretrainingTask.js +41 -46
  234. package/dist/training/tasks/StartSentenceTask.d.ts +1 -1
  235. package/dist/training/tasks/StartSentenceTask.js +44 -48
  236. package/dist/training/tasks/Task.d.ts +1 -1
  237. package/dist/training/tasks/Task.js +53 -66
  238. package/dist/training/tasks/splitter.js +17 -20
  239. package/dist/training/types.d.ts +2 -2
  240. package/dist/training/types.js +0 -1
  241. package/dist/training/validation.d.ts +1 -1
  242. package/dist/training/validation.js +2 -84
  243. package/dist/utilities/arrayClose.js +15 -19
  244. package/dist/utilities/datasetID.js +17 -20
  245. package/dist/utilities/dummy.d.ts +1 -1
  246. package/dist/utilities/dummy.js +33 -40
  247. package/dist/utilities/multinomialCPU.js +8 -12
  248. package/dist/utilities/naming.js +0 -1
  249. package/dist/utilities/packed.js +10 -12
  250. package/dist/utilities/parameters.d.ts +1 -1
  251. package/dist/utilities/parameters.js +32 -51
  252. package/dist/utilities/performance.js +15 -15
  253. package/dist/utilities/profile.js +32 -37
  254. package/dist/utilities/safetensors.js +49 -79
  255. package/dist/utilities/sentences.d.ts +1 -1
  256. package/dist/utilities/sentences.js +29 -38
  257. package/dist/utilities/tokenParse.js +16 -20
  258. package/dist/utilities/topP.js +11 -12
  259. package/dist/utilities/waitForModel.d.ts +1 -1
  260. package/dist/utilities/waitForModel.js +11 -11
  261. package/dist/utilities/weights.js +37 -42
  262. package/dist/utilities/yielder.js +6 -6
  263. package/dist/webgpu-Dt7BMzWz.js +525 -0
  264. package/dist/webgpu_program-WOyIVMlZ.js +392 -0
  265. package/dist/webgpu_util-B_F3SShA.js +106 -0
  266. package/package.json +9 -10
  267. package/dist/RealDiv-CGwv0liw.js +0 -365
  268. package/dist/Reshape-BW__R4mZ.js +0 -79
  269. package/dist/Reshape-CPBkTIH2.js +0 -14
  270. package/dist/_commonjsHelpers-ByX85dGu.js +0 -33
  271. package/dist/axis_util-GTVlo58H.js +0 -55
  272. package/dist/backend_util-GaFarB78.js +0 -425
  273. package/dist/backend_webgpu-BqASlsbV.js +0 -545
  274. package/dist/binary_op_util-pKXltfxI.js +0 -192
  275. package/dist/broadcast_to-eS93CCN_.js +0 -28
  276. package/dist/clip_by_value-DDA7rrcT.js +0 -12
  277. package/dist/complex-DI35Q-gW.js +0 -11
  278. package/dist/complex_util-Yc1A_gV1.js +0 -55
  279. package/dist/concat-CAQpCret.js +0 -17
  280. package/dist/concat_util-D18dJ4fD.js +0 -22
  281. package/dist/data/parquet.d.ts +0 -2
  282. package/dist/data/parquet.js +0 -17
  283. package/dist/dataset-CGGp1z9P.js +0 -1124
  284. package/dist/dropout_util--NxWuYg2.js +0 -27
  285. package/dist/expand_dims-Bkd1YD5x.js +0 -11
  286. package/dist/exports_initializers-CYzKLjN7.js +0 -7
  287. package/dist/floor-BQtb-Azg.js +0 -9
  288. package/dist/gather-qIqEqaGn.js +0 -9
  289. package/dist/gelu-B220X1Go.js +0 -26
  290. package/dist/gpgpu_math-BwvV12df.js +0 -2022
  291. package/dist/index-CUXkjxiT.js +0 -3516
  292. package/dist/index-CieiGp4Y.js +0 -349
  293. package/dist/index-CjOWnMXP.js +0 -7308
  294. package/dist/index-Cp39cXWe.js +0 -1016
  295. package/dist/index-D5v913EJ.js +0 -4
  296. package/dist/index-DmeWGGmS.js +0 -1074
  297. package/dist/index-DvYrXKkX.js +0 -113
  298. package/dist/index-Ksja3su6.js +0 -151
  299. package/dist/index-xuotMAFm.js +0 -118
  300. package/dist/jszip.min-BZhlzntC.js +0 -2313
  301. package/dist/kernel_funcs_utils-pq0CK9co.js +0 -306
  302. package/dist/matMul16-BcVC_E62.js +0 -80
  303. package/dist/matMulGelu-JNLZqKQp.js +0 -163
  304. package/dist/mat_mul-DhG0Newp.js +0 -11
  305. package/dist/mod-CSdCpRjf.js +0 -11
  306. package/dist/non_max_suppression_impl-B2W7YjZB.js +0 -102
  307. package/dist/not_equal-hurPF26l.js +0 -64
  308. package/dist/ones-BytntneX.js +0 -14
  309. package/dist/ops-CsXeTq1P.js +0 -476
  310. package/dist/pack16-bqltoUlR.js +0 -39
  311. package/dist/papaparse.min-C0cScC2i.js +0 -418
  312. package/dist/parquet-Bqjmp2vo.js +0 -44231
  313. package/dist/pdf-NIhmP3sq.js +0 -19477
  314. package/dist/rand_util-CZ7yLoUm.js +0 -50
  315. package/dist/random_normal-IBRrha8a.js +0 -14
  316. package/dist/random_width-DN5ZtQkM.js +0 -9796
  317. package/dist/range-C-CjF-LI.js +0 -10
  318. package/dist/relu-J_X6MUzx.js +0 -9
  319. package/dist/reshape-BDOuCSNW.js +0 -9
  320. package/dist/resize_nearest_neighbor-BojqlfRe.js +0 -150
  321. package/dist/rope-DcrZM_e6.js +0 -24
  322. package/dist/scatter_nd_util-ByNJaL6I.js +0 -46
  323. package/dist/segment_util-Dasb2Zaf.js +0 -43
  324. package/dist/selu_util-BLhIqRkw.js +0 -44
  325. package/dist/shared-3agzAqQ_.js +0 -53
  326. package/dist/shared-CagdqkLh.js +0 -2143
  327. package/dist/slice-BzS11Qh0.js +0 -12
  328. package/dist/slice_util-CC35pLmT.js +0 -153
  329. package/dist/softmax-D4q1LJN7.js +0 -12
  330. package/dist/split-C2Sj255c.js +0 -9
  331. package/dist/squeeze-ho4wLUek.js +0 -10
  332. package/dist/stack-DudVrtmG.js +0 -11
  333. package/dist/step-BTxPtq1r.js +0 -261
  334. package/dist/sum-BpiwSWvg.js +0 -11
  335. package/dist/tensor-BWFldCso.js +0 -8
  336. package/dist/tensor1d-LMGMIUlr.js +0 -11
  337. package/dist/tensor2d-BnXMKScO.js +0 -14
  338. package/dist/tensor4d-C6UCG_u8.js +0 -14
  339. package/dist/tfjs_backend-BGnG-ppu.js +0 -654
  340. package/dist/tile-CFy-xTO6.js +0 -11
  341. package/dist/transpose-9kRxIXWR.js +0 -36
  342. package/dist/unsorted_segment_sum-DJvk5xnh.js +0 -277
  343. package/dist/variable-Ck482e3n.js +0 -7
  344. package/dist/webgpu_program-B4HmApL1.js +0 -525
  345. package/dist/webgpu_util-DYlGSwOJ.js +0 -64
  346. package/dist/zeros-DvZpK8s6.js +0 -13
  347. package/dist/zeros_like-CWjDdwr-.js +0 -721
@@ -1,64 +0,0 @@
1
- import { o as c, q as e, _ as h, E as u, aL as b, aM as E, aN as _, aO as g, ah as S, a1 as w, j as K, aP as q, B as M, aQ as T } from "./index-CUXkjxiT.js";
2
- import { b as d } from "./broadcast_to-eS93CCN_.js";
3
- import { e as N } from "./axis_util-GTVlo58H.js";
4
- import { r as f } from "./reshape-BDOuCSNW.js";
5
- import { s as A } from "./sum-BpiwSWvg.js";
6
- function B(s, o, n) {
7
- const a = e(o, "a", "where"), t = e(n, "b", "where"), r = e(s, "condition", "where", "bool"), p = h(h(r.shape, a.shape), t.shape), l = d(r, p), m = d(a, p), x = d(t, p), i = {
8
- condition: l,
9
- t: m,
10
- e: x
11
- };
12
- return u.runKernel(b, i);
13
- }
14
- const H = /* @__PURE__ */ c({ where_: B });
15
- function G(s, o = null, n = !1) {
16
- const t = { x: e(s, "x", "max") }, r = { reductionIndices: o, keepDims: n };
17
- return u.runKernel(E, t, r);
18
- }
19
- const I = /* @__PURE__ */ c({ max_: G });
20
- function L(s) {
21
- const n = { x: e(s, "x", "exp") };
22
- return u.runKernel(_, n);
23
- }
24
- const P = /* @__PURE__ */ c({ exp_: L });
25
- function j(s) {
26
- const n = { x: e(s, "x", "log", "float32") };
27
- return u.runKernel(g, n);
28
- }
29
- const k = /* @__PURE__ */ c({ log_: j });
30
- function v(s, o = null, n = !1) {
31
- const a = e(s, "x", "logSumExp"), t = S(o, a.shape), r = I(
32
- a,
33
- t,
34
- !0
35
- /* keepDims */
36
- ), p = w(a, r), l = P(p), m = A(l, t), x = k(m), i = K(f(r, x.shape), x);
37
- if (n) {
38
- const $ = N(i.shape, t);
39
- return f(i, $);
40
- }
41
- return i;
42
- }
43
- const J = /* @__PURE__ */ c({ logSumExp_: v });
44
- function y(s, o = null, n = !1) {
45
- const t = { x: e(s, "x", "mean") }, r = { axis: o, keepDims: n };
46
- return u.runKernel(q, t, r);
47
- }
48
- const R = /* @__PURE__ */ c({ mean_: y });
49
- function C(s, o) {
50
- let n = e(s, "a", "notEqual", "string_or_numeric"), a = e(o, "b", "notEqual", "string_or_numeric");
51
- [n, a] = M(n, a), h(n.shape, a.shape);
52
- const t = { a: n, b: a };
53
- return u.runKernel(T, t);
54
- }
55
- const U = /* @__PURE__ */ c({ notEqual_: C });
56
- export {
57
- R as a,
58
- k as b,
59
- P as e,
60
- J as l,
61
- I as m,
62
- U as n,
63
- H as w
64
- };
@@ -1,14 +0,0 @@
1
- import { u as n, V as t, U as m, E as i } from "./index-CUXkjxiT.js";
2
- import { c as f } from "./complex-DI35Q-gW.js";
3
- import { z as c } from "./zeros-DvZpK8s6.js";
4
- function l(o, r = "float32") {
5
- if (n(o), r === "complex64") {
6
- const s = l(o, "float32"), a = c(o, "float32");
7
- return f(s, a);
8
- }
9
- const e = t(m(o), r);
10
- return i.makeTensor(e, o, r);
11
- }
12
- export {
13
- l as o
14
- };
@@ -1,476 +0,0 @@
1
- import { o as h, q as u, x as p, E as k, bd as ds, be as hs, a5 as bs, bf as gs, bg as Es, L as W, bh as $s, bi as ys, bj as _s, bk as Ns, a as $, m as d, j as G, i as S, f as Ss, a1 as b, bl as ks, w as K, d as Is, a6 as L, a_ as ns, n as Ts, a2 as Ms } from "./index-CUXkjxiT.js";
2
- import { t as v } from "./tile-CFy-xTO6.js";
3
- import { e as R } from "./expand_dims-Bkd1YD5x.js";
4
- import { t as x } from "./tensor1d-LMGMIUlr.js";
5
- import { n as xs, a as As, b as ws } from "./non_max_suppression_impl-B2W7YjZB.js";
6
- import { r as Os, l as ls, g as es, a as rs, m as Q, b as Gs, c as Ls, u as us, n as ps, s as Bs, d as Ds, e as Ws, f as Rs } from "./resize_nearest_neighbor-BojqlfRe.js";
7
- import { s as ms } from "./split-C2Sj255c.js";
8
- import { s as _ } from "./sum-BpiwSWvg.js";
9
- import { w as q, a as qs, n as zs, b as as, e as ss, l as Vs } from "./not_equal-hurPF26l.js";
10
- import { s as T } from "./slice-BzS11Qh0.js";
11
- import { r as F } from "./range-C-CjF-LI.js";
12
- import { t as Cs } from "./tensor-BWFldCso.js";
13
- import { n as C, t as is } from "./transpose-9kRxIXWR.js";
14
- import { r as O } from "./reshape-BDOuCSNW.js";
15
- import { s as U } from "./stack-DudVrtmG.js";
16
- import { z as Ps } from "./zeros-DvZpK8s6.js";
17
- import { s as Ys } from "./squeeze-ho4wLUek.js";
18
- import { c as X } from "./concat-CAQpCret.js";
19
- import { m as w } from "./mat_mul-DhG0Newp.js";
20
- import { t as J } from "./tensor2d-BnXMKScO.js";
21
- import { o as js } from "./ones-BytntneX.js";
22
- import { r as fs } from "./relu-J_X6MUzx.js";
23
- import { e as vs } from "./axis_util-GTVlo58H.js";
24
- function Fs(t, a, n) {
25
- const r = u(t, "x", "bincount"), e = u(a, "weights", "bincount");
26
- p(r.dtype === "int32", () => `Error in bincount: input dtype must be int32, but got ${r.dtype}`), p(n >= 0, () => `size must be non-negative, but got ${n}.`), p(e.size === r.size || e.size === 0, () => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${e.shape}.`);
27
- const s = { x: r, weights: e }, o = { size: n };
28
- return k.runKernel(ds, s, o);
29
- }
30
- const Us = /* @__PURE__ */ h({ bincount_: Fs });
31
- function Zs(t, ...a) {
32
- const n = a.map((e, s) => u(e, `tensors${s}`, "einsum")), r = { equation: t };
33
- return k.runKernel(hs, n, r);
34
- }
35
- const V = /* @__PURE__ */ h({ einsum_: Zs });
36
- function Hs(t, a, n, r = "float32") {
37
- a == null && (a = t);
38
- const e = bs([t, a], r), s = t <= a ? t : a;
39
- for (let i = 0; i < s; ++i)
40
- e.set(1, i, i);
41
- const o = O(e.toTensor(), [t, a]);
42
- if (n == null)
43
- return o;
44
- if (n.length === 1)
45
- return v(R(o, 0), [n[0], 1, 1]);
46
- if (n.length === 2)
47
- return v(R(R(o, 0), 0), [n[0], n[1], 1, 1]);
48
- if (n.length === 3)
49
- return v(R(R(R(o, 0), 0), 0), [
50
- n[0],
51
- n[1],
52
- n[2],
53
- 1,
54
- 1
55
- ]);
56
- throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`);
57
- }
58
- const Ks = /* @__PURE__ */ h({ eye_: Hs });
59
- function Xs(t, a, n, r, e = "bilinear", s = 0) {
60
- const o = u(t, "image", "cropAndResize"), i = u(a, "boxes", "cropAndResize", "float32"), l = u(n, "boxInd", "cropAndResize", "int32"), c = i.shape[0];
61
- p(o.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`), p(i.rank === 2 && i.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${c},4] but had shape ${i.shape}.`), p(l.rank === 1 && l.shape[0] === c, () => `Error in cropAndResize: boxInd must be have size [${c}] but had shape ${i.shape}.`), p(r.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`), p(r[0] >= 1 && r[1] >= 1, () => `cropSize must be atleast [1,1], but was ${r}`), p(e === "bilinear" || e === "nearest", () => `method must be bilinear or nearest, but was ${e}`);
62
- const f = { image: o, boxes: i, boxInd: l }, m = { method: e, extrapolationValue: s, cropSize: r };
63
- return k.runKernel(gs, f, m);
64
- }
65
- const Js = /* @__PURE__ */ h({ cropAndResize_: Xs });
66
- function Qs(t) {
67
- const a = u(t, "image", "flipLeftRight", "float32");
68
- p(a.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${a.rank}.`);
69
- const n = { image: a };
70
- return k.runKernel(Es, n, {});
71
- }
72
- const sn = /* @__PURE__ */ h({ flipLeftRight_: Qs });
73
- function nn(t) {
74
- const a = u(t, "image", "grayscaleToRGB"), n = a.rank - 1, r = a.shape[n];
75
- p(a.rank >= 2, () => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${a.rank}.`), p(r === 1, () => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`);
76
- const e = new Array(a.rank);
77
- return e.fill(1, 0, n), e[n] = 3, v(a, e);
78
- }
79
- const en = /* @__PURE__ */ h({ grayscaleToRGB_: nn });
80
- function tn(t) {
81
- const a = u(t, "image", "RGBToGrayscale"), n = a.rank - 1, r = a.shape[n];
82
- p(a.rank >= 2, () => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${a.rank}.`), p(r === 3, () => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${r}.`);
83
- const e = a.dtype, s = W(a, "float32"), o = x([0.2989, 0.587, 0.114]);
84
- let i;
85
- switch (a.rank) {
86
- case 2:
87
- i = V("ij,j->i", s, o);
88
- break;
89
- case 3:
90
- i = V("ijk,k->ij", s, o);
91
- break;
92
- case 4:
93
- i = V("ijkl,l->ijk", s, o);
94
- break;
95
- case 5:
96
- i = V("ijklm,m->ijkl", s, o);
97
- break;
98
- case 6:
99
- i = V("ijklmn,n->ijklm", s, o);
100
- break;
101
- default:
102
- throw new Error("Not a valid tensor rank.");
103
- }
104
- return i = R(i, -1), W(i, e);
105
- }
106
- const on = /* @__PURE__ */ h({ rgbToGrayscale_: tn });
107
- function rn(t, a, n = 0, r = 0.5) {
108
- const e = u(t, "image", "rotateWithOffset", "float32");
109
- p(e.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${e.rank}.`);
110
- const s = { image: e }, o = { radians: a, fillValue: n, center: r };
111
- return k.runKernel($s, s, o);
112
- }
113
- const an = /* @__PURE__ */ h({ rotateWithOffset_: rn });
114
- function z(t, a, n, r, e, s) {
115
- r == null && (r = 0.5), e == null && (e = Number.NEGATIVE_INFINITY), s == null && (s = 0);
116
- const o = t.shape[0];
117
- return n = Math.min(n, o), p(0 <= r && r <= 1, () => `iouThreshold must be in [0, 1], but was '${r}'`), p(t.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${t.rank}'`), p(t.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${t.shape[1]}`), p(a.rank === 1, () => "scores must be a 1D tensor"), p(a.shape[0] === o, () => `scores has incompatible shape with boxes. Expected ${o}, but was ${a.shape[0]}`), p(0 <= s && s <= 1, () => `softNmsSigma must be in [0, 1], but was '${s}'`), { maxOutputSize: n, iouThreshold: r, scoreThreshold: e, softNmsSigma: s };
118
- }
119
- function cn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY) {
120
- const s = u(t, "boxes", "nonMaxSuppression", "float32"), o = u(a, "scores", "nonMaxSuppression", "float32"), i = z(s, o, n, r, e);
121
- n = i.maxOutputSize, r = i.iouThreshold, e = i.scoreThreshold;
122
- const l = { maxOutputSize: n, iouThreshold: r, scoreThreshold: e };
123
- return k.runKernel(ys, { boxes: s, scores: o }, l);
124
- }
125
- const ln = /* @__PURE__ */ h({ nonMaxSuppression_: cn });
126
- async function un(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY) {
127
- const s = u(t, "boxes", "nonMaxSuppressionAsync"), o = u(a, "scores", "nonMaxSuppressionAsync"), i = z(s, o, n, r, e);
128
- n = i.maxOutputSize, r = i.iouThreshold, e = i.scoreThreshold;
129
- const l = await Promise.all([s.data(), o.data()]), c = l[0], f = l[1], { selectedIndices: m } = xs(c, f, n, r, e);
130
- return s !== t && s.dispose(), o !== a && o.dispose(), x(m, "int32");
131
- }
132
- const pn = un;
133
- function mn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = 0) {
134
- const o = u(t, "boxes", "nonMaxSuppression"), i = u(a, "scores", "nonMaxSuppression"), l = z(o, i, n, r, e, s);
135
- n = l.maxOutputSize, r = l.iouThreshold, e = l.scoreThreshold, s = l.softNmsSigma;
136
- const c = { boxes: o, scores: i }, f = { maxOutputSize: n, iouThreshold: r, scoreThreshold: e, softNmsSigma: s }, m = k.runKernel(_s, c, f);
137
- return { selectedIndices: m[0], selectedScores: m[1] };
138
- }
139
- const fn = /* @__PURE__ */ h({ nonMaxSuppressionWithScore_: mn });
140
- async function dn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = 0) {
141
- const o = u(t, "boxes", "nonMaxSuppressionAsync"), i = u(a, "scores", "nonMaxSuppressionAsync"), l = z(o, i, n, r, e, s);
142
- n = l.maxOutputSize, r = l.iouThreshold, e = l.scoreThreshold, s = l.softNmsSigma;
143
- const c = await Promise.all([o.data(), i.data()]), f = c[0], m = c[1], { selectedIndices: E, selectedScores: g } = As(f, m, n, r, e, s);
144
- return o !== t && o.dispose(), i !== a && i.dispose(), {
145
- selectedIndices: x(E, "int32"),
146
- selectedScores: x(g)
147
- };
148
- }
149
- const hn = dn;
150
- function bn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = !1) {
151
- const o = u(t, "boxes", "nonMaxSuppression"), i = u(a, "scores", "nonMaxSuppression"), l = z(
152
- o,
153
- i,
154
- n,
155
- r,
156
- e,
157
- null
158
- /* softNmsSigma */
159
- ), c = l.maxOutputSize, f = l.iouThreshold, m = l.scoreThreshold, E = { boxes: o, scores: i }, g = {
160
- maxOutputSize: c,
161
- iouThreshold: f,
162
- scoreThreshold: m,
163
- padToMaxOutputSize: s
164
- }, y = k.runKernel(Ns, E, g);
165
- return { selectedIndices: y[0], validOutputs: y[1] };
166
- }
167
- const gn = /* @__PURE__ */ h({ nonMaxSuppressionPadded_: bn });
168
- async function En(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = !1) {
169
- const o = u(t, "boxes", "nonMaxSuppressionAsync"), i = u(a, "scores", "nonMaxSuppressionAsync"), l = z(
170
- o,
171
- i,
172
- n,
173
- r,
174
- e,
175
- null
176
- /* softNmsSigma */
177
- ), c = l.maxOutputSize, f = l.iouThreshold, m = l.scoreThreshold, [E, g] = await Promise.all([o.data(), i.data()]), { selectedIndices: y, validOutputs: M } = ws(E, g, c, f, m, s);
178
- return o !== t && o.dispose(), i !== a && i.dispose(), {
179
- selectedIndices: x(y, "int32"),
180
- validOutputs: $(M, "int32")
181
- };
182
- }
183
- const $n = En;
184
- function yn(t, a = "binary", n = !1, r = 0.5) {
185
- const e = u(t, "image", "threshold"), s = 0.2989, o = 0.587, i = 0.114, l = e.shape[0] * e.shape[1];
186
- let c = d(x([r]), 255), f, m, E, g;
187
- if (p(e.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${e.rank}.`), p(e.shape[2] === 3 || e.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${e.shape[2]}.`), p(e.dtype === "int32" || e.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${e.dtype}.`), p(a === "otsu" || a === "binary", () => `Method must be binary or otsu, but was ${a}`), e.shape[2] === 3) {
188
- [f, m, E] = ms(e, [1, 1, 1], -1);
189
- const I = d(f, s), A = d(m, o), D = d(E, i);
190
- g = G(G(I, A), D);
191
- } else
192
- g = t;
193
- if (a === "otsu") {
194
- const I = Us(W(Os(g), "int32"), Cs([]), 256);
195
- c = _n(I, l);
196
- }
197
- const y = n ? ls(g, c) : es(g, c);
198
- return W(d(y, 255), "int32");
199
- }
200
- function _n(t, a) {
201
- let n = x([-1]), r = x([0]), e = x([0]), s, o, i, l, c, f;
202
- for (let m = 0; m < t.size - 1; m++) {
203
- s = T(t, 0, m + 1), o = T(t, m + 1), c = S(_(s), a), f = S(_(o), a);
204
- const E = _(d(s, F(0, s.size)));
205
- i = S(E, _(s));
206
- const g = Ss(o.shape, s.size), y = G(F(0, o.size), g), M = d(o, y);
207
- l = S(_(M), _(o));
208
- const I = b(i, l), A = b(i, l), D = d(c, f);
209
- e = d(d(D, I), A);
210
- const P = es(e, r);
211
- r = q(P, e, r), n = q(P, x([m]), n);
212
- }
213
- return n;
214
- }
215
- const Nn = /* @__PURE__ */ h({ threshold_: yn });
216
- function Sn(t, a, n = "nearest", r = "constant", e = 0, s) {
217
- const o = u(t, "image", "transform", "float32"), i = u(a, "transforms", "transform", "float32");
218
- p(o.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${o.rank}.`), p(i.rank === 2 && (i.shape[0] === o.shape[0] || i.shape[0] === 1) && i.shape[1] === 8, () => "Error in transform: Input transform should be batch x 8 or 1 x 8"), p(s == null || s.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${s}.`);
219
- const l = { image: o, transforms: i }, c = { interpolation: n, fillMode: r, fillValue: e, outputShape: s };
220
- return k.runKernel(ks, l, c);
221
- }
222
- const kn = /* @__PURE__ */ h({ transform_: Sn });
223
- function In(t, a, n) {
224
- const r = u(t, "a", "bandPart");
225
- p(r.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${r.rank}.`);
226
- const e = r.shape, [s, o] = r.shape.slice(-2);
227
- let i, l;
228
- typeof a == "number" ? (p(a % 1 === 0, () => `bandPart(): numLower must be an integer, got ${a}.`), p(a <= s, () => `bandPart(): numLower (${a}) must not be greater than the number of rows (${s}).`), i = u(a < 0 ? s : a, "numLower", "bandPart")) : (p(a.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), i = q(rs(a, 0), s, Q(a, s))), typeof n == "number" ? (p(n % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${n}.`), p(n <= o, () => `bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`), l = u(n < 0 ? o : n, "numUpper", "bandPart")) : (p(n.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), l = q(rs(n, 0), o, Q(n, o)));
229
- const c = O(F(0, s, 1, "int32"), [-1, 1]), f = F(0, o, 1, "int32"), m = b(c, f), E = Gs(ls(m, i), Ls(m, C(l))), g = Ps([s, o], r.dtype);
230
- return O(U(us(O(r, [-1, s, o])).map((y) => q(E, y, g))), e);
231
- }
232
- const Tn = /* @__PURE__ */ h({ bandPart_: In });
233
- function Mn(t) {
234
- let a;
235
- if (Array.isArray(t)) {
236
- a = !1, p(t != null && t.length > 0, () => "Gram-Schmidt process: input must not be null, undefined, or empty");
237
- const e = t[0].shape[0];
238
- for (let s = 1; s < t.length; ++s)
239
- p(t[s].shape[0] === e, () => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${t[s].shape[0]} vs. ${e})`);
240
- } else
241
- a = !0, t = ms(t, t.shape[0], 0).map((e) => Ys(e, [0]));
242
- p(t.length <= t[0].shape[0], () => `Gram-Schmidt: Number of vectors (${t.length}) exceeds number of dimensions (${t[0].shape[0]}).`);
243
- const n = [], r = t;
244
- for (let e = 0; e < t.length; ++e)
245
- n.push(k.tidy(() => {
246
- let s = r[e];
247
- if (e > 0)
248
- for (let o = 0; o < e; ++o) {
249
- const i = d(_(d(n[o], s)), n[o]);
250
- s = b(s, i);
251
- }
252
- return S(s, ps(s, "euclidean"));
253
- }));
254
- return a ? U(n, 0) : n;
255
- }
256
- const xn = /* @__PURE__ */ h({ gramSchmidt_: Mn });
257
- function An(t, a = !1) {
258
- if (p(t.rank >= 2, () => `qr() requires input tensor to have a rank >= 2, but got rank ${t.rank}`), t.rank === 2)
259
- return cs(t, a);
260
- {
261
- const n = t.shape.slice(0, t.shape.length - 2).reduce((l, c) => l * c), r = us(O(t, [
262
- n,
263
- t.shape[t.shape.length - 2],
264
- t.shape[t.shape.length - 1]
265
- ]), 0), e = [], s = [];
266
- r.forEach((l) => {
267
- const [c, f] = cs(l, a);
268
- e.push(c), s.push(f);
269
- });
270
- const o = O(U(e, 0), t.shape), i = O(U(s, 0), t.shape);
271
- return [o, i];
272
- }
273
- }
274
- function cs(t, a = !1) {
275
- return k.tidy(() => {
276
- p(t.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${t.shape.length}D Tensor.`);
277
- const n = t.shape[0], r = t.shape[1];
278
- let e = Ks(n), s = K(t);
279
- const o = J([[1]], [1, 1]);
280
- let i = K(o);
281
- const l = n >= r ? r : n;
282
- for (let c = 0; c < l; ++c) {
283
- const f = s, m = i, E = e;
284
- [i, s, e] = k.tidy(() => {
285
- const g = T(s, [c, c], [n - c, 1]), y = ps(g), M = T(s, [c, c], [1, 1]), I = q(es(M, 0), J([[-1]]), J([[1]])), A = b(M, d(I, y)), D = S(g, A);
286
- D.shape[0] === 1 ? i = K(o) : i = X([
287
- o,
288
- T(D, [1, 0], [D.shape[0] - 1, D.shape[1]])
289
- ], 0);
290
- const P = C(S(w(I, A), y)), Y = T(s, [c, 0], [n - c, r]), Z = d(P, i), ts = is(i);
291
- if (c === 0)
292
- s = b(Y, w(Z, w(ts, Y)));
293
- else {
294
- const H = b(Y, w(Z, w(ts, Y)));
295
- s = X([T(s, [0, 0], [c, r]), H], 0);
296
- }
297
- const os = is(Z), j = T(e, [0, c], [n, e.shape[1] - c]);
298
- if (c === 0)
299
- e = b(j, w(w(j, i), os));
300
- else {
301
- const H = b(j, w(w(j, i), os));
302
- e = X([T(e, [0, 0], [n, c]), H], 1);
303
- }
304
- return [i, s, e];
305
- }), Is([f, m, E]);
306
- }
307
- return !a && n > r && (e = T(e, [0, 0], [n, r]), s = T(s, [0, 0], [r, r])), [e, s];
308
- });
309
- }
310
- const wn = /* @__PURE__ */ h({ qr_: An });
311
- var N;
312
- (function(t) {
313
- t[t.NONE = 0] = "NONE", t[t.MEAN = 1] = "MEAN", t[t.SUM = 2] = "SUM", t[t.SUM_BY_NONZERO_WEIGHTS = 3] = "SUM_BY_NONZERO_WEIGHTS";
314
- })(N || (N = {}));
315
- function On(t, a, n = N.SUM_BY_NONZERO_WEIGHTS) {
316
- const r = u(t, "losses", "computeWeightedLoss");
317
- let e = null;
318
- a != null && (e = u(a, "weights", "computeWeightedLoss"));
319
- const s = e == null ? r : d(r, e);
320
- if (n === N.NONE)
321
- return s;
322
- if (n === N.SUM)
323
- return _(s);
324
- if (n === N.MEAN) {
325
- if (e == null)
326
- return qs(s);
327
- {
328
- const o = r.size / e.size, i = S(_(s), _(e));
329
- return o > 1 ? S(i, $(o)) : i;
330
- }
331
- }
332
- if (n === N.SUM_BY_NONZERO_WEIGHTS) {
333
- if (e == null)
334
- return S(_(s), $(r.size));
335
- {
336
- const o = d(e, js(r.shape)), i = W(_(zs(o, $(0))), "float32");
337
- return S(_(s), i);
338
- }
339
- }
340
- throw Error(`Unknown reduction: ${n}`);
341
- }
342
- const B = /* @__PURE__ */ h({ computeWeightedLoss_: On });
343
- function Gn(t, a, n, r = N.SUM_BY_NONZERO_WEIGHTS) {
344
- const e = u(t, "labels", "absoluteDifference"), s = u(a, "predictions", "absoluteDifference");
345
- let o = null;
346
- n != null && (o = u(n, "weights", "absoluteDifference")), L(e.shape, s.shape, "Error in absoluteDifference: ");
347
- const i = ns(b(e, s));
348
- return B(i, o, r);
349
- }
350
- const Ln = /* @__PURE__ */ h({ absoluteDifference_: Gn });
351
- function Bn(t, a, n, r, e = N.SUM_BY_NONZERO_WEIGHTS) {
352
- const s = u(t, "labels", "cosineDistance"), o = u(a, "predictions", "cosineDistance");
353
- let i = null;
354
- r != null && (i = u(r, "weights", "cosineDistance")), L(s.shape, o.shape, "Error in cosineDistance: ");
355
- const l = $(1), c = b(l, _(d(s, o), n, !0));
356
- return B(c, i, e);
357
- }
358
- const Dn = /* @__PURE__ */ h({ cosineDistance_: Bn });
359
- function Wn(t, a, n, r = N.SUM_BY_NONZERO_WEIGHTS) {
360
- let e = u(t, "labels", "hingeLoss");
361
- const s = u(a, "predictions", "hingeLoss");
362
- let o = null;
363
- n != null && (o = u(n, "weights", "hingeLoss")), L(e.shape, s.shape, "Error in hingeLoss: ");
364
- const i = $(1);
365
- e = b(d($(2), e), i);
366
- const l = fs(b(i, d(e, s)));
367
- return B(l, o, r);
368
- }
369
- const Rn = /* @__PURE__ */ h({ hingeLoss_: Wn });
370
- function qn(t, a, n, r = 1, e = N.SUM_BY_NONZERO_WEIGHTS) {
371
- const s = u(t, "labels", "huberLoss"), o = u(a, "predictions", "huberLoss");
372
- let i = null;
373
- n != null && (i = u(n, "weights", "huberLoss")), L(s.shape, o.shape, "Error in huberLoss: ");
374
- const l = $(r), c = ns(b(o, s)), f = Q(c, l), m = b(c, f), E = G(d($(0.5), Ts(f)), d(l, m));
375
- return B(E, i, e);
376
- }
377
- const zn = /* @__PURE__ */ h({ huberLoss_: qn });
378
- function Vn(t, a, n, r = 1e-7, e = N.SUM_BY_NONZERO_WEIGHTS) {
379
- const s = u(t, "labels", "logLoss"), o = u(a, "predictions", "logLoss");
380
- let i = null;
381
- n != null && (i = u(n, "weights", "logLoss")), L(s.shape, o.shape, "Error in logLoss: ");
382
- const l = $(1), c = $(r), f = C(d(s, as(G(o, c)))), m = d(b(l, s), as(G(b(l, o), c))), E = b(f, m);
383
- return B(E, i, e);
384
- }
385
- const Cn = /* @__PURE__ */ h({ logLoss_: Vn });
386
- function Pn(t, a, n, r = N.SUM_BY_NONZERO_WEIGHTS) {
387
- const e = u(t, "labels", "meanSquaredError"), s = u(a, "predictions", "meanSquaredError");
388
- let o = null;
389
- n != null && (o = u(n, "weights", "meanSquaredError")), L(e.shape, s.shape, "Error in meanSquaredError: ");
390
- const i = Bs(e, s);
391
- return B(i, o, r);
392
- }
393
- const Yn = /* @__PURE__ */ h({ meanSquaredError_: Pn });
394
- function jn(t, a) {
395
- const n = u(t, "labels", "sigmoidCrossEntropyWithLogits"), r = u(a, "logits", "sigmoidCrossEntropyWithLogits");
396
- L(n.shape, r.shape, "Error in sigmoidCrossEntropyWithLogits: ");
397
- const e = fs(r), s = d(r, n), o = Ds(ss(C(ns(r))));
398
- return G(b(e, s), o);
399
- }
400
- function vn(t, a, n, r = 0, e = N.SUM_BY_NONZERO_WEIGHTS) {
401
- let s = u(t, "multiClassLabels", "sigmoidCrossEntropy");
402
- const o = u(a, "logits", "sigmoidCrossEntropy");
403
- let i = null;
404
- if (n != null && (i = u(n, "weights", "sigmoidCrossEntropy")), L(s.shape, o.shape, "Error in sigmoidCrossEntropy: "), r > 0) {
405
- const c = $(r), f = $(1), m = $(0.5);
406
- s = G(d(s, b(f, c)), d(m, c));
407
- }
408
- const l = jn(s, o);
409
- return B(l, i, e);
410
- }
411
- const Fn = /* @__PURE__ */ h({ sigmoidCrossEntropy_: vn });
412
- function Un(t, a, n = -1) {
413
- if (n === -1 && (n = a.rank - 1), n !== a.rank - 1)
414
- throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${a.rank} and dim was ${n}`);
415
- return Ms((e, s, o) => {
416
- const l = Vs(s, [n], !0), c = b(W(s, "float32"), l);
417
- o([e, c]);
418
- const f = C(d(c, e));
419
- return { value: _(f, [n]), gradFunc: (g, y) => {
420
- const [M, I] = y, A = vs(g.shape, [n]);
421
- return [
422
- d(O(g, A), b(W(M, "float32"), ss(I))),
423
- d(O(g, A), b(ss(I), W(M, "float32")))
424
- ];
425
- } };
426
- })(t, a);
427
- }
428
- function Zn(t, a, n, r = 0, e = N.SUM_BY_NONZERO_WEIGHTS) {
429
- let s = u(t, "onehotLabels", "softmaxCrossEntropy");
430
- const o = u(a, "logits", "softmaxCrossEntropy");
431
- let i = null;
432
- if (n != null && (i = u(n, "weights", "softmaxCrossEntropy")), L(s.shape, o.shape, "Error in softmaxCrossEntropy: "), r > 0) {
433
- const c = $(r), f = $(1), m = $(s.shape[1]);
434
- s = G(d(s, b(f, c)), S(c, m));
435
- }
436
- const l = Un(s, o);
437
- return B(l, i, e);
438
- }
439
- const Hn = /* @__PURE__ */ h({ softmaxCrossEntropy_: Zn });
440
- const $e = {
441
- flipLeftRight: sn,
442
- grayscaleToRGB: en,
443
- resizeNearestNeighbor: Ws,
444
- resizeBilinear: Rs,
445
- rgbToGrayscale: on,
446
- rotateWithOffset: an,
447
- cropAndResize: Js,
448
- nonMaxSuppression: ln,
449
- nonMaxSuppressionAsync: pn,
450
- nonMaxSuppressionWithScore: fn,
451
- nonMaxSuppressionWithScoreAsync: hn,
452
- nonMaxSuppressionPadded: gn,
453
- nonMaxSuppressionPaddedAsync: $n,
454
- threshold: Nn,
455
- transform: kn
456
- }, ye = {
457
- bandPart: Tn,
458
- gramSchmidt: xn,
459
- qr: wn
460
- }, _e = {
461
- absoluteDifference: Ln,
462
- computeWeightedLoss: B,
463
- cosineDistance: Dn,
464
- hingeLoss: Rn,
465
- huberLoss: zn,
466
- logLoss: Cn,
467
- meanSquaredError: Yn,
468
- sigmoidCrossEntropy: Fn,
469
- softmaxCrossEntropy: Hn
470
- };
471
- export {
472
- _e as a,
473
- Ks as e,
474
- $e as i,
475
- ye as l
476
- };
@@ -1,39 +0,0 @@
1
- import { e as o, h as i } from "./index-CUXkjxiT.js";
2
- import { isPackedTensor as t } from "./utilities/packed.js";
3
- import { s as u } from "./slice-BzS11Qh0.js";
4
- const s = {
5
- kernelName: "Unpack16",
6
- inputsToSave: [],
7
- outputsToSave: [],
8
- gradFunc: (n) => ({
9
- x: () => d(n)
10
- })
11
- };
12
- o(s);
13
- function p(n, a = 1, e = !1) {
14
- if (!t(n))
15
- return n;
16
- const r = i().runKernel("Unpack16", { x: n }, { scaling: a });
17
- return e && n.dispose(), r;
18
- }
19
- const c = {
20
- kernelName: "Pack16",
21
- inputsToSave: [],
22
- outputsToSave: [],
23
- gradFunc: (n, a, e) => ({
24
- x: () => {
25
- const r = p(n);
26
- return e.originalShape && e.padding && e.padding > 0 ? u(r, new Array(r.shape.length).fill(0), e.originalShape) : r;
27
- }
28
- })
29
- };
30
- o(c);
31
- function d(n, a = 1, e = 0) {
32
- return i().runKernel("Pack16", { x: n }, { scaling: a, padding: e });
33
- }
34
- export {
35
- s as a,
36
- c as b,
37
- d as p,
38
- p as u
39
- };