@genai-fi/nanogpt 0.5.6 → 0.6.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.
- package/dist/Generator.js +10 -9
- package/dist/NanoGPTModel.js +70 -121
- package/dist/RealDiv-7xu-pkZN.js +540 -0
- package/dist/Reshape-BYC1oUku.js +127 -0
- package/dist/TeachableLLM.d.ts +2 -0
- package/dist/TeachableLLM.js +42 -34
- package/dist/{TiedEmbedding-8S8xn8e6.js → TiedEmbedding-C1HBot-5.js} +12 -13
- package/dist/{axis_util-BczFISHz.js → axis_util-CCNL7jea.js} +14 -12
- package/dist/{broadcast_to-B7NGsBSh.js → broadcast_to-CddAF879.js} +2 -2
- package/dist/{concat-DdKPyAtw.js → concat-XOK9ANZu.js} +7 -7
- package/dist/{dataset-iqT4Otvb.js → dataset-BFFipD1c.js} +5 -5
- package/dist/{dropout-B09InSJS.js → dropout-xlKRoJyU.js} +9 -9
- package/dist/{gather-D6MsdXqc.js → gather-DKtUaTtA.js} +1 -1
- package/dist/gpgpu_math-B_ycgZ4W.js +3115 -0
- package/dist/{index-Du-bmOP8.js → index-CamYe_M8.js} +844 -647
- package/dist/{kernel_funcs_utils-DShm7-0k.js → kernel_funcs_utils-D5MS0JFg.js} +232 -136
- package/dist/layers/BaseLayer.js +2 -2
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +5 -5
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +13 -33
- package/dist/layers/TiedEmbedding.js +6 -7
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/{log_sum_exp-CxfBtUaG.js → log_sum_exp-CV_5-TTu.js} +15 -15
- package/dist/main.js +24 -20
- package/dist/{mat_mul-CbiqIe2d.js → mat_mul-CAbRFWUj.js} +4 -4
- package/dist/{max-0Xnlpv8k.js → max-JBBv7aUf.js} +3 -3
- package/dist/mulmat_packed_gpu-DW4doKL_.js +71 -0
- package/dist/{norm-01kY9I2B.js → norm-B9dQTFYn.js} +12 -12
- package/dist/{ones-CrutWGas.js → ones-CMHNqMr6.js} +2 -2
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +5 -5
- package/dist/ops/cpu/fusedSoftmax.js +2 -2
- package/dist/ops/cpu/gatherSub.js +5 -5
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.js +1 -1
- package/dist/ops/cpu/matMulMul.js +1 -1
- package/dist/ops/cpu/mulDropout.js +1 -1
- package/dist/ops/cpu/normRMS.js +1 -1
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +18 -49
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +1 -1
- package/dist/ops/grads/attentionMask.js +15 -11
- package/dist/ops/grads/fusedSoftmax.js +12 -10
- package/dist/ops/grads/gelu.js +1 -1
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/normRMS.js +1 -1
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/log.d.ts +0 -0
- package/dist/ops/log.js +1 -0
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/node/sparseCrossEntropy.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +8 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +31 -3379
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/{gpgpu_math-BFbOyvk4.js → ops/webgl/log.d.ts} +2 -8
- package/dist/ops/webgl/log.js +39 -0
- package/dist/ops/webgl/matMulGelu.js +48 -115
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +1 -1
- package/dist/ops/webgl/normRMS.js +2 -2
- package/dist/ops/webgl/qkv.js +1 -1
- package/dist/ops/webgl/rope.js +1 -1
- package/dist/ops/webgl/scatterSub.js +1 -1
- package/dist/{ops-CJNniCAV.js → ops-DqtYemmV.js} +143 -135
- package/dist/{random_width-C-v-35bY.js → random_width-CLMQG5Jn.js} +6925 -6291
- package/dist/{range-Bvs1hidm.js → range-DqYjKnuG.js} +1 -1
- package/dist/reciprocal-z49filta.js +25 -0
- package/dist/register_all_kernels-COt6wLD0.js +21397 -0
- package/dist/{reshape-BH7eBpwq.js → reshape-C45vIIRU.js} +1 -1
- package/dist/scatter_nd_util-qgtnviTE.js +46 -0
- package/dist/selu_util-4QV_GXTB.js +740 -0
- package/dist/shared-ByfrGA97.js +3199 -0
- package/dist/{sin-CPAZXNjH.js → sin-9JBrfVaB.js} +1 -1
- package/dist/{softmax-DhWoBa7r.js → softmax-DvMvui-_.js} +1 -1
- package/dist/{split-BCUhuU7B.js → split-DxrHrPFK.js} +4 -4
- package/dist/{stack-BV1v7l3S.js → stack-DgaoDmnF.js} +1 -1
- package/dist/{sum-Cvq06317.js → sum-BpcpxNEh.js} +3 -3
- package/dist/{tensor-DgTOPY6h.js → tensor-CDz5x1mP.js} +1 -1
- package/dist/{tensor2d-CRWjDyUe.js → tensor2d-jO8JY5Jd.js} +1 -1
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +3 -3
- package/dist/training/sparseCrossEntropy.js +4 -4
- package/dist/utilities/dummy.d.ts +6 -0
- package/dist/utilities/dummy.js +31 -10
- package/dist/utilities/generate.js +3 -3
- package/dist/utilities/load.d.ts +25 -0
- package/dist/utilities/load.js +89 -37
- package/dist/utilities/profile.d.ts +5 -0
- package/dist/utilities/profile.js +12 -9
- package/dist/utilities/safetensors.d.ts +3 -0
- package/dist/utilities/safetensors.js +83 -0
- package/dist/utilities/save.js +47 -29
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-DZ3fF0R2.js → variable-CLVXjN7F.js} +1 -1
- package/dist/{zeros-BaHhQTWf.js → zeros-DUkkVccu.js} +8 -8
- package/package.json +3 -9
- package/dist/Reshape-Biok_3X1.js +0 -212
- package/dist/slice_util-DskXqRZa.js +0 -49
- package/dist/tfjs_backend-D9Ytje0G.js +0 -1010
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as m, w as r, Z as l, E as c, _ as i, y as p, $ as u, i as f } from "./index-CamYe_M8.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -16,9 +16,9 @@ import { o as m, j as r, X as l, E as c, Y as i, n as p, Z as u, q as f } from "
|
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
18
|
function x(a, e) {
|
|
19
|
-
const
|
|
20
|
-
l(
|
|
21
|
-
const n = { real:
|
|
19
|
+
const s = r(a, "real", "complex"), o = r(e, "imag", "complex");
|
|
20
|
+
l(s.shape, o.shape, `real and imag shapes, ${s.shape} and ${o.shape}, must match in call to tf.complex().`);
|
|
21
|
+
const n = { real: s, imag: o };
|
|
22
22
|
return c.runKernel(i, n);
|
|
23
23
|
}
|
|
24
24
|
const g = /* @__PURE__ */ m({ complex_: x });
|
|
@@ -40,11 +40,11 @@ const g = /* @__PURE__ */ m({ complex_: x });
|
|
|
40
40
|
*/
|
|
41
41
|
function t(a, e = "float32") {
|
|
42
42
|
if (p(a), e === "complex64") {
|
|
43
|
-
const
|
|
44
|
-
return g(
|
|
43
|
+
const o = t(a, "float32"), n = t(a, "float32");
|
|
44
|
+
return g(o, n);
|
|
45
45
|
}
|
|
46
|
-
const
|
|
47
|
-
return c.makeTensor(
|
|
46
|
+
const s = u(f(a), e);
|
|
47
|
+
return c.makeTensor(s, a, e);
|
|
48
48
|
}
|
|
49
49
|
export {
|
|
50
50
|
g as c,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genai-fi/nanogpt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -24,18 +24,11 @@
|
|
|
24
24
|
"test:gl": "playwright test",
|
|
25
25
|
"ci:test": "vitest --coverage --reporter=junit --outputFile=junit.xml",
|
|
26
26
|
"coverage": "vitest run --coverage",
|
|
27
|
-
"train": "tsx scripts/train.ts",
|
|
28
|
-
"generate": "tsx scripts/generate.ts",
|
|
29
|
-
"evaluate": "tsx scripts/evaluate.ts",
|
|
30
27
|
"debug": "tsx scripts/debug.ts"
|
|
31
28
|
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"@tensorflow/tfjs": "^4.22.0"
|
|
34
|
-
},
|
|
35
29
|
"devDependencies": {
|
|
36
30
|
"@eslint/js": "^9.32.0",
|
|
37
31
|
"@playwright/test": "^1.55.0",
|
|
38
|
-
"@tensorflow/tfjs-node-gpu": "^4.22.0",
|
|
39
32
|
"@types/node": "^22.13.14",
|
|
40
33
|
"@types/papaparse": "^5.3.16",
|
|
41
34
|
"@types/yargs": "^17.0.33",
|
|
@@ -59,6 +52,7 @@
|
|
|
59
52
|
"eventemitter3": "^5.0.1",
|
|
60
53
|
"jszip": "^3.10.1",
|
|
61
54
|
"papaparse": "^5.5.3",
|
|
62
|
-
"pdfjs-dist": "^5.4.149"
|
|
55
|
+
"pdfjs-dist": "^5.4.149",
|
|
56
|
+
"@tensorflow/tfjs": "^4.22.0"
|
|
63
57
|
}
|
|
64
58
|
}
|
package/dist/Reshape-Biok_3X1.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { ac as f, ad as g, q as p, ae as C, l as x } from "./index-Du-bmOP8.js";
|
|
2
|
-
import { u as I } from "./gpgpu_math-BFbOyvk4.js";
|
|
3
|
-
/**
|
|
4
|
-
* @license
|
|
5
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
* =============================================================================
|
|
18
|
-
*/
|
|
19
|
-
function R(t, e, o = "index") {
|
|
20
|
-
const s = f(e);
|
|
21
|
-
return s.map((n, r) => {
|
|
22
|
-
const i = `int ${t[r]} = ${o} / ${n}`, u = r === s.length - 1 ? `int ${t[r + 1]} = ${o} - ${t[r]} * ${n}` : `index -= ${t[r]} * ${n}`;
|
|
23
|
-
return `${i}; ${u};`;
|
|
24
|
-
}).join("");
|
|
25
|
-
}
|
|
26
|
-
function y(t, e) {
|
|
27
|
-
const o = t.length, s = t.map((r) => `${e}[${r}]`), n = new Array(o - 1);
|
|
28
|
-
n[o - 2] = s[o - 1];
|
|
29
|
-
for (let r = o - 3; r >= 0; --r)
|
|
30
|
-
n[r] = `(${n[r + 1]} * ${s[r + 1]})`;
|
|
31
|
-
return n;
|
|
32
|
-
}
|
|
33
|
-
function S(t, e, o = "index") {
|
|
34
|
-
const s = t.map((r, i) => i), n = y(s, e);
|
|
35
|
-
return n.map((r, i) => {
|
|
36
|
-
const u = `int ${t[i]} = ${o} / ${n[i]}`, a = i === n.length - 1 ? `int ${t[i + 1]} = ${o} - ${t[i]} * ${n[i]}` : `index -= ${t[i]} * ${n[i]}`;
|
|
37
|
-
return `${u}; ${a};`;
|
|
38
|
-
}).join("");
|
|
39
|
-
}
|
|
40
|
-
function F(t) {
|
|
41
|
-
const e = f(t).map((o) => o.toString());
|
|
42
|
-
return `
|
|
43
|
-
int getFlatIndex(ivec3 coords) {
|
|
44
|
-
return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z;
|
|
45
|
-
}
|
|
46
|
-
`;
|
|
47
|
-
}
|
|
48
|
-
function v() {
|
|
49
|
-
return `
|
|
50
|
-
int getFlatIndex(ivec3 coords) {
|
|
51
|
-
return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @license
|
|
57
|
-
* Copyright 2017 Google LLC. All Rights Reserved.
|
|
58
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
59
|
-
* you may not use this file except in compliance with the License.
|
|
60
|
-
* You may obtain a copy of the License at
|
|
61
|
-
*
|
|
62
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
63
|
-
*
|
|
64
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
65
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
66
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
67
|
-
* See the License for the specific language governing permissions and
|
|
68
|
-
* limitations under the License.
|
|
69
|
-
* =============================================================================
|
|
70
|
-
*/
|
|
71
|
-
function h(t, e = 2) {
|
|
72
|
-
return p(t.slice(0, t.length - e));
|
|
73
|
-
}
|
|
74
|
-
function m(t) {
|
|
75
|
-
if (t.length === 0)
|
|
76
|
-
throw Error("Cannot get rows and columns of an empty shape array.");
|
|
77
|
-
return [
|
|
78
|
-
t.length > 1 ? t[t.length - 2] : 1,
|
|
79
|
-
t[t.length - 1]
|
|
80
|
-
];
|
|
81
|
-
}
|
|
82
|
-
function d(t) {
|
|
83
|
-
return t % 2 === 0;
|
|
84
|
-
}
|
|
85
|
-
function $(t, e) {
|
|
86
|
-
if (t = t.slice(-2), e = e.slice(-2), g(t, e) || !t.length || !e.length || t[0] === 0 || t[1] === 0 || e[0] === 0 || e[1] === 0)
|
|
87
|
-
return !0;
|
|
88
|
-
if (t.length !== e.length) {
|
|
89
|
-
const o = t[t.length - 1], s = e[e.length - 1];
|
|
90
|
-
if (o === s || d(o) && d(s) && (t[0] === 1 || e[0] === 1))
|
|
91
|
-
return !0;
|
|
92
|
-
}
|
|
93
|
-
return t[1] === e[1] && d(t[0]) && d(e[0]);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* @license
|
|
97
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
98
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
99
|
-
* you may not use this file except in compliance with the License.
|
|
100
|
-
* You may obtain a copy of the License at
|
|
101
|
-
*
|
|
102
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
103
|
-
*
|
|
104
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
105
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
106
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
107
|
-
* See the License for the specific language governing permissions and
|
|
108
|
-
* limitations under the License.
|
|
109
|
-
* =============================================================================
|
|
110
|
-
*/
|
|
111
|
-
class b {
|
|
112
|
-
constructor(e, o) {
|
|
113
|
-
this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = e, this.enableShapeUniforms = I(this.outputShape.length);
|
|
114
|
-
let s = "";
|
|
115
|
-
for (let n = 0; n < 4; n++) {
|
|
116
|
-
let r = "thisRC = rc;";
|
|
117
|
-
n % 2 === 1 && (r += "thisRC.z += 1;"), n > 1 && (r += "thisRC.y += 1;"), s += `
|
|
118
|
-
${r}
|
|
119
|
-
${n > 0 ? "if(thisRC.y < rows && thisRC.z < cols){" : ""}
|
|
120
|
-
int flatIndex = getFlatIndex(thisRC);
|
|
121
|
-
|
|
122
|
-
ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);
|
|
123
|
-
vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));
|
|
124
|
-
|
|
125
|
-
result[${n}] =
|
|
126
|
-
getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);
|
|
127
|
-
${n > 0 ? "}" : ""}
|
|
128
|
-
`;
|
|
129
|
-
}
|
|
130
|
-
this.userCode = `
|
|
131
|
-
${w(o, this.enableShapeUniforms)}
|
|
132
|
-
${this.enableShapeUniforms ? v() : F(e)}
|
|
133
|
-
|
|
134
|
-
void main() {
|
|
135
|
-
ivec3 rc = getOutputCoords();
|
|
136
|
-
|
|
137
|
-
vec4 result = vec4(0.);
|
|
138
|
-
|
|
139
|
-
ivec3 thisRC;
|
|
140
|
-
int rows = ${this.enableShapeUniforms ? "outShape[1]" : e[1]};
|
|
141
|
-
int cols = ${this.enableShapeUniforms ? "outShape[2]" : e[2]};
|
|
142
|
-
|
|
143
|
-
${s}
|
|
144
|
-
|
|
145
|
-
setOutput(result);
|
|
146
|
-
}
|
|
147
|
-
`;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function w(t, e) {
|
|
151
|
-
return `
|
|
152
|
-
ivec3 inputCoordsFromReshapedOutCoords(int index) {
|
|
153
|
-
${e ? S(["r", "c", "d"], "inputShape") : R(["r", "c", "d"], t)}
|
|
154
|
-
return ivec3(r, c, d);
|
|
155
|
-
}
|
|
156
|
-
`;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* @license
|
|
160
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
161
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
162
|
-
* you may not use this file except in compliance with the License.
|
|
163
|
-
* You may obtain a copy of the License at
|
|
164
|
-
*
|
|
165
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
166
|
-
*
|
|
167
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
168
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
169
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
170
|
-
* See the License for the specific language governing permissions and
|
|
171
|
-
* limitations under the License.
|
|
172
|
-
* =============================================================================
|
|
173
|
-
*/
|
|
174
|
-
function D(t, e, o) {
|
|
175
|
-
const s = [
|
|
176
|
-
h(t.shape),
|
|
177
|
-
...m(t.shape)
|
|
178
|
-
], n = {
|
|
179
|
-
dtype: t.dtype,
|
|
180
|
-
shape: s,
|
|
181
|
-
dataId: t.dataId
|
|
182
|
-
}, r = [
|
|
183
|
-
h(e),
|
|
184
|
-
...m(e)
|
|
185
|
-
], i = new b(r, s), u = !0, a = [s], c = o.runWebGLProgram(i, [n], t.dtype, a, u);
|
|
186
|
-
return { dataId: c.dataId, shape: e, dtype: c.dtype };
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* @license
|
|
190
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
191
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
* you may not use this file except in compliance with the License.
|
|
193
|
-
* You may obtain a copy of the License at
|
|
194
|
-
*
|
|
195
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
*
|
|
197
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
* See the License for the specific language governing permissions and
|
|
201
|
-
* limitations under the License.
|
|
202
|
-
* =============================================================================
|
|
203
|
-
*/
|
|
204
|
-
function k(t) {
|
|
205
|
-
const { inputs: e, backend: o, attrs: s } = t, { x: n } = e, { shape: r } = s, i = o, u = p(n.shape), a = C(r, u), c = p(a);
|
|
206
|
-
x(u === c, () => `The new shape (${a}) has ${c} elements and the old shape (${n.shape}) has ${u} elements. The new shape and old shape must have the same number of elements.`);
|
|
207
|
-
const l = i.texData.get(n.dataId);
|
|
208
|
-
return l.isPacked && !$(n.shape, a) && !(l.texture !== null && $(l.shape, a)) ? D(n, a, i) : (i.incRef(n.dataId), { dataId: n.dataId, shape: a, dtype: n.dtype });
|
|
209
|
-
}
|
|
210
|
-
export {
|
|
211
|
-
k as r
|
|
212
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { l as s } from "./index-Du-bmOP8.js";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright 2021 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 u(r, n, t) {
|
|
19
|
-
let l = t.length;
|
|
20
|
-
for (let e = 0; e < t.length; e++)
|
|
21
|
-
if (t[e] > 1) {
|
|
22
|
-
l = e;
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
for (let e = l + 1; e < t.length; e++)
|
|
26
|
-
if (n[e] > 0 || t[e] !== r[e])
|
|
27
|
-
return !1;
|
|
28
|
-
return !0;
|
|
29
|
-
}
|
|
30
|
-
function c(r, n) {
|
|
31
|
-
let t = r.length > 0 ? r[r.length - 1] : 1;
|
|
32
|
-
for (let l = 0; l < r.length - 1; l++)
|
|
33
|
-
t += r[l] * n[l];
|
|
34
|
-
return t;
|
|
35
|
-
}
|
|
36
|
-
function h(r, n, t) {
|
|
37
|
-
let l;
|
|
38
|
-
const e = r.shape.length;
|
|
39
|
-
typeof n == "number" ? l = [n, ...new Array(e - 1).fill(0)] : n.length < e ? l = n.concat(new Array(e - n.length).fill(0)) : l = n.slice(), l.forEach((a) => {
|
|
40
|
-
s(a !== -1, () => "slice() does not support negative begin indexing.");
|
|
41
|
-
});
|
|
42
|
-
let f;
|
|
43
|
-
return t == null ? f = new Array(e).fill(-1) : typeof t == "number" ? f = [t, ...new Array(e - 1).fill(-1)] : t.length < e ? f = t.concat(new Array(e - t.length).fill(-1)) : f = t, f = f.map((a, o) => a >= 0 ? a : (s(a === -1, () => `Negative size values should be exactly -1 but got ${a} for the slice() size at index ${o}.`), r.shape[o] - l[o])), [l, f];
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
c,
|
|
47
|
-
u as i,
|
|
48
|
-
h as p
|
|
49
|
-
};
|