@genai-fi/nanogpt 0.2.10 → 0.2.11

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,8 @@
1
- import { gatherSub as w } from "../ops/gatherSub.js";
2
- import { scatterSub as K } from "../ops/scatterSub.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";
1
+ import { gatherSub as _ } from "../ops/gatherSub.js";
2
+ import { scatterSub as v } from "../ops/scatterSub.js";
3
+ import { o as l, d, E as f, M as w, y as I, L as z, z as N, b as E, D as F, F as M, e as m, H as g, I as $, J as S } from "../index-YPKosni4.js";
4
+ import { r as b } from "../reshape-DmnmKT6r.js";
5
+ import { s as T } from "../sum-D7fu15XL.js";
5
6
  /**
6
7
  * @license
7
8
  * Copyright 2017 Google LLC. All Rights Reserved.
@@ -18,7 +19,7 @@ import { s as D, r as b } from "../sum-CnIf1YOh.js";
18
19
  * limitations under the License.
19
20
  * =============================================================================
20
21
  */
21
- function F(n, s, t) {
22
+ function D(n, s, t) {
22
23
  const a = n.length + s.length, e = [];
23
24
  let r = 0, c = 0;
24
25
  for (let o = 0; o < a; o++)
@@ -27,7 +28,7 @@ function F(n, s, t) {
27
28
  }
28
29
  function P(n, s) {
29
30
  const t = s.map((a) => 1);
30
- return F(n, t, s);
31
+ return D(n, t, s);
31
32
  }
32
33
  /**
33
34
  * @license
@@ -47,7 +48,7 @@ function P(n, s) {
47
48
  */
48
49
  function A(n, s = null, t = !1) {
49
50
  const e = { x: d(n, "x", "max") }, r = { reductionIndices: s, keepDims: t };
50
- return f.runKernel(_, e, r);
51
+ return f.runKernel(w, e, r);
51
52
  }
52
53
  const L = /* @__PURE__ */ l({ max_: A });
53
54
  /**
@@ -66,11 +67,11 @@ const L = /* @__PURE__ */ l({ max_: A });
66
67
  * limitations under the License.
67
68
  * =============================================================================
68
69
  */
69
- function O(n) {
70
+ function H(n) {
70
71
  const t = { x: d(n, "x", "exp") };
71
- return f.runKernel(z, t);
72
+ return f.runKernel(I, t);
72
73
  }
73
- const W = /* @__PURE__ */ l({ exp_: O });
74
+ const J = /* @__PURE__ */ l({ exp_: H });
74
75
  /**
75
76
  * @license
76
77
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -87,11 +88,11 @@ const W = /* @__PURE__ */ l({ exp_: O });
87
88
  * limitations under the License.
88
89
  * =============================================================================
89
90
  */
90
- function j(n) {
91
+ function O(n) {
91
92
  const t = { x: d(n, "x", "log", "float32") };
92
- return f.runKernel(I, t);
93
+ return f.runKernel(z, t);
93
94
  }
94
- const q = /* @__PURE__ */ l({ log_: j });
95
+ const W = /* @__PURE__ */ l({ log_: O });
95
96
  /**
96
97
  * @license
97
98
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -108,20 +109,20 @@ const q = /* @__PURE__ */ l({ log_: j });
108
109
  * limitations under the License.
109
110
  * =============================================================================
110
111
  */
111
- function B(n, s = null, t = !1) {
112
+ function j(n, s = null, t = !1) {
112
113
  const a = d(n, "x", "logSumExp"), e = N(s, a.shape), r = L(
113
114
  a,
114
115
  e,
115
116
  !0
116
117
  /* keepDims */
117
- ), c = E(a, r), o = W(c), p = D(o, e), u = q(p), i = M(b(r, u.shape), u);
118
+ ), c = E(a, r), o = J(c), p = T(o, e), u = W(p), x = F(b(r, u.shape), u);
118
119
  if (t) {
119
- const h = P(i.shape, e);
120
- return b(i, h);
120
+ const h = P(x.shape, e);
121
+ return b(x, h);
121
122
  }
122
- return i;
123
+ return x;
123
124
  }
124
- const H = /* @__PURE__ */ l({ logSumExp_: B });
125
+ const q = /* @__PURE__ */ l({ logSumExp_: j });
125
126
  /**
126
127
  * @license
127
128
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -138,21 +139,21 @@ const H = /* @__PURE__ */ l({ logSumExp_: B });
138
139
  * limitations under the License.
139
140
  * =============================================================================
140
141
  */
141
- function J(n, s = -1) {
142
+ function B(n, s = -1) {
142
143
  const t = d(n, "logits", "softmax", "float32");
143
144
  if (s === -1 && (s = t.rank - 1), s !== t.rank - 1)
144
145
  throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${s}`);
145
146
  const a = { logits: t }, e = { dim: s };
146
- return f.runKernel(T, a, e);
147
+ return f.runKernel(M, a, e);
147
148
  }
148
- const Q = /* @__PURE__ */ l({ softmax_: J });
149
+ const Q = /* @__PURE__ */ l({ softmax_: B });
149
150
  function R(n, s) {
150
151
  return $(() => {
151
- const t = n.shape[n.shape.length - 1], e = n.shape.slice(0, -1).reduce((h, x) => h * x, 1), r = n.shape.length > 2 ? n.reshape([e, t]) : n, c = s.shape.length > 1 ? s.reshape([e]).cast("int32") : s.cast("int32"), o = L(r, -1, !0), p = E(r, o), u = H(p, -1);
152
- return w(u, c, p);
152
+ const t = n.shape[n.shape.length - 1], e = n.shape.slice(0, -1).reduce((h, i) => h * i, 1), r = n.shape.length > 2 ? n.reshape([e, t]) : n, c = s.shape.length > 1 ? s.reshape([e]).cast("int32") : s.cast("int32"), o = L(r, -1, !0), p = E(r, o), u = q(p, -1);
153
+ return _(u, c, p);
153
154
  });
154
155
  }
155
- function ss() {
156
+ function ts() {
156
157
  return m().backendName === "tensorflow" ? g((s, t, a) => {
157
158
  const e = s.shape.length > 2 ? s.reshape([-1, s.shape[s.shape.length - 1]]) : s, r = t.shape.length > 1 ? t.reshape([-1]).cast("int32") : t.cast("int32"), [c, o] = m().runKernel(
158
159
  "NativeSparseSoftmaxCrossEntropy",
@@ -163,15 +164,15 @@ function ss() {
163
164
  }) : g(
164
165
  // @ts-expect-error Invalid params
165
166
  (s, t, a) => {
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
- return a([o, p]), o.dispose(), p.dispose(), { value: u, gradFunc: (h, x) => $(() => {
168
- const y = x[0], k = x[1], C = Q(y), G = K(C, k, h), v = S(t);
169
- return [G.reshape(s.shape), v];
167
+ const e = s.shape[s.shape.length - 1], c = s.shape.slice(0, -1).reduce((h, i) => h * i, 1), o = s.reshape([c, e]), p = t.reshape([c]).cast("int32"), u = R(o, p);
168
+ return a([o, p]), o.dispose(), p.dispose(), { value: u, gradFunc: (h, i) => $(() => {
169
+ const y = i[0], k = i[1], C = Q(y), G = v(C, k, h), K = S(t);
170
+ return [G.reshape(s.shape), K];
170
171
  }) };
171
172
  }
172
173
  );
173
174
  }
174
175
  export {
175
- ss as createSoftmaxCrossEntropyWithGrad,
176
+ ts as createSoftmaxCrossEntropyWithGrad,
176
177
  R as sparseSoftmaxCrossEntropy
177
178
  };
@@ -1,4 +1,4 @@
1
- import { m as s } from "../index-CWQLouWz.js";
1
+ import { m as s } from "../index-YPKosni4.js";
2
2
  const m = 1024 * 1024;
3
3
  class i {
4
4
  log = /* @__PURE__ */ new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genai-fi/nanogpt",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
@@ -1,49 +0,0 @@
1
- import { o, d as a, E as u, j as p, k as i, S as x } from "./index-CWQLouWz.js";
2
- /**
3
- * @license
4
- * Copyright 2020 Google LLC. All Rights Reserved.
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- * =============================================================================
17
- */
18
- function l(n, t) {
19
- const s = { x: a(n, "x", "reshape", "string_or_numeric") }, r = { shape: t };
20
- return u.runKernel(p, s, r);
21
- }
22
- const h = /* @__PURE__ */ o({ reshape_: l });
23
- /**
24
- * @license
25
- * Copyright 2018 Google LLC. All Rights Reserved.
26
- * Licensed under the Apache License, Version 2.0 (the "License");
27
- * you may not use this file except in compliance with the License.
28
- * You may obtain a copy of the License at
29
- *
30
- * http://www.apache.org/licenses/LICENSE-2.0
31
- *
32
- * Unless required by applicable law or agreed to in writing, software
33
- * distributed under the License is distributed on an "AS IS" BASIS,
34
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35
- * See the License for the specific language governing permissions and
36
- * limitations under the License.
37
- * =============================================================================
38
- */
39
- function m(n, t = null, e = !1) {
40
- let s = a(n, "x", "sum");
41
- s.dtype === "bool" && (s = i(s, "int32"));
42
- const r = { x: s }, c = { axis: t, keepDims: e };
43
- return u.runKernel(x, r, c);
44
- }
45
- const _ = /* @__PURE__ */ o({ sum_: m });
46
- export {
47
- h as r,
48
- _ as s
49
- };