@genai-fi/nanogpt 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { gatherSub as w } from "../ops/gatherSub.js";
2
2
  import { scatterSub as K } from "../ops/scatterSub.js";
3
- import { o as l, c as d, E as f, M as _, q as z, L as I, t as N, a as E, u as M, v as T, e as m, w as g, x as $, z as S } from "../index-DQfEAU9u.js";
4
- import { s as F, r as b } from "../sum-B-O33dgG.js";
3
+ import { o as l, d, E as f, M as _, u as z, L as I, v as N, b as E, w as M, x as T, e as m, y as g, z as $, D as S } from "../index-CWQLouWz.js";
4
+ import { s as D, r as b } from "../sum-CnIf1YOh.js";
5
5
  /**
6
6
  * @license
7
7
  * Copyright 2017 Google LLC. All Rights Reserved.
@@ -18,16 +18,16 @@ import { s as F, r as b } from "../sum-B-O33dgG.js";
18
18
  * limitations under the License.
19
19
  * =============================================================================
20
20
  */
21
- function P(n, s, t) {
21
+ function F(n, s, t) {
22
22
  const a = n.length + s.length, e = [];
23
23
  let r = 0, c = 0;
24
24
  for (let o = 0; o < a; o++)
25
25
  t.indexOf(o) === -1 ? e.push(n[r++]) : e.push(s[c++]);
26
26
  return e;
27
27
  }
28
- function q(n, s) {
28
+ function P(n, s) {
29
29
  const t = s.map((a) => 1);
30
- return P(n, t, s);
30
+ return F(n, t, s);
31
31
  }
32
32
  /**
33
33
  * @license
@@ -66,11 +66,11 @@ const L = /* @__PURE__ */ l({ max_: A });
66
66
  * limitations under the License.
67
67
  * =============================================================================
68
68
  */
69
- function D(n) {
69
+ function O(n) {
70
70
  const t = { x: d(n, "x", "exp") };
71
71
  return f.runKernel(z, t);
72
72
  }
73
- const O = /* @__PURE__ */ l({ exp_: D });
73
+ const W = /* @__PURE__ */ l({ exp_: O });
74
74
  /**
75
75
  * @license
76
76
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -87,11 +87,11 @@ const O = /* @__PURE__ */ l({ exp_: D });
87
87
  * limitations under the License.
88
88
  * =============================================================================
89
89
  */
90
- function W(n) {
90
+ function j(n) {
91
91
  const t = { x: d(n, "x", "log", "float32") };
92
92
  return f.runKernel(I, t);
93
93
  }
94
- const j = /* @__PURE__ */ l({ log_: W });
94
+ const q = /* @__PURE__ */ l({ log_: j });
95
95
  /**
96
96
  * @license
97
97
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -114,9 +114,9 @@ function B(n, s = null, t = !1) {
114
114
  e,
115
115
  !0
116
116
  /* keepDims */
117
- ), c = E(a, r), o = O(c), p = F(o, e), u = j(p), i = M(b(r, u.shape), u);
117
+ ), c = E(a, r), o = W(c), p = D(o, e), u = q(p), i = M(b(r, u.shape), u);
118
118
  if (t) {
119
- const h = q(i.shape, e);
119
+ const h = P(i.shape, e);
120
120
  return b(i, h);
121
121
  }
122
122
  return i;
@@ -165,7 +165,7 @@ function ss() {
165
165
  (s, t, a) => {
166
166
  const e = s.shape[s.shape.length - 1], c = s.shape.slice(0, -1).reduce((h, x) => h * x, 1), o = s.reshape([c, e]), p = t.reshape([c]).cast("int32"), u = R(o, p);
167
167
  return a([o, p]), o.dispose(), p.dispose(), { value: u, gradFunc: (h, x) => $(() => {
168
- const k = x[0], y = x[1], C = Q(k), G = K(C, y, h), v = S(t);
168
+ const y = x[0], k = x[1], C = Q(y), G = K(C, k, h), v = S(t);
169
169
  return [G.reshape(s.shape), v];
170
170
  }) };
171
171
  }
@@ -0,0 +1,10 @@
1
+ export default class MemoryProfiler {
2
+ private log;
3
+ private maxMemory;
4
+ private maxLabel?;
5
+ private lastMemInfo;
6
+ private peakMemory;
7
+ startMemory(): void;
8
+ endMemory(label: string): void;
9
+ printSummary(): void;
10
+ }
@@ -0,0 +1,29 @@
1
+ import { m as s } from "../index-CWQLouWz.js";
2
+ const m = 1024 * 1024;
3
+ class i {
4
+ log = /* @__PURE__ */ new Map();
5
+ maxMemory = 0;
6
+ maxLabel;
7
+ lastMemInfo = [];
8
+ peakMemory = 0;
9
+ startMemory() {
10
+ this.lastMemInfo.push(s());
11
+ }
12
+ endMemory(e) {
13
+ if (this.lastMemInfo.length === 0) {
14
+ console.warn("MemoryProfiler: endMemory called without matching startMemory");
15
+ return;
16
+ }
17
+ const o = s(), t = o.numBytes - (this.lastMemInfo.pop()?.numBytes || 0);
18
+ this.log.set(e, Math.max(this.log.get(e) || 0, t)), t > this.maxMemory && (this.maxMemory = t, this.maxLabel = e), this.peakMemory = Math.max(this.peakMemory, o.numBytes);
19
+ }
20
+ printSummary() {
21
+ console.log("Memory Usage Summary:");
22
+ for (const [e, o] of this.log.entries())
23
+ console.log(`- ${e}: ${(o / m).toFixed(2)} MB`);
24
+ this.maxLabel && console.log(`Peak Memory Usage: ${(this.maxMemory / m).toFixed(2)} MB at "${this.maxLabel}"`), console.log(`Overall Peak Memory Usage: ${(this.peakMemory / m).toFixed(2)} MB`);
25
+ }
26
+ }
27
+ export {
28
+ i as default
29
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genai-fi/nanogpt",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",