oidn-web 0.1.0 → 0.1.2
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/oidn.mjs +602 -605
- package/dist/oidn.umd.js +137 -137
- package/lib/UNet.js +5 -2
- package/lib/UNet.js.map +1 -1
- package/package.json +1 -1
- package/src/UNet.ts +14 -14
- package/weights/rt_hdr_calb_cnrm.tza +0 -0
package/dist/oidn.mjs
CHANGED
|
@@ -132,57 +132,57 @@ class If {
|
|
|
132
132
|
}
|
|
133
133
|
class Fl {
|
|
134
134
|
refCount(t) {
|
|
135
|
-
return
|
|
135
|
+
return Bt("refCount");
|
|
136
136
|
}
|
|
137
137
|
incRef(t) {
|
|
138
|
-
return
|
|
138
|
+
return Bt("incRef");
|
|
139
139
|
}
|
|
140
140
|
timerAvailable() {
|
|
141
141
|
return !0;
|
|
142
142
|
}
|
|
143
143
|
time(t) {
|
|
144
|
-
return
|
|
144
|
+
return Bt("time");
|
|
145
145
|
}
|
|
146
146
|
read(t) {
|
|
147
|
-
return
|
|
147
|
+
return Bt("read");
|
|
148
148
|
}
|
|
149
149
|
readSync(t) {
|
|
150
|
-
return
|
|
150
|
+
return Bt("readSync");
|
|
151
151
|
}
|
|
152
152
|
readToGPU(t, e) {
|
|
153
|
-
return
|
|
153
|
+
return Bt("readToGPU");
|
|
154
154
|
}
|
|
155
155
|
numDataIds() {
|
|
156
|
-
return
|
|
156
|
+
return Bt("numDataIds");
|
|
157
157
|
}
|
|
158
158
|
disposeData(t, e) {
|
|
159
|
-
return
|
|
159
|
+
return Bt("disposeData");
|
|
160
160
|
}
|
|
161
161
|
write(t, e, s) {
|
|
162
|
-
return
|
|
162
|
+
return Bt("write");
|
|
163
163
|
}
|
|
164
164
|
move(t, e, s, r, o) {
|
|
165
|
-
return
|
|
165
|
+
return Bt("move");
|
|
166
166
|
}
|
|
167
167
|
createTensorFromGPUData(t, e, s) {
|
|
168
|
-
return
|
|
168
|
+
return Bt("createTensorFromGPUData");
|
|
169
169
|
}
|
|
170
170
|
memory() {
|
|
171
|
-
return
|
|
171
|
+
return Bt("memory");
|
|
172
172
|
}
|
|
173
173
|
/** Returns the highest precision for floats in bits (e.g. 16 or 32) */
|
|
174
174
|
floatPrecision() {
|
|
175
|
-
return
|
|
175
|
+
return Bt("floatPrecision");
|
|
176
176
|
}
|
|
177
177
|
/** Returns the smallest representable number. */
|
|
178
178
|
epsilon() {
|
|
179
179
|
return this.floatPrecision() === 32 ? $f : vf;
|
|
180
180
|
}
|
|
181
181
|
dispose() {
|
|
182
|
-
return
|
|
182
|
+
return Bt("dispose");
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function Bt(n) {
|
|
186
186
|
throw new Error(`'${n}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`);
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
@@ -204,9 +204,9 @@ function Mt(n) {
|
|
|
204
204
|
function Af(n) {
|
|
205
205
|
let t = n.length, e = 0;
|
|
206
206
|
for (; t > 0; )
|
|
207
|
-
e = Math.random() * t | 0, t--,
|
|
207
|
+
e = Math.random() * t | 0, t--, Cn(n, t, e);
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function Cn(n, t, e) {
|
|
210
210
|
const s = n[t];
|
|
211
211
|
n[t] = n[e], n[e] = s;
|
|
212
212
|
}
|
|
@@ -273,12 +273,12 @@ function kf(n, t) {
|
|
|
273
273
|
const r = n.slice();
|
|
274
274
|
return r[s] = t / e, r;
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function Es(n, t) {
|
|
277
277
|
const e = t.length;
|
|
278
278
|
return n = n == null ? t.map((s, r) => r) : [].concat(n), w(n.every((s) => s >= -e && s < e), () => `All values in axis param must be in range [-${e}, ${e}) but got axis ${n}`), w(n.every((s) => Io(s)), () => `All values in axis param must be integers but got axis ${n}`), n.map((s) => s < 0 ? e + s : s);
|
|
279
279
|
}
|
|
280
280
|
function _f(n, t) {
|
|
281
|
-
const e = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, o = t == null || r ? null :
|
|
281
|
+
const e = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, o = t == null || r ? null : Es(t, n).sort();
|
|
282
282
|
let i = 0;
|
|
283
283
|
for (let a = 0; a < n.length; ++a) {
|
|
284
284
|
if (o != null) {
|
|
@@ -290,7 +290,7 @@ function _f(n, t) {
|
|
|
290
290
|
}
|
|
291
291
|
return { newShape: e, keptDims: s };
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function Ln(n, t) {
|
|
294
294
|
return yt(n, t);
|
|
295
295
|
}
|
|
296
296
|
function yt(n, t) {
|
|
@@ -341,8 +341,8 @@ function Rf(n) {
|
|
|
341
341
|
function Eo(n) {
|
|
342
342
|
return typeof n == "number";
|
|
343
343
|
}
|
|
344
|
-
function
|
|
345
|
-
return Array.isArray(n) ?
|
|
344
|
+
function Cs(n) {
|
|
345
|
+
return Array.isArray(n) ? Cs(n[0]) : n instanceof Float32Array ? "float32" : n instanceof Int32Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray ? "int32" : Eo(n) ? "float32" : Or(n) ? "string" : Rf(n) ? "bool" : "float32";
|
|
346
346
|
}
|
|
347
347
|
function Co(n) {
|
|
348
348
|
return !!(n && n.constructor && n.call && n.apply);
|
|
@@ -392,12 +392,12 @@ function no(n, t) {
|
|
|
392
392
|
throw new Error(`Unknown dtype ${t}`);
|
|
393
393
|
}
|
|
394
394
|
function Wl(n, t) {
|
|
395
|
-
const e =
|
|
395
|
+
const e = je(n, t);
|
|
396
396
|
for (let s = 0; s < e.length; s++)
|
|
397
397
|
e[s] = 1;
|
|
398
398
|
return e;
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function je(n, t) {
|
|
401
401
|
if (t == null || t === "float32" || t === "complex64")
|
|
402
402
|
return new Float32Array(n);
|
|
403
403
|
if (t === "int32")
|
|
@@ -600,7 +600,7 @@ const zf = "Abs", ql = "Add", Uf = "All", Wf = "ArgMax", Gf = "AvgPool", Vf = "A
|
|
|
600
600
|
* limitations under the License.
|
|
601
601
|
* =============================================================================
|
|
602
602
|
*/
|
|
603
|
-
function
|
|
603
|
+
function kn(...n) {
|
|
604
604
|
W().getBool("IS_TEST") || W().getBool("PROD") || console.warn(...n);
|
|
605
605
|
}
|
|
606
606
|
/**
|
|
@@ -640,7 +640,7 @@ function ya(n) {
|
|
|
640
640
|
}
|
|
641
641
|
function up(n) {
|
|
642
642
|
const { kernelName: t, backendName: e } = n, s = tu(t, e);
|
|
643
|
-
rr.has(s) &&
|
|
643
|
+
rr.has(s) && kn(`The kernel '${t}' for backend '${e}' is already registered`), rr.set(s, n);
|
|
644
644
|
}
|
|
645
645
|
function tu(n, t) {
|
|
646
646
|
return `${t}_${n}`;
|
|
@@ -986,10 +986,10 @@ function at(n, t, e) {
|
|
|
986
986
|
}
|
|
987
987
|
at.prototype.__isLong__;
|
|
988
988
|
Object.defineProperty(at.prototype, "__isLong__", { value: !0 });
|
|
989
|
-
function
|
|
989
|
+
function qt(n) {
|
|
990
990
|
return (n && n.__isLong__) === !0;
|
|
991
991
|
}
|
|
992
|
-
at.isLong =
|
|
992
|
+
at.isLong = qt;
|
|
993
993
|
var wa = {}, xa = {};
|
|
994
994
|
function xn(n, t) {
|
|
995
995
|
var e, s, r;
|
|
@@ -1006,11 +1006,11 @@ function ee(n, t) {
|
|
|
1006
1006
|
return iu;
|
|
1007
1007
|
} else {
|
|
1008
1008
|
if (n <= -$a)
|
|
1009
|
-
return
|
|
1009
|
+
return Ut;
|
|
1010
1010
|
if (n + 1 >= $a)
|
|
1011
1011
|
return ou;
|
|
1012
1012
|
}
|
|
1013
|
-
return n < 0 ? ee(-n, t).neg() : lt(n %
|
|
1013
|
+
return n < 0 ? ee(-n, t).neg() : lt(n % Mn | 0, n / Mn | 0, t);
|
|
1014
1014
|
}
|
|
1015
1015
|
at.fromNumber = ee;
|
|
1016
1016
|
function lt(n, t, e) {
|
|
@@ -1045,12 +1045,12 @@ function me(n, t) {
|
|
|
1045
1045
|
return typeof n == "number" ? ee(n, t) : typeof n == "string" ? ui(n, t) : lt(n.low, n.high, typeof t == "boolean" ? t : n.unsigned);
|
|
1046
1046
|
}
|
|
1047
1047
|
at.fromValue = me;
|
|
1048
|
-
var Sa = 65536, fp = 1 << 24,
|
|
1048
|
+
var Sa = 65536, fp = 1 << 24, Mn = Sa * Sa, su = Mn * Mn, $a = su / 2, va = xn(fp), ne = xn(0);
|
|
1049
1049
|
at.ZERO = ne;
|
|
1050
1050
|
var tn = xn(0, !0);
|
|
1051
1051
|
at.UZERO = tn;
|
|
1052
|
-
var
|
|
1053
|
-
at.ONE =
|
|
1052
|
+
var Dn = xn(1);
|
|
1053
|
+
at.ONE = Dn;
|
|
1054
1054
|
var ru = xn(1, !0);
|
|
1055
1055
|
at.UONE = ru;
|
|
1056
1056
|
var To = xn(-1);
|
|
@@ -1059,14 +1059,14 @@ var ou = lt(-1, 2147483647, !1);
|
|
|
1059
1059
|
at.MAX_VALUE = ou;
|
|
1060
1060
|
var iu = lt(-1, -1, !0);
|
|
1061
1061
|
at.MAX_UNSIGNED_VALUE = iu;
|
|
1062
|
-
var
|
|
1063
|
-
at.MIN_VALUE =
|
|
1062
|
+
var Ut = lt(0, -2147483648, !1);
|
|
1063
|
+
at.MIN_VALUE = Ut;
|
|
1064
1064
|
var R = at.prototype;
|
|
1065
1065
|
R.toInt = function() {
|
|
1066
1066
|
return this.unsigned ? this.low >>> 0 : this.low;
|
|
1067
1067
|
};
|
|
1068
1068
|
R.toNumber = function() {
|
|
1069
|
-
return this.unsigned ? (this.high >>> 0) *
|
|
1069
|
+
return this.unsigned ? (this.high >>> 0) * Mn + (this.low >>> 0) : this.high * Mn + (this.low >>> 0);
|
|
1070
1070
|
};
|
|
1071
1071
|
R.toString = function(t) {
|
|
1072
1072
|
if (t = t || 10, t < 2 || 36 < t)
|
|
@@ -1074,7 +1074,7 @@ R.toString = function(t) {
|
|
|
1074
1074
|
if (this.isZero())
|
|
1075
1075
|
return "0";
|
|
1076
1076
|
if (this.isNegative())
|
|
1077
|
-
if (this.eq(
|
|
1077
|
+
if (this.eq(Ut)) {
|
|
1078
1078
|
var e = ee(t), s = this.div(e), r = s.mul(e).sub(this);
|
|
1079
1079
|
return s.toString(t) + r.toInt().toString(t);
|
|
1080
1080
|
} else
|
|
@@ -1102,7 +1102,7 @@ R.getLowBitsUnsigned = function() {
|
|
|
1102
1102
|
};
|
|
1103
1103
|
R.getNumBitsAbs = function() {
|
|
1104
1104
|
if (this.isNegative())
|
|
1105
|
-
return this.eq(
|
|
1105
|
+
return this.eq(Ut) ? 64 : this.neg().getNumBitsAbs();
|
|
1106
1106
|
for (var t = this.high != 0 ? this.high : this.low, e = 31; e > 0 && !(t & 1 << e); e--)
|
|
1107
1107
|
;
|
|
1108
1108
|
return this.high != 0 ? e + 33 : e + 1;
|
|
@@ -1124,7 +1124,7 @@ R.isEven = function() {
|
|
|
1124
1124
|
return (this.low & 1) === 0;
|
|
1125
1125
|
};
|
|
1126
1126
|
R.equals = function(t) {
|
|
1127
|
-
return
|
|
1127
|
+
return qt(t) || (t = me(t)), this.unsigned !== t.unsigned && this.high >>> 31 === 1 && t.high >>> 31 === 1 ? !1 : this.high === t.high && this.low === t.low;
|
|
1128
1128
|
};
|
|
1129
1129
|
R.eq = R.equals;
|
|
1130
1130
|
R.notEquals = function(t) {
|
|
@@ -1166,29 +1166,29 @@ R.greaterThanOrEqual = function(t) {
|
|
|
1166
1166
|
R.gte = R.greaterThanOrEqual;
|
|
1167
1167
|
R.ge = R.greaterThanOrEqual;
|
|
1168
1168
|
R.compare = function(t) {
|
|
1169
|
-
if (
|
|
1169
|
+
if (qt(t) || (t = me(t)), this.eq(t))
|
|
1170
1170
|
return 0;
|
|
1171
1171
|
var e = this.isNegative(), s = t.isNegative();
|
|
1172
1172
|
return e && !s ? -1 : !e && s ? 1 : this.unsigned ? t.high >>> 0 > this.high >>> 0 || t.high === this.high && t.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(t).isNegative() ? -1 : 1;
|
|
1173
1173
|
};
|
|
1174
1174
|
R.comp = R.compare;
|
|
1175
1175
|
R.negate = function() {
|
|
1176
|
-
return !this.unsigned && this.eq(
|
|
1176
|
+
return !this.unsigned && this.eq(Ut) ? Ut : this.not().add(Dn);
|
|
1177
1177
|
};
|
|
1178
1178
|
R.neg = R.negate;
|
|
1179
1179
|
R.add = function(t) {
|
|
1180
|
-
|
|
1180
|
+
qt(t) || (t = me(t));
|
|
1181
1181
|
var e = this.high >>> 16, s = this.high & 65535, r = this.low >>> 16, o = this.low & 65535, i = t.high >>> 16, a = t.high & 65535, l = t.low >>> 16, u = t.low & 65535, c = 0, h = 0, f = 0, d = 0;
|
|
1182
1182
|
return d += o + u, f += d >>> 16, d &= 65535, f += r + l, h += f >>> 16, f &= 65535, h += s + a, c += h >>> 16, h &= 65535, c += e + i, c &= 65535, lt(f << 16 | d, c << 16 | h, this.unsigned);
|
|
1183
1183
|
};
|
|
1184
1184
|
R.subtract = function(t) {
|
|
1185
|
-
return
|
|
1185
|
+
return qt(t) || (t = me(t)), this.add(t.neg());
|
|
1186
1186
|
};
|
|
1187
1187
|
R.sub = R.subtract;
|
|
1188
1188
|
R.multiply = function(t) {
|
|
1189
1189
|
if (this.isZero())
|
|
1190
1190
|
return ne;
|
|
1191
|
-
if (
|
|
1191
|
+
if (qt(t) || (t = me(t)), te) {
|
|
1192
1192
|
var e = te.mul(
|
|
1193
1193
|
this.low,
|
|
1194
1194
|
this.high,
|
|
@@ -1199,10 +1199,10 @@ R.multiply = function(t) {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
if (t.isZero())
|
|
1201
1201
|
return ne;
|
|
1202
|
-
if (this.eq(
|
|
1203
|
-
return t.isOdd() ?
|
|
1204
|
-
if (t.eq(
|
|
1205
|
-
return this.isOdd() ?
|
|
1202
|
+
if (this.eq(Ut))
|
|
1203
|
+
return t.isOdd() ? Ut : ne;
|
|
1204
|
+
if (t.eq(Ut))
|
|
1205
|
+
return this.isOdd() ? Ut : ne;
|
|
1206
1206
|
if (this.isNegative())
|
|
1207
1207
|
return t.isNegative() ? this.neg().mul(t.neg()) : this.neg().mul(t).neg();
|
|
1208
1208
|
if (t.isNegative())
|
|
@@ -1214,7 +1214,7 @@ R.multiply = function(t) {
|
|
|
1214
1214
|
};
|
|
1215
1215
|
R.mul = R.multiply;
|
|
1216
1216
|
R.divide = function(t) {
|
|
1217
|
-
if (
|
|
1217
|
+
if (qt(t) || (t = me(t)), t.isZero())
|
|
1218
1218
|
throw Error("division by zero");
|
|
1219
1219
|
if (te) {
|
|
1220
1220
|
if (!this.unsigned && this.high === -2147483648 && t.low === -1 && t.high === -1)
|
|
@@ -1237,14 +1237,14 @@ R.divide = function(t) {
|
|
|
1237
1237
|
return ru;
|
|
1238
1238
|
o = tn;
|
|
1239
1239
|
} else {
|
|
1240
|
-
if (this.eq(
|
|
1241
|
-
if (t.eq(
|
|
1242
|
-
return
|
|
1243
|
-
if (t.eq(
|
|
1244
|
-
return
|
|
1240
|
+
if (this.eq(Ut)) {
|
|
1241
|
+
if (t.eq(Dn) || t.eq(To))
|
|
1242
|
+
return Ut;
|
|
1243
|
+
if (t.eq(Ut))
|
|
1244
|
+
return Dn;
|
|
1245
1245
|
var i = this.shr(1);
|
|
1246
|
-
return s = i.div(t).shl(1), s.eq(ne) ? t.isNegative() ?
|
|
1247
|
-
} else if (t.eq(
|
|
1246
|
+
return s = i.div(t).shl(1), s.eq(ne) ? t.isNegative() ? Dn : To : (r = this.sub(t.mul(s)), o = s.add(r.div(t)), o);
|
|
1247
|
+
} else if (t.eq(Ut))
|
|
1248
1248
|
return this.unsigned ? tn : ne;
|
|
1249
1249
|
if (this.isNegative())
|
|
1250
1250
|
return t.isNegative() ? this.neg().div(t.neg()) : this.neg().div(t).neg();
|
|
@@ -1256,13 +1256,13 @@ R.divide = function(t) {
|
|
|
1256
1256
|
s = Math.max(1, Math.floor(r.toNumber() / t.toNumber()));
|
|
1257
1257
|
for (var a = Math.ceil(Math.log(s) / Math.LN2), l = a <= 48 ? 1 : or(2, a - 48), u = ee(s), c = u.mul(t); c.isNegative() || c.gt(r); )
|
|
1258
1258
|
s -= l, u = ee(s, this.unsigned), c = u.mul(t);
|
|
1259
|
-
u.isZero() && (u =
|
|
1259
|
+
u.isZero() && (u = Dn), o = o.add(u), r = r.sub(c);
|
|
1260
1260
|
}
|
|
1261
1261
|
return o;
|
|
1262
1262
|
};
|
|
1263
1263
|
R.div = R.divide;
|
|
1264
1264
|
R.modulo = function(t) {
|
|
1265
|
-
if (
|
|
1265
|
+
if (qt(t) || (t = me(t)), te) {
|
|
1266
1266
|
var e = (this.unsigned ? te.rem_u : te.rem_s)(
|
|
1267
1267
|
this.low,
|
|
1268
1268
|
this.high,
|
|
@@ -1279,24 +1279,24 @@ R.not = function() {
|
|
|
1279
1279
|
return lt(~this.low, ~this.high, this.unsigned);
|
|
1280
1280
|
};
|
|
1281
1281
|
R.and = function(t) {
|
|
1282
|
-
return
|
|
1282
|
+
return qt(t) || (t = me(t)), lt(this.low & t.low, this.high & t.high, this.unsigned);
|
|
1283
1283
|
};
|
|
1284
1284
|
R.or = function(t) {
|
|
1285
|
-
return
|
|
1285
|
+
return qt(t) || (t = me(t)), lt(this.low | t.low, this.high | t.high, this.unsigned);
|
|
1286
1286
|
};
|
|
1287
1287
|
R.xor = function(t) {
|
|
1288
|
-
return
|
|
1288
|
+
return qt(t) || (t = me(t)), lt(this.low ^ t.low, this.high ^ t.high, this.unsigned);
|
|
1289
1289
|
};
|
|
1290
1290
|
R.shiftLeft = function(t) {
|
|
1291
|
-
return
|
|
1291
|
+
return qt(t) && (t = t.toInt()), (t &= 63) === 0 ? this : t < 32 ? lt(this.low << t, this.high << t | this.low >>> 32 - t, this.unsigned) : lt(0, this.low << t - 32, this.unsigned);
|
|
1292
1292
|
};
|
|
1293
1293
|
R.shl = R.shiftLeft;
|
|
1294
1294
|
R.shiftRight = function(t) {
|
|
1295
|
-
return
|
|
1295
|
+
return qt(t) && (t = t.toInt()), (t &= 63) === 0 ? this : t < 32 ? lt(this.low >>> t | this.high << 32 - t, this.high >> t, this.unsigned) : lt(this.high >> t - 32, this.high >= 0 ? 0 : -1, this.unsigned);
|
|
1296
1296
|
};
|
|
1297
1297
|
R.shr = R.shiftRight;
|
|
1298
1298
|
R.shiftRightUnsigned = function(t) {
|
|
1299
|
-
if (
|
|
1299
|
+
if (qt(t) && (t = t.toInt()), t &= 63, t === 0)
|
|
1300
1300
|
return this;
|
|
1301
1301
|
var e = this.high;
|
|
1302
1302
|
if (t < 32) {
|
|
@@ -1403,7 +1403,7 @@ function Ia(n, t) {
|
|
|
1403
1403
|
function bt(n, t) {
|
|
1404
1404
|
return t === 0 ? n : n.shru(t).or(n.shl(64 - t));
|
|
1405
1405
|
}
|
|
1406
|
-
function
|
|
1406
|
+
function We(n, t, e = Br("9ddfea08eb382d69")) {
|
|
1407
1407
|
let s = n.xor(t).mul(e);
|
|
1408
1408
|
s = s.xor(s.shru(47));
|
|
1409
1409
|
let r = t.xor(s).mul(e);
|
|
@@ -1420,11 +1420,11 @@ function Fs(n, t, e, s) {
|
|
|
1420
1420
|
function mp(n, t = n.length) {
|
|
1421
1421
|
if (t >= 8) {
|
|
1422
1422
|
const e = _t.add(t * 2), s = rt(n, 0).add(_t), r = rt(n, t - 8), o = bt(r, 37).mul(e).add(s), i = bt(s, 25).add(r).mul(e);
|
|
1423
|
-
return
|
|
1423
|
+
return We(o, i, e);
|
|
1424
1424
|
}
|
|
1425
1425
|
if (t >= 4) {
|
|
1426
1426
|
const e = _t.add(t * 2), s = Ia(n, 0);
|
|
1427
|
-
return
|
|
1427
|
+
return We(s.shl(3).add(t), Ia(n, t - 4), e);
|
|
1428
1428
|
}
|
|
1429
1429
|
if (t > 0) {
|
|
1430
1430
|
const e = n[0], s = n[t >> 1], r = n[t - 1], o = e + (s << 8), i = t + (r << 2);
|
|
@@ -1434,11 +1434,11 @@ function mp(n, t = n.length) {
|
|
|
1434
1434
|
}
|
|
1435
1435
|
function gp(n, t = n.length) {
|
|
1436
1436
|
const e = _t.add(t * 2), s = rt(n, 0).mul(Je), r = rt(n, 8), o = rt(n, t - 8).mul(e), i = rt(n, t - 16).mul(_t);
|
|
1437
|
-
return
|
|
1437
|
+
return We(bt(s.add(r), 43).add(bt(o, 30)).add(i), s.add(bt(r.add(_t), 18)).add(o), e);
|
|
1438
1438
|
}
|
|
1439
1439
|
function bp(n, t = n.length) {
|
|
1440
|
-
const e = _t.add(t * 2), s = rt(n, 0).mul(_t), r = rt(n, 8), o = rt(n, t - 8).mul(e), i = rt(n, t - 16).mul(_t), a = bt(s.add(r), 43).add(bt(o, 30)).add(i), l =
|
|
1441
|
-
return
|
|
1440
|
+
const e = _t.add(t * 2), s = rt(n, 0).mul(_t), r = rt(n, 8), o = rt(n, t - 8).mul(e), i = rt(n, t - 16).mul(_t), a = bt(s.add(r), 43).add(bt(o, 30)).add(i), l = We(a, s.add(bt(r.add(_t), 18)).add(o), e), u = rt(n, 16).mul(e), c = rt(n, 24), h = a.add(rt(n, t - 32)).mul(e), f = l.add(rt(n, t - 24)).mul(e);
|
|
1441
|
+
return We(bt(u.add(c), 43).add(bt(h, 30)).add(f), u.add(bt(c.add(s), 18)).add(h), e);
|
|
1442
1442
|
}
|
|
1443
1443
|
function yp(n, t = n.length) {
|
|
1444
1444
|
const e = Ze.fromNumber(81, !0);
|
|
@@ -1454,7 +1454,7 @@ function yp(n, t = n.length) {
|
|
|
1454
1454
|
s = bt(s.add(r).add(i[0]).add(rt(n, l + 8)), 37).mul(Je), r = bt(r.add(i[1]).add(rt(n, l + 48)), 42).mul(Je), s = s.xor(a[1]), r = r.add(i[0]).add(rt(n, l + 40)), o = bt(o.add(a[0]), 33).mul(Je), i = Fs(n, l, i[1].mul(Je), s.add(a[0])), a = Fs(n, l + 32, o.add(a[1]), r.add(rt(n, l + 16))), [o, s] = [s, o], l += 64;
|
|
1455
1455
|
while (l !== u);
|
|
1456
1456
|
const h = Je.add(o.and(255).shl(1));
|
|
1457
|
-
return l = c, a[0] = a[0].add(t - 1 & 63), i[0] = i[0].add(a[0]), a[0] = a[0].add(i[0]), s = bt(s.add(r).add(i[0]).add(rt(n, l + 8)), 37).mul(h), r = bt(r.add(i[1]).add(rt(n, l + 48)), 42).mul(h), s = s.xor(a[1].mul(9)), r = r.add(i[0].mul(9).add(rt(n, l + 40))), o = bt(o.add(a[0]), 33).mul(h), i = Fs(n, l, i[1].mul(h), s.add(a[0])), a = Fs(n, l + 32, o.add(a[1]), r.add(rt(n, l + 16))), [o, s] = [s, o],
|
|
1457
|
+
return l = c, a[0] = a[0].add(t - 1 & 63), i[0] = i[0].add(a[0]), a[0] = a[0].add(i[0]), s = bt(s.add(r).add(i[0]).add(rt(n, l + 8)), 37).mul(h), r = bt(r.add(i[1]).add(rt(n, l + 48)), 42).mul(h), s = s.xor(a[1].mul(9)), r = r.add(i[0].mul(9).add(rt(n, l + 40))), o = bt(o.add(a[0]), 33).mul(h), i = Fs(n, l, i[1].mul(h), s.add(a[0])), a = Fs(n, l + 32, o.add(a[1]), r.add(rt(n, l + 16))), [o, s] = [s, o], We(We(i[0], a[0], h).add(No(r).mul(lu)).add(o), We(i[1], a[1], h).add(s), h);
|
|
1458
1458
|
}
|
|
1459
1459
|
/**
|
|
1460
1460
|
* @license
|
|
@@ -1495,7 +1495,7 @@ function Fr(n, t) {
|
|
|
1495
1495
|
} else
|
|
1496
1496
|
throw new Error(`Unknown data type ${t}`);
|
|
1497
1497
|
}
|
|
1498
|
-
function
|
|
1498
|
+
function On() {
|
|
1499
1499
|
return W().platform.now();
|
|
1500
1500
|
}
|
|
1501
1501
|
function nn(n, t = "utf-8") {
|
|
@@ -1548,14 +1548,14 @@ class Sp {
|
|
|
1548
1548
|
r = s();
|
|
1549
1549
|
};
|
|
1550
1550
|
let i;
|
|
1551
|
-
const a =
|
|
1551
|
+
const a = On();
|
|
1552
1552
|
if (this.backendTimer.timerAvailable())
|
|
1553
1553
|
i = this.backendTimer.time(o);
|
|
1554
1554
|
else {
|
|
1555
1555
|
o();
|
|
1556
1556
|
for (const u of r)
|
|
1557
1557
|
u.dataSync();
|
|
1558
|
-
i = Promise.resolve({ kernelMs:
|
|
1558
|
+
i = Promise.resolve({ kernelMs: On() - a });
|
|
1559
1559
|
}
|
|
1560
1560
|
if (W().getBool("CHECK_COMPUTATION_FOR_ERRORS"))
|
|
1561
1561
|
for (let u = 0; u < r.length; u++) {
|
|
@@ -1709,7 +1709,7 @@ function Ap(n, t, e, s) {
|
|
|
1709
1709
|
* limitations under the License.
|
|
1710
1710
|
* =============================================================================
|
|
1711
1711
|
*/
|
|
1712
|
-
const Aa = 20,
|
|
1712
|
+
const Aa = 20, ss = 3, oo = 7;
|
|
1713
1713
|
function Ep(n, t, e, s) {
|
|
1714
1714
|
const r = Ht(t), o = Cp(n, t, e, r), i = t.length, a = Qs(n, t, e, r, o), l = ["Tensor"];
|
|
1715
1715
|
return s && (l.push(` dtype: ${e}`), l.push(` rank: ${i}`), l.push(` shape: [${t}]`), l.push(" values:")), l.push(a.map((u) => " " + u).join(`
|
|
@@ -1717,16 +1717,16 @@ function Ep(n, t, e, s) {
|
|
|
1717
1717
|
`);
|
|
1718
1718
|
}
|
|
1719
1719
|
function Cp(n, t, e, s) {
|
|
1720
|
-
const r = U(t), o = s[s.length - 1], i = new Array(o).fill(0), a = t.length, l = e === "complex64" ?
|
|
1720
|
+
const r = U(t), o = s[s.length - 1], i = new Array(o).fill(0), a = t.length, l = e === "complex64" ? us(n) : n;
|
|
1721
1721
|
if (a > 1)
|
|
1722
1722
|
for (let u = 0; u < r / o; u++) {
|
|
1723
1723
|
const c = u * o;
|
|
1724
1724
|
for (let h = 0; h < o; h++)
|
|
1725
|
-
i[h] = Math.max(i[h],
|
|
1725
|
+
i[h] = Math.max(i[h], ls(l[c + h], 0, e).length);
|
|
1726
1726
|
}
|
|
1727
1727
|
return i;
|
|
1728
1728
|
}
|
|
1729
|
-
function
|
|
1729
|
+
function ls(n, t, e) {
|
|
1730
1730
|
let s;
|
|
1731
1731
|
return Array.isArray(n) ? s = `${parseFloat(n[0].toFixed(oo))} + ${parseFloat(n[1].toFixed(oo))}j` : Or(n) ? s = `'${n}'` : e === "bool" ? s = cu(n) : s = parseFloat(n.toFixed(oo)).toString(), Zs(s, t);
|
|
1732
1732
|
}
|
|
@@ -1737,26 +1737,26 @@ function Qs(n, t, e, s, r, o = !0) {
|
|
|
1737
1737
|
const i = e === "complex64" ? 2 : 1, a = t[0], l = t.length;
|
|
1738
1738
|
if (l === 0) {
|
|
1739
1739
|
if (e === "complex64") {
|
|
1740
|
-
const g =
|
|
1741
|
-
return [
|
|
1740
|
+
const g = us(n);
|
|
1741
|
+
return [ls(g[0], 0, e)];
|
|
1742
1742
|
}
|
|
1743
1743
|
return e === "bool" ? [cu(n[0])] : [n[0].toString()];
|
|
1744
1744
|
}
|
|
1745
1745
|
if (l === 1) {
|
|
1746
1746
|
if (a > Aa) {
|
|
1747
|
-
const m =
|
|
1748
|
-
let b = Array.from(n.slice(0, m)), y = Array.from(n.slice((a -
|
|
1749
|
-
return e === "complex64" && (b =
|
|
1750
|
-
"[" + b.map((S, x) =>
|
|
1747
|
+
const m = ss * i;
|
|
1748
|
+
let b = Array.from(n.slice(0, m)), y = Array.from(n.slice((a - ss) * i, a * i));
|
|
1749
|
+
return e === "complex64" && (b = us(b), y = us(y)), [
|
|
1750
|
+
"[" + b.map((S, x) => ls(S, r[x], e)).join(", ") + ", ..., " + y.map((S, x) => ls(S, r[a - ss + x], e)).join(", ") + "]"
|
|
1751
1751
|
];
|
|
1752
1752
|
}
|
|
1753
1753
|
return [
|
|
1754
|
-
"[" + (e === "complex64" ?
|
|
1754
|
+
"[" + (e === "complex64" ? us(n) : Array.from(n)).map((m, b) => ls(m, r[b], e)).join(", ") + "]"
|
|
1755
1755
|
];
|
|
1756
1756
|
}
|
|
1757
1757
|
const u = t.slice(1), c = s.slice(1), h = s[0] * i, f = [];
|
|
1758
1758
|
if (a > Aa) {
|
|
1759
|
-
for (let g = 0; g <
|
|
1759
|
+
for (let g = 0; g < ss; g++) {
|
|
1760
1760
|
const m = g * h, b = m + h;
|
|
1761
1761
|
f.push(...Qs(
|
|
1762
1762
|
n.slice(m, b),
|
|
@@ -1769,7 +1769,7 @@ function Qs(n, t, e, s, r, o = !0) {
|
|
|
1769
1769
|
));
|
|
1770
1770
|
}
|
|
1771
1771
|
f.push("...");
|
|
1772
|
-
for (let g = a -
|
|
1772
|
+
for (let g = a - ss; g < a; g++) {
|
|
1773
1773
|
const m = g * h, b = m + h;
|
|
1774
1774
|
f.push(...Qs(
|
|
1775
1775
|
n.slice(m, b),
|
|
@@ -1805,7 +1805,7 @@ function Qs(n, t, e, s, r, o = !0) {
|
|
|
1805
1805
|
`;
|
|
1806
1806
|
return f[f.length - 1] = " " + f[f.length - 1] + "]" + (o ? "" : p), f;
|
|
1807
1807
|
}
|
|
1808
|
-
function
|
|
1808
|
+
function us(n) {
|
|
1809
1809
|
const t = [];
|
|
1810
1810
|
for (let e = 0; e < n.length; e += 2)
|
|
1811
1811
|
t.push([n[e], n[e + 1]]);
|
|
@@ -1904,12 +1904,12 @@ class ar {
|
|
|
1904
1904
|
return he().makeTensor(this.values, this.shape, this.dtype);
|
|
1905
1905
|
}
|
|
1906
1906
|
}
|
|
1907
|
-
let he = null,
|
|
1907
|
+
let he = null, _n = null;
|
|
1908
1908
|
function kp(n) {
|
|
1909
1909
|
he = n;
|
|
1910
1910
|
}
|
|
1911
1911
|
function _p(n) {
|
|
1912
|
-
|
|
1912
|
+
_n = n;
|
|
1913
1913
|
}
|
|
1914
1914
|
class Et {
|
|
1915
1915
|
constructor(t, e, s, r) {
|
|
@@ -1925,14 +1925,14 @@ class Et {
|
|
|
1925
1925
|
*/
|
|
1926
1926
|
async buffer() {
|
|
1927
1927
|
const t = await this.data();
|
|
1928
|
-
return
|
|
1928
|
+
return _n.buffer(this.shape, this.dtype, t);
|
|
1929
1929
|
}
|
|
1930
1930
|
/**
|
|
1931
1931
|
* Returns a `tf.TensorBuffer` that holds the underlying data.
|
|
1932
1932
|
* @doc {heading: 'Tensors', subheading: 'Classes'}
|
|
1933
1933
|
*/
|
|
1934
1934
|
bufferSync() {
|
|
1935
|
-
return
|
|
1935
|
+
return _n.buffer(this.shape, this.dtype, this.dataSync());
|
|
1936
1936
|
}
|
|
1937
1937
|
/**
|
|
1938
1938
|
* Returns the tensor data as a nested array. The transfer of data is done
|
|
@@ -2056,14 +2056,14 @@ class Et {
|
|
|
2056
2056
|
* @doc {heading: 'Tensors', subheading: 'Classes'}
|
|
2057
2057
|
*/
|
|
2058
2058
|
print(t = !1) {
|
|
2059
|
-
return
|
|
2059
|
+
return _n.print(this, t);
|
|
2060
2060
|
}
|
|
2061
2061
|
/**
|
|
2062
2062
|
* Returns a copy of the tensor. See `tf.clone` for details.
|
|
2063
2063
|
* @doc {heading: 'Tensors', subheading: 'Classes'}
|
|
2064
2064
|
*/
|
|
2065
2065
|
clone() {
|
|
2066
|
-
return this.throwIfDisposed(),
|
|
2066
|
+
return this.throwIfDisposed(), _n.clone(this);
|
|
2067
2067
|
}
|
|
2068
2068
|
/**
|
|
2069
2069
|
* Returns a human-readable description of the tensor. Useful for logging.
|
|
@@ -2075,7 +2075,7 @@ class Et {
|
|
|
2075
2075
|
return Ep(e, this.shape, this.dtype, t);
|
|
2076
2076
|
}
|
|
2077
2077
|
cast(t) {
|
|
2078
|
-
return this.throwIfDisposed(),
|
|
2078
|
+
return this.throwIfDisposed(), _n.cast(this, t);
|
|
2079
2079
|
}
|
|
2080
2080
|
variable(t = !0, e, s) {
|
|
2081
2081
|
return this.throwIfDisposed(), he().makeVariable(this, t, e, s);
|
|
@@ -2258,7 +2258,7 @@ class Ca {
|
|
|
2258
2258
|
this.registeredVariables[t].dispose();
|
|
2259
2259
|
}
|
|
2260
2260
|
}
|
|
2261
|
-
class
|
|
2261
|
+
class Bn {
|
|
2262
2262
|
constructor(t) {
|
|
2263
2263
|
this.ENV = t, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new Ca();
|
|
2264
2264
|
}
|
|
@@ -2306,7 +2306,7 @@ class On {
|
|
|
2306
2306
|
return t in this.registryFactory ? this.registryFactory[t].factory : null;
|
|
2307
2307
|
}
|
|
2308
2308
|
registerBackend(t, e, s = 1) {
|
|
2309
|
-
return t in this.registryFactory ? (
|
|
2309
|
+
return t in this.registryFactory ? (kn(`${t} backend was already registered. Reusing existing backend factory.`), !1) : (this.registryFactory[t] = { factory: e, priority: s }, !0);
|
|
2310
2310
|
}
|
|
2311
2311
|
async setBackend(t) {
|
|
2312
2312
|
if (this.registryFactory[t] == null)
|
|
@@ -2342,12 +2342,12 @@ class On {
|
|
|
2342
2342
|
try {
|
|
2343
2343
|
const s = e.factory();
|
|
2344
2344
|
if (s && !(s instanceof Fl) && typeof s.then == "function") {
|
|
2345
|
-
const r = ++this.pendingBackendInitId, o = s.then((i) => r < this.pendingBackendInitId ? !1 : (this.registry[t] = i, this.pendingBackendInit = null, !0)).catch((i) => (r < this.pendingBackendInitId || (this.pendingBackendInit = null,
|
|
2345
|
+
const r = ++this.pendingBackendInitId, o = s.then((i) => r < this.pendingBackendInitId ? !1 : (this.registry[t] = i, this.pendingBackendInit = null, !0)).catch((i) => (r < this.pendingBackendInitId || (this.pendingBackendInit = null, kn(`Initialization of backend ${t} failed`), kn(i.stack || i.message)), !1));
|
|
2346
2346
|
return this.pendingBackendInit = o, { success: o, asyncInit: !0 };
|
|
2347
2347
|
} else
|
|
2348
2348
|
return this.registry[t] = s, { success: !0, asyncInit: !1 };
|
|
2349
2349
|
} catch (s) {
|
|
2350
|
-
return
|
|
2350
|
+
return kn(`Initialization of backend ${t} failed`), kn(s.stack || s.message), { success: !1, asyncInit: !1 };
|
|
2351
2351
|
}
|
|
2352
2352
|
}
|
|
2353
2353
|
removeBackend(t) {
|
|
@@ -2399,10 +2399,10 @@ class On {
|
|
|
2399
2399
|
}
|
|
2400
2400
|
}
|
|
2401
2401
|
nextTensorId() {
|
|
2402
|
-
return
|
|
2402
|
+
return Bn.nextTensorId++;
|
|
2403
2403
|
}
|
|
2404
2404
|
nextVariableId() {
|
|
2405
|
-
return
|
|
2405
|
+
return Bn.nextVariableId++;
|
|
2406
2406
|
}
|
|
2407
2407
|
/**
|
|
2408
2408
|
* This method is called instead of the public-facing tensor.clone() when
|
|
@@ -2646,7 +2646,7 @@ class On {
|
|
|
2646
2646
|
const a = { id: this.state.nextTapeNodeId++, kernelName: t, inputs: e, outputs: s, saved: o }, l = ba(t);
|
|
2647
2647
|
l != null && (r = l.gradFunc), r != null && (a.gradient = (u) => (u = u.map((c, h) => {
|
|
2648
2648
|
if (c == null) {
|
|
2649
|
-
const f = s[h], d =
|
|
2649
|
+
const f = s[h], d = je(f.size, f.dtype);
|
|
2650
2650
|
return this.makeTensor(d, f.shape, f.dtype);
|
|
2651
2651
|
}
|
|
2652
2652
|
return c;
|
|
@@ -2752,8 +2752,8 @@ class On {
|
|
|
2752
2752
|
return this.state.tensorInfo.get(t).backend.readToGPU(t, e);
|
|
2753
2753
|
}
|
|
2754
2754
|
async time(t) {
|
|
2755
|
-
const e =
|
|
2756
|
-
return s.wallMs =
|
|
2755
|
+
const e = On(), s = await this.backend.time(t);
|
|
2756
|
+
return s.wallMs = On() - e, s;
|
|
2757
2757
|
}
|
|
2758
2758
|
/**
|
|
2759
2759
|
* Tracks a Tensor in the current scope to be automatically cleaned up
|
|
@@ -2778,8 +2778,8 @@ class On {
|
|
|
2778
2778
|
this.backendName = null, this.backendInstance = null, this.pendingBackendInit = null;
|
|
2779
2779
|
}
|
|
2780
2780
|
}
|
|
2781
|
-
|
|
2782
|
-
|
|
2781
|
+
Bn.nextTensorId = 0;
|
|
2782
|
+
Bn.nextVariableId = 0;
|
|
2783
2783
|
function Rp(n) {
|
|
2784
2784
|
const t = Wl(U(n), "float32");
|
|
2785
2785
|
return A.makeTensor(t, n, "float32");
|
|
@@ -2788,7 +2788,7 @@ function gu() {
|
|
|
2788
2788
|
const n = Vl();
|
|
2789
2789
|
if (n._tfengine == null) {
|
|
2790
2790
|
const t = new Pf(n);
|
|
2791
|
-
n._tfengine = new
|
|
2791
|
+
n._tfengine = new Bn(t);
|
|
2792
2792
|
}
|
|
2793
2793
|
return Bf(n._tfengine.ENV), kp(() => n._tfengine), n._tfengine;
|
|
2794
2794
|
}
|
|
@@ -2850,7 +2850,7 @@ function ka(n, t, e, s) {
|
|
|
2850
2850
|
function v(n, t, e, s = "numeric") {
|
|
2851
2851
|
if (n instanceof hu())
|
|
2852
2852
|
return ka(s, n.dtype, t, e), n;
|
|
2853
|
-
let r =
|
|
2853
|
+
let r = Cs(n);
|
|
2854
2854
|
if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), ka(s, r, t, e), n == null || !se(n) && !Array.isArray(n) && typeof n != "number" && typeof n != "boolean" && typeof n != "string") {
|
|
2855
2855
|
const l = n == null ? "null" : n.constructor.name;
|
|
2856
2856
|
throw new Error(`Argument '${t}' passed to '${e}' must be a Tensor or TensorLike, but got '${l}'`);
|
|
@@ -2883,7 +2883,7 @@ function yu(n, t, e, s = "numeric") {
|
|
|
2883
2883
|
*/
|
|
2884
2884
|
function Ur(n, t, e, s) {
|
|
2885
2885
|
if (s == null)
|
|
2886
|
-
s =
|
|
2886
|
+
s = Cs(n);
|
|
2887
2887
|
else if (s === "complex64")
|
|
2888
2888
|
throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");
|
|
2889
2889
|
if (du(n) || fu(n)) {
|
|
@@ -3083,7 +3083,7 @@ function Gp(n, t, e) {
|
|
|
3083
3083
|
const s = v(n, "x", "slice4d");
|
|
3084
3084
|
return w(s.rank === 4, () => `slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`), At(s, t, e);
|
|
3085
3085
|
}
|
|
3086
|
-
const
|
|
3086
|
+
const ys = /* @__PURE__ */ k({ slice4d_: Gp });
|
|
3087
3087
|
/**
|
|
3088
3088
|
* @license
|
|
3089
3089
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3213,7 +3213,7 @@ function Yp(n, t) {
|
|
|
3213
3213
|
return A.runKernel(Kf, r);
|
|
3214
3214
|
}
|
|
3215
3215
|
const hi = /* @__PURE__ */ k({ complex_: Yp });
|
|
3216
|
-
class
|
|
3216
|
+
class Vn {
|
|
3217
3217
|
/**
|
|
3218
3218
|
* Concatenate a number of ArrayBuffers into one.
|
|
3219
3219
|
*
|
|
@@ -3222,7 +3222,7 @@ class Gn {
|
|
|
3222
3222
|
* @returns Result of concatenating `buffers` in order.
|
|
3223
3223
|
*/
|
|
3224
3224
|
static join(t) {
|
|
3225
|
-
return new
|
|
3225
|
+
return new Vn(t).slice();
|
|
3226
3226
|
}
|
|
3227
3227
|
constructor(t) {
|
|
3228
3228
|
if (this.shards = [], this.previousShardIndex = 0, t == null || (t instanceof Array || (t = [t]), t = t.map((s) => se(s) ? s.buffer : s), t.length === 0))
|
|
@@ -3309,7 +3309,7 @@ function C(n, t) {
|
|
|
3309
3309
|
function ut(n) {
|
|
3310
3310
|
pu(n).forEach((e) => e.dispose());
|
|
3311
3311
|
}
|
|
3312
|
-
function
|
|
3312
|
+
function Pn(n) {
|
|
3313
3313
|
return A.keep(n);
|
|
3314
3314
|
}
|
|
3315
3315
|
function Jp(n, t, e = 1) {
|
|
@@ -3399,7 +3399,7 @@ function em(n) {
|
|
|
3399
3399
|
return e.buffer;
|
|
3400
3400
|
}
|
|
3401
3401
|
function nm(n) {
|
|
3402
|
-
return
|
|
3402
|
+
return Vn.join(n);
|
|
3403
3403
|
}
|
|
3404
3404
|
function wu(n) {
|
|
3405
3405
|
if (n.modelTopology instanceof ArrayBuffer)
|
|
@@ -3409,7 +3409,7 @@ function wu(n) {
|
|
|
3409
3409
|
modelTopologyType: "JSON",
|
|
3410
3410
|
modelTopologyBytes: n.modelTopology == null ? 0 : Da(JSON.stringify(n.modelTopology)),
|
|
3411
3411
|
weightSpecsBytes: n.weightSpecs == null ? 0 : Da(JSON.stringify(n.weightSpecs)),
|
|
3412
|
-
weightDataBytes: n.weightData == null ? 0 : new
|
|
3412
|
+
weightDataBytes: n.weightData == null ? 0 : new Vn(n.weightData).byteLength
|
|
3413
3413
|
};
|
|
3414
3414
|
}
|
|
3415
3415
|
/**
|
|
@@ -3500,7 +3500,7 @@ const sm = (n) => kt.getSaveHandlers(n);
|
|
|
3500
3500
|
* limitations under the License.
|
|
3501
3501
|
* =============================================================================
|
|
3502
3502
|
*/
|
|
3503
|
-
const Mo = "tensorflowjs", Oo = 1, en = "models_store",
|
|
3503
|
+
const Mo = "tensorflowjs", Oo = 1, en = "models_store", ze = "model_info_store";
|
|
3504
3504
|
function xu() {
|
|
3505
3505
|
if (!W().getBool("IS_BROWSER"))
|
|
3506
3506
|
throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");
|
|
@@ -3511,7 +3511,7 @@ function xu() {
|
|
|
3511
3511
|
}
|
|
3512
3512
|
function Bo(n) {
|
|
3513
3513
|
const t = n.result;
|
|
3514
|
-
t.createObjectStore(en, { keyPath: "modelPath" }), t.createObjectStore(
|
|
3514
|
+
t.createObjectStore(en, { keyPath: "modelPath" }), t.createObjectStore(ze, { keyPath: "modelPath" });
|
|
3515
3515
|
}
|
|
3516
3516
|
class dn {
|
|
3517
3517
|
constructor(t) {
|
|
@@ -3554,9 +3554,9 @@ class dn {
|
|
|
3554
3554
|
s(u.result.modelArtifacts);
|
|
3555
3555
|
}, u.onerror = (c) => (i.close(), r(u.error)), a.oncomplete = () => i.close();
|
|
3556
3556
|
} else {
|
|
3557
|
-
e.weightData =
|
|
3558
|
-
const a = wu(e), l = i.transaction(
|
|
3559
|
-
let u = l.objectStore(
|
|
3557
|
+
e.weightData = Vn.join(e.weightData);
|
|
3558
|
+
const a = wu(e), l = i.transaction(ze, "readwrite");
|
|
3559
|
+
let u = l.objectStore(ze), c;
|
|
3560
3560
|
try {
|
|
3561
3561
|
c = u.put({ modelPath: this.modelPath, modelArtifactsInfo: a });
|
|
3562
3562
|
} catch (f) {
|
|
@@ -3577,7 +3577,7 @@ class dn {
|
|
|
3577
3577
|
return r(p);
|
|
3578
3578
|
}
|
|
3579
3579
|
d.onsuccess = () => s({ modelArtifactsInfo: a }), d.onerror = (p) => {
|
|
3580
|
-
u = l.objectStore(
|
|
3580
|
+
u = l.objectStore(ze);
|
|
3581
3581
|
const g = u.delete(this.modelPath);
|
|
3582
3582
|
g.onsuccess = () => (i.close(), r(d.error)), g.onerror = (m) => (i.close(), r(d.error));
|
|
3583
3583
|
};
|
|
@@ -3607,7 +3607,7 @@ class im {
|
|
|
3607
3607
|
return new Promise((t, e) => {
|
|
3608
3608
|
const s = this.indexedDB.open(Mo, Oo);
|
|
3609
3609
|
s.onupgradeneeded = () => Bo(s), s.onsuccess = () => {
|
|
3610
|
-
const r = s.result, o = r.transaction(
|
|
3610
|
+
const r = s.result, o = r.transaction(ze, "readonly"), a = o.objectStore(ze).getAll();
|
|
3611
3611
|
a.onsuccess = () => {
|
|
3612
3612
|
const l = {};
|
|
3613
3613
|
for (const u of a.result)
|
|
@@ -3621,7 +3621,7 @@ class im {
|
|
|
3621
3621
|
return t = om(t), new Promise((e, s) => {
|
|
3622
3622
|
const r = this.indexedDB.open(Mo, Oo);
|
|
3623
3623
|
r.onupgradeneeded = () => Bo(r), r.onsuccess = () => {
|
|
3624
|
-
const o = r.result, i = o.transaction(
|
|
3624
|
+
const o = r.result, i = o.transaction(ze, "readwrite"), a = i.objectStore(ze), l = a.get(t);
|
|
3625
3625
|
let u;
|
|
3626
3626
|
l.onsuccess = () => {
|
|
3627
3627
|
if (l.result == null)
|
|
@@ -3657,14 +3657,14 @@ class im {
|
|
|
3657
3657
|
* limitations under the License.
|
|
3658
3658
|
* =============================================================================
|
|
3659
3659
|
*/
|
|
3660
|
-
const Re = "/",
|
|
3660
|
+
const Re = "/", Tn = "tensorflowjs_models", $u = "info", am = "model_topology", lm = "weight_specs", um = "weight_data", cm = "model_metadata";
|
|
3661
3661
|
function vu(n) {
|
|
3662
3662
|
return {
|
|
3663
|
-
info: [
|
|
3664
|
-
topology: [
|
|
3665
|
-
weightSpecs: [
|
|
3666
|
-
weightData: [
|
|
3667
|
-
modelMetadata: [
|
|
3663
|
+
info: [Tn, n, $u].join(Re),
|
|
3664
|
+
topology: [Tn, n, am].join(Re),
|
|
3665
|
+
weightSpecs: [Tn, n, lm].join(Re),
|
|
3666
|
+
weightData: [Tn, n, um].join(Re),
|
|
3667
|
+
modelMetadata: [Tn, n, cm].join(Re)
|
|
3668
3668
|
};
|
|
3669
3669
|
}
|
|
3670
3670
|
function Iu(n) {
|
|
@@ -3701,7 +3701,7 @@ class pn {
|
|
|
3701
3701
|
if (t.modelTopology instanceof ArrayBuffer)
|
|
3702
3702
|
throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");
|
|
3703
3703
|
{
|
|
3704
|
-
const e = JSON.stringify(t.modelTopology), s = JSON.stringify(t.weightSpecs), r = wu(t), o =
|
|
3704
|
+
const e = JSON.stringify(t.modelTopology), s = JSON.stringify(t.weightSpecs), r = wu(t), o = Vn.join(t.weightData);
|
|
3705
3705
|
try {
|
|
3706
3706
|
this.LS.setItem(this.keys.info, JSON.stringify(r)), this.LS.setItem(this.keys.topology, e), this.LS.setItem(this.keys.weightSpecs, s), this.LS.setItem(this.keys.weightData, tm(o));
|
|
3707
3707
|
const i = {
|
|
@@ -3765,7 +3765,7 @@ class pm {
|
|
|
3765
3765
|
w(W().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), w(typeof window > "u" || typeof window.localStorage < "u", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage;
|
|
3766
3766
|
}
|
|
3767
3767
|
async listModels() {
|
|
3768
|
-
const t = {}, e =
|
|
3768
|
+
const t = {}, e = Tn + Re, s = Re + $u;
|
|
3769
3769
|
for (let r = 0; r < this.LS.length; ++r) {
|
|
3770
3770
|
const o = this.LS.key(r);
|
|
3771
3771
|
if (o.startsWith(e) && o.endsWith(s)) {
|
|
@@ -4209,7 +4209,7 @@ const ur = /* @__PURE__ */ k({ argMax_: _m });
|
|
|
4209
4209
|
* =============================================================================
|
|
4210
4210
|
*/
|
|
4211
4211
|
function Tm(n, t, e, s, r, o, i = "channelsLast") {
|
|
4212
|
-
const [a, l] =
|
|
4212
|
+
const [a, l] = ws(t);
|
|
4213
4213
|
let u;
|
|
4214
4214
|
if (i === "channelsLast")
|
|
4215
4215
|
u = [a, l, n[3], n[3]];
|
|
@@ -4227,7 +4227,7 @@ function di(n, t, e, s, r, o, i = !1, a = "channelsLast") {
|
|
|
4227
4227
|
[l, h, u, c] = n;
|
|
4228
4228
|
else
|
|
4229
4229
|
throw new Error(`Unknown dataFormat ${a}`);
|
|
4230
|
-
const [f, d, , p] = t, [g, m] =
|
|
4230
|
+
const [f, d, , p] = t, [g, m] = ws(e), [b, y] = ws(s), S = Fo(f, b), x = Fo(d, y), { padInfo: $, outHeight: E, outWidth: D } = Rm(r, u, c, g, m, S, x, o, a), _ = i ? p * h : p;
|
|
4231
4231
|
let T;
|
|
4232
4232
|
return a === "channelsFirst" ? T = [l, _, E, D] : a === "channelsLast" && (T = [l, E, D, _]), {
|
|
4233
4233
|
batchSize: l,
|
|
@@ -4261,7 +4261,7 @@ function Dm(n, t, e, s = 1) {
|
|
|
4261
4261
|
const r = Fo(t, s);
|
|
4262
4262
|
return Math.floor((n[0] * (e - 1) - e + r) / 2);
|
|
4263
4263
|
}
|
|
4264
|
-
function
|
|
4264
|
+
function ws(n) {
|
|
4265
4265
|
return typeof n == "number" ? [n, n, n] : n.length === 2 ? [n[0], n[1], 1] : n;
|
|
4266
4266
|
}
|
|
4267
4267
|
function Fo(n, t) {
|
|
@@ -4301,14 +4301,14 @@ function cr(n, t) {
|
|
|
4301
4301
|
}
|
|
4302
4302
|
}
|
|
4303
4303
|
function zo(n) {
|
|
4304
|
-
const [t, e, s] =
|
|
4304
|
+
const [t, e, s] = ws(n);
|
|
4305
4305
|
return t === 1 && e === 1 && s === 1;
|
|
4306
4306
|
}
|
|
4307
|
-
function
|
|
4307
|
+
function qn(n, t) {
|
|
4308
4308
|
return zo(n) || zo(t);
|
|
4309
4309
|
}
|
|
4310
|
-
function
|
|
4311
|
-
return
|
|
4310
|
+
function Fn(n) {
|
|
4311
|
+
return ws(n).every((t) => t > 0);
|
|
4312
4312
|
}
|
|
4313
4313
|
function Pm(n) {
|
|
4314
4314
|
if (n === "NHWC")
|
|
@@ -4372,7 +4372,7 @@ const L = /* @__PURE__ */ k({ reshape_: Lm });
|
|
|
4372
4372
|
*/
|
|
4373
4373
|
function Mm(n, t, e, s, r) {
|
|
4374
4374
|
const o = v(n, "x", "avgPool", "float32"), i = 1;
|
|
4375
|
-
w(
|
|
4375
|
+
w(qn(e, i), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${e} and dilations '${i}'`);
|
|
4376
4376
|
let a = o, l = !1;
|
|
4377
4377
|
o.rank === 3 && (l = !0, a = L(o, [1, o.shape[0], o.shape[1], o.shape[2]])), w(a.rank === 4, () => `Error in avgPool: x must be rank 4 but got rank ${a.rank}.`), _e("avgPool", s, r);
|
|
4378
4378
|
const u = { x: a }, c = { filterSize: t, strides: e, pad: s, dimRoundingMode: r };
|
|
@@ -4549,7 +4549,7 @@ const er = /* @__PURE__ */ k({ broadcastTo_: qm });
|
|
|
4549
4549
|
* =============================================================================
|
|
4550
4550
|
*/
|
|
4551
4551
|
function Wr(n, t, e) {
|
|
4552
|
-
Me(n), e = e ||
|
|
4552
|
+
Me(n), e = e || Cs(t);
|
|
4553
4553
|
const s = { shape: n, value: t, dtype: e };
|
|
4554
4554
|
return A.runKernel(cd, {}, s);
|
|
4555
4555
|
}
|
|
@@ -4598,7 +4598,7 @@ function Hm(n, t, e, s, r = "NHWC", o = [1, 1], i) {
|
|
|
4598
4598
|
let u = a, c = !1;
|
|
4599
4599
|
a.rank === 3 && (c = !0, u = L(a, [1, a.shape[0], a.shape[1], a.shape[2]])), w(u.rank === 4, () => `Error in conv2d: input must be rank 4, but got rank ${u.rank}.`), w(l.rank === 4, () => `Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`), _e("conv2d", s, i);
|
|
4600
4600
|
const h = r === "NHWC" ? u.shape[3] : u.shape[1];
|
|
4601
|
-
w(h === l.shape[2], () => `Error in conv2d: depth of input (${h}) must match input depth for filter ${l.shape[2]}.`), w(
|
|
4601
|
+
w(h === l.shape[2], () => `Error in conv2d: depth of input (${h}) must match input depth for filter ${l.shape[2]}.`), w(qn(e, o), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${e} and dilations '${o}'`), w(Fn(o), () => "Error in conv2D: Dilated rates should be larger than 0."), w(Fn(e), () => "Error in conv2D: Strides should be larger than 0.");
|
|
4602
4602
|
const f = { x: u, filter: l }, d = { strides: e, pad: s, dataFormat: r, dilations: o, dimRoundingMode: i }, p = A.runKernel(Xf, f, d);
|
|
4603
4603
|
return c ? L(p, [p.shape[1], p.shape[2], p.shape[3]]) : p;
|
|
4604
4604
|
}
|
|
@@ -4606,7 +4606,7 @@ const gi = /* @__PURE__ */ k({ conv2d_: Hm });
|
|
|
4606
4606
|
function Km(n, t, e, s, r = "NWC", o = 1, i) {
|
|
4607
4607
|
const a = v(n, "x", "conv1d"), l = v(t, "filter", "conv1d");
|
|
4608
4608
|
let u = a, c = !1;
|
|
4609
|
-
a.rank === 2 && (c = !0, u = L(a, [1, a.shape[0], a.shape[1]])), w(u.rank === 3, () => `Error in conv1d: input must be rank 3, but got rank ${u.rank}.`), w(l.rank === 3, () => `Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`), _e("conv1d", s, i), w(u.shape[2] === l.shape[1], () => `Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${l.shape[1]}.`), w(
|
|
4609
|
+
a.rank === 2 && (c = !0, u = L(a, [1, a.shape[0], a.shape[1]])), w(u.rank === 3, () => `Error in conv1d: input must be rank 3, but got rank ${u.rank}.`), w(l.rank === 3, () => `Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`), _e("conv1d", s, i), w(u.shape[2] === l.shape[1], () => `Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${l.shape[1]}.`), w(qn(e, o), () => `Error in conv1D: Either stride or dilation must be 1. Got stride ${e} and dilation '${o}'`), w(Fn(o), () => "Error in conv1D: Dilated rates should be larger than 0."), w(Fn(e), () => "Error in conv1D: Stride should be larger than 0."), w(r === "NWC", () => `Error in conv1d: got dataFormat of ${r} but only NWC is currently supported.`);
|
|
4610
4610
|
const h = L(l, [1, l.shape[0], l.shape[1], l.shape[2]]), f = L(u, [u.shape[0], 1, u.shape[1], u.shape[2]]), m = gi(f, h, [1, e], s, "NHWC", [1, o], i);
|
|
4611
4611
|
return c ? L(m, [m.shape[2], m.shape[3]]) : L(m, [m.shape[0], m.shape[2], m.shape[3]]);
|
|
4612
4612
|
}
|
|
@@ -4661,7 +4661,7 @@ const Zm = /* @__PURE__ */ k({ conv2dTranspose_: Jm });
|
|
|
4661
4661
|
function Qm(n, t, e, s, r = "NDHWC", o = [1, 1, 1]) {
|
|
4662
4662
|
const i = v(n, "x", "conv3d"), a = v(t, "filter", "conv3d");
|
|
4663
4663
|
let l = i, u = !1;
|
|
4664
|
-
i.rank === 4 && (u = !0, l = L(i, [1, i.shape[0], i.shape[1], i.shape[2], i.shape[3]])), w(l.rank === 5, () => `Error in conv3d: input must be rank 5, but got rank ${l.rank}.`), w(a.rank === 5, () => `Error in conv3d: filter must be rank 5, but got rank ${a.rank}.`), w(l.shape[4] === a.shape[3], () => `Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${a.shape[3]}.`), w(
|
|
4664
|
+
i.rank === 4 && (u = !0, l = L(i, [1, i.shape[0], i.shape[1], i.shape[2], i.shape[3]])), w(l.rank === 5, () => `Error in conv3d: input must be rank 5, but got rank ${l.rank}.`), w(a.rank === 5, () => `Error in conv3d: filter must be rank 5, but got rank ${a.rank}.`), w(l.shape[4] === a.shape[3], () => `Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${a.shape[3]}.`), w(qn(e, o), () => `Error in conv3D: Either strides or dilations must be 1. Got strides ${e} and dilations '${o}'`), w(r === "NDHWC", () => `Error in conv3d: got dataFormat of ${r} but only NDHWC is currently supported.`), w(Fn(o), () => "Error in conv3D: Dilated rates should be larger than 0."), w(Fn(e), () => "Error in conv3D: Strides should be larger than 0.");
|
|
4665
4665
|
const c = { x: l, filter: a }, h = { strides: e, pad: s, dataFormat: r, dilations: o }, f = A.runKernel(Qf, c, h);
|
|
4666
4666
|
return u ? L(f, [f.shape[1], f.shape[2], f.shape[3], f.shape[4]]) : f;
|
|
4667
4667
|
}
|
|
@@ -4755,7 +4755,7 @@ function ag(n, t) {
|
|
|
4755
4755
|
}
|
|
4756
4756
|
return e;
|
|
4757
4757
|
}
|
|
4758
|
-
function
|
|
4758
|
+
function Wt(n, t) {
|
|
4759
4759
|
const e = Math.max(n.length, t.length), s = new Array(e);
|
|
4760
4760
|
for (let r = 0; r < e; r++) {
|
|
4761
4761
|
let o = n[n.length - r - 1];
|
|
@@ -4791,7 +4791,7 @@ function zt(n, t) {
|
|
|
4791
4791
|
*/
|
|
4792
4792
|
function lg(n, t) {
|
|
4793
4793
|
let e = v(n, "a", "equal", "string_or_numeric"), s = v(t, "b", "equal", "string_or_numeric");
|
|
4794
|
-
[e, s] = Pt(e, s),
|
|
4794
|
+
[e, s] = Pt(e, s), Wt(e.shape, s.shape);
|
|
4795
4795
|
const r = { a: e, b: s };
|
|
4796
4796
|
return A.runKernel(ad, r);
|
|
4797
4797
|
}
|
|
@@ -4813,7 +4813,7 @@ const mn = /* @__PURE__ */ k({ equal_: lg });
|
|
|
4813
4813
|
* =============================================================================
|
|
4814
4814
|
*/
|
|
4815
4815
|
function ug(n, t, e) {
|
|
4816
|
-
const s = v(t, "a", "where"), r = v(e, "b", "where"), o = v(n, "condition", "where", "bool"), i =
|
|
4816
|
+
const s = v(t, "a", "where"), r = v(e, "b", "where"), o = v(n, "condition", "where", "bool"), i = Wt(Wt(o.shape, s.shape), r.shape), a = er(o, i), l = er(s, i), u = er(r, i), c = {
|
|
4817
4817
|
condition: a,
|
|
4818
4818
|
t: l,
|
|
4819
4819
|
e: u
|
|
@@ -4862,7 +4862,7 @@ function hg(n, ...t) {
|
|
|
4862
4862
|
const e = t.map((r, o) => v(r, `tensors${o}`, "einsum")), s = { equation: n };
|
|
4863
4863
|
return A.runKernel(rd, e, s);
|
|
4864
4864
|
}
|
|
4865
|
-
const
|
|
4865
|
+
const rs = /* @__PURE__ */ k({ einsum_: hg });
|
|
4866
4866
|
/**
|
|
4867
4867
|
* @license
|
|
4868
4868
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -4984,7 +4984,7 @@ function wg(n, t = null, e = !1) {
|
|
|
4984
4984
|
const r = { x: v(n, "x", "max") }, o = { reductionIndices: t, keepDims: e };
|
|
4985
4985
|
return A.runKernel(Id, r, o);
|
|
4986
4986
|
}
|
|
4987
|
-
const
|
|
4987
|
+
const Ge = /* @__PURE__ */ k({ max_: wg });
|
|
4988
4988
|
/**
|
|
4989
4989
|
* @license
|
|
4990
4990
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -5093,7 +5093,7 @@ function vg(n) {
|
|
|
5093
5093
|
const t = v(n, "x", "square"), e = {};
|
|
5094
5094
|
return A.runKernel("Square", { x: t }, e);
|
|
5095
5095
|
}
|
|
5096
|
-
const
|
|
5096
|
+
const Ve = /* @__PURE__ */ k({ square_: vg });
|
|
5097
5097
|
/**
|
|
5098
5098
|
* @license
|
|
5099
5099
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -5138,7 +5138,7 @@ function Ag(n, t = "euclidean", e = null, s = !1) {
|
|
|
5138
5138
|
const r = Tu(n, t, e);
|
|
5139
5139
|
let o = r.shape;
|
|
5140
5140
|
if (s) {
|
|
5141
|
-
const i =
|
|
5141
|
+
const i = Es(e, n.shape);
|
|
5142
5142
|
o = _u(r.shape, i);
|
|
5143
5143
|
}
|
|
5144
5144
|
return L(r, o);
|
|
@@ -5152,7 +5152,7 @@ function Tu(n, t, e = null) {
|
|
|
5152
5152
|
if (t === 1)
|
|
5153
5153
|
return et(Nt(n), e);
|
|
5154
5154
|
if (t === 1 / 0)
|
|
5155
|
-
return
|
|
5155
|
+
return Ge(Nt(n), e);
|
|
5156
5156
|
if (t === -1 / 0)
|
|
5157
5157
|
return Pa(Nt(n), e);
|
|
5158
5158
|
if (t === "euclidean" || t === 2)
|
|
@@ -5161,13 +5161,13 @@ function Tu(n, t, e = null) {
|
|
|
5161
5161
|
}
|
|
5162
5162
|
if (Array.isArray(e) && e.length === 2) {
|
|
5163
5163
|
if (t === 1)
|
|
5164
|
-
return
|
|
5164
|
+
return Ge(et(Nt(n), e[0]), e[1] - 1);
|
|
5165
5165
|
if (t === 1 / 0)
|
|
5166
|
-
return
|
|
5166
|
+
return Ge(et(Nt(n), e[1]), e[0]);
|
|
5167
5167
|
if (t === -1 / 0)
|
|
5168
5168
|
return Pa(et(Nt(n), e[1]), e[0]);
|
|
5169
5169
|
if (t === "fro" || t === "euclidean")
|
|
5170
|
-
return de(et(
|
|
5170
|
+
return de(et(Ve(n), e));
|
|
5171
5171
|
throw new Error(`Error in norm: invalid ord value: ${t}`);
|
|
5172
5172
|
}
|
|
5173
5173
|
throw new Error(`Error in norm: invalid axis: ${e}`);
|
|
@@ -5339,11 +5339,11 @@ const Rg = /* @__PURE__ */ k({ gather_: Dg });
|
|
|
5339
5339
|
*/
|
|
5340
5340
|
function Pg(n, t) {
|
|
5341
5341
|
let e = v(n, "a", "greater", "string_or_numeric"), s = v(t, "b", "greater", "string_or_numeric");
|
|
5342
|
-
[e, s] = Pt(e, s),
|
|
5342
|
+
[e, s] = Pt(e, s), Wt(e.shape, s.shape);
|
|
5343
5343
|
const r = { a: e, b: s };
|
|
5344
5344
|
return A.runKernel(md, r);
|
|
5345
5345
|
}
|
|
5346
|
-
const
|
|
5346
|
+
const ks = /* @__PURE__ */ k({ greater_: Pg });
|
|
5347
5347
|
/**
|
|
5348
5348
|
* @license
|
|
5349
5349
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -5362,7 +5362,7 @@ const Cs = /* @__PURE__ */ k({ greater_: Pg });
|
|
|
5362
5362
|
*/
|
|
5363
5363
|
function Lg(n, t) {
|
|
5364
5364
|
let e = v(n, "a", "greaterEqual", "string_or_numeric"), s = v(t, "b", "greaterEqual", "string_or_numeric");
|
|
5365
|
-
[e, s] = Pt(e, s),
|
|
5365
|
+
[e, s] = Pt(e, s), Wt(e.shape, s.shape);
|
|
5366
5366
|
const r = { a: e, b: s };
|
|
5367
5367
|
return A.runKernel(gd, r);
|
|
5368
5368
|
}
|
|
@@ -5427,7 +5427,7 @@ const zg = /* @__PURE__ */ k({ leakyRelu_: Fg });
|
|
|
5427
5427
|
*/
|
|
5428
5428
|
function Ug(n, t) {
|
|
5429
5429
|
let e = v(n, "a", "less", "string_or_numeric"), s = v(t, "b", "less", "string_or_numeric");
|
|
5430
|
-
[e, s] = Pt(e, s),
|
|
5430
|
+
[e, s] = Pt(e, s), Wt(e.shape, s.shape);
|
|
5431
5431
|
const r = { a: e, b: s };
|
|
5432
5432
|
return A.runKernel(wd, r);
|
|
5433
5433
|
}
|
|
@@ -5450,7 +5450,7 @@ const La = /* @__PURE__ */ k({ less_: Ug });
|
|
|
5450
5450
|
*/
|
|
5451
5451
|
function Wg(n, t) {
|
|
5452
5452
|
let e = v(n, "a", "lessEqual", "string_or_numeric"), s = v(t, "b", "lessEqual", "string_or_numeric");
|
|
5453
|
-
[e, s] = Pt(e, s),
|
|
5453
|
+
[e, s] = Pt(e, s), Wt(e.shape, s.shape);
|
|
5454
5454
|
const r = { a: e, b: s };
|
|
5455
5455
|
return A.runKernel(xd, r);
|
|
5456
5456
|
}
|
|
@@ -5553,7 +5553,7 @@ function Hg(n) {
|
|
|
5553
5553
|
const e = { x: v(n, "x", "neg") };
|
|
5554
5554
|
return A.runKernel(Nd, e);
|
|
5555
5555
|
}
|
|
5556
|
-
const
|
|
5556
|
+
const jn = /* @__PURE__ */ k({ neg_: Hg });
|
|
5557
5557
|
/**
|
|
5558
5558
|
* @license
|
|
5559
5559
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -5619,7 +5619,7 @@ function Xg(n, t = -1) {
|
|
|
5619
5619
|
if (t === -1 && (t = e.rank - 1), t !== e.rank - 1)
|
|
5620
5620
|
throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${e.rank} and axis was ${t}`);
|
|
5621
5621
|
return Wo((r, o) => {
|
|
5622
|
-
const a =
|
|
5622
|
+
const a = Ge(r, t, !0), l = Z(r, a), u = Z(ot(l, "float32"), gn(et(Uo(l), t, !0)));
|
|
5623
5623
|
return o([u]), { value: u, gradFunc: (h, f) => {
|
|
5624
5624
|
const [d] = f, p = !0, g = Uo(d);
|
|
5625
5625
|
return Z(h, N(et(h, t, p), g));
|
|
@@ -5645,7 +5645,7 @@ const Jg = /* @__PURE__ */ k({ logSoftmax_: Xg });
|
|
|
5645
5645
|
*/
|
|
5646
5646
|
function Zg(n, t) {
|
|
5647
5647
|
const e = v(n, "a", "logicalAnd", "bool"), s = v(t, "b", "logicalAnd", "bool");
|
|
5648
|
-
|
|
5648
|
+
Wt(e.shape, s.shape);
|
|
5649
5649
|
const r = { a: e, b: s };
|
|
5650
5650
|
return A.runKernel(vd, r);
|
|
5651
5651
|
}
|
|
@@ -5669,7 +5669,7 @@ const Gr = /* @__PURE__ */ k({ logicalAnd_: Zg });
|
|
|
5669
5669
|
function Qg(n, t, e, s, r) {
|
|
5670
5670
|
const o = v(n, "x", "maxPool"), i = 1;
|
|
5671
5671
|
let a = o, l = !1;
|
|
5672
|
-
o.rank === 3 && (l = !0, a = L(o, [1, o.shape[0], o.shape[1], o.shape[2]])), w(a.rank === 4, () => `Error in maxPool: input must be rank 4 but got rank ${a.rank}.`), w(
|
|
5672
|
+
o.rank === 3 && (l = !0, a = L(o, [1, o.shape[0], o.shape[1], o.shape[2]])), w(a.rank === 4, () => `Error in maxPool: input must be rank 4 but got rank ${a.rank}.`), w(qn(e, i), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${e} and dilations '${i}'`), _e("maxPool", s, r);
|
|
5673
5673
|
const u = { x: a }, c = { filterSize: t, strides: e, pad: s, dimRoundingMode: r }, h = A.runKernel(Kl, u, c);
|
|
5674
5674
|
return l ? L(h, [h.shape[1], h.shape[2], h.shape[3]]) : h;
|
|
5675
5675
|
}
|
|
@@ -5716,11 +5716,11 @@ const n0 = /* @__PURE__ */ k({ maxPool3d_: e0 });
|
|
|
5716
5716
|
*/
|
|
5717
5717
|
function s0(n, t) {
|
|
5718
5718
|
let e = v(n, "a", "maximum"), s = v(t, "b", "maximum");
|
|
5719
|
-
[e, s] = Pt(e, s), e.dtype === "bool" && (e = ot(e, "int32"), s = ot(s, "int32")),
|
|
5719
|
+
[e, s] = Pt(e, s), e.dtype === "bool" && (e = ot(e, "int32"), s = ot(s, "int32")), Wt(e.shape, s.shape);
|
|
5720
5720
|
const r = { a: e, b: s };
|
|
5721
5721
|
return A.runKernel(Ad, r);
|
|
5722
5722
|
}
|
|
5723
|
-
const
|
|
5723
|
+
const Hn = /* @__PURE__ */ k({ maximum_: s0 });
|
|
5724
5724
|
/**
|
|
5725
5725
|
* @license
|
|
5726
5726
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -5758,12 +5758,12 @@ const St = /* @__PURE__ */ k({ mean_: r0 });
|
|
|
5758
5758
|
* limitations under the License.
|
|
5759
5759
|
* =============================================================================
|
|
5760
5760
|
*/
|
|
5761
|
-
function
|
|
5761
|
+
function zn(n, t = "float32") {
|
|
5762
5762
|
if (Me(n), t === "complex64") {
|
|
5763
|
-
const s =
|
|
5763
|
+
const s = zn(n, "float32"), r = zn(n, "float32");
|
|
5764
5764
|
return hi(s, r);
|
|
5765
5765
|
}
|
|
5766
|
-
const e =
|
|
5766
|
+
const e = je(U(n), t);
|
|
5767
5767
|
return A.makeTensor(e, n, t);
|
|
5768
5768
|
}
|
|
5769
5769
|
/**
|
|
@@ -5784,7 +5784,7 @@ function Fn(n, t = "float32") {
|
|
|
5784
5784
|
*/
|
|
5785
5785
|
function wi(n, t = "float32") {
|
|
5786
5786
|
if (Me(n), t === "complex64") {
|
|
5787
|
-
const s = wi(n, "float32"), r =
|
|
5787
|
+
const s = wi(n, "float32"), r = zn(n, "float32");
|
|
5788
5788
|
return hi(s, r);
|
|
5789
5789
|
}
|
|
5790
5790
|
const e = Wl(U(n), t);
|
|
@@ -5808,7 +5808,7 @@ function wi(n, t = "float32") {
|
|
|
5808
5808
|
*/
|
|
5809
5809
|
function o0(n, t) {
|
|
5810
5810
|
let e = v(n, "a", "minimum"), s = v(t, "b", "minimum");
|
|
5811
|
-
[e, s] = Pt(e, s), e.dtype === "bool" && (e = ot(e, "int32"), s = ot(s, "int32")),
|
|
5811
|
+
[e, s] = Pt(e, s), e.dtype === "bool" && (e = ot(e, "int32"), s = ot(s, "int32")), Wt(e.shape, s.shape);
|
|
5812
5812
|
const r = { a: e, b: s };
|
|
5813
5813
|
return A.runKernel(_d, r);
|
|
5814
5814
|
}
|
|
@@ -6395,7 +6395,7 @@ function R0(n) {
|
|
|
6395
6395
|
const e = { x: v(n, "x", "relu") };
|
|
6396
6396
|
return A.runKernel(Wd, e);
|
|
6397
6397
|
}
|
|
6398
|
-
const
|
|
6398
|
+
const _s = /* @__PURE__ */ k({ relu_: R0 });
|
|
6399
6399
|
/**
|
|
6400
6400
|
* @license
|
|
6401
6401
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -6762,7 +6762,7 @@ function tb(n, t, e) {
|
|
|
6762
6762
|
const r = { x: s }, o = { perm: t };
|
|
6763
6763
|
return s.dtype === "complex64" ? C(() => {
|
|
6764
6764
|
let i = D0(s), a = Bg(s);
|
|
6765
|
-
return i = A.runKernel(ro, { x: i }, o), a = A.runKernel(ro, { x: a }, o), e && (a =
|
|
6765
|
+
return i = A.runKernel(ro, { x: i }, o), a = A.runKernel(ro, { x: a }, o), e && (a = jn(a)), hi(i, a);
|
|
6766
6766
|
}) : A.runKernel(ro, r, o);
|
|
6767
6767
|
}
|
|
6768
6768
|
const pt = /* @__PURE__ */ k({ transpose_: tb });
|
|
@@ -6825,7 +6825,7 @@ function ob(n, t, e, s) {
|
|
|
6825
6825
|
if (t === "linear")
|
|
6826
6826
|
return n;
|
|
6827
6827
|
if (t === "relu")
|
|
6828
|
-
return
|
|
6828
|
+
return _s(n);
|
|
6829
6829
|
if (t === "elu")
|
|
6830
6830
|
return Cu(n);
|
|
6831
6831
|
if (t === "relu6")
|
|
@@ -6865,10 +6865,10 @@ function ab({ x: n, filter: t, strides: e, pad: s, dataFormat: r = "NHWC", dilat
|
|
|
6865
6865
|
let d = h, p = !1;
|
|
6866
6866
|
h.rank === 3 && (p = !0, d = L(h, [1, h.shape[0], h.shape[1], h.shape[2]])), w(d.rank === 4, () => `Error in fused conv2d: input must be rank 4, but got rank ${d.rank}.`), w(f.rank === 4, () => `Error in fused conv2d: filter must be rank 4, but got rank ${f.rank}.`), _e("fused conv2d", s, i);
|
|
6867
6867
|
const g = r === "NHWC" ? d.shape[3] : d.shape[1];
|
|
6868
|
-
w(f.shape[2] === g, () => `Error in conv2d: depth of input (${g}) must match input depth for filter ${f.shape[2]}.`), w(
|
|
6868
|
+
w(f.shape[2] === g, () => `Error in conv2d: depth of input (${g}) must match input depth for filter ${f.shape[2]}.`), w(qn(e, o), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${e} and dilations '${o}'`);
|
|
6869
6869
|
const m = di(d.shape, f.shape, e, o, s, i);
|
|
6870
6870
|
let b;
|
|
6871
|
-
a != null && (b = v(a, "bias", "fused conv2d"), [b] = Pt(b, h), r === "NHWC" ?
|
|
6871
|
+
a != null && (b = v(a, "bias", "fused conv2d"), [b] = Pt(b, h), r === "NHWC" ? Wt(m.outShape, b.shape) : (w(b.shape.length <= 1, () => `Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${b.shape.length}.`), w(b.shape.length === 0 || b.shape[0] === m.outChannels || b.shape[0] === 1, () => `Error in fused conv2d: bias shape (${b.shape}) is not compatible with the number of output channels (${m.outChannels})`)));
|
|
6872
6872
|
let y;
|
|
6873
6873
|
if (u != null) {
|
|
6874
6874
|
const E = u.shape;
|
|
@@ -6876,7 +6876,7 @@ function ab({ x: n, filter: t, strides: e, pad: s, dataFormat: r = "NHWC", dilat
|
|
|
6876
6876
|
w(E[0] === 1 || E[0] === m.outChannels, () => `Error in fused conv2d: PReLU activation weights (${E}) is not compatible with the number of output channels (${m.outChannels}).`);
|
|
6877
6877
|
else if (E.length === 3)
|
|
6878
6878
|
try {
|
|
6879
|
-
|
|
6879
|
+
Wt(E, m.outShape);
|
|
6880
6880
|
} catch {
|
|
6881
6881
|
const _ = `Error in fused conv2d: PReLU activation weights (${E}) is not compatible with the output shape of the conv2d (${m.outShape}).`;
|
|
6882
6882
|
throw Error(_);
|
|
@@ -7011,19 +7011,19 @@ function mb(n) {
|
|
|
7011
7011
|
let a;
|
|
7012
7012
|
switch (t.rank) {
|
|
7013
7013
|
case 2:
|
|
7014
|
-
a =
|
|
7014
|
+
a = rs("ij,j->i", o, i);
|
|
7015
7015
|
break;
|
|
7016
7016
|
case 3:
|
|
7017
|
-
a =
|
|
7017
|
+
a = rs("ijk,k->ij", o, i);
|
|
7018
7018
|
break;
|
|
7019
7019
|
case 4:
|
|
7020
|
-
a =
|
|
7020
|
+
a = rs("ijkl,l->ijk", o, i);
|
|
7021
7021
|
break;
|
|
7022
7022
|
case 5:
|
|
7023
|
-
a =
|
|
7023
|
+
a = rs("ijklm,m->ijkl", o, i);
|
|
7024
7024
|
break;
|
|
7025
7025
|
case 6:
|
|
7026
|
-
a =
|
|
7026
|
+
a = rs("ijklmn,n->ijklm", o, i);
|
|
7027
7027
|
break;
|
|
7028
7028
|
default:
|
|
7029
7029
|
throw new Error("Not a valid tensor rank.");
|
|
@@ -7070,7 +7070,7 @@ const yb = /* @__PURE__ */ k({ rotateWithOffset_: bb });
|
|
|
7070
7070
|
* limitations under the License.
|
|
7071
7071
|
* =============================================================================
|
|
7072
7072
|
*/
|
|
7073
|
-
function
|
|
7073
|
+
function Kn(n, t, e, s, r, o) {
|
|
7074
7074
|
s == null && (s = 0.5), r == null && (r = Number.NEGATIVE_INFINITY), o == null && (o = 0);
|
|
7075
7075
|
const i = n.shape[0];
|
|
7076
7076
|
return e = Math.min(e, i), w(0 <= s && s <= 1, () => `iouThreshold must be in [0, 1], but was '${s}'`), w(n.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${n.rank}'`), w(n.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${n.shape[1]}`), w(t.rank === 1, () => "scores must be a 1D tensor"), w(t.shape[0] === i, () => `scores has incompatible shape with boxes. Expected ${i}, but was ${t.shape[0]}`), w(0 <= o && o <= 1, () => `softNmsSigma must be in [0, 1], but was '${o}'`), { maxOutputSize: e, iouThreshold: s, scoreThreshold: r, softNmsSigma: o };
|
|
@@ -7092,7 +7092,7 @@ function Hn(n, t, e, s, r, o) {
|
|
|
7092
7092
|
* =============================================================================
|
|
7093
7093
|
*/
|
|
7094
7094
|
function wb(n, t, e, s = 0.5, r = Number.NEGATIVE_INFINITY) {
|
|
7095
|
-
const o = v(n, "boxes", "nonMaxSuppression", "float32"), i = v(t, "scores", "nonMaxSuppression", "float32"), a =
|
|
7095
|
+
const o = v(n, "boxes", "nonMaxSuppression", "float32"), i = v(t, "scores", "nonMaxSuppression", "float32"), a = Kn(o, i, e, s, r);
|
|
7096
7096
|
e = a.maxOutputSize, s = a.iouThreshold, r = a.scoreThreshold;
|
|
7097
7097
|
const l = { maxOutputSize: e, iouThreshold: s, scoreThreshold: r };
|
|
7098
7098
|
return A.runKernel(Dd, { boxes: o, scores: i }, l);
|
|
@@ -7244,7 +7244,7 @@ function Ma(n, t) {
|
|
|
7244
7244
|
* =============================================================================
|
|
7245
7245
|
*/
|
|
7246
7246
|
async function Tb(n, t, e, s = 0.5, r = Number.NEGATIVE_INFINITY) {
|
|
7247
|
-
const o = v(n, "boxes", "nonMaxSuppressionAsync"), i = v(t, "scores", "nonMaxSuppressionAsync"), a =
|
|
7247
|
+
const o = v(n, "boxes", "nonMaxSuppressionAsync"), i = v(t, "scores", "nonMaxSuppressionAsync"), a = Kn(o, i, e, s, r);
|
|
7248
7248
|
e = a.maxOutputSize, s = a.iouThreshold, r = a.scoreThreshold;
|
|
7249
7249
|
const l = await Promise.all([o.data(), i.data()]), u = l[0], c = l[1], { selectedIndices: h } = Ab(u, c, e, s, r);
|
|
7250
7250
|
return o !== n && o.dispose(), i !== t && i.dispose(), Dt(h, "int32");
|
|
@@ -7267,7 +7267,7 @@ const Nb = Tb;
|
|
|
7267
7267
|
* =============================================================================
|
|
7268
7268
|
*/
|
|
7269
7269
|
function Db(n, t, e, s = 0.5, r = Number.NEGATIVE_INFINITY, o = 0) {
|
|
7270
|
-
const i = v(n, "boxes", "nonMaxSuppression"), a = v(t, "scores", "nonMaxSuppression"), l =
|
|
7270
|
+
const i = v(n, "boxes", "nonMaxSuppression"), a = v(t, "scores", "nonMaxSuppression"), l = Kn(i, a, e, s, r, o);
|
|
7271
7271
|
e = l.maxOutputSize, s = l.iouThreshold, r = l.scoreThreshold, o = l.softNmsSigma;
|
|
7272
7272
|
const u = { boxes: i, scores: a }, c = { maxOutputSize: e, iouThreshold: s, scoreThreshold: r, softNmsSigma: o }, h = A.runKernel(Pd, u, c);
|
|
7273
7273
|
return { selectedIndices: h[0], selectedScores: h[1] };
|
|
@@ -7290,7 +7290,7 @@ const Rb = /* @__PURE__ */ k({ nonMaxSuppressionWithScore_: Db });
|
|
|
7290
7290
|
* =============================================================================
|
|
7291
7291
|
*/
|
|
7292
7292
|
async function Pb(n, t, e, s = 0.5, r = Number.NEGATIVE_INFINITY, o = 0) {
|
|
7293
|
-
const i = v(n, "boxes", "nonMaxSuppressionAsync"), a = v(t, "scores", "nonMaxSuppressionAsync"), l =
|
|
7293
|
+
const i = v(n, "boxes", "nonMaxSuppressionAsync"), a = v(t, "scores", "nonMaxSuppressionAsync"), l = Kn(i, a, e, s, r, o);
|
|
7294
7294
|
e = l.maxOutputSize, s = l.iouThreshold, r = l.scoreThreshold, o = l.softNmsSigma;
|
|
7295
7295
|
const u = await Promise.all([i.data(), a.data()]), c = u[0], h = u[1], { selectedIndices: f, selectedScores: d } = Cb(c, h, e, s, r, o);
|
|
7296
7296
|
return i !== n && i.dispose(), a !== t && a.dispose(), {
|
|
@@ -7316,7 +7316,7 @@ const Lb = Pb;
|
|
|
7316
7316
|
* =============================================================================
|
|
7317
7317
|
*/
|
|
7318
7318
|
function Mb(n, t, e, s = 0.5, r = Number.NEGATIVE_INFINITY, o = !1) {
|
|
7319
|
-
const i = v(n, "boxes", "nonMaxSuppression"), a = v(t, "scores", "nonMaxSuppression"), l =
|
|
7319
|
+
const i = v(n, "boxes", "nonMaxSuppression"), a = v(t, "scores", "nonMaxSuppression"), l = Kn(
|
|
7320
7320
|
i,
|
|
7321
7321
|
a,
|
|
7322
7322
|
e,
|
|
@@ -7350,7 +7350,7 @@ const Ob = /* @__PURE__ */ k({ nonMaxSuppressionPadded_: Mb });
|
|
|
7350
7350
|
* =============================================================================
|
|
7351
7351
|
*/
|
|
7352
7352
|
async function Bb(n, t, e, s = 0.5, r = Number.NEGATIVE_INFINITY, o = !1) {
|
|
7353
|
-
const i = v(n, "boxes", "nonMaxSuppressionAsync"), a = v(t, "scores", "nonMaxSuppressionAsync"), l =
|
|
7353
|
+
const i = v(n, "boxes", "nonMaxSuppressionAsync"), a = v(t, "scores", "nonMaxSuppressionAsync"), l = Kn(
|
|
7354
7354
|
i,
|
|
7355
7355
|
a,
|
|
7356
7356
|
e,
|
|
@@ -7444,7 +7444,7 @@ function Vb(n, t = "binary", e = !1, s = 0.5) {
|
|
|
7444
7444
|
const m = Vm(ot(O0(d), "int32"), tr([]), 256);
|
|
7445
7445
|
u = qb(m, l);
|
|
7446
7446
|
}
|
|
7447
|
-
const p = e ? Ru(d, u) :
|
|
7447
|
+
const p = e ? Ru(d, u) : ks(d, u);
|
|
7448
7448
|
return ot(N(p, 255), "int32");
|
|
7449
7449
|
}
|
|
7450
7450
|
function qb(n, t) {
|
|
@@ -7457,7 +7457,7 @@ function qb(n, t) {
|
|
|
7457
7457
|
l = X(et(g), et(i));
|
|
7458
7458
|
const m = Z(a, l), b = Z(a, l), y = N(u, c);
|
|
7459
7459
|
r = N(N(y, m), b);
|
|
7460
|
-
const S =
|
|
7460
|
+
const S = ks(r, s);
|
|
7461
7461
|
s = on(S, r, s), e = on(S, Dt([h]), e);
|
|
7462
7462
|
}
|
|
7463
7463
|
return e;
|
|
@@ -7508,7 +7508,7 @@ function Yb(n, t, e) {
|
|
|
7508
7508
|
const r = s.shape, [o, i] = s.shape.slice(-2);
|
|
7509
7509
|
let a, l;
|
|
7510
7510
|
typeof t == "number" ? (w(t % 1 === 0, () => `bandPart(): numLower must be an integer, got ${t}.`), w(t <= o, () => `bandPart(): numLower (${t}) must not be greater than the number of rows (${o}).`), a = v(t < 0 ? o : t, "numLower", "bandPart")) : (w(t.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), a = on(La(t, 0), o, dr(t, o))), typeof e == "number" ? (w(e % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${e}.`), w(e <= i, () => `bandPart(): numUpper (${e}) must not be greater than the number of columns (${i}).`), l = v(e < 0 ? i : e, "numUpper", "bandPart")) : (w(e.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), l = on(La(e, 0), i, dr(e, i)));
|
|
7511
|
-
const u = L(pr(0, o, 1, "int32"), [-1, 1]), c = pr(0, i, 1, "int32"), h = Z(u, c), f = Gr(Ru(h, a), Mg(h,
|
|
7511
|
+
const u = L(pr(0, o, 1, "int32"), [-1, 1]), c = pr(0, i, 1, "int32"), h = Z(u, c), f = Gr(Ru(h, a), Mg(h, jn(l))), d = zn([o, i], s.dtype);
|
|
7512
7512
|
return L(mr(Gu(L(s, [-1, o, i])).map((p) => on(f, p, d))), r);
|
|
7513
7513
|
}
|
|
7514
7514
|
const Xb = /* @__PURE__ */ k({ bandPart_: Yb });
|
|
@@ -7596,12 +7596,12 @@ function Oa(n, t = !1) {
|
|
|
7596
7596
|
for (let u = 0; u < l; ++u) {
|
|
7597
7597
|
const c = o, h = a, f = r;
|
|
7598
7598
|
[a, o, r] = A.tidy(() => {
|
|
7599
|
-
const d = At(o, [u, u], [e - u, 1]), p = Nu(d), g = At(o, [u, u], [1, 1]), m = on(
|
|
7599
|
+
const d = At(o, [u, u], [e - u, 1]), p = Nu(d), g = At(o, [u, u], [1, 1]), m = on(ks(g, 0), uo([[-1]]), uo([[1]])), b = Z(g, N(m, p)), y = X(d, b);
|
|
7600
7600
|
y.shape[0] === 1 ? a = sn(i) : a = rn([
|
|
7601
7601
|
i,
|
|
7602
7602
|
At(y, [1, 0], [y.shape[0] - 1, y.shape[1]])
|
|
7603
7603
|
], 0);
|
|
7604
|
-
const S =
|
|
7604
|
+
const S = jn(X(ye(m, b), p)), x = At(o, [u, 0], [e - u, s]), $ = N(S, a), E = pt(a);
|
|
7605
7605
|
if (u === 0)
|
|
7606
7606
|
o = Z(x, ye($, ye(E, x)));
|
|
7607
7607
|
else {
|
|
@@ -7676,7 +7676,7 @@ const zs = {
|
|
|
7676
7676
|
* =============================================================================
|
|
7677
7677
|
*/
|
|
7678
7678
|
const ny = /* @__PURE__ */ new Map(), sy = /* @__PURE__ */ new Map();
|
|
7679
|
-
class
|
|
7679
|
+
class Yn {
|
|
7680
7680
|
/**
|
|
7681
7681
|
* Return the class name for this class to use in serialization contexts.
|
|
7682
7682
|
*
|
|
@@ -7742,7 +7742,7 @@ function M(n, t, e) {
|
|
|
7742
7742
|
* limitations under the License.
|
|
7743
7743
|
* =============================================================================
|
|
7744
7744
|
*/
|
|
7745
|
-
class
|
|
7745
|
+
class Ke extends Yn {
|
|
7746
7746
|
/**
|
|
7747
7747
|
* Executes `f()` and minimizes the scalar output of `f()` by computing
|
|
7748
7748
|
* gradients of y with respect to the list of trainable variables provided by
|
|
@@ -7821,7 +7821,7 @@ class He extends Kn {
|
|
|
7821
7821
|
return this.iterations_ = (await t[0].tensor.data())[0], t.slice(1);
|
|
7822
7822
|
}
|
|
7823
7823
|
}
|
|
7824
|
-
Object.defineProperty(
|
|
7824
|
+
Object.defineProperty(Ke, Symbol.hasInstance, {
|
|
7825
7825
|
value: (n) => n.minimize != null && n.computeGradients != null && n.applyGradients != null
|
|
7826
7826
|
});
|
|
7827
7827
|
/**
|
|
@@ -7840,7 +7840,7 @@ Object.defineProperty(He, Symbol.hasInstance, {
|
|
|
7840
7840
|
* limitations under the License.
|
|
7841
7841
|
* =============================================================================
|
|
7842
7842
|
*/
|
|
7843
|
-
class Vu extends
|
|
7843
|
+
class Vu extends Ke {
|
|
7844
7844
|
/** @nocollapse */
|
|
7845
7845
|
static get className() {
|
|
7846
7846
|
return "Adadelta";
|
|
@@ -7863,7 +7863,7 @@ class Vu extends He {
|
|
|
7863
7863
|
return;
|
|
7864
7864
|
const l = this.accumulatedGrads[r].variable, u = this.accumulatedUpdates[r].variable;
|
|
7865
7865
|
C(() => {
|
|
7866
|
-
const c = O(N(l, this.rho), N(
|
|
7866
|
+
const c = O(N(l, this.rho), N(Ve(a), 1 - this.rho)), h = N(X(de(O(u, this.epsilon)), de(O(l, this.epsilon))), a), f = O(N(u, this.rho), N(Ve(h), 1 - this.rho));
|
|
7867
7867
|
l.assign(c), u.assign(f);
|
|
7868
7868
|
const d = O(N(h, -this.learningRate), o);
|
|
7869
7869
|
o.assign(d);
|
|
@@ -7916,7 +7916,7 @@ class Vu extends He {
|
|
|
7916
7916
|
* limitations under the License.
|
|
7917
7917
|
* =============================================================================
|
|
7918
7918
|
*/
|
|
7919
|
-
class qu extends
|
|
7919
|
+
class qu extends Ke {
|
|
7920
7920
|
/** @nocollapse */
|
|
7921
7921
|
static get className() {
|
|
7922
7922
|
return "Adagrad";
|
|
@@ -7936,7 +7936,7 @@ class qu extends He {
|
|
|
7936
7936
|
return;
|
|
7937
7937
|
const a = this.accumulatedGrads[r].variable;
|
|
7938
7938
|
C(() => {
|
|
7939
|
-
const l = O(a,
|
|
7939
|
+
const l = O(a, Ve(i));
|
|
7940
7940
|
a.assign(l);
|
|
7941
7941
|
const u = O(N(X(i, de(O(l, A.backend.epsilon()))), -this.learningRate), o);
|
|
7942
7942
|
o.assign(u);
|
|
@@ -7981,7 +7981,7 @@ class qu extends He {
|
|
|
7981
7981
|
* limitations under the License.
|
|
7982
7982
|
* =============================================================================
|
|
7983
7983
|
*/
|
|
7984
|
-
class ju extends
|
|
7984
|
+
class ju extends Ke {
|
|
7985
7985
|
/** @nocollapse */
|
|
7986
7986
|
static get className() {
|
|
7987
7987
|
return "Adam";
|
|
@@ -8007,7 +8007,7 @@ class ju extends He {
|
|
|
8007
8007
|
const u = Array.isArray(t) ? t[i].tensor : t[o];
|
|
8008
8008
|
if (u == null)
|
|
8009
8009
|
return;
|
|
8010
|
-
const c = this.accumulatedFirstMoment[i].variable, h = this.accumulatedSecondMoment[i].variable, f = O(N(c, this.beta1), N(u, 1 - this.beta1)), d = O(N(h, this.beta2), N(
|
|
8010
|
+
const c = this.accumulatedFirstMoment[i].variable, h = this.accumulatedSecondMoment[i].variable, f = O(N(c, this.beta1), N(u, 1 - this.beta1)), d = O(N(h, this.beta2), N(Ve(u), 1 - this.beta2)), p = X(f, s), g = X(d, r);
|
|
8011
8011
|
c.assign(f), h.assign(d);
|
|
8012
8012
|
const m = O(N(X(p, O(de(g), this.epsilon)), -this.learningRate), a);
|
|
8013
8013
|
a.assign(m);
|
|
@@ -8063,7 +8063,7 @@ class ju extends He {
|
|
|
8063
8063
|
* limitations under the License.
|
|
8064
8064
|
* =============================================================================
|
|
8065
8065
|
*/
|
|
8066
|
-
class Hu extends
|
|
8066
|
+
class Hu extends Ke {
|
|
8067
8067
|
/** @nocollapse */
|
|
8068
8068
|
static get className() {
|
|
8069
8069
|
return "Adamax";
|
|
@@ -8089,7 +8089,7 @@ class Hu extends He {
|
|
|
8089
8089
|
const u = Array.isArray(t) ? t[i].tensor : t[o];
|
|
8090
8090
|
if (u == null)
|
|
8091
8091
|
return;
|
|
8092
|
-
const c = this.accumulatedFirstMoment[i].variable, h = this.accumulatedWeightedInfNorm[i].variable, f = O(N(c, this.beta1), N(u, 1 - this.beta1)), d = N(h, this.beta2), p = Nt(u), g =
|
|
8092
|
+
const c = this.accumulatedFirstMoment[i].variable, h = this.accumulatedWeightedInfNorm[i].variable, f = O(N(c, this.beta1), N(u, 1 - this.beta1)), d = N(h, this.beta2), p = Nt(u), g = Hn(d, p);
|
|
8093
8093
|
c.assign(f), h.assign(g);
|
|
8094
8094
|
const m = O(N(X(r, s), X(f, O(g, this.epsilon))), a);
|
|
8095
8095
|
a.assign(m);
|
|
@@ -8135,7 +8135,7 @@ class Hu extends He {
|
|
|
8135
8135
|
* limitations under the License.
|
|
8136
8136
|
* =============================================================================
|
|
8137
8137
|
*/
|
|
8138
|
-
class _i extends
|
|
8138
|
+
class _i extends Ke {
|
|
8139
8139
|
/** @nocollapse */
|
|
8140
8140
|
static get className() {
|
|
8141
8141
|
return "SGD";
|
|
@@ -8159,7 +8159,7 @@ class _i extends He {
|
|
|
8159
8159
|
* Sets the learning rate of the optimizer.
|
|
8160
8160
|
*/
|
|
8161
8161
|
setLearningRate(t) {
|
|
8162
|
-
this.learningRate = t, this.c != null && this.c.dispose(), this.c =
|
|
8162
|
+
this.learningRate = t, this.c != null && this.c.dispose(), this.c = Pn(Kt(-t));
|
|
8163
8163
|
}
|
|
8164
8164
|
dispose() {
|
|
8165
8165
|
this.c.dispose();
|
|
@@ -8266,7 +8266,7 @@ class Ku extends _i {
|
|
|
8266
8266
|
* limitations under the License.
|
|
8267
8267
|
* =============================================================================
|
|
8268
8268
|
*/
|
|
8269
|
-
class Yu extends
|
|
8269
|
+
class Yu extends Ke {
|
|
8270
8270
|
/** @nocollapse */
|
|
8271
8271
|
static get className() {
|
|
8272
8272
|
return "RMSProp";
|
|
@@ -8293,14 +8293,14 @@ class Yu extends He {
|
|
|
8293
8293
|
return;
|
|
8294
8294
|
const l = this.accumulatedMeanSquares[r].variable, u = this.accumulatedMoments[r].variable;
|
|
8295
8295
|
C(() => {
|
|
8296
|
-
const c = O(N(l, this.decay), N(
|
|
8296
|
+
const c = O(N(l, this.decay), N(Ve(a), 1 - this.decay));
|
|
8297
8297
|
if (this.centered) {
|
|
8298
|
-
const h = this.accumulatedMeanGrads[r].variable, f = O(N(h, this.decay), N(a, 1 - this.decay)), d = X(N(a, this.learningRate), de(Z(c, O(
|
|
8298
|
+
const h = this.accumulatedMeanGrads[r].variable, f = O(N(h, this.decay), N(a, 1 - this.decay)), d = X(N(a, this.learningRate), de(Z(c, O(Ve(f), this.epsilon)))), p = O(N(u, this.momentum), d);
|
|
8299
8299
|
l.assign(c), h.assign(f), u.assign(p);
|
|
8300
8300
|
const g = Z(o, p);
|
|
8301
8301
|
o.assign(g);
|
|
8302
8302
|
} else {
|
|
8303
|
-
const h = O(N(l, this.decay), N(
|
|
8303
|
+
const h = O(N(l, this.decay), N(Ve(a), 1 - this.decay)), f = O(N(u, this.momentum), X(N(a, this.learningRate), de(O(h, this.epsilon))));
|
|
8304
8304
|
l.assign(h), u.assign(f);
|
|
8305
8305
|
const d = Z(o, f);
|
|
8306
8306
|
o.assign(d);
|
|
@@ -8601,7 +8601,7 @@ class cy {
|
|
|
8601
8601
|
* limitations under the License.
|
|
8602
8602
|
* =============================================================================
|
|
8603
8603
|
*/
|
|
8604
|
-
const
|
|
8604
|
+
const In = cy;
|
|
8605
8605
|
/**
|
|
8606
8606
|
* @license
|
|
8607
8607
|
* Copyright 2017 Google LLC. All Rights Reserved.
|
|
@@ -8649,7 +8649,7 @@ function dy(n, t) {
|
|
|
8649
8649
|
w(i === t || r[i] === s[i], () => `Error in concat${e}D: Shape of tensors[${o}] (${r}) does not match the shape of the rest (${s}) along the non-concatenated axis ${o}.`);
|
|
8650
8650
|
});
|
|
8651
8651
|
}
|
|
8652
|
-
function
|
|
8652
|
+
function xs(n, t) {
|
|
8653
8653
|
const e = n[0].slice();
|
|
8654
8654
|
for (let s = 1; s < n.length; s++)
|
|
8655
8655
|
e[t] += n[s][t];
|
|
@@ -8938,14 +8938,14 @@ const By = ["channelsFirst", "channelsLast"], Fy = ["nearest", "bilinear"], zy =
|
|
|
8938
8938
|
* https://opensource.org/licenses/MIT.
|
|
8939
8939
|
* =============================================================================
|
|
8940
8940
|
*/
|
|
8941
|
-
class
|
|
8941
|
+
class Fe extends Error {
|
|
8942
8942
|
constructor(t) {
|
|
8943
|
-
super(t), Object.setPrototypeOf(this,
|
|
8943
|
+
super(t), Object.setPrototypeOf(this, Fe.prototype);
|
|
8944
8944
|
}
|
|
8945
8945
|
}
|
|
8946
|
-
class
|
|
8946
|
+
class qe extends Error {
|
|
8947
8947
|
constructor(t) {
|
|
8948
|
-
super(t), Object.setPrototypeOf(this,
|
|
8948
|
+
super(t), Object.setPrototypeOf(this, qe.prototype);
|
|
8949
8949
|
}
|
|
8950
8950
|
}
|
|
8951
8951
|
class I extends Error {
|
|
@@ -8993,7 +8993,7 @@ function za(n, t) {
|
|
|
8993
8993
|
s === t && e++;
|
|
8994
8994
|
return e;
|
|
8995
8995
|
}
|
|
8996
|
-
function
|
|
8996
|
+
function zt(n) {
|
|
8997
8997
|
return n.length === 1 ? n[0] : n;
|
|
8998
8998
|
}
|
|
8999
8999
|
function st(n) {
|
|
@@ -9025,7 +9025,7 @@ function Go(n) {
|
|
|
9025
9025
|
}
|
|
9026
9026
|
}
|
|
9027
9027
|
}
|
|
9028
|
-
function
|
|
9028
|
+
function Ts(n, t = {}, e = {}, s = "object", r = !1) {
|
|
9029
9029
|
if (typeof n == "string") {
|
|
9030
9030
|
const o = n;
|
|
9031
9031
|
let i;
|
|
@@ -9094,7 +9094,7 @@ function Gy(n) {
|
|
|
9094
9094
|
return !1;
|
|
9095
9095
|
return !0;
|
|
9096
9096
|
}
|
|
9097
|
-
function
|
|
9097
|
+
function Xn(n, t, e) {
|
|
9098
9098
|
if (e != null && n.indexOf(e) < 0)
|
|
9099
9099
|
throw new I(`${e} is not a valid ${t}. Valid values are ${n} or null/undefined.`);
|
|
9100
9100
|
}
|
|
@@ -9108,9 +9108,9 @@ function Ju(n) {
|
|
|
9108
9108
|
return n === null ? "null" : Array.isArray(n) ? "[" + n.map((t) => Ju(t)).join(",") + "]" : typeof n == "string" ? `"${n}"` : `${n}`;
|
|
9109
9109
|
}
|
|
9110
9110
|
function Vy(n, t, e) {
|
|
9111
|
-
let s = e != null ? e() :
|
|
9111
|
+
let s = e != null ? e() : On(), r;
|
|
9112
9112
|
return (...i) => {
|
|
9113
|
-
const a = e != null ? e() :
|
|
9113
|
+
const a = e != null ? e() : On();
|
|
9114
9114
|
return a - s < t || (s = a, r = n(...i)), r;
|
|
9115
9115
|
};
|
|
9116
9116
|
}
|
|
@@ -9126,31 +9126,31 @@ function qy(n) {
|
|
|
9126
9126
|
* https://opensource.org/licenses/MIT.
|
|
9127
9127
|
* =============================================================================
|
|
9128
9128
|
*/
|
|
9129
|
-
const
|
|
9129
|
+
const An = /* @__PURE__ */ new Map();
|
|
9130
9130
|
function gt(n) {
|
|
9131
|
-
|
|
9131
|
+
Xn(By, "DataFormat", n);
|
|
9132
9132
|
}
|
|
9133
9133
|
function jy(n) {
|
|
9134
|
-
|
|
9134
|
+
Xn(Fy, "InterpolationFormat", n);
|
|
9135
9135
|
}
|
|
9136
9136
|
function oe(n) {
|
|
9137
|
-
|
|
9137
|
+
Xn(zy, "PaddingMode", n);
|
|
9138
9138
|
}
|
|
9139
9139
|
function Zu(n) {
|
|
9140
|
-
|
|
9140
|
+
Xn(Uy, "PoolMode", n);
|
|
9141
9141
|
}
|
|
9142
|
-
const
|
|
9142
|
+
const ps = [], Ua = "/";
|
|
9143
9143
|
function sr(n, t) {
|
|
9144
|
-
|
|
9144
|
+
ps.push(n);
|
|
9145
9145
|
try {
|
|
9146
9146
|
const e = t();
|
|
9147
|
-
return
|
|
9147
|
+
return ps.pop(), e;
|
|
9148
9148
|
} catch (e) {
|
|
9149
|
-
throw
|
|
9149
|
+
throw ps.pop(), e;
|
|
9150
9150
|
}
|
|
9151
9151
|
}
|
|
9152
9152
|
function Hy() {
|
|
9153
|
-
return
|
|
9153
|
+
return ps.length === 0 ? "" : ps.join(Ua) + Ua;
|
|
9154
9154
|
}
|
|
9155
9155
|
function Qu(n) {
|
|
9156
9156
|
if (!ec(n))
|
|
@@ -9160,11 +9160,11 @@ function Qu(n) {
|
|
|
9160
9160
|
function tc(n) {
|
|
9161
9161
|
if (!ec(n))
|
|
9162
9162
|
throw new Error("Not a valid tensor name: '" + n + "'");
|
|
9163
|
-
|
|
9164
|
-
const t =
|
|
9165
|
-
if (
|
|
9163
|
+
An.has(n) || An.set(n, 0);
|
|
9164
|
+
const t = An.get(n);
|
|
9165
|
+
if (An.set(n, An.get(n) + 1), t > 0) {
|
|
9166
9166
|
const e = `${n}_${t}`;
|
|
9167
|
-
return
|
|
9167
|
+
return An.set(e, 1), e;
|
|
9168
9168
|
} else
|
|
9169
9169
|
return n;
|
|
9170
9170
|
}
|
|
@@ -9184,7 +9184,7 @@ function ec(n) {
|
|
|
9184
9184
|
function Yy(n) {
|
|
9185
9185
|
return n === parseInt(n.toString(), 10);
|
|
9186
9186
|
}
|
|
9187
|
-
function
|
|
9187
|
+
function ms(n, t, e) {
|
|
9188
9188
|
t == null && (t = 0), e == null && (e = n.length);
|
|
9189
9189
|
let s = 1;
|
|
9190
9190
|
for (let r = t; r < e; ++r)
|
|
@@ -9222,7 +9222,7 @@ let co;
|
|
|
9222
9222
|
function mt() {
|
|
9223
9223
|
return co == null && (co = Zp().epsilon()), co;
|
|
9224
9224
|
}
|
|
9225
|
-
function
|
|
9225
|
+
function Jn() {
|
|
9226
9226
|
return "channelsLast";
|
|
9227
9227
|
}
|
|
9228
9228
|
/**
|
|
@@ -9242,7 +9242,7 @@ function Ri(n, t = -1) {
|
|
|
9242
9242
|
return t < 0 && (t = e.length + t + 1), e.splice(t, 0, 1), L(n, e);
|
|
9243
9243
|
}
|
|
9244
9244
|
function Xy(n) {
|
|
9245
|
-
const t = [
|
|
9245
|
+
const t = [ms(n.shape)];
|
|
9246
9246
|
return L(n, t);
|
|
9247
9247
|
}
|
|
9248
9248
|
function ln(n, t, e) {
|
|
@@ -9255,7 +9255,7 @@ function ln(n, t, e) {
|
|
|
9255
9255
|
case 3:
|
|
9256
9256
|
return Ci(n, [t, 0, 0], [e, n.shape[1], n.shape[2]]);
|
|
9257
9257
|
case 4:
|
|
9258
|
-
return
|
|
9258
|
+
return ys(n, [t, 0, 0, 0], [e, n.shape[1], n.shape[2], n.shape[3]]);
|
|
9259
9259
|
case 5:
|
|
9260
9260
|
return At(n, [t, 0, 0, 0, 0], [
|
|
9261
9261
|
e,
|
|
@@ -9288,7 +9288,7 @@ function ho(n, t, e) {
|
|
|
9288
9288
|
case 3:
|
|
9289
9289
|
return Ci(n, [0, 0, t], [n.shape[0], n.shape[1], e]);
|
|
9290
9290
|
case 4:
|
|
9291
|
-
return
|
|
9291
|
+
return ys(n, [0, 0, 0, t], [n.shape[0], n.shape[1], n.shape[2], e]);
|
|
9292
9292
|
default:
|
|
9293
9293
|
throw new I(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`);
|
|
9294
9294
|
}
|
|
@@ -9324,9 +9324,9 @@ function Ws(n, t, e, s) {
|
|
|
9324
9324
|
case 1:
|
|
9325
9325
|
return ln(n, t, e);
|
|
9326
9326
|
case 2:
|
|
9327
|
-
return
|
|
9327
|
+
return ys(n, [0, t, 0, 0], [n.shape[0], e, n.shape[2], n.shape[3]]);
|
|
9328
9328
|
case 3:
|
|
9329
|
-
return
|
|
9329
|
+
return ys(n, [0, 0, t, 0], [n.shape[0], n.shape[1], e, n.shape[3]]);
|
|
9330
9330
|
case 4:
|
|
9331
9331
|
return ho(n, t, e);
|
|
9332
9332
|
default:
|
|
@@ -9347,7 +9347,7 @@ function rc(n, t = 0, e = 1, s, r) {
|
|
|
9347
9347
|
function Zy(n, t, e) {
|
|
9348
9348
|
return C(() => (Array.isArray(t) ? t = Dt(t, "int32") : t = ot(t, "int32"), Rg(n, t, e)));
|
|
9349
9349
|
}
|
|
9350
|
-
function
|
|
9350
|
+
function Ns(n) {
|
|
9351
9351
|
return N(n, n);
|
|
9352
9352
|
}
|
|
9353
9353
|
function Qy(n, t, e) {
|
|
@@ -9373,8 +9373,8 @@ function Qy(n, t, e) {
|
|
|
9373
9373
|
return t;
|
|
9374
9374
|
throw new I(`Unsupported input rank by biasAdd: ${t.rank}`);
|
|
9375
9375
|
}
|
|
9376
|
-
function
|
|
9377
|
-
return C(() => (e == null && (e =
|
|
9376
|
+
function Ds(n, t, e) {
|
|
9377
|
+
return C(() => (e == null && (e = Jn()), gt(e), O(n, Qy(n.rank, t, e))));
|
|
9378
9378
|
}
|
|
9379
9379
|
function tw(n, t = 1) {
|
|
9380
9380
|
if (t !== 1)
|
|
@@ -9399,7 +9399,7 @@ function nw(n) {
|
|
|
9399
9399
|
* https://opensource.org/licenses/MIT.
|
|
9400
9400
|
* =============================================================================
|
|
9401
9401
|
*/
|
|
9402
|
-
class Ct extends
|
|
9402
|
+
class Ct extends Yn {
|
|
9403
9403
|
getConfig() {
|
|
9404
9404
|
return {};
|
|
9405
9405
|
}
|
|
@@ -9427,14 +9427,14 @@ ic.className = "selu";
|
|
|
9427
9427
|
M(ic);
|
|
9428
9428
|
class ac extends Ct {
|
|
9429
9429
|
apply(t) {
|
|
9430
|
-
return
|
|
9430
|
+
return _s(t);
|
|
9431
9431
|
}
|
|
9432
9432
|
}
|
|
9433
9433
|
ac.className = "relu";
|
|
9434
9434
|
M(ac);
|
|
9435
9435
|
class lc extends Ct {
|
|
9436
9436
|
apply(t) {
|
|
9437
|
-
return C(() => dr(6,
|
|
9437
|
+
return C(() => dr(6, _s(t)));
|
|
9438
9438
|
}
|
|
9439
9439
|
}
|
|
9440
9440
|
lc.className = "relu6";
|
|
@@ -9580,7 +9580,7 @@ function sw(n) {
|
|
|
9580
9580
|
return n.getClassName();
|
|
9581
9581
|
}
|
|
9582
9582
|
function fo(n, t = {}) {
|
|
9583
|
-
return
|
|
9583
|
+
return Ts(n, Qt.getMap().classNameMap, t, "activation");
|
|
9584
9584
|
}
|
|
9585
9585
|
function rw(n) {
|
|
9586
9586
|
if (n == null) {
|
|
@@ -9605,12 +9605,12 @@ function rw(n) {
|
|
|
9605
9605
|
function Pi(n, t) {
|
|
9606
9606
|
return C(() => de(et(N(n, n), t, !0)));
|
|
9607
9607
|
}
|
|
9608
|
-
class
|
|
9608
|
+
class Rs extends Yn {
|
|
9609
9609
|
getConfig() {
|
|
9610
9610
|
return {};
|
|
9611
9611
|
}
|
|
9612
9612
|
}
|
|
9613
|
-
class Sc extends
|
|
9613
|
+
class Sc extends Rs {
|
|
9614
9614
|
constructor(t) {
|
|
9615
9615
|
super(), this.defaultMaxValue = 2, this.defaultAxis = 0, this.maxValue = t.maxValue != null ? t.maxValue : this.defaultMaxValue, this.axis = t.axis != null ? t.axis : this.defaultAxis;
|
|
9616
9616
|
}
|
|
@@ -9626,7 +9626,7 @@ class Sc extends Ds {
|
|
|
9626
9626
|
}
|
|
9627
9627
|
Sc.className = "MaxNorm";
|
|
9628
9628
|
M(Sc);
|
|
9629
|
-
class $c extends
|
|
9629
|
+
class $c extends Rs {
|
|
9630
9630
|
constructor(t) {
|
|
9631
9631
|
super(), this.defaultAxis = 0, this.axis = t.axis != null ? t.axis : this.defaultAxis;
|
|
9632
9632
|
}
|
|
@@ -9639,14 +9639,14 @@ class $c extends Ds {
|
|
|
9639
9639
|
}
|
|
9640
9640
|
$c.className = "UnitNorm";
|
|
9641
9641
|
M($c);
|
|
9642
|
-
class vc extends
|
|
9642
|
+
class vc extends Rs {
|
|
9643
9643
|
apply(t) {
|
|
9644
|
-
return
|
|
9644
|
+
return _s(t);
|
|
9645
9645
|
}
|
|
9646
9646
|
}
|
|
9647
9647
|
vc.className = "NonNeg";
|
|
9648
9648
|
M(vc);
|
|
9649
|
-
class Ic extends
|
|
9649
|
+
class Ic extends Rs {
|
|
9650
9650
|
constructor(t) {
|
|
9651
9651
|
super(), this.defaultMinValue = 0, this.defaultMaxValue = 1, this.defaultRate = 1, this.defaultAxis = 0, this.minValue = t.minValue != null ? t.minValue : this.defaultMinValue, this.maxValue = t.maxValue != null ? t.maxValue : this.defaultMaxValue, this.rate = t.rate != null ? t.rate : this.defaultRate, this.axis = t.axis != null ? t.axis : this.defaultAxis;
|
|
9652
9652
|
}
|
|
@@ -9677,7 +9677,7 @@ function yr(n) {
|
|
|
9677
9677
|
return Ni(n);
|
|
9678
9678
|
}
|
|
9679
9679
|
function Ga(n, t = {}) {
|
|
9680
|
-
return
|
|
9680
|
+
return Ts(n, Qt.getMap().classNameMap, t, "constraint");
|
|
9681
9681
|
}
|
|
9682
9682
|
function wr(n) {
|
|
9683
9683
|
if (n == null)
|
|
@@ -9686,7 +9686,7 @@ function wr(n) {
|
|
|
9686
9686
|
const e = { className: n in Wa ? Wa[n] : n, config: {} };
|
|
9687
9687
|
return Ga(e);
|
|
9688
9688
|
} else
|
|
9689
|
-
return n instanceof
|
|
9689
|
+
return n instanceof Rs ? n : Ga(n);
|
|
9690
9690
|
}
|
|
9691
9691
|
/**
|
|
9692
9692
|
* @license
|
|
@@ -9725,12 +9725,12 @@ const iw = ["fanIn", "fanOut", "fanAvg"], aw = ["normal", "uniform", "truncatedN
|
|
|
9725
9725
|
* =============================================================================
|
|
9726
9726
|
*/
|
|
9727
9727
|
function lw(n) {
|
|
9728
|
-
|
|
9728
|
+
Xn(iw, "FanMode", n);
|
|
9729
9729
|
}
|
|
9730
9730
|
function uw(n) {
|
|
9731
|
-
|
|
9731
|
+
Xn(aw, "Distribution", n);
|
|
9732
9732
|
}
|
|
9733
|
-
class Te extends
|
|
9733
|
+
class Te extends Yn {
|
|
9734
9734
|
fromConfigUsesCustomObjects() {
|
|
9735
9735
|
return !1;
|
|
9736
9736
|
}
|
|
@@ -9740,7 +9740,7 @@ class Te extends Kn {
|
|
|
9740
9740
|
}
|
|
9741
9741
|
class Ec extends Te {
|
|
9742
9742
|
apply(t, e) {
|
|
9743
|
-
return
|
|
9743
|
+
return zn(t, e);
|
|
9744
9744
|
}
|
|
9745
9745
|
}
|
|
9746
9746
|
Ec.className = "Zeros";
|
|
@@ -9837,19 +9837,19 @@ function cw(n, t = "channelsLast") {
|
|
|
9837
9837
|
e = n[0], s = n[1];
|
|
9838
9838
|
else if ([3, 4, 5].indexOf(n.length) !== -1) {
|
|
9839
9839
|
if (t === "channelsFirst") {
|
|
9840
|
-
const r =
|
|
9840
|
+
const r = ms(n, 2);
|
|
9841
9841
|
e = n[1] * r, s = n[0] * r;
|
|
9842
9842
|
} else if (t === "channelsLast") {
|
|
9843
|
-
const r =
|
|
9843
|
+
const r = ms(n, 0, n.length - 2);
|
|
9844
9844
|
e = n[n.length - 2] * r, s = n[n.length - 1] * r;
|
|
9845
9845
|
}
|
|
9846
9846
|
} else {
|
|
9847
|
-
const r =
|
|
9847
|
+
const r = ms(n);
|
|
9848
9848
|
e = Math.sqrt(r), s = Math.sqrt(r);
|
|
9849
9849
|
}
|
|
9850
9850
|
return [e, s];
|
|
9851
9851
|
}
|
|
9852
|
-
class
|
|
9852
|
+
class Gt extends Te {
|
|
9853
9853
|
/**
|
|
9854
9854
|
* Constructor of VarianceScaling.
|
|
9855
9855
|
* @throws ValueError for invalid value in scale.
|
|
@@ -9881,9 +9881,9 @@ class Ut extends Te {
|
|
|
9881
9881
|
};
|
|
9882
9882
|
}
|
|
9883
9883
|
}
|
|
9884
|
-
|
|
9885
|
-
M(
|
|
9886
|
-
class Mi extends
|
|
9884
|
+
Gt.className = "VarianceScaling";
|
|
9885
|
+
M(Gt);
|
|
9886
|
+
class Mi extends Gt {
|
|
9887
9887
|
/**
|
|
9888
9888
|
* Constructor of GlorotUniform
|
|
9889
9889
|
* @param scale
|
|
@@ -9900,12 +9900,12 @@ class Mi extends Ut {
|
|
|
9900
9900
|
});
|
|
9901
9901
|
}
|
|
9902
9902
|
getClassName() {
|
|
9903
|
-
return
|
|
9903
|
+
return Gt.className;
|
|
9904
9904
|
}
|
|
9905
9905
|
}
|
|
9906
9906
|
Mi.className = "GlorotUniform";
|
|
9907
9907
|
M(Mi);
|
|
9908
|
-
class Oi extends
|
|
9908
|
+
class Oi extends Gt {
|
|
9909
9909
|
/**
|
|
9910
9910
|
* Constructor of GlorotNormal.
|
|
9911
9911
|
* @param scale
|
|
@@ -9922,12 +9922,12 @@ class Oi extends Ut {
|
|
|
9922
9922
|
});
|
|
9923
9923
|
}
|
|
9924
9924
|
getClassName() {
|
|
9925
|
-
return
|
|
9925
|
+
return Gt.className;
|
|
9926
9926
|
}
|
|
9927
9927
|
}
|
|
9928
9928
|
Oi.className = "GlorotNormal";
|
|
9929
9929
|
M(Oi);
|
|
9930
|
-
class Bi extends
|
|
9930
|
+
class Bi extends Gt {
|
|
9931
9931
|
constructor(t) {
|
|
9932
9932
|
super({
|
|
9933
9933
|
scale: 2,
|
|
@@ -9937,12 +9937,12 @@ class Bi extends Ut {
|
|
|
9937
9937
|
});
|
|
9938
9938
|
}
|
|
9939
9939
|
getClassName() {
|
|
9940
|
-
return
|
|
9940
|
+
return Gt.className;
|
|
9941
9941
|
}
|
|
9942
9942
|
}
|
|
9943
9943
|
Bi.className = "HeNormal";
|
|
9944
9944
|
M(Bi);
|
|
9945
|
-
class Fi extends
|
|
9945
|
+
class Fi extends Gt {
|
|
9946
9946
|
constructor(t) {
|
|
9947
9947
|
super({
|
|
9948
9948
|
scale: 2,
|
|
@@ -9952,12 +9952,12 @@ class Fi extends Ut {
|
|
|
9952
9952
|
});
|
|
9953
9953
|
}
|
|
9954
9954
|
getClassName() {
|
|
9955
|
-
return
|
|
9955
|
+
return Gt.className;
|
|
9956
9956
|
}
|
|
9957
9957
|
}
|
|
9958
9958
|
Fi.className = "HeUniform";
|
|
9959
9959
|
M(Fi);
|
|
9960
|
-
class zi extends
|
|
9960
|
+
class zi extends Gt {
|
|
9961
9961
|
constructor(t) {
|
|
9962
9962
|
super({
|
|
9963
9963
|
scale: 1,
|
|
@@ -9967,12 +9967,12 @@ class zi extends Ut {
|
|
|
9967
9967
|
});
|
|
9968
9968
|
}
|
|
9969
9969
|
getClassName() {
|
|
9970
|
-
return
|
|
9970
|
+
return Gt.className;
|
|
9971
9971
|
}
|
|
9972
9972
|
}
|
|
9973
9973
|
zi.className = "LeCunNormal";
|
|
9974
9974
|
M(zi);
|
|
9975
|
-
class Ui extends
|
|
9975
|
+
class Ui extends Gt {
|
|
9976
9976
|
constructor(t) {
|
|
9977
9977
|
super({
|
|
9978
9978
|
scale: 1,
|
|
@@ -9982,7 +9982,7 @@ class Ui extends Ut {
|
|
|
9982
9982
|
});
|
|
9983
9983
|
}
|
|
9984
9984
|
getClassName() {
|
|
9985
|
-
return
|
|
9985
|
+
return Gt.className;
|
|
9986
9986
|
}
|
|
9987
9987
|
}
|
|
9988
9988
|
Ui.className = "LeCunUniform";
|
|
@@ -10033,12 +10033,12 @@ const Va = {
|
|
|
10033
10033
|
zeros: "Zeros"
|
|
10034
10034
|
};
|
|
10035
10035
|
function qa(n, t = {}) {
|
|
10036
|
-
return
|
|
10036
|
+
return Ts(n, Qt.getMap().classNameMap, t, "initializer");
|
|
10037
10037
|
}
|
|
10038
10038
|
function xr(n) {
|
|
10039
10039
|
return Ni(n);
|
|
10040
10040
|
}
|
|
10041
|
-
function
|
|
10041
|
+
function Ss(n) {
|
|
10042
10042
|
if (typeof n == "string") {
|
|
10043
10043
|
const t = n in Va ? Va[n] : n;
|
|
10044
10044
|
if (t === "GlorotNormal")
|
|
@@ -10072,7 +10072,7 @@ function xs(n) {
|
|
|
10072
10072
|
function Sr(n) {
|
|
10073
10073
|
return n.length === 0 ? [] : Array.isArray(n[0]) ? n : [n];
|
|
10074
10074
|
}
|
|
10075
|
-
function
|
|
10075
|
+
function Vt(n) {
|
|
10076
10076
|
let t;
|
|
10077
10077
|
if (Array.isArray(n)) {
|
|
10078
10078
|
if (n.length !== 1)
|
|
@@ -10235,7 +10235,7 @@ class Wi {
|
|
|
10235
10235
|
}
|
|
10236
10236
|
}
|
|
10237
10237
|
let pw = 0;
|
|
10238
|
-
class ge extends
|
|
10238
|
+
class ge extends Yn {
|
|
10239
10239
|
constructor(t = {}) {
|
|
10240
10240
|
super(), this._callHook = null, this._addedWeightNames = [], this._stateful = !1, this.id = pw++, this.activityRegularizer = null, this.inputSpec = null, this.supportsMasking = !1, this._trainableWeights = [], this._nonTrainableWeights = [], this._losses = [], this._updates = [], this._built = !1, this.inboundNodes = [], this.outboundNodes = [];
|
|
10241
10241
|
let e = t.name;
|
|
@@ -10278,7 +10278,7 @@ class ge extends Kn {
|
|
|
10278
10278
|
*/
|
|
10279
10279
|
getNodeAtIndex(t, e) {
|
|
10280
10280
|
if (this.inboundNodes.length === 0)
|
|
10281
|
-
throw new
|
|
10281
|
+
throw new qe(`The layer has never been called and thus has no defined ${e}.`);
|
|
10282
10282
|
if (this.inboundNodes.length <= t)
|
|
10283
10283
|
throw new I(`Asked to get ${e} at node ${t}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);
|
|
10284
10284
|
return this.inboundNodes[t];
|
|
@@ -10293,7 +10293,7 @@ class ge extends Kn {
|
|
|
10293
10293
|
* @return A tensor (or list of tensors if the layer has multiple inputs).
|
|
10294
10294
|
*/
|
|
10295
10295
|
getInputAt(t) {
|
|
10296
|
-
return
|
|
10296
|
+
return zt(this.getNodeAtIndex(t, "input").inputTensors);
|
|
10297
10297
|
}
|
|
10298
10298
|
/**
|
|
10299
10299
|
* Retrieves the output tensor(s) of a layer at a given node.
|
|
@@ -10305,7 +10305,7 @@ class ge extends Kn {
|
|
|
10305
10305
|
* @return A tensor (or list of tensors if the layer has multiple outputs).
|
|
10306
10306
|
*/
|
|
10307
10307
|
getOutputAt(t) {
|
|
10308
|
-
return
|
|
10308
|
+
return zt(this.getNodeAtIndex(t, "output").outputTensors);
|
|
10309
10309
|
}
|
|
10310
10310
|
// Properties
|
|
10311
10311
|
/**
|
|
@@ -10321,10 +10321,10 @@ class ge extends Kn {
|
|
|
10321
10321
|
*/
|
|
10322
10322
|
get input() {
|
|
10323
10323
|
if (this.inboundNodes.length > 1)
|
|
10324
|
-
throw new
|
|
10324
|
+
throw new Fe(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);
|
|
10325
10325
|
if (this.inboundNodes.length === 0)
|
|
10326
|
-
throw new
|
|
10327
|
-
return
|
|
10326
|
+
throw new Fe(`Layer ${this.name} is not connected, no input to return.`);
|
|
10327
|
+
return zt(this.getNodeAtIndex(0, "input").inputTensors);
|
|
10328
10328
|
}
|
|
10329
10329
|
/**
|
|
10330
10330
|
* Retrieves the output tensor(s) of a layer.
|
|
@@ -10339,10 +10339,10 @@ class ge extends Kn {
|
|
|
10339
10339
|
*/
|
|
10340
10340
|
get output() {
|
|
10341
10341
|
if (this.inboundNodes.length === 0)
|
|
10342
|
-
throw new
|
|
10342
|
+
throw new Fe(`Layer ${this.name} has no inbound nodes.`);
|
|
10343
10343
|
if (this.inboundNodes.length > 1)
|
|
10344
|
-
throw new
|
|
10345
|
-
return
|
|
10344
|
+
throw new Fe(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);
|
|
10345
|
+
return zt(this.getNodeAtIndex(0, "output").outputTensors);
|
|
10346
10346
|
}
|
|
10347
10347
|
get losses() {
|
|
10348
10348
|
return this._losses;
|
|
@@ -10560,7 +10560,7 @@ class ge extends Kn {
|
|
|
10560
10560
|
const i = [];
|
|
10561
10561
|
for (const a of st(t))
|
|
10562
10562
|
i.push(a.shape);
|
|
10563
|
-
this.build(
|
|
10563
|
+
this.build(zt(i)), this.built = !0, this.initialWeights && this.setWeights(this.initialWeights), this._refCount === null && o && (this._refCount = 1);
|
|
10564
10564
|
}
|
|
10565
10565
|
if (this.assertInputCompatibility(t), o) {
|
|
10566
10566
|
let i = this.call(t, e);
|
|
@@ -10568,7 +10568,7 @@ class ge extends Kn {
|
|
|
10568
10568
|
const a = st(i), l = [];
|
|
10569
10569
|
for (let u of a)
|
|
10570
10570
|
s.indexOf(u) !== -1 && (u = u.clone()), l.push(u);
|
|
10571
|
-
if (i =
|
|
10571
|
+
if (i = zt(l), this.activityRegularizer != null)
|
|
10572
10572
|
throw new J("Layer invocation in the presence of activity regularizer(s) is not supported yet.");
|
|
10573
10573
|
return i;
|
|
10574
10574
|
} else {
|
|
@@ -10613,7 +10613,7 @@ class ge extends Kn {
|
|
|
10613
10613
|
*/
|
|
10614
10614
|
get outputShape() {
|
|
10615
10615
|
if (this.inboundNodes == null || this.inboundNodes.length === 0)
|
|
10616
|
-
throw new
|
|
10616
|
+
throw new Fe(`The layer ${this.name} has never been called and thus has no defined output shape.`);
|
|
10617
10617
|
const t = [];
|
|
10618
10618
|
for (const e of this.inboundNodes) {
|
|
10619
10619
|
const s = JSON.stringify(e.outputShapes);
|
|
@@ -10623,7 +10623,7 @@ class ge extends Kn {
|
|
|
10623
10623
|
const e = this.inboundNodes[0].outputShapes;
|
|
10624
10624
|
return Array.isArray(e) && Array.isArray(e[0]) && e.length === 1 ? e[0] : e;
|
|
10625
10625
|
} else
|
|
10626
|
-
throw new
|
|
10626
|
+
throw new Fe(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`);
|
|
10627
10627
|
}
|
|
10628
10628
|
/**
|
|
10629
10629
|
* Counts the total number of numbers (e.g., float32, int32) in the
|
|
@@ -10637,7 +10637,7 @@ class ge extends Kn {
|
|
|
10637
10637
|
*/
|
|
10638
10638
|
countParams() {
|
|
10639
10639
|
if (!this.built)
|
|
10640
|
-
throw new
|
|
10640
|
+
throw new qe(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);
|
|
10641
10641
|
return $r(this.weights);
|
|
10642
10642
|
}
|
|
10643
10643
|
/**
|
|
@@ -10712,7 +10712,7 @@ class ge extends Kn {
|
|
|
10712
10712
|
addWeight(t, e, s, r, o, i, a, l) {
|
|
10713
10713
|
if (this._addedWeightNames.indexOf(t) !== -1)
|
|
10714
10714
|
throw new I(`Duplicate weight name ${t} for layer ${this.name}`);
|
|
10715
|
-
this._addedWeightNames.push(t), s == null && (s = "float32"), this.fastWeightInitDuringBuild && (r = l != null ? l() :
|
|
10715
|
+
this._addedWeightNames.push(t), s == null && (s = "float32"), this.fastWeightInitDuringBuild && (r = l != null ? l() : Ss("zeros"));
|
|
10716
10716
|
const u = r.apply(e, s), c = new hw(u, s, t, i, a);
|
|
10717
10717
|
return u.dispose(), o != null && this.addLoss(() => o.apply(c.read())), i == null && (i = !0), i ? this._trainableWeights.push(c) : this._nonTrainableWeights.push(c), c;
|
|
10718
10718
|
}
|
|
@@ -10901,7 +10901,7 @@ function mw(n) {
|
|
|
10901
10901
|
const t = [];
|
|
10902
10902
|
for (const e of n)
|
|
10903
10903
|
t.push(e.shape);
|
|
10904
|
-
return
|
|
10904
|
+
return zt(t);
|
|
10905
10905
|
}
|
|
10906
10906
|
function gw(n) {
|
|
10907
10907
|
return "float32";
|
|
@@ -10937,7 +10937,7 @@ function ww(n) {
|
|
|
10937
10937
|
if (n != null && typeof n != "object")
|
|
10938
10938
|
throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${n}`);
|
|
10939
10939
|
}
|
|
10940
|
-
class Lc extends
|
|
10940
|
+
class Lc extends Yn {
|
|
10941
10941
|
}
|
|
10942
10942
|
class Mc extends Lc {
|
|
10943
10943
|
constructor(t) {
|
|
@@ -10949,8 +10949,8 @@ class Mc extends Lc {
|
|
|
10949
10949
|
*/
|
|
10950
10950
|
apply(t) {
|
|
10951
10951
|
return C(() => {
|
|
10952
|
-
let e =
|
|
10953
|
-
return this.hasL1 && (e = O(e, et(N(this.l1, Nt(t))))), this.hasL2 && (e = O(e, et(N(this.l2,
|
|
10952
|
+
let e = zn([1]);
|
|
10953
|
+
return this.hasL1 && (e = O(e, et(N(this.l1, Nt(t))))), this.hasL2 && (e = O(e, et(N(this.l2, Ns(t))))), L(e, []);
|
|
10954
10954
|
});
|
|
10955
10955
|
}
|
|
10956
10956
|
getConfig() {
|
|
@@ -10966,13 +10966,13 @@ M(Mc);
|
|
|
10966
10966
|
const Ka = {
|
|
10967
10967
|
l1l2: "L1L2"
|
|
10968
10968
|
};
|
|
10969
|
-
function
|
|
10969
|
+
function $s(n) {
|
|
10970
10970
|
return Ni(n);
|
|
10971
10971
|
}
|
|
10972
10972
|
function Ya(n, t = {}) {
|
|
10973
|
-
return
|
|
10973
|
+
return Ts(n, Qt.getMap().classNameMap, t, "regularizer");
|
|
10974
10974
|
}
|
|
10975
|
-
function
|
|
10975
|
+
function vs(n) {
|
|
10976
10976
|
if (n == null)
|
|
10977
10977
|
return null;
|
|
10978
10978
|
if (typeof n == "string") {
|
|
@@ -11037,7 +11037,7 @@ function Bc(n, t) {
|
|
|
11037
11037
|
}
|
|
11038
11038
|
function xw(n, t, e, s = 1, r = "valid", o, i = 1) {
|
|
11039
11039
|
return C(() => {
|
|
11040
|
-
if (o == null && (o =
|
|
11040
|
+
if (o == null && (o = Jn()), gt(o), n.shape.length !== 3)
|
|
11041
11041
|
throw new I(`The input of a conv1dWithBias operation should be 3, but is ${n.shape.length} instead.`);
|
|
11042
11042
|
if (t.shape.length !== 3)
|
|
11043
11043
|
throw new I(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);
|
|
@@ -11046,12 +11046,12 @@ function xw(n, t, e, s = 1, r = "valid", o, i = 1) {
|
|
|
11046
11046
|
if (o === "channelsFirst" && (n = pt(n, [0, 2, 1])), r === "causal")
|
|
11047
11047
|
throw new J("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");
|
|
11048
11048
|
let a = Ym(n, t, s, r === "same" ? "same" : "valid", "NWC", i);
|
|
11049
|
-
return e != null && (a =
|
|
11049
|
+
return e != null && (a = Ds(a, e)), a;
|
|
11050
11050
|
});
|
|
11051
11051
|
}
|
|
11052
11052
|
function Xa(n, t, e, s = [1, 1], r = "valid", o, i, a = null) {
|
|
11053
11053
|
return C(() => {
|
|
11054
|
-
if (o == null && (o =
|
|
11054
|
+
if (o == null && (o = Jn()), gt(o), n.rank !== 3 && n.rank !== 4)
|
|
11055
11055
|
throw new I(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${n.rank}.`);
|
|
11056
11056
|
if (t.rank !== 3 && t.rank !== 4)
|
|
11057
11057
|
throw new I(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${n.rank}.`);
|
|
@@ -11072,21 +11072,21 @@ function Xa(n, t, e, s = [1, 1], r = "valid", o, i, a = null) {
|
|
|
11072
11072
|
}
|
|
11073
11073
|
function Sw(n, t, e, s = [1, 1, 1], r = "valid", o, i) {
|
|
11074
11074
|
return C(() => {
|
|
11075
|
-
if (o == null && (o =
|
|
11075
|
+
if (o == null && (o = Jn()), gt(o), n.rank !== 4 && n.rank !== 5)
|
|
11076
11076
|
throw new I(`conv3dWithBias expects input to be of rank 4 or 5, but received ${n.rank}.`);
|
|
11077
11077
|
if (t.rank !== 4 && t.rank !== 5)
|
|
11078
11078
|
throw new I(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${n.rank}.`);
|
|
11079
11079
|
let a = Bc(n, o);
|
|
11080
11080
|
if (r === "causal")
|
|
11081
11081
|
throw new J("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");
|
|
11082
|
-
return a = tg(a, t, s, r === "same" ? "same" : "valid", "NDHWC", i), e != null && (a =
|
|
11082
|
+
return a = tg(a, t, s, r === "same" ? "same" : "valid", "NDHWC", i), e != null && (a = Ds(a, e)), o === "channelsFirst" && (a = pt(a, [0, 4, 1, 2, 3])), a;
|
|
11083
11083
|
});
|
|
11084
11084
|
}
|
|
11085
11085
|
class Gi extends ge {
|
|
11086
11086
|
constructor(t, e) {
|
|
11087
11087
|
if (super(e), this.bias = null, this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_BIAS_INITIALIZER = "zeros", Gi.verifyArgs(e), this.rank = t, Le(this.rank, "rank"), this.rank !== 1 && this.rank !== 2 && this.rank !== 3)
|
|
11088
11088
|
throw new J(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);
|
|
11089
|
-
if (this.kernelSize = po(e.kernelSize, t, "kernelSize"), this.strides = po(e.strides == null ? 1 : e.strides, t, "strides"), this.padding = e.padding == null ? "valid" : e.padding, oe(this.padding), this.dataFormat = e.dataFormat == null ? "channelsLast" : e.dataFormat, gt(this.dataFormat), this.activation = rw(e.activation), this.useBias = e.useBias == null ? !0 : e.useBias, this.biasInitializer =
|
|
11089
|
+
if (this.kernelSize = po(e.kernelSize, t, "kernelSize"), this.strides = po(e.strides == null ? 1 : e.strides, t, "strides"), this.padding = e.padding == null ? "valid" : e.padding, oe(this.padding), this.dataFormat = e.dataFormat == null ? "channelsLast" : e.dataFormat, gt(this.dataFormat), this.activation = rw(e.activation), this.useBias = e.useBias == null ? !0 : e.useBias, this.biasInitializer = Ss(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.biasConstraint = wr(e.biasConstraint), this.biasRegularizer = vs(e.biasRegularizer), this.activityRegularizer = vs(e.activityRegularizer), this.dilationRate = po(e.dilationRate == null ? 1 : e.dilationRate, t, "dilationRate"), this.rank === 1 && Array.isArray(this.dilationRate) && this.dilationRate.length !== 1)
|
|
11090
11090
|
throw new I(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);
|
|
11091
11091
|
if (this.rank === 2) {
|
|
11092
11092
|
if (typeof this.dilationRate == "number")
|
|
@@ -11114,16 +11114,16 @@ class Gi extends ge {
|
|
|
11114
11114
|
activation: sw(this.activation),
|
|
11115
11115
|
useBias: this.useBias,
|
|
11116
11116
|
biasInitializer: xr(this.biasInitializer),
|
|
11117
|
-
biasRegularizer:
|
|
11118
|
-
activityRegularizer:
|
|
11117
|
+
biasRegularizer: $s(this.biasRegularizer),
|
|
11118
|
+
activityRegularizer: $s(this.activityRegularizer),
|
|
11119
11119
|
biasConstraint: yr(this.biasConstraint)
|
|
11120
11120
|
}, e = super.getConfig();
|
|
11121
11121
|
return Object.assign(t, e), t;
|
|
11122
11122
|
}
|
|
11123
11123
|
}
|
|
11124
|
-
class
|
|
11124
|
+
class Zn extends Gi {
|
|
11125
11125
|
constructor(t, e) {
|
|
11126
|
-
super(t, e), this.kernel = null,
|
|
11126
|
+
super(t, e), this.kernel = null, Zn.verifyArgs(e), this.filters = e.filters, Le(this.filters, "filters"), this.kernelInitializer = Ss(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.kernelConstraint = wr(e.kernelConstraint), this.kernelRegularizer = vs(e.kernelRegularizer);
|
|
11127
11127
|
}
|
|
11128
11128
|
build(t) {
|
|
11129
11129
|
t = pe(t);
|
|
@@ -11135,7 +11135,7 @@ class Jn extends Gi {
|
|
|
11135
11135
|
}
|
|
11136
11136
|
call(t, e) {
|
|
11137
11137
|
return C(() => {
|
|
11138
|
-
t =
|
|
11138
|
+
t = Vt(t);
|
|
11139
11139
|
let s;
|
|
11140
11140
|
const r = this.bias == null ? null : this.bias.read(), o = qy(this.activation.getClassName());
|
|
11141
11141
|
if (o != null && this.rank === 2)
|
|
@@ -11168,7 +11168,7 @@ class Jn extends Gi {
|
|
|
11168
11168
|
const t = {
|
|
11169
11169
|
filters: this.filters,
|
|
11170
11170
|
kernelInitializer: xr(this.kernelInitializer),
|
|
11171
|
-
kernelRegularizer:
|
|
11171
|
+
kernelRegularizer: $s(this.kernelRegularizer),
|
|
11172
11172
|
kernelConstraint: yr(this.kernelConstraint)
|
|
11173
11173
|
}, e = super.getConfig();
|
|
11174
11174
|
return Object.assign(t, e), t;
|
|
@@ -11178,9 +11178,9 @@ class Jn extends Gi {
|
|
|
11178
11178
|
throw new I(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(t.filters)}`);
|
|
11179
11179
|
}
|
|
11180
11180
|
}
|
|
11181
|
-
class
|
|
11181
|
+
class Qn extends Zn {
|
|
11182
11182
|
constructor(t) {
|
|
11183
|
-
super(2, t),
|
|
11183
|
+
super(2, t), Qn.verifyArgs(t);
|
|
11184
11184
|
}
|
|
11185
11185
|
getConfig() {
|
|
11186
11186
|
const t = super.getConfig();
|
|
@@ -11191,11 +11191,11 @@ class Zn extends Jn {
|
|
|
11191
11191
|
throw new I(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(t.kernelSize)}.`);
|
|
11192
11192
|
}
|
|
11193
11193
|
}
|
|
11194
|
-
|
|
11195
|
-
M(
|
|
11196
|
-
class
|
|
11194
|
+
Qn.className = "Conv2D";
|
|
11195
|
+
M(Qn);
|
|
11196
|
+
class Ps extends Zn {
|
|
11197
11197
|
constructor(t) {
|
|
11198
|
-
super(3, t),
|
|
11198
|
+
super(3, t), Ps.verifyArgs(t);
|
|
11199
11199
|
}
|
|
11200
11200
|
getConfig() {
|
|
11201
11201
|
const t = super.getConfig();
|
|
@@ -11206,9 +11206,9 @@ class Rs extends Jn {
|
|
|
11206
11206
|
throw new I(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(t.kernelSize)}.`);
|
|
11207
11207
|
}
|
|
11208
11208
|
}
|
|
11209
|
-
|
|
11210
|
-
M(
|
|
11211
|
-
class Fc extends
|
|
11209
|
+
Ps.className = "Conv3D";
|
|
11210
|
+
M(Ps);
|
|
11211
|
+
class Fc extends Qn {
|
|
11212
11212
|
constructor(t) {
|
|
11213
11213
|
if (super(t), this.inputSpec = [new Ce({ ndim: 4 })], this.padding !== "same" && this.padding !== "valid")
|
|
11214
11214
|
throw new I(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`);
|
|
@@ -11224,7 +11224,7 @@ class Fc extends Zn {
|
|
|
11224
11224
|
}
|
|
11225
11225
|
call(t, e) {
|
|
11226
11226
|
return C(() => {
|
|
11227
|
-
let s =
|
|
11227
|
+
let s = Vt(t);
|
|
11228
11228
|
if (s.shape.length !== 4)
|
|
11229
11229
|
throw new I(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);
|
|
11230
11230
|
const r = s.shape, o = r[0];
|
|
@@ -11233,7 +11233,7 @@ class Fc extends Zn {
|
|
|
11233
11233
|
const l = r[i], u = r[a], c = this.kernelSize[0], h = this.kernelSize[1], f = this.strides[0], d = this.strides[1], p = Ae(l, f, c, this.padding), g = Ae(u, d, h, this.padding), m = [o, p, g, this.filters];
|
|
11234
11234
|
this.dataFormat !== "channelsLast" && (s = pt(s, [0, 2, 3, 1]));
|
|
11235
11235
|
let b = Zm(s, this.kernel.read(), m, this.strides, this.padding);
|
|
11236
|
-
return this.dataFormat !== "channelsLast" && (b = pt(b, [0, 3, 1, 2])), this.bias != null && (b =
|
|
11236
|
+
return this.dataFormat !== "channelsLast" && (b = pt(b, [0, 3, 1, 2])), this.bias != null && (b = Ds(b, this.bias.read(), this.dataFormat)), this.activation != null && (b = this.activation.apply(b)), b;
|
|
11237
11237
|
});
|
|
11238
11238
|
}
|
|
11239
11239
|
computeOutputShape(t) {
|
|
@@ -11251,7 +11251,7 @@ class Fc extends Zn {
|
|
|
11251
11251
|
}
|
|
11252
11252
|
Fc.className = "Conv2DTranspose";
|
|
11253
11253
|
M(Fc);
|
|
11254
|
-
class zc extends
|
|
11254
|
+
class zc extends Ps {
|
|
11255
11255
|
constructor(t) {
|
|
11256
11256
|
if (super(t), this.inputSpec = [new Ce({ ndim: 5 })], this.padding !== "same" && this.padding !== "valid")
|
|
11257
11257
|
throw new I(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`);
|
|
@@ -11267,7 +11267,7 @@ class zc extends Rs {
|
|
|
11267
11267
|
}
|
|
11268
11268
|
call(t, e) {
|
|
11269
11269
|
return C(() => {
|
|
11270
|
-
let s =
|
|
11270
|
+
let s = Vt(t);
|
|
11271
11271
|
if (s.shape.length !== 5)
|
|
11272
11272
|
throw new I(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);
|
|
11273
11273
|
const r = s.shape, o = r[0];
|
|
@@ -11276,7 +11276,7 @@ class zc extends Rs {
|
|
|
11276
11276
|
const u = r[l], c = r[i], h = r[a], f = this.kernelSize[0], d = this.kernelSize[1], p = this.kernelSize[2], g = this.strides[0], m = this.strides[1], b = this.strides[2], y = Ae(u, g, f, this.padding), S = Ae(c, m, d, this.padding), x = Ae(h, b, p, this.padding), $ = [o, y, S, x, this.filters];
|
|
11277
11277
|
this.dataFormat !== "channelsLast" && (s = pt(s, [0, 2, 3, 4, 1]));
|
|
11278
11278
|
let E = rg(s, this.kernel.read(), $, this.strides, this.padding);
|
|
11279
|
-
return this.dataFormat !== "channelsLast" && (E = pt(E, [0, 4, 1, 2, 3])), this.bias !== null && (E =
|
|
11279
|
+
return this.dataFormat !== "channelsLast" && (E = pt(E, [0, 4, 1, 2, 3])), this.bias !== null && (E = Ds(E, this.bias.read(), this.dataFormat)), this.activation !== null && (E = this.activation.apply(E)), E;
|
|
11280
11280
|
});
|
|
11281
11281
|
}
|
|
11282
11282
|
computeOutputShape(t) {
|
|
@@ -11294,7 +11294,7 @@ class zc extends Rs {
|
|
|
11294
11294
|
}
|
|
11295
11295
|
zc.className = "Conv3DTranspose";
|
|
11296
11296
|
M(zc);
|
|
11297
|
-
class Uc extends
|
|
11297
|
+
class Uc extends Zn {
|
|
11298
11298
|
constructor(t, e) {
|
|
11299
11299
|
if (super(t, e), this.DEFAULT_DEPTHWISE_INITIALIZER = "glorotUniform", this.DEFAULT_POINTWISE_INITIALIZER = "glorotUniform", this.depthwiseKernel = null, this.pointwiseKernel = null, e.filters == null)
|
|
11300
11300
|
throw new I("The `filters` configuration field is required by SeparableConv, but is unspecified.");
|
|
@@ -11302,7 +11302,7 @@ class Uc extends Jn {
|
|
|
11302
11302
|
throw new I("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");
|
|
11303
11303
|
if (e.padding != null && e.padding !== "same" && e.padding !== "valid")
|
|
11304
11304
|
throw new I(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(e.padding)}`);
|
|
11305
|
-
this.depthMultiplier = e.depthMultiplier == null ? 1 : e.depthMultiplier, this.depthwiseInitializer =
|
|
11305
|
+
this.depthMultiplier = e.depthMultiplier == null ? 1 : e.depthMultiplier, this.depthwiseInitializer = Ss(e.depthwiseInitializer || this.DEFAULT_DEPTHWISE_INITIALIZER), this.depthwiseRegularizer = vs(e.depthwiseRegularizer), this.depthwiseConstraint = wr(e.depthwiseConstraint), this.pointwiseInitializer = Ss(e.depthwiseInitializer || this.DEFAULT_POINTWISE_INITIALIZER), this.pointwiseRegularizer = vs(e.pointwiseRegularizer), this.pointwiseConstraint = wr(e.pointwiseConstraint);
|
|
11306
11306
|
}
|
|
11307
11307
|
build(t) {
|
|
11308
11308
|
if (t = pe(t), t.length < this.rank + 2)
|
|
@@ -11319,16 +11319,16 @@ class Uc extends Jn {
|
|
|
11319
11319
|
}
|
|
11320
11320
|
call(t, e) {
|
|
11321
11321
|
return C(() => {
|
|
11322
|
-
t =
|
|
11322
|
+
t = Vt(t);
|
|
11323
11323
|
let s;
|
|
11324
11324
|
if (this.rank === 1)
|
|
11325
11325
|
throw new J("1D separable convolution is not implemented yet.");
|
|
11326
|
-
return this.rank === 2 && (this.dataFormat === "channelsFirst" && (t = pt(t, [0, 2, 3, 1])), s = U0(t, this.depthwiseKernel.read(), this.pointwiseKernel.read(), this.strides, this.padding, this.dilationRate, "NHWC")), this.useBias && (s =
|
|
11326
|
+
return this.rank === 2 && (this.dataFormat === "channelsFirst" && (t = pt(t, [0, 2, 3, 1])), s = U0(t, this.depthwiseKernel.read(), this.pointwiseKernel.read(), this.strides, this.padding, this.dilationRate, "NHWC")), this.useBias && (s = Ds(s, this.bias.read(), this.dataFormat)), this.activation != null && (s = this.activation.apply(s)), this.dataFormat === "channelsFirst" && (s = pt(s, [0, 3, 1, 2])), s;
|
|
11327
11327
|
});
|
|
11328
11328
|
}
|
|
11329
11329
|
getConfig() {
|
|
11330
11330
|
const t = super.getConfig();
|
|
11331
|
-
return delete t.rank, delete t.kernelInitializer, delete t.kernelRegularizer, delete t.kernelConstraint, t.depthwiseInitializer = xr(this.depthwiseInitializer), t.pointwiseInitializer = xr(this.pointwiseInitializer), t.depthwiseRegularizer =
|
|
11331
|
+
return delete t.rank, delete t.kernelInitializer, delete t.kernelRegularizer, delete t.kernelConstraint, t.depthwiseInitializer = xr(this.depthwiseInitializer), t.pointwiseInitializer = xr(this.pointwiseInitializer), t.depthwiseRegularizer = $s(this.depthwiseRegularizer), t.pointwiseRegularizer = $s(this.pointwiseRegularizer), t.depthwiseConstraint = yr(this.depthwiseConstraint), t.pointwiseConstraint = yr(this.pointwiseConstraint), t;
|
|
11332
11332
|
}
|
|
11333
11333
|
}
|
|
11334
11334
|
Uc.className = "SeparableConv";
|
|
@@ -11339,7 +11339,7 @@ class Wc extends Uc {
|
|
|
11339
11339
|
}
|
|
11340
11340
|
Wc.className = "SeparableConv2D";
|
|
11341
11341
|
M(Wc);
|
|
11342
|
-
class qr extends
|
|
11342
|
+
class qr extends Zn {
|
|
11343
11343
|
constructor(t) {
|
|
11344
11344
|
super(1, t), qr.verifyArgs(t), this.inputSpec = [{ ndim: 3 }];
|
|
11345
11345
|
}
|
|
@@ -11376,7 +11376,7 @@ class Gc extends ge {
|
|
|
11376
11376
|
}
|
|
11377
11377
|
call(t, e) {
|
|
11378
11378
|
return C(() => {
|
|
11379
|
-
if (t =
|
|
11379
|
+
if (t = Vt(t), this.dataFormat === "channelsLast") {
|
|
11380
11380
|
const s = Ws(t, this.cropping[0][0], t.shape[1] - this.cropping[0][0] - this.cropping[0][1], 2);
|
|
11381
11381
|
return Ws(s, this.cropping[1][0], t.shape[2] - this.cropping[1][1] - this.cropping[1][0], 3);
|
|
11382
11382
|
} else {
|
|
@@ -11407,7 +11407,7 @@ class Vi extends ge {
|
|
|
11407
11407
|
}
|
|
11408
11408
|
call(t, e) {
|
|
11409
11409
|
return C(() => {
|
|
11410
|
-
let s =
|
|
11410
|
+
let s = Vt(t);
|
|
11411
11411
|
const r = s.shape;
|
|
11412
11412
|
if (this.dataFormat === "channelsFirst") {
|
|
11413
11413
|
s = pt(s, [0, 2, 3, 1]);
|
|
@@ -11441,7 +11441,7 @@ M(Vi);
|
|
|
11441
11441
|
*/
|
|
11442
11442
|
function jr(n, t, e, s, r, o) {
|
|
11443
11443
|
return C(() => {
|
|
11444
|
-
gt(r), Zu(o), oe(s), e == null && (e = [1, 1]), s == null && (s = "valid"), r == null && (r =
|
|
11444
|
+
gt(r), Zu(o), oe(s), e == null && (e = [1, 1]), s == null && (s = "valid"), r == null && (r = Jn()), o == null && (o = "max"), n = Oc(n, r);
|
|
11445
11445
|
let i;
|
|
11446
11446
|
const a = s === "same" ? "same" : "valid";
|
|
11447
11447
|
return o === "max" ? i = t0(n, t, e, a) : i = Om(
|
|
@@ -11455,7 +11455,7 @@ function jr(n, t, e, s, r, o) {
|
|
|
11455
11455
|
}
|
|
11456
11456
|
function Vc(n, t, e, s, r, o) {
|
|
11457
11457
|
return C(() => {
|
|
11458
|
-
gt(r), Zu(o), oe(s), e == null && (e = [1, 1, 1]), s == null && (s = "valid"), r == null && (r =
|
|
11458
|
+
gt(r), Zu(o), oe(s), e == null && (e = [1, 1, 1]), s == null && (s = "valid"), r == null && (r = Jn()), o == null && (o = "max"), n = Bc(n, r);
|
|
11459
11459
|
let i;
|
|
11460
11460
|
const a = s === "same" ? "same" : "valid";
|
|
11461
11461
|
return o === "max" ? i = n0(n, t, e, a) : i = Fm(n, t, e, a), r === "channelsFirst" && (i = pt(i, [0, 4, 1, 2, 3])), i;
|
|
@@ -11492,8 +11492,8 @@ class qc extends ge {
|
|
|
11492
11492
|
}
|
|
11493
11493
|
call(t, e) {
|
|
11494
11494
|
return C(() => {
|
|
11495
|
-
this.invokeCallHook(t, e), t = Ri(
|
|
11496
|
-
const s = this.poolingFunction(
|
|
11495
|
+
this.invokeCallHook(t, e), t = Ri(Vt(t), 2);
|
|
11496
|
+
const s = this.poolingFunction(Vt(t), [this.poolSize[0], 1], [this.strides[0], 1], this.padding, "channelsLast");
|
|
11497
11497
|
return Vr(s, [2]);
|
|
11498
11498
|
});
|
|
11499
11499
|
}
|
|
@@ -11544,7 +11544,7 @@ class Kc extends ge {
|
|
|
11544
11544
|
return e = un(e, this.poolSize[0], this.padding, this.strides[0]), s = un(s, this.poolSize[1], this.padding, this.strides[1]), this.dataFormat === "channelsFirst" ? [t[0], t[1], e, s] : [t[0], e, s, t[3]];
|
|
11545
11545
|
}
|
|
11546
11546
|
call(t, e) {
|
|
11547
|
-
return C(() => (this.invokeCallHook(t, e), this.poolingFunction(
|
|
11547
|
+
return C(() => (this.invokeCallHook(t, e), this.poolingFunction(Vt(t), this.poolSize, this.strides, this.padding, this.dataFormat)));
|
|
11548
11548
|
}
|
|
11549
11549
|
getConfig() {
|
|
11550
11550
|
const t = {
|
|
@@ -11594,7 +11594,7 @@ class Xc extends ge {
|
|
|
11594
11594
|
return e = un(e, this.poolSize[0], this.padding, this.strides[0]), s = un(s, this.poolSize[1], this.padding, this.strides[1]), r = un(r, this.poolSize[2], this.padding, this.strides[2]), this.dataFormat === "channelsFirst" ? [t[0], t[1], e, s, r] : [t[0], e, s, r, t[4]];
|
|
11595
11595
|
}
|
|
11596
11596
|
call(t, e) {
|
|
11597
|
-
return C(() => (this.invokeCallHook(t, e), this.poolingFunction(
|
|
11597
|
+
return C(() => (this.invokeCallHook(t, e), this.poolingFunction(Vt(t), this.poolSize, this.strides, this.padding, this.dataFormat)));
|
|
11598
11598
|
}
|
|
11599
11599
|
getConfig() {
|
|
11600
11600
|
const t = {
|
|
@@ -11643,7 +11643,7 @@ class th extends Qc {
|
|
|
11643
11643
|
}
|
|
11644
11644
|
call(t, e) {
|
|
11645
11645
|
return C(() => {
|
|
11646
|
-
const s =
|
|
11646
|
+
const s = Vt(t);
|
|
11647
11647
|
return St(s, 1);
|
|
11648
11648
|
});
|
|
11649
11649
|
}
|
|
@@ -11656,8 +11656,8 @@ class eh extends Qc {
|
|
|
11656
11656
|
}
|
|
11657
11657
|
call(t, e) {
|
|
11658
11658
|
return C(() => {
|
|
11659
|
-
const s =
|
|
11660
|
-
return
|
|
11659
|
+
const s = Vt(t);
|
|
11660
|
+
return Ge(s, 1);
|
|
11661
11661
|
});
|
|
11662
11662
|
}
|
|
11663
11663
|
}
|
|
@@ -11681,7 +11681,7 @@ class nh extends ge {
|
|
|
11681
11681
|
class sh extends nh {
|
|
11682
11682
|
call(t, e) {
|
|
11683
11683
|
return C(() => {
|
|
11684
|
-
const s =
|
|
11684
|
+
const s = Vt(t);
|
|
11685
11685
|
return this.dataFormat === "channelsLast" ? St(s, [1, 2]) : St(s, [2, 3]);
|
|
11686
11686
|
});
|
|
11687
11687
|
}
|
|
@@ -11691,8 +11691,8 @@ M(sh);
|
|
|
11691
11691
|
class rh extends nh {
|
|
11692
11692
|
call(t, e) {
|
|
11693
11693
|
return C(() => {
|
|
11694
|
-
const s =
|
|
11695
|
-
return this.dataFormat === "channelsLast" ?
|
|
11694
|
+
const s = Vt(t);
|
|
11695
|
+
return this.dataFormat === "channelsLast" ? Ge(s, [1, 2]) : Ge(s, [2, 3]);
|
|
11696
11696
|
});
|
|
11697
11697
|
}
|
|
11698
11698
|
}
|
|
@@ -11710,12 +11710,12 @@ M(rh);
|
|
|
11710
11710
|
function vr(n, t) {
|
|
11711
11711
|
return C(() => {
|
|
11712
11712
|
n.dtype !== "float32" && (n = ot(n, "float32"));
|
|
11713
|
-
const e = et(
|
|
11713
|
+
const e = et(Ns(n), t, !0), s = Wr(e.shape, mt()), r = de(Hn(e, s));
|
|
11714
11714
|
return X(n, r);
|
|
11715
11715
|
});
|
|
11716
11716
|
}
|
|
11717
11717
|
function Hr(n, t) {
|
|
11718
|
-
return C(() => St(
|
|
11718
|
+
return C(() => St(Ns(Z(t, n)), -1));
|
|
11719
11719
|
}
|
|
11720
11720
|
function ji(n, t) {
|
|
11721
11721
|
return C(() => St(Nt(Z(t, n)), -1));
|
|
@@ -11729,25 +11729,25 @@ function Hi(n, t) {
|
|
|
11729
11729
|
function $w(n, t) {
|
|
11730
11730
|
return C(() => {
|
|
11731
11731
|
const e = fe(t, mt(), Number.MAX_VALUE), s = gn(O(1, e)), r = fe(n, mt(), Number.MAX_VALUE), o = gn(O(1, r));
|
|
11732
|
-
return St(
|
|
11732
|
+
return St(Ns(Z(s, o)), -1);
|
|
11733
11733
|
});
|
|
11734
11734
|
}
|
|
11735
11735
|
function vw(n, t) {
|
|
11736
11736
|
return C(() => {
|
|
11737
|
-
const e =
|
|
11738
|
-
return St(
|
|
11737
|
+
const e = Hn(0, Z(1, N(n, t)));
|
|
11738
|
+
return St(Ns(e), -1);
|
|
11739
11739
|
});
|
|
11740
11740
|
}
|
|
11741
11741
|
function Iw(n, t) {
|
|
11742
11742
|
return C(() => {
|
|
11743
|
-
const e =
|
|
11743
|
+
const e = Hn(0, Z(1, N(n, t)));
|
|
11744
11744
|
return St(e, -1);
|
|
11745
11745
|
});
|
|
11746
11746
|
}
|
|
11747
11747
|
function Aw(n, t) {
|
|
11748
11748
|
return C(() => {
|
|
11749
|
-
const e = et(N(n, t), -1), s =
|
|
11750
|
-
return
|
|
11749
|
+
const e = et(N(n, t), -1), s = Ge(N(Z(1, n), t), -1);
|
|
11750
|
+
return Hn(0, O(1, Z(s, e)));
|
|
11751
11751
|
});
|
|
11752
11752
|
}
|
|
11753
11753
|
function Ew(n, t) {
|
|
@@ -11756,7 +11756,7 @@ function Ew(n, t) {
|
|
|
11756
11756
|
return St(r, -1);
|
|
11757
11757
|
});
|
|
11758
11758
|
}
|
|
11759
|
-
function
|
|
11759
|
+
function Is(n, t, e = !1) {
|
|
11760
11760
|
return C(() => {
|
|
11761
11761
|
if (e)
|
|
11762
11762
|
t = zu(t);
|
|
@@ -11764,7 +11764,7 @@ function vs(n, t, e = !1) {
|
|
|
11764
11764
|
const s = et(t, t.shape.length - 1, !0);
|
|
11765
11765
|
t = X(t, s);
|
|
11766
11766
|
}
|
|
11767
|
-
return t = fe(t, mt(), 1 - mt()),
|
|
11767
|
+
return t = fe(t, mt(), 1 - mt()), jn(et(N(ot(n, "float32"), gn(t)), t.shape.length - 1));
|
|
11768
11768
|
});
|
|
11769
11769
|
}
|
|
11770
11770
|
function Ir(n, t, e = !1) {
|
|
@@ -11772,14 +11772,14 @@ function Ir(n, t, e = !1) {
|
|
|
11772
11772
|
const s = ot(Ng(Xy(n)), "int32");
|
|
11773
11773
|
t = fe(t, mt(), 1 - mt());
|
|
11774
11774
|
const r = t.shape, o = L(a0(s, r[r.length - 1]), r);
|
|
11775
|
-
return
|
|
11775
|
+
return Is(o, t, e);
|
|
11776
11776
|
});
|
|
11777
11777
|
}
|
|
11778
11778
|
function Cw(n, t) {
|
|
11779
11779
|
if (!re(n.shape, t.shape))
|
|
11780
11780
|
throw new I(`logits and labels must have the same shape, but got shapes ${JSON.stringify(n.shape)} and ${JSON.stringify(t.shape)}`);
|
|
11781
11781
|
return C(() => {
|
|
11782
|
-
const e =
|
|
11782
|
+
const e = _s(t), s = jn(Nt(t));
|
|
11783
11783
|
return O(Z(e, N(t, n)), qg(Uo(s)));
|
|
11784
11784
|
});
|
|
11785
11785
|
}
|
|
@@ -11804,7 +11804,7 @@ function _w(n, t) {
|
|
|
11804
11804
|
function oh(n, t) {
|
|
11805
11805
|
return C(() => {
|
|
11806
11806
|
const e = vr(n, -1), s = vr(t, -1), r = N(e, s);
|
|
11807
|
-
return
|
|
11807
|
+
return jn(et(r, -1));
|
|
11808
11808
|
});
|
|
11809
11809
|
}
|
|
11810
11810
|
const Ar = {
|
|
@@ -11816,7 +11816,7 @@ const Ar = {
|
|
|
11816
11816
|
hinge: Iw,
|
|
11817
11817
|
categoricalHinge: Aw,
|
|
11818
11818
|
logcosh: Ew,
|
|
11819
|
-
categoricalCrossentropy:
|
|
11819
|
+
categoricalCrossentropy: Is,
|
|
11820
11820
|
sparseCategoricalCrossentropy: Ir,
|
|
11821
11821
|
binaryCrossentropy: Kr,
|
|
11822
11822
|
kullbackLeiblerDivergence: kw,
|
|
@@ -11921,7 +11921,7 @@ class $n extends ge {
|
|
|
11921
11921
|
const u = l.rank;
|
|
11922
11922
|
if (u == null) {
|
|
11923
11923
|
const c = l.shape, h = c[0], f = c.slice(1).concat([h]);
|
|
11924
|
-
let d = L(l, [h].concat(
|
|
11924
|
+
let d = L(l, [h].concat(ms(c.slice(1))));
|
|
11925
11925
|
d = pt(d, [1, 0]), d = L(d, f), s.push(d), o = !0;
|
|
11926
11926
|
} else if (u > 1) {
|
|
11927
11927
|
const c = br(1, u).concat([0]);
|
|
@@ -12032,7 +12032,7 @@ class uh extends $n {
|
|
|
12032
12032
|
return C(() => {
|
|
12033
12033
|
let e = t[0];
|
|
12034
12034
|
for (let s = 1; s < t.length; ++s)
|
|
12035
|
-
e =
|
|
12035
|
+
e = Hn(e, t[s]);
|
|
12036
12036
|
return e;
|
|
12037
12037
|
});
|
|
12038
12038
|
}
|
|
@@ -12135,7 +12135,7 @@ class Ki extends $n {
|
|
|
12135
12135
|
}
|
|
12136
12136
|
Ki.className = "Concatenate";
|
|
12137
12137
|
M(Ki);
|
|
12138
|
-
function
|
|
12138
|
+
function os(n, t) {
|
|
12139
12139
|
for (; n < 0; )
|
|
12140
12140
|
n += t;
|
|
12141
12141
|
return n;
|
|
@@ -12199,16 +12199,16 @@ class hh extends $n {
|
|
|
12199
12199
|
if (t.length !== 2)
|
|
12200
12200
|
throw new I(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${t.length} input(s).`);
|
|
12201
12201
|
let e = t[0], s = t[1], r;
|
|
12202
|
-
return Array.isArray(this.axes) ? r = this.axes.map((o, i) =>
|
|
12203
|
-
|
|
12204
|
-
|
|
12202
|
+
return Array.isArray(this.axes) ? r = this.axes.map((o, i) => os(o, t[i].shape.length)) : r = [
|
|
12203
|
+
os(this.axes, e.shape.length),
|
|
12204
|
+
os(this.axes, s.shape.length)
|
|
12205
12205
|
], this.normalize && (e = vr(e, r[0]), s = vr(s, r[1])), Tw(e, s, r);
|
|
12206
12206
|
}
|
|
12207
12207
|
interpretAxes(t, e) {
|
|
12208
12208
|
let s;
|
|
12209
12209
|
return Array.isArray(this.axes) ? s = this.axes : s = [
|
|
12210
|
-
|
|
12211
|
-
|
|
12210
|
+
os(this.axes, t.length),
|
|
12211
|
+
os(this.axes, e.length)
|
|
12212
12212
|
], s;
|
|
12213
12213
|
}
|
|
12214
12214
|
computeOutputShape(t) {
|
|
@@ -12282,7 +12282,7 @@ var Ja;
|
|
|
12282
12282
|
n[n.SILENT = 0] = "SILENT", n[n.VERBOSE = 1] = "VERBOSE";
|
|
12283
12283
|
})(Ja || (Ja = {}));
|
|
12284
12284
|
const Nw = 125;
|
|
12285
|
-
class
|
|
12285
|
+
class As {
|
|
12286
12286
|
constructor() {
|
|
12287
12287
|
this.validationData = null;
|
|
12288
12288
|
}
|
|
@@ -12396,7 +12396,7 @@ class Dw {
|
|
|
12396
12396
|
await e.onTrainEnd(t);
|
|
12397
12397
|
}
|
|
12398
12398
|
}
|
|
12399
|
-
class Rw extends
|
|
12399
|
+
class Rw extends As {
|
|
12400
12400
|
constructor() {
|
|
12401
12401
|
super();
|
|
12402
12402
|
}
|
|
@@ -12424,11 +12424,11 @@ class Rw extends Is {
|
|
|
12424
12424
|
for (const s of this.params.metrics)
|
|
12425
12425
|
this.totals[s] != null && (typeof this.totals[s] == "number" ? e[s] = this.totals[s] / this.seen : C(() => {
|
|
12426
12426
|
const r = N(X(1, this.seen), this.totals[s]);
|
|
12427
|
-
e[s] = r, this.totals[s].dispose(),
|
|
12427
|
+
e[s] = r, this.totals[s].dispose(), Pn(e[s]);
|
|
12428
12428
|
}));
|
|
12429
12429
|
}
|
|
12430
12430
|
}
|
|
12431
|
-
class Pw extends
|
|
12431
|
+
class Pw extends As {
|
|
12432
12432
|
async onTrainBegin(t) {
|
|
12433
12433
|
this.epoch = [], this.history = {};
|
|
12434
12434
|
}
|
|
@@ -12455,7 +12455,7 @@ class Pw extends Is {
|
|
|
12455
12455
|
this.history[e[o]][s[o]].dispose(), this.history[e[o]][s[o]] = r[o][0];
|
|
12456
12456
|
}
|
|
12457
12457
|
}
|
|
12458
|
-
class Lw extends
|
|
12458
|
+
class Lw extends As {
|
|
12459
12459
|
constructor(t, e) {
|
|
12460
12460
|
if (super(), this.currentEpoch = 0, this.nowFunc = t.nowFunc, this.nextFrameFunc = t.nextFrameFunc || fy, this.yieldEvery = e || "auto", this.yieldEvery === "auto" && (this.yieldEvery = Nw), this.yieldEvery === "never" && t.onYield != null)
|
|
12461
12461
|
throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");
|
|
@@ -12487,7 +12487,7 @@ class Lw extends Is {
|
|
|
12487
12487
|
}
|
|
12488
12488
|
}
|
|
12489
12489
|
function dh(n, t) {
|
|
12490
|
-
return n == null && (n = {}), n instanceof
|
|
12490
|
+
return n == null && (n = {}), n instanceof As ? [n] : Array.isArray(n) && n[0] instanceof As ? n : st(n).map((s) => new Lw(s, t));
|
|
12491
12491
|
}
|
|
12492
12492
|
class Zt {
|
|
12493
12493
|
/**
|
|
@@ -12569,7 +12569,7 @@ function ph(n, t, e, s, r, o, i, a, l) {
|
|
|
12569
12569
|
* =============================================================================
|
|
12570
12570
|
*/
|
|
12571
12571
|
function mh(n, t = {}, e = !1) {
|
|
12572
|
-
return
|
|
12572
|
+
return Ts(n, Qt.getMap().classNameMap, t, "layer", e);
|
|
12573
12573
|
}
|
|
12574
12574
|
/**
|
|
12575
12575
|
* @license
|
|
@@ -12582,7 +12582,7 @@ function mh(n, t = {}, e = !1) {
|
|
|
12582
12582
|
*/
|
|
12583
12583
|
function gh(n, t) {
|
|
12584
12584
|
return C(() => {
|
|
12585
|
-
const e = N(0.5, Pu(t)), s = sc(
|
|
12585
|
+
const e = N(0.5, Pu(t)), s = sc(ks(t, e), n.dtype);
|
|
12586
12586
|
return St(mn(n, s), -1);
|
|
12587
12587
|
});
|
|
12588
12588
|
}
|
|
@@ -12598,7 +12598,7 @@ function Ow(n, t) {
|
|
|
12598
12598
|
function Bw(n, t) {
|
|
12599
12599
|
return C(() => {
|
|
12600
12600
|
const e = Mw(n, t), s = Ow(n, t), r = O(e, s);
|
|
12601
|
-
return ot(on(
|
|
12601
|
+
return ot(on(ks(r, 0), X(e, r), 0), "float32");
|
|
12602
12602
|
});
|
|
12603
12603
|
}
|
|
12604
12604
|
function Fw(n, t) {
|
|
@@ -12607,7 +12607,7 @@ function Fw(n, t) {
|
|
|
12607
12607
|
function zw(n, t) {
|
|
12608
12608
|
return n.rank === t.rank && (n = Vr(n, [n.rank - 1])), t = ur(t, -1), t.dtype !== n.dtype && (t = ot(t, n.dtype)), ot(mn(n, t), "float32");
|
|
12609
12609
|
}
|
|
12610
|
-
const Uw = Hr, Ww = Hr, Gw = ji, Vw = ji, qw = Hi, jw = Hi, yh =
|
|
12610
|
+
const Uw = Hr, Ww = Hr, Gw = ji, Vw = ji, qw = Hi, jw = Hi, yh = Is, Hw = oh, wh = Ir, Er = {
|
|
12611
12611
|
binaryAccuracy: gh,
|
|
12612
12612
|
categoricalAccuracy: bh,
|
|
12613
12613
|
precision: Bw,
|
|
@@ -12659,12 +12659,12 @@ function Vs(n) {
|
|
|
12659
12659
|
*/
|
|
12660
12660
|
function Yw(n) {
|
|
12661
12661
|
const t = {
|
|
12662
|
-
Adagrad: () =>
|
|
12663
|
-
Adadelta: () =>
|
|
12664
|
-
Adam: () =>
|
|
12665
|
-
Adamax: () =>
|
|
12666
|
-
RMSProp: () =>
|
|
12667
|
-
SGD: () =>
|
|
12662
|
+
Adagrad: () => In.adagrad(0.01),
|
|
12663
|
+
Adadelta: () => In.adadelta(1, 0.95, mt()),
|
|
12664
|
+
Adam: () => In.adam(1e-3, 0.9, 0.999, mt()),
|
|
12665
|
+
Adamax: () => In.adamax(2e-3, 0.9, 0.999, mt(), 0),
|
|
12666
|
+
RMSProp: () => In.rmsprop(1e-3, 0.9, 0, mt()),
|
|
12667
|
+
SGD: () => In.sgd(0.01)
|
|
12668
12668
|
};
|
|
12669
12669
|
if (t.adagrad = t.Adagrad, t.adadelta = t.Adadelta, t.adam = t.Adam, t.adamax = t.Adamax, t.rmsprop = t.RMSProp, t.sgd = t.SGD, n in t)
|
|
12670
12670
|
return t[n]();
|
|
@@ -12951,7 +12951,7 @@ class $h {
|
|
|
12951
12951
|
* https://opensource.org/licenses/MIT.
|
|
12952
12952
|
* =============================================================================
|
|
12953
12953
|
*/
|
|
12954
|
-
class
|
|
12954
|
+
class Ls extends ge {
|
|
12955
12955
|
constructor(t) {
|
|
12956
12956
|
if (super({
|
|
12957
12957
|
dtype: t.dtype,
|
|
@@ -12996,8 +12996,8 @@ class Ps extends ge {
|
|
|
12996
12996
|
};
|
|
12997
12997
|
}
|
|
12998
12998
|
}
|
|
12999
|
-
|
|
13000
|
-
M(
|
|
12999
|
+
Ls.className = "InputLayer";
|
|
13000
|
+
M(Ls);
|
|
13001
13001
|
function e1(n) {
|
|
13002
13002
|
if (n.batchShape == null && n.shape == null)
|
|
13003
13003
|
throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");
|
|
@@ -13006,7 +13006,7 @@ function e1(n) {
|
|
|
13006
13006
|
let t = n.batchShape;
|
|
13007
13007
|
n.shape != null && t == null && (t = [null].concat(n.shape));
|
|
13008
13008
|
let e = n.dtype;
|
|
13009
|
-
return e == null && (e = "float32"), new
|
|
13009
|
+
return e == null && (e = "float32"), new Ls({
|
|
13010
13010
|
batchInputShape: t,
|
|
13011
13011
|
name: n.name,
|
|
13012
13012
|
dtype: e,
|
|
@@ -13031,14 +13031,14 @@ function n1(n, t) {
|
|
|
13031
13031
|
throw new I(`The dtype of the feed (${t.dtype}) can not be cast to the dtype of the key '${n.name}' (${n.dtype}).`);
|
|
13032
13032
|
}
|
|
13033
13033
|
}
|
|
13034
|
-
class
|
|
13034
|
+
class Ue {
|
|
13035
13035
|
/**
|
|
13036
13036
|
* Constructor, optionally does copy-construction.
|
|
13037
13037
|
* @param feeds An Array of `Feed`s, or another `FeedDict`, in which case
|
|
13038
13038
|
* copy-construction will be performed.
|
|
13039
13039
|
*/
|
|
13040
13040
|
constructor(t) {
|
|
13041
|
-
if (this.id2Value = {}, this.id2Mask = {}, this.name2Id = {}, t instanceof
|
|
13041
|
+
if (this.id2Value = {}, this.id2Mask = {}, this.name2Id = {}, t instanceof Ue)
|
|
13042
13042
|
for (const e in t.id2Value)
|
|
13043
13043
|
this.id2Value[e] = t.id2Value[e], e in t.id2Mask && (this.id2Mask[e] = t.id2Mask[e]);
|
|
13044
13044
|
else {
|
|
@@ -13130,7 +13130,7 @@ class ze {
|
|
|
13130
13130
|
}
|
|
13131
13131
|
}
|
|
13132
13132
|
const tl = new $h(), el = new $h();
|
|
13133
|
-
function
|
|
13133
|
+
function cs(n, t, e, s) {
|
|
13134
13134
|
const r = e == null ? !1 : e.training, o = Array.isArray(n), i = o ? n : [n], a = i.map((p) => p.name), l = [], u = t.names();
|
|
13135
13135
|
for (const p of a)
|
|
13136
13136
|
u.indexOf(p) !== -1 ? l.push(t.getValue(p)) : l.push(null);
|
|
@@ -13141,10 +13141,10 @@ function us(n, t, e, s) {
|
|
|
13141
13141
|
h = p.sorted, f = p.recipientCounts, tl.put(c, h), el.put(c, f);
|
|
13142
13142
|
}
|
|
13143
13143
|
f = {}, r || Object.assign(f, el.get(c));
|
|
13144
|
-
const d = new
|
|
13144
|
+
const d = new Ue(t);
|
|
13145
13145
|
for (let p = 0; p < h.length; ++p) {
|
|
13146
13146
|
const g = h[p], m = g.sourceLayer;
|
|
13147
|
-
if (m instanceof
|
|
13147
|
+
if (m instanceof Ls)
|
|
13148
13148
|
continue;
|
|
13149
13149
|
const b = [], y = [], S = [];
|
|
13150
13150
|
let x = !1;
|
|
@@ -13267,7 +13267,7 @@ class ce extends ge {
|
|
|
13267
13267
|
this.inputNames = [], this.outputNames = [], this.feedInputShapes = [], this.feedInputNames = [], this.feedOutputNames = [];
|
|
13268
13268
|
for (let y = 0; y < this.inputLayers.length; y++) {
|
|
13269
13269
|
const S = this.inputLayers[y];
|
|
13270
|
-
if (!(S instanceof
|
|
13270
|
+
if (!(S instanceof Ls))
|
|
13271
13271
|
throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${t.inputs}. Input ${y} (0-based) originates from layer type ${S.getClassName()}.`);
|
|
13272
13272
|
this.inputNames.push(S.name), this.feedInputShapes.push(S.batchInputShape), this.feedInputNames.push(S.name);
|
|
13273
13273
|
}
|
|
@@ -13278,7 +13278,7 @@ class ce extends ge {
|
|
|
13278
13278
|
($ == null || E == null || D == null) && ($ = y.sourceLayer, E = y.nodeIndex, D = y.tensorIndex);
|
|
13279
13279
|
const _ = $.inboundNodes[E];
|
|
13280
13280
|
if (x.indexOf(_) !== -1)
|
|
13281
|
-
throw new
|
|
13281
|
+
throw new qe(`The tensor ${y.name} at layer "${$.name}" is part of a cycle.`);
|
|
13282
13282
|
if (S.indexOf(_) !== -1)
|
|
13283
13283
|
return;
|
|
13284
13284
|
this.containerNodes.add(ce.nodeKey($, E)), $.id in i || (i[$.id] = Object.keys(i).length), x.indexOf(_) === -1 && x.push(_);
|
|
@@ -13333,7 +13333,7 @@ class ce extends ge {
|
|
|
13333
13333
|
if (x != null) {
|
|
13334
13334
|
for (const $ of S.inputTensors)
|
|
13335
13335
|
if (g.indexOf($) === -1)
|
|
13336
|
-
throw new
|
|
13336
|
+
throw new qe(`Graph disconnected: cannot obtain value for tensor ${$} at layer "${x.name}". The following previous layers were accessed without issue: ${m}`);
|
|
13337
13337
|
for (const $ of S.outputTensors)
|
|
13338
13338
|
g.push($);
|
|
13339
13339
|
m.push(x.name);
|
|
@@ -13344,7 +13344,7 @@ class ce extends ge {
|
|
|
13344
13344
|
for (const y of b) {
|
|
13345
13345
|
const S = b.filter((x) => x === y).length;
|
|
13346
13346
|
if (S !== 1)
|
|
13347
|
-
throw new
|
|
13347
|
+
throw new qe(`The name "${y}" is used ${S} times in the model. All layer names should be unique. Layer names: ` + JSON.stringify(b));
|
|
13348
13348
|
}
|
|
13349
13349
|
this.outboundNodes = [], this.inboundNodes = [], new Wi({
|
|
13350
13350
|
outboundLayer: this,
|
|
@@ -13528,10 +13528,10 @@ class ce extends ge {
|
|
|
13528
13528
|
call(t, e) {
|
|
13529
13529
|
return C(() => {
|
|
13530
13530
|
t = st(t);
|
|
13531
|
-
const s = new
|
|
13531
|
+
const s = new Ue();
|
|
13532
13532
|
for (let r = 0; r < this.inputs.length; ++r)
|
|
13533
13533
|
s.add(this.inputs[r], t[r]);
|
|
13534
|
-
return
|
|
13534
|
+
return cs(this.outputs, s, e);
|
|
13535
13535
|
});
|
|
13536
13536
|
}
|
|
13537
13537
|
/**
|
|
@@ -13581,7 +13581,7 @@ class ce extends ge {
|
|
|
13581
13581
|
const m = u.inboundLayers[g], b = u.nodeIndices[g], y = u.tensorIndices[g], S = `${m.name}_${b}_${y}`, x = s[S];
|
|
13582
13582
|
h.push(x);
|
|
13583
13583
|
}
|
|
13584
|
-
const f = c.computeOutputShape(
|
|
13584
|
+
const f = c.computeOutputShape(zt(h)), d = Sr(f), p = c.inboundNodes.indexOf(u);
|
|
13585
13585
|
for (let g = 0; g < d.length; g++) {
|
|
13586
13586
|
const m = `${c.name}_${p}_${g}`;
|
|
13587
13587
|
s[m] = d[g];
|
|
@@ -13597,7 +13597,7 @@ class ce extends ge {
|
|
|
13597
13597
|
const l = i[a];
|
|
13598
13598
|
Ie(l in s), o.push(s[l]);
|
|
13599
13599
|
}
|
|
13600
|
-
return
|
|
13600
|
+
return zt(o);
|
|
13601
13601
|
}
|
|
13602
13602
|
/**
|
|
13603
13603
|
* Computes output tensors for new inputs.
|
|
@@ -13787,7 +13787,7 @@ class ce extends ge {
|
|
|
13787
13787
|
const T = _.inboundNodes[E];
|
|
13788
13788
|
y.push(T.outputTensors[D]);
|
|
13789
13789
|
}
|
|
13790
|
-
y.length > 0 && m.apply(
|
|
13790
|
+
y.length > 0 && m.apply(zt(y), S);
|
|
13791
13791
|
}
|
|
13792
13792
|
function u(m) {
|
|
13793
13793
|
const b = m.name, y = mh(m, e.customObjects != null ? e.customObjects : {});
|
|
@@ -14012,7 +14012,7 @@ async function h1(n, t, e) {
|
|
|
14012
14012
|
ut(_);
|
|
14013
14013
|
for (let P = 0; P < l.length; ++P) {
|
|
14014
14014
|
const B = l[P], Y = T[P];
|
|
14015
|
-
E[B] = Y,
|
|
14015
|
+
E[B] = Y, Pn(Y);
|
|
14016
14016
|
}
|
|
14017
14017
|
await f.onBatchEnd(y, E), fh(E), y++, b++;
|
|
14018
14018
|
}
|
|
@@ -14083,7 +14083,7 @@ async function p1(n, t, e) {
|
|
|
14083
14083
|
const c = o[u];
|
|
14084
14084
|
o[u] = X(o[u], a), ut(c);
|
|
14085
14085
|
}
|
|
14086
|
-
return
|
|
14086
|
+
return zt(o);
|
|
14087
14087
|
}
|
|
14088
14088
|
/**
|
|
14089
14089
|
* @license
|
|
@@ -14097,7 +14097,7 @@ async function p1(n, t, e) {
|
|
|
14097
14097
|
function go(n) {
|
|
14098
14098
|
w(n > 0 && Number.isInteger(n), () => `batchSize is required to be a positive integer, but got ${n}`);
|
|
14099
14099
|
}
|
|
14100
|
-
function
|
|
14100
|
+
function is(n, t, e) {
|
|
14101
14101
|
return n == null ? [null] : Array.isArray(n) ? n.map((s) => ln(s, t, e - t)) : ln(n, t, e - t);
|
|
14102
14102
|
}
|
|
14103
14103
|
function Ho(n, t) {
|
|
@@ -14242,12 +14242,12 @@ function b1(n, t, e) {
|
|
|
14242
14242
|
const s = [
|
|
14243
14243
|
Hr,
|
|
14244
14244
|
Kr,
|
|
14245
|
-
|
|
14245
|
+
Is
|
|
14246
14246
|
];
|
|
14247
14247
|
for (let r = 0; r < n.length; ++r) {
|
|
14248
14248
|
const o = n[r], i = t[r], a = e[r];
|
|
14249
14249
|
if (i != null) {
|
|
14250
|
-
if (i ===
|
|
14250
|
+
if (i === Is && o.shape[o.shape.length - 1] === 1)
|
|
14251
14251
|
throw new I(`You are passing a target array of shape ${o.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);
|
|
14252
14252
|
if (s.indexOf(i) !== -1) {
|
|
14253
14253
|
const l = o.shape.slice(1), u = a.slice(1);
|
|
@@ -14367,7 +14367,7 @@ class Yr extends ce {
|
|
|
14367
14367
|
if (t.loss == null && (t.loss = []), this.loss = t.loss, typeof t.optimizer == "string")
|
|
14368
14368
|
this.optimizer_ = Yw(t.optimizer), this.isOptimizerOwned = !0;
|
|
14369
14369
|
else {
|
|
14370
|
-
if (!(t.optimizer instanceof
|
|
14370
|
+
if (!(t.optimizer instanceof Ke))
|
|
14371
14371
|
throw new I("User-defined optimizer must be an instance of tf.Optimizer.");
|
|
14372
14372
|
this.optimizer_ = t.optimizer, this.isOptimizerOwned = !1;
|
|
14373
14373
|
}
|
|
@@ -14482,7 +14482,7 @@ class Yr extends ce {
|
|
|
14482
14482
|
const a = i[0].concat(i[1]);
|
|
14483
14483
|
this.makeTestFunction();
|
|
14484
14484
|
const l = this.testFunction, u = this.testLoop(l, a, r, s.verbose, s.steps);
|
|
14485
|
-
return
|
|
14485
|
+
return zt(u);
|
|
14486
14486
|
} finally {
|
|
14487
14487
|
ae(i[0], t), ae(i[1], e);
|
|
14488
14488
|
}
|
|
@@ -14543,7 +14543,7 @@ class Yr extends ce {
|
|
|
14543
14543
|
execute(t, e) {
|
|
14544
14544
|
if (Array.isArray(e) && e.length === 0)
|
|
14545
14545
|
throw new I("`outputs` is an empty Array, which is not allowed.");
|
|
14546
|
-
const s = Array.isArray(e), r = s ? e : [e], o = this.retrieveSymbolicTensors(r), i = new
|
|
14546
|
+
const s = Array.isArray(e), r = s ? e : [e], o = this.retrieveSymbolicTensors(r), i = new Ue();
|
|
14547
14547
|
if (t instanceof Et && (t = [t]), Array.isArray(t)) {
|
|
14548
14548
|
if (t.length !== this.inputs.length)
|
|
14549
14549
|
throw new I(`The number of inputs provided (${t.length}) does not match the number of inputs of this model (${this.inputs.length}).`);
|
|
@@ -14556,7 +14556,7 @@ class Yr extends ce {
|
|
|
14556
14556
|
throw new I(`No value is provided for the model's input ${l.name}`);
|
|
14557
14557
|
i.add(l, u);
|
|
14558
14558
|
}
|
|
14559
|
-
const a =
|
|
14559
|
+
const a = cs(o, i);
|
|
14560
14560
|
return s ? a : a[0];
|
|
14561
14561
|
}
|
|
14562
14562
|
/**
|
|
@@ -14604,16 +14604,16 @@ class Yr extends ce {
|
|
|
14604
14604
|
const o = bo(r, e), i = this.outputs.map((a) => []);
|
|
14605
14605
|
for (let a = 0; a < o.length; ++a)
|
|
14606
14606
|
C(() => {
|
|
14607
|
-
const u = o[a][0], c = o[a][1], h =
|
|
14607
|
+
const u = o[a][0], c = o[a][1], h = is(t, u, c), f = [];
|
|
14608
14608
|
if (Array.isArray(h))
|
|
14609
14609
|
for (let p = 0; p < h.length; ++p)
|
|
14610
14610
|
f.push({ key: this.inputs[p], value: h[p] });
|
|
14611
14611
|
else
|
|
14612
14612
|
f.push({ key: this.inputs[0], value: h });
|
|
14613
|
-
const d = new
|
|
14614
|
-
return
|
|
14613
|
+
const d = new Ue(f);
|
|
14614
|
+
return cs(this.outputs, d);
|
|
14615
14615
|
}).forEach((u, c) => i[c].push(u));
|
|
14616
|
-
return
|
|
14616
|
+
return zt(i.map((a) => rn(a, 0)));
|
|
14617
14617
|
});
|
|
14618
14618
|
}
|
|
14619
14619
|
/**
|
|
@@ -14675,7 +14675,7 @@ class Yr extends ce {
|
|
|
14675
14675
|
}
|
|
14676
14676
|
standardizeUserDataXY(t, e, s = !0, r) {
|
|
14677
14677
|
if (this.optimizer_ == null)
|
|
14678
|
-
throw new
|
|
14678
|
+
throw new qe("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");
|
|
14679
14679
|
const o = [];
|
|
14680
14680
|
for (let i = 0; i < this.feedOutputShapes.length; ++i) {
|
|
14681
14681
|
const a = this.feedOutputShapes[i];
|
|
@@ -14763,7 +14763,7 @@ class Yr extends ce {
|
|
|
14763
14763
|
const h = [];
|
|
14764
14764
|
for (let g = 0; g < this.inputs.length; ++g)
|
|
14765
14765
|
h.push({ key: this.inputs[g], value: s[g] });
|
|
14766
|
-
const f = new
|
|
14766
|
+
const f = new Ue(h), d = cs(this.outputs, f, { training: !0 });
|
|
14767
14767
|
let p;
|
|
14768
14768
|
for (let g = 0; g < this.lossFunctions.length; ++g) {
|
|
14769
14769
|
const m = this.lossFunctions[g];
|
|
@@ -14780,7 +14780,7 @@ class Yr extends ce {
|
|
|
14780
14780
|
const b = this.metricsTensors[g][0], y = this.metricsTensors[g][1];
|
|
14781
14781
|
m = St(b(r[y], d[y]));
|
|
14782
14782
|
}
|
|
14783
|
-
|
|
14783
|
+
Pn(m), i.push(m);
|
|
14784
14784
|
}
|
|
14785
14785
|
return p = St(p), this.calculateLosses().forEach((g) => {
|
|
14786
14786
|
p = O(p, g);
|
|
@@ -14801,7 +14801,7 @@ class Yr extends ce {
|
|
|
14801
14801
|
const r = t.slice(0, this.inputs.length), o = t.slice(this.inputs.length, this.inputs.length + this.outputs.length), i = [];
|
|
14802
14802
|
for (let u = 0; u < this.inputs.length; ++u)
|
|
14803
14803
|
i.push({ key: this.inputs[u], value: r[u] });
|
|
14804
|
-
const a = new
|
|
14804
|
+
const a = new Ue(i), l = cs(this.outputs, a);
|
|
14805
14805
|
for (let u = 0; u < this.lossFunctions.length; ++u) {
|
|
14806
14806
|
const c = this.lossFunctions[u], h = St(c(o[u], l[u]));
|
|
14807
14807
|
u === 0 ? s = h : s = O(s, h), e.push(s);
|
|
@@ -14876,7 +14876,7 @@ class Yr extends ce {
|
|
|
14876
14876
|
} else if (s.validationSplit != null && s.validationSplit > 0 && s.validationSplit < 1) {
|
|
14877
14877
|
m = !0;
|
|
14878
14878
|
const T = Math.floor(r[0].shape[0] * (1 - s.validationSplit)), P = r[0].shape[0];
|
|
14879
|
-
c =
|
|
14879
|
+
c = is(r, T, P), i = r, r = is(r, 0, T), h = is(o, T, P), a = o, o = is(o, 0, T), b = c.concat(h);
|
|
14880
14880
|
} else
|
|
14881
14881
|
s.validationSteps != null && (m = !0);
|
|
14882
14882
|
const y = r.concat(o).concat(f);
|
|
@@ -14945,13 +14945,13 @@ class Yr extends ce {
|
|
|
14945
14945
|
const j = Ho(e, Y), F = t(j);
|
|
14946
14946
|
for (let G = 0; G < s.length; ++G) {
|
|
14947
14947
|
const q = s[G], be = F[G];
|
|
14948
|
-
T[q] = be,
|
|
14948
|
+
T[q] = be, Pn(be);
|
|
14949
14949
|
}
|
|
14950
14950
|
if (_ === D.length - 1 && g) {
|
|
14951
14951
|
const G = this.testLoop(l, u, r);
|
|
14952
14952
|
for (let q = 0; q < s.length; ++q) {
|
|
14953
|
-
const be = s[q],
|
|
14954
|
-
|
|
14953
|
+
const be = s[q], Mt = G[q];
|
|
14954
|
+
Pn(Mt), $["val_" + be] = Mt;
|
|
14955
14955
|
}
|
|
14956
14956
|
}
|
|
14957
14957
|
}), await y.onBatchEnd(_, T), fh(T), this.stopTraining_)
|
|
@@ -15019,7 +15019,7 @@ class Yr extends ce {
|
|
|
15019
15019
|
const c = await u.data();
|
|
15020
15020
|
l.push(c[0]);
|
|
15021
15021
|
}
|
|
15022
|
-
return ut(a), ae(s[0], t), ae(s[1], e),
|
|
15022
|
+
return ut(a), ae(s[0], t), ae(s[1], e), zt(l);
|
|
15023
15023
|
}
|
|
15024
15024
|
/**
|
|
15025
15025
|
* Extract weight values of the model.
|
|
@@ -15294,25 +15294,25 @@ class Ch extends Yr {
|
|
|
15294
15294
|
}
|
|
15295
15295
|
Ch.className = "Functional";
|
|
15296
15296
|
M(Ch);
|
|
15297
|
-
const x1 = "This is not an object", S1 = "This is not a Float16Array object", ll = "This constructor is not a subclass of Float16Array", kh = "The constructor property value is not an object", $1 = "Species constructor didn't return TypedArray object", v1 = "Derived constructor created TypedArray object which was too small length",
|
|
15297
|
+
const x1 = "This is not an object", S1 = "This is not a Float16Array object", ll = "This constructor is not a subclass of Float16Array", kh = "The constructor property value is not an object", $1 = "Species constructor didn't return TypedArray object", v1 = "Derived constructor created TypedArray object which was too small length", gs = "Attempting to access detached ArrayBuffer", Yo = "Cannot convert undefined or null to object", Xo = "Cannot mix BigInt and other types, use explicit conversions", ul = "@@iterator property is not callable", cl = "Reduce of empty array with no initial value", I1 = "The comparison function must be either a function or undefined", yo = "Offset is out of bounds";
|
|
15298
15298
|
function ct(n) {
|
|
15299
|
-
return (t, ...e) =>
|
|
15299
|
+
return (t, ...e) => Ft(n, t, e);
|
|
15300
15300
|
}
|
|
15301
|
-
function
|
|
15301
|
+
function ts(n, t) {
|
|
15302
15302
|
return ct(
|
|
15303
|
-
|
|
15303
|
+
Un(
|
|
15304
15304
|
n,
|
|
15305
15305
|
t
|
|
15306
15306
|
).get
|
|
15307
15307
|
);
|
|
15308
15308
|
}
|
|
15309
15309
|
const {
|
|
15310
|
-
apply:
|
|
15311
|
-
construct:
|
|
15310
|
+
apply: Ft,
|
|
15311
|
+
construct: hs,
|
|
15312
15312
|
defineProperty: hl,
|
|
15313
15313
|
get: wo,
|
|
15314
|
-
getOwnPropertyDescriptor:
|
|
15315
|
-
getPrototypeOf:
|
|
15314
|
+
getOwnPropertyDescriptor: Un,
|
|
15315
|
+
getPrototypeOf: Ms,
|
|
15316
15316
|
has: Jo,
|
|
15317
15317
|
ownKeys: _h,
|
|
15318
15318
|
set: fl,
|
|
@@ -15321,18 +15321,18 @@ const {
|
|
|
15321
15321
|
EPSILON: E1,
|
|
15322
15322
|
MAX_SAFE_INTEGER: dl,
|
|
15323
15323
|
isFinite: Nh,
|
|
15324
|
-
isNaN:
|
|
15324
|
+
isNaN: Wn
|
|
15325
15325
|
} = Number, {
|
|
15326
15326
|
iterator: ke,
|
|
15327
15327
|
species: C1,
|
|
15328
15328
|
toStringTag: Yi,
|
|
15329
15329
|
for: k1
|
|
15330
|
-
} = Symbol,
|
|
15330
|
+
} = Symbol, Gn = Object, {
|
|
15331
15331
|
create: Xr,
|
|
15332
|
-
defineProperty:
|
|
15332
|
+
defineProperty: Os,
|
|
15333
15333
|
freeze: _1,
|
|
15334
15334
|
is: pl
|
|
15335
|
-
} =
|
|
15335
|
+
} = Gn, Zo = Gn.prototype, T1 = (
|
|
15336
15336
|
/** @type {any} */
|
|
15337
15337
|
Zo.__lookupGetter__ ? ct(
|
|
15338
15338
|
/** @type {any} */
|
|
@@ -15342,22 +15342,22 @@ const {
|
|
|
15342
15342
|
throw ft(
|
|
15343
15343
|
Yo
|
|
15344
15344
|
);
|
|
15345
|
-
let e =
|
|
15345
|
+
let e = Gn(n);
|
|
15346
15346
|
do {
|
|
15347
|
-
const s =
|
|
15347
|
+
const s = Un(e, t);
|
|
15348
15348
|
if (s !== void 0)
|
|
15349
15349
|
return Pe(s, "get") ? s.get : void 0;
|
|
15350
|
-
} while ((e =
|
|
15350
|
+
} while ((e = Ms(e)) !== null);
|
|
15351
15351
|
}
|
|
15352
15352
|
), Pe = (
|
|
15353
15353
|
/** @type {any} */
|
|
15354
|
-
|
|
15354
|
+
Gn.hasOwn || ct(Zo.hasOwnProperty)
|
|
15355
15355
|
), Dh = Array, Rh = Dh.isArray, Jr = Dh.prototype, N1 = ct(Jr.join), D1 = ct(Jr.push), R1 = ct(
|
|
15356
15356
|
Jr.toLocaleString
|
|
15357
15357
|
), Xi = Jr[ke], P1 = ct(Xi), {
|
|
15358
15358
|
abs: L1,
|
|
15359
15359
|
trunc: Ph
|
|
15360
|
-
} = Math, Zr = ArrayBuffer, M1 = Zr.isView, Lh = Zr.prototype, O1 = ct(Lh.slice), B1 =
|
|
15360
|
+
} = Math, Zr = ArrayBuffer, M1 = Zr.isView, Lh = Zr.prototype, O1 = ct(Lh.slice), B1 = ts(Lh, "byteLength"), Qo = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : null, F1 = Qo && ts(Qo.prototype, "byteLength"), Ji = Ms(Uint8Array), z1 = Ji.from, vt = Ji.prototype, U1 = vt[ke], W1 = ct(vt.keys), G1 = ct(
|
|
15361
15361
|
vt.values
|
|
15362
15362
|
), V1 = ct(
|
|
15363
15363
|
vt.entries
|
|
@@ -15365,22 +15365,22 @@ const {
|
|
|
15365
15365
|
vt.reverse
|
|
15366
15366
|
), j1 = ct(vt.fill), H1 = ct(
|
|
15367
15367
|
vt.copyWithin
|
|
15368
|
-
), gl = ct(vt.sort),
|
|
15368
|
+
), gl = ct(vt.sort), as = ct(vt.slice), K1 = ct(
|
|
15369
15369
|
vt.subarray
|
|
15370
|
-
), xt =
|
|
15370
|
+
), xt = ts(
|
|
15371
15371
|
vt,
|
|
15372
15372
|
"buffer"
|
|
15373
|
-
), Xe =
|
|
15373
|
+
), Xe = ts(
|
|
15374
15374
|
vt,
|
|
15375
15375
|
"byteOffset"
|
|
15376
|
-
), tt =
|
|
15376
|
+
), tt = ts(
|
|
15377
15377
|
vt,
|
|
15378
15378
|
"length"
|
|
15379
|
-
), Mh =
|
|
15379
|
+
), Mh = ts(
|
|
15380
15380
|
vt,
|
|
15381
15381
|
Yi
|
|
15382
|
-
), Y1 = Uint8Array, jt = Uint16Array, bl = (...n) =>
|
|
15383
|
-
}().next), Z1 =
|
|
15382
|
+
), Y1 = Uint8Array, jt = Uint16Array, bl = (...n) => Ft(z1, jt, n), Zi = Uint32Array, X1 = Float32Array, yn = Ms([][ke]()), Qr = ct(yn.next), J1 = ct(function* () {
|
|
15383
|
+
}().next), Z1 = Ms(yn), ft = TypeError, xo = RangeError, Oh = WeakSet, Bh = Oh.prototype, Q1 = ct(Bh.add), tx = ct(Bh.has), to = WeakMap, Qi = to.prototype, kr = ct(Qi.get), ex = ct(Qi.has), ta = ct(Qi.set), Fh = new to(), nx = Xr(null, {
|
|
15384
15384
|
next: {
|
|
15385
15385
|
value: function() {
|
|
15386
15386
|
const t = kr(Fh, this);
|
|
@@ -15410,7 +15410,7 @@ const zh = new to(), Uh = Xr(Z1, {
|
|
|
15410
15410
|
}
|
|
15411
15411
|
});
|
|
15412
15412
|
for (const n of _h(yn))
|
|
15413
|
-
n !== "next" &&
|
|
15413
|
+
n !== "next" && Os(Uh, n, Un(yn, n));
|
|
15414
15414
|
function yl(n) {
|
|
15415
15415
|
const t = Xr(Uh);
|
|
15416
15416
|
return ta(zh, t, n), t;
|
|
@@ -15469,7 +15469,7 @@ const Nr = k1("__Float16Array__");
|
|
|
15469
15469
|
function ix(n) {
|
|
15470
15470
|
if (!wl(n))
|
|
15471
15471
|
return !1;
|
|
15472
|
-
const t =
|
|
15472
|
+
const t = Ms(n);
|
|
15473
15473
|
if (!wl(t))
|
|
15474
15474
|
return !1;
|
|
15475
15475
|
const e = t.constructor;
|
|
@@ -15492,7 +15492,7 @@ function cx(n) {
|
|
|
15492
15492
|
if (s < Gh)
|
|
15493
15493
|
return e * ax(s / Sl) * Sl;
|
|
15494
15494
|
const r = (1 + ux) * s, o = r - (r - s);
|
|
15495
|
-
return o > lx ||
|
|
15495
|
+
return o > lx || Wn(o) ? e * (1 / 0) : e * o;
|
|
15496
15496
|
}
|
|
15497
15497
|
const qh = new Zr(4), jh = new X1(qh), Hh = new Zi(qh), le = new jt(512), ue = new Y1(512);
|
|
15498
15498
|
for (let n = 0; n < 256; ++n) {
|
|
@@ -15513,24 +15513,24 @@ for (let n = 1; n < 1024; ++n) {
|
|
|
15513
15513
|
}
|
|
15514
15514
|
for (let n = 1024; n < 2048; ++n)
|
|
15515
15515
|
ea[n] = 939524096 + (n - 1024 << 13);
|
|
15516
|
-
const
|
|
15516
|
+
const es = new Zi(64);
|
|
15517
15517
|
for (let n = 1; n < 31; ++n)
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15518
|
+
es[n] = n << 23;
|
|
15519
|
+
es[31] = 1199570944;
|
|
15520
|
+
es[32] = 2147483648;
|
|
15521
15521
|
for (let n = 33; n < 63; ++n)
|
|
15522
|
-
|
|
15523
|
-
|
|
15522
|
+
es[n] = 2147483648 + (n - 32 << 23);
|
|
15523
|
+
es[63] = 3347054592;
|
|
15524
15524
|
const Kh = new jt(64);
|
|
15525
15525
|
for (let n = 1; n < 64; ++n)
|
|
15526
15526
|
n !== 32 && (Kh[n] = 1024);
|
|
15527
15527
|
function nt(n) {
|
|
15528
15528
|
const t = n >> 10;
|
|
15529
|
-
return Hh[0] = ea[Kh[t] + (n & 1023)] +
|
|
15529
|
+
return Hh[0] = ea[Kh[t] + (n & 1023)] + es[t], jh[0];
|
|
15530
15530
|
}
|
|
15531
15531
|
function Ne(n) {
|
|
15532
15532
|
const t = +n;
|
|
15533
|
-
return
|
|
15533
|
+
return Wn(t) || t === 0 ? 0 : Ph(t);
|
|
15534
15534
|
}
|
|
15535
15535
|
function So(n) {
|
|
15536
15536
|
const t = Ne(n);
|
|
@@ -15547,7 +15547,7 @@ function Hs(n, t) {
|
|
|
15547
15547
|
const s = e[C1];
|
|
15548
15548
|
return s ?? t;
|
|
15549
15549
|
}
|
|
15550
|
-
function
|
|
15550
|
+
function bs(n) {
|
|
15551
15551
|
if (Wh(n))
|
|
15552
15552
|
return !1;
|
|
15553
15553
|
try {
|
|
@@ -15557,7 +15557,7 @@ function gs(n) {
|
|
|
15557
15557
|
return !0;
|
|
15558
15558
|
}
|
|
15559
15559
|
function $l(n, t) {
|
|
15560
|
-
const e =
|
|
15560
|
+
const e = Wn(n), s = Wn(t);
|
|
15561
15561
|
if (e && s)
|
|
15562
15562
|
return 0;
|
|
15563
15563
|
if (e)
|
|
@@ -15576,15 +15576,15 @@ function $l(n, t) {
|
|
|
15576
15576
|
return 0;
|
|
15577
15577
|
}
|
|
15578
15578
|
const na = 2, Dr = new to();
|
|
15579
|
-
function
|
|
15579
|
+
function Rn(n) {
|
|
15580
15580
|
return ex(Dr, n) || !M1(n) && ix(n);
|
|
15581
15581
|
}
|
|
15582
15582
|
function Q(n) {
|
|
15583
|
-
if (!
|
|
15583
|
+
if (!Rn(n))
|
|
15584
15584
|
throw ft(S1);
|
|
15585
15585
|
}
|
|
15586
15586
|
function Ks(n, t) {
|
|
15587
|
-
const e =
|
|
15587
|
+
const e = Rn(n), s = Tr(n);
|
|
15588
15588
|
if (!e && !s)
|
|
15589
15589
|
throw ft($1);
|
|
15590
15590
|
if (typeof t == "number") {
|
|
@@ -15606,17 +15606,17 @@ function V(n) {
|
|
|
15606
15606
|
const t = kr(Dr, n);
|
|
15607
15607
|
if (t !== void 0) {
|
|
15608
15608
|
const r = xt(t);
|
|
15609
|
-
if (
|
|
15610
|
-
throw ft(
|
|
15609
|
+
if (bs(r))
|
|
15610
|
+
throw ft(gs);
|
|
15611
15611
|
return t;
|
|
15612
15612
|
}
|
|
15613
15613
|
const e = (
|
|
15614
15614
|
/** @type {any} */
|
|
15615
15615
|
n.buffer
|
|
15616
15616
|
);
|
|
15617
|
-
if (
|
|
15618
|
-
throw ft(
|
|
15619
|
-
const s =
|
|
15617
|
+
if (bs(e))
|
|
15618
|
+
throw ft(gs);
|
|
15619
|
+
const s = hs(ht, [
|
|
15620
15620
|
e,
|
|
15621
15621
|
/** @type {any} */
|
|
15622
15622
|
n.byteOffset,
|
|
@@ -15635,7 +15635,7 @@ const Yh = new Oh();
|
|
|
15635
15635
|
for (const n of _h(vt)) {
|
|
15636
15636
|
if (n === Yi)
|
|
15637
15637
|
continue;
|
|
15638
|
-
const t =
|
|
15638
|
+
const t = Un(vt, n);
|
|
15639
15639
|
Pe(t, "get") && typeof t.get == "function" && Q1(Yh, t.get);
|
|
15640
15640
|
}
|
|
15641
15641
|
const hx = _1(
|
|
@@ -15649,10 +15649,10 @@ const hx = _1(
|
|
|
15649
15649
|
},
|
|
15650
15650
|
getOwnPropertyDescriptor(n, t) {
|
|
15651
15651
|
if (js(t) && Pe(n, t)) {
|
|
15652
|
-
const e =
|
|
15652
|
+
const e = Un(n, t);
|
|
15653
15653
|
return e.value = nt(e.value), e;
|
|
15654
15654
|
}
|
|
15655
|
-
return
|
|
15655
|
+
return Un(n, t);
|
|
15656
15656
|
},
|
|
15657
15657
|
defineProperty(n, t, e) {
|
|
15658
15658
|
return js(t) && Pe(n, t) && Pe(e, "value") && (e.value = we(e.value)), hl(n, t, e);
|
|
@@ -15663,33 +15663,33 @@ class ht {
|
|
|
15663
15663
|
/** @see https://tc39.es/ecma262/#sec-typedarray */
|
|
15664
15664
|
constructor(t, e, s) {
|
|
15665
15665
|
let r;
|
|
15666
|
-
if (
|
|
15667
|
-
r =
|
|
15666
|
+
if (Rn(t))
|
|
15667
|
+
r = hs(jt, [V(t)], new.target);
|
|
15668
15668
|
else if (_r(t) && !rx(t)) {
|
|
15669
15669
|
let i, a;
|
|
15670
15670
|
if (Tr(t)) {
|
|
15671
15671
|
i = t, a = tt(t);
|
|
15672
15672
|
const l = xt(t);
|
|
15673
|
-
if (
|
|
15674
|
-
throw ft(
|
|
15673
|
+
if (bs(l))
|
|
15674
|
+
throw ft(gs);
|
|
15675
15675
|
if (ti(t))
|
|
15676
15676
|
throw ft(Xo);
|
|
15677
15677
|
const u = new Zr(
|
|
15678
15678
|
a * na
|
|
15679
15679
|
);
|
|
15680
|
-
r =
|
|
15680
|
+
r = hs(jt, [u], new.target);
|
|
15681
15681
|
} else {
|
|
15682
15682
|
const l = t[ke];
|
|
15683
15683
|
if (l != null && typeof l != "function")
|
|
15684
15684
|
throw ft(ul);
|
|
15685
15685
|
l != null ? xl(t) ? (i = t, a = t.length) : (i = [.../** @type {Iterable<unknown>} */
|
|
15686
15686
|
t], a = i.length) : (i = /** @type {ArrayLike<unknown>} */
|
|
15687
|
-
t, a = So(i.length)), r =
|
|
15687
|
+
t, a = So(i.length)), r = hs(jt, [a], new.target);
|
|
15688
15688
|
}
|
|
15689
15689
|
for (let l = 0; l < a; ++l)
|
|
15690
15690
|
r[l] = we(i[l]);
|
|
15691
15691
|
} else
|
|
15692
|
-
r =
|
|
15692
|
+
r = hs(jt, arguments, new.target);
|
|
15693
15693
|
const o = (
|
|
15694
15694
|
/** @type {any} */
|
|
15695
15695
|
new A1(r, hx)
|
|
@@ -15707,14 +15707,14 @@ class ht {
|
|
|
15707
15707
|
ll
|
|
15708
15708
|
);
|
|
15709
15709
|
if (s === ht) {
|
|
15710
|
-
if (
|
|
15710
|
+
if (Rn(t) && e.length === 0) {
|
|
15711
15711
|
const c = V(t), h = new jt(
|
|
15712
15712
|
xt(c),
|
|
15713
15713
|
Xe(c),
|
|
15714
15714
|
tt(c)
|
|
15715
15715
|
);
|
|
15716
15716
|
return new ht(
|
|
15717
|
-
xt(
|
|
15717
|
+
xt(as(h))
|
|
15718
15718
|
);
|
|
15719
15719
|
}
|
|
15720
15720
|
if (e.length === 0)
|
|
@@ -15728,7 +15728,7 @@ class ht {
|
|
|
15728
15728
|
xt(
|
|
15729
15729
|
bl(t, function(c, ...h) {
|
|
15730
15730
|
return we(
|
|
15731
|
-
|
|
15731
|
+
Ft(l, this, [c, ...qs(h)])
|
|
15732
15732
|
);
|
|
15733
15733
|
}, u)
|
|
15734
15734
|
)
|
|
@@ -15745,7 +15745,7 @@ class ht {
|
|
|
15745
15745
|
throw ft(
|
|
15746
15746
|
Yo
|
|
15747
15747
|
);
|
|
15748
|
-
r =
|
|
15748
|
+
r = Gn(t), o = So(r.length);
|
|
15749
15749
|
}
|
|
15750
15750
|
const a = new s(o);
|
|
15751
15751
|
if (e.length === 0)
|
|
@@ -15755,7 +15755,7 @@ class ht {
|
|
|
15755
15755
|
else {
|
|
15756
15756
|
const l = e[0], u = e[1];
|
|
15757
15757
|
for (let c = 0; c < o; ++c)
|
|
15758
|
-
a[c] =
|
|
15758
|
+
a[c] = Ft(l, u, [r[c], c]);
|
|
15759
15759
|
}
|
|
15760
15760
|
return a;
|
|
15761
15761
|
}
|
|
@@ -15833,7 +15833,7 @@ class ht {
|
|
|
15833
15833
|
tt(s)
|
|
15834
15834
|
), u = new ht(
|
|
15835
15835
|
xt(
|
|
15836
|
-
|
|
15836
|
+
as(l)
|
|
15837
15837
|
)
|
|
15838
15838
|
), c = V(u);
|
|
15839
15839
|
return c[i] = we(a), u;
|
|
@@ -15847,7 +15847,7 @@ class ht {
|
|
|
15847
15847
|
for (let c = 0; c < r; ++c) {
|
|
15848
15848
|
const h = nt(s[c]);
|
|
15849
15849
|
u[c] = we(
|
|
15850
|
-
|
|
15850
|
+
Ft(t, o, [h, c, this])
|
|
15851
15851
|
);
|
|
15852
15852
|
}
|
|
15853
15853
|
return l;
|
|
@@ -15856,7 +15856,7 @@ class ht {
|
|
|
15856
15856
|
Ks(a, r);
|
|
15857
15857
|
for (let l = 0; l < r; ++l) {
|
|
15858
15858
|
const u = nt(s[l]);
|
|
15859
|
-
a[l] =
|
|
15859
|
+
a[l] = Ft(t, o, [u, l, this]);
|
|
15860
15860
|
}
|
|
15861
15861
|
return (
|
|
15862
15862
|
/** @type {any} */
|
|
@@ -15869,7 +15869,7 @@ class ht {
|
|
|
15869
15869
|
const s = V(this), r = tt(s), o = e[0], i = [];
|
|
15870
15870
|
for (let u = 0; u < r; ++u) {
|
|
15871
15871
|
const c = nt(s[u]);
|
|
15872
|
-
|
|
15872
|
+
Ft(t, o, [c, u, this]) && D1(i, c);
|
|
15873
15873
|
}
|
|
15874
15874
|
const a = Hs(s, ht), l = new a(i);
|
|
15875
15875
|
return Ks(l), /** @type {any} */
|
|
@@ -15914,7 +15914,7 @@ class ht {
|
|
|
15914
15914
|
Q(this);
|
|
15915
15915
|
const s = V(this), r = tt(s), o = e[0];
|
|
15916
15916
|
for (let i = 0; i < r; ++i)
|
|
15917
|
-
|
|
15917
|
+
Ft(t, o, [
|
|
15918
15918
|
nt(s[i]),
|
|
15919
15919
|
i,
|
|
15920
15920
|
this
|
|
@@ -15926,7 +15926,7 @@ class ht {
|
|
|
15926
15926
|
const s = V(this), r = tt(s), o = e[0];
|
|
15927
15927
|
for (let i = 0; i < r; ++i) {
|
|
15928
15928
|
const a = nt(s[i]);
|
|
15929
|
-
if (
|
|
15929
|
+
if (Ft(t, o, [a, i, this]))
|
|
15930
15930
|
return a;
|
|
15931
15931
|
}
|
|
15932
15932
|
}
|
|
@@ -15936,7 +15936,7 @@ class ht {
|
|
|
15936
15936
|
const s = V(this), r = tt(s), o = e[0];
|
|
15937
15937
|
for (let i = 0; i < r; ++i) {
|
|
15938
15938
|
const a = nt(s[i]);
|
|
15939
|
-
if (
|
|
15939
|
+
if (Ft(t, o, [a, i, this]))
|
|
15940
15940
|
return i;
|
|
15941
15941
|
}
|
|
15942
15942
|
return -1;
|
|
@@ -15947,7 +15947,7 @@ class ht {
|
|
|
15947
15947
|
const s = V(this), r = tt(s), o = e[0];
|
|
15948
15948
|
for (let i = r - 1; i >= 0; --i) {
|
|
15949
15949
|
const a = nt(s[i]);
|
|
15950
|
-
if (
|
|
15950
|
+
if (Ft(t, o, [a, i, this]))
|
|
15951
15951
|
return a;
|
|
15952
15952
|
}
|
|
15953
15953
|
}
|
|
@@ -15957,7 +15957,7 @@ class ht {
|
|
|
15957
15957
|
const s = V(this), r = tt(s), o = e[0];
|
|
15958
15958
|
for (let i = r - 1; i >= 0; --i) {
|
|
15959
15959
|
const a = nt(s[i]);
|
|
15960
|
-
if (
|
|
15960
|
+
if (Ft(t, o, [a, i, this]))
|
|
15961
15961
|
return i;
|
|
15962
15962
|
}
|
|
15963
15963
|
return -1;
|
|
@@ -15967,7 +15967,7 @@ class ht {
|
|
|
15967
15967
|
Q(this);
|
|
15968
15968
|
const s = V(this), r = tt(s), o = e[0];
|
|
15969
15969
|
for (let i = 0; i < r; ++i)
|
|
15970
|
-
if (!
|
|
15970
|
+
if (!Ft(t, o, [
|
|
15971
15971
|
nt(s[i]),
|
|
15972
15972
|
i,
|
|
15973
15973
|
this
|
|
@@ -15980,7 +15980,7 @@ class ht {
|
|
|
15980
15980
|
Q(this);
|
|
15981
15981
|
const s = V(this), r = tt(s), o = e[0];
|
|
15982
15982
|
for (let i = 0; i < r; ++i)
|
|
15983
|
-
if (
|
|
15983
|
+
if (Ft(t, o, [
|
|
15984
15984
|
nt(s[i]),
|
|
15985
15985
|
i,
|
|
15986
15986
|
this
|
|
@@ -16002,7 +16002,7 @@ class ht {
|
|
|
16002
16002
|
throw ft(
|
|
16003
16003
|
Xo
|
|
16004
16004
|
);
|
|
16005
|
-
if (
|
|
16005
|
+
if (Rn(t))
|
|
16006
16006
|
return q1(
|
|
16007
16007
|
V(this),
|
|
16008
16008
|
V(t),
|
|
@@ -16010,10 +16010,10 @@ class ht {
|
|
|
16010
16010
|
);
|
|
16011
16011
|
if (Tr(t)) {
|
|
16012
16012
|
const l = xt(t);
|
|
16013
|
-
if (
|
|
16014
|
-
throw ft(
|
|
16013
|
+
if (bs(l))
|
|
16014
|
+
throw ft(gs);
|
|
16015
16015
|
}
|
|
16016
|
-
const o = tt(s), i =
|
|
16016
|
+
const o = tt(s), i = Gn(t), a = So(i.length);
|
|
16017
16017
|
if (r === 1 / 0 || a + r > o)
|
|
16018
16018
|
throw xo(yo);
|
|
16019
16019
|
for (let l = 0; l < a; ++l)
|
|
@@ -16034,7 +16034,7 @@ class ht {
|
|
|
16034
16034
|
tt(t)
|
|
16035
16035
|
), s = new ht(
|
|
16036
16036
|
xt(
|
|
16037
|
-
|
|
16037
|
+
as(e)
|
|
16038
16038
|
)
|
|
16039
16039
|
), r = V(s);
|
|
16040
16040
|
return ml(r), s;
|
|
@@ -16073,7 +16073,7 @@ class ht {
|
|
|
16073
16073
|
tt(e)
|
|
16074
16074
|
), o = new ht(
|
|
16075
16075
|
xt(
|
|
16076
|
-
|
|
16076
|
+
as(r)
|
|
16077
16077
|
)
|
|
16078
16078
|
), i = V(o);
|
|
16079
16079
|
return gl(i, (a, l) => s(nt(a), nt(l))), o;
|
|
@@ -16090,7 +16090,7 @@ class ht {
|
|
|
16090
16090
|
);
|
|
16091
16091
|
return new ht(
|
|
16092
16092
|
xt(
|
|
16093
|
-
|
|
16093
|
+
as(p, t, e)
|
|
16094
16094
|
)
|
|
16095
16095
|
);
|
|
16096
16096
|
}
|
|
@@ -16103,8 +16103,8 @@ class ht {
|
|
|
16103
16103
|
if (Ks(h, c), c === 0)
|
|
16104
16104
|
return h;
|
|
16105
16105
|
const f = xt(s);
|
|
16106
|
-
if (
|
|
16107
|
-
throw ft(
|
|
16106
|
+
if (bs(f))
|
|
16107
|
+
throw ft(gs);
|
|
16108
16108
|
let d = 0;
|
|
16109
16109
|
for (; l < u; )
|
|
16110
16110
|
h[d] = nt(s[l]), ++l, ++d;
|
|
@@ -16162,10 +16162,10 @@ class ht {
|
|
|
16162
16162
|
if (o === 1 / 0)
|
|
16163
16163
|
return !1;
|
|
16164
16164
|
o < 0 && (o += r, o < 0 && (o = 0));
|
|
16165
|
-
const i =
|
|
16165
|
+
const i = Wn(t);
|
|
16166
16166
|
for (let a = o; a < r; ++a) {
|
|
16167
16167
|
const l = nt(s[a]);
|
|
16168
|
-
if (i &&
|
|
16168
|
+
if (i && Wn(l) || l === t)
|
|
16169
16169
|
return !0;
|
|
16170
16170
|
}
|
|
16171
16171
|
return !1;
|
|
@@ -16184,23 +16184,23 @@ class ht {
|
|
|
16184
16184
|
}
|
|
16185
16185
|
/** @see https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag */
|
|
16186
16186
|
get [Yi]() {
|
|
16187
|
-
if (
|
|
16187
|
+
if (Rn(this))
|
|
16188
16188
|
return (
|
|
16189
16189
|
/** @type {any} */
|
|
16190
16190
|
"Float16Array"
|
|
16191
16191
|
);
|
|
16192
16192
|
}
|
|
16193
16193
|
}
|
|
16194
|
-
|
|
16194
|
+
Os(ht, "BYTES_PER_ELEMENT", {
|
|
16195
16195
|
value: na
|
|
16196
16196
|
});
|
|
16197
|
-
|
|
16197
|
+
Os(ht, Nr, {});
|
|
16198
16198
|
Th(ht, Ji);
|
|
16199
16199
|
const Rr = ht.prototype;
|
|
16200
|
-
|
|
16200
|
+
Os(Rr, "BYTES_PER_ELEMENT", {
|
|
16201
16201
|
value: na
|
|
16202
16202
|
});
|
|
16203
|
-
|
|
16203
|
+
Os(Rr, ke, {
|
|
16204
16204
|
value: Rr.values,
|
|
16205
16205
|
writable: !0,
|
|
16206
16206
|
configurable: !0
|
|
@@ -16701,7 +16701,7 @@ class Sx {
|
|
|
16701
16701
|
El(o.data, o.desc.dataType),
|
|
16702
16702
|
"float32"
|
|
16703
16703
|
);
|
|
16704
|
-
return new
|
|
16704
|
+
return new Qn({
|
|
16705
16705
|
name: t,
|
|
16706
16706
|
filters: r.desc.dims[0],
|
|
16707
16707
|
kernelSize: r.desc.dims.slice(2, 4),
|
|
@@ -16852,18 +16852,15 @@ class Sx {
|
|
|
16852
16852
|
t.color,
|
|
16853
16853
|
t.albedo,
|
|
16854
16854
|
t.normal
|
|
16855
|
-
), be = [1, S, y, 4]
|
|
16856
|
-
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
}),
|
|
16865
|
-
3
|
|
16866
|
-
);
|
|
16855
|
+
), be = [1, S, y, 4], Mt = [F, G, q].map((Ot) => {
|
|
16856
|
+
const Be = tr({ buffer: Ot, zeroCopy: !0 }, be), vn = ys(
|
|
16857
|
+
Be,
|
|
16858
|
+
[0, 0, 0, 0],
|
|
16859
|
+
[1, S, y, 3]
|
|
16860
|
+
);
|
|
16861
|
+
return Be.dispose(), vn;
|
|
16862
|
+
});
|
|
16863
|
+
E = Hp(Mt, 3), Mt.forEach((Ot) => Ot.dispose());
|
|
16867
16864
|
}
|
|
16868
16865
|
if (x) {
|
|
16869
16866
|
const F = E;
|
|
@@ -16897,9 +16894,9 @@ class Sx {
|
|
|
16897
16894
|
);
|
|
16898
16895
|
for (let G = 0; G < Y; G++)
|
|
16899
16896
|
for (let q = 0; q < B; q++) {
|
|
16900
|
-
const be = (G * B + q) * 4,
|
|
16901
|
-
for (let
|
|
16902
|
-
e.data[be +
|
|
16897
|
+
const be = (G * B + q) * 4, Mt = ((G + j.y) * i + (q + j.x)) * 4;
|
|
16898
|
+
for (let Ot = 0; Ot < 4; Ot++)
|
|
16899
|
+
e.data[be + Ot] = s.data[Mt + Ot];
|
|
16903
16900
|
}
|
|
16904
16901
|
P.dispose();
|
|
16905
16902
|
} else {
|
|
@@ -17358,7 +17355,7 @@ function _x(n, t, e) {
|
|
|
17358
17355
|
`}
|
|
17359
17356
|
}
|
|
17360
17357
|
`), e.pixelsOpType != null) {
|
|
17361
|
-
const p = e.pixelsOpType === Pr.FROM_PIXELS ? `@group(0) @binding(0) var<storage, read_write> result: array<${
|
|
17358
|
+
const p = e.pixelsOpType === Pr.FROM_PIXELS ? `@group(0) @binding(0) var<storage, read_write> result: array<${Nn(t.dtype, e.outputComponent)}>;` : `@group(0) @binding(1) var<storage, read> inBuf : array<${Nn(n[0].dtype, e.outputComponent)}>;`, g = t.shape.length === 3 ? "vec2<i32>" : "i32";
|
|
17362
17359
|
s.push(`
|
|
17363
17360
|
struct Uniform {
|
|
17364
17361
|
outShapeStrides : ${g},
|
|
@@ -17391,10 +17388,10 @@ function _x(n, t, e) {
|
|
|
17391
17388
|
outShapeStrides: ${i}, `, e.size && (a += "size : i32, "), e.uniforms && (a += e.uniforms), a += "};", a = Bx(a), s.push(a), e.atomic ? s.push(`
|
|
17392
17389
|
@group(0) @binding(0) var<storage, read_write> result: array<atomic<i32>>;
|
|
17393
17390
|
`) : s.push(`
|
|
17394
|
-
@group(0) @binding(0) var<storage, read_write> result: array<${
|
|
17391
|
+
@group(0) @binding(0) var<storage, read_write> result: array<${Nn(t.dtype, e.outputComponent)}>;
|
|
17395
17392
|
`), e.variableNames.forEach((p, g) => {
|
|
17396
17393
|
s.push(`
|
|
17397
|
-
@group(0) @binding(${1 + g}) var<storage, read> ${p}: array<${e.variableComponents ?
|
|
17394
|
+
@group(0) @binding(${1 + g}) var<storage, read> ${p}: array<${e.variableComponents ? Nn(n[g].dtype, e.variableComponents[g]) : Nn(n[g].dtype, e.outputComponent)}>;
|
|
17398
17395
|
`);
|
|
17399
17396
|
}), a !== "" && s.push(`
|
|
17400
17397
|
@group(0) @binding(${1 + e.variableNames.length}) var<uniform> uniforms: Uniforms;
|
|
@@ -17674,7 +17671,7 @@ function Mx(n) {
|
|
|
17674
17671
|
function rf(n) {
|
|
17675
17672
|
return n.dispatch[1] === 1 && n.dispatch[2] === 1;
|
|
17676
17673
|
}
|
|
17677
|
-
function
|
|
17674
|
+
function Nn(n, t = 1) {
|
|
17678
17675
|
if (n === "float32")
|
|
17679
17676
|
return K(t, "f32");
|
|
17680
17677
|
if (n === "int32" || n === "bool")
|
|
@@ -17682,7 +17679,7 @@ function Tn(n, t = 1) {
|
|
|
17682
17679
|
throw new Error(`type ${n} is not supported.`);
|
|
17683
17680
|
}
|
|
17684
17681
|
function Ox(n, t, e) {
|
|
17685
|
-
const s = n.length, r =
|
|
17682
|
+
const s = n.length, r = Nn(t, e);
|
|
17686
17683
|
let o = `fn setOutputAtIndex(flatIndex : i32, value : ${K(e)}) {
|
|
17687
17684
|
result[flatIndex] = ${r}(value);
|
|
17688
17685
|
}
|
|
@@ -17802,9 +17799,9 @@ const Wx = W().getNumber("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD"), Gx = (n, t) => {
|
|
|
17802
17799
|
let o = Math.ceil(Math.sqrt(r[0]));
|
|
17803
17800
|
return o > e ? (o = Math.ceil(Math.cbrt(r[0])), w(o <= e, () => "Total dispatch size exceeds WebGPU maximum."), [o, o, o]) : [o, o, 1];
|
|
17804
17801
|
};
|
|
17805
|
-
class
|
|
17802
|
+
class Bs extends Fl {
|
|
17806
17803
|
nextDataId() {
|
|
17807
|
-
return
|
|
17804
|
+
return Bs.nextDataId++;
|
|
17808
17805
|
}
|
|
17809
17806
|
constructor(t, e) {
|
|
17810
17807
|
if (super(), this.commandQueueOwnedIds = /* @__PURE__ */ new WeakSet(), this.dispatchCountInPass = 0, this.disposed = !1, this.downloadWaitMs = 0, this.tensorDataPendingDisposal = [], this.queryResolveBuffer = null, this.querySet = null, this.querySetCount = 2, this.stagingPendingDisposal = [], this.uniformPendingDisposal = [], this.uploadWaitMs = 0, this.hasReadSyncWarned = !1, this.hasTimestampQueryWarned = !1, !of())
|
|
@@ -18121,7 +18118,7 @@ class Os extends Fl {
|
|
|
18121
18118
|
}
|
|
18122
18119
|
runWebGPUProgram(t, e, s, r, o) {
|
|
18123
18120
|
if (o || (o = this.makeTensorInfo(t.outputShape, s)), U(o.shape) === 0)
|
|
18124
|
-
return this.tensorMap.get(o.dataId).values =
|
|
18121
|
+
return this.tensorMap.get(o.dataId).values = Ln(o.dtype, 0), o;
|
|
18125
18122
|
this.uploadToGPU(o.dataId), t.dispatch = Gx(this.device, t);
|
|
18126
18123
|
const i = e.map((l, u) => {
|
|
18127
18124
|
if (l.dtype === "complex64")
|
|
@@ -18205,7 +18202,7 @@ class Os extends Fl {
|
|
|
18205
18202
|
this.disposed || (this.querySet != null && this.querySet.destroy(), this.bufferManager.dispose(), this.textureManager.dispose(), this.disposed = !0);
|
|
18206
18203
|
}
|
|
18207
18204
|
}
|
|
18208
|
-
|
|
18205
|
+
Bs.nextDataId = 0;
|
|
18209
18206
|
/**
|
|
18210
18207
|
* @license
|
|
18211
18208
|
* Copyright 2022 Google Inc. All Rights Reserved.
|
|
@@ -18239,7 +18236,7 @@ of() && Jp(
|
|
|
18239
18236
|
maxComputeInvocationsPerWorkgroup: r.maxComputeInvocationsPerWorkgroup
|
|
18240
18237
|
};
|
|
18241
18238
|
const o = await t.requestDevice(e), i = await t.requestAdapterInfo();
|
|
18242
|
-
return new
|
|
18239
|
+
return new Bs(o, i);
|
|
18243
18240
|
},
|
|
18244
18241
|
3
|
|
18245
18242
|
/*priority*/
|
|
@@ -18331,14 +18328,14 @@ const qx = {
|
|
|
18331
18328
|
* limitations under the License.
|
|
18332
18329
|
* =============================================================================
|
|
18333
18330
|
*/
|
|
18334
|
-
function
|
|
18331
|
+
function He(n) {
|
|
18335
18332
|
const { inputs: t } = n, { x: e } = t;
|
|
18336
18333
|
return n.backend.incRef(e.dataId), { dataId: e.dataId, shape: e.shape, dtype: e.dtype };
|
|
18337
18334
|
}
|
|
18338
18335
|
const jx = {
|
|
18339
18336
|
kernelName: li,
|
|
18340
18337
|
backendName: "webgpu",
|
|
18341
|
-
kernelFunc:
|
|
18338
|
+
kernelFunc: He
|
|
18342
18339
|
};
|
|
18343
18340
|
/**
|
|
18344
18341
|
* @license
|
|
@@ -18438,7 +18435,7 @@ class Yx {
|
|
|
18438
18435
|
function af(n) {
|
|
18439
18436
|
const { backend: t, attrs: e } = n, { shape: s, value: r } = e;
|
|
18440
18437
|
let { dtype: o } = e;
|
|
18441
|
-
if (o = o ||
|
|
18438
|
+
if (o = o || Cs(r), o === "string") {
|
|
18442
18439
|
const i = yt(o, U(s));
|
|
18443
18440
|
return i.fill(r), t.makeTensorInfo(s, o, i);
|
|
18444
18441
|
} else {
|
|
@@ -18465,7 +18462,7 @@ function af(n) {
|
|
|
18465
18462
|
const Xx = (n) => {
|
|
18466
18463
|
const { inputs: t, backend: e, attrs: s } = n, { x: r } = t, { paddings: o, constantValue: i } = s;
|
|
18467
18464
|
if (o.every((u) => re(u, [0, 0])))
|
|
18468
|
-
return
|
|
18465
|
+
return He({ inputs: { x: r }, backend: e });
|
|
18469
18466
|
if (U(r.shape) === 0) {
|
|
18470
18467
|
const u = o.map(
|
|
18471
18468
|
(c, h) => c[0] + r.shape[h] + c[1]
|
|
@@ -18525,7 +18522,7 @@ function Zx(n) {
|
|
|
18525
18522
|
*/
|
|
18526
18523
|
function Lt(n) {
|
|
18527
18524
|
return (t, e, s, r, o) => {
|
|
18528
|
-
const i =
|
|
18525
|
+
const i = Wt(t, e), a = i.length, l = Ht(i), u = U(i), c = Ln(o, u), h = t.length, f = e.length, d = Ht(t), p = Ht(e), g = hr(t, i), m = hr(e, i);
|
|
18529
18526
|
if (g.length + m.length === 0)
|
|
18530
18527
|
for (let b = 0; b < c.length; ++b)
|
|
18531
18528
|
c[b] = n(s[b % s.length], r[b % r.length]);
|
|
@@ -18602,7 +18599,7 @@ const tS = Lt((n, t) => n + t);
|
|
|
18602
18599
|
* =============================================================================
|
|
18603
18600
|
*/
|
|
18604
18601
|
function eS(n, t, e, s, r) {
|
|
18605
|
-
const o = U(s), i =
|
|
18602
|
+
const o = U(s), i = je(r, e);
|
|
18606
18603
|
for (let a = 0; a < n.length; a++) {
|
|
18607
18604
|
const l = n[a];
|
|
18608
18605
|
if (l < 0)
|
|
@@ -18947,7 +18944,7 @@ const gS = Lt((n, t) => n <= t ? 1 : 0);
|
|
|
18947
18944
|
* =============================================================================
|
|
18948
18945
|
*/
|
|
18949
18946
|
function bS(n, t, e) {
|
|
18950
|
-
const s = (t - n) / (e - 1), r =
|
|
18947
|
+
const s = (t - n) / (e - 1), r = je(e, "float32");
|
|
18951
18948
|
r[0] = n;
|
|
18952
18949
|
for (let o = 1; o < r.length; o++)
|
|
18953
18950
|
r[o] = r[o - 1] + s;
|
|
@@ -18987,7 +18984,7 @@ const yS = Oe((n) => Math.log(n));
|
|
|
18987
18984
|
* =============================================================================
|
|
18988
18985
|
*/
|
|
18989
18986
|
function wS(n, t, e, s) {
|
|
18990
|
-
const r =
|
|
18987
|
+
const r = Ln(s, U(e));
|
|
18991
18988
|
for (let o = 0; o < r.length; ++o) {
|
|
18992
18989
|
const i = o * t;
|
|
18993
18990
|
let a = n[i];
|
|
@@ -19104,7 +19101,7 @@ const vS = Lt((n, t) => n !== t ? 1 : 0);
|
|
|
19104
19101
|
* =============================================================================
|
|
19105
19102
|
*/
|
|
19106
19103
|
function IS(n, t, e, s, r) {
|
|
19107
|
-
const o = t.length, i = U(t), a = Ht(t), l = Ht(r), u =
|
|
19104
|
+
const o = t.length, i = U(t), a = Ht(t), l = Ht(r), u = Ln(e, U(r));
|
|
19108
19105
|
for (let c = 0; c < i; ++c) {
|
|
19109
19106
|
const h = oi(c, o, a), f = new Array(h.length);
|
|
19110
19107
|
for (let p = 0; p < f.length; p++)
|
|
@@ -19131,7 +19128,7 @@ function IS(n, t, e, s, r) {
|
|
|
19131
19128
|
* =============================================================================
|
|
19132
19129
|
*/
|
|
19133
19130
|
function AS(n, t, e, s) {
|
|
19134
|
-
const [r, o] = bi(n, s), i = ci(t, "int32"), a =
|
|
19131
|
+
const [r, o] = bi(n, s), i = ci(t, "int32"), a = je(U(r), i), l = U(o);
|
|
19135
19132
|
for (let u = 0; u < a.length; ++u) {
|
|
19136
19133
|
const c = u * l;
|
|
19137
19134
|
let h = 1;
|
|
@@ -19586,8 +19583,8 @@ function PS(n, t, e, s, r, o, i, a, l, u) {
|
|
|
19586
19583
|
function LS(n, t, e, s) {
|
|
19587
19584
|
const r = n === t, o = n < t && e < 0, i = t < n && e > 1;
|
|
19588
19585
|
if (r || o || i)
|
|
19589
|
-
return
|
|
19590
|
-
const a = Math.abs(Math.ceil((t - n) / e)), l =
|
|
19586
|
+
return je(0, s);
|
|
19587
|
+
const a = Math.abs(Math.ceil((t - n) / e)), l = je(a, s);
|
|
19591
19588
|
t < n && e === 1 && (e = -1), l[0] = n;
|
|
19592
19589
|
for (let u = 1; u < l.length; u++)
|
|
19593
19590
|
l[u] = l[u - 1] + e;
|
|
@@ -20228,7 +20225,7 @@ function QS(n, t) {
|
|
|
20228
20225
|
* limitations under the License.
|
|
20229
20226
|
* =============================================================================
|
|
20230
20227
|
*/
|
|
20231
|
-
const
|
|
20228
|
+
const fs = (n, t) => {
|
|
20232
20229
|
const e = t.value - n.value;
|
|
20233
20230
|
return e === 0 ? n.index - t.index : e;
|
|
20234
20231
|
};
|
|
@@ -20240,21 +20237,21 @@ function uf(n, t, e = 0, s = n.length - 1) {
|
|
|
20240
20237
|
}
|
|
20241
20238
|
const r = n[t];
|
|
20242
20239
|
let o = e, i = s;
|
|
20243
|
-
for (
|
|
20244
|
-
for (
|
|
20240
|
+
for (Cn(n, e, t), fs(n[s], r) > 0 && Cn(n, e, s); o < i; ) {
|
|
20241
|
+
for (Cn(n, o, i), o++, i--; fs(n[o], r) < 0; )
|
|
20245
20242
|
o = o + 1;
|
|
20246
|
-
for (;
|
|
20243
|
+
for (; fs(n[i], r) > 0; )
|
|
20247
20244
|
i = i - 1;
|
|
20248
20245
|
}
|
|
20249
|
-
|
|
20246
|
+
fs(n[e], r) === 0 ? Cn(n, e, i) : (i = i + 1, Cn(n, i, s)), i <= t && (e = i + 1), t <= i && (s = i - 1);
|
|
20250
20247
|
}
|
|
20251
20248
|
}
|
|
20252
20249
|
function t2(n, t, e, s, r) {
|
|
20253
|
-
const o = t[t.length - 1], [i, a] = [n.length / o, o], l =
|
|
20250
|
+
const o = t[t.length - 1], [i, a] = [n.length / o, o], l = Ln(e, i * s), u = Ln("int32", i * s);
|
|
20254
20251
|
for (let h = 0; h < i; h++) {
|
|
20255
20252
|
const f = h * a, d = n.subarray(f, f + a);
|
|
20256
20253
|
let p = new Array(d.length);
|
|
20257
|
-
d.forEach((y, S) => p[S] = { value: y, index: S }), s < p.length && (uf(p, s), p = p.slice(0, s)), r && p.sort(
|
|
20254
|
+
d.forEach((y, S) => p[S] = { value: y, index: S }), s < p.length && (uf(p, s), p = p.slice(0, s)), r && p.sort(fs);
|
|
20258
20255
|
const g = h * s, m = l.subarray(g, g + s), b = u.subarray(g, g + s);
|
|
20259
20256
|
for (let y = 0; y < s; y++)
|
|
20260
20257
|
m[y] = p[y].value, b[y] = p[y].index;
|
|
@@ -20282,7 +20279,7 @@ function t2(n, t, e, s, r) {
|
|
|
20282
20279
|
* =============================================================================
|
|
20283
20280
|
*/
|
|
20284
20281
|
function e2(n, t, e, s) {
|
|
20285
|
-
const r =
|
|
20282
|
+
const r = Es(t, e)[0], o = [1, e[0], 1];
|
|
20286
20283
|
for (let p = 0; p < r; p++)
|
|
20287
20284
|
o[0] *= e[p];
|
|
20288
20285
|
o[1] = e[r];
|
|
@@ -20817,7 +20814,7 @@ const W2 = "return abs(a);", G2 = `
|
|
|
20817
20814
|
let e2x = exp(-2.0 * abs(a));
|
|
20818
20815
|
return sign(a) * (1.0 - e2x) / (1.0 + e2x);
|
|
20819
20816
|
`, D$ = "return f32(i32((a)));";
|
|
20820
|
-
function
|
|
20817
|
+
function En(n, t) {
|
|
20821
20818
|
switch (n) {
|
|
20822
20819
|
case z.ABS:
|
|
20823
20820
|
return W2;
|
|
@@ -20921,24 +20918,24 @@ function An(n, t) {
|
|
|
20921
20918
|
* limitations under the License.
|
|
20922
20919
|
* =============================================================================
|
|
20923
20920
|
*/
|
|
20924
|
-
function
|
|
20921
|
+
function ns(n, t = !1, e = !1, s = 3) {
|
|
20925
20922
|
if (n === null)
|
|
20926
20923
|
return "";
|
|
20927
20924
|
let r = "";
|
|
20928
20925
|
if (n === "linear")
|
|
20929
|
-
r =
|
|
20926
|
+
r = En(z.LINEAR);
|
|
20930
20927
|
else if (n === "relu")
|
|
20931
|
-
r =
|
|
20928
|
+
r = En(z.RELU, e);
|
|
20932
20929
|
else if (n === "elu")
|
|
20933
|
-
r =
|
|
20930
|
+
r = En(z.ELU, e);
|
|
20934
20931
|
else if (n === "relu6")
|
|
20935
|
-
r =
|
|
20932
|
+
r = En(z.RELU6, e);
|
|
20936
20933
|
else if (n === "prelu")
|
|
20937
20934
|
r = U2(it.PRELU, e);
|
|
20938
20935
|
else if (n === "sigmoid")
|
|
20939
|
-
r =
|
|
20936
|
+
r = En(z.SIGMOID, e);
|
|
20940
20937
|
else if (n === "leakyrelu")
|
|
20941
|
-
r =
|
|
20938
|
+
r = En(z.LEAKYRELU, e);
|
|
20942
20939
|
else
|
|
20943
20940
|
throw new Error(`Activation ${n} has not been implemented for the WebGPU backend.`);
|
|
20944
20941
|
const i = K(e ? 4 : 1);
|
|
@@ -21320,7 +21317,7 @@ class B$ {
|
|
|
21320
21317
|
}
|
|
21321
21318
|
getUserCode() {
|
|
21322
21319
|
return `
|
|
21323
|
-
${
|
|
21320
|
+
${ns(this.activation, this.hasPreluActivationWeights, this.isVec4)}
|
|
21324
21321
|
${ca(this.addBias, this.activation, !1, this.transposeB, this.fitAOuter, this.fitBOuter, this.fitInner, this.isVec4 ? 4 : 1)}
|
|
21325
21322
|
${this.isVec4 ? ha(this.elementsPerThread, this.workgroupSize, this.transposeA, this.tileInner, !1, null, !0) : this.isVectorA ? O$(this.workgroupSize, this.transposeA) : fa(this.elementsPerThread, this.workgroupSize, this.transposeA, this.tileInner, !1, null, this.sequentialAccessByThreads, !0)}
|
|
21326
21323
|
`;
|
|
@@ -21410,7 +21407,7 @@ function F$(n, t, e, s, r = !1, o = null, i = !1, a = 4, l = 4, u = 4) {
|
|
|
21410
21407
|
}
|
|
21411
21408
|
return ${K(a)}(0.0);`, x = `${h(l)}`, $ = K(u), E = K(n ? a : l), D = K(n ? l : a);
|
|
21412
21409
|
return `
|
|
21413
|
-
${
|
|
21410
|
+
${ns(o, i, u === 4, 4)}
|
|
21414
21411
|
fn mm_readA(batch: i32, row : i32, col : i32) -> ${E} {
|
|
21415
21412
|
${n ? S : x}
|
|
21416
21413
|
}
|
|
@@ -21464,7 +21461,7 @@ class U$ {
|
|
|
21464
21461
|
}
|
|
21465
21462
|
getUserCode() {
|
|
21466
21463
|
return `
|
|
21467
|
-
${
|
|
21464
|
+
${ns(this.activation, this.hasPreluActivationWeights, !1, 4)}
|
|
21468
21465
|
fn readInp(batch : i32, row : i32, col : i32, chan : i32) -> f32{
|
|
21469
21466
|
let coords = vec4<i32>(batch, row, col, chan);
|
|
21470
21467
|
if (coordsInBounds4D(coords, uniforms.xShape)) {
|
|
@@ -21621,7 +21618,7 @@ class V$ {
|
|
|
21621
21618
|
}
|
|
21622
21619
|
getUserCode() {
|
|
21623
21620
|
return `
|
|
21624
|
-
${
|
|
21621
|
+
${ns(this.activation, this.hasPreluActivationWeights)}
|
|
21625
21622
|
${ca(this.addBias, this.activation, this.transposeA, this.transposeB)}
|
|
21626
21623
|
${G$(this.workgroupSize[0])}
|
|
21627
21624
|
`;
|
|
@@ -21713,7 +21710,7 @@ class j$ {
|
|
|
21713
21710
|
}
|
|
21714
21711
|
getUserCode() {
|
|
21715
21712
|
return `
|
|
21716
|
-
${
|
|
21713
|
+
${ns(this.activation, this.hasPreluActivationWeights)}
|
|
21717
21714
|
${ca(this.addBias, this.activation, this.transposeA, this.transposeB)}
|
|
21718
21715
|
${q$(this.workgroupSize)}
|
|
21719
21716
|
`;
|
|
@@ -21771,7 +21768,7 @@ class K$ {
|
|
|
21771
21768
|
}
|
|
21772
21769
|
getUserCode() {
|
|
21773
21770
|
return `
|
|
21774
|
-
${
|
|
21771
|
+
${ns(this.activation, this.hasPreluActivationWeights)}
|
|
21775
21772
|
${wt("index")} {
|
|
21776
21773
|
if (index < uniforms.size) {
|
|
21777
21774
|
let coords = getCoordsFromIndex(index);
|
|
@@ -21820,7 +21817,7 @@ function dt(n) {
|
|
|
21820
21817
|
* =============================================================================
|
|
21821
21818
|
*/
|
|
21822
21819
|
function hf({ a: n, b: t, transposeA: e, transposeB: s, backend: r, bias: o = null, preluActivationWeights: i = null, leakyreluAlpha: a = 0, activation: l = null }) {
|
|
21823
|
-
const u = n.shape.length, c = t.shape.length, h = e ? n.shape[u - 2] : n.shape[u - 1], f = s ? t.shape[c - 1] : t.shape[c - 2], d = e ? n.shape[u - 1] : n.shape[u - 2], p = s ? t.shape[c - 2] : t.shape[c - 1], g = n.shape.slice(0, -2), m = t.shape.slice(0, -2), b = U(g), y = U(m), x =
|
|
21820
|
+
const u = n.shape.length, c = t.shape.length, h = e ? n.shape[u - 2] : n.shape[u - 1], f = s ? t.shape[c - 1] : t.shape[c - 2], d = e ? n.shape[u - 1] : n.shape[u - 2], p = s ? t.shape[c - 2] : t.shape[c - 1], g = n.shape.slice(0, -2), m = t.shape.slice(0, -2), b = U(g), y = U(m), x = Wt(n.shape.slice(0, -2), t.shape.slice(0, -2)).concat([d, p]);
|
|
21824
21821
|
w(h === f, () => `Error in matMul: inner shapes (${h}) and (${f}) of Tensors with shapes ${n.shape} and ${t.shape} and transposeA=${e} and transposeB=${s} must match.`);
|
|
21825
21822
|
const $ = e ? [b, h, d] : [b, d, h], E = s ? [y, p, f] : [y, f, p], D = dt({ inputs: { x: n }, backend: r, attrs: { shape: $ } }), _ = dt({ inputs: { x: t }, backend: r, attrs: { shape: E } }), T = [D, _], P = Math.max(b, y), B = [D, _], Y = [
|
|
21826
21823
|
{ type: "int32", data: [d] },
|
|
@@ -21831,8 +21828,8 @@ function hf({ a: n, b: t, transposeA: e, transposeB: s, backend: r, bias: o = nu
|
|
|
21831
21828
|
const G = [P, d, p];
|
|
21832
21829
|
let q = W().get("WEBGPU_MATMUL_PROGRAM_TYPE");
|
|
21833
21830
|
if (q < 0) {
|
|
21834
|
-
const
|
|
21835
|
-
|
|
21831
|
+
const Mt = W().getNumber("WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL"), Ot = Mt > 0 ? Mt : r.thresholdToIncreaseWorkgroups, Be = P * Math.ceil(d / 32) * Math.ceil(p / 32);
|
|
21832
|
+
Be <= Ot || d <= 8 && Be <= Ot * 2 ? P * d * p <= 128 ? q = xe.MatMulReduceProgram : P === 1 && f >= 2e3 ? q = xe.MatMulSplitKProgram : q = xe.MatMulSmallOutputSizeProgram : q = xe.MatMulPackedProgram;
|
|
21836
21833
|
}
|
|
21837
21834
|
switch (q) {
|
|
21838
21835
|
case xe.MatMulReduceProgram:
|
|
@@ -21841,11 +21838,11 @@ function hf({ a: n, b: t, transposeA: e, transposeB: s, backend: r, bias: o = nu
|
|
|
21841
21838
|
case xe.MatMulSplitKProgram: {
|
|
21842
21839
|
if (F = af({ backend: r, attrs: { shape: G, value: 0, dtype: n.dtype } }), j = new H$(G, f, e, s), o || l) {
|
|
21843
21840
|
F = r.runWebGPUProgram(j, B, n.dtype, Y, F);
|
|
21844
|
-
const
|
|
21845
|
-
let
|
|
21846
|
-
const
|
|
21847
|
-
o &&
|
|
21848
|
-
const da = r.runWebGPUProgram(
|
|
21841
|
+
const Ot = new K$(F.shape, o, l, i);
|
|
21842
|
+
let Be = null;
|
|
21843
|
+
const vn = [F];
|
|
21844
|
+
o && vn.push(o), i && vn.push(i), l === "leakyrelu" && (Be = [{ type: "float32", data: [a] }], Ot.uniforms += " alpha : f32,");
|
|
21845
|
+
const da = r.runWebGPUProgram(Ot, vn, F.dtype, Be);
|
|
21849
21846
|
T.push(F);
|
|
21850
21847
|
const df = dt({ inputs: { x: da }, backend: r, attrs: { shape: x } });
|
|
21851
21848
|
T.push(da);
|
|
@@ -21859,8 +21856,8 @@ function hf({ a: n, b: t, transposeA: e, transposeB: s, backend: r, bias: o = nu
|
|
|
21859
21856
|
j = new j$($, E, G, e, s, o, l, i);
|
|
21860
21857
|
break;
|
|
21861
21858
|
case xe.MatMulPackedProgram:
|
|
21862
|
-
const
|
|
21863
|
-
j = new B$($, G, e, s, o, l, i,
|
|
21859
|
+
const Mt = r.adapterInfo.isIntel();
|
|
21860
|
+
j = new B$($, G, e, s, o, l, i, Mt);
|
|
21864
21861
|
break;
|
|
21865
21862
|
default:
|
|
21866
21863
|
throw new Error(`Unsupported MatMulProgramType ${q}.`);
|
|
@@ -21868,8 +21865,8 @@ function hf({ a: n, b: t, transposeA: e, transposeB: s, backend: r, bias: o = nu
|
|
|
21868
21865
|
o && B.push(o), i && B.push(i), l === "leakyrelu" && (Y.push({ type: "float32", data: [a] }), j.uniforms += " alpha : f32,"), F = r.runWebGPUProgram(j, B, n.dtype, Y, F);
|
|
21869
21866
|
const be = dt({ inputs: { x: F }, backend: r, attrs: { shape: x } });
|
|
21870
21867
|
T.push(F);
|
|
21871
|
-
for (const
|
|
21872
|
-
r.disposeData(
|
|
21868
|
+
for (const Mt of T)
|
|
21869
|
+
r.disposeData(Mt.dataId);
|
|
21873
21870
|
return be;
|
|
21874
21871
|
}
|
|
21875
21872
|
/**
|
|
@@ -22429,7 +22426,7 @@ const av = {
|
|
|
22429
22426
|
any: "bool"
|
|
22430
22427
|
};
|
|
22431
22428
|
function lv(n, t, e, s, r) {
|
|
22432
|
-
const o = n.shape.length, i = [], a =
|
|
22429
|
+
const o = n.shape.length, i = [], a = Es(t, n.shape);
|
|
22433
22430
|
let l = a;
|
|
22434
22431
|
const u = bg(l, o);
|
|
22435
22432
|
let c = n;
|
|
@@ -22498,7 +22495,7 @@ function uv(n) {
|
|
|
22498
22495
|
*/
|
|
22499
22496
|
function cv(n, t, e, s) {
|
|
22500
22497
|
if (t.filterWidth === 1 && t.filterHeight === 1 && re(t.inShape, t.outShape))
|
|
22501
|
-
return
|
|
22498
|
+
return He({ inputs: { x: n }, backend: s });
|
|
22502
22499
|
if (t.filterWidth === t.inWidth && t.filterHeight === t.inHeight && t.batchSize === 1 && t.padInfo.type === "VALID") {
|
|
22503
22500
|
const i = n.shape.length, a = dt({
|
|
22504
22501
|
inputs: { x: n },
|
|
@@ -22657,7 +22654,7 @@ const mv = {
|
|
|
22657
22654
|
*/
|
|
22658
22655
|
class gv {
|
|
22659
22656
|
constructor(t) {
|
|
22660
|
-
this.uniforms = "", this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape =
|
|
22657
|
+
this.uniforms = "", this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.size = !0, this.outputShape = xs(
|
|
22661
22658
|
t,
|
|
22662
22659
|
1
|
|
22663
22660
|
/* axis */
|
|
@@ -22710,7 +22707,7 @@ class gv {
|
|
|
22710
22707
|
* =============================================================================
|
|
22711
22708
|
*/
|
|
22712
22709
|
function bv(n) {
|
|
22713
|
-
const { inputs: t, backend: e } = n, { real: s, imag: r } = t, o = e.makeTensorInfo(s.shape, "complex64"), i = e.tensorMap.get(o.dataId), a =
|
|
22710
|
+
const { inputs: t, backend: e } = n, { real: s, imag: r } = t, o = e.makeTensorInfo(s.shape, "complex64"), i = e.tensorMap.get(o.dataId), a = He({ inputs: { x: s }, backend: e }), l = He({ inputs: { x: r }, backend: e });
|
|
22714
22711
|
return i.complexTensorInfos = { real: a, imag: l }, o;
|
|
22715
22712
|
}
|
|
22716
22713
|
/**
|
|
@@ -22731,7 +22728,7 @@ function bv(n) {
|
|
|
22731
22728
|
*/
|
|
22732
22729
|
function yv(n) {
|
|
22733
22730
|
const { inputs: t, backend: e } = n, { input: s } = t, r = e.tensorMap.get(s.dataId);
|
|
22734
|
-
return
|
|
22731
|
+
return He({ inputs: { x: r.complexTensorInfos.imag }, backend: e });
|
|
22735
22732
|
}
|
|
22736
22733
|
/**
|
|
22737
22734
|
* @license
|
|
@@ -22751,7 +22748,7 @@ function yv(n) {
|
|
|
22751
22748
|
*/
|
|
22752
22749
|
function wv(n) {
|
|
22753
22750
|
const { inputs: t, backend: e } = n, { input: s } = t, r = e.tensorMap.get(s.dataId);
|
|
22754
|
-
return
|
|
22751
|
+
return He({ inputs: { x: r.complexTensorInfos.real }, backend: e });
|
|
22755
22752
|
}
|
|
22756
22753
|
/**
|
|
22757
22754
|
* @license
|
|
@@ -22769,10 +22766,10 @@ function wv(n) {
|
|
|
22769
22766
|
* limitations under the License.
|
|
22770
22767
|
* =============================================================================
|
|
22771
22768
|
*/
|
|
22772
|
-
function
|
|
22769
|
+
function ds(n, t, e) {
|
|
22773
22770
|
const s = n[0].dtype;
|
|
22774
22771
|
if (s === "complex64") {
|
|
22775
|
-
const p = n.map((S) => wv({ inputs: { input: S }, backend: e })), g = n.map((S) => yv({ inputs: { input: S }, backend: e })), m =
|
|
22772
|
+
const p = n.map((S) => wv({ inputs: { input: S }, backend: e })), g = n.map((S) => yv({ inputs: { input: S }, backend: e })), m = ds(p, t, e), b = ds(g, t, e), y = bv({ inputs: { real: m, imag: b }, backend: e });
|
|
22776
22773
|
return p.forEach((S) => e.disposeData(S.dataId)), g.forEach((S) => e.disposeData(S.dataId)), e.disposeData(m.dataId), e.disposeData(b.dataId), y;
|
|
22777
22774
|
}
|
|
22778
22775
|
let r = e.shouldExecuteOnCPU(n);
|
|
@@ -22780,11 +22777,11 @@ function fs(n, t, e) {
|
|
|
22780
22777
|
const p = n.map(($) => {
|
|
22781
22778
|
const D = [-1, U($.shape.slice(t))];
|
|
22782
22779
|
return dt({ inputs: { x: $ }, backend: e, attrs: { shape: D } });
|
|
22783
|
-
}), g = p.map(($) => ({ vals: e.readSync($.dataId), shape: $.shape })), m =
|
|
22780
|
+
}), g = p.map(($) => ({ vals: e.readSync($.dataId), shape: $.shape })), m = xs(
|
|
22784
22781
|
p.map(($) => $.shape),
|
|
22785
22782
|
1
|
|
22786
22783
|
/* axis */
|
|
22787
|
-
), b = p[0].shape[0] === 1, y = s2(g, m, s, b), S =
|
|
22784
|
+
), b = p[0].shape[0] === 1, y = s2(g, m, s, b), S = xs(n.map(($) => $.shape), t), x = e.makeTensorInfo(S, s, y);
|
|
22788
22785
|
return p.forEach(($) => e.disposeData($.dataId)), x;
|
|
22789
22786
|
}
|
|
22790
22787
|
const o = e.device.limits.maxStorageBuffersPerShaderStage - 1;
|
|
@@ -22792,9 +22789,9 @@ function fs(n, t, e) {
|
|
|
22792
22789
|
const p = [];
|
|
22793
22790
|
for (let m = 0; m < n.length; m += o) {
|
|
22794
22791
|
const b = n.slice(m, m + o);
|
|
22795
|
-
p.push(
|
|
22792
|
+
p.push(ds(b, t, e));
|
|
22796
22793
|
}
|
|
22797
|
-
const g =
|
|
22794
|
+
const g = ds(p, t, e);
|
|
22798
22795
|
for (const m of p)
|
|
22799
22796
|
e.disposeData(m.dataId);
|
|
22800
22797
|
return g;
|
|
@@ -22811,7 +22808,7 @@ function fs(n, t, e) {
|
|
|
22811
22808
|
return e.disposeData(f.dataId), d;
|
|
22812
22809
|
}
|
|
22813
22810
|
function xv(n, t, e) {
|
|
22814
|
-
const s =
|
|
22811
|
+
const s = xs(n.map((o) => o.shape), t);
|
|
22815
22812
|
return { tensors2D: n.map((o) => dt({
|
|
22816
22813
|
inputs: { x: o },
|
|
22817
22814
|
backend: e,
|
|
@@ -22840,13 +22837,13 @@ function xv(n, t, e) {
|
|
|
22840
22837
|
* =============================================================================
|
|
22841
22838
|
*/
|
|
22842
22839
|
function Sv(n) {
|
|
22843
|
-
const { inputs: t, backend: e, attrs: s } = n, { axis: r } = s, o =
|
|
22840
|
+
const { inputs: t, backend: e, attrs: s } = n, { axis: r } = s, o = Es(r, t[0].shape)[0], i = t.map((u) => u.shape);
|
|
22844
22841
|
dy(i, o);
|
|
22845
|
-
const a =
|
|
22842
|
+
const a = xs(t.map((u) => u.shape), o);
|
|
22846
22843
|
if (U(a) === 0)
|
|
22847
22844
|
return e.makeTensorInfo(a, t[0].dtype, []);
|
|
22848
22845
|
const l = t.filter((u) => U(u.shape) > 0);
|
|
22849
|
-
return l.length === 1 ?
|
|
22846
|
+
return l.length === 1 ? He({ inputs: { x: l[0] }, backend: e }) : ds(l, o, e);
|
|
22850
22847
|
}
|
|
22851
22848
|
const $v = {
|
|
22852
22849
|
kernelName: Hl,
|
|
@@ -22888,7 +22885,7 @@ async function Iv() {
|
|
|
22888
22885
|
}
|
|
22889
22886
|
}
|
|
22890
22887
|
async function ff(n, t) {
|
|
22891
|
-
const e = new
|
|
22888
|
+
const e = new Bs(n, t);
|
|
22892
22889
|
return A.registerBackend("webgpu-oidn", () => e), await A.setBackend("webgpu-oidn"), e;
|
|
22893
22890
|
}
|
|
22894
22891
|
async function Av(n, t, e) {
|