@genai-fi/nanogpt 0.10.1 → 0.10.3

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 (249) hide show
  1. package/dist/Generator.js +11761 -171
  2. package/dist/{RealDiv-DgA3z9oO.js → RealDiv-KAPDe8zB.js} +28 -30
  3. package/dist/Reshape-BYkmUnAv.js +14 -0
  4. package/dist/{Reshape-_kILl6tK.js → Reshape-Zt6eb7yh.js} +18 -20
  5. package/dist/TeachableLLM.js +10 -11
  6. package/dist/{axis_util-BvHEw88j.js → axis_util-BaG7mf5A.js} +3 -3
  7. package/dist/backend.js +2 -2
  8. package/dist/{backend_util-D-rUb2ty.js → backend_util-RCe-rHaj.js} +59 -60
  9. package/dist/{backend_webgpu-B0u2ndUn.js → backend_webgpu-DE3ACOLx.js} +45 -47
  10. package/dist/broadcast_to-B3eYlZm7.js +28 -0
  11. package/dist/checks/appendCache.js +2 -2
  12. package/dist/checks/attentionMask.js +3 -3
  13. package/dist/checks/gelu.js +2 -2
  14. package/dist/checks/matMulGelu.js +7 -11
  15. package/dist/checks/normRMS.js +9 -9
  16. package/dist/checks/normRMSGrad.js +3 -3
  17. package/dist/checks/packUnpack.js +2 -2
  18. package/dist/checks/qkv.js +12 -13
  19. package/dist/checks/rope.js +2 -2
  20. package/dist/clip_by_value-BnO7-a88.js +12 -0
  21. package/dist/complex-DjxcVmoX.js +11 -0
  22. package/dist/concat-BV8bt5H-.js +17 -0
  23. package/dist/{concat_util-DcJk7YHS.js → concat_util-DpW8mL_l.js} +1 -1
  24. package/dist/{dataset-0xP8GjwI.js → dataset-BcwmTGYc.js} +137 -139
  25. package/dist/dropout-BcvN9JYi.js +92 -0
  26. package/dist/expand_dims-DT4tEPwA.js +11 -0
  27. package/dist/{exports_initializers-xuidcwI4.js → exports_initializers-Hta_rEnm.js} +1 -1
  28. package/dist/floor-D5QdR_le.js +9 -0
  29. package/dist/gather-D3JcZUaI.js +9 -0
  30. package/dist/{gelu-CNLFZWea.js → gelu-CjNPL4OH.js} +10 -11
  31. package/dist/{gpgpu_math-DDVJCn6-.js → gpgpu_math-DAOmgtXR.js} +841 -1015
  32. package/dist/{index-CjOj7j-u.js → index-BwexR4lA.js} +262 -263
  33. package/dist/index-DOvlwCh-.js +3520 -0
  34. package/dist/{kernel_funcs_utils-Dg_-E44D.js → kernel_funcs_utils-CCzYdUZg.js} +129 -131
  35. package/dist/layers/BaseLayer.js +14 -15
  36. package/dist/layers/CausalSelfAttention.js +6 -6
  37. package/dist/layers/MLP.js +4 -4
  38. package/dist/layers/PositionEmbedding.js +7 -7
  39. package/dist/layers/RMSNorm.js +3 -3
  40. package/dist/layers/RoPECache.js +9 -9
  41. package/dist/layers/TiedEmbedding.js +6 -6
  42. package/dist/layers/TransformerBlock.js +1 -1
  43. package/dist/loader/loadTransformers.js +1 -1
  44. package/dist/loader/oldZipLoad.js +13 -14
  45. package/dist/log_sum_exp-ngO0-4pK.js +39 -0
  46. package/dist/main.js +49 -50
  47. package/dist/{matMul16--R5hOwDG.js → matMul16-BWRSOCWB.js} +14 -15
  48. package/dist/matMulGelu-CzfgT6Wq.js +163 -0
  49. package/dist/mat_mul-SjpJRLyL.js +11 -0
  50. package/dist/mod-AnXEvvpo.js +11 -0
  51. package/dist/models/NanoGPTV1.js +2 -2
  52. package/dist/models/model.js +13 -14
  53. package/dist/ones-D2rT0xk2.js +14 -0
  54. package/dist/ops/adamAdjust.js +1 -1
  55. package/dist/ops/adamMoments.js +1 -1
  56. package/dist/ops/add16.js +1 -1
  57. package/dist/ops/appendCache.js +3 -3
  58. package/dist/ops/attentionMask.js +1 -1
  59. package/dist/ops/concat16.js +2 -2
  60. package/dist/ops/cpu/adamAdjust.js +13 -14
  61. package/dist/ops/cpu/adamMoments.js +6 -7
  62. package/dist/ops/cpu/appendCache.js +7 -8
  63. package/dist/ops/cpu/attentionMask.js +7 -7
  64. package/dist/ops/cpu/fusedSoftmax.js +10 -11
  65. package/dist/ops/cpu/gatherSub.js +9 -10
  66. package/dist/ops/cpu/gelu.js +9 -10
  67. package/dist/ops/cpu/matMul16.js +6 -7
  68. package/dist/ops/cpu/matMulGelu.js +5 -6
  69. package/dist/ops/cpu/matMulMul.js +3 -4
  70. package/dist/ops/cpu/mulDropout.js +3 -4
  71. package/dist/ops/cpu/normRMS.js +10 -11
  72. package/dist/ops/cpu/qkv.js +8 -9
  73. package/dist/ops/cpu/rope.js +5 -6
  74. package/dist/ops/cpu/scatterSub.js +17 -19
  75. package/dist/ops/dot16.js +2 -2
  76. package/dist/ops/gatherSub.js +1 -1
  77. package/dist/ops/gelu.js +2 -2
  78. package/dist/ops/grads/add16.js +11 -12
  79. package/dist/ops/grads/attentionMask.js +5 -6
  80. package/dist/ops/grads/gelu.js +3 -4
  81. package/dist/ops/grads/matMul16.js +4 -5
  82. package/dist/ops/grads/matMulGelu.js +9 -10
  83. package/dist/ops/grads/normRMS.js +7 -8
  84. package/dist/ops/grads/pack16.js +4 -5
  85. package/dist/ops/grads/qkv.js +17 -19
  86. package/dist/ops/grads/rope.js +3 -5
  87. package/dist/ops/grads/softmax16.js +3 -4
  88. package/dist/ops/grads/unpack16.js +3 -4
  89. package/dist/ops/grads/utils.d.ts +1 -0
  90. package/dist/ops/grads/utils.js +8 -4
  91. package/dist/ops/matMul16.js +3 -3
  92. package/dist/ops/matMulGelu.js +2 -2
  93. package/dist/ops/matMulMul.js +1 -1
  94. package/dist/ops/mul16.js +1 -1
  95. package/dist/ops/mulDrop.js +1 -1
  96. package/dist/ops/normRMS.js +1 -1
  97. package/dist/ops/pack16.js +3 -4
  98. package/dist/ops/qkv.js +4 -8
  99. package/dist/ops/reshape16.js +14 -16
  100. package/dist/ops/rope.d.ts +1 -1
  101. package/dist/ops/rope.js +3 -8
  102. package/dist/ops/scatterSub.js +1 -1
  103. package/dist/ops/slice16.js +2 -2
  104. package/dist/ops/softmax16.js +5 -8
  105. package/dist/ops/sub16.js +1 -1
  106. package/dist/ops/sum16.js +2 -2
  107. package/dist/ops/transpose16.js +23 -24
  108. package/dist/ops/unpack16.js +2 -2
  109. package/dist/ops/webgl/adamAdjust.js +2 -3
  110. package/dist/ops/webgl/adamMoments.js +1 -2
  111. package/dist/ops/webgl/appendCache.js +1 -2
  112. package/dist/ops/webgl/attentionMask.js +4 -5
  113. package/dist/ops/webgl/fusedSoftmax.js +4 -6
  114. package/dist/ops/webgl/gatherSub.js +6 -7
  115. package/dist/ops/webgl/gelu.js +2 -3
  116. package/dist/ops/webgl/log.js +11 -12
  117. package/dist/ops/webgl/matMul16.js +10 -11
  118. package/dist/ops/webgl/matMulGelu.js +7 -111
  119. package/dist/ops/webgl/matMulMul.js +9 -10
  120. package/dist/ops/webgl/mulDropout.js +8 -9
  121. package/dist/ops/webgl/normRMS.js +2 -3
  122. package/dist/ops/webgl/qkv.js +5 -6
  123. package/dist/ops/webgl/rope.js +7 -8
  124. package/dist/ops/webgl/scatterSub.js +5 -6
  125. package/dist/ops/webgpu/adamAdjust.js +10 -12
  126. package/dist/ops/webgpu/adamMoments.js +8 -10
  127. package/dist/ops/webgpu/add16.js +8 -9
  128. package/dist/ops/webgpu/appendCache.js +23 -25
  129. package/dist/ops/webgpu/attentionMask.js +8 -10
  130. package/dist/ops/webgpu/attentionMask32_program.js +2 -2
  131. package/dist/ops/webgpu/concat16.js +12 -14
  132. package/dist/ops/webgpu/gatherSub.js +11 -13
  133. package/dist/ops/webgpu/gelu.js +28 -29
  134. package/dist/ops/webgpu/matMul16.js +26 -28
  135. package/dist/ops/webgpu/matMul16_program.js +4 -5
  136. package/dist/ops/webgpu/mul16.js +9 -10
  137. package/dist/ops/webgpu/normRMS.js +15 -17
  138. package/dist/ops/webgpu/normRMSGrad.js +21 -28
  139. package/dist/ops/webgpu/pack16.js +12 -13
  140. package/dist/ops/webgpu/pack16_program.js +2 -2
  141. package/dist/ops/webgpu/qkv.js +16 -18
  142. package/dist/ops/webgpu/rope.js +25 -27
  143. package/dist/ops/webgpu/scatterSub.js +7 -9
  144. package/dist/ops/webgpu/slice16.js +21 -23
  145. package/dist/ops/webgpu/softmax16.js +17 -19
  146. package/dist/ops/webgpu/softmax16_program.js +2 -2
  147. package/dist/ops/webgpu/softmax16_subgroup_program.js +2 -2
  148. package/dist/ops/webgpu/softmax16grad.js +7 -8
  149. package/dist/ops/webgpu/sub16.js +7 -8
  150. package/dist/ops/webgpu/sum16.js +18 -20
  151. package/dist/ops/webgpu/transpose16.js +19 -20
  152. package/dist/ops/webgpu/transpose16_program.js +2 -2
  153. package/dist/ops/webgpu/transpose16_shared_program.js +11 -12
  154. package/dist/ops/webgpu/unpack16.js +3 -4
  155. package/dist/ops/webgpu/utils/binary_op.js +7 -8
  156. package/dist/ops/webgpu/utils/reductions.js +14 -22
  157. package/dist/ops-B5yanEdW.js +476 -0
  158. package/dist/pack16-nQ6JaLo-.js +39 -0
  159. package/dist/patches/webgpu_backend.js +19 -20
  160. package/dist/patches/webgpu_base.js +1 -1
  161. package/dist/patches/webgpu_program.js +21 -22
  162. package/dist/{random_width-DY6Kk2Dl.js → random_width-or-CEftb.js} +2506 -2761
  163. package/dist/range-BklejeeW.js +10 -0
  164. package/dist/relu-CP0ZcxWO.js +9 -0
  165. package/dist/reshape-ByE68wS9.js +9 -0
  166. package/dist/resize_nearest_neighbor-B19mCEg2.js +175 -0
  167. package/dist/rope-Ir4mTyD1.js +24 -0
  168. package/dist/{scatter_nd_util-5EL-8VAQ.js → scatter_nd_util-lvSiX8q4.js} +1 -1
  169. package/dist/selu_util-kbhpTdYD.js +44 -0
  170. package/dist/{shared-BRksrJb3.js → shared-DT1TkE6w.js} +1 -1
  171. package/dist/{shared-BuAXb4CI.js → shared-dntlHIDQ.js} +343 -345
  172. package/dist/slice-BfEGSH82.js +12 -0
  173. package/dist/{slice_util-DtEldBfK.js → slice_util-uTKwiEpW.js} +1 -1
  174. package/dist/{softmax-ZHVebtR1.js → softmax-CA5jFsLR.js} +4 -5
  175. package/dist/split-CVLc0w--.js +9 -0
  176. package/dist/squeeze-C7Z2srUo.js +10 -0
  177. package/dist/stack-Cf4n9h0N.js +11 -0
  178. package/dist/step-CINUs5QB.js +261 -0
  179. package/dist/sum-DWAtNGez.js +11 -0
  180. package/dist/tensor-DJoc7gJU.js +8 -0
  181. package/dist/tensor1d-D11P_7Dp.js +11 -0
  182. package/dist/{tensor2d-G4Ys2GxX.js → tensor2d-Bs9wZRc7.js} +6 -7
  183. package/dist/{tensor4d-B8roDgtc.js → tensor4d-BARPdTaS.js} +6 -7
  184. package/dist/{tfjs_backend-kNyO5L2d.js → tfjs_backend-y1cvNhLA.js} +244 -253
  185. package/dist/tile-mbfagpsB.js +11 -0
  186. package/dist/training/Adam.js +2 -2
  187. package/dist/training/AdamExt.js +1 -1
  188. package/dist/training/DatasetBuilder.js +2 -2
  189. package/dist/training/FullTrainer.js +1 -1
  190. package/dist/training/Trainer.js +2 -2
  191. package/dist/training/sparseCrossEntropy.js +5 -5
  192. package/dist/transpose-ClWiBS_b.js +36 -0
  193. package/dist/unsorted_segment_sum-BDDhB_E6.js +277 -0
  194. package/dist/utilities/dummy.js +3 -3
  195. package/dist/utilities/multinomialCPU.js +2 -2
  196. package/dist/utilities/packed.d.ts +1 -4
  197. package/dist/utilities/packed.js +10 -711
  198. package/dist/utilities/performance.js +1 -1
  199. package/dist/utilities/profile.js +1 -1
  200. package/dist/utilities/safetensors.js +2 -2
  201. package/dist/utilities/sentences.js +5 -5
  202. package/dist/utilities/weights.js +2 -2
  203. package/dist/{variable-Bhn5bHYv.js → variable-WawDEaAb.js} +1 -1
  204. package/dist/{webgpu_program-Cigz-7RF.js → webgpu_program-DuOXPQol.js} +178 -172
  205. package/dist/{webgpu_util-BBCnKm2X.js → webgpu_util-RxEF33Rj.js} +34 -35
  206. package/dist/zeros-KnWaWf-X.js +13 -0
  207. package/dist/zeros_like-DvE73F4e.js +721 -0
  208. package/package.json +4 -2
  209. package/dist/Reshape-CF6odzV4.js +0 -16
  210. package/dist/broadcast_to-CwF7XIeu.js +0 -30
  211. package/dist/complex-CSlYz-2T.js +0 -13
  212. package/dist/concat-BHlIJeyT.js +0 -19
  213. package/dist/dropout-C1pM3f11.js +0 -99
  214. package/dist/expand_dims-BPG4fwBP.js +0 -13
  215. package/dist/gather-DykLGqmW.js +0 -10
  216. package/dist/index-ZyQhjEPo.js +0 -2157
  217. package/dist/log_sum_exp-DWI-76TI.js +0 -41
  218. package/dist/mat_mul-DeAh4uTH.js +0 -12
  219. package/dist/mod-Gt1rMB4n.js +0 -12
  220. package/dist/mulmat_packed_gpu-BMFhLwta.js +0 -55
  221. package/dist/ones-CAMiP4I2.js +0 -15
  222. package/dist/ops-CNI3TwqM.js +0 -645
  223. package/dist/pack16-CFUqumar.js +0 -41
  224. package/dist/patches/PackedTensor.d.ts +0 -12
  225. package/dist/patches/PackedTensor.js +0 -11
  226. package/dist/patches/engine.d.ts +0 -261
  227. package/dist/patches/engine.js +0 -10
  228. package/dist/patches/tape.d.ts +0 -12
  229. package/dist/patches/tape.js +0 -5
  230. package/dist/range-BMS52eQi.js +0 -11
  231. package/dist/reciprocal-CTmshQ9J.js +0 -10
  232. package/dist/register_all_kernels-Bwu1PTuU.js +0 -12307
  233. package/dist/relu-yZ2-7WxU.js +0 -10
  234. package/dist/reshape-DevtBWtf.js +0 -10
  235. package/dist/rope-B5UUMsPi.js +0 -32
  236. package/dist/selu_util-D1w6yyTO.js +0 -303
  237. package/dist/sin-BGfy2HZo.js +0 -16
  238. package/dist/slice-D_gkkqZK.js +0 -13
  239. package/dist/split-DrfihRpZ.js +0 -10
  240. package/dist/squeeze-DZEpeblb.js +0 -11
  241. package/dist/stack-yOIAalTq.js +0 -13
  242. package/dist/sum-_fzj5ZTB.js +0 -12
  243. package/dist/tensor-DdQUJZlz.js +0 -909
  244. package/dist/tensor-f35l8Odg.js +0 -8
  245. package/dist/tensor1d-CeZuc-Rv.js +0 -12
  246. package/dist/tensor_util-DV-FP5Q3.js +0 -523
  247. package/dist/tile-BzyEiF-F.js +0 -13
  248. package/dist/transpose-DKELTqhe.js +0 -38
  249. package/dist/zeros-2gldETuK.js +0 -14
@@ -1,12 +0,0 @@
1
- import { Rank } from '@tensorflow/tfjs-core/dist/types';
2
- import { Tensor, Variable } from '@tensorflow/tfjs-core/dist/tensor';
3
- import { TensorInfo } from '@tensorflow/tfjs-core/dist/tensor_info';
4
- export interface PackedTensorInfo extends TensorInfo {
5
- packed?: boolean;
6
- }
7
- export declare class PackableTensor<R extends Rank = Rank> extends Tensor<R> implements PackedTensorInfo {
8
- packed: boolean;
9
- }
10
- export declare class PackableVariable<R extends Rank = Rank> extends Variable<R> implements PackedTensorInfo {
11
- packed: boolean;
12
- }
@@ -1,11 +0,0 @@
1
- import { T as e, V as s } from "../tensor-DdQUJZlz.js";
2
- class r extends e {
3
- packed = !1;
4
- }
5
- class c extends s {
6
- packed = !1;
7
- }
8
- export {
9
- r as PackableTensor,
10
- c as PackableVariable
11
- };
@@ -1,261 +0,0 @@
1
- import { BackendTimingInfo, DataMover, KernelBackend } from '@tensorflow/tfjs-core/dist/backends/backend';
2
- import { Environment } from '@tensorflow/tfjs-core/dist/environment';
3
- import { NamedAttrMap } from '@tensorflow/tfjs-core/dist/kernel_registry';
4
- import { TensorInfo, DataId } from '@tensorflow/tfjs-core/dist/tensor_info';
5
- import { TapeNode } from '@tensorflow/tfjs-core/dist/tape';
6
- import { DataToGPUOptions, GPUData, Tensor, TensorTracker, Variable } from '@tensorflow/tfjs-core/dist/tensor';
7
- import { GradSaveFunc, NamedTensorMap, NamedVariableMap, TensorContainer } from '@tensorflow/tfjs-core/dist/tensor_types';
8
- import { BackendValues, DataType, DataValues } from '@tensorflow/tfjs-core/dist/types';
9
- /**
10
- * A function that computes an output. The save function is for saving tensors
11
- * computed in the forward pass, that we need in the backward pass.
12
- */
13
- export type ForwardFunc<T> = (backend: KernelBackend, save?: GradSaveFunc) => T;
14
- /**
15
- * @docalias (a: Tensor, b: Tensor,..., save?: Function) => {
16
- * value: Tensor,
17
- * gradFunc: (dy: Tensor, saved?: NamedTensorMap) => Tensor | Tensor[]
18
- * }
19
- */
20
- export type CustomGradientFunc<T extends Tensor> = (...inputs: Array<Tensor | GradSaveFunc>) => {
21
- value: T;
22
- gradFunc: (dy: T, saved: Tensor[]) => Tensor | Tensor[];
23
- };
24
- export type MemoryInfo = {
25
- numTensors: number;
26
- numDataBuffers: number;
27
- numBytes: number;
28
- unreliable?: boolean;
29
- reasons: string[];
30
- };
31
- type KernelInfo = {
32
- name: string;
33
- bytesAdded: number;
34
- totalBytesSnapshot: number;
35
- tensorsAdded: number;
36
- totalTensorsSnapshot: number;
37
- inputShapes: number[][];
38
- outputShapes: number[][];
39
- kernelTimeMs: number | {
40
- error: string;
41
- } | Promise<number | {
42
- error: string;
43
- }>;
44
- extraInfo: string | Promise<string>;
45
- };
46
- export type ProfileInfo = {
47
- newBytes: number;
48
- newTensors: number;
49
- peakBytes: number;
50
- kernels: KernelInfo[];
51
- result: TensorContainer;
52
- kernelNames: string[];
53
- };
54
- export interface TimingInfo extends BackendTimingInfo {
55
- wallMs: number;
56
- }
57
- /** @docalias Function */
58
- export type ScopeFn<T extends TensorContainer> = () => T;
59
- interface ScopeState {
60
- track: Tensor[];
61
- name: string;
62
- id: number;
63
- }
64
- declare class EngineState {
65
- registeredVariables: NamedVariableMap;
66
- nextTapeNodeId: number;
67
- numBytes: number;
68
- numTensors: number;
69
- numStringTensors: number;
70
- numDataBuffers: number;
71
- activeTape: TapeNode[];
72
- gradientDepth: number;
73
- kernelDepth: number;
74
- activeScope: ScopeState;
75
- scopeStack: ScopeState[];
76
- /**
77
- * Keeps track of the number of data moves during a kernel execution. We
78
- * maintain a stack since kernels can call other kernels, recursively.
79
- */
80
- numDataMovesStack: number[];
81
- nextScopeId: number;
82
- tensorInfo: WeakMap<object, {
83
- backend: KernelBackend;
84
- bytes: number;
85
- dtype: DataType;
86
- shape: number[];
87
- }>;
88
- profiling: boolean;
89
- activeProfile: ProfileInfo;
90
- dispose(): void;
91
- }
92
- export declare class Engine implements TensorTracker, DataMover {
93
- ENV: Environment;
94
- version: string;
95
- state: EngineState;
96
- backendName: string;
97
- registry: {
98
- [id: string]: KernelBackend;
99
- };
100
- registryFactory: {
101
- [id: string]: {
102
- factory: () => KernelBackend | Promise<KernelBackend>;
103
- priority: number;
104
- };
105
- };
106
- private profiler;
107
- private backendInstance;
108
- private pendingBackendInit;
109
- private pendingBackendInitId;
110
- constructor(ENV: Environment);
111
- ready(): Promise<void>;
112
- get backend(): KernelBackend;
113
- backendNames(): string[];
114
- findBackend(backendName: string): KernelBackend;
115
- findBackendFactory(backendName: string): () => KernelBackend | Promise<KernelBackend>;
116
- registerBackend(backendName: string, factory: () => KernelBackend | Promise<KernelBackend>, priority?: number): boolean;
117
- setBackend(backendName: string): Promise<boolean>;
118
- private setupRegisteredKernels;
119
- private disposeRegisteredKernels;
120
- /**
121
- * Initializes a backend by looking up the backend name in the factory
122
- * registry and calling the factory method. Returns a boolean representing
123
- * whether the initialization of the backend succeeded. Throws an error if
124
- * there is no backend in the factory registry.
125
- */
126
- private initializeBackend;
127
- removeBackend(backendName: string): void;
128
- private getSortedBackends;
129
- private initializeBackendsAndReturnBest;
130
- moveData(backend: KernelBackend, dataId: DataId): void;
131
- tidy<T extends TensorContainer>(nameOrFn: string | ScopeFn<T>, fn?: ScopeFn<T>): T;
132
- private scopedRun;
133
- private static nextTensorId;
134
- private nextTensorId;
135
- private static nextVariableId;
136
- private nextVariableId;
137
- /**
138
- * This method is called instead of the public-facing tensor.clone() when
139
- * saving a tensor for backwards pass. It makes sure to add the clone
140
- * operation to the tape regardless of being called inside a kernel
141
- * execution.
142
- */
143
- private clone;
144
- /**
145
- * Execute a kernel with the given name and return the output tensor.
146
- *
147
- * @param kernelName The name of the kernel to execute.
148
- * @param inputs A map of input names to tensors.
149
- * @param attrs A map of attribute names to their values. An attribute is a
150
- * primitive (non-tensor) input to the kernel.
151
- * @param inputsToSave A list of tensors, inputs to save for the backprop
152
- * computation.
153
- * @param outputsToSave A list of booleans, specifying which output to save
154
- * for the backprop computation. These are booleans since the output
155
- * tensors are not visible to the user.
156
- */
157
- runKernel<T extends Tensor | Tensor[]>(kernelName: string, inputs: NamedTensorMap, attrs?: NamedAttrMap): T;
158
- private shouldCheckForMemLeaks;
159
- private checkKernelForMemLeak;
160
- /**
161
- * Internal helper method to execute a kernel Func
162
- *
163
- * Use `runKernel` to execute kernels from outside of engine.
164
- */
165
- private runKernelFunc;
166
- /**
167
- * Saves tensors used in forward mode for use in backward mode.
168
- *
169
- * @param tensors the list of tensors to save.
170
- */
171
- private saveTensorsForBackwardMode;
172
- /**
173
- * Returns a list of tensors to save for a given gradient calculation.
174
- *
175
- * @param kernelName name of kernel to look up gradient for.
176
- * @param inputs a map of input tensors.
177
- * @param outputs an array of output tensors from forward mode of kernel.
178
- */
179
- private getTensorsForGradient;
180
- /**
181
- * Internal method used by public APIs for tensor creation. Makes a new
182
- * tensor with the provided shape, dtype and values. It always
183
- * creates a new data id and writes the values to the underlying backend.
184
- */
185
- makeTensor(values: DataValues, shape: number[], dtype: DataType, backend?: KernelBackend): Tensor;
186
- /**
187
- * Internal method used by backends. Makes a new tensor
188
- * that is a wrapper around an existing data id. It doesn't create
189
- * a new data id, only increments the ref count used in memory tracking.
190
- * @deprecated
191
- */
192
- makeTensorFromDataId(dataId: DataId, shape: number[], dtype: DataType, backend?: KernelBackend): Tensor;
193
- /**
194
- * Internal method used by backends. Makes a new tensor that is a wrapper
195
- * around an existing data id in TensorInfo. It doesn't create a new data id,
196
- * only increments the ref count used in memory tracking.
197
- */
198
- makeTensorFromTensorInfo(tensorInfo: TensorInfo, backend?: KernelBackend): Tensor;
199
- makeVariable(initialValue: Tensor, trainable?: boolean, name?: string, dtype?: DataType): Variable;
200
- trackTensor(a: Tensor, backend: KernelBackend): void;
201
- incRef(a: Tensor, backend: KernelBackend): void;
202
- removeDataId(dataId: DataId, backend: KernelBackend): void;
203
- disposeTensor(a: Tensor): void;
204
- disposeVariables(): void;
205
- disposeVariable(v: Variable): void;
206
- memory(): MemoryInfo;
207
- profile(query: () => TensorContainer | Promise<TensorContainer>): Promise<ProfileInfo>;
208
- isTapeOn(): boolean;
209
- private addTapeNode;
210
- keep<T extends Tensor>(result: T): T;
211
- private startTape;
212
- private endTape;
213
- /**
214
- * Start a scope. Use this with endScope() to achieve the same functionality
215
- * as scope() without the need for a function closure.
216
- */
217
- startScope(name?: string): void;
218
- /**
219
- * End a scope. Use this with startScope() to achieve the same functionality
220
- * as scope() without the need for a function closure.
221
- */
222
- endScope(result?: TensorContainer): void;
223
- /**
224
- * Returns gradients of `f` with respect to each of the `xs`. The gradients
225
- * returned are of the same length as `xs`, but some might be null if `f`
226
- * was not a function of that `x`. It also takes optional dy to multiply the
227
- * gradient, which defaults to `1`.
228
- */
229
- gradients<T extends Tensor>(f: () => T, xs: Tensor[], dy?: T, allowNoGradients?: boolean): {
230
- value: T;
231
- grads: Tensor[];
232
- };
233
- customGrad<T extends Tensor>(f: CustomGradientFunc<T>): (...args: Array<Tensor>) => T;
234
- readSync(dataId: DataId): BackendValues;
235
- read(dataId: DataId): Promise<BackendValues>;
236
- readToGPU(dataId: DataId, options?: DataToGPUOptions): GPUData;
237
- time(query: () => void): Promise<TimingInfo>;
238
- /**
239
- * Tracks a Tensor in the current scope to be automatically cleaned up
240
- * when the current scope ends, and returns the value.
241
- *
242
- * @param result The Tensor to track in the current scope.
243
- */
244
- private track;
245
- get registeredVariables(): NamedVariableMap;
246
- /**
247
- * Resets the engine state. Removes all backends but does not remove
248
- * registered backend factories.
249
- */
250
- reset(): void;
251
- }
252
- export declare function getOrMakeEngine(): Engine;
253
- export declare const ENGINE: Engine;
254
- /**
255
- * A implementation of the add op for use within engine and tape.
256
- *
257
- * This allows us to avoid a circular dependency between add.ts and engine.
258
- * It is exported to be available in tape tests.
259
- */
260
- export declare function add(a: Tensor, b: Tensor): Tensor;
261
- export {};
@@ -1,10 +0,0 @@
1
- import "../tensor_util-DV-FP5Q3.js";
2
- import "../tensor-DdQUJZlz.js";
3
- import "./PackedTensor.js";
4
- import { a as t, E, c as g, g as m } from "../utilities/packed.js";
5
- export {
6
- t as ENGINE,
7
- E as Engine,
8
- g as add,
9
- m as getOrMakeEngine
10
- };
@@ -1,12 +0,0 @@
1
- import { Tensor } from '@tensorflow/tfjs-core/dist/tensor';
2
- import { TapeNode } from '@tensorflow/tfjs-core/dist/tape';
3
- /**
4
- * Backpropagate gradients through the filtered TapeNodes.
5
- *
6
- * @param tensorAccumulatedGradientMap A map of Tensor to its gradient. This map
7
- * is mutated by this method.
8
- * @param filteredTape The filtered TapeNodes to backprop through.
9
- */
10
- export declare function backpropagateGradients(tensorAccumulatedGradientMap: {
11
- [tensorId: number]: Tensor;
12
- }, filteredTape: TapeNode[], tidy: (f: Function) => Tensor, add: (a: Tensor, b: Tensor) => Tensor): void;
@@ -1,5 +0,0 @@
1
- import { b as p } from "../utilities/packed.js";
2
- import "../tensor-DdQUJZlz.js";
3
- export {
4
- p as backpropagateGradients
5
- };
@@ -1,11 +0,0 @@
1
- import { E as e } from "./index-ZyQhjEPo.js";
2
- import { R as f } from "./tensor_util-DV-FP5Q3.js";
3
- function m(o, n, r = 1, t = "float32") {
4
- if (r === 0)
5
- throw new Error("Cannot have a step of zero");
6
- const a = { start: o, stop: n, step: r, dtype: t };
7
- return e.runKernel(f, {}, a);
8
- }
9
- export {
10
- m as r
11
- };
@@ -1,10 +0,0 @@
1
- import { A as c, B as n, E as e } from "./index-ZyQhjEPo.js";
2
- import { d as s } from "./tensor_util-DV-FP5Q3.js";
3
- function t(r) {
4
- const o = { x: n(r, "x", "reciprocal") };
5
- return e.runKernel(s, o);
6
- }
7
- const l = /* @__PURE__ */ c({ reciprocal_: t });
8
- export {
9
- l as r
10
- };