diff --git a/README.md b/README.md
index 5b43191a..aa1b5975 100644
--- a/README.md
+++ b/README.md
@@ -436,7 +436,7 @@ For more info, see [**Configuration Details**](https://github.com/vladmandic/hum
-`Human` library is written in [TypeScript](https://www.typescriptlang.org/docs/handbook/intro.html) **4.9** using [TensorFlow/JS](https://www.tensorflow.org/js/) **4.0** and conforming to latest `JavaScript` [ECMAScript version 2022](https://262.ecma-international.org/) standard
+`Human` library is written in [TypeScript](https://www.typescriptlang.org/docs/handbook/intro.html) **4.9** using [TensorFlow/JS](https://www.tensorflow.org/js/) **4.1** and conforming to latest `JavaScript` [ECMAScript version 2022](https://262.ecma-international.org/) standard
Build target for distributables is `JavaScript` [EMCAScript version 2018](https://262.ecma-international.org/9.0/)
diff --git a/TODO.md b/TODO.md
index f1208a35..642e8330 100644
--- a/TODO.md
+++ b/TODO.md
@@ -77,7 +77,7 @@ Features:
See `human.result.face[n].distance`
Architecture:
-- Upgrade to **TFJS 4.0** with **strong typing**
+- Upgrade to **TFJS 4.1** with **strong typing**
see [notes](https://github.com/vladmandic/human#typedefs) on how to use
- `TypeDef` refactoring
- Re-architect `human.models` namespace for better dynamic model handling
diff --git a/demo/faceid/index.js b/demo/faceid/index.js
index 635d01de..67a9f377 100644
--- a/demo/faceid/index.js
+++ b/demo/faceid/index.js
@@ -4,6 +4,359 @@
author: '
*/
-import*as S from"../../dist/human.esm.js";var l,F="human",f="person",v=(...a)=>console.log("indexdb",...a);async function h(){return l?!0:new Promise(a=>{let n=indexedDB.open(F,1);n.onerror=o=>v("error:",o),n.onupgradeneeded=o=>{v("create:",o.target),l=o.target.result,l.createObjectStore(f,{keyPath:"id",autoIncrement:!0})},n.onsuccess=o=>{l=o.target.result,v("open:",l),a(!0)}})}async function C(){let a=[];return l||await h(),new Promise(n=>{let o=l.transaction([f],"readwrite").objectStore(f).openCursor(null,"next");o.onerror=i=>v("load error:",i),o.onsuccess=i=>{i.target.result?(a.push(i.target.result.value),i.target.result.continue()):n(a)}})}async function b(){return l||await h(),new Promise(a=>{let n=l.transaction([f],"readwrite").objectStore(f).count();n.onerror=o=>v("count error:",o),n.onsuccess=()=>a(n.result)})}async function x(a){l||await h();let n={name:a.name,descriptor:a.descriptor,image:a.image};l.transaction([f],"readwrite").objectStore(f).put(n),v("save:",n)}async function D(a){l||await h(),l.transaction([f],"readwrite").objectStore(f).delete(a.id),v("delete:",a)}var g={cacheSensitivity:0,modelBasePath:"../../models",filter:{enabled:!0,equalization:!0},debug:!0,face:{enabled:!0,detector:{rotation:!0,return:!0,cropFactor:1.6,mask:!1},description:{enabled:!0},iris:{enabled:!0},emotion:{enabled:!1},antispoof:{enabled:!0},liveness:{enabled:!0}},body:{enabled:!1},hand:{enabled:!1},object:{enabled:!1},gesture:{enabled:!0}},B={order:2,multiplier:25,min:.2,max:.8},r={minConfidence:.6,minSize:224,maxTime:3e4,blinkMin:10,blinkMax:800,threshold:.5,distanceMin:.4,distanceMax:1,mask:g.face.detector.mask,rotation:g.face.detector.rotation,cropFactor:g.face.detector.cropFactor,...B},e={faceCount:{status:!1,val:0},faceConfidence:{status:!1,val:0},facingCenter:{status:!1,val:0},lookingCenter:{status:!1,val:0},blinkDetected:{status:!1,val:0},faceSize:{status:!1,val:0},antispoofCheck:{status:!1,val:0},livenessCheck:{status:!1,val:0},distance:{status:!1,val:0},age:{status:!1,val:0},gender:{status:!1,val:0},timeout:{status:!0,val:0},descriptor:{status:!1,val:0},elapsedMs:{status:void 0,val:0},detectFPS:{status:void 0,val:0},drawFPS:{status:void 0,val:0}},E=()=>e.faceCount.status&&e.faceSize.status&&e.blinkDetected.status&&e.facingCenter.status&&e.lookingCenter.status&&e.faceConfidence.status&&e.antispoofCheck.status&&e.livenessCheck.status&&e.distance.status&&e.descriptor.status&&e.age.status&&e.gender.status,c={face:null,record:null},u={start:0,end:0,time:0},s=new S.Human(g);s.env.perfadd=!1;s.draw.options.font='small-caps 18px "Lato"';s.draw.options.lineHeight=20;var t={video:document.getElementById("video"),canvas:document.getElementById("canvas"),log:document.getElementById("log"),fps:document.getElementById("fps"),match:document.getElementById("match"),name:document.getElementById("name"),save:document.getElementById("save"),delete:document.getElementById("delete"),retry:document.getElementById("retry"),source:document.getElementById("source"),ok:document.getElementById("ok")},y={detect:0,draw:0},I=0,d=(...a)=>{t.log.innerText+=a.join(" ")+`
-`,console.log(...a)};async function H(){let a={audio:!1,video:{facingMode:"user",resizeMode:"none",width:{ideal:document.body.clientWidth}}},n=await navigator.mediaDevices.getUserMedia(a),o=new Promise(i=>{t.video.onloadeddata=()=>i(!0)});t.video.srcObject=n,t.video.play(),await o,t.canvas.width=t.video.videoWidth,t.canvas.height=t.video.videoHeight,t.canvas.style.width="50%",t.canvas.style.height="50%",s.env.initial&&d("video:",t.video.videoWidth,t.video.videoHeight,"|",n.getVideoTracks()[0].label),t.canvas.onclick=()=>{t.video.paused?t.video.play():t.video.pause()}}async function T(){var a;if(!t.video.paused){(a=c.face)!=null&&a.tensor&&s.tf.dispose(c.face.tensor),await s.detect(t.video);let n=s.now();e.detectFPS.val=Math.round(1e4/(n-y.detect))/10,y.detect=n,requestAnimationFrame(T)}}function P(){let a=32;for(let[n,o]of Object.entries(e)){let i=document.getElementById(`ok-${n}`);i||(i=document.createElement("div"),i.id=`ok-${n}`,i.innerText=n,i.className="ok",i.style.top=`${a}px`,t.ok.appendChild(i)),typeof o.status=="boolean"&&(i.style.backgroundColor=o.status?"lightgreen":"lightcoral");let m=o.status?"ok":"fail";i.innerText=`${n}: ${o.val===0?m:o.val}`,a+=28}}async function R(){var o;let a=s.next(s.result);s.draw.canvas(t.video,t.canvas),await s.draw.all(t.canvas,a);let n=s.now();if(e.drawFPS.val=Math.round(1e4/(n-y.draw))/10,y.draw=n,e.faceCount.val=s.result.face.length,e.faceCount.status=e.faceCount.val===1,e.faceCount.status){let i=Object.values(s.result.gesture).map(m=>m.gesture);(i.includes("blink left eye")||i.includes("blink right eye"))&&(u.start=s.now()),u.start>0&&!i.includes("blink left eye")&&!i.includes("blink right eye")&&(u.end=s.now()),e.blinkDetected.status=e.blinkDetected.status||Math.abs(u.end-u.start)>r.blinkMin&&Math.abs(u.end-u.start)=r.minConfidence,e.antispoofCheck.val=s.result.face[0].real||0,e.antispoofCheck.status=e.antispoofCheck.val>=r.minConfidence,e.livenessCheck.val=s.result.face[0].live||0,e.livenessCheck.status=e.livenessCheck.val>=r.minConfidence,e.faceSize.val=Math.min(s.result.face[0].box[2],s.result.face[0].box[3]),e.faceSize.status=e.faceSize.val>=r.minSize,e.distance.val=s.result.face[0].distance||0,e.distance.status=e.distance.val>=r.distanceMin&&e.distance.val<=r.distanceMax,e.descriptor.val=((o=s.result.face[0].embedding)==null?void 0:o.length)||0,e.descriptor.status=e.descriptor.val>0,e.age.val=s.result.face[0].age||0,e.age.status=e.age.val>0,e.gender.val=s.result.face[0].genderScore||0,e.gender.status=e.gender.val>=r.minConfidence}return e.timeout.status=e.elapsedMs.val<=r.maxTime,P(),E()||!e.timeout.status?(t.video.pause(),s.result.face[0]):(e.elapsedMs.val=Math.trunc(s.now()-I),new Promise(i=>{setTimeout(async()=>{await R(),i(s.result.face[0])},30)}))}async function z(){var a,n,o,i;if(t.name.value.length>0){let m=(a=t.canvas.getContext("2d"))==null?void 0:a.getImageData(0,0,t.canvas.width,t.canvas.height),p={id:0,name:t.name.value,descriptor:(n=c.face)==null?void 0:n.embedding,image:m};await x(p),d("saved face record:",p.name,"descriptor length:",(i=(o=c.face)==null?void 0:o.embedding)==null?void 0:i.length),d("known face records:",await b())}else d("invalid name")}async function j(){c.record&&c.record.id>0&&await D(c.record)}async function $(){var i,m,p,k;if(t.canvas.style.height="",(i=t.canvas.getContext("2d"))==null||i.clearRect(0,0,r.minSize,r.minSize),!((m=c==null?void 0:c.face)!=null&&m.tensor)||!((p=c==null?void 0:c.face)!=null&&p.embedding))return!1;if(console.log("face record:",c.face),d(`detected face: ${c.face.gender} ${c.face.age||0}y distance ${100*(c.face.distance||0)}cm/${Math.round(100*(c.face.distance||0)/2.54)}in`),await s.tf.browser.toPixels(c.face.tensor,t.canvas),await b()===0)return d("face database is empty: nothing to compare face with"),document.body.style.background="black",t.delete.style.display="none",!1;let a=await C(),n=a.map(w=>w.descriptor).filter(w=>w.length>0),o=s.match.find(c.face.embedding,n,B);return c.record=a[o.index]||null,c.record&&(d(`best match: ${c.record.name} | id: ${c.record.id} | similarity: ${Math.round(1e3*o.similarity)/10}%`),t.name.value=c.record.name,t.source.style.display="",(k=t.source.getContext("2d"))==null||k.putImageData(c.record.image,0,0)),document.body.style.background=o.similarity>r.threshold?"darkgreen":"maroon",o.similarity>r.threshold}async function M(){var a,n,o,i;return e.faceCount.status=!1,e.faceConfidence.status=!1,e.facingCenter.status=!1,e.blinkDetected.status=!1,e.faceSize.status=!1,e.antispoofCheck.status=!1,e.livenessCheck.status=!1,e.age.status=!1,e.gender.status=!1,e.elapsedMs.val=0,t.match.style.display="none",t.retry.style.display="none",t.source.style.display="none",t.canvas.style.height="50%",document.body.style.background="black",await H(),await T(),I=s.now(),c.face=await R(),t.canvas.width=((n=(a=c.face)==null?void 0:a.tensor)==null?void 0:n.shape[1])||r.minSize,t.canvas.height=((i=(o=c.face)==null?void 0:o.tensor)==null?void 0:i.shape[0])||r.minSize,t.source.width=t.canvas.width,t.source.height=t.canvas.height,t.canvas.style.width="",t.match.style.display="flex",t.save.style.display="flex",t.delete.style.display="flex",t.retry.style.display="block",E()?$():(d("did not find valid face"),!1)}async function q(){var a,n;d("human version:",s.version,"| tfjs version:",s.tf.version["tfjs-core"]),d("options:",JSON.stringify(r).replace(/{|}|"|\[|\]/g,"").replace(/,/g," ")),d("initializing webcam..."),await H(),d("loading human models..."),await s.load(),d("initializing human..."),d("face embedding model:",g.face.description.enabled?"faceres":"",(a=g.face.mobilefacenet)!=null&&a.enabled?"mobilefacenet":"",(n=g.face.insightface)!=null&&n.enabled?"insightface":""),d("loading face database..."),d("known face records:",await b()),t.retry.addEventListener("click",M),t.save.addEventListener("click",z),t.delete.addEventListener("click",j),await s.warmup(),await M()}window.onload=q;
+
+// demo/faceid/index.ts
+import * as H from "../../dist/human.esm.js";
+
+// demo/faceid/indexdb.ts
+var db;
+var database = "human";
+var table = "person";
+var log = (...msg) => console.log("indexdb", ...msg);
+async function open() {
+ if (db)
+ return true;
+ return new Promise((resolve) => {
+ const request = indexedDB.open(database, 1);
+ request.onerror = (evt) => log("error:", evt);
+ request.onupgradeneeded = (evt) => {
+ log("create:", evt.target);
+ db = evt.target.result;
+ db.createObjectStore(table, { keyPath: "id", autoIncrement: true });
+ };
+ request.onsuccess = (evt) => {
+ db = evt.target.result;
+ log("open:", db);
+ resolve(true);
+ };
+ });
+}
+async function load() {
+ const faceDB = [];
+ if (!db)
+ await open();
+ return new Promise((resolve) => {
+ const cursor = db.transaction([table], "readwrite").objectStore(table).openCursor(null, "next");
+ cursor.onerror = (evt) => log("load error:", evt);
+ cursor.onsuccess = (evt) => {
+ if (evt.target.result) {
+ faceDB.push(evt.target.result.value);
+ evt.target.result.continue();
+ } else {
+ resolve(faceDB);
+ }
+ };
+ });
+}
+async function count() {
+ if (!db)
+ await open();
+ return new Promise((resolve) => {
+ const store = db.transaction([table], "readwrite").objectStore(table).count();
+ store.onerror = (evt) => log("count error:", evt);
+ store.onsuccess = () => resolve(store.result);
+ });
+}
+async function save(faceRecord) {
+ if (!db)
+ await open();
+ const newRecord = { name: faceRecord.name, descriptor: faceRecord.descriptor, image: faceRecord.image };
+ db.transaction([table], "readwrite").objectStore(table).put(newRecord);
+ log("save:", newRecord);
+}
+async function remove(faceRecord) {
+ if (!db)
+ await open();
+ db.transaction([table], "readwrite").objectStore(table).delete(faceRecord.id);
+ log("delete:", faceRecord);
+}
+
+// demo/faceid/index.ts
+var humanConfig = {
+ cacheSensitivity: 0,
+ modelBasePath: "../../models",
+ filter: { enabled: true, equalization: true },
+ debug: true,
+ face: {
+ enabled: true,
+ detector: { rotation: true, return: true, cropFactor: 1.6, mask: false },
+ description: { enabled: true },
+ iris: { enabled: true },
+ emotion: { enabled: false },
+ antispoof: { enabled: true },
+ liveness: { enabled: true }
+ },
+ body: { enabled: false },
+ hand: { enabled: false },
+ object: { enabled: false },
+ gesture: { enabled: true }
+};
+var matchOptions = { order: 2, multiplier: 25, min: 0.2, max: 0.8 };
+var options = {
+ minConfidence: 0.6,
+ minSize: 224,
+ maxTime: 3e4,
+ blinkMin: 10,
+ blinkMax: 800,
+ threshold: 0.5,
+ distanceMin: 0.4,
+ distanceMax: 1,
+ mask: humanConfig.face.detector.mask,
+ rotation: humanConfig.face.detector.rotation,
+ cropFactor: humanConfig.face.detector.cropFactor,
+ ...matchOptions
+};
+var ok = {
+ faceCount: { status: false, val: 0 },
+ faceConfidence: { status: false, val: 0 },
+ facingCenter: { status: false, val: 0 },
+ lookingCenter: { status: false, val: 0 },
+ blinkDetected: { status: false, val: 0 },
+ faceSize: { status: false, val: 0 },
+ antispoofCheck: { status: false, val: 0 },
+ livenessCheck: { status: false, val: 0 },
+ distance: { status: false, val: 0 },
+ age: { status: false, val: 0 },
+ gender: { status: false, val: 0 },
+ timeout: { status: true, val: 0 },
+ descriptor: { status: false, val: 0 },
+ elapsedMs: { status: void 0, val: 0 },
+ detectFPS: { status: void 0, val: 0 },
+ drawFPS: { status: void 0, val: 0 }
+};
+var allOk = () => ok.faceCount.status && ok.faceSize.status && ok.blinkDetected.status && ok.facingCenter.status && ok.lookingCenter.status && ok.faceConfidence.status && ok.antispoofCheck.status && ok.livenessCheck.status && ok.distance.status && ok.descriptor.status && ok.age.status && ok.gender.status;
+var current = { face: null, record: null };
+var blink = {
+ start: 0,
+ end: 0,
+ time: 0
+};
+var human = new H.Human(humanConfig);
+human.env.perfadd = false;
+human.draw.options.font = 'small-caps 18px "Lato"';
+human.draw.options.lineHeight = 20;
+var dom = {
+ video: document.getElementById("video"),
+ canvas: document.getElementById("canvas"),
+ log: document.getElementById("log"),
+ fps: document.getElementById("fps"),
+ match: document.getElementById("match"),
+ name: document.getElementById("name"),
+ save: document.getElementById("save"),
+ delete: document.getElementById("delete"),
+ retry: document.getElementById("retry"),
+ source: document.getElementById("source"),
+ ok: document.getElementById("ok")
+};
+var timestamp = { detect: 0, draw: 0 };
+var startTime = 0;
+var log2 = (...msg) => {
+ dom.log.innerText += msg.join(" ") + "\n";
+ console.log(...msg);
+};
+async function webCam() {
+ const cameraOptions = { audio: false, video: { facingMode: "user", resizeMode: "none", width: { ideal: document.body.clientWidth } } };
+ const stream = await navigator.mediaDevices.getUserMedia(cameraOptions);
+ const ready = new Promise((resolve) => {
+ dom.video.onloadeddata = () => resolve(true);
+ });
+ dom.video.srcObject = stream;
+ void dom.video.play();
+ await ready;
+ dom.canvas.width = dom.video.videoWidth;
+ dom.canvas.height = dom.video.videoHeight;
+ dom.canvas.style.width = "50%";
+ dom.canvas.style.height = "50%";
+ if (human.env.initial)
+ log2("video:", dom.video.videoWidth, dom.video.videoHeight, "|", stream.getVideoTracks()[0].label);
+ dom.canvas.onclick = () => {
+ if (dom.video.paused)
+ void dom.video.play();
+ else
+ dom.video.pause();
+ };
+}
+async function detectionLoop() {
+ var _a;
+ if (!dom.video.paused) {
+ if ((_a = current.face) == null ? void 0 : _a.tensor)
+ human.tf.dispose(current.face.tensor);
+ await human.detect(dom.video);
+ const now = human.now();
+ ok.detectFPS.val = Math.round(1e4 / (now - timestamp.detect)) / 10;
+ timestamp.detect = now;
+ requestAnimationFrame(detectionLoop);
+ }
+}
+function drawValidationTests() {
+ let y = 32;
+ for (const [key, val] of Object.entries(ok)) {
+ let el = document.getElementById(`ok-${key}`);
+ if (!el) {
+ el = document.createElement("div");
+ el.id = `ok-${key}`;
+ el.innerText = key;
+ el.className = "ok";
+ el.style.top = `${y}px`;
+ dom.ok.appendChild(el);
+ }
+ if (typeof val.status === "boolean")
+ el.style.backgroundColor = val.status ? "lightgreen" : "lightcoral";
+ const status = val.status ? "ok" : "fail";
+ el.innerText = `${key}: ${val.val === 0 ? status : val.val}`;
+ y += 28;
+ }
+}
+async function validationLoop() {
+ var _a;
+ const interpolated = human.next(human.result);
+ human.draw.canvas(dom.video, dom.canvas);
+ await human.draw.all(dom.canvas, interpolated);
+ const now = human.now();
+ ok.drawFPS.val = Math.round(1e4 / (now - timestamp.draw)) / 10;
+ timestamp.draw = now;
+ ok.faceCount.val = human.result.face.length;
+ ok.faceCount.status = ok.faceCount.val === 1;
+ if (ok.faceCount.status) {
+ const gestures = Object.values(human.result.gesture).map((gesture) => gesture.gesture);
+ if (gestures.includes("blink left eye") || gestures.includes("blink right eye"))
+ blink.start = human.now();
+ if (blink.start > 0 && !gestures.includes("blink left eye") && !gestures.includes("blink right eye"))
+ blink.end = human.now();
+ ok.blinkDetected.status = ok.blinkDetected.status || Math.abs(blink.end - blink.start) > options.blinkMin && Math.abs(blink.end - blink.start) < options.blinkMax;
+ if (ok.blinkDetected.status && blink.time === 0)
+ blink.time = Math.trunc(blink.end - blink.start);
+ ok.facingCenter.status = gestures.includes("facing center");
+ ok.lookingCenter.status = gestures.includes("looking center");
+ ok.faceConfidence.val = human.result.face[0].faceScore || human.result.face[0].boxScore || 0;
+ ok.faceConfidence.status = ok.faceConfidence.val >= options.minConfidence;
+ ok.antispoofCheck.val = human.result.face[0].real || 0;
+ ok.antispoofCheck.status = ok.antispoofCheck.val >= options.minConfidence;
+ ok.livenessCheck.val = human.result.face[0].live || 0;
+ ok.livenessCheck.status = ok.livenessCheck.val >= options.minConfidence;
+ ok.faceSize.val = Math.min(human.result.face[0].box[2], human.result.face[0].box[3]);
+ ok.faceSize.status = ok.faceSize.val >= options.minSize;
+ ok.distance.val = human.result.face[0].distance || 0;
+ ok.distance.status = ok.distance.val >= options.distanceMin && ok.distance.val <= options.distanceMax;
+ ok.descriptor.val = ((_a = human.result.face[0].embedding) == null ? void 0 : _a.length) || 0;
+ ok.descriptor.status = ok.descriptor.val > 0;
+ ok.age.val = human.result.face[0].age || 0;
+ ok.age.status = ok.age.val > 0;
+ ok.gender.val = human.result.face[0].genderScore || 0;
+ ok.gender.status = ok.gender.val >= options.minConfidence;
+ }
+ ok.timeout.status = ok.elapsedMs.val <= options.maxTime;
+ drawValidationTests();
+ if (allOk() || !ok.timeout.status) {
+ dom.video.pause();
+ return human.result.face[0];
+ }
+ ok.elapsedMs.val = Math.trunc(human.now() - startTime);
+ return new Promise((resolve) => {
+ setTimeout(async () => {
+ await validationLoop();
+ resolve(human.result.face[0]);
+ }, 30);
+ });
+}
+async function saveRecords() {
+ var _a, _b, _c, _d;
+ if (dom.name.value.length > 0) {
+ const image = (_a = dom.canvas.getContext("2d")) == null ? void 0 : _a.getImageData(0, 0, dom.canvas.width, dom.canvas.height);
+ const rec = { id: 0, name: dom.name.value, descriptor: (_b = current.face) == null ? void 0 : _b.embedding, image };
+ await save(rec);
+ log2("saved face record:", rec.name, "descriptor length:", (_d = (_c = current.face) == null ? void 0 : _c.embedding) == null ? void 0 : _d.length);
+ log2("known face records:", await count());
+ } else {
+ log2("invalid name");
+ }
+}
+async function deleteRecord() {
+ if (current.record && current.record.id > 0) {
+ await remove(current.record);
+ }
+}
+async function detectFace() {
+ var _a, _b, _c, _d;
+ dom.canvas.style.height = "";
+ (_a = dom.canvas.getContext("2d")) == null ? void 0 : _a.clearRect(0, 0, options.minSize, options.minSize);
+ if (!((_b = current == null ? void 0 : current.face) == null ? void 0 : _b.tensor) || !((_c = current == null ? void 0 : current.face) == null ? void 0 : _c.embedding))
+ return false;
+ console.log("face record:", current.face);
+ log2(`detected face: ${current.face.gender} ${current.face.age || 0}y distance ${100 * (current.face.distance || 0)}cm/${Math.round(100 * (current.face.distance || 0) / 2.54)}in`);
+ await human.tf.browser.toPixels(current.face.tensor, dom.canvas);
+ if (await count() === 0) {
+ log2("face database is empty: nothing to compare face with");
+ document.body.style.background = "black";
+ dom.delete.style.display = "none";
+ return false;
+ }
+ const db2 = await load();
+ const descriptors = db2.map((rec) => rec.descriptor).filter((desc) => desc.length > 0);
+ const res = human.match.find(current.face.embedding, descriptors, matchOptions);
+ current.record = db2[res.index] || null;
+ if (current.record) {
+ log2(`best match: ${current.record.name} | id: ${current.record.id} | similarity: ${Math.round(1e3 * res.similarity) / 10}%`);
+ dom.name.value = current.record.name;
+ dom.source.style.display = "";
+ (_d = dom.source.getContext("2d")) == null ? void 0 : _d.putImageData(current.record.image, 0, 0);
+ }
+ document.body.style.background = res.similarity > options.threshold ? "darkgreen" : "maroon";
+ return res.similarity > options.threshold;
+}
+async function main() {
+ var _a, _b, _c, _d;
+ ok.faceCount.status = false;
+ ok.faceConfidence.status = false;
+ ok.facingCenter.status = false;
+ ok.blinkDetected.status = false;
+ ok.faceSize.status = false;
+ ok.antispoofCheck.status = false;
+ ok.livenessCheck.status = false;
+ ok.age.status = false;
+ ok.gender.status = false;
+ ok.elapsedMs.val = 0;
+ dom.match.style.display = "none";
+ dom.retry.style.display = "none";
+ dom.source.style.display = "none";
+ dom.canvas.style.height = "50%";
+ document.body.style.background = "black";
+ await webCam();
+ await detectionLoop();
+ startTime = human.now();
+ current.face = await validationLoop();
+ dom.canvas.width = ((_b = (_a = current.face) == null ? void 0 : _a.tensor) == null ? void 0 : _b.shape[1]) || options.minSize;
+ dom.canvas.height = ((_d = (_c = current.face) == null ? void 0 : _c.tensor) == null ? void 0 : _d.shape[0]) || options.minSize;
+ dom.source.width = dom.canvas.width;
+ dom.source.height = dom.canvas.height;
+ dom.canvas.style.width = "";
+ dom.match.style.display = "flex";
+ dom.save.style.display = "flex";
+ dom.delete.style.display = "flex";
+ dom.retry.style.display = "block";
+ if (!allOk()) {
+ log2("did not find valid face");
+ return false;
+ }
+ return detectFace();
+}
+async function init() {
+ var _a, _b;
+ log2("human version:", human.version, "| tfjs version:", human.tf.version["tfjs-core"]);
+ log2("options:", JSON.stringify(options).replace(/{|}|"|\[|\]/g, "").replace(/,/g, " "));
+ log2("initializing webcam...");
+ await webCam();
+ log2("loading human models...");
+ await human.load();
+ log2("initializing human...");
+ log2("face embedding model:", humanConfig.face.description.enabled ? "faceres" : "", ((_a = humanConfig.face["mobilefacenet"]) == null ? void 0 : _a.enabled) ? "mobilefacenet" : "", ((_b = humanConfig.face["insightface"]) == null ? void 0 : _b.enabled) ? "insightface" : "");
+ log2("loading face database...");
+ log2("known face records:", await count());
+ dom.retry.addEventListener("click", main);
+ dom.save.addEventListener("click", saveRecords);
+ dom.delete.addEventListener("click", deleteRecord);
+ await human.warmup();
+ await main();
+}
+window.onload = init;
//# sourceMappingURL=index.js.map
diff --git a/demo/faceid/index.js.map b/demo/faceid/index.js.map
index e15df82b..3f5d4efb 100644
--- a/demo/faceid/index.js.map
+++ b/demo/faceid/index.js.map
@@ -2,6 +2,6 @@
"version": 3,
"sources": ["index.ts", "indexdb.ts"],
"sourcesContent": ["/**\n * Human demo for browsers\n * @default Human Library\n * @summary \n * @author \n * @copyright \n * @license MIT\n */\n\nimport * as H from '../../dist/human.esm.js'; // equivalent of @vladmandic/Human\nimport * as indexDb from './indexdb'; // methods to deal with indexdb\n\nconst humanConfig = { // user configuration for human, used to fine-tune behavior\n cacheSensitivity: 0,\n modelBasePath: '../../models',\n filter: { enabled: true, equalization: true }, // lets run with histogram equilizer\n debug: true,\n face: {\n enabled: true,\n detector: { rotation: true, return: true, cropFactor: 1.6, mask: false }, // return tensor is used to get detected face image\n description: { enabled: true }, // default model for face descriptor extraction is faceres\n // mobilefacenet: { enabled: true, modelPath: 'https://vladmandic.github.io/human-models/models/mobilefacenet.json' }, // alternative model\n // insightface: { enabled: true, modelPath: 'https://vladmandic.github.io/insightface/models/insightface-mobilenet-swish.json' }, // alternative model\n iris: { enabled: true }, // needed to determine gaze direction\n emotion: { enabled: false }, // not needed\n antispoof: { enabled: true }, // enable optional antispoof module\n liveness: { enabled: true }, // enable optional liveness module\n },\n body: { enabled: false },\n hand: { enabled: false },\n object: { enabled: false },\n gesture: { enabled: true }, // parses face and iris gestures\n};\n\n// const matchOptions = { order: 2, multiplier: 1000, min: 0.0, max: 1.0 }; // for embedding model\nconst matchOptions = { order: 2, multiplier: 25, min: 0.2, max: 0.8 }; // for faceres model\n\nconst options = {\n minConfidence: 0.6, // overal face confidence for box, face, gender, real, live\n minSize: 224, // min input to face descriptor model before degradation\n maxTime: 30000, // max time before giving up\n blinkMin: 10, // minimum duration of a valid blink\n blinkMax: 800, // maximum duration of a valid blink\n threshold: 0.5, // minimum similarity\n distanceMin: 0.4, // closest that face is allowed to be to the cammera in cm\n distanceMax: 1.0, // farthest that face is allowed to be to the cammera in cm\n mask: humanConfig.face.detector.mask,\n rotation: humanConfig.face.detector.rotation,\n cropFactor: humanConfig.face.detector.cropFactor,\n ...matchOptions,\n};\n\nconst ok: Record = { // must meet all rules\n faceCount: { status: false, val: 0 },\n faceConfidence: { status: false, val: 0 },\n facingCenter: { status: false, val: 0 },\n lookingCenter: { status: false, val: 0 },\n blinkDetected: { status: false, val: 0 },\n faceSize: { status: false, val: 0 },\n antispoofCheck: { status: false, val: 0 },\n livenessCheck: { status: false, val: 0 },\n distance: { status: false, val: 0 },\n age: { status: false, val: 0 },\n gender: { status: false, val: 0 },\n timeout: { status: true, val: 0 },\n descriptor: { status: false, val: 0 },\n elapsedMs: { status: undefined, val: 0 }, // total time while waiting for valid face\n detectFPS: { status: undefined, val: 0 }, // mark detection fps performance\n drawFPS: { status: undefined, val: 0 }, // mark redraw fps performance\n};\n\nconst allOk = () => ok.faceCount.status\n && ok.faceSize.status\n && ok.blinkDetected.status\n && ok.facingCenter.status\n && ok.lookingCenter.status\n && ok.faceConfidence.status\n && ok.antispoofCheck.status\n && ok.livenessCheck.status\n && ok.distance.status\n && ok.descriptor.status\n && ok.age.status\n && ok.gender.status;\n\nconst current: { face: H.FaceResult | null, record: indexDb.FaceRecord | null } = { face: null, record: null }; // current face record and matched database record\n\nconst blink = { // internal timers for blink start/end/duration\n start: 0,\n end: 0,\n time: 0,\n};\n\n// let db: Array<{ name: string, source: string, embedding: number[] }> = []; // holds loaded face descriptor database\nconst human = new H.Human(humanConfig); // create instance of human with overrides from user configuration\n\nhuman.env.perfadd = false; // is performance data showing instant or total values\nhuman.draw.options.font = 'small-caps 18px \"Lato\"'; // set font used to draw labels when using draw methods\nhuman.draw.options.lineHeight = 20;\n\nconst dom = { // grab instances of dom objects so we dont have to look them up later\n video: document.getElementById('video') as HTMLVideoElement,\n canvas: document.getElementById('canvas') as HTMLCanvasElement,\n log: document.getElementById('log') as HTMLPreElement,\n fps: document.getElementById('fps') as HTMLPreElement,\n match: document.getElementById('match') as HTMLDivElement,\n name: document.getElementById('name') as HTMLInputElement,\n save: document.getElementById('save') as HTMLSpanElement,\n delete: document.getElementById('delete') as HTMLSpanElement,\n retry: document.getElementById('retry') as HTMLDivElement,\n source: document.getElementById('source') as HTMLCanvasElement,\n ok: document.getElementById('ok') as HTMLDivElement,\n};\nconst timestamp = { detect: 0, draw: 0 }; // holds information used to calculate performance and possible memory leaks\nlet startTime = 0;\n\nconst log = (...msg) => { // helper method to output messages\n dom.log.innerText += msg.join(' ') + '\\n';\n console.log(...msg); // eslint-disable-line no-console\n};\n\nasync function webCam() { // initialize webcam\n // @ts-ignore resizeMode is not yet defined in tslib\n const cameraOptions: MediaStreamConstraints = { audio: false, video: { facingMode: 'user', resizeMode: 'none', width: { ideal: document.body.clientWidth } } };\n const stream: MediaStream = await navigator.mediaDevices.getUserMedia(cameraOptions);\n const ready = new Promise((resolve) => { dom.video.onloadeddata = () => resolve(true); });\n dom.video.srcObject = stream;\n void dom.video.play();\n await ready;\n dom.canvas.width = dom.video.videoWidth;\n dom.canvas.height = dom.video.videoHeight;\n dom.canvas.style.width = '50%';\n dom.canvas.style.height = '50%';\n if (human.env.initial) log('video:', dom.video.videoWidth, dom.video.videoHeight, '|', stream.getVideoTracks()[0].label);\n dom.canvas.onclick = () => { // pause when clicked on screen and resume on next click\n if (dom.video.paused) void dom.video.play();\n else dom.video.pause();\n };\n}\n\nasync function detectionLoop() { // main detection loop\n if (!dom.video.paused) {\n if (current.face?.tensor) human.tf.dispose(current.face.tensor); // dispose previous tensor\n await human.detect(dom.video); // actual detection; were not capturing output in a local variable as it can also be reached via human.result\n const now = human.now();\n ok.detectFPS.val = Math.round(10000 / (now - timestamp.detect)) / 10;\n timestamp.detect = now;\n requestAnimationFrame(detectionLoop); // start new frame immediately\n }\n}\n\nfunction drawValidationTests() {\n let y = 32;\n for (const [key, val] of Object.entries(ok)) {\n let el = document.getElementById(`ok-${key}`);\n if (!el) {\n el = document.createElement('div');\n el.id = `ok-${key}`;\n el.innerText = key;\n el.className = 'ok';\n el.style.top = `${y}px`;\n dom.ok.appendChild(el);\n }\n if (typeof val.status === 'boolean') el.style.backgroundColor = val.status ? 'lightgreen' : 'lightcoral';\n const status = val.status ? 'ok' : 'fail';\n el.innerText = `${key}: ${val.val === 0 ? status : val.val}`;\n y += 28;\n }\n}\n\nasync function validationLoop(): Promise { // main screen refresh loop\n const interpolated = human.next(human.result); // smoothen result using last-known results\n human.draw.canvas(dom.video, dom.canvas); // draw canvas to screen\n await human.draw.all(dom.canvas, interpolated); // draw labels, boxes, lines, etc.\n const now = human.now();\n ok.drawFPS.val = Math.round(10000 / (now - timestamp.draw)) / 10;\n timestamp.draw = now;\n ok.faceCount.val = human.result.face.length;\n ok.faceCount.status = ok.faceCount.val === 1; // must be exactly detected face\n if (ok.faceCount.status) { // skip the rest if no face\n const gestures: string[] = Object.values(human.result.gesture).map((gesture: H.GestureResult) => gesture.gesture); // flatten all gestures\n if (gestures.includes('blink left eye') || gestures.includes('blink right eye')) blink.start = human.now(); // blink starts when eyes get closed\n if (blink.start > 0 && !gestures.includes('blink left eye') && !gestures.includes('blink right eye')) blink.end = human.now(); // if blink started how long until eyes are back open\n ok.blinkDetected.status = ok.blinkDetected.status || (Math.abs(blink.end - blink.start) > options.blinkMin && Math.abs(blink.end - blink.start) < options.blinkMax);\n if (ok.blinkDetected.status && blink.time === 0) blink.time = Math.trunc(blink.end - blink.start);\n ok.facingCenter.status = gestures.includes('facing center');\n ok.lookingCenter.status = gestures.includes('looking center'); // must face camera and look at camera\n ok.faceConfidence.val = human.result.face[0].faceScore || human.result.face[0].boxScore || 0;\n ok.faceConfidence.status = ok.faceConfidence.val >= options.minConfidence;\n ok.antispoofCheck.val = human.result.face[0].real || 0;\n ok.antispoofCheck.status = ok.antispoofCheck.val >= options.minConfidence;\n ok.livenessCheck.val = human.result.face[0].live || 0;\n ok.livenessCheck.status = ok.livenessCheck.val >= options.minConfidence;\n ok.faceSize.val = Math.min(human.result.face[0].box[2], human.result.face[0].box[3]);\n ok.faceSize.status = ok.faceSize.val >= options.minSize;\n ok.distance.val = human.result.face[0].distance || 0;\n ok.distance.status = (ok.distance.val >= options.distanceMin) && (ok.distance.val <= options.distanceMax);\n ok.descriptor.val = human.result.face[0].embedding?.length || 0;\n ok.descriptor.status = ok.descriptor.val > 0;\n ok.age.val = human.result.face[0].age || 0;\n ok.age.status = ok.age.val > 0;\n ok.gender.val = human.result.face[0].genderScore || 0;\n ok.gender.status = ok.gender.val >= options.minConfidence;\n }\n // run again\n ok.timeout.status = ok.elapsedMs.val <= options.maxTime;\n drawValidationTests();\n if (allOk() || !ok.timeout.status) { // all criteria met\n dom.video.pause();\n return human.result.face[0];\n }\n ok.elapsedMs.val = Math.trunc(human.now() - startTime);\n return new Promise((resolve) => {\n setTimeout(async () => {\n await validationLoop(); // run validation loop until conditions are met\n resolve(human.result.face[0]); // recursive promise resolve\n }, 30); // use to slow down refresh from max refresh rate to target of 30 fps\n });\n}\n\nasync function saveRecords() {\n if (dom.name.value.length > 0) {\n const image = dom.canvas.getContext('2d')?.getImageData(0, 0, dom.canvas.width, dom.canvas.height) as ImageData;\n const rec = { id: 0, name: dom.name.value, descriptor: current.face?.embedding as number[], image };\n await indexDb.save(rec);\n log('saved face record:', rec.name, 'descriptor length:', current.face?.embedding?.length);\n log('known face records:', await indexDb.count());\n } else {\n log('invalid name');\n }\n}\n\nasync function deleteRecord() {\n if (current.record && current.record.id > 0) {\n await indexDb.remove(current.record);\n }\n}\n\nasync function detectFace() {\n dom.canvas.style.height = '';\n dom.canvas.getContext('2d')?.clearRect(0, 0, options.minSize, options.minSize);\n if (!current?.face?.tensor || !current?.face?.embedding) return false;\n console.log('face record:', current.face); // eslint-disable-line no-console\n log(`detected face: ${current.face.gender} ${current.face.age || 0}y distance ${100 * (current.face.distance || 0)}cm/${Math.round(100 * (current.face.distance || 0) / 2.54)}in`);\n await human.tf.browser.toPixels(current.face.tensor, dom.canvas);\n if (await indexDb.count() === 0) {\n log('face database is empty: nothing to compare face with');\n document.body.style.background = 'black';\n dom.delete.style.display = 'none';\n return false;\n }\n const db = await indexDb.load();\n const descriptors = db.map((rec) => rec.descriptor).filter((desc) => desc.length > 0);\n const res = human.match.find(current.face.embedding, descriptors, matchOptions);\n current.record = db[res.index] || null;\n if (current.record) {\n log(`best match: ${current.record.name} | id: ${current.record.id} | similarity: ${Math.round(1000 * res.similarity) / 10}%`);\n dom.name.value = current.record.name;\n dom.source.style.display = '';\n dom.source.getContext('2d')?.putImageData(current.record.image, 0, 0);\n }\n document.body.style.background = res.similarity > options.threshold ? 'darkgreen' : 'maroon';\n return res.similarity > options.threshold;\n}\n\nasync function main() { // main entry point\n ok.faceCount.status = false;\n ok.faceConfidence.status = false;\n ok.facingCenter.status = false;\n ok.blinkDetected.status = false;\n ok.faceSize.status = false;\n ok.antispoofCheck.status = false;\n ok.livenessCheck.status = false;\n ok.age.status = false;\n ok.gender.status = false;\n ok.elapsedMs.val = 0;\n dom.match.style.display = 'none';\n dom.retry.style.display = 'none';\n dom.source.style.display = 'none';\n dom.canvas.style.height = '50%';\n document.body.style.background = 'black';\n await webCam();\n await detectionLoop(); // start detection loop\n startTime = human.now();\n current.face = await validationLoop(); // start validation loop\n dom.canvas.width = current.face?.tensor?.shape[1] || options.minSize;\n dom.canvas.height = current.face?.tensor?.shape[0] || options.minSize;\n dom.source.width = dom.canvas.width;\n dom.source.height = dom.canvas.height;\n dom.canvas.style.width = '';\n dom.match.style.display = 'flex';\n dom.save.style.display = 'flex';\n dom.delete.style.display = 'flex';\n dom.retry.style.display = 'block';\n if (!allOk()) { // is all criteria met?\n log('did not find valid face');\n return false;\n }\n return detectFace();\n}\n\nasync function init() {\n log('human version:', human.version, '| tfjs version:', human.tf.version['tfjs-core']);\n log('options:', JSON.stringify(options).replace(/{|}|\"|\\[|\\]/g, '').replace(/,/g, ' '));\n log('initializing webcam...');\n await webCam(); // start webcam\n log('loading human models...');\n await human.load(); // preload all models\n log('initializing human...');\n log('face embedding model:', humanConfig.face.description.enabled ? 'faceres' : '', humanConfig.face['mobilefacenet']?.enabled ? 'mobilefacenet' : '', humanConfig.face['insightface']?.enabled ? 'insightface' : '');\n log('loading face database...');\n log('known face records:', await indexDb.count());\n dom.retry.addEventListener('click', main);\n dom.save.addEventListener('click', saveRecords);\n dom.delete.addEventListener('click', deleteRecord);\n await human.warmup(); // warmup function to initialize backend for future faster detection\n await main();\n}\n\nwindow.onload = init;\n", "let db: IDBDatabase; // instance of indexdb\n\nconst database = 'human';\nconst table = 'person';\n\nexport interface FaceRecord { id: number, name: string, descriptor: number[], image: ImageData }\n\nconst log = (...msg) => console.log('indexdb', ...msg); // eslint-disable-line no-console\n\nexport async function open() {\n if (db) return true;\n return new Promise((resolve) => {\n const request: IDBOpenDBRequest = indexedDB.open(database, 1);\n request.onerror = (evt) => log('error:', evt);\n request.onupgradeneeded = (evt: IDBVersionChangeEvent) => { // create if doesnt exist\n log('create:', evt.target);\n db = (evt.target as IDBOpenDBRequest).result;\n db.createObjectStore(table, { keyPath: 'id', autoIncrement: true });\n };\n request.onsuccess = (evt) => { // open\n db = (evt.target as IDBOpenDBRequest).result;\n log('open:', db);\n resolve(true);\n };\n });\n}\n\nexport async function load(): Promise {\n const faceDB: FaceRecord[] = [];\n if (!db) await open(); // open or create if not already done\n return new Promise((resolve) => {\n const cursor: IDBRequest = db.transaction([table], 'readwrite').objectStore(table).openCursor(null, 'next');\n cursor.onerror = (evt) => log('load error:', evt);\n cursor.onsuccess = (evt) => {\n if ((evt.target as IDBRequest).result) {\n faceDB.push((evt.target as IDBRequest).result.value);\n (evt.target as IDBRequest).result.continue();\n } else {\n resolve(faceDB);\n }\n };\n });\n}\n\nexport async function count(): Promise {\n if (!db) await open(); // open or create if not already done\n return new Promise((resolve) => {\n const store: IDBRequest = db.transaction([table], 'readwrite').objectStore(table).count();\n store.onerror = (evt) => log('count error:', evt);\n store.onsuccess = () => resolve(store.result);\n });\n}\n\nexport async function save(faceRecord: FaceRecord) {\n if (!db) await open(); // open or create if not already done\n const newRecord = { name: faceRecord.name, descriptor: faceRecord.descriptor, image: faceRecord.image }; // omit id as its autoincrement\n db.transaction([table], 'readwrite').objectStore(table).put(newRecord);\n log('save:', newRecord);\n}\n\nexport async function remove(faceRecord: FaceRecord) {\n if (!db) await open(); // open or create if not already done\n db.transaction([table], 'readwrite').objectStore(table).delete(faceRecord.id); // delete based on id\n log('delete:', faceRecord);\n}\n"],
- "mappings": ";;;;;;AASA,UAAYA,MAAO,0BCTnB,IAAIC,EAEEC,EAAW,QACXC,EAAQ,SAIRC,EAAM,IAAIC,IAAQ,QAAQ,IAAI,UAAW,GAAGA,CAAG,EAErD,eAAsBC,GAAO,CAC3B,OAAIL,EAAW,GACR,IAAI,QAASM,GAAY,CAC9B,IAAMC,EAA4B,UAAU,KAAKN,EAAU,CAAC,EAC5DM,EAAQ,QAAWC,GAAQL,EAAI,SAAUK,CAAG,EAC5CD,EAAQ,gBAAmBC,GAA+B,CACxDL,EAAI,UAAWK,EAAI,MAAM,EACzBR,EAAMQ,EAAI,OAA4B,OACtCR,EAAG,kBAAkBE,EAAO,CAAE,QAAS,KAAM,cAAe,EAAK,CAAC,CACpE,EACAK,EAAQ,UAAaC,GAAQ,CAC3BR,EAAMQ,EAAI,OAA4B,OACtCL,EAAI,QAASH,CAAE,EACfM,EAAQ,EAAI,CACd,CACF,CAAC,CACH,CAEA,eAAsBG,GAA8B,CAClD,IAAMC,EAAuB,CAAC,EAC9B,OAAKV,GAAI,MAAMK,EAAK,EACb,IAAI,QAASC,GAAY,CAC9B,IAAMK,EAAqBX,EAAG,YAAY,CAACE,CAAK,EAAG,WAAW,EAAE,YAAYA,CAAK,EAAE,WAAW,KAAM,MAAM,EAC1GS,EAAO,QAAWH,GAAQL,EAAI,cAAeK,CAAG,EAChDG,EAAO,UAAaH,GAAQ,CACrBA,EAAI,OAAsB,QAC7BE,EAAO,KAAMF,EAAI,OAAsB,OAAO,KAAK,EAClDA,EAAI,OAAsB,OAAO,SAAS,GAE3CF,EAAQI,CAAM,CAElB,CACF,CAAC,CACH,CAEA,eAAsBE,GAAyB,CAC7C,OAAKZ,GAAI,MAAMK,EAAK,EACb,IAAI,QAASC,GAAY,CAC9B,IAAMO,EAAoBb,EAAG,YAAY,CAACE,CAAK,EAAG,WAAW,EAAE,YAAYA,CAAK,EAAE,MAAM,EACxFW,EAAM,QAAWL,GAAQL,EAAI,eAAgBK,CAAG,EAChDK,EAAM,UAAY,IAAMP,EAAQO,EAAM,MAAM,CAC9C,CAAC,CACH,CAEA,eAAsBC,EAAKC,EAAwB,CAC5Cf,GAAI,MAAMK,EAAK,EACpB,IAAMW,EAAY,CAAE,KAAMD,EAAW,KAAM,WAAYA,EAAW,WAAY,MAAOA,EAAW,KAAM,EACtGf,EAAG,YAAY,CAACE,CAAK,EAAG,WAAW,EAAE,YAAYA,CAAK,EAAE,IAAIc,CAAS,EACrEb,EAAI,QAASa,CAAS,CACxB,CAEA,eAAsBC,EAAOF,EAAwB,CAC9Cf,GAAI,MAAMK,EAAK,EACpBL,EAAG,YAAY,CAACE,CAAK,EAAG,WAAW,EAAE,YAAYA,CAAK,EAAE,OAAOa,EAAW,EAAE,EAC5EZ,EAAI,UAAWY,CAAU,CAC3B,CDpDA,IAAMG,EAAc,CAClB,iBAAkB,EAClB,cAAe,eACf,OAAQ,CAAE,QAAS,GAAM,aAAc,EAAK,EAC5C,MAAO,GACP,KAAM,CACJ,QAAS,GACT,SAAU,CAAE,SAAU,GAAM,OAAQ,GAAM,WAAY,IAAK,KAAM,EAAM,EACvE,YAAa,CAAE,QAAS,EAAK,EAG7B,KAAM,CAAE,QAAS,EAAK,EACtB,QAAS,CAAE,QAAS,EAAM,EAC1B,UAAW,CAAE,QAAS,EAAK,EAC3B,SAAU,CAAE,QAAS,EAAK,CAC5B,EACA,KAAM,CAAE,QAAS,EAAM,EACvB,KAAM,CAAE,QAAS,EAAM,EACvB,OAAQ,CAAE,QAAS,EAAM,EACzB,QAAS,CAAE,QAAS,EAAK,CAC3B,EAGMC,EAAe,CAAE,MAAO,EAAG,WAAY,GAAI,IAAK,GAAK,IAAK,EAAI,EAE9DC,EAAU,CACd,cAAe,GACf,QAAS,IACT,QAAS,IACT,SAAU,GACV,SAAU,IACV,UAAW,GACX,YAAa,GACb,YAAa,EACb,KAAMF,EAAY,KAAK,SAAS,KAChC,SAAUA,EAAY,KAAK,SAAS,SACpC,WAAYA,EAAY,KAAK,SAAS,WACtC,GAAGC,CACL,EAEME,EAAmE,CACvE,UAAW,CAAE,OAAQ,GAAO,IAAK,CAAE,EACnC,eAAgB,CAAE,OAAQ,GAAO,IAAK,CAAE,EACxC,aAAc,CAAE,OAAQ,GAAO,IAAK,CAAE,EACtC,cAAe,CAAE,OAAQ,GAAO,IAAK,CAAE,EACvC,cAAe,CAAE,OAAQ,GAAO,IAAK,CAAE,EACvC,SAAU,CAAE,OAAQ,GAAO,IAAK,CAAE,EAClC,eAAgB,CAAE,OAAQ,GAAO,IAAK,CAAE,EACxC,cAAe,CAAE,OAAQ,GAAO,IAAK,CAAE,EACvC,SAAU,CAAE,OAAQ,GAAO,IAAK,CAAE,EAClC,IAAK,CAAE,OAAQ,GAAO,IAAK,CAAE,EAC7B,OAAQ,CAAE,OAAQ,GAAO,IAAK,CAAE,EAChC,QAAS,CAAE,OAAQ,GAAM,IAAK,CAAE,EAChC,WAAY,CAAE,OAAQ,GAAO,IAAK,CAAE,EACpC,UAAW,CAAE,OAAQ,OAAW,IAAK,CAAE,EACvC,UAAW,CAAE,OAAQ,OAAW,IAAK,CAAE,EACvC,QAAS,CAAE,OAAQ,OAAW,IAAK,CAAE,CACvC,EAEMC,EAAQ,IAAMD,EAAG,UAAU,QAC5BA,EAAG,SAAS,QACZA,EAAG,cAAc,QACjBA,EAAG,aAAa,QAChBA,EAAG,cAAc,QACjBA,EAAG,eAAe,QAClBA,EAAG,eAAe,QAClBA,EAAG,cAAc,QACjBA,EAAG,SAAS,QACZA,EAAG,WAAW,QACdA,EAAG,IAAI,QACPA,EAAG,OAAO,OAETE,EAA4E,CAAE,KAAM,KAAM,OAAQ,IAAK,EAEvGC,EAAQ,CACZ,MAAO,EACP,IAAK,EACL,KAAM,CACR,EAGMC,EAAQ,IAAM,QAAMP,CAAW,EAErCO,EAAM,IAAI,QAAU,GACpBA,EAAM,KAAK,QAAQ,KAAO,yBAC1BA,EAAM,KAAK,QAAQ,WAAa,GAEhC,IAAMC,EAAM,CACV,MAAO,SAAS,eAAe,OAAO,EACtC,OAAQ,SAAS,eAAe,QAAQ,EACxC,IAAK,SAAS,eAAe,KAAK,EAClC,IAAK,SAAS,eAAe,KAAK,EAClC,MAAO,SAAS,eAAe,OAAO,EACtC,KAAM,SAAS,eAAe,MAAM,EACpC,KAAM,SAAS,eAAe,MAAM,EACpC,OAAQ,SAAS,eAAe,QAAQ,EACxC,MAAO,SAAS,eAAe,OAAO,EACtC,OAAQ,SAAS,eAAe,QAAQ,EACxC,GAAI,SAAS,eAAe,IAAI,CAClC,EACMC,EAAY,CAAE,OAAQ,EAAG,KAAM,CAAE,EACnCC,EAAY,EAEVC,EAAM,IAAIC,IAAQ,CACtBJ,EAAI,IAAI,WAAaI,EAAI,KAAK,GAAG,EAAI;AAAA,EACrC,QAAQ,IAAI,GAAGA,CAAG,CACpB,EAEA,eAAeC,GAAS,CAEtB,IAAMC,EAAwC,CAAE,MAAO,GAAO,MAAO,CAAE,WAAY,OAAQ,WAAY,OAAQ,MAAO,CAAE,MAAO,SAAS,KAAK,WAAY,CAAE,CAAE,EACvJC,EAAsB,MAAM,UAAU,aAAa,aAAaD,CAAa,EAC7EE,EAAQ,IAAI,QAASC,GAAY,CAAET,EAAI,MAAM,aAAe,IAAMS,EAAQ,EAAI,CAAG,CAAC,EACxFT,EAAI,MAAM,UAAYO,EACjBP,EAAI,MAAM,KAAK,EACpB,MAAMQ,EACNR,EAAI,OAAO,MAAQA,EAAI,MAAM,WAC7BA,EAAI,OAAO,OAASA,EAAI,MAAM,YAC9BA,EAAI,OAAO,MAAM,MAAQ,MACzBA,EAAI,OAAO,MAAM,OAAS,MACtBD,EAAM,IAAI,SAASI,EAAI,SAAUH,EAAI,MAAM,WAAYA,EAAI,MAAM,YAAa,IAAKO,EAAO,eAAe,EAAE,GAAG,KAAK,EACvHP,EAAI,OAAO,QAAU,IAAM,CACrBA,EAAI,MAAM,OAAaA,EAAI,MAAM,KAAK,EACrCA,EAAI,MAAM,MAAM,CACvB,CACF,CAEA,eAAeU,GAAgB,CA3I/B,IAAAC,EA4IE,GAAI,CAACX,EAAI,MAAM,OAAQ,EACjBW,EAAAd,EAAQ,OAAR,MAAAc,EAAc,QAAQZ,EAAM,GAAG,QAAQF,EAAQ,KAAK,MAAM,EAC9D,MAAME,EAAM,OAAOC,EAAI,KAAK,EAC5B,IAAMY,EAAMb,EAAM,IAAI,EACtBJ,EAAG,UAAU,IAAM,KAAK,MAAM,KAASiB,EAAMX,EAAU,OAAO,EAAI,GAClEA,EAAU,OAASW,EACnB,sBAAsBF,CAAa,CACrC,CACF,CAEA,SAASG,GAAsB,CAC7B,IAAIC,EAAI,GACR,OAAW,CAACC,EAAKC,CAAG,IAAK,OAAO,QAAQrB,CAAE,EAAG,CAC3C,IAAIsB,EAAK,SAAS,eAAe,MAAMF,GAAK,EACvCE,IACHA,EAAK,SAAS,cAAc,KAAK,EACjCA,EAAG,GAAK,MAAMF,IACdE,EAAG,UAAYF,EACfE,EAAG,UAAY,KACfA,EAAG,MAAM,IAAM,GAAGH,MAClBd,EAAI,GAAG,YAAYiB,CAAE,GAEnB,OAAOD,EAAI,QAAW,YAAWC,EAAG,MAAM,gBAAkBD,EAAI,OAAS,aAAe,cAC5F,IAAME,EAASF,EAAI,OAAS,KAAO,OACnCC,EAAG,UAAY,GAAGF,MAAQC,EAAI,MAAQ,EAAIE,EAASF,EAAI,MACvDF,GAAK,EACP,CACF,CAEA,eAAeK,GAAwC,CAzKvD,IAAAR,EA0KE,IAAMS,EAAerB,EAAM,KAAKA,EAAM,MAAM,EAC5CA,EAAM,KAAK,OAAOC,EAAI,MAAOA,EAAI,MAAM,EACvC,MAAMD,EAAM,KAAK,IAAIC,EAAI,OAAQoB,CAAY,EAC7C,IAAMR,EAAMb,EAAM,IAAI,EAKtB,GAJAJ,EAAG,QAAQ,IAAM,KAAK,MAAM,KAASiB,EAAMX,EAAU,KAAK,EAAI,GAC9DA,EAAU,KAAOW,EACjBjB,EAAG,UAAU,IAAMI,EAAM,OAAO,KAAK,OACrCJ,EAAG,UAAU,OAASA,EAAG,UAAU,MAAQ,EACvCA,EAAG,UAAU,OAAQ,CACvB,IAAM0B,EAAqB,OAAO,OAAOtB,EAAM,OAAO,OAAO,EAAE,IAAKuB,GAA6BA,EAAQ,OAAO,GAC5GD,EAAS,SAAS,gBAAgB,GAAKA,EAAS,SAAS,iBAAiB,KAAGvB,EAAM,MAAQC,EAAM,IAAI,GACrGD,EAAM,MAAQ,GAAK,CAACuB,EAAS,SAAS,gBAAgB,GAAK,CAACA,EAAS,SAAS,iBAAiB,IAAGvB,EAAM,IAAMC,EAAM,IAAI,GAC5HJ,EAAG,cAAc,OAASA,EAAG,cAAc,QAAW,KAAK,IAAIG,EAAM,IAAMA,EAAM,KAAK,EAAIJ,EAAQ,UAAY,KAAK,IAAII,EAAM,IAAMA,EAAM,KAAK,EAAIJ,EAAQ,SACtJC,EAAG,cAAc,QAAUG,EAAM,OAAS,IAAGA,EAAM,KAAO,KAAK,MAAMA,EAAM,IAAMA,EAAM,KAAK,GAChGH,EAAG,aAAa,OAAS0B,EAAS,SAAS,eAAe,EAC1D1B,EAAG,cAAc,OAAS0B,EAAS,SAAS,gBAAgB,EAC5D1B,EAAG,eAAe,IAAMI,EAAM,OAAO,KAAK,GAAG,WAAaA,EAAM,OAAO,KAAK,GAAG,UAAY,EAC3FJ,EAAG,eAAe,OAASA,EAAG,eAAe,KAAOD,EAAQ,cAC5DC,EAAG,eAAe,IAAMI,EAAM,OAAO,KAAK,GAAG,MAAQ,EACrDJ,EAAG,eAAe,OAASA,EAAG,eAAe,KAAOD,EAAQ,cAC5DC,EAAG,cAAc,IAAMI,EAAM,OAAO,KAAK,GAAG,MAAQ,EACpDJ,EAAG,cAAc,OAASA,EAAG,cAAc,KAAOD,EAAQ,cAC1DC,EAAG,SAAS,IAAM,KAAK,IAAII,EAAM,OAAO,KAAK,GAAG,IAAI,GAAIA,EAAM,OAAO,KAAK,GAAG,IAAI,EAAE,EACnFJ,EAAG,SAAS,OAASA,EAAG,SAAS,KAAOD,EAAQ,QAChDC,EAAG,SAAS,IAAMI,EAAM,OAAO,KAAK,GAAG,UAAY,EACnDJ,EAAG,SAAS,OAAUA,EAAG,SAAS,KAAOD,EAAQ,aAAiBC,EAAG,SAAS,KAAOD,EAAQ,YAC7FC,EAAG,WAAW,MAAMgB,EAAAZ,EAAM,OAAO,KAAK,GAAG,YAArB,YAAAY,EAAgC,SAAU,EAC9DhB,EAAG,WAAW,OAASA,EAAG,WAAW,IAAM,EAC3CA,EAAG,IAAI,IAAMI,EAAM,OAAO,KAAK,GAAG,KAAO,EACzCJ,EAAG,IAAI,OAASA,EAAG,IAAI,IAAM,EAC7BA,EAAG,OAAO,IAAMI,EAAM,OAAO,KAAK,GAAG,aAAe,EACpDJ,EAAG,OAAO,OAASA,EAAG,OAAO,KAAOD,EAAQ,aAC9C,CAIA,OAFAC,EAAG,QAAQ,OAASA,EAAG,UAAU,KAAOD,EAAQ,QAChDmB,EAAoB,EAChBjB,EAAM,GAAK,CAACD,EAAG,QAAQ,QACzBK,EAAI,MAAM,MAAM,EACTD,EAAM,OAAO,KAAK,KAE3BJ,EAAG,UAAU,IAAM,KAAK,MAAMI,EAAM,IAAI,EAAIG,CAAS,EAC9C,IAAI,QAASO,GAAY,CAC9B,WAAW,SAAY,CACrB,MAAMU,EAAe,EACrBV,EAAQV,EAAM,OAAO,KAAK,EAAE,CAC9B,EAAG,EAAE,CACP,CAAC,EACH,CAEA,eAAewB,GAAc,CA3N7B,IAAAZ,EAAAa,EAAAC,EAAAC,EA4NE,GAAI1B,EAAI,KAAK,MAAM,OAAS,EAAG,CAC7B,IAAM2B,GAAQhB,EAAAX,EAAI,OAAO,WAAW,IAAI,IAA1B,YAAAW,EAA6B,aAAa,EAAG,EAAGX,EAAI,OAAO,MAAOA,EAAI,OAAO,QACrF4B,EAAM,CAAE,GAAI,EAAG,KAAM5B,EAAI,KAAK,MAAO,YAAYwB,EAAA3B,EAAQ,OAAR,YAAA2B,EAAc,UAAuB,MAAAG,CAAM,EAClG,MAAcE,EAAKD,CAAG,EACtBzB,EAAI,qBAAsByB,EAAI,KAAM,sBAAsBF,GAAAD,EAAA5B,EAAQ,OAAR,YAAA4B,EAAc,YAAd,YAAAC,EAAyB,MAAM,EACzFvB,EAAI,sBAAuB,MAAc2B,EAAM,CAAC,CAClD,MACE3B,EAAI,cAAc,CAEtB,CAEA,eAAe4B,GAAe,CACxBlC,EAAQ,QAAUA,EAAQ,OAAO,GAAK,GACxC,MAAcmC,EAAOnC,EAAQ,MAAM,CAEvC,CAEA,eAAeoC,GAAa,CA7O5B,IAAAtB,EAAAa,EAAAC,EAAAC,EAgPE,GAFA1B,EAAI,OAAO,MAAM,OAAS,IAC1BW,EAAAX,EAAI,OAAO,WAAW,IAAI,IAA1B,MAAAW,EAA6B,UAAU,EAAG,EAAGjB,EAAQ,QAASA,EAAQ,SAClE,GAAC8B,EAAA3B,GAAA,YAAAA,EAAS,OAAT,MAAA2B,EAAe,SAAU,GAACC,EAAA5B,GAAA,YAAAA,EAAS,OAAT,MAAA4B,EAAe,WAAW,MAAO,GAIhE,GAHA,QAAQ,IAAI,eAAgB5B,EAAQ,IAAI,EACxCM,EAAI,kBAAkBN,EAAQ,KAAK,UAAUA,EAAQ,KAAK,KAAO,eAAe,KAAOA,EAAQ,KAAK,UAAY,QAAQ,KAAK,MAAM,KAAOA,EAAQ,KAAK,UAAY,GAAK,IAAI,KAAK,EACjL,MAAME,EAAM,GAAG,QAAQ,SAASF,EAAQ,KAAK,OAAQG,EAAI,MAAM,EAC3D,MAAc8B,EAAM,IAAM,EAC5B,OAAA3B,EAAI,sDAAsD,EAC1D,SAAS,KAAK,MAAM,WAAa,QACjCH,EAAI,OAAO,MAAM,QAAU,OACpB,GAET,IAAMkC,EAAK,MAAcC,EAAK,EACxBC,EAAcF,EAAG,IAAKN,GAAQA,EAAI,UAAU,EAAE,OAAQS,GAASA,EAAK,OAAS,CAAC,EAC9EC,EAAMvC,EAAM,MAAM,KAAKF,EAAQ,KAAK,UAAWuC,EAAa3C,CAAY,EAC9E,OAAAI,EAAQ,OAASqC,EAAGI,EAAI,QAAU,KAC9BzC,EAAQ,SACVM,EAAI,eAAeN,EAAQ,OAAO,cAAcA,EAAQ,OAAO,oBAAoB,KAAK,MAAM,IAAOyC,EAAI,UAAU,EAAI,KAAK,EAC5HtC,EAAI,KAAK,MAAQH,EAAQ,OAAO,KAChCG,EAAI,OAAO,MAAM,QAAU,IAC3B0B,EAAA1B,EAAI,OAAO,WAAW,IAAI,IAA1B,MAAA0B,EAA6B,aAAa7B,EAAQ,OAAO,MAAO,EAAG,IAErE,SAAS,KAAK,MAAM,WAAayC,EAAI,WAAa5C,EAAQ,UAAY,YAAc,SAC7E4C,EAAI,WAAa5C,EAAQ,SAClC,CAEA,eAAe6C,GAAO,CAxQtB,IAAA5B,EAAAa,EAAAC,EAAAC,EAqSE,OA5BA/B,EAAG,UAAU,OAAS,GACtBA,EAAG,eAAe,OAAS,GAC3BA,EAAG,aAAa,OAAS,GACzBA,EAAG,cAAc,OAAS,GAC1BA,EAAG,SAAS,OAAS,GACrBA,EAAG,eAAe,OAAS,GAC3BA,EAAG,cAAc,OAAS,GAC1BA,EAAG,IAAI,OAAS,GAChBA,EAAG,OAAO,OAAS,GACnBA,EAAG,UAAU,IAAM,EACnBK,EAAI,MAAM,MAAM,QAAU,OAC1BA,EAAI,MAAM,MAAM,QAAU,OAC1BA,EAAI,OAAO,MAAM,QAAU,OAC3BA,EAAI,OAAO,MAAM,OAAS,MAC1B,SAAS,KAAK,MAAM,WAAa,QACjC,MAAMK,EAAO,EACb,MAAMK,EAAc,EACpBR,EAAYH,EAAM,IAAI,EACtBF,EAAQ,KAAO,MAAMsB,EAAe,EACpCnB,EAAI,OAAO,QAAQwB,GAAAb,EAAAd,EAAQ,OAAR,YAAAc,EAAc,SAAd,YAAAa,EAAsB,MAAM,KAAM9B,EAAQ,QAC7DM,EAAI,OAAO,SAAS0B,GAAAD,EAAA5B,EAAQ,OAAR,YAAA4B,EAAc,SAAd,YAAAC,EAAsB,MAAM,KAAMhC,EAAQ,QAC9DM,EAAI,OAAO,MAAQA,EAAI,OAAO,MAC9BA,EAAI,OAAO,OAASA,EAAI,OAAO,OAC/BA,EAAI,OAAO,MAAM,MAAQ,GACzBA,EAAI,MAAM,MAAM,QAAU,OAC1BA,EAAI,KAAK,MAAM,QAAU,OACzBA,EAAI,OAAO,MAAM,QAAU,OAC3BA,EAAI,MAAM,MAAM,QAAU,QACrBJ,EAAM,EAIJqC,EAAW,GAHhB9B,EAAI,yBAAyB,EACtB,GAGX,CAEA,eAAeqC,GAAO,CA5StB,IAAA7B,EAAAa,EA6SErB,EAAI,iBAAkBJ,EAAM,QAAS,kBAAmBA,EAAM,GAAG,QAAQ,YAAY,EACrFI,EAAI,WAAY,KAAK,UAAUT,CAAO,EAAE,QAAQ,eAAgB,EAAE,EAAE,QAAQ,KAAM,GAAG,CAAC,EACtFS,EAAI,wBAAwB,EAC5B,MAAME,EAAO,EACbF,EAAI,yBAAyB,EAC7B,MAAMJ,EAAM,KAAK,EACjBI,EAAI,uBAAuB,EAC3BA,EAAI,wBAAyBX,EAAY,KAAK,YAAY,QAAU,UAAY,IAAImB,EAAAnB,EAAY,KAAK,gBAAjB,MAAAmB,EAAmC,QAAU,gBAAkB,IAAIa,EAAAhC,EAAY,KAAK,cAAjB,MAAAgC,EAAiC,QAAU,cAAgB,EAAE,EACpNrB,EAAI,0BAA0B,EAC9BA,EAAI,sBAAuB,MAAc2B,EAAM,CAAC,EAChD9B,EAAI,MAAM,iBAAiB,QAASuC,CAAI,EACxCvC,EAAI,KAAK,iBAAiB,QAASuB,CAAW,EAC9CvB,EAAI,OAAO,iBAAiB,QAAS+B,CAAY,EACjD,MAAMhC,EAAM,OAAO,EACnB,MAAMwC,EAAK,CACb,CAEA,OAAO,OAASC",
- "names": ["H", "db", "database", "table", "log", "msg", "open", "resolve", "request", "evt", "load", "faceDB", "cursor", "count", "store", "save", "faceRecord", "newRecord", "remove", "humanConfig", "matchOptions", "options", "ok", "allOk", "current", "blink", "human", "dom", "timestamp", "startTime", "log", "msg", "webCam", "cameraOptions", "stream", "ready", "resolve", "detectionLoop", "_a", "now", "drawValidationTests", "y", "key", "val", "el", "status", "validationLoop", "interpolated", "gestures", "gesture", "saveRecords", "_b", "_c", "_d", "image", "rec", "save", "count", "deleteRecord", "remove", "detectFace", "db", "load", "descriptors", "desc", "res", "main", "init"]
+ "mappings": ";;;;;;;;AASA,YAAY,OAAO;;;ACTnB,IAAI;AAEJ,IAAM,WAAW;AACjB,IAAM,QAAQ;AAId,IAAM,MAAM,IAAI,QAAQ,QAAQ,IAAI,WAAW,GAAG,GAAG;AAErD,eAAsB,OAAO;AAC3B,MAAI;AAAI,WAAO;AACf,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,UAA4B,UAAU,KAAK,UAAU,CAAC;AAC5D,YAAQ,UAAU,CAAC,QAAQ,IAAI,UAAU,GAAG;AAC5C,YAAQ,kBAAkB,CAAC,QAA+B;AACxD,UAAI,WAAW,IAAI,MAAM;AACzB,WAAM,IAAI,OAA4B;AACtC,SAAG,kBAAkB,OAAO,EAAE,SAAS,MAAM,eAAe,KAAK,CAAC;AAAA,IACpE;AACA,YAAQ,YAAY,CAAC,QAAQ;AAC3B,WAAM,IAAI,OAA4B;AACtC,UAAI,SAAS,EAAE;AACf,cAAQ,IAAI;AAAA,IACd;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,OAA8B;AAClD,QAAM,SAAuB,CAAC;AAC9B,MAAI,CAAC;AAAI,UAAM,KAAK;AACpB,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,SAAqB,GAAG,YAAY,CAAC,KAAK,GAAG,WAAW,EAAE,YAAY,KAAK,EAAE,WAAW,MAAM,MAAM;AAC1G,WAAO,UAAU,CAAC,QAAQ,IAAI,eAAe,GAAG;AAChD,WAAO,YAAY,CAAC,QAAQ;AAC1B,UAAK,IAAI,OAAsB,QAAQ;AACrC,eAAO,KAAM,IAAI,OAAsB,OAAO,KAAK;AACnD,QAAC,IAAI,OAAsB,OAAO,SAAS;AAAA,MAC7C,OAAO;AACL,gBAAQ,MAAM;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,QAAyB;AAC7C,MAAI,CAAC;AAAI,UAAM,KAAK;AACpB,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,QAAoB,GAAG,YAAY,CAAC,KAAK,GAAG,WAAW,EAAE,YAAY,KAAK,EAAE,MAAM;AACxF,UAAM,UAAU,CAAC,QAAQ,IAAI,gBAAgB,GAAG;AAChD,UAAM,YAAY,MAAM,QAAQ,MAAM,MAAM;AAAA,EAC9C,CAAC;AACH;AAEA,eAAsB,KAAK,YAAwB;AACjD,MAAI,CAAC;AAAI,UAAM,KAAK;AACpB,QAAM,YAAY,EAAE,MAAM,WAAW,MAAM,YAAY,WAAW,YAAY,OAAO,WAAW,MAAM;AACtG,KAAG,YAAY,CAAC,KAAK,GAAG,WAAW,EAAE,YAAY,KAAK,EAAE,IAAI,SAAS;AACrE,MAAI,SAAS,SAAS;AACxB;AAEA,eAAsB,OAAO,YAAwB;AACnD,MAAI,CAAC;AAAI,UAAM,KAAK;AACpB,KAAG,YAAY,CAAC,KAAK,GAAG,WAAW,EAAE,YAAY,KAAK,EAAE,OAAO,WAAW,EAAE;AAC5E,MAAI,WAAW,UAAU;AAC3B;;;ADpDA,IAAM,cAAc;AAAA,EAClB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,QAAQ,EAAE,SAAS,MAAM,cAAc,KAAK;AAAA,EAC5C,OAAO;AAAA,EACP,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,UAAU,EAAE,UAAU,MAAM,QAAQ,MAAM,YAAY,KAAK,MAAM,MAAM;AAAA,IACvE,aAAa,EAAE,SAAS,KAAK;AAAA,IAG7B,MAAM,EAAE,SAAS,KAAK;AAAA,IACtB,SAAS,EAAE,SAAS,MAAM;AAAA,IAC1B,WAAW,EAAE,SAAS,KAAK;AAAA,IAC3B,UAAU,EAAE,SAAS,KAAK;AAAA,EAC5B;AAAA,EACA,MAAM,EAAE,SAAS,MAAM;AAAA,EACvB,MAAM,EAAE,SAAS,MAAM;AAAA,EACvB,QAAQ,EAAE,SAAS,MAAM;AAAA,EACzB,SAAS,EAAE,SAAS,KAAK;AAC3B;AAGA,IAAM,eAAe,EAAE,OAAO,GAAG,YAAY,IAAI,KAAK,KAAK,KAAK,IAAI;AAEpE,IAAM,UAAU;AAAA,EACd,eAAe;AAAA,EACf,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AAAA,EACb,aAAa;AAAA,EACb,MAAM,YAAY,KAAK,SAAS;AAAA,EAChC,UAAU,YAAY,KAAK,SAAS;AAAA,EACpC,YAAY,YAAY,KAAK,SAAS;AAAA,EACtC,GAAG;AACL;AAEA,IAAM,KAAmE;AAAA,EACvE,WAAW,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EACnC,gBAAgB,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EACxC,cAAc,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EACtC,eAAe,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EACvC,eAAe,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EACvC,UAAU,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EAClC,gBAAgB,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EACxC,eAAe,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EACvC,UAAU,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EAClC,KAAK,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EAC7B,QAAQ,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EAChC,SAAS,EAAE,QAAQ,MAAM,KAAK,EAAE;AAAA,EAChC,YAAY,EAAE,QAAQ,OAAO,KAAK,EAAE;AAAA,EACpC,WAAW,EAAE,QAAQ,QAAW,KAAK,EAAE;AAAA,EACvC,WAAW,EAAE,QAAQ,QAAW,KAAK,EAAE;AAAA,EACvC,SAAS,EAAE,QAAQ,QAAW,KAAK,EAAE;AACvC;AAEA,IAAM,QAAQ,MAAM,GAAG,UAAU,UAC5B,GAAG,SAAS,UACZ,GAAG,cAAc,UACjB,GAAG,aAAa,UAChB,GAAG,cAAc,UACjB,GAAG,eAAe,UAClB,GAAG,eAAe,UAClB,GAAG,cAAc,UACjB,GAAG,SAAS,UACZ,GAAG,WAAW,UACd,GAAG,IAAI,UACP,GAAG,OAAO;AAEf,IAAM,UAA4E,EAAE,MAAM,MAAM,QAAQ,KAAK;AAE7G,IAAM,QAAQ;AAAA,EACZ,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AACR;AAGA,IAAM,QAAQ,IAAM,QAAM,WAAW;AAErC,MAAM,IAAI,UAAU;AACpB,MAAM,KAAK,QAAQ,OAAO;AAC1B,MAAM,KAAK,QAAQ,aAAa;AAEhC,IAAM,MAAM;AAAA,EACV,OAAO,SAAS,eAAe,OAAO;AAAA,EACtC,QAAQ,SAAS,eAAe,QAAQ;AAAA,EACxC,KAAK,SAAS,eAAe,KAAK;AAAA,EAClC,KAAK,SAAS,eAAe,KAAK;AAAA,EAClC,OAAO,SAAS,eAAe,OAAO;AAAA,EACtC,MAAM,SAAS,eAAe,MAAM;AAAA,EACpC,MAAM,SAAS,eAAe,MAAM;AAAA,EACpC,QAAQ,SAAS,eAAe,QAAQ;AAAA,EACxC,OAAO,SAAS,eAAe,OAAO;AAAA,EACtC,QAAQ,SAAS,eAAe,QAAQ;AAAA,EACxC,IAAI,SAAS,eAAe,IAAI;AAClC;AACA,IAAM,YAAY,EAAE,QAAQ,GAAG,MAAM,EAAE;AACvC,IAAI,YAAY;AAEhB,IAAMA,OAAM,IAAI,QAAQ;AACtB,MAAI,IAAI,aAAa,IAAI,KAAK,GAAG,IAAI;AACrC,UAAQ,IAAI,GAAG,GAAG;AACpB;AAEA,eAAe,SAAS;AAEtB,QAAM,gBAAwC,EAAE,OAAO,OAAO,OAAO,EAAE,YAAY,QAAQ,YAAY,QAAQ,OAAO,EAAE,OAAO,SAAS,KAAK,YAAY,EAAE,EAAE;AAC7J,QAAM,SAAsB,MAAM,UAAU,aAAa,aAAa,aAAa;AACnF,QAAM,QAAQ,IAAI,QAAQ,CAAC,YAAY;AAAE,QAAI,MAAM,eAAe,MAAM,QAAQ,IAAI;AAAA,EAAG,CAAC;AACxF,MAAI,MAAM,YAAY;AACtB,OAAK,IAAI,MAAM,KAAK;AACpB,QAAM;AACN,MAAI,OAAO,QAAQ,IAAI,MAAM;AAC7B,MAAI,OAAO,SAAS,IAAI,MAAM;AAC9B,MAAI,OAAO,MAAM,QAAQ;AACzB,MAAI,OAAO,MAAM,SAAS;AAC1B,MAAI,MAAM,IAAI;AAAS,IAAAA,KAAI,UAAU,IAAI,MAAM,YAAY,IAAI,MAAM,aAAa,KAAK,OAAO,eAAe,EAAE,GAAG,KAAK;AACvH,MAAI,OAAO,UAAU,MAAM;AACzB,QAAI,IAAI,MAAM;AAAQ,WAAK,IAAI,MAAM,KAAK;AAAA;AACrC,UAAI,MAAM,MAAM;AAAA,EACvB;AACF;AAEA,eAAe,gBAAgB;AA3I/B;AA4IE,MAAI,CAAC,IAAI,MAAM,QAAQ;AACrB,SAAI,aAAQ,SAAR,mBAAc;AAAQ,YAAM,GAAG,QAAQ,QAAQ,KAAK,MAAM;AAC9D,UAAM,MAAM,OAAO,IAAI,KAAK;AAC5B,UAAM,MAAM,MAAM,IAAI;AACtB,OAAG,UAAU,MAAM,KAAK,MAAM,OAAS,MAAM,UAAU,OAAO,IAAI;AAClE,cAAU,SAAS;AACnB,0BAAsB,aAAa;AAAA,EACrC;AACF;AAEA,SAAS,sBAAsB;AAC7B,MAAI,IAAI;AACR,aAAW,CAAC,KAAK,GAAG,KAAK,OAAO,QAAQ,EAAE,GAAG;AAC3C,QAAI,KAAK,SAAS,eAAe,MAAM,KAAK;AAC5C,QAAI,CAAC,IAAI;AACP,WAAK,SAAS,cAAc,KAAK;AACjC,SAAG,KAAK,MAAM;AACd,SAAG,YAAY;AACf,SAAG,YAAY;AACf,SAAG,MAAM,MAAM,GAAG;AAClB,UAAI,GAAG,YAAY,EAAE;AAAA,IACvB;AACA,QAAI,OAAO,IAAI,WAAW;AAAW,SAAG,MAAM,kBAAkB,IAAI,SAAS,eAAe;AAC5F,UAAM,SAAS,IAAI,SAAS,OAAO;AACnC,OAAG,YAAY,GAAG,QAAQ,IAAI,QAAQ,IAAI,SAAS,IAAI;AACvD,SAAK;AAAA,EACP;AACF;AAEA,eAAe,iBAAwC;AAzKvD;AA0KE,QAAM,eAAe,MAAM,KAAK,MAAM,MAAM;AAC5C,QAAM,KAAK,OAAO,IAAI,OAAO,IAAI,MAAM;AACvC,QAAM,MAAM,KAAK,IAAI,IAAI,QAAQ,YAAY;AAC7C,QAAM,MAAM,MAAM,IAAI;AACtB,KAAG,QAAQ,MAAM,KAAK,MAAM,OAAS,MAAM,UAAU,KAAK,IAAI;AAC9D,YAAU,OAAO;AACjB,KAAG,UAAU,MAAM,MAAM,OAAO,KAAK;AACrC,KAAG,UAAU,SAAS,GAAG,UAAU,QAAQ;AAC3C,MAAI,GAAG,UAAU,QAAQ;AACvB,UAAM,WAAqB,OAAO,OAAO,MAAM,OAAO,OAAO,EAAE,IAAI,CAAC,YAA6B,QAAQ,OAAO;AAChH,QAAI,SAAS,SAAS,gBAAgB,KAAK,SAAS,SAAS,iBAAiB;AAAG,YAAM,QAAQ,MAAM,IAAI;AACzG,QAAI,MAAM,QAAQ,KAAK,CAAC,SAAS,SAAS,gBAAgB,KAAK,CAAC,SAAS,SAAS,iBAAiB;AAAG,YAAM,MAAM,MAAM,IAAI;AAC5H,OAAG,cAAc,SAAS,GAAG,cAAc,UAAW,KAAK,IAAI,MAAM,MAAM,MAAM,KAAK,IAAI,QAAQ,YAAY,KAAK,IAAI,MAAM,MAAM,MAAM,KAAK,IAAI,QAAQ;AAC1J,QAAI,GAAG,cAAc,UAAU,MAAM,SAAS;AAAG,YAAM,OAAO,KAAK,MAAM,MAAM,MAAM,MAAM,KAAK;AAChG,OAAG,aAAa,SAAS,SAAS,SAAS,eAAe;AAC1D,OAAG,cAAc,SAAS,SAAS,SAAS,gBAAgB;AAC5D,OAAG,eAAe,MAAM,MAAM,OAAO,KAAK,GAAG,aAAa,MAAM,OAAO,KAAK,GAAG,YAAY;AAC3F,OAAG,eAAe,SAAS,GAAG,eAAe,OAAO,QAAQ;AAC5D,OAAG,eAAe,MAAM,MAAM,OAAO,KAAK,GAAG,QAAQ;AACrD,OAAG,eAAe,SAAS,GAAG,eAAe,OAAO,QAAQ;AAC5D,OAAG,cAAc,MAAM,MAAM,OAAO,KAAK,GAAG,QAAQ;AACpD,OAAG,cAAc,SAAS,GAAG,cAAc,OAAO,QAAQ;AAC1D,OAAG,SAAS,MAAM,KAAK,IAAI,MAAM,OAAO,KAAK,GAAG,IAAI,IAAI,MAAM,OAAO,KAAK,GAAG,IAAI,EAAE;AACnF,OAAG,SAAS,SAAS,GAAG,SAAS,OAAO,QAAQ;AAChD,OAAG,SAAS,MAAM,MAAM,OAAO,KAAK,GAAG,YAAY;AACnD,OAAG,SAAS,SAAU,GAAG,SAAS,OAAO,QAAQ,eAAiB,GAAG,SAAS,OAAO,QAAQ;AAC7F,OAAG,WAAW,QAAM,WAAM,OAAO,KAAK,GAAG,cAArB,mBAAgC,WAAU;AAC9D,OAAG,WAAW,SAAS,GAAG,WAAW,MAAM;AAC3C,OAAG,IAAI,MAAM,MAAM,OAAO,KAAK,GAAG,OAAO;AACzC,OAAG,IAAI,SAAS,GAAG,IAAI,MAAM;AAC7B,OAAG,OAAO,MAAM,MAAM,OAAO,KAAK,GAAG,eAAe;AACpD,OAAG,OAAO,SAAS,GAAG,OAAO,OAAO,QAAQ;AAAA,EAC9C;AAEA,KAAG,QAAQ,SAAS,GAAG,UAAU,OAAO,QAAQ;AAChD,sBAAoB;AACpB,MAAI,MAAM,KAAK,CAAC,GAAG,QAAQ,QAAQ;AACjC,QAAI,MAAM,MAAM;AAChB,WAAO,MAAM,OAAO,KAAK;AAAA,EAC3B;AACA,KAAG,UAAU,MAAM,KAAK,MAAM,MAAM,IAAI,IAAI,SAAS;AACrD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,eAAW,YAAY;AACrB,YAAM,eAAe;AACrB,cAAQ,MAAM,OAAO,KAAK,EAAE;AAAA,IAC9B,GAAG,EAAE;AAAA,EACP,CAAC;AACH;AAEA,eAAe,cAAc;AA3N7B;AA4NE,MAAI,IAAI,KAAK,MAAM,SAAS,GAAG;AAC7B,UAAM,SAAQ,SAAI,OAAO,WAAW,IAAI,MAA1B,mBAA6B,aAAa,GAAG,GAAG,IAAI,OAAO,OAAO,IAAI,OAAO;AAC3F,UAAM,MAAM,EAAE,IAAI,GAAG,MAAM,IAAI,KAAK,OAAO,aAAY,aAAQ,SAAR,mBAAc,WAAuB,MAAM;AAClG,UAAc,KAAK,GAAG;AACtB,IAAAA,KAAI,sBAAsB,IAAI,MAAM,uBAAsB,mBAAQ,SAAR,mBAAc,cAAd,mBAAyB,MAAM;AACzF,IAAAA,KAAI,uBAAuB,MAAc,MAAM,CAAC;AAAA,EAClD,OAAO;AACL,IAAAA,KAAI,cAAc;AAAA,EACpB;AACF;AAEA,eAAe,eAAe;AAC5B,MAAI,QAAQ,UAAU,QAAQ,OAAO,KAAK,GAAG;AAC3C,UAAc,OAAO,QAAQ,MAAM;AAAA,EACrC;AACF;AAEA,eAAe,aAAa;AA7O5B;AA8OE,MAAI,OAAO,MAAM,SAAS;AAC1B,YAAI,OAAO,WAAW,IAAI,MAA1B,mBAA6B,UAAU,GAAG,GAAG,QAAQ,SAAS,QAAQ;AACtE,MAAI,GAAC,wCAAS,SAAT,mBAAe,WAAU,GAAC,wCAAS,SAAT,mBAAe;AAAW,WAAO;AAChE,UAAQ,IAAI,gBAAgB,QAAQ,IAAI;AACxC,EAAAA,KAAI,kBAAkB,QAAQ,KAAK,UAAU,QAAQ,KAAK,OAAO,eAAe,OAAO,QAAQ,KAAK,YAAY,QAAQ,KAAK,MAAM,OAAO,QAAQ,KAAK,YAAY,KAAK,IAAI,KAAK;AACjL,QAAM,MAAM,GAAG,QAAQ,SAAS,QAAQ,KAAK,QAAQ,IAAI,MAAM;AAC/D,MAAI,MAAc,MAAM,MAAM,GAAG;AAC/B,IAAAA,KAAI,sDAAsD;AAC1D,aAAS,KAAK,MAAM,aAAa;AACjC,QAAI,OAAO,MAAM,UAAU;AAC3B,WAAO;AAAA,EACT;AACA,QAAMC,MAAK,MAAc,KAAK;AAC9B,QAAM,cAAcA,IAAG,IAAI,CAAC,QAAQ,IAAI,UAAU,EAAE,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC;AACpF,QAAM,MAAM,MAAM,MAAM,KAAK,QAAQ,KAAK,WAAW,aAAa,YAAY;AAC9E,UAAQ,SAASA,IAAG,IAAI,UAAU;AAClC,MAAI,QAAQ,QAAQ;AAClB,IAAAD,KAAI,eAAe,QAAQ,OAAO,cAAc,QAAQ,OAAO,oBAAoB,KAAK,MAAM,MAAO,IAAI,UAAU,IAAI,KAAK;AAC5H,QAAI,KAAK,QAAQ,QAAQ,OAAO;AAChC,QAAI,OAAO,MAAM,UAAU;AAC3B,cAAI,OAAO,WAAW,IAAI,MAA1B,mBAA6B,aAAa,QAAQ,OAAO,OAAO,GAAG;AAAA,EACrE;AACA,WAAS,KAAK,MAAM,aAAa,IAAI,aAAa,QAAQ,YAAY,cAAc;AACpF,SAAO,IAAI,aAAa,QAAQ;AAClC;AAEA,eAAe,OAAO;AAxQtB;AAyQE,KAAG,UAAU,SAAS;AACtB,KAAG,eAAe,SAAS;AAC3B,KAAG,aAAa,SAAS;AACzB,KAAG,cAAc,SAAS;AAC1B,KAAG,SAAS,SAAS;AACrB,KAAG,eAAe,SAAS;AAC3B,KAAG,cAAc,SAAS;AAC1B,KAAG,IAAI,SAAS;AAChB,KAAG,OAAO,SAAS;AACnB,KAAG,UAAU,MAAM;AACnB,MAAI,MAAM,MAAM,UAAU;AAC1B,MAAI,MAAM,MAAM,UAAU;AAC1B,MAAI,OAAO,MAAM,UAAU;AAC3B,MAAI,OAAO,MAAM,SAAS;AAC1B,WAAS,KAAK,MAAM,aAAa;AACjC,QAAM,OAAO;AACb,QAAM,cAAc;AACpB,cAAY,MAAM,IAAI;AACtB,UAAQ,OAAO,MAAM,eAAe;AACpC,MAAI,OAAO,UAAQ,mBAAQ,SAAR,mBAAc,WAAd,mBAAsB,MAAM,OAAM,QAAQ;AAC7D,MAAI,OAAO,WAAS,mBAAQ,SAAR,mBAAc,WAAd,mBAAsB,MAAM,OAAM,QAAQ;AAC9D,MAAI,OAAO,QAAQ,IAAI,OAAO;AAC9B,MAAI,OAAO,SAAS,IAAI,OAAO;AAC/B,MAAI,OAAO,MAAM,QAAQ;AACzB,MAAI,MAAM,MAAM,UAAU;AAC1B,MAAI,KAAK,MAAM,UAAU;AACzB,MAAI,OAAO,MAAM,UAAU;AAC3B,MAAI,MAAM,MAAM,UAAU;AAC1B,MAAI,CAAC,MAAM,GAAG;AACZ,IAAAA,KAAI,yBAAyB;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,WAAW;AACpB;AAEA,eAAe,OAAO;AA5StB;AA6SE,EAAAA,KAAI,kBAAkB,MAAM,SAAS,mBAAmB,MAAM,GAAG,QAAQ,YAAY;AACrF,EAAAA,KAAI,YAAY,KAAK,UAAU,OAAO,EAAE,QAAQ,gBAAgB,EAAE,EAAE,QAAQ,MAAM,GAAG,CAAC;AACtF,EAAAA,KAAI,wBAAwB;AAC5B,QAAM,OAAO;AACb,EAAAA,KAAI,yBAAyB;AAC7B,QAAM,MAAM,KAAK;AACjB,EAAAA,KAAI,uBAAuB;AAC3B,EAAAA,KAAI,yBAAyB,YAAY,KAAK,YAAY,UAAU,YAAY,MAAI,iBAAY,KAAK,qBAAjB,mBAAmC,WAAU,kBAAkB,MAAI,iBAAY,KAAK,mBAAjB,mBAAiC,WAAU,gBAAgB,EAAE;AACpN,EAAAA,KAAI,0BAA0B;AAC9B,EAAAA,KAAI,uBAAuB,MAAc,MAAM,CAAC;AAChD,MAAI,MAAM,iBAAiB,SAAS,IAAI;AACxC,MAAI,KAAK,iBAAiB,SAAS,WAAW;AAC9C,MAAI,OAAO,iBAAiB,SAAS,YAAY;AACjD,QAAM,MAAM,OAAO;AACnB,QAAM,KAAK;AACb;AAEA,OAAO,SAAS;",
+ "names": ["log", "db"]
}
diff --git a/demo/index.js b/demo/index.js
index 65fbdd66..934d159b 100644
--- a/demo/index.js
+++ b/demo/index.js
@@ -977,8 +977,7 @@ async function main() {
if (ui.modelsPreload && !ui.useWorker) {
status('loading');
await human.load(userConfig); // this is not required, just pre-loads all models
- const loaded = Object.keys(human.models).filter((a) => human.models[a]);
- log('demo loaded models:', loaded);
+ log('demo loaded models:', human.models.loaded());
} else {
await human.init();
}
diff --git a/demo/nodejs/node-canvas.js b/demo/nodejs/node-canvas.js
index ca250c0b..2a49e589 100644
--- a/demo/nodejs/node-canvas.js
+++ b/demo/nodejs/node-canvas.js
@@ -35,7 +35,7 @@ async function main() {
log.info('Human:', human.version, 'TF:', tf.version_core);
await human.load(); // pre-load models
- log.info('Loaded models:', Object.keys(human.models).filter((a) => human.models[a]));
+ log.info('Loaded models:', human.models.loaded());
log.info('Memory state:', human.tf.engine().memory());
// parse cmdline
diff --git a/demo/nodejs/node-event.js b/demo/nodejs/node-event.js
index 5d46777c..6703965c 100644
--- a/demo/nodejs/node-event.js
+++ b/demo/nodejs/node-event.js
@@ -65,8 +65,7 @@ async function main() {
});
human.events.addEventListener('load', () => {
- const loaded = Object.keys(human.models).filter((a) => human.models[a]);
- log.info('Event Loaded:', loaded, human.tf.engine().memory());
+ log.info('Event Loaded:', human.models.loaded(), human.tf.engine().memory());
});
human.events.addEventListener('image', () => {
diff --git a/demo/nodejs/node-similarity.js b/demo/nodejs/node-similarity.js
index e9dbdf3d..902caf7d 100644
--- a/demo/nodejs/node-similarity.js
+++ b/demo/nodejs/node-similarity.js
@@ -27,8 +27,7 @@ async function init() {
await human.tf.ready();
log.info('Human:', human.version, 'TF:', tf.version_core);
await human.load();
- const loaded = Object.keys(human.models).filter((a) => human.models[a]);
- log.info('Loaded:', loaded);
+ log.info('Loaded:', human.models.loaded());
log.info('Memory state:', human.tf.engine().memory());
}
diff --git a/demo/nodejs/node.js b/demo/nodejs/node.js
index 6e02405d..24df7e20 100644
--- a/demo/nodejs/node.js
+++ b/demo/nodejs/node.js
@@ -49,8 +49,7 @@ async function init() {
log.info('Human:', human.version);
// log.info('Active Configuration', human.config);
await human.load();
- const loaded = Object.keys(human.models).filter((a) => human.models[a]);
- log.info('Loaded:', loaded);
+ log.info('Loaded:', human.models.loaded());
// log.info('Memory state:', human.tf.engine().memory());
log.data(tf.backend().binding ? tf.backend().binding.TF_Version : null);
}
diff --git a/demo/nodejs/process-folder.js b/demo/nodejs/process-folder.js
index fc2500b6..a066ba34 100644
--- a/demo/nodejs/process-folder.js
+++ b/demo/nodejs/process-folder.js
@@ -80,7 +80,7 @@ async function main() {
const configErrors = await human.validate();
if (configErrors.length > 0) log.error('Configuration errors:', configErrors);
await human.load(); // pre-load models
- log.info('Loaded models:', Object.keys(human.models).filter((a) => human.models[a]));
+ log.info('Loaded models:', human.models.loaded());
const inDir = process.argv[2];
const outDir = process.argv[3];
diff --git a/demo/segmentation/index.js b/demo/segmentation/index.js
index 7b9ba172..d09f3e7a 100644
--- a/demo/segmentation/index.js
+++ b/demo/segmentation/index.js
@@ -53,7 +53,7 @@ async function main() {
await human.load(); // preload all models
log('backend:', human.tf.getBackend(), '| available:', human.env.backends);
log('models stats:', human.models.stats());
- log('models loaded:', Object.values(human.models).filter((model) => model !== null).length);
+ log('models loaded:', human.models.loaded());
await human.warmup(); // warmup function to initialize backend for future faster detection
const numTensors = human.tf.engine().state.numTensors;
diff --git a/demo/typescript/index.js b/demo/typescript/index.js
index 0d696947..ae0b945e 100644
--- a/demo/typescript/index.js
+++ b/demo/typescript/index.js
@@ -4,6 +4,100 @@
author: '
*/
-import*as m from"../../dist/human.esm.js";var f=1920,b={modelBasePath:"../../models",filter:{enabled:!0,equalization:!1,flip:!1,width:f},face:{enabled:!0,detector:{rotation:!0},mesh:{enabled:!0},attention:{enabled:!1},iris:{enabled:!0},description:{enabled:!0},emotion:{enabled:!0},antispoof:{enabled:!0},liveness:{enabled:!0}},body:{enabled:!0},hand:{enabled:!1},object:{enabled:!1},segmentation:{enabled:!1},gesture:{enabled:!0}},e=new m.Human(b);e.env.perfadd=!1;e.draw.options.font='small-caps 18px "Lato"';e.draw.options.lineHeight=20;var a={video:document.getElementById("video"),canvas:document.getElementById("canvas"),log:document.getElementById("log"),fps:document.getElementById("status"),perf:document.getElementById("performance")},n={detect:0,draw:0,tensors:0,start:0},s={detectFPS:0,drawFPS:0,frames:0,averageMs:0},o=(...t)=>{a.log.innerText+=t.join(" ")+`
-`,console.log(...t)},r=t=>a.fps.innerText=t,g=t=>a.perf.innerText="tensors:"+e.tf.memory().numTensors.toString()+" | performance: "+JSON.stringify(t).replace(/"|{|}/g,"").replace(/,/g," | ");async function u(){if(!a.video.paused){n.start===0&&(n.start=e.now()),await e.detect(a.video);let t=e.tf.memory().numTensors;t-n.tensors!==0&&o("allocated tensors:",t-n.tensors),n.tensors=t,s.detectFPS=Math.round(1e3*1e3/(e.now()-n.detect))/1e3,s.frames++,s.averageMs=Math.round(1e3*(e.now()-n.start)/s.frames)/1e3,s.frames%100===0&&!a.video.paused&&o("performance",{...s,tensors:n.tensors})}n.detect=e.now(),requestAnimationFrame(u)}async function p(){var d,i,c;if(!a.video.paused){let l=e.next(e.result),w=await e.image(a.video);e.draw.canvas(w.canvas,a.canvas);let v={bodyLabels:`person confidence [score] and ${(c=(i=(d=e.result)==null?void 0:d.body)==null?void 0:i[0])==null?void 0:c.keypoints.length} keypoints`};await e.draw.all(a.canvas,l,v),g(l.performance)}let t=e.now();s.drawFPS=Math.round(1e3*1e3/(t-n.draw))/1e3,n.draw=t,r(a.video.paused?"paused":`fps: ${s.detectFPS.toFixed(1).padStart(5," ")} detect | ${s.drawFPS.toFixed(1).padStart(5," ")} draw`),setTimeout(p,30)}async function h(){let d=(await e.webcam.enumerate())[0].deviceId;await e.webcam.start({element:a.video,crop:!0,width:f,id:d}),a.canvas.width=e.webcam.width,a.canvas.height=e.webcam.height,a.canvas.onclick=async()=>{e.webcam.paused?await e.webcam.play():e.webcam.pause()}}async function y(){o("human version:",e.version,"| tfjs version:",e.tf.version["tfjs-core"]),o("platform:",e.env.platform,"| agent:",e.env.agent),r("loading..."),await e.load(),o("backend:",e.tf.getBackend(),"| available:",e.env.backends),o("models stats:",e.models.stats()),o("models loaded:",Object.values(e.models).filter(t=>t!==null).length),o("environment",e.env),r("initializing..."),await e.warmup(),await h(),await u(),await p()}window.onload=y;
+
+// demo/typescript/index.ts
+import * as H from "../../dist/human.esm.js";
+var width = 1920;
+var humanConfig = {
+ modelBasePath: "../../models",
+ filter: { enabled: true, equalization: false, flip: false, width },
+ face: { enabled: true, detector: { rotation: true }, mesh: { enabled: true }, attention: { enabled: false }, iris: { enabled: true }, description: { enabled: true }, emotion: { enabled: true }, antispoof: { enabled: true }, liveness: { enabled: true } },
+ body: { enabled: true },
+ hand: { enabled: false },
+ object: { enabled: false },
+ segmentation: { enabled: false },
+ gesture: { enabled: true }
+};
+var human = new H.Human(humanConfig);
+human.env.perfadd = false;
+human.draw.options.font = 'small-caps 18px "Lato"';
+human.draw.options.lineHeight = 20;
+var dom = {
+ video: document.getElementById("video"),
+ canvas: document.getElementById("canvas"),
+ log: document.getElementById("log"),
+ fps: document.getElementById("status"),
+ perf: document.getElementById("performance")
+};
+var timestamp = { detect: 0, draw: 0, tensors: 0, start: 0 };
+var fps = { detectFPS: 0, drawFPS: 0, frames: 0, averageMs: 0 };
+var log = (...msg) => {
+ dom.log.innerText += msg.join(" ") + "\n";
+ console.log(...msg);
+};
+var status = (msg) => dom.fps.innerText = msg;
+var perf = (msg) => dom.perf.innerText = "tensors:" + human.tf.memory().numTensors.toString() + " | performance: " + JSON.stringify(msg).replace(/"|{|}/g, "").replace(/,/g, " | ");
+async function detectionLoop() {
+ if (!dom.video.paused) {
+ if (timestamp.start === 0)
+ timestamp.start = human.now();
+ await human.detect(dom.video);
+ const tensors = human.tf.memory().numTensors;
+ if (tensors - timestamp.tensors !== 0)
+ log("allocated tensors:", tensors - timestamp.tensors);
+ timestamp.tensors = tensors;
+ fps.detectFPS = Math.round(1e3 * 1e3 / (human.now() - timestamp.detect)) / 1e3;
+ fps.frames++;
+ fps.averageMs = Math.round(1e3 * (human.now() - timestamp.start) / fps.frames) / 1e3;
+ if (fps.frames % 100 === 0 && !dom.video.paused)
+ log("performance", { ...fps, tensors: timestamp.tensors });
+ }
+ timestamp.detect = human.now();
+ requestAnimationFrame(detectionLoop);
+}
+async function drawLoop() {
+ var _a, _b, _c;
+ if (!dom.video.paused) {
+ const interpolated = human.next(human.result);
+ const processed = await human.image(dom.video);
+ human.draw.canvas(processed.canvas, dom.canvas);
+ const opt = { bodyLabels: `person confidence [score] and ${(_c = (_b = (_a = human.result) == null ? void 0 : _a.body) == null ? void 0 : _b[0]) == null ? void 0 : _c.keypoints.length} keypoints` };
+ await human.draw.all(dom.canvas, interpolated, opt);
+ perf(interpolated.performance);
+ }
+ const now = human.now();
+ fps.drawFPS = Math.round(1e3 * 1e3 / (now - timestamp.draw)) / 1e3;
+ timestamp.draw = now;
+ status(dom.video.paused ? "paused" : `fps: ${fps.detectFPS.toFixed(1).padStart(5, " ")} detect | ${fps.drawFPS.toFixed(1).padStart(5, " ")} draw`);
+ setTimeout(drawLoop, 30);
+}
+async function webCam() {
+ const devices = await human.webcam.enumerate();
+ const id = devices[0].deviceId;
+ await human.webcam.start({ element: dom.video, crop: true, width, id });
+ dom.canvas.width = human.webcam.width;
+ dom.canvas.height = human.webcam.height;
+ dom.canvas.onclick = async () => {
+ if (human.webcam.paused)
+ await human.webcam.play();
+ else
+ human.webcam.pause();
+ };
+}
+async function main() {
+ log("human version:", human.version, "| tfjs version:", human.tf.version["tfjs-core"]);
+ log("platform:", human.env.platform, "| agent:", human.env.agent);
+ status("loading...");
+ await human.load();
+ log("backend:", human.tf.getBackend(), "| available:", human.env.backends);
+ log("models stats:", human.models.stats());
+ log("models loaded:", human.models.loaded());
+ log("environment", human.env);
+ status("initializing...");
+ await human.warmup();
+ await webCam();
+ await detectionLoop();
+ await drawLoop();
+}
+window.onload = main;
//# sourceMappingURL=index.js.map
diff --git a/demo/typescript/index.js.map b/demo/typescript/index.js.map
index e5987da1..7f7b95c1 100644
--- a/demo/typescript/index.js.map
+++ b/demo/typescript/index.js.map
@@ -1,7 +1,7 @@
{
"version": 3,
"sources": ["index.ts"],
- "sourcesContent": ["/**\n * Human demo for browsers\n * @default Human Library\n * @summary \n * @author \n * @copyright \n * @license MIT\n */\n\nimport * as H from '../../dist/human.esm.js'; // equivalent of @vladmandic/Human\n\nconst width = 1920; // used by webcam config as well as human maximum resultion // can be anything, but resolutions higher than 4k will disable internal optimizations\n\nconst humanConfig: Partial = { // user configuration for human, used to fine-tune behavior\n // backend: 'webgpu',\n modelBasePath: '../../models',\n filter: { enabled: true, equalization: false, flip: false, width },\n face: { enabled: true, detector: { rotation: true }, mesh: { enabled: true }, attention: { enabled: false }, iris: { enabled: true }, description: { enabled: true }, emotion: { enabled: true }, antispoof: { enabled: true }, liveness: { enabled: true } },\n body: { enabled: true },\n // hand: { enabled: true },\n hand: { enabled: false },\n object: { enabled: false },\n segmentation: { enabled: false },\n gesture: { enabled: true },\n};\n\nconst human = new H.Human(humanConfig); // create instance of human with overrides from user configuration\n\nhuman.env.perfadd = false; // is performance data showing instant or total values\nhuman.draw.options.font = 'small-caps 18px \"Lato\"'; // set font used to draw labels when using draw methods\nhuman.draw.options.lineHeight = 20;\n// human.draw.options.fillPolygons = true;\n\nconst dom = { // grab instances of dom objects so we dont have to look them up later\n video: document.getElementById('video') as HTMLVideoElement,\n canvas: document.getElementById('canvas') as HTMLCanvasElement,\n log: document.getElementById('log') as HTMLPreElement,\n fps: document.getElementById('status') as HTMLPreElement,\n perf: document.getElementById('performance') as HTMLDivElement,\n};\nconst timestamp = { detect: 0, draw: 0, tensors: 0, start: 0 }; // holds information used to calculate performance and possible memory leaks\nconst fps = { detectFPS: 0, drawFPS: 0, frames: 0, averageMs: 0 }; // holds calculated fps information for both detect and screen refresh\n\nconst log = (...msg) => { // helper method to output messages\n dom.log.innerText += msg.join(' ') + '\\n';\n console.log(...msg); // eslint-disable-line no-console\n};\nconst status = (msg) => dom.fps.innerText = msg; // print status element\nconst perf = (msg) => dom.perf.innerText = 'tensors:' + human.tf.memory().numTensors.toString() + ' | performance: ' + JSON.stringify(msg).replace(/\"|{|}/g, '').replace(/,/g, ' | '); // print performance element\n\nasync function detectionLoop() { // main detection loop\n if (!dom.video.paused) {\n if (timestamp.start === 0) timestamp.start = human.now();\n // log('profiling data:', await human.profile(dom.video));\n await human.detect(dom.video); // actual detection; were not capturing output in a local variable as it can also be reached via human.result\n const tensors = human.tf.memory().numTensors; // check current tensor usage for memory leaks\n if (tensors - timestamp.tensors !== 0) log('allocated tensors:', tensors - timestamp.tensors); // printed on start and each time there is a tensor leak\n timestamp.tensors = tensors;\n fps.detectFPS = Math.round(1000 * 1000 / (human.now() - timestamp.detect)) / 1000;\n fps.frames++;\n fps.averageMs = Math.round(1000 * (human.now() - timestamp.start) / fps.frames) / 1000;\n if (fps.frames % 100 === 0 && !dom.video.paused) log('performance', { ...fps, tensors: timestamp.tensors });\n }\n timestamp.detect = human.now();\n requestAnimationFrame(detectionLoop); // start new frame immediately\n}\n\nasync function drawLoop() { // main screen refresh loop\n if (!dom.video.paused) {\n const interpolated = human.next(human.result); // smoothen result using last-known results\n const processed = await human.image(dom.video); // get current video frame, but enhanced with human.filters\n human.draw.canvas(processed.canvas as HTMLCanvasElement, dom.canvas);\n\n const opt: Partial = { bodyLabels: `person confidence [score] and ${human.result?.body?.[0]?.keypoints.length} keypoints` };\n await human.draw.all(dom.canvas, interpolated, opt); // draw labels, boxes, lines, etc.\n perf(interpolated.performance); // write performance data\n }\n const now = human.now();\n fps.drawFPS = Math.round(1000 * 1000 / (now - timestamp.draw)) / 1000;\n timestamp.draw = now;\n status(dom.video.paused ? 'paused' : `fps: ${fps.detectFPS.toFixed(1).padStart(5, ' ')} detect | ${fps.drawFPS.toFixed(1).padStart(5, ' ')} draw`); // write status\n setTimeout(drawLoop, 30); // use to slow down refresh from max refresh rate to target of 30 fps\n}\n\nasync function webCam() {\n const devices = await human.webcam.enumerate();\n const id = devices[0].deviceId; // use first available video source\n await human.webcam.start({ element: dom.video, crop: true, width, id }); // use human webcam helper methods and associate webcam stream with a dom element\n dom.canvas.width = human.webcam.width;\n dom.canvas.height = human.webcam.height;\n dom.canvas.onclick = async () => { // pause when clicked on screen and resume on next click\n if (human.webcam.paused) await human.webcam.play();\n else human.webcam.pause();\n };\n}\n\nasync function main() { // main entry point\n log('human version:', human.version, '| tfjs version:', human.tf.version['tfjs-core']);\n log('platform:', human.env.platform, '| agent:', human.env.agent);\n status('loading...');\n await human.load(); // preload all models\n log('backend:', human.tf.getBackend(), '| available:', human.env.backends);\n log('models stats:', human.models.stats());\n log('models loaded:', Object.values(human.models).filter((model) => model !== null).length);\n log('environment', human.env);\n status('initializing...');\n await human.warmup(); // warmup function to initialize backend for future faster detection\n await webCam(); // start webcam\n await detectionLoop(); // start detection loop\n await drawLoop(); // start draw loop\n}\n\nwindow.onload = main;\n"],
- "mappings": ";;;;;;AASA,UAAYA,MAAO,0BAEnB,IAAMC,EAAQ,KAERC,EAAiC,CAErC,cAAe,eACf,OAAQ,CAAE,QAAS,GAAM,aAAc,GAAO,KAAM,GAAO,MAAAD,CAAM,EACjE,KAAM,CAAE,QAAS,GAAM,SAAU,CAAE,SAAU,EAAK,EAAG,KAAM,CAAE,QAAS,EAAK,EAAG,UAAW,CAAE,QAAS,EAAM,EAAG,KAAM,CAAE,QAAS,EAAK,EAAG,YAAa,CAAE,QAAS,EAAK,EAAG,QAAS,CAAE,QAAS,EAAK,EAAG,UAAW,CAAE,QAAS,EAAK,EAAG,SAAU,CAAE,QAAS,EAAK,CAAE,EAC5P,KAAM,CAAE,QAAS,EAAK,EAEtB,KAAM,CAAE,QAAS,EAAM,EACvB,OAAQ,CAAE,QAAS,EAAM,EACzB,aAAc,CAAE,QAAS,EAAM,EAC/B,QAAS,CAAE,QAAS,EAAK,CAC3B,EAEME,EAAQ,IAAM,QAAMD,CAAW,EAErCC,EAAM,IAAI,QAAU,GACpBA,EAAM,KAAK,QAAQ,KAAO,yBAC1BA,EAAM,KAAK,QAAQ,WAAa,GAGhC,IAAMC,EAAM,CACV,MAAO,SAAS,eAAe,OAAO,EACtC,OAAQ,SAAS,eAAe,QAAQ,EACxC,IAAK,SAAS,eAAe,KAAK,EAClC,IAAK,SAAS,eAAe,QAAQ,EACrC,KAAM,SAAS,eAAe,aAAa,CAC7C,EACMC,EAAY,CAAE,OAAQ,EAAG,KAAM,EAAG,QAAS,EAAG,MAAO,CAAE,EACvDC,EAAM,CAAE,UAAW,EAAG,QAAS,EAAG,OAAQ,EAAG,UAAW,CAAE,EAE1DC,EAAM,IAAIC,IAAQ,CACtBJ,EAAI,IAAI,WAAaI,EAAI,KAAK,GAAG,EAAI;AAAA,EACrC,QAAQ,IAAI,GAAGA,CAAG,CACpB,EACMC,EAAUD,GAAQJ,EAAI,IAAI,UAAYI,EACtCE,EAAQF,GAAQJ,EAAI,KAAK,UAAY,WAAaD,EAAM,GAAG,OAAO,EAAE,WAAW,SAAS,EAAI,mBAAqB,KAAK,UAAUK,CAAG,EAAE,QAAQ,SAAU,EAAE,EAAE,QAAQ,KAAM,KAAK,EAEpL,eAAeG,GAAgB,CAC7B,GAAI,CAACP,EAAI,MAAM,OAAQ,CACjBC,EAAU,QAAU,IAAGA,EAAU,MAAQF,EAAM,IAAI,GAEvD,MAAMA,EAAM,OAAOC,EAAI,KAAK,EAC5B,IAAMQ,EAAUT,EAAM,GAAG,OAAO,EAAE,WAC9BS,EAAUP,EAAU,UAAY,GAAGE,EAAI,qBAAsBK,EAAUP,EAAU,OAAO,EAC5FA,EAAU,QAAUO,EACpBN,EAAI,UAAY,KAAK,MAAM,IAAO,KAAQH,EAAM,IAAI,EAAIE,EAAU,OAAO,EAAI,IAC7EC,EAAI,SACJA,EAAI,UAAY,KAAK,MAAM,KAAQH,EAAM,IAAI,EAAIE,EAAU,OAASC,EAAI,MAAM,EAAI,IAC9EA,EAAI,OAAS,MAAQ,GAAK,CAACF,EAAI,MAAM,QAAQG,EAAI,cAAe,CAAE,GAAGD,EAAK,QAASD,EAAU,OAAQ,CAAC,CAC5G,CACAA,EAAU,OAASF,EAAM,IAAI,EAC7B,sBAAsBQ,CAAa,CACrC,CAEA,eAAeE,GAAW,CAnE1B,IAAAC,EAAAC,EAAAC,EAoEE,GAAI,CAACZ,EAAI,MAAM,OAAQ,CACrB,IAAMa,EAAed,EAAM,KAAKA,EAAM,MAAM,EACtCe,EAAY,MAAMf,EAAM,MAAMC,EAAI,KAAK,EAC7CD,EAAM,KAAK,OAAOe,EAAU,OAA6Bd,EAAI,MAAM,EAEnE,IAAMe,EAA8B,CAAE,WAAY,kCAAiCH,GAAAD,GAAAD,EAAAX,EAAM,SAAN,YAAAW,EAAc,OAAd,YAAAC,EAAqB,KAArB,YAAAC,EAAyB,UAAU,kBAAmB,EACzI,MAAMb,EAAM,KAAK,IAAIC,EAAI,OAAQa,EAAcE,CAAG,EAClDT,EAAKO,EAAa,WAAW,CAC/B,CACA,IAAMG,EAAMjB,EAAM,IAAI,EACtBG,EAAI,QAAU,KAAK,MAAM,IAAO,KAAQc,EAAMf,EAAU,KAAK,EAAI,IACjEA,EAAU,KAAOe,EACjBX,EAAOL,EAAI,MAAM,OAAS,SAAW,QAAQE,EAAI,UAAU,QAAQ,CAAC,EAAE,SAAS,EAAG,GAAG,cAAcA,EAAI,QAAQ,QAAQ,CAAC,EAAE,SAAS,EAAG,GAAG,QAAQ,EACjJ,WAAWO,EAAU,EAAE,CACzB,CAEA,eAAeQ,GAAS,CAEtB,IAAMC,GADU,MAAMnB,EAAM,OAAO,UAAU,GAC1B,GAAG,SACtB,MAAMA,EAAM,OAAO,MAAM,CAAE,QAASC,EAAI,MAAO,KAAM,GAAM,MAAAH,EAAO,GAAAqB,CAAG,CAAC,EACtElB,EAAI,OAAO,MAAQD,EAAM,OAAO,MAChCC,EAAI,OAAO,OAASD,EAAM,OAAO,OACjCC,EAAI,OAAO,QAAU,SAAY,CAC3BD,EAAM,OAAO,OAAQ,MAAMA,EAAM,OAAO,KAAK,EAC5CA,EAAM,OAAO,MAAM,CAC1B,CACF,CAEA,eAAeoB,GAAO,CACpBhB,EAAI,iBAAkBJ,EAAM,QAAS,kBAAmBA,EAAM,GAAG,QAAQ,YAAY,EACrFI,EAAI,YAAaJ,EAAM,IAAI,SAAU,WAAYA,EAAM,IAAI,KAAK,EAChEM,EAAO,YAAY,EACnB,MAAMN,EAAM,KAAK,EACjBI,EAAI,WAAYJ,EAAM,GAAG,WAAW,EAAG,eAAgBA,EAAM,IAAI,QAAQ,EACzEI,EAAI,gBAAiBJ,EAAM,OAAO,MAAM,CAAC,EACzCI,EAAI,iBAAkB,OAAO,OAAOJ,EAAM,MAAM,EAAE,OAAQqB,GAAUA,IAAU,IAAI,EAAE,MAAM,EAC1FjB,EAAI,cAAeJ,EAAM,GAAG,EAC5BM,EAAO,iBAAiB,EACxB,MAAMN,EAAM,OAAO,EACnB,MAAMkB,EAAO,EACb,MAAMV,EAAc,EACpB,MAAME,EAAS,CACjB,CAEA,OAAO,OAASU",
- "names": ["H", "width", "humanConfig", "human", "dom", "timestamp", "fps", "log", "msg", "status", "perf", "detectionLoop", "tensors", "drawLoop", "_a", "_b", "_c", "interpolated", "processed", "opt", "now", "webCam", "id", "main", "model"]
+ "sourcesContent": ["/**\n * Human demo for browsers\n * @default Human Library\n * @summary \n * @author \n * @copyright \n * @license MIT\n */\n\nimport * as H from '../../dist/human.esm.js'; // equivalent of @vladmandic/Human\n\nconst width = 1920; // used by webcam config as well as human maximum resultion // can be anything, but resolutions higher than 4k will disable internal optimizations\n\nconst humanConfig: Partial = { // user configuration for human, used to fine-tune behavior\n // backend: 'webgpu',\n modelBasePath: '../../models',\n filter: { enabled: true, equalization: false, flip: false, width },\n face: { enabled: true, detector: { rotation: true }, mesh: { enabled: true }, attention: { enabled: false }, iris: { enabled: true }, description: { enabled: true }, emotion: { enabled: true }, antispoof: { enabled: true }, liveness: { enabled: true } },\n body: { enabled: true },\n // hand: { enabled: true },\n hand: { enabled: false },\n object: { enabled: false },\n segmentation: { enabled: false },\n gesture: { enabled: true },\n};\n\nconst human = new H.Human(humanConfig); // create instance of human with overrides from user configuration\n\nhuman.env.perfadd = false; // is performance data showing instant or total values\nhuman.draw.options.font = 'small-caps 18px \"Lato\"'; // set font used to draw labels when using draw methods\nhuman.draw.options.lineHeight = 20;\n// human.draw.options.fillPolygons = true;\n\nconst dom = { // grab instances of dom objects so we dont have to look them up later\n video: document.getElementById('video') as HTMLVideoElement,\n canvas: document.getElementById('canvas') as HTMLCanvasElement,\n log: document.getElementById('log') as HTMLPreElement,\n fps: document.getElementById('status') as HTMLPreElement,\n perf: document.getElementById('performance') as HTMLDivElement,\n};\nconst timestamp = { detect: 0, draw: 0, tensors: 0, start: 0 }; // holds information used to calculate performance and possible memory leaks\nconst fps = { detectFPS: 0, drawFPS: 0, frames: 0, averageMs: 0 }; // holds calculated fps information for both detect and screen refresh\n\nconst log = (...msg) => { // helper method to output messages\n dom.log.innerText += msg.join(' ') + '\\n';\n console.log(...msg); // eslint-disable-line no-console\n};\nconst status = (msg) => dom.fps.innerText = msg; // print status element\nconst perf = (msg) => dom.perf.innerText = 'tensors:' + human.tf.memory().numTensors.toString() + ' | performance: ' + JSON.stringify(msg).replace(/\"|{|}/g, '').replace(/,/g, ' | '); // print performance element\n\nasync function detectionLoop() { // main detection loop\n if (!dom.video.paused) {\n if (timestamp.start === 0) timestamp.start = human.now();\n // log('profiling data:', await human.profile(dom.video));\n await human.detect(dom.video); // actual detection; were not capturing output in a local variable as it can also be reached via human.result\n const tensors = human.tf.memory().numTensors; // check current tensor usage for memory leaks\n if (tensors - timestamp.tensors !== 0) log('allocated tensors:', tensors - timestamp.tensors); // printed on start and each time there is a tensor leak\n timestamp.tensors = tensors;\n fps.detectFPS = Math.round(1000 * 1000 / (human.now() - timestamp.detect)) / 1000;\n fps.frames++;\n fps.averageMs = Math.round(1000 * (human.now() - timestamp.start) / fps.frames) / 1000;\n if (fps.frames % 100 === 0 && !dom.video.paused) log('performance', { ...fps, tensors: timestamp.tensors });\n }\n timestamp.detect = human.now();\n requestAnimationFrame(detectionLoop); // start new frame immediately\n}\n\nasync function drawLoop() { // main screen refresh loop\n if (!dom.video.paused) {\n const interpolated = human.next(human.result); // smoothen result using last-known results\n const processed = await human.image(dom.video); // get current video frame, but enhanced with human.filters\n human.draw.canvas(processed.canvas as HTMLCanvasElement, dom.canvas);\n\n const opt: Partial = { bodyLabels: `person confidence [score] and ${human.result?.body?.[0]?.keypoints.length} keypoints` };\n await human.draw.all(dom.canvas, interpolated, opt); // draw labels, boxes, lines, etc.\n perf(interpolated.performance); // write performance data\n }\n const now = human.now();\n fps.drawFPS = Math.round(1000 * 1000 / (now - timestamp.draw)) / 1000;\n timestamp.draw = now;\n status(dom.video.paused ? 'paused' : `fps: ${fps.detectFPS.toFixed(1).padStart(5, ' ')} detect | ${fps.drawFPS.toFixed(1).padStart(5, ' ')} draw`); // write status\n setTimeout(drawLoop, 30); // use to slow down refresh from max refresh rate to target of 30 fps\n}\n\nasync function webCam() {\n const devices = await human.webcam.enumerate();\n const id = devices[0].deviceId; // use first available video source\n await human.webcam.start({ element: dom.video, crop: true, width, id }); // use human webcam helper methods and associate webcam stream with a dom element\n dom.canvas.width = human.webcam.width;\n dom.canvas.height = human.webcam.height;\n dom.canvas.onclick = async () => { // pause when clicked on screen and resume on next click\n if (human.webcam.paused) await human.webcam.play();\n else human.webcam.pause();\n };\n}\n\nasync function main() { // main entry point\n log('human version:', human.version, '| tfjs version:', human.tf.version['tfjs-core']);\n log('platform:', human.env.platform, '| agent:', human.env.agent);\n status('loading...');\n await human.load(); // preload all models\n log('backend:', human.tf.getBackend(), '| available:', human.env.backends);\n log('models stats:', human.models.stats());\n log('models loaded:', human.models.loaded());\n log('environment', human.env);\n status('initializing...');\n await human.warmup(); // warmup function to initialize backend for future faster detection\n await webCam(); // start webcam\n await detectionLoop(); // start detection loop\n await drawLoop(); // start draw loop\n}\n\nwindow.onload = main;\n"],
+ "mappings": ";;;;;;;;AASA,YAAY,OAAO;AAEnB,IAAM,QAAQ;AAEd,IAAM,cAAiC;AAAA,EAErC,eAAe;AAAA,EACf,QAAQ,EAAE,SAAS,MAAM,cAAc,OAAO,MAAM,OAAO,MAAM;AAAA,EACjE,MAAM,EAAE,SAAS,MAAM,UAAU,EAAE,UAAU,KAAK,GAAG,MAAM,EAAE,SAAS,KAAK,GAAG,WAAW,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,KAAK,GAAG,aAAa,EAAE,SAAS,KAAK,GAAG,SAAS,EAAE,SAAS,KAAK,GAAG,WAAW,EAAE,SAAS,KAAK,GAAG,UAAU,EAAE,SAAS,KAAK,EAAE;AAAA,EAC5P,MAAM,EAAE,SAAS,KAAK;AAAA,EAEtB,MAAM,EAAE,SAAS,MAAM;AAAA,EACvB,QAAQ,EAAE,SAAS,MAAM;AAAA,EACzB,cAAc,EAAE,SAAS,MAAM;AAAA,EAC/B,SAAS,EAAE,SAAS,KAAK;AAC3B;AAEA,IAAM,QAAQ,IAAM,QAAM,WAAW;AAErC,MAAM,IAAI,UAAU;AACpB,MAAM,KAAK,QAAQ,OAAO;AAC1B,MAAM,KAAK,QAAQ,aAAa;AAGhC,IAAM,MAAM;AAAA,EACV,OAAO,SAAS,eAAe,OAAO;AAAA,EACtC,QAAQ,SAAS,eAAe,QAAQ;AAAA,EACxC,KAAK,SAAS,eAAe,KAAK;AAAA,EAClC,KAAK,SAAS,eAAe,QAAQ;AAAA,EACrC,MAAM,SAAS,eAAe,aAAa;AAC7C;AACA,IAAM,YAAY,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,EAAE;AAC7D,IAAM,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,EAAE;AAEhE,IAAM,MAAM,IAAI,QAAQ;AACtB,MAAI,IAAI,aAAa,IAAI,KAAK,GAAG,IAAI;AACrC,UAAQ,IAAI,GAAG,GAAG;AACpB;AACA,IAAM,SAAS,CAAC,QAAQ,IAAI,IAAI,YAAY;AAC5C,IAAM,OAAO,CAAC,QAAQ,IAAI,KAAK,YAAY,aAAa,MAAM,GAAG,OAAO,EAAE,WAAW,SAAS,IAAI,qBAAqB,KAAK,UAAU,GAAG,EAAE,QAAQ,UAAU,EAAE,EAAE,QAAQ,MAAM,KAAK;AAEpL,eAAe,gBAAgB;AAC7B,MAAI,CAAC,IAAI,MAAM,QAAQ;AACrB,QAAI,UAAU,UAAU;AAAG,gBAAU,QAAQ,MAAM,IAAI;AAEvD,UAAM,MAAM,OAAO,IAAI,KAAK;AAC5B,UAAM,UAAU,MAAM,GAAG,OAAO,EAAE;AAClC,QAAI,UAAU,UAAU,YAAY;AAAG,UAAI,sBAAsB,UAAU,UAAU,OAAO;AAC5F,cAAU,UAAU;AACpB,QAAI,YAAY,KAAK,MAAM,MAAO,OAAQ,MAAM,IAAI,IAAI,UAAU,OAAO,IAAI;AAC7E,QAAI;AACJ,QAAI,YAAY,KAAK,MAAM,OAAQ,MAAM,IAAI,IAAI,UAAU,SAAS,IAAI,MAAM,IAAI;AAClF,QAAI,IAAI,SAAS,QAAQ,KAAK,CAAC,IAAI,MAAM;AAAQ,UAAI,eAAe,EAAE,GAAG,KAAK,SAAS,UAAU,QAAQ,CAAC;AAAA,EAC5G;AACA,YAAU,SAAS,MAAM,IAAI;AAC7B,wBAAsB,aAAa;AACrC;AAEA,eAAe,WAAW;AAnE1B;AAoEE,MAAI,CAAC,IAAI,MAAM,QAAQ;AACrB,UAAM,eAAe,MAAM,KAAK,MAAM,MAAM;AAC5C,UAAM,YAAY,MAAM,MAAM,MAAM,IAAI,KAAK;AAC7C,UAAM,KAAK,OAAO,UAAU,QAA6B,IAAI,MAAM;AAEnE,UAAM,MAA8B,EAAE,YAAY,kCAAiC,uBAAM,WAAN,mBAAc,SAAd,mBAAqB,OAArB,mBAAyB,UAAU,mBAAmB;AACzI,UAAM,MAAM,KAAK,IAAI,IAAI,QAAQ,cAAc,GAAG;AAClD,SAAK,aAAa,WAAW;AAAA,EAC/B;AACA,QAAM,MAAM,MAAM,IAAI;AACtB,MAAI,UAAU,KAAK,MAAM,MAAO,OAAQ,MAAM,UAAU,KAAK,IAAI;AACjE,YAAU,OAAO;AACjB,SAAO,IAAI,MAAM,SAAS,WAAW,QAAQ,IAAI,UAAU,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG,cAAc,IAAI,QAAQ,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG,QAAQ;AACjJ,aAAW,UAAU,EAAE;AACzB;AAEA,eAAe,SAAS;AACtB,QAAM,UAAU,MAAM,MAAM,OAAO,UAAU;AAC7C,QAAM,KAAK,QAAQ,GAAG;AACtB,QAAM,MAAM,OAAO,MAAM,EAAE,SAAS,IAAI,OAAO,MAAM,MAAM,OAAO,GAAG,CAAC;AACtE,MAAI,OAAO,QAAQ,MAAM,OAAO;AAChC,MAAI,OAAO,SAAS,MAAM,OAAO;AACjC,MAAI,OAAO,UAAU,YAAY;AAC/B,QAAI,MAAM,OAAO;AAAQ,YAAM,MAAM,OAAO,KAAK;AAAA;AAC5C,YAAM,OAAO,MAAM;AAAA,EAC1B;AACF;AAEA,eAAe,OAAO;AACpB,MAAI,kBAAkB,MAAM,SAAS,mBAAmB,MAAM,GAAG,QAAQ,YAAY;AACrF,MAAI,aAAa,MAAM,IAAI,UAAU,YAAY,MAAM,IAAI,KAAK;AAChE,SAAO,YAAY;AACnB,QAAM,MAAM,KAAK;AACjB,MAAI,YAAY,MAAM,GAAG,WAAW,GAAG,gBAAgB,MAAM,IAAI,QAAQ;AACzE,MAAI,iBAAiB,MAAM,OAAO,MAAM,CAAC;AACzC,MAAI,kBAAkB,MAAM,OAAO,OAAO,CAAC;AAC3C,MAAI,eAAe,MAAM,GAAG;AAC5B,SAAO,iBAAiB;AACxB,QAAM,MAAM,OAAO;AACnB,QAAM,OAAO;AACb,QAAM,cAAc;AACpB,QAAM,SAAS;AACjB;AAEA,OAAO,SAAS;",
+ "names": []
}
diff --git a/demo/typescript/index.ts b/demo/typescript/index.ts
index ed53b09b..b56bbb58 100644
--- a/demo/typescript/index.ts
+++ b/demo/typescript/index.ts
@@ -101,7 +101,7 @@ async function main() { // main entry point
await human.load(); // preload all models
log('backend:', human.tf.getBackend(), '| available:', human.env.backends);
log('models stats:', human.models.stats());
- log('models loaded:', Object.values(human.models).filter((model) => model !== null).length);
+ log('models loaded:', human.models.loaded());
log('environment', human.env);
status('initializing...');
await human.warmup(); // warmup function to initialize backend for future faster detection
diff --git a/dist/human.esm-nobundle.js b/dist/human.esm-nobundle.js
index 46f72414..0df1e74d 100644
--- a/dist/human.esm-nobundle.js
+++ b/dist/human.esm-nobundle.js
@@ -4,7 +4,271 @@
author: '
*/
-var nt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Gn=Object.getOwnPropertyNames;var Vn=Object.prototype.hasOwnProperty;var Zn=(e,t,n)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var te=(e,t)=>{for(var n in t)nt(e,n,{get:t[n],enumerable:!0})},C5=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Gn(t))!Vn.call(e,s)&&s!==n&&nt(e,s,{get:()=>t[s],enumerable:!(o=Hn(t,s))||o.enumerable});return e},w=(e,t,n)=>(C5(e,t,"default"),n&&C5(n,t,"default"));var E=(e,t,n)=>(Zn(e,typeof t!="symbol"?t+"":t,n),n),W5=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var V0=(e,t,n)=>(W5(e,t,"read from private field"),n?n.call(e):t.get(e)),Ne=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Ye=(e,t,n,o)=>(W5(e,t,"write to private field"),o?o.call(e,n):t.set(e,n),n);var r={};te(r,{version:()=>Ke});w(r,fA);w(r,mA);w(r,pA);w(r,uA);w(r,hA);w(r,bA);import*as fA from"@tensorflow/tfjs-core/dist/index.js";import*as mA from"@tensorflow/tfjs-converter/dist/index.js";import*as pA from"@tensorflow/tfjs-backend-cpu/dist/index.js";import*as uA from"@tensorflow/tfjs-backend-webgl/dist/index.js";import*as hA from"@tensorflow/tfjs-backend-wasm/dist/index.js";import*as bA from"@tensorflow/tfjs-backend-webgpu/dist/index.js";var D5="4.0.0",Xn="4.0.0",qn="4.0.0",Un="4.0.0",Yn="4.0.0",Kn="0.0.1-alpha.14",Ke={tfjs:D5,"tfjs-core":D5,"tfjs-converter":Xn,"tfjs-backend-cpu":qn,"tfjs-backend-webgl":Un,"tfjs-backend-wasm":Yn,"tfjs-backend-webgpu":Kn};function h(...e){let t=new Date,n=`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`;e&&console.log(n,"Human:",...e)}function F5(e,t){let n=e.endsWith("/")?"":"/",s=t.startsWith(".")||t.startsWith("/")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("file:")?`${t}`:`${e}${n}${t}`;if(!s.toLocaleLowerCase().includes(".json"))throw new Error(`modelpath error: expecting json file: ${s}`);return s}var T=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function ot(e,t,n="config",o=[]){for(let s of Object.keys(t))if(typeof t[s]=="object")ot(e[s],t[s],s,o);else{let A=e&&typeof e[s]!="undefined";A||o.push({reason:"unknown property",where:`${n}.${s} = ${t[s]}`});let a=e&&typeof e[s]==typeof t[s];A&&!a&&o.push({reason:"property type mismatch",where:`${n}.${s} = ${t[s]}`,expected:typeof e[s]})}return t.debug&&n==="config"&&o.length>0&&h("invalid configuration",o),o}function J(...e){let t=n=>n&&typeof n=="object";return e.reduce((n,o)=>(Object.keys(o||{}).forEach(s=>{let A=n[s],a=o[s];Array.isArray(A)&&Array.isArray(a)?n[s]=A.concat(...a):t(A)&&t(a)?n[s]=J(A,a):n[s]=a}),n),{})}var Ie={backend:"",modelBasePath:"",cacheModels:!0,validateModels:!0,wasmPath:"",wasmPlatformFetch:!1,debug:!1,async:!0,warmup:"full",cacheSensitivity:.7,skipAllowed:!1,deallocate:!1,flags:{},softwareKernels:!1,filter:{enabled:!0,equalization:!1,width:0,height:0,flip:!1,return:!0,autoBrightness:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"blazeface.json",rotation:!0,maxDetected:1,skipFrames:99,skipTime:2500,minConfidence:.2,iouThreshold:.1,mask:!1,return:!1},mesh:{enabled:!0,modelPath:"facemesh.json",keepInvalid:!1},attention:{enabled:!1,modelPath:"facemesh-attention.json"},iris:{enabled:!0,modelPath:"iris.json"},emotion:{enabled:!0,minConfidence:.1,skipFrames:99,skipTime:1500,modelPath:"emotion.json"},description:{enabled:!0,modelPath:"faceres.json",skipFrames:99,skipTime:3e3,minConfidence:.1},antispoof:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"antispoof.json"},liveness:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"liveness.json"}},body:{enabled:!0,modelPath:"movenet-lightning.json",maxDetected:-1,minConfidence:.3,skipFrames:1,skipTime:200},hand:{enabled:!0,rotation:!0,skipFrames:99,skipTime:1e3,minConfidence:.5,iouThreshold:.2,maxDetected:-1,landmarks:!0,detector:{modelPath:"handtrack.json"},skeleton:{modelPath:"handlandmark-full.json"}},object:{enabled:!1,modelPath:"centernet.json",minConfidence:.2,iouThreshold:.4,maxDetected:10,skipFrames:99,skipTime:2e3},segmentation:{enabled:!1,modelPath:"rvm.json",ratio:.5,mode:"default"}};var B5=`
+var __defProp = Object.defineProperty;
+var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
+var __getOwnPropNames = Object.getOwnPropertyNames;
+var __hasOwnProp = Object.prototype.hasOwnProperty;
+var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
+var __export = (target, all2) => {
+ for (var name in all2)
+ __defProp(target, name, { get: all2[name], enumerable: true });
+};
+var __copyProps = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
+ }
+ return to;
+};
+var __reExport = (target, mod3, secondTarget) => (__copyProps(target, mod3, "default"), secondTarget && __copyProps(secondTarget, mod3, "default"));
+var __publicField = (obj, key, value) => {
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
+ return value;
+};
+var __accessCheck = (obj, member, msg) => {
+ if (!member.has(obj))
+ throw TypeError("Cannot " + msg);
+};
+var __privateGet = (obj, member, getter) => {
+ __accessCheck(obj, member, "read from private field");
+ return getter ? getter.call(obj) : member.get(obj);
+};
+var __privateAdd = (obj, member, value) => {
+ if (member.has(obj))
+ throw TypeError("Cannot add the same private member more than once");
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
+};
+var __privateSet = (obj, member, value, setter) => {
+ __accessCheck(obj, member, "write to private field");
+ setter ? setter.call(obj, value) : member.set(obj, value);
+ return value;
+};
+
+// dist/tfjs.esm.js
+var tfjs_esm_exports = {};
+__export(tfjs_esm_exports, {
+ version: () => version7
+});
+__reExport(tfjs_esm_exports, dist_star);
+__reExport(tfjs_esm_exports, dist_star2);
+__reExport(tfjs_esm_exports, dist_star3);
+__reExport(tfjs_esm_exports, dist_star4);
+__reExport(tfjs_esm_exports, dist_star5);
+__reExport(tfjs_esm_exports, dist_star6);
+import * as dist_star from "@tensorflow/tfjs-core/dist/index.js";
+import * as dist_star2 from "@tensorflow/tfjs-converter/dist/index.js";
+import * as dist_star3 from "@tensorflow/tfjs-backend-cpu/dist/index.js";
+import * as dist_star4 from "@tensorflow/tfjs-backend-webgl/dist/index.js";
+import * as dist_star5 from "@tensorflow/tfjs-backend-wasm/dist/index.js";
+import * as dist_star6 from "@tensorflow/tfjs-backend-webgpu/dist/index.js";
+var version = "4.1.0";
+var version2 = "4.1.0";
+var version3 = "4.1.0";
+var version4 = "4.1.0";
+var version5 = "4.1.0";
+var version6 = "0.0.1-alpha.16";
+var version7 = {
+ tfjs: version,
+ "tfjs-core": version,
+ "tfjs-converter": version2,
+ "tfjs-backend-cpu": version3,
+ "tfjs-backend-webgl": version4,
+ "tfjs-backend-wasm": version5,
+ "tfjs-backend-webgpu": version6
+};
+
+// src/util/util.ts
+function log(...msg) {
+ const dt = new Date();
+ const ts = `${dt.getHours().toString().padStart(2, "0")}:${dt.getMinutes().toString().padStart(2, "0")}:${dt.getSeconds().toString().padStart(2, "0")}.${dt.getMilliseconds().toString().padStart(3, "0")}`;
+ if (msg)
+ console.log(ts, "Human:", ...msg);
+}
+function join(folder, file) {
+ const separator = folder.endsWith("/") ? "" : "/";
+ const skipJoin = file.startsWith(".") || file.startsWith("/") || file.startsWith("http:") || file.startsWith("https:") || file.startsWith("file:");
+ const path = skipJoin ? `${file}` : `${folder}${separator}${file}`;
+ if (!path.toLocaleLowerCase().includes(".json"))
+ throw new Error(`modelpath error: expecting json file: ${path}`);
+ return path;
+}
+var now = () => {
+ if (typeof performance !== "undefined")
+ return performance.now();
+ return parseInt((Number(process.hrtime.bigint()) / 1e3 / 1e3).toString());
+};
+function validate(defaults, config3, parent = "config", msgs = []) {
+ for (const key of Object.keys(config3)) {
+ if (typeof config3[key] === "object") {
+ validate(defaults[key], config3[key], key, msgs);
+ } else {
+ const defined = defaults && typeof defaults[key] !== "undefined";
+ if (!defined)
+ msgs.push({ reason: "unknown property", where: `${parent}.${key} = ${config3[key]}` });
+ const same = defaults && typeof defaults[key] === typeof config3[key];
+ if (defined && !same)
+ msgs.push({ reason: "property type mismatch", where: `${parent}.${key} = ${config3[key]}`, expected: typeof defaults[key] });
+ }
+ }
+ if (config3.debug && parent === "config" && msgs.length > 0)
+ log("invalid configuration", msgs);
+ return msgs;
+}
+function mergeDeep(...objects) {
+ const isObject = (obj) => obj && typeof obj === "object";
+ return objects.reduce((prev, obj) => {
+ Object.keys(obj || {}).forEach((key) => {
+ const pVal = prev[key];
+ const oVal = obj[key];
+ if (Array.isArray(pVal) && Array.isArray(oVal))
+ prev[key] = pVal.concat(...oVal);
+ else if (isObject(pVal) && isObject(oVal))
+ prev[key] = mergeDeep(pVal, oVal);
+ else
+ prev[key] = oVal;
+ });
+ return prev;
+ }, {});
+}
+
+// src/config.ts
+var config = {
+ backend: "",
+ modelBasePath: "",
+ cacheModels: true,
+ validateModels: true,
+ wasmPath: "",
+ wasmPlatformFetch: false,
+ debug: false,
+ async: true,
+ warmup: "full",
+ cacheSensitivity: 0.7,
+ skipAllowed: false,
+ deallocate: false,
+ flags: {},
+ softwareKernels: false,
+ filter: {
+ enabled: true,
+ equalization: false,
+ width: 0,
+ height: 0,
+ flip: false,
+ return: true,
+ autoBrightness: true,
+ brightness: 0,
+ contrast: 0,
+ sharpness: 0,
+ blur: 0,
+ saturation: 0,
+ hue: 0,
+ negative: false,
+ sepia: false,
+ vintage: false,
+ kodachrome: false,
+ technicolor: false,
+ polaroid: false,
+ pixelate: 0
+ },
+ gesture: {
+ enabled: true
+ },
+ face: {
+ enabled: true,
+ detector: {
+ modelPath: "blazeface.json",
+ rotation: true,
+ maxDetected: 1,
+ skipFrames: 99,
+ skipTime: 2500,
+ minConfidence: 0.2,
+ iouThreshold: 0.1,
+ mask: false,
+ return: false
+ },
+ mesh: {
+ enabled: true,
+ modelPath: "facemesh.json",
+ keepInvalid: false
+ },
+ attention: {
+ enabled: false,
+ modelPath: "facemesh-attention.json"
+ },
+ iris: {
+ enabled: true,
+ modelPath: "iris.json"
+ },
+ emotion: {
+ enabled: true,
+ minConfidence: 0.1,
+ skipFrames: 99,
+ skipTime: 1500,
+ modelPath: "emotion.json"
+ },
+ description: {
+ enabled: true,
+ modelPath: "faceres.json",
+ skipFrames: 99,
+ skipTime: 3e3,
+ minConfidence: 0.1
+ },
+ antispoof: {
+ enabled: false,
+ skipFrames: 99,
+ skipTime: 4e3,
+ modelPath: "antispoof.json"
+ },
+ liveness: {
+ enabled: false,
+ skipFrames: 99,
+ skipTime: 4e3,
+ modelPath: "liveness.json"
+ }
+ },
+ body: {
+ enabled: true,
+ modelPath: "movenet-lightning.json",
+ maxDetected: -1,
+ minConfidence: 0.3,
+ skipFrames: 1,
+ skipTime: 200
+ },
+ hand: {
+ enabled: true,
+ rotation: true,
+ skipFrames: 99,
+ skipTime: 1e3,
+ minConfidence: 0.5,
+ iouThreshold: 0.2,
+ maxDetected: -1,
+ landmarks: true,
+ detector: {
+ modelPath: "handtrack.json"
+ },
+ skeleton: {
+ modelPath: "handlandmark-full.json"
+ }
+ },
+ object: {
+ enabled: false,
+ modelPath: "centernet.json",
+ minConfidence: 0.2,
+ iouThreshold: 0.4,
+ maxDetected: 10,
+ skipFrames: 99,
+ skipTime: 2e3
+ },
+ segmentation: {
+ enabled: false,
+ modelPath: "rvm.json",
+ ratio: 0.5,
+ mode: "default"
+ }
+};
+
+// src/image/imagefxshaders.ts
+var vertexIdentity = `
precision highp float;
attribute vec2 pos;
attribute vec2 uv;
@@ -14,7 +278,8 @@ var nt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Gn=Objec
vUv = uv;
gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);
}
-`;var H5=`
+`;
+var colorMatrixWithAlpha = `
precision highp float;
varying vec2 vUv;
uniform sampler2D texture;
@@ -26,7 +291,8 @@ var nt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Gn=Objec
gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14];
gl_FragColor.a = m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19];
}
-`,G5=`
+`;
+var colorMatrixWithoutAlpha = `
precision highp float;
varying vec2 vUv;
uniform sampler2D texture;
@@ -38,7 +304,8 @@ var nt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Gn=Objec
gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[14];
gl_FragColor.a = c.a;
}
-`,V5=`
+`;
+var pixelate = `
precision highp float;
varying vec2 vUv;
uniform vec2 size;
@@ -51,7 +318,8 @@ var nt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Gn=Objec
vec2 coord = pixelate(vUv, size);
gl_FragColor += texture2D(texture, coord);
}
-`,Z5=`
+`;
+var blur = `
precision highp float;
varying vec2 vUv;
uniform sampler2D texture;
@@ -74,7 +342,8 @@ var nt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Gn=Objec
gl_FragColor += texture2D(texture, vUv + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794;
gl_FragColor += texture2D(texture, vUv + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265;
}
-`,X5=`
+`;
+var convolution = `
precision highp float;
varying vec2 vUv;
uniform sampler2D texture;
@@ -96,20 +365,6026 @@ var nt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Gn=Objec
c31 * m[6] + c32 * m[7] + c33 * m[8];
gl_FragColor.a = c22.a;
}
-`;var rt=(e,t,n)=>{let o=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(o,(s,A)=>(n[A]=0,s))},st=class{constructor(t,n,o){E(this,"uniform",{});E(this,"attribute",{});E(this,"gl");E(this,"id");E(this,"compile",(t,n)=>{let o=this.gl.createShader(n);return o?(this.gl.shaderSource(o,t),this.gl.compileShader(o),this.gl.getShaderParameter(o,this.gl.COMPILE_STATUS)?o:(h(`filter: gl compile failed: ${this.gl.getShaderInfoLog(o)||"unknown"}`),null)):(h("filter: could not create shader"),null)});this.gl=t;let s=this.compile(n,this.gl.VERTEX_SHADER),A=this.compile(o,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!s||!A)){if(!this.id){h("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,s),this.gl.attachShader(this.id,A),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){h(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),rt(n,"attribute",this.attribute);for(let a in this.attribute)this.attribute[a]=this.gl.getAttribLocation(this.id,a);rt(n,"uniform",this.uniform),rt(o,"uniform",this.uniform);for(let a in this.uniform)this.uniform[a]=this.gl.getUniformLocation(this.id,a)}}};function q5(){let e=0,t=null,n=!1,o=-1,s=[null,null],A=[],a=null,i=null,c=I0(100,100),x={},y={INTERMEDIATE:1},l=c.getContext("webgl");if(!l){h("filter: cannot get webgl context");return}this.gl=l;function f(v,p){if(!(v===c.width&&p===c.height)){if(c.width=v,c.height=p,!a){let b=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);a=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,a),l.bufferData(l.ARRAY_BUFFER,b,l.STATIC_DRAW),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}l.viewport(0,0,c.width,c.height),s=[null,null]}}function d(v,p){let b=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,b);let j=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,j);let k=l.createTexture();return l.bindTexture(l.TEXTURE_2D,k),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,v,p,0,l.RGBA,l.UNSIGNED_BYTE,null),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,k,0),l.bindTexture(l.TEXTURE_2D,null),l.bindFramebuffer(l.FRAMEBUFFER,null),{fbo:b,texture:k}}function u(v){return s[v]=s[v]||d(c.width,c.height),s[v]}function m(v=0){if(!i)return;let p=null,b=null,j=!1;e===0?p=t:p=u(o).texture||null,e++,n&&!(v&y.INTERMEDIATE)?(b=null,j=e%2===0):(o=(o+1)%2,b=u(o).fbo||null),l.bindTexture(l.TEXTURE_2D,p),l.bindFramebuffer(l.FRAMEBUFFER,b),l.uniform1f(i.uniform.flipY,j?-1:1),l.drawArrays(l.TRIANGLES,0,6)}function g(v){if(x[v])return i=x[v],l.useProgram((i?i.id:null)||null),i;if(i=new st(l,B5,v),!i)return h("filter: could not get webgl program"),null;let p=Float32Array.BYTES_PER_ELEMENT,b=4*p;return l.enableVertexAttribArray(i.attribute.pos),l.vertexAttribPointer(i.attribute.pos,2,l.FLOAT,!1,b,0*p),l.enableVertexAttribArray(i.attribute.uv),l.vertexAttribPointer(i.attribute.uv,2,l.FLOAT,!1,b,2*p),x[v]=i,i}let P={colorMatrix:v=>{let p=new Float32Array(v);p[4]/=255,p[9]/=255,p[14]/=255,p[19]/=255;let b=p[18]===1&&p[3]===0&&p[8]===0&&p[13]===0&&p[15]===0&&p[16]===0&&p[17]===0&&p[19]===0?G5:H5,j=g(b);!j||(l.uniform1fv(j.uniform.m,p),m())},brightness:v=>{let p=(v||0)+1;P.colorMatrix([p,0,0,0,0,0,p,0,0,0,0,0,p,0,0,0,0,0,1,0])},saturation:v=>{let p=(v||0)*2/3+1,b=(p-1)*-.5;P.colorMatrix([p,b,b,0,0,b,p,b,0,0,b,b,p,0,0,0,0,0,1,0])},desaturate:()=>{P.saturation(-1)},contrast:v=>{let p=(v||0)+1,b=-128*(p-1);P.colorMatrix([p,0,0,0,b,0,p,0,0,b,0,0,p,0,b,0,0,0,1,0])},negative:()=>{P.contrast(-2)},hue:v=>{v=(v||0)/180*Math.PI;let p=Math.cos(v),b=Math.sin(v),j=.213,k=.715,I=.072;P.colorMatrix([j+p*(1-j)+b*-j,k+p*-k+b*-k,I+p*-I+b*(1-I),0,0,j+p*-j+b*.143,k+p*(1-k)+b*.14,I+p*-I+b*-.283,0,0,j+p*-j+b*-(1-j),k+p*-k+b*k,I+p*(1-I)+b*I,0,0,0,0,0,1,0])},desaturateLuminance:()=>{P.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{P.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{P.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{P.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{P.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{P.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{P.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{P.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:v=>{let p=new Float32Array(v),b=1/c.width,j=1/c.height,k=g(X5);!k||(l.uniform1fv(k.uniform.m,p),l.uniform2f(k.uniform.px,b,j),m())},detectEdges:()=>{P.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{P.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{P.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:v=>{let p=v||1;P.convolution.call(this,[0,-1*p,0,-1*p,1+4*p,-1*p,0,-1*p,0])},emboss:v=>{let p=v||1;P.convolution.call(this,[-2*p,-1*p,0,-1*p,1,1*p,0,1*p,2*p])},blur:v=>{let p=v/7/c.width,b=v/7/c.height,j=g(Z5);!j||(l.uniform2f(j.uniform.px,0,b),m(y.INTERMEDIATE),l.uniform2f(j.uniform.px,p,0),m())},pixelate:v=>{let p=v/c.width,b=v/c.height,j=g(V5);!j||(l.uniform2f(j.uniform.size,p,b),m())}};this.add=function(v){let p=Array.prototype.slice.call(arguments,1),b=P[v];A.push({func:b,args:p})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(v){f(v.width,v.height),e=0,t||(t=l.createTexture()),l.bindTexture(l.TEXTURE_2D,t),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,v);for(let p=0;py.data())),a=Math.max(A[0][0],A[1][0],A[2][0]),c=(a>1?255:1)/a,x;if(c>1){let y=[r.sub(n[0],o[0]),r.sub(n[1],o[1]),r.sub(n[2],o[2])],l=[r.sub(s[0],o[0]),r.sub(s[1],o[1]),r.sub(s[2],o[2])],f=[r.mul(y[0],c),r.mul(y[1],c),r.mul(y[2],c)],d=r.stack([f[0],f[1],f[2]],2);x=r.reshape(d,[1,t.shape[0]||0,t.shape[1]||0,3]),r.dispose([...y,...l,...f])}else x=r.expandDims(t,0);return r.dispose([...n,...o,...s,n,t,e]),x}var i2=3840,l0=null,c0=null,Le=null,X,E0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function At(){E0.inputSum=0,E0.cacheDiff=1,E0.sumMethod=0,E0.inputTensor=void 0}function I0(e,t){let n;if(M.browser)if(M.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");n=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");n=document.createElement("canvas"),n.width=e,n.height=t}else typeof M.Canvas!="undefined"?n=new M.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(n=new globalThis.Canvas(e,t));return n}function l2(e,t){let n=t||I0(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),n}async function c2(e,t,n=!0){var f,d,u;if(!e)return t.debug&&h("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof r.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof M.Canvas!="undefined"&&e instanceof M.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof r.Tensor){let m=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)m=r.expandDims(e,0);else if(e.shape[2]===4){let g=r.slice3d(e,[0,0,0],[-1,-1,3]);m=r.expandDims(g,0),r.dispose(g)}}else e.shape.length===4&&(e.shape[3]===3?m=r.clone(e):e.shape[3]===4&&(m=r.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(m==null||m.shape.length!==4||m.shape[0]!==1||m.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(m.dtype==="int32"){let g=r.cast(m,"float32");r.dispose(m),m=g}return{tensor:m,canvas:t.filter.return?c0:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&h("input stream is not ready"),{tensor:null,canvas:l0};let o=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,s=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!o||!s)return t.debug&&h("cannot determine input dimensions"),{tensor:null,canvas:l0};let A=o,a=s;if(A>i2&&(A=i2,a=Math.trunc(A*s/o)),a>i2&&(a=i2,A=Math.trunc(a*o/s)),(((f=t.filter)==null?void 0:f.width)||0)>0?A=t.filter.width:(((d=t.filter)==null?void 0:d.height)||0)>0&&(A=o*((t.filter.height||0)/s)),(t.filter.height||0)>0?a=t.filter.height:(t.filter.width||0)>0&&(a=s*((t.filter.width||0)/o)),!A||!a)throw new Error("input error: cannot determine dimension");(!l0||l0.width!==A||l0.height!==a)&&(l0=I0(A,a));let i=l0.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?i.putImageData(e,0,0):t.filter.flip&&typeof i.translate!="undefined"?(i.translate(o,0),i.scale(-1,1),i.drawImage(e,0,0,o,s,0,0,l0.width,l0.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,o,s,0,0,l0.width,l0.height),(!c0||l0.width!==c0.width||l0.height!==c0.height)&&(c0=I0(l0.width,l0.height)),t.filter.enabled&&M.webgl.supported?(X||(X=M.browser?new q5:null),M.filter=!!X,X!=null&&X.add?(X.reset(),t.filter.brightness!==0&&X.add("brightness",t.filter.brightness),t.filter.contrast!==0&&X.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&X.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&X.add("blur",t.filter.blur),t.filter.saturation!==0&&X.add("saturation",t.filter.saturation),t.filter.hue!==0&&X.add("hue",t.filter.hue),t.filter.negative&&X.add("negative"),t.filter.sepia&&X.add("sepia"),t.filter.vintage&&X.add("brownie"),t.filter.sepia&&X.add("sepia"),t.filter.kodachrome&&X.add("kodachrome"),t.filter.technicolor&&X.add("technicolor"),t.filter.polaroid&&X.add("polaroid"),t.filter.pixelate!==0&&X.add("pixelate",t.filter.pixelate),((u=X.get())==null?void 0:u.length)>1?c0=X.apply(l0):c0=X.draw(l0)):(t.debug&&h("input process error: cannot initialize filters"),M.webgl.supported=!1,t.filter.enabled=!1,l2(l0,c0))):(l2(l0,c0),X&&(X=null),M.filter=!!X),!n)return{tensor:null,canvas:c0};if(!c0)throw new Error("canvas error: cannot create output");let c,x=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(M.browser&&r.browser)c=r.browser?r.browser.fromPixels(e):null;else{x=e.data.length/e.height/e.width;let m=new Uint8Array(e.data.buffer);c=r.tensor(m,[e.height,e.width,x],"int32")}else if((!Le||c0.width!==Le.width||c0.height!==Le.height)&&(Le=I0(c0.width,c0.height)),r.browser&&M.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?c=r.browser.fromPixels(c0):(Le=l2(c0),c=r.browser.fromPixels(Le));else{let P=l2(c0).getContext("2d").getImageData(0,0,A,a);x=P.data.length/A/a;let v=new Uint8Array(P.data.buffer);c=r.tensor(v,[A,a,x])}if(x===4){let m=r.slice3d(c,[0,0,0],[-1,-1,3]);r.dispose(c),c=m}if(!c)throw new Error("input error: cannot create tensor");let y=r.cast(c,"float32"),l=t.filter.equalization?await a2(y):r.expandDims(y,0);if(r.dispose([c,y]),t.filter.autoBrightness){let m=r.max(l),g=await m.data();t.filter.brightness=g[0]>1?1-g[0]/255:1-g[0],r.dispose(m)}return{tensor:l,canvas:t.filter.return?c0:null}}async function U5(e,t){let n=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>3840||t.shape[2]>2160)return n;if(!E0.inputTensor)E0.inputTensor=r.clone(t);else if(E0.inputTensor.shape[1]!==t.shape[1]||E0.inputTensor.shape[2]!==t.shape[2])r.dispose(E0.inputTensor),E0.inputTensor=r.clone(t);else{let o={};o.diff=r.sub(t,E0.inputTensor),o.squared=r.mul(o.diff,o.diff),o.sum=r.sum(o.squared);let A=(await o.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;r.dispose([E0.inputTensor,o.diff,o.squared,o.sum]),E0.inputTensor=r.clone(t),n=A<=(e.cacheSensitivity||0)}return n}async function Y5(e,t,n){let o={};if(!t||!n||t.shape.length!==4||t.shape.length!==n.shape.length)return e.debug||h("invalid input tensor or tensor shapes do not match:",t.shape,n.shape),0;if(t.shape[0]!==1||n.shape[0]!==1||t.shape[3]!==3||n.shape[3]!==3)return e.debug||h("input tensors must be of shape [1, height, width, 3]:",t.shape,n.shape),0;o.input1=r.clone(t),o.input2=t.shape[1]!==n.shape[1]||t.shape[2]!==n.shape[2]?r.image.resizeBilinear(n,[t.shape[1],t.shape[2]]):r.clone(n),o.diff=r.sub(o.input1,o.input2),o.squared=r.mul(o.diff,o.diff),o.sum=r.sum(o.squared);let A=(await o.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return r.dispose([o.input1,o.input2,o.diff,o.squared,o.sum]),A}var d2=class{constructor(){E(this,"browser");E(this,"node");E(this,"worker");E(this,"platform","");E(this,"agent","");E(this,"backends",[]);E(this,"initial");E(this,"filter");E(this,"tfjs");E(this,"offscreen");E(this,"perfadd",!1);E(this,"tensorflow",{version:void 0,gpu:void 0});E(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});E(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0,shader:void 0,vendor:void 0});E(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});E(this,"cpu",{model:void 0,flags:[]});E(this,"kernels",[]);E(this,"Canvas");E(this,"Image");E(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:Ke["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let n=t[0].match(/\(([^()]+)\)/g);this.platform=n!=null&&n[0]?n[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(r.engine().registryFactory);try{this.tensorflow={version:r.backend().binding?r.backend().binding.TF_Version:void 0,gpu:r.backend().binding?r.backend().binding.isUsingGpuDevice():void 0}}catch(o){}this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&(this.wasm.simd=await r.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await r.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=I0(100,100),n=t?t.getContext("webgl2"):void 0;this.webgl.supported=typeof n!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.vendor=n.getParameter(n.VENDOR),this.webgl.renderer=n.getParameter(n.RENDERER),this.webgl.shader=n.getParameter(n.SHADING_LANGUAGE_VERSION)),this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let o=await navigator.gpu.requestAdapter();this.webgpu.adapter=await(o==null?void 0:o.requestAdapterInfo())}}catch(o){this.webgpu.supported=!1}try{this.kernels=r.getKernelsForBackend(r.getBackend()).map(o=>o.kernelName.toLowerCase())}catch(o){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},M=new d2;var y2=class{constructor(){E(this,"config");E(this,"element");E(this,"stream");E(this,"devices",[]);E(this,"enumerate",async()=>{try{let t=await navigator.mediaDevices.enumerateDevices();this.devices=t.filter(n=>n.kind==="videoinput")}catch(t){this.devices=[]}return this.devices});E(this,"start",async t=>{if(t!=null&&t.debug&&(this.config.debug=t==null?void 0:t.debug),t!=null&&t.crop&&(this.config.crop=t==null?void 0:t.crop),t!=null&&t.mode&&(this.config.mode=t==null?void 0:t.mode),t!=null&&t.width&&(this.config.width=t==null?void 0:t.width),t!=null&&t.height&&(this.config.height=t==null?void 0:t.height),t!=null&&t.id&&(this.config.id=t==null?void 0:t.id),t!=null&&t.element)if(typeof t.element=="string"){let s=document.getElementById(t.element);if(s&&s instanceof HTMLVideoElement)this.element=s;else{this.config.debug&&h("webcam","cannot get dom element",t.element);return}}else if(t.element instanceof HTMLVideoElement)this.element=t.element;else{this.config.debug&&h("webcam","unknown dom element",t.element);return}else this.element=document.createElement("video");let n={audio:!1,video:{facingMode:this.config.mode==="front"?"user":"environment",resizeMode:this.config.crop?"crop-and-scale":"none",width:{ideal:this.config.width>0?this.config.width:window.innerWidth},height:{ideal:this.config.height>0?this.config.height:window.innerHeight}}};if(this.config.id&&(n.video.deviceId=this.config.id),this.element.addEventListener("play",()=>{this.config.debug&&h("webcam","play")}),this.element.addEventListener("pause",()=>{this.config.debug&&h("webcam","pause")}),this.element.addEventListener("click",async()=>{!this.element||!this.stream||(this.element.paused?await this.element.play():this.element.pause())}),!(navigator!=null&&navigator.mediaDevices)){this.config.debug&&h("webcam","no devices");return}try{this.stream=await navigator.mediaDevices.getUserMedia(n)}catch(s){h("webcam",s);return}if(!this.stream){this.config.debug&&h("webcam","no stream");return}this.element.srcObject=this.stream,await new Promise(s=>{this.element?this.element.onloadeddata=()=>s(!0):s(!1)}),await this.element.play(),this.config.debug&&h("webcam",{width:this.width,height:this.height,label:this.label,stream:this.stream,track:this.track,settings:this.settings,constraints:this.constraints,capabilities:this.capabilities})});E(this,"pause",()=>{this.element&&this.element.pause()});E(this,"play",async()=>{this.element&&await this.element.play()});E(this,"stop",()=>{this.config.debug&&h("webcam","stop"),this.track&&this.track.stop()});this.config={element:void 0,debug:!0,mode:"front",crop:!1,width:0,height:0}}get track(){if(!!this.stream)return this.stream.getVideoTracks()[0]}get capabilities(){if(!!this.track)return this.track.getCapabilities?this.track.getCapabilities():void 0}get constraints(){if(!!this.track)return this.track.getConstraints?this.track.getConstraints():void 0}get settings(){if(!this.stream)return;let t=this.stream.getVideoTracks()[0];return t.getSettings?t.getSettings():void 0}get label(){return this.track?this.track.label:""}get paused(){var t;return((t=this.element)==null?void 0:t.paused)||!1}get width(){var t;return((t=this.element)==null?void 0:t.videoWidth)||0}get height(){var t;return((t=this.element)==null?void 0:t.videoHeight)||0}};var at={};te(at,{age:()=>xo,"anti-spoofing":()=>Xo,antispoof:()=>$n,blazeface:()=>eo,"blazeface-back":()=>yo,"blazeface-front":()=>fo,"blazepose-detect":()=>Zo,"blazepose-detector2d":()=>mo,"blazepose-detector3d":()=>po,"blazepose-full":()=>uo,"blazepose-heavy":()=>ho,"blazepose-lite":()=>bo,centernet:()=>to,default:()=>rr,efficientpose:()=>go,"efficientpose-i-lite":()=>qo,"efficientpose-ii-lite":()=>Uo,"efficientpose-iv":()=>Yo,emotion:()=>no,faceboxes:()=>To,facemesh:()=>oo,"facemesh-attention":()=>Ro,"facemesh-attention-alt":()=>vo,"facemesh-detection-full":()=>Mo,"facemesh-detection-short":()=>Po,"facemesh-orig":()=>ko,faceres:()=>ro,"faceres-deep":()=>wo,gear:()=>Eo,gender:()=>So,"gender-ssrnet-imdb":()=>zo,handdetect:()=>jo,"handlandmark-full":()=>so,"handlandmark-lite":()=>No,"handlandmark-sparse":()=>Io,handskeleton:()=>Lo,handtrack:()=>Ao,"insightface-efficientnet-b0":()=>Ko,"insightface-ghostnet-strides1":()=>Jo,"insightface-ghostnet-strides2":()=>Qo,"insightface-mobilenet-emore":()=>_o,"insightface-mobilenet-swish":()=>$o,iris:()=>ao,liveness:()=>io,meet:()=>Oo,mobileface:()=>Co,mobilefacenet:()=>Wo,models:()=>lo,"movenet-lightning":()=>co,"movenet-multipose":()=>Do,"movenet-thunder":()=>Fo,nanodet:()=>Bo,"nanodet-e":()=>er,"nanodet-g":()=>tr,"nanodet-m":()=>nr,"nanodet-t":()=>or,posenet:()=>Ho,rvm:()=>Go,selfie:()=>Vo});var $n=853098,eo=538928,to=4030290,no=820516,oo=1477958,ro=6978814,so=5431368,Ao=2964837,ao=2599092,io=592976,lo=0,co=4650216,xo=161240,yo=538928,fo=402048,mo=7499400,po=5928856,uo=6338290,ho=27501554,bo=2725490,go=5651240,To=2013002,vo=2387598,Ro=2382414,Mo=1026192,Po=201268,ko=2955780,wo=13957620,Eo=1498916,zo=161236,So=201808,jo=3515612,No=2023432,Io=5286322,Lo=5502280,Oo=372228,Co=2183192,Wo=5171976,Do=9448838,Fo=12477112,Bo=7574558,Ho=5032780,Go=3739355,Vo=212886,Zo=5928804,Xo=853098,qo=2269064,Uo=5651240,Yo=25643252,Ko=13013224,Jo=8093408,Qo=8049584,_o=6938536,$o=12168584,er=12319156,tr=7574558,nr=1887474,or=5294216,rr={antispoof:$n,blazeface:eo,centernet:to,emotion:no,facemesh:oo,faceres:ro,"handlandmark-full":so,handtrack:Ao,iris:ao,liveness:io,models:lo,"movenet-lightning":co,age:xo,"blazeface-back":yo,"blazeface-front":fo,"blazepose-detector2d":mo,"blazepose-detector3d":po,"blazepose-full":uo,"blazepose-heavy":ho,"blazepose-lite":bo,efficientpose:go,faceboxes:To,"facemesh-attention-alt":vo,"facemesh-attention":Ro,"facemesh-detection-full":Mo,"facemesh-detection-short":Po,"facemesh-orig":ko,"faceres-deep":wo,gear:Eo,"gender-ssrnet-imdb":zo,gender:So,handdetect:jo,"handlandmark-lite":No,"handlandmark-sparse":Io,handskeleton:Lo,meet:Oo,mobileface:Co,mobilefacenet:Wo,"movenet-multipose":Do,"movenet-thunder":Fo,nanodet:Bo,posenet:Ho,rvm:Go,selfie:Vo,"blazepose-detect":Zo,"anti-spoofing":Xo,"efficientpose-i-lite":qo,"efficientpose-ii-lite":Uo,"efficientpose-iv":Yo,"insightface-efficientnet-b0":Ko,"insightface-ghostnet-strides1":Jo,"insightface-ghostnet-strides2":Qo,"insightface-mobilenet-emore":_o,"insightface-mobilenet-swish":$o,"nanodet-e":er,"nanodet-g":tr,"nanodet-m":nr,"nanodet-t":or};var u0={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},y0={};async function sr(e,t){return u0.debug&&h("load model fetch:",e,t),fetch(e,t)}function K5(e){u0.cacheModels=e.cacheModels,u0.verbose=e.debug,u0.modelBasePath=e.modelBasePath}async function L(e){var x,y,l,f;let t=F5(u0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let n=t.includes("/")?t.split("/"):t.split("\\"),o=n[n.length-1].replace(".json",""),s="indexeddb://"+o;y0[o]={name:o,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:at[o],inCache:!1,url:""},u0.cacheSupported=typeof indexedDB!="undefined";let A={};try{A=u0.cacheSupported&&u0.cacheModels?await r.io.listModels():{}}catch(d){u0.cacheSupported=!1}y0[o].inCache=u0.cacheSupported&&u0.cacheModels&&Object.keys(A).includes(s),y0[o].url=y0[o].inCache?s:t;let a=typeof fetch=="undefined"?{}:{fetchFunc:(d,u)=>sr(d,u)},i=new r.GraphModel(y0[o].url,a),c=!1;try{i.findIOHandler(),u0.debug&&h("model load handler:",i.handler)}catch(d){h("error finding model i/o handler:",t,d)}try{let d=await((x=i.handler)==null?void 0:x.load())||null;y0[o].sizeFromManifest=((y=d==null?void 0:d.weightData)==null?void 0:y.byteLength)||0,d?i.loadSync(d):i=await r.loadGraphModel(y0[o].inCache?s:t,a),y0[o].sizeLoadedWeights=((f=(l=i.artifacts)==null?void 0:l.weightData)==null?void 0:f.byteLength)||0,u0.verbose&&h("load:",{model:o,url:i.modelUrl,bytes:y0[o].sizeLoadedWeights}),c=!0}catch(d){h("error loading model:",t,d)}if(c&&u0.cacheModels&&u0.cacheSupported&&!y0[o].inCache)try{let d=await i.save(s);u0.debug&&h("model saved:",s,d)}catch(d){h("error saving model:",t,d)}return i}var it="3.0.0";var U={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function ir(){let e=U.gl;!e||(U.extensions=e.getSupportedExtensions())}function J5(e){var t;if(e.config.backend==="humangl"&&(U.name in r.engine().registry&&!((t=U==null?void 0:U.gl)!=null&&t.getParameter(U.gl.VERSION))&&(h("humangl error: backend invalid context"),e.models.reset()),!r.findBackend(U.name))){try{U.canvas=I0(100,100)}catch(s){h("humangl error: cannot create canvas:",s);return}try{if(U.gl=U.canvas.getContext("webgl2",U.webGLattr),!U.gl){h("humangl error: cannot get webgl context");return}if(!U.gl.getParameter(U.gl.VERSION).includes("2.0")){h("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}U.canvas&&(U.canvas.addEventListener("webglcontextlost",A=>{throw h("humangl error:",A.type),h("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),U.canvas.addEventListener("webglcontextrestored",A=>{h("humangl error: context restored:",A)}),U.canvas.addEventListener("webglcontextcreationerror",A=>{h("humangl error: context create:",A)}))}catch(s){h("humangl error: cannot get webgl context:",s);return}try{r.setWebGLContext(2,U.gl)}catch(s){h("humangl error: cannot set webgl context:",s);return}try{let s=new r.GPGPUContext(U.gl);r.registerBackend(U.name,()=>new r.MathBackendWebGL(s),U.priority)}catch(s){h("humangl error: cannot register webgl backend:",s);return}try{r.getKernelsForBackend("webgl").forEach(A=>{let a={...A,backendName:U.name};r.registerKernel(a)})}catch(s){h("humangl error: cannot update webgl backend registration:",s);return}try{r.env().flagRegistry.WEBGL_VERSION&&r.env().set("WEBGL_VERSION",2)}catch(s){h("humangl error: cannot set WebGL backend flags:",s);return}ir();let n=r.backend(),o=typeof n.gpgpu!="undefined"?n.getGPGPUContext().gl:null;o?e.config.debug&&h("humangl backend registered:",{webgl:o.getParameter(o.VERSION),renderer:o.getParameter(o.RENDERER)}):h("humangl error: no current gl context:",o,U.gl)}}var O={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Q5(){O.tf255=r.scalar(255,"float32"),O.tf1=r.scalar(1,"float32"),O.tf2=r.scalar(2,"float32"),O.tf05=r.scalar(.5,"float32"),O.tf127=r.scalar(127.5,"float32"),O.rgb=r.tensor1d([.2989,.587,.114],"float32")}async function xr(){return await M.updateBackend(),M.browser?M.webgpu.supported&&M.webgpu.backend?"webgpu":M.webgl.supported&&M.webgl.backend?"webgl":M.wasm.supported&&M.wasm.backend?"wasm":"cpu":"tensorflow"}function dr(e){let t=[];if(!M.kernels.includes("mod")){let n={kernelName:"Mod",backendName:r.getBackend(),kernelFunc:o=>r.tidy(()=>r.sub(o.inputs.a,r.mul(r.div(o.inputs.a,o.inputs.b),o.inputs.b)))};r.registerKernel(n),M.kernels.push("mod"),t.push("mod")}if(!M.kernels.includes("floormod")){let n={kernelName:"FloorMod",backendName:r.getBackend(),kernelFunc:o=>r.tidy(()=>r.add(r.mul(r.floorDiv(o.inputs.a,o.inputs.b),o.inputs.b),r.mod(o.inputs.a,o.inputs.b)))};r.registerKernel(n),M.kernels.push("floormod"),t.push("floormod")}if(!M.kernels.includes("rotatewithoffset")&&e.softwareKernels){let n={kernelName:"RotateWithOffset",backendName:r.getBackend(),kernelFunc:o=>r.tidy(()=>{let s=r.getBackend();r.setBackend("cpu");let A=r.image.rotateWithOffset(o.inputs.image,o.attrs.radians,o.attrs.fillValue,o.attrs.center);return r.setBackend(s),A})};r.registerKernel(n),M.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&h("registered kernels:",t)}var _5={};async function Je(e,t=!1){var n;if(e.state="backend",((n=e.config.backend)==null?void 0:n.length)===0&&(e.config.backend=await xr()),t||M.initial||e.config.backend&&e.config.backend.length>0&&r.getBackend()!==e.config.backend){let o=T();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&h("running inside web worker"),M.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&h("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),M.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&h(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),M.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")h("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let A=await navigator.gpu.requestAdapter();if(e.config.debug&&h("enumerated webgpu adapter:",A),!A)h("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let a="requestAdapterInfo"in A?await A.requestAdapterInfo():void 0;h("webgpu adapter info:",a)}}let s=Object.keys(r.engine().registryFactory);if(e.config.backend==="humangl"&&!s.includes("humangl")&&(J5(e),s=Object.keys(r.engine().registryFactory)),e.config.debug&&h("available backends:",s),s.includes(e.config.backend)||(h(`error: backend ${e.config.backend} not found in registry`),e.config.backend=M.node?"tensorflow":"webgl",e.config.debug&&h(`override: setting backend ${e.config.backend}`)),e.config.debug&&h("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(r.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&r.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&h("wasm path:",e.config.wasmPath),typeof r.setWasmPaths!="undefined")r.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let A=!1,a=!1;try{A=await r.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),a=await r.env().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&h(`wasm execution: ${a?"simd":"no simd"} ${A?"multithreaded":"singlethreaded"}`),e.config.debug&&!a&&h("warning: wasm simd support is not enabled")}catch(i){h("wasm detection failed")}}try{await r.setBackend(e.config.backend),await r.ready()}catch(A){return h("error: cannot set backend:",e.config.backend,A),!1}e.config.debug&&(_5=JSON.parse(JSON.stringify(r.env().flags)))}if((r.getBackend()==="humangl"||r.getBackend()==="webgl")&&(r.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&r.env().set("WEBGL_USE_SHAPES_UNIFORMS",!0),r.env().flagRegistry.WEBGL_EXP_CONV&&r.env().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(h("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),r.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),r.getBackend(),e.config.debug){let s=r.env().flags,A={};for(let a of Object.keys(s))_5[a]!==s[a]&&(A[a]=s[a]);e.config.debug&&Object.keys(A).length>0&&h("backend:",r.getBackend(),"flags:",A)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&h("flags:",e.config.flags);for(let[s,A]of Object.entries(e.config.flags))r.env().set(s,A)}r.enableProdMode(),Q5(),e.performance.initBackend=Math.trunc(T()-o),e.config.backend=r.getBackend(),await M.updateBackend(),dr(e.config),M.initial=!1}return!0}function f2(e,t){for(let n of e){let o={kernelName:n,backendName:t.backend,kernelFunc:s=>{var A;return t.debug&&h("kernelFunc",n,t.backend,s),(A=s==null?void 0:s.inputs)==null?void 0:A.info}};r.registerKernel(o)}M.kernels=r.getKernelsForBackend(r.getBackend()).map(n=>n.kernelName.toLowerCase())}var pt={};te(pt,{all:()=>Vr,body:()=>p2,canvas:()=>Gr,face:()=>m2,gesture:()=>b2,hand:()=>u2,init:()=>mt,object:()=>h2,options:()=>$,person:()=>Hr});var z0=e=>{if(!e)h("draw error: invalid canvas");else if(!e.getContext)h("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)h("draw error: cannot get canvas context");else return t}return null},ue=e=>Math.round(e*180/Math.PI),V=(e,t,n)=>e.replace(t,typeof n=="number"?n.toFixed(1):n),he=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let n=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${t.alpha})`};function L0(e,t,n,o,s){let A=t.replace(/\[.*\]/g,"").split(`
-`).map(i=>i.trim()),a=Math.max(0,n);for(let i=A.length-1;i>=0;i--){let c=i*s.lineHeight+o;s.shadowColor&&s.shadowColor!==""&&(e.fillStyle=s.shadowColor,e.fillText(A[i],a+5,c+16)),e.fillStyle=s.labelColor,e.fillText(A[i],a+4,c+15)}}function U0(e,t,n,o,s){e.fillStyle=he(o,s),e.beginPath(),e.arc(t,n,s.pointSize,0,2*Math.PI),e.fill()}function Z0(e,t,n,o,s,A){if(e.beginPath(),e.lineWidth=A.lineWidth,A.useCurves){let a=(t+t+o)/2,i=(n+n+s)/2;e.ellipse(a,i,o/2,s/2,0,0,2*Math.PI)}else e.moveTo(t+A.roundRect,n),e.lineTo(t+o-A.roundRect,n),e.quadraticCurveTo(t+o,n,t+o,n+A.roundRect),e.lineTo(t+o,n+s-A.roundRect),e.quadraticCurveTo(t+o,n+s,t+o-A.roundRect,n+s),e.lineTo(t+A.roundRect,n+s),e.quadraticCurveTo(t,n+s,t,n+s-A.roundRect),e.lineTo(t,n+A.roundRect),e.quadraticCurveTo(t,n,t+A.roundRect,n),e.closePath();e.stroke()}function lt(e,t,n){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let o of t)e.strokeStyle=he(o[2]||0,n),e.lineTo(Math.trunc(o[0]),Math.trunc(o[1]));e.stroke(),n.fillPolygons&&(e.closePath(),e.fill())}}function e1(e,t,n){if(!(t.length<2)){if(e.lineWidth=n.lineWidth,!n.useCurves||t.length<=2){lt(e,t,n);return}e.moveTo(t[0][0],t[0][1]);for(let o=0;oQe[e]),HA=fr.map(e=>Qe[e]),GA=mr.map(e=>Qe[e]);function ne(e){let t=e.map(n=>n[0]);return t.push(e[e.length-1][1]),t}var pr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],ur=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],hr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],br=[[474,475],[475,476],[476,477],[477,474]],gr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Tr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],vr=[[469,470],[470,471],[471,472],[472,469]],Rr=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],VA={lips:ne(pr),leftEye:ne(ur),leftEyebrow:ne(hr),leftIris:ne(br),rightEye:ne(gr),rightEyebrow:ne(Tr),rightIris:ne(vr),faceOval:ne(Rr)};var Mr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],Pr=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],kr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],wr=[[474,475],[475,476],[476,477],[477,474]],Er=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],zr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Sr=[[469,470],[470,471],[471,472],[472,469]],jr=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function oe(e){let t=e.map(n=>n[0]);return t.push(e[e.length-1][1]),t}var Nr={lips:oe(Mr),leftEye:oe(Pr),leftEyebrow:oe(kr),leftIris:oe(wr),rightEye:oe(Er),rightEyebrow:oe(zr),rightIris:oe(Sr),faceOval:oe(jr)},Ir=Object.entries(Nr).map(([e,t])=>t.map(n=>[n,e])).flat(),ZA=new Map(Ir),_e=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],Te=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],ve=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];var G;function Lr(e,t){var o,s,A,a,i,c,x,y,l;if(!G.drawLabels||((o=G.faceLabels)==null?void 0:o.length)===0)return;let n=G.faceLabels.slice();if(e.score&&(n=V(n,"[score]",100*e.score)),e.gender&&(n=V(n,"[gender]",e.gender)),e.genderScore&&(n=V(n,"[genderScore]",100*e.genderScore)),e.age&&(n=V(n,"[age]",e.age)),e.distance&&(n=V(n,"[distance]",100*e.distance)),e.real&&(n=V(n,"[real]",100*e.real)),e.live&&(n=V(n,"[live]",100*e.live)),e.emotion&&e.emotion.length>0){let f=e.emotion.map(d=>`${Math.trunc(100*d.score)}% ${d.emotion}`);f.length>3&&(f.length=3),n=V(n,"[emotions]",f.join(" "))}(A=(s=e.rotation)==null?void 0:s.angle)!=null&&A.roll&&(n=V(n,"[roll]",ue(e.rotation.angle.roll))),(i=(a=e.rotation)==null?void 0:a.angle)!=null&&i.yaw&&(n=V(n,"[yaw]",ue(e.rotation.angle.yaw))),(x=(c=e.rotation)==null?void 0:c.angle)!=null&&x.pitch&&(n=V(n,"[pitch]",ue(e.rotation.angle.pitch))),(l=(y=e.rotation)==null?void 0:y.gaze)!=null&&l.bearing&&(n=V(n,"[gaze]",ue(e.rotation.gaze.bearing))),L0(t,n,e.box[0],e.box[1],G)}function Or(e,t){var n,o,s,A;if(((n=e.annotations)==null?void 0:n.leftEyeIris)&&((o=e.annotations)==null?void 0:o.leftEyeIris[0])){t.strokeStyle=G.useDepth?"rgba(255, 200, 255, 0.3)":G.color,t.beginPath();let a=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,i=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],a,i,0,0,2*Math.PI),t.stroke(),G.fillPolygons&&(t.fillStyle=G.useDepth?"rgba(255, 255, 200, 0.3)":G.color,t.fill())}if(((s=e.annotations)==null?void 0:s.rightEyeIris)&&((A=e.annotations)==null?void 0:A.rightEyeIris[0])){t.strokeStyle=G.useDepth?"rgba(255, 200, 255, 0.3)":G.color,t.beginPath();let a=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,i=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],a,i,0,0,2*Math.PI),t.stroke(),G.fillPolygons&&(t.fillStyle=G.useDepth?"rgba(255, 255, 200, 0.3)":G.color,t.fill())}}function Cr(e,t){var n;if(G.drawGaze&&((n=e.rotation)==null?void 0:n.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let o=e.box[0]+e.box[2]/2-e.box[3]*ue(e.rotation.angle.yaw)/90,s=e.box[1]+e.box[3]/2+e.box[2]*ue(e.rotation.angle.pitch)/90,A=new Path2D(`
- M ${e.box[0]+e.box[2]/2} ${e.box[1]}
+`;
+
+// src/image/imagefx.ts
+var collect = (source, prefix, collection) => {
+ const r = new RegExp("\\b" + prefix + " \\w+ (\\w+)", "ig");
+ source.replace(r, (match2, name) => {
+ collection[name] = 0;
+ return match2;
+ });
+};
+var GLProgram = class {
+ constructor(gl, vertexSource, fragmentSource) {
+ __publicField(this, "uniform", {});
+ __publicField(this, "attribute", {});
+ __publicField(this, "gl");
+ __publicField(this, "id");
+ __publicField(this, "compile", (source, type) => {
+ const shader = this.gl.createShader(type);
+ if (!shader) {
+ log("filter: could not create shader");
+ return null;
+ }
+ this.gl.shaderSource(shader, source);
+ this.gl.compileShader(shader);
+ if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
+ log(`filter: gl compile failed: ${this.gl.getShaderInfoLog(shader) || "unknown"}`);
+ return null;
+ }
+ return shader;
+ });
+ this.gl = gl;
+ const vertexShader = this.compile(vertexSource, this.gl.VERTEX_SHADER);
+ const fragmentShader = this.compile(fragmentSource, this.gl.FRAGMENT_SHADER);
+ this.id = this.gl.createProgram();
+ if (!vertexShader || !fragmentShader)
+ return;
+ if (!this.id) {
+ log("filter: could not create webgl program");
+ return;
+ }
+ this.gl.attachShader(this.id, vertexShader);
+ this.gl.attachShader(this.id, fragmentShader);
+ this.gl.linkProgram(this.id);
+ if (!this.gl.getProgramParameter(this.id, this.gl.LINK_STATUS)) {
+ log(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id) || "unknown"}`);
+ return;
+ }
+ this.gl.useProgram(this.id);
+ collect(vertexSource, "attribute", this.attribute);
+ for (const a in this.attribute)
+ this.attribute[a] = this.gl.getAttribLocation(this.id, a);
+ collect(vertexSource, "uniform", this.uniform);
+ collect(fragmentSource, "uniform", this.uniform);
+ for (const u in this.uniform)
+ this.uniform[u] = this.gl.getUniformLocation(this.id, u);
+ }
+};
+function GLImageFilter() {
+ let drawCount = 0;
+ let sourceTexture = null;
+ let lastInChain = false;
+ let currentFramebufferIndex = -1;
+ let tempFramebuffers = [null, null];
+ let filterChain = [];
+ let vertexBuffer = null;
+ let currentProgram = null;
+ const fxcanvas = canvas(100, 100);
+ const shaderProgramCache = {};
+ const DRAW = { INTERMEDIATE: 1 };
+ const gl = fxcanvas.getContext("webgl");
+ if (!gl) {
+ log("filter: cannot get webgl context");
+ return;
+ }
+ this.gl = gl;
+ function resize(width, height) {
+ if (width === fxcanvas.width && height === fxcanvas.height)
+ return;
+ fxcanvas.width = width;
+ fxcanvas.height = height;
+ if (!vertexBuffer) {
+ const vertices = new Float32Array([-1, -1, 0, 1, 1, -1, 1, 1, -1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 1, 1, 1, 1, 1, 0]);
+ vertexBuffer = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
+ gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
+ }
+ gl.viewport(0, 0, fxcanvas.width, fxcanvas.height);
+ tempFramebuffers = [null, null];
+ }
+ function createFramebufferTexture(width, height) {
+ const fbo = gl.createFramebuffer();
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+ const renderbuffer = gl.createRenderbuffer();
+ gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
+ const texture = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
+ gl.bindTexture(gl.TEXTURE_2D, null);
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+ return { fbo, texture };
+ }
+ function getTempFramebuffer(index2) {
+ tempFramebuffers[index2] = tempFramebuffers[index2] || createFramebufferTexture(fxcanvas.width, fxcanvas.height);
+ return tempFramebuffers[index2];
+ }
+ function draw(flags = 0) {
+ if (!currentProgram)
+ return;
+ let source = null;
+ let target = null;
+ let flipY = false;
+ if (drawCount === 0)
+ source = sourceTexture;
+ else
+ source = getTempFramebuffer(currentFramebufferIndex).texture || null;
+ drawCount++;
+ if (lastInChain && !(flags & DRAW.INTERMEDIATE)) {
+ target = null;
+ flipY = drawCount % 2 === 0;
+ } else {
+ currentFramebufferIndex = (currentFramebufferIndex + 1) % 2;
+ target = getTempFramebuffer(currentFramebufferIndex).fbo || null;
+ }
+ gl.bindTexture(gl.TEXTURE_2D, source);
+ gl.bindFramebuffer(gl.FRAMEBUFFER, target);
+ gl.uniform1f(currentProgram.uniform["flipY"], flipY ? -1 : 1);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ }
+ function compileShader(fragmentSource) {
+ if (shaderProgramCache[fragmentSource]) {
+ currentProgram = shaderProgramCache[fragmentSource];
+ gl.useProgram((currentProgram ? currentProgram.id : null) || null);
+ return currentProgram;
+ }
+ currentProgram = new GLProgram(gl, vertexIdentity, fragmentSource);
+ if (!currentProgram) {
+ log("filter: could not get webgl program");
+ return null;
+ }
+ const floatSize = Float32Array.BYTES_PER_ELEMENT;
+ const vertSize = 4 * floatSize;
+ gl.enableVertexAttribArray(currentProgram.attribute["pos"]);
+ gl.vertexAttribPointer(currentProgram.attribute["pos"], 2, gl.FLOAT, false, vertSize, 0 * floatSize);
+ gl.enableVertexAttribArray(currentProgram.attribute["uv"]);
+ gl.vertexAttribPointer(currentProgram.attribute["uv"], 2, gl.FLOAT, false, vertSize, 2 * floatSize);
+ shaderProgramCache[fragmentSource] = currentProgram;
+ return currentProgram;
+ }
+ const filter = {
+ colorMatrix: (matrix) => {
+ const m = new Float32Array(matrix);
+ m[4] /= 255;
+ m[9] /= 255;
+ m[14] /= 255;
+ m[19] /= 255;
+ const shader = m[18] === 1 && m[3] === 0 && m[8] === 0 && m[13] === 0 && m[15] === 0 && m[16] === 0 && m[17] === 0 && m[19] === 0 ? colorMatrixWithoutAlpha : colorMatrixWithAlpha;
+ const program = compileShader(shader);
+ if (!program)
+ return;
+ gl.uniform1fv(program.uniform["m"], m);
+ draw();
+ },
+ brightness: (brightness) => {
+ const b = (brightness || 0) + 1;
+ filter.colorMatrix([
+ b,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ b,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ b,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ saturation: (amount) => {
+ const x = (amount || 0) * 2 / 3 + 1;
+ const y = (x - 1) * -0.5;
+ filter.colorMatrix([
+ x,
+ y,
+ y,
+ 0,
+ 0,
+ y,
+ x,
+ y,
+ 0,
+ 0,
+ y,
+ y,
+ x,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ desaturate: () => {
+ filter.saturation(-1);
+ },
+ contrast: (amount) => {
+ const v = (amount || 0) + 1;
+ const o = -128 * (v - 1);
+ filter.colorMatrix([
+ v,
+ 0,
+ 0,
+ 0,
+ o,
+ 0,
+ v,
+ 0,
+ 0,
+ o,
+ 0,
+ 0,
+ v,
+ 0,
+ o,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ negative: () => {
+ filter.contrast(-2);
+ },
+ hue: (rotation) => {
+ rotation = (rotation || 0) / 180 * Math.PI;
+ const cos = Math.cos(rotation);
+ const sin = Math.sin(rotation);
+ const lumR = 0.213;
+ const lumG = 0.715;
+ const lumB = 0.072;
+ filter.colorMatrix([
+ lumR + cos * (1 - lumR) + sin * -lumR,
+ lumG + cos * -lumG + sin * -lumG,
+ lumB + cos * -lumB + sin * (1 - lumB),
+ 0,
+ 0,
+ lumR + cos * -lumR + sin * 0.143,
+ lumG + cos * (1 - lumG) + sin * 0.14,
+ lumB + cos * -lumB + sin * -0.283,
+ 0,
+ 0,
+ lumR + cos * -lumR + sin * -(1 - lumR),
+ lumG + cos * -lumG + sin * lumG,
+ lumB + cos * (1 - lumB) + sin * lumB,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ desaturateLuminance: () => {
+ filter.colorMatrix([
+ 0.2764723,
+ 0.929708,
+ 0.0938197,
+ 0,
+ -37.1,
+ 0.2764723,
+ 0.929708,
+ 0.0938197,
+ 0,
+ -37.1,
+ 0.2764723,
+ 0.929708,
+ 0.0938197,
+ 0,
+ -37.1,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ sepia: () => {
+ filter.colorMatrix([
+ 0.393,
+ 0.7689999,
+ 0.18899999,
+ 0,
+ 0,
+ 0.349,
+ 0.6859999,
+ 0.16799999,
+ 0,
+ 0,
+ 0.272,
+ 0.5339999,
+ 0.13099999,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ brownie: () => {
+ filter.colorMatrix([
+ 0.5997023498159715,
+ 0.34553243048391263,
+ -0.2708298674538042,
+ 0,
+ 47.43192855600873,
+ -0.037703249837783157,
+ 0.8609577587992641,
+ 0.15059552388459913,
+ 0,
+ -36.96841498319127,
+ 0.24113635128153335,
+ -0.07441037908422492,
+ 0.44972182064877153,
+ 0,
+ -7.562075277591283,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ vintagePinhole: () => {
+ filter.colorMatrix([
+ 0.6279345635605994,
+ 0.3202183420819367,
+ -0.03965408211312453,
+ 0,
+ 9.651285835294123,
+ 0.02578397704808868,
+ 0.6441188644374771,
+ 0.03259127616149294,
+ 0,
+ 7.462829176470591,
+ 0.0466055556782719,
+ -0.0851232987247891,
+ 0.5241648018700465,
+ 0,
+ 5.159190588235296,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ kodachrome: () => {
+ filter.colorMatrix([
+ 1.1285582396593525,
+ -0.3967382283601348,
+ -0.03992559172921793,
+ 0,
+ 63.72958762196502,
+ -0.16404339962244616,
+ 1.0835251566291304,
+ -0.05498805115633132,
+ 0,
+ 24.732407896706203,
+ -0.16786010706155763,
+ -0.5603416277695248,
+ 1.6014850761964943,
+ 0,
+ 35.62982807460946,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ technicolor: () => {
+ filter.colorMatrix([
+ 1.9125277891456083,
+ -0.8545344976951645,
+ -0.09155508482755585,
+ 0,
+ 11.793603434377337,
+ -0.3087833385928097,
+ 1.7658908555458428,
+ -0.10601743074722245,
+ 0,
+ -70.35205161461398,
+ -0.231103377548616,
+ -0.7501899197440212,
+ 1.847597816108189,
+ 0,
+ 30.950940869491138,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ polaroid: () => {
+ filter.colorMatrix([
+ 1.438,
+ -0.062,
+ -0.062,
+ 0,
+ 0,
+ -0.122,
+ 1.378,
+ -0.122,
+ 0,
+ 0,
+ -0.016,
+ -0.016,
+ 1.483,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ shiftToBGR: () => {
+ filter.colorMatrix([
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ convolution: (matrix) => {
+ const m = new Float32Array(matrix);
+ const pixelSizeX = 1 / fxcanvas.width;
+ const pixelSizeY = 1 / fxcanvas.height;
+ const program = compileShader(convolution);
+ if (!program)
+ return;
+ gl.uniform1fv(program.uniform["m"], m);
+ gl.uniform2f(program.uniform["px"], pixelSizeX, pixelSizeY);
+ draw();
+ },
+ detectEdges: () => {
+ filter.convolution.call(this, [
+ 0,
+ 1,
+ 0,
+ 1,
+ -4,
+ 1,
+ 0,
+ 1,
+ 0
+ ]);
+ },
+ sobelX: () => {
+ filter.convolution.call(this, [
+ -1,
+ 0,
+ 1,
+ -2,
+ 0,
+ 2,
+ -1,
+ 0,
+ 1
+ ]);
+ },
+ sobelY: () => {
+ filter.convolution.call(this, [
+ -1,
+ -2,
+ -1,
+ 0,
+ 0,
+ 0,
+ 1,
+ 2,
+ 1
+ ]);
+ },
+ sharpen: (amount) => {
+ const a = amount || 1;
+ filter.convolution.call(this, [
+ 0,
+ -1 * a,
+ 0,
+ -1 * a,
+ 1 + 4 * a,
+ -1 * a,
+ 0,
+ -1 * a,
+ 0
+ ]);
+ },
+ emboss: (size2) => {
+ const s = size2 || 1;
+ filter.convolution.call(this, [
+ -2 * s,
+ -1 * s,
+ 0,
+ -1 * s,
+ 1,
+ 1 * s,
+ 0,
+ 1 * s,
+ 2 * s
+ ]);
+ },
+ blur: (size2) => {
+ const blurSizeX = size2 / 7 / fxcanvas.width;
+ const blurSizeY = size2 / 7 / fxcanvas.height;
+ const program = compileShader(blur);
+ if (!program)
+ return;
+ gl.uniform2f(program.uniform["px"], 0, blurSizeY);
+ draw(DRAW.INTERMEDIATE);
+ gl.uniform2f(program.uniform["px"], blurSizeX, 0);
+ draw();
+ },
+ pixelate: (size2) => {
+ const blurSizeX = size2 / fxcanvas.width;
+ const blurSizeY = size2 / fxcanvas.height;
+ const program = compileShader(pixelate);
+ if (!program)
+ return;
+ gl.uniform2f(program.uniform["size"], blurSizeX, blurSizeY);
+ draw();
+ }
+ };
+ this.add = function(name) {
+ const args = Array.prototype.slice.call(arguments, 1);
+ const func = filter[name];
+ filterChain.push({ func, args });
+ };
+ this.reset = function() {
+ filterChain = [];
+ };
+ this.get = function() {
+ return filterChain;
+ };
+ this.apply = function(image28) {
+ resize(image28.width, image28.height);
+ drawCount = 0;
+ if (!sourceTexture)
+ sourceTexture = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, sourceTexture);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image28);
+ for (let i = 0; i < filterChain.length; i++) {
+ lastInChain = i === filterChain.length - 1;
+ const f = filterChain[i];
+ f.func.apply(this, f.args || []);
+ }
+ return fxcanvas;
+ };
+ this.draw = function(image28) {
+ this.add("brightness", 0);
+ return this.apply(image28);
+ };
+}
+
+// src/image/enhance.ts
+async function histogramEqualization(inputImage) {
+ const squeeze14 = inputImage.shape.length === 4 ? tfjs_esm_exports.squeeze(inputImage) : inputImage;
+ const rgb2 = tfjs_esm_exports.split(squeeze14, 3, 2);
+ const min2 = [tfjs_esm_exports.min(rgb2[0]), tfjs_esm_exports.min(rgb2[1]), tfjs_esm_exports.min(rgb2[2])];
+ const max5 = [tfjs_esm_exports.max(rgb2[0]), tfjs_esm_exports.max(rgb2[1]), tfjs_esm_exports.max(rgb2[2])];
+ const absMax = await Promise.all(max5.map((channel) => channel.data()));
+ const maxValue = Math.max(absMax[0][0], absMax[1][0], absMax[2][0]);
+ const maxRange = maxValue > 1 ? 255 : 1;
+ const factor = maxRange / maxValue;
+ let final;
+ if (factor > 1) {
+ const sub11 = [tfjs_esm_exports.sub(rgb2[0], min2[0]), tfjs_esm_exports.sub(rgb2[1], min2[1]), tfjs_esm_exports.sub(rgb2[2], min2[2])];
+ const range = [tfjs_esm_exports.sub(max5[0], min2[0]), tfjs_esm_exports.sub(max5[1], min2[1]), tfjs_esm_exports.sub(max5[2], min2[2])];
+ const enh = [tfjs_esm_exports.mul(sub11[0], factor), tfjs_esm_exports.mul(sub11[1], factor), tfjs_esm_exports.mul(sub11[2], factor)];
+ const stack5 = tfjs_esm_exports.stack([enh[0], enh[1], enh[2]], 2);
+ final = tfjs_esm_exports.reshape(stack5, [1, squeeze14.shape[0] || 0, squeeze14.shape[1] || 0, 3]);
+ tfjs_esm_exports.dispose([...sub11, ...range, ...enh]);
+ } else {
+ final = tfjs_esm_exports.expandDims(squeeze14, 0);
+ }
+ tfjs_esm_exports.dispose([...rgb2, ...min2, ...max5, rgb2, squeeze14, inputImage]);
+ return final;
+}
+
+// src/image/image.ts
+var maxSize = 3840;
+var inCanvas = null;
+var outCanvas = null;
+var tmpCanvas = null;
+var fx;
+var last = {
+ inputSum: 0,
+ cacheDiff: 1,
+ sumMethod: 0,
+ inputTensor: void 0
+};
+function reset() {
+ last.inputSum = 0;
+ last.cacheDiff = 1;
+ last.sumMethod = 0;
+ last.inputTensor = void 0;
+}
+function canvas(width, height) {
+ let c;
+ if (env.browser) {
+ if (env.worker) {
+ if (typeof OffscreenCanvas === "undefined")
+ throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");
+ c = new OffscreenCanvas(width, height);
+ } else {
+ if (typeof document === "undefined")
+ throw new Error("canvas error: attempted to run in browser but DOM is not defined");
+ c = document.createElement("canvas");
+ c.width = width;
+ c.height = height;
+ }
+ } else {
+ if (typeof env.Canvas !== "undefined")
+ c = new env.Canvas(width, height);
+ else if (typeof globalThis.Canvas !== "undefined")
+ c = new globalThis.Canvas(width, height);
+ }
+ return c;
+}
+function copy(input, output) {
+ const outputCanvas = output || canvas(input.width, input.height);
+ const ctx = outputCanvas.getContext("2d");
+ ctx.drawImage(input, 0, 0);
+ return outputCanvas;
+}
+async function process2(input, config3, getTensor = true) {
+ var _a, _b, _c;
+ if (!input) {
+ if (config3.debug)
+ log("input error: input is missing");
+ return { tensor: null, canvas: null };
+ }
+ if (!(input instanceof tfjs_esm_exports.Tensor) && !(typeof Image !== "undefined" && input instanceof Image) && !(typeof env.Canvas !== "undefined" && input instanceof env.Canvas) && !(typeof globalThis.Canvas !== "undefined" && input instanceof globalThis.Canvas) && !(typeof ImageData !== "undefined" && input instanceof ImageData) && !(typeof ImageBitmap !== "undefined" && input instanceof ImageBitmap) && !(typeof HTMLImageElement !== "undefined" && input instanceof HTMLImageElement) && !(typeof HTMLMediaElement !== "undefined" && input instanceof HTMLMediaElement) && !(typeof HTMLVideoElement !== "undefined" && input instanceof HTMLVideoElement) && !(typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement) && !(typeof OffscreenCanvas !== "undefined" && input instanceof OffscreenCanvas)) {
+ throw new Error("input error: type is not recognized");
+ }
+ if (input instanceof tfjs_esm_exports.Tensor) {
+ let tensor7 = null;
+ if (input["isDisposedInternal"])
+ throw new Error("input error: attempted to use tensor but it is disposed");
+ if (!input.shape)
+ throw new Error("input error: attempted to use tensor without a shape");
+ if (input.shape.length === 3) {
+ if (input.shape[2] === 3) {
+ tensor7 = tfjs_esm_exports.expandDims(input, 0);
+ } else if (input.shape[2] === 4) {
+ const rgb2 = tfjs_esm_exports.slice3d(input, [0, 0, 0], [-1, -1, 3]);
+ tensor7 = tfjs_esm_exports.expandDims(rgb2, 0);
+ tfjs_esm_exports.dispose(rgb2);
+ }
+ } else if (input.shape.length === 4) {
+ if (input.shape[3] === 3) {
+ tensor7 = tfjs_esm_exports.clone(input);
+ } else if (input.shape[3] === 4) {
+ tensor7 = tfjs_esm_exports.slice4d(input, [0, 0, 0, 0], [-1, -1, -1, 3]);
+ }
+ }
+ if (tensor7 == null || tensor7.shape.length !== 4 || tensor7.shape[0] !== 1 || tensor7.shape[3] !== 3)
+ throw new Error(`input error: attempted to use tensor with unrecognized shape: ${input.shape.toString()}`);
+ if (tensor7.dtype === "int32") {
+ const cast8 = tfjs_esm_exports.cast(tensor7, "float32");
+ tfjs_esm_exports.dispose(tensor7);
+ tensor7 = cast8;
+ }
+ return { tensor: tensor7, canvas: config3.filter.return ? outCanvas : null };
+ }
+ if (typeof input["readyState"] !== "undefined" && input.readyState <= 2) {
+ if (config3.debug)
+ log("input stream is not ready");
+ return { tensor: null, canvas: inCanvas };
+ }
+ const originalWidth = input["naturalWidth"] || input["videoWidth"] || input["width"] || input["shape"] && input["shape"][1] > 0;
+ const originalHeight = input["naturalHeight"] || input["videoHeight"] || input["height"] || input["shape"] && input["shape"][2] > 0;
+ if (!originalWidth || !originalHeight) {
+ if (config3.debug)
+ log("cannot determine input dimensions");
+ return { tensor: null, canvas: inCanvas };
+ }
+ let targetWidth = originalWidth;
+ let targetHeight = originalHeight;
+ if (targetWidth > maxSize) {
+ targetWidth = maxSize;
+ targetHeight = Math.trunc(targetWidth * originalHeight / originalWidth);
+ }
+ if (targetHeight > maxSize) {
+ targetHeight = maxSize;
+ targetWidth = Math.trunc(targetHeight * originalWidth / originalHeight);
+ }
+ if ((((_a = config3.filter) == null ? void 0 : _a.width) || 0) > 0)
+ targetWidth = config3.filter.width;
+ else if ((((_b = config3.filter) == null ? void 0 : _b.height) || 0) > 0)
+ targetWidth = originalWidth * ((config3.filter.height || 0) / originalHeight);
+ if ((config3.filter.height || 0) > 0)
+ targetHeight = config3.filter.height;
+ else if ((config3.filter.width || 0) > 0)
+ targetHeight = originalHeight * ((config3.filter.width || 0) / originalWidth);
+ if (!targetWidth || !targetHeight)
+ throw new Error("input error: cannot determine dimension");
+ if (!inCanvas || inCanvas.width !== targetWidth || inCanvas.height !== targetHeight)
+ inCanvas = canvas(targetWidth, targetHeight);
+ const inCtx = inCanvas.getContext("2d");
+ if (typeof ImageData !== "undefined" && input instanceof ImageData) {
+ inCtx.putImageData(input, 0, 0);
+ } else {
+ if (config3.filter.flip && typeof inCtx.translate !== "undefined") {
+ inCtx.translate(originalWidth, 0);
+ inCtx.scale(-1, 1);
+ inCtx.drawImage(input, 0, 0, originalWidth, originalHeight, 0, 0, inCanvas.width, inCanvas.height);
+ inCtx.setTransform(1, 0, 0, 1, 0, 0);
+ } else {
+ inCtx.drawImage(input, 0, 0, originalWidth, originalHeight, 0, 0, inCanvas.width, inCanvas.height);
+ }
+ }
+ if (!outCanvas || inCanvas.width !== outCanvas.width || inCanvas.height !== outCanvas.height)
+ outCanvas = canvas(inCanvas.width, inCanvas.height);
+ if (config3.filter.enabled && env.webgl.supported) {
+ if (!fx)
+ fx = env.browser ? new GLImageFilter() : null;
+ env.filter = !!fx;
+ if (!(fx == null ? void 0 : fx.add)) {
+ if (config3.debug)
+ log("input process error: cannot initialize filters");
+ env.webgl.supported = false;
+ config3.filter.enabled = false;
+ copy(inCanvas, outCanvas);
+ } else {
+ fx.reset();
+ if (config3.filter.brightness !== 0)
+ fx.add("brightness", config3.filter.brightness);
+ if (config3.filter.contrast !== 0)
+ fx.add("contrast", config3.filter.contrast);
+ if (config3.filter.sharpness !== 0)
+ fx.add("sharpen", config3.filter.sharpness);
+ if (config3.filter.blur !== 0)
+ fx.add("blur", config3.filter.blur);
+ if (config3.filter.saturation !== 0)
+ fx.add("saturation", config3.filter.saturation);
+ if (config3.filter.hue !== 0)
+ fx.add("hue", config3.filter.hue);
+ if (config3.filter.negative)
+ fx.add("negative");
+ if (config3.filter.sepia)
+ fx.add("sepia");
+ if (config3.filter.vintage)
+ fx.add("brownie");
+ if (config3.filter.sepia)
+ fx.add("sepia");
+ if (config3.filter.kodachrome)
+ fx.add("kodachrome");
+ if (config3.filter.technicolor)
+ fx.add("technicolor");
+ if (config3.filter.polaroid)
+ fx.add("polaroid");
+ if (config3.filter.pixelate !== 0)
+ fx.add("pixelate", config3.filter.pixelate);
+ if (((_c = fx.get()) == null ? void 0 : _c.length) > 1)
+ outCanvas = fx.apply(inCanvas);
+ else
+ outCanvas = fx.draw(inCanvas);
+ }
+ } else {
+ copy(inCanvas, outCanvas);
+ if (fx)
+ fx = null;
+ env.filter = !!fx;
+ }
+ if (!getTensor)
+ return { tensor: null, canvas: outCanvas };
+ if (!outCanvas)
+ throw new Error("canvas error: cannot create output");
+ let pixels;
+ let depth = 3;
+ if (typeof ImageData !== "undefined" && input instanceof ImageData || input.data && input.width && input.height) {
+ if (env.browser && tfjs_esm_exports.browser) {
+ pixels = tfjs_esm_exports.browser ? tfjs_esm_exports.browser.fromPixels(input) : null;
+ } else {
+ depth = input.data.length / input.height / input.width;
+ const arr = new Uint8Array(input.data.buffer);
+ pixels = tfjs_esm_exports.tensor(arr, [input.height, input.width, depth], "int32");
+ }
+ } else {
+ if (!tmpCanvas || outCanvas.width !== tmpCanvas.width || outCanvas.height !== tmpCanvas.height)
+ tmpCanvas = canvas(outCanvas.width, outCanvas.height);
+ if (tfjs_esm_exports.browser && env.browser) {
+ if (config3.backend === "webgl" || config3.backend === "humangl" || config3.backend === "webgpu") {
+ pixels = tfjs_esm_exports.browser.fromPixels(outCanvas);
+ } else {
+ tmpCanvas = copy(outCanvas);
+ pixels = tfjs_esm_exports.browser.fromPixels(tmpCanvas);
+ }
+ } else {
+ const tempCanvas = copy(outCanvas);
+ const tempCtx = tempCanvas.getContext("2d");
+ const tempData = tempCtx.getImageData(0, 0, targetWidth, targetHeight);
+ depth = tempData.data.length / targetWidth / targetHeight;
+ const arr = new Uint8Array(tempData.data.buffer);
+ pixels = tfjs_esm_exports.tensor(arr, [targetWidth, targetHeight, depth]);
+ }
+ }
+ if (depth === 4) {
+ const rgb2 = tfjs_esm_exports.slice3d(pixels, [0, 0, 0], [-1, -1, 3]);
+ tfjs_esm_exports.dispose(pixels);
+ pixels = rgb2;
+ }
+ if (!pixels)
+ throw new Error("input error: cannot create tensor");
+ const casted = tfjs_esm_exports.cast(pixels, "float32");
+ const tensor6 = config3.filter.equalization ? await histogramEqualization(casted) : tfjs_esm_exports.expandDims(casted, 0);
+ tfjs_esm_exports.dispose([pixels, casted]);
+ if (config3.filter.autoBrightness) {
+ const max5 = tfjs_esm_exports.max(tensor6);
+ const maxVal = await max5.data();
+ config3.filter.brightness = maxVal[0] > 1 ? 1 - maxVal[0] / 255 : 1 - maxVal[0];
+ tfjs_esm_exports.dispose(max5);
+ }
+ return { tensor: tensor6, canvas: config3.filter.return ? outCanvas : null };
+}
+async function skip(config3, input) {
+ let skipFrame = false;
+ if (config3.cacheSensitivity === 0 || !input.shape || input.shape.length !== 4 || input.shape[1] > 3840 || input.shape[2] > 2160)
+ return skipFrame;
+ if (!last.inputTensor) {
+ last.inputTensor = tfjs_esm_exports.clone(input);
+ } else if (last.inputTensor.shape[1] !== input.shape[1] || last.inputTensor.shape[2] !== input.shape[2]) {
+ tfjs_esm_exports.dispose(last.inputTensor);
+ last.inputTensor = tfjs_esm_exports.clone(input);
+ } else {
+ const t2 = {};
+ t2.diff = tfjs_esm_exports.sub(input, last.inputTensor);
+ t2.squared = tfjs_esm_exports.mul(t2.diff, t2.diff);
+ t2.sum = tfjs_esm_exports.sum(t2.squared);
+ const diffSum = await t2.sum.data();
+ const diffRelative = diffSum[0] / (input.shape[1] || 1) / (input.shape[2] || 1) / 255 / 3;
+ tfjs_esm_exports.dispose([last.inputTensor, t2.diff, t2.squared, t2.sum]);
+ last.inputTensor = tfjs_esm_exports.clone(input);
+ skipFrame = diffRelative <= (config3.cacheSensitivity || 0);
+ }
+ return skipFrame;
+}
+async function compare(config3, input1, input2) {
+ const t2 = {};
+ if (!input1 || !input2 || input1.shape.length !== 4 || input1.shape.length !== input2.shape.length) {
+ if (!config3.debug)
+ log("invalid input tensor or tensor shapes do not match:", input1.shape, input2.shape);
+ return 0;
+ }
+ if (input1.shape[0] !== 1 || input2.shape[0] !== 1 || input1.shape[3] !== 3 || input2.shape[3] !== 3) {
+ if (!config3.debug)
+ log("input tensors must be of shape [1, height, width, 3]:", input1.shape, input2.shape);
+ return 0;
+ }
+ t2.input1 = tfjs_esm_exports.clone(input1);
+ t2.input2 = input1.shape[1] !== input2.shape[1] || input1.shape[2] !== input2.shape[2] ? tfjs_esm_exports.image.resizeBilinear(input2, [input1.shape[1], input1.shape[2]]) : tfjs_esm_exports.clone(input2);
+ t2.diff = tfjs_esm_exports.sub(t2.input1, t2.input2);
+ t2.squared = tfjs_esm_exports.mul(t2.diff, t2.diff);
+ t2.sum = tfjs_esm_exports.sum(t2.squared);
+ const diffSum = await t2.sum.data();
+ const diffRelative = diffSum[0] / (input1.shape[1] || 1) / (input1.shape[2] || 1) / 255 / 3;
+ tfjs_esm_exports.dispose([t2.input1, t2.input2, t2.diff, t2.squared, t2.sum]);
+ return diffRelative;
+}
+
+// src/util/env.ts
+var Env = class {
+ constructor() {
+ __publicField(this, "browser");
+ __publicField(this, "node");
+ __publicField(this, "worker");
+ __publicField(this, "platform", "");
+ __publicField(this, "agent", "");
+ __publicField(this, "backends", []);
+ __publicField(this, "initial");
+ __publicField(this, "filter");
+ __publicField(this, "tfjs");
+ __publicField(this, "offscreen");
+ __publicField(this, "perfadd", false);
+ __publicField(this, "tensorflow", {
+ version: void 0,
+ gpu: void 0
+ });
+ __publicField(this, "wasm", {
+ supported: void 0,
+ backend: void 0,
+ simd: void 0,
+ multithread: void 0
+ });
+ __publicField(this, "webgl", {
+ supported: void 0,
+ backend: void 0,
+ version: void 0,
+ renderer: void 0,
+ shader: void 0,
+ vendor: void 0
+ });
+ __publicField(this, "webgpu", {
+ supported: void 0,
+ backend: void 0,
+ adapter: void 0
+ });
+ __publicField(this, "cpu", {
+ model: void 0,
+ flags: []
+ });
+ __publicField(this, "kernels", []);
+ __publicField(this, "Canvas");
+ __publicField(this, "Image");
+ __publicField(this, "ImageData");
+ this.browser = typeof navigator !== "undefined";
+ this.node = typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined";
+ this.tfjs = { version: version7["tfjs-core"] };
+ this.offscreen = typeof OffscreenCanvas !== "undefined";
+ this.initial = true;
+ this.worker = this.browser && this.offscreen ? typeof WorkerGlobalScope !== "undefined" : void 0;
+ if (typeof navigator !== "undefined") {
+ const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
+ if (raw == null ? void 0 : raw[0]) {
+ const platformMatch = raw[0].match(/\(([^()]+)\)/g);
+ this.platform = (platformMatch == null ? void 0 : platformMatch[0]) ? platformMatch[0].replace(/\(|\)/g, "") : "";
+ this.agent = navigator.userAgent.replace(raw[0], "");
+ if (this.platform[1])
+ this.agent = this.agent.replace(raw[1], "");
+ this.agent = this.agent.replace(/ /g, " ");
+ }
+ } else if (typeof process !== "undefined") {
+ this.platform = `${process.platform} ${process.arch}`;
+ this.agent = `NodeJS ${process.version}`;
+ }
+ }
+ async updateBackend() {
+ this.backends = Object.keys(tfjs_esm_exports.engine().registryFactory);
+ try {
+ this.tensorflow = {
+ version: tfjs_esm_exports.backend()["binding"] ? tfjs_esm_exports.backend()["binding"].TF_Version : void 0,
+ gpu: tfjs_esm_exports.backend()["binding"] ? tfjs_esm_exports.backend()["binding"].isUsingGpuDevice() : void 0
+ };
+ } catch (e) {
+ }
+ this.wasm.supported = typeof WebAssembly !== "undefined";
+ this.wasm.backend = this.backends.includes("wasm");
+ if (this.wasm.supported && this.wasm.backend) {
+ this.wasm.simd = await tfjs_esm_exports.env().getAsync("WASM_HAS_SIMD_SUPPORT");
+ this.wasm.multithread = await tfjs_esm_exports.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");
+ }
+ const c = canvas(100, 100);
+ const gl = c ? c.getContext("webgl2") : void 0;
+ this.webgl.supported = typeof gl !== "undefined";
+ this.webgl.backend = this.backends.includes("webgl");
+ if (this.webgl.supported && this.webgl.backend && gl) {
+ this.webgl.version = gl.getParameter(gl.VERSION);
+ this.webgl.vendor = gl.getParameter(gl.VENDOR);
+ this.webgl.renderer = gl.getParameter(gl.RENDERER);
+ this.webgl.shader = gl.getParameter(gl.SHADING_LANGUAGE_VERSION);
+ }
+ this.webgpu.supported = this.browser && typeof navigator.gpu !== "undefined";
+ this.webgpu.backend = this.backends.includes("webgpu");
+ try {
+ if (this.webgpu.supported) {
+ const adapter = await navigator.gpu.requestAdapter();
+ this.webgpu.adapter = await (adapter == null ? void 0 : adapter.requestAdapterInfo());
+ }
+ } catch (e) {
+ this.webgpu.supported = false;
+ }
+ try {
+ this.kernels = tfjs_esm_exports.getKernelsForBackend(tfjs_esm_exports.getBackend()).map((kernel) => kernel.kernelName.toLowerCase());
+ } catch (e) {
+ }
+ }
+ updateCPU() {
+ const cpu = { model: "", flags: [] };
+ if (this.node && this.platform.startsWith("linux")) {
+ }
+ if (!this.cpu)
+ Object.defineProperty(this, "cpu", { value: cpu });
+ else
+ this.cpu = cpu;
+ }
+};
+var env = new Env();
+
+// src/util/webcam.ts
+var WebCam = class {
+ constructor() {
+ __publicField(this, "config");
+ __publicField(this, "element");
+ __publicField(this, "stream");
+ __publicField(this, "devices", []);
+ __publicField(this, "enumerate", async () => {
+ try {
+ const devices = await navigator.mediaDevices.enumerateDevices();
+ this.devices = devices.filter((device) => device.kind === "videoinput");
+ } catch (e) {
+ this.devices = [];
+ }
+ return this.devices;
+ });
+ __publicField(this, "start", async (webcamConfig) => {
+ if (webcamConfig == null ? void 0 : webcamConfig.debug)
+ this.config.debug = webcamConfig == null ? void 0 : webcamConfig.debug;
+ if (webcamConfig == null ? void 0 : webcamConfig.crop)
+ this.config.crop = webcamConfig == null ? void 0 : webcamConfig.crop;
+ if (webcamConfig == null ? void 0 : webcamConfig.mode)
+ this.config.mode = webcamConfig == null ? void 0 : webcamConfig.mode;
+ if (webcamConfig == null ? void 0 : webcamConfig.width)
+ this.config.width = webcamConfig == null ? void 0 : webcamConfig.width;
+ if (webcamConfig == null ? void 0 : webcamConfig.height)
+ this.config.height = webcamConfig == null ? void 0 : webcamConfig.height;
+ if (webcamConfig == null ? void 0 : webcamConfig.id)
+ this.config.id = webcamConfig == null ? void 0 : webcamConfig.id;
+ if (webcamConfig == null ? void 0 : webcamConfig.element) {
+ if (typeof webcamConfig.element === "string") {
+ const el = document.getElementById(webcamConfig.element);
+ if (el && el instanceof HTMLVideoElement) {
+ this.element = el;
+ } else {
+ if (this.config.debug)
+ log("webcam", "cannot get dom element", webcamConfig.element);
+ return;
+ }
+ } else if (webcamConfig.element instanceof HTMLVideoElement) {
+ this.element = webcamConfig.element;
+ } else {
+ if (this.config.debug)
+ log("webcam", "unknown dom element", webcamConfig.element);
+ return;
+ }
+ } else {
+ this.element = document.createElement("video");
+ }
+ const requestedConstraints = {
+ audio: false,
+ video: {
+ facingMode: this.config.mode === "front" ? "user" : "environment",
+ resizeMode: this.config.crop ? "crop-and-scale" : "none",
+ width: { ideal: this.config.width > 0 ? this.config.width : window.innerWidth },
+ height: { ideal: this.config.height > 0 ? this.config.height : window.innerHeight }
+ }
+ };
+ if (this.config.id)
+ requestedConstraints.video.deviceId = this.config.id;
+ this.element.addEventListener("play", () => {
+ if (this.config.debug)
+ log("webcam", "play");
+ });
+ this.element.addEventListener("pause", () => {
+ if (this.config.debug)
+ log("webcam", "pause");
+ });
+ this.element.addEventListener("click", async () => {
+ if (!this.element || !this.stream)
+ return;
+ if (this.element.paused)
+ await this.element.play();
+ else
+ this.element.pause();
+ });
+ if (!(navigator == null ? void 0 : navigator.mediaDevices)) {
+ if (this.config.debug)
+ log("webcam", "no devices");
+ return;
+ }
+ try {
+ this.stream = await navigator.mediaDevices.getUserMedia(requestedConstraints);
+ } catch (err) {
+ log("webcam", err);
+ return;
+ }
+ if (!this.stream) {
+ if (this.config.debug)
+ log("webcam", "no stream");
+ return;
+ }
+ this.element.srcObject = this.stream;
+ const ready3 = new Promise((resolve) => {
+ if (!this.element)
+ resolve(false);
+ else
+ this.element.onloadeddata = () => resolve(true);
+ });
+ await ready3;
+ await this.element.play();
+ if (this.config.debug) {
+ log("webcam", {
+ width: this.width,
+ height: this.height,
+ label: this.label,
+ stream: this.stream,
+ track: this.track,
+ settings: this.settings,
+ constraints: this.constraints,
+ capabilities: this.capabilities
+ });
+ }
+ });
+ __publicField(this, "pause", () => {
+ if (this.element)
+ this.element.pause();
+ });
+ __publicField(this, "play", async () => {
+ if (this.element)
+ await this.element.play();
+ });
+ __publicField(this, "stop", () => {
+ if (this.config.debug)
+ log("webcam", "stop");
+ if (this.track)
+ this.track.stop();
+ });
+ this.config = {
+ element: void 0,
+ debug: true,
+ mode: "front",
+ crop: false,
+ width: 0,
+ height: 0
+ };
+ }
+ get track() {
+ if (!this.stream)
+ return void 0;
+ return this.stream.getVideoTracks()[0];
+ }
+ get capabilities() {
+ if (!this.track)
+ return void 0;
+ return this.track.getCapabilities ? this.track.getCapabilities() : void 0;
+ }
+ get constraints() {
+ if (!this.track)
+ return void 0;
+ return this.track.getConstraints ? this.track.getConstraints() : void 0;
+ }
+ get settings() {
+ if (!this.stream)
+ return void 0;
+ const track = this.stream.getVideoTracks()[0];
+ return track.getSettings ? track.getSettings() : void 0;
+ }
+ get label() {
+ if (!this.track)
+ return "";
+ return this.track.label;
+ }
+ get paused() {
+ var _a;
+ return ((_a = this.element) == null ? void 0 : _a.paused) || false;
+ }
+ get width() {
+ var _a;
+ return ((_a = this.element) == null ? void 0 : _a.videoWidth) || 0;
+ }
+ get height() {
+ var _a;
+ return ((_a = this.element) == null ? void 0 : _a.videoHeight) || 0;
+ }
+};
+
+// models/models.json
+var models_exports = {};
+__export(models_exports, {
+ age: () => age,
+ "anti-spoofing": () => anti_spoofing,
+ antispoof: () => antispoof,
+ blazeface: () => blazeface,
+ "blazeface-back": () => blazeface_back,
+ "blazeface-front": () => blazeface_front,
+ "blazepose-detector": () => blazepose_detector,
+ "blazepose-detector2d": () => blazepose_detector2d,
+ "blazepose-detector3d": () => blazepose_detector3d,
+ "blazepose-full": () => blazepose_full,
+ "blazepose-heavy": () => blazepose_heavy,
+ "blazepose-lite": () => blazepose_lite,
+ centernet: () => centernet,
+ default: () => models_default,
+ efficientpose: () => efficientpose,
+ "efficientpose-i-lite": () => efficientpose_i_lite,
+ "efficientpose-ii-lite": () => efficientpose_ii_lite,
+ "efficientpose-iv": () => efficientpose_iv,
+ emotion: () => emotion,
+ faceboxes: () => faceboxes,
+ facemesh: () => facemesh,
+ "facemesh-attention": () => facemesh_attention,
+ "facemesh-attention-alt": () => facemesh_attention_alt,
+ "facemesh-detection-full": () => facemesh_detection_full,
+ "facemesh-detection-short": () => facemesh_detection_short,
+ "facemesh-orig": () => facemesh_orig,
+ faceres: () => faceres,
+ "faceres-deep": () => faceres_deep,
+ gear: () => gear,
+ gender: () => gender,
+ "gender-ssrnet-imdb": () => gender_ssrnet_imdb,
+ handdetect: () => handdetect,
+ "handlandmark-full": () => handlandmark_full,
+ "handlandmark-lite": () => handlandmark_lite,
+ "handlandmark-sparse": () => handlandmark_sparse,
+ handskeleton: () => handskeleton,
+ handtrack: () => handtrack,
+ "insightface-efficientnet-b0": () => insightface_efficientnet_b0,
+ "insightface-ghostnet-strides1": () => insightface_ghostnet_strides1,
+ "insightface-ghostnet-strides2": () => insightface_ghostnet_strides2,
+ "insightface-mobilenet-emore": () => insightface_mobilenet_emore,
+ "insightface-mobilenet-swish": () => insightface_mobilenet_swish,
+ iris: () => iris,
+ liveness: () => liveness,
+ meet: () => meet,
+ mobileface: () => mobileface,
+ mobilefacenet: () => mobilefacenet,
+ models: () => models,
+ "movenet-lightning": () => movenet_lightning,
+ "movenet-multipose": () => movenet_multipose,
+ "movenet-thunder": () => movenet_thunder,
+ nanodet: () => nanodet,
+ "nanodet-e": () => nanodet_e,
+ "nanodet-g": () => nanodet_g,
+ "nanodet-m": () => nanodet_m,
+ "nanodet-t": () => nanodet_t,
+ posenet: () => posenet,
+ rvm: () => rvm,
+ selfie: () => selfie
+});
+var antispoof = 853098;
+var blazeface = 538928;
+var centernet = 4030290;
+var emotion = 820516;
+var facemesh = 1477958;
+var faceres = 6978814;
+var handlandmark_full = 5431368;
+var handtrack = 2964837;
+var iris = 2599092;
+var liveness = 592976;
+var models = 0;
+var movenet_lightning = 4650216;
+var age = 161240;
+var blazeface_back = 538928;
+var blazeface_front = 402048;
+var blazepose_detector2d = 7499400;
+var blazepose_detector3d = 5928856;
+var blazepose_full = 6338290;
+var blazepose_heavy = 27501554;
+var blazepose_lite = 2725490;
+var efficientpose = 5651240;
+var faceboxes = 2013002;
+var facemesh_attention_alt = 2387598;
+var facemesh_attention = 2382414;
+var facemesh_detection_full = 1026192;
+var facemesh_detection_short = 201268;
+var facemesh_orig = 2955780;
+var faceres_deep = 13957620;
+var gear = 1498916;
+var gender_ssrnet_imdb = 161236;
+var gender = 201808;
+var handdetect = 3515612;
+var handlandmark_lite = 2023432;
+var handlandmark_sparse = 5286322;
+var handskeleton = 5502280;
+var meet = 372228;
+var mobileface = 2183192;
+var mobilefacenet = 5171976;
+var movenet_multipose = 9448838;
+var movenet_thunder = 12477112;
+var nanodet = 7574558;
+var posenet = 5032780;
+var rvm = 3739355;
+var selfie = 212886;
+var blazepose_detector = 5928856;
+var anti_spoofing = 853098;
+var efficientpose_i_lite = 2269064;
+var efficientpose_ii_lite = 5651240;
+var efficientpose_iv = 25643252;
+var insightface_efficientnet_b0 = 13013224;
+var insightface_ghostnet_strides1 = 8093408;
+var insightface_ghostnet_strides2 = 8049584;
+var insightface_mobilenet_emore = 6938536;
+var insightface_mobilenet_swish = 12168584;
+var nanodet_e = 12319156;
+var nanodet_g = 7574558;
+var nanodet_m = 1887474;
+var nanodet_t = 5294216;
+var models_default = {
+ antispoof,
+ blazeface,
+ centernet,
+ emotion,
+ facemesh,
+ faceres,
+ "handlandmark-full": handlandmark_full,
+ handtrack,
+ iris,
+ liveness,
+ models,
+ "movenet-lightning": movenet_lightning,
+ age,
+ "blazeface-back": blazeface_back,
+ "blazeface-front": blazeface_front,
+ "blazepose-detector2d": blazepose_detector2d,
+ "blazepose-detector3d": blazepose_detector3d,
+ "blazepose-full": blazepose_full,
+ "blazepose-heavy": blazepose_heavy,
+ "blazepose-lite": blazepose_lite,
+ efficientpose,
+ faceboxes,
+ "facemesh-attention-alt": facemesh_attention_alt,
+ "facemesh-attention": facemesh_attention,
+ "facemesh-detection-full": facemesh_detection_full,
+ "facemesh-detection-short": facemesh_detection_short,
+ "facemesh-orig": facemesh_orig,
+ "faceres-deep": faceres_deep,
+ gear,
+ "gender-ssrnet-imdb": gender_ssrnet_imdb,
+ gender,
+ handdetect,
+ "handlandmark-lite": handlandmark_lite,
+ "handlandmark-sparse": handlandmark_sparse,
+ handskeleton,
+ meet,
+ mobileface,
+ mobilefacenet,
+ "movenet-multipose": movenet_multipose,
+ "movenet-thunder": movenet_thunder,
+ nanodet,
+ posenet,
+ rvm,
+ selfie,
+ "blazepose-detector": blazepose_detector,
+ "anti-spoofing": anti_spoofing,
+ "efficientpose-i-lite": efficientpose_i_lite,
+ "efficientpose-ii-lite": efficientpose_ii_lite,
+ "efficientpose-iv": efficientpose_iv,
+ "insightface-efficientnet-b0": insightface_efficientnet_b0,
+ "insightface-ghostnet-strides1": insightface_ghostnet_strides1,
+ "insightface-ghostnet-strides2": insightface_ghostnet_strides2,
+ "insightface-mobilenet-emore": insightface_mobilenet_emore,
+ "insightface-mobilenet-swish": insightface_mobilenet_swish,
+ "nanodet-e": nanodet_e,
+ "nanodet-g": nanodet_g,
+ "nanodet-m": nanodet_m,
+ "nanodet-t": nanodet_t
+};
+
+// src/tfjs/load.ts
+var options = {
+ cacheModels: true,
+ cacheSupported: true,
+ verbose: true,
+ debug: false,
+ modelBasePath: ""
+};
+var modelStats = {};
+async function httpHandler(url, init4) {
+ if (options.debug)
+ log("load model fetch:", url, init4);
+ return fetch(url, init4);
+}
+function setModelLoadOptions(config3) {
+ options.cacheModels = config3.cacheModels;
+ options.verbose = config3.debug;
+ options.modelBasePath = config3.modelBasePath;
+}
+async function loadModel(modelPath) {
+ var _a, _b, _c, _d;
+ let modelUrl = join(options.modelBasePath, modelPath || "");
+ if (!modelUrl.toLowerCase().endsWith(".json"))
+ modelUrl += ".json";
+ const modelPathSegments = modelUrl.includes("/") ? modelUrl.split("/") : modelUrl.split("\\");
+ const shortModelName = modelPathSegments[modelPathSegments.length - 1].replace(".json", "");
+ const cachedModelName = "indexeddb://" + shortModelName;
+ modelStats[shortModelName] = {
+ name: shortModelName,
+ sizeFromManifest: 0,
+ sizeLoadedWeights: 0,
+ sizeDesired: models_exports[shortModelName],
+ inCache: false,
+ url: ""
+ };
+ options.cacheSupported = typeof indexedDB !== "undefined";
+ let cachedModels = {};
+ try {
+ cachedModels = options.cacheSupported && options.cacheModels ? await tfjs_esm_exports.io.listModels() : {};
+ } catch (e) {
+ options.cacheSupported = false;
+ }
+ modelStats[shortModelName].inCache = options.cacheSupported && options.cacheModels && Object.keys(cachedModels).includes(cachedModelName);
+ modelStats[shortModelName].url = modelStats[shortModelName].inCache ? cachedModelName : modelUrl;
+ const tfLoadOptions = typeof fetch === "undefined" ? {} : { fetchFunc: (url, init4) => httpHandler(url, init4) };
+ let model23 = new tfjs_esm_exports.GraphModel(modelStats[shortModelName].url, tfLoadOptions);
+ let loaded = false;
+ try {
+ model23.findIOHandler();
+ if (options.debug)
+ log("model load handler:", model23["handler"]);
+ } catch (err) {
+ log("error finding model i/o handler:", modelUrl, err);
+ }
+ try {
+ const artifacts = await ((_a = model23.handler) == null ? void 0 : _a.load()) || null;
+ modelStats[shortModelName].sizeFromManifest = ((_b = artifacts == null ? void 0 : artifacts.weightData) == null ? void 0 : _b.byteLength) || 0;
+ if (artifacts)
+ model23.loadSync(artifacts);
+ else
+ model23 = await tfjs_esm_exports.loadGraphModel(modelStats[shortModelName].inCache ? cachedModelName : modelUrl, tfLoadOptions);
+ modelStats[shortModelName].sizeLoadedWeights = ((_d = (_c = model23.artifacts) == null ? void 0 : _c.weightData) == null ? void 0 : _d.byteLength) || 0;
+ if (options.verbose)
+ log("load:", { model: shortModelName, url: model23["modelUrl"], bytes: modelStats[shortModelName].sizeLoadedWeights });
+ loaded = true;
+ } catch (err) {
+ log("error loading model:", modelUrl, err);
+ }
+ if (loaded && options.cacheModels && options.cacheSupported && !modelStats[shortModelName].inCache) {
+ try {
+ const saveResult = await model23.save(cachedModelName);
+ if (options.debug)
+ log("model saved:", cachedModelName, saveResult);
+ } catch (err) {
+ log("error saving model:", modelUrl, err);
+ }
+ }
+ return model23;
+}
+
+// package.json
+var version8 = "3.0.0";
+
+// src/tfjs/humangl.ts
+var config2 = {
+ name: "humangl",
+ priority: 999,
+ canvas: null,
+ gl: null,
+ extensions: [],
+ webGLattr: {
+ alpha: false,
+ antialias: false,
+ premultipliedAlpha: false,
+ preserveDrawingBuffer: false,
+ depth: false,
+ stencil: false,
+ failIfMajorPerformanceCaveat: false,
+ desynchronized: true
+ }
+};
+function extensions() {
+ const gl = config2.gl;
+ if (!gl)
+ return;
+ config2.extensions = gl.getSupportedExtensions();
+}
+function register(instance) {
+ var _a;
+ if (instance.config.backend !== "humangl")
+ return;
+ if (config2.name in tfjs_esm_exports.engine().registry && !((_a = config2 == null ? void 0 : config2.gl) == null ? void 0 : _a.getParameter(config2.gl.VERSION))) {
+ log("humangl error: backend invalid context");
+ instance.models.reset();
+ }
+ if (!tfjs_esm_exports.findBackend(config2.name)) {
+ try {
+ config2.canvas = canvas(100, 100);
+ } catch (err) {
+ log("humangl error: cannot create canvas:", err);
+ return;
+ }
+ try {
+ config2.gl = config2.canvas.getContext("webgl2", config2.webGLattr);
+ if (!config2.gl) {
+ log("humangl error: cannot get webgl context");
+ return;
+ }
+ const glv2 = config2.gl.getParameter(config2.gl.VERSION).includes("2.0");
+ if (!glv2) {
+ log("backend override: using fallback webgl backend as webgl 2.0 is not detected");
+ instance.config.backend = "webgl";
+ return;
+ }
+ if (config2.canvas) {
+ config2.canvas.addEventListener("webglcontextlost", (e) => {
+ log("humangl error:", e.type);
+ log("possible browser memory leak using webgl or conflict with multiple backend registrations");
+ instance.emit("error");
+ throw new Error("backend error: webgl context lost");
+ });
+ config2.canvas.addEventListener("webglcontextrestored", (e) => {
+ log("humangl error: context restored:", e);
+ });
+ config2.canvas.addEventListener("webglcontextcreationerror", (e) => {
+ log("humangl error: context create:", e);
+ });
+ }
+ } catch (err) {
+ log("humangl error: cannot get webgl context:", err);
+ return;
+ }
+ try {
+ tfjs_esm_exports.setWebGLContext(2, config2.gl);
+ } catch (err) {
+ log("humangl error: cannot set webgl context:", err);
+ return;
+ }
+ try {
+ const ctx = new tfjs_esm_exports.GPGPUContext(config2.gl);
+ tfjs_esm_exports.registerBackend(config2.name, () => new tfjs_esm_exports.MathBackendWebGL(ctx), config2.priority);
+ } catch (err) {
+ log("humangl error: cannot register webgl backend:", err);
+ return;
+ }
+ try {
+ const kernels = tfjs_esm_exports.getKernelsForBackend("webgl");
+ kernels.forEach((kernelConfig) => {
+ const newKernelConfig = { ...kernelConfig, backendName: config2.name };
+ tfjs_esm_exports.registerKernel(newKernelConfig);
+ });
+ } catch (err) {
+ log("humangl error: cannot update webgl backend registration:", err);
+ return;
+ }
+ try {
+ if (tfjs_esm_exports.env().flagRegistry.WEBGL_VERSION)
+ tfjs_esm_exports.env().set("WEBGL_VERSION", 2);
+ } catch (err) {
+ log("humangl error: cannot set WebGL backend flags:", err);
+ return;
+ }
+ extensions();
+ const backend4 = tfjs_esm_exports.backend();
+ const current = typeof backend4["gpgpu"] !== "undefined" ? backend4["getGPGPUContext"]().gl : null;
+ if (current) {
+ if (instance.config.debug)
+ log("humangl backend registered:", { webgl: current.getParameter(current.VERSION), renderer: current.getParameter(current.RENDERER) });
+ } else {
+ log("humangl error: no current gl context:", current, config2.gl);
+ }
+ }
+}
+
+// src/tfjs/constants.ts
+var constants = {
+ tf255: 255,
+ tf1: 1,
+ tf2: 2,
+ tf05: 0.5,
+ tf127: 127.5,
+ rgb: [0.2989, 0.587, 0.114]
+};
+function init() {
+ constants.tf255 = tfjs_esm_exports.scalar(255, "float32");
+ constants.tf1 = tfjs_esm_exports.scalar(1, "float32");
+ constants.tf2 = tfjs_esm_exports.scalar(2, "float32");
+ constants.tf05 = tfjs_esm_exports.scalar(0.5, "float32");
+ constants.tf127 = tfjs_esm_exports.scalar(127.5, "float32");
+ constants.rgb = tfjs_esm_exports.tensor1d([0.2989, 0.587, 0.114], "float32");
+}
+
+// src/tfjs/backend.ts
+async function getBestBackend() {
+ await env.updateBackend();
+ if (!env.browser)
+ return "tensorflow";
+ if (env.webgpu.supported && env.webgpu.backend)
+ return "webgpu";
+ if (env.webgl.supported && env.webgl.backend)
+ return "webgl";
+ if (env.wasm.supported && env.wasm.backend)
+ return "wasm";
+ return "cpu";
+}
+function registerCustomOps(config3) {
+ const newKernels = [];
+ if (!env.kernels.includes("mod")) {
+ const kernelMod = {
+ kernelName: "Mod",
+ backendName: tfjs_esm_exports.getBackend(),
+ kernelFunc: (op) => tfjs_esm_exports.tidy(() => tfjs_esm_exports.sub(op.inputs.a, tfjs_esm_exports.mul(tfjs_esm_exports.div(op.inputs.a, op.inputs.b), op.inputs.b)))
+ };
+ tfjs_esm_exports.registerKernel(kernelMod);
+ env.kernels.push("mod");
+ newKernels.push("mod");
+ }
+ if (!env.kernels.includes("floormod")) {
+ const kernelFloorMod = {
+ kernelName: "FloorMod",
+ backendName: tfjs_esm_exports.getBackend(),
+ kernelFunc: (op) => tfjs_esm_exports.tidy(() => tfjs_esm_exports.add(tfjs_esm_exports.mul(tfjs_esm_exports.floorDiv(op.inputs.a, op.inputs.b), op.inputs.b), tfjs_esm_exports.mod(op.inputs.a, op.inputs.b)))
+ };
+ tfjs_esm_exports.registerKernel(kernelFloorMod);
+ env.kernels.push("floormod");
+ newKernels.push("floormod");
+ }
+ if (!env.kernels.includes("rotatewithoffset") && config3.softwareKernels) {
+ const kernelRotateWithOffset = {
+ kernelName: "RotateWithOffset",
+ backendName: tfjs_esm_exports.getBackend(),
+ kernelFunc: (op) => tfjs_esm_exports.tidy(() => {
+ const backend4 = tfjs_esm_exports.getBackend();
+ tfjs_esm_exports.setBackend("cpu");
+ const t2 = tfjs_esm_exports.image.rotateWithOffset(op.inputs.image, op.attrs.radians, op.attrs.fillValue, op.attrs.center);
+ tfjs_esm_exports.setBackend(backend4);
+ return t2;
+ })
+ };
+ tfjs_esm_exports.registerKernel(kernelRotateWithOffset);
+ env.kernels.push("rotatewithoffset");
+ newKernels.push("rotatewithoffset");
+ }
+ if (newKernels.length > 0 && config3.debug)
+ log("registered kernels:", newKernels);
+}
+var defaultFlags = {};
+async function check(instance, force = false) {
+ var _a;
+ instance.state = "backend";
+ if (((_a = instance.config.backend) == null ? void 0 : _a.length) === 0)
+ instance.config.backend = await getBestBackend();
+ if (force || env.initial || instance.config.backend && instance.config.backend.length > 0 && tfjs_esm_exports.getBackend() !== instance.config.backend) {
+ const timeStamp = now();
+ if (instance.config.backend && instance.config.backend.length > 0) {
+ if (typeof window === "undefined" && typeof WorkerGlobalScope !== "undefined" && instance.config.debug) {
+ if (instance.config.debug)
+ log("running inside web worker");
+ }
+ if (env.browser && instance.config.backend === "tensorflow") {
+ if (instance.config.debug)
+ log("override: backend set to tensorflow while running in browser");
+ instance.config.backend = "webgl";
+ }
+ if (env.node && (instance.config.backend === "webgl" || instance.config.backend === "humangl")) {
+ if (instance.config.debug)
+ log(`override: backend set to ${instance.config.backend} while running in nodejs`);
+ instance.config.backend = "tensorflow";
+ }
+ if (env.browser && instance.config.backend === "webgpu") {
+ if (typeof navigator === "undefined" || typeof navigator.gpu === "undefined") {
+ log("override: backend set to webgpu but browser does not support webgpu");
+ instance.config.backend = "webgl";
+ } else {
+ const adapter = await navigator.gpu.requestAdapter();
+ if (instance.config.debug)
+ log("enumerated webgpu adapter:", adapter);
+ if (!adapter) {
+ log("override: backend set to webgpu but browser reports no available gpu");
+ instance.config.backend = "webgl";
+ } else {
+ const adapterInfo = "requestAdapterInfo" in adapter ? await adapter.requestAdapterInfo() : void 0;
+ log("webgpu adapter info:", adapterInfo);
+ }
+ }
+ }
+ let available = Object.keys(tfjs_esm_exports.engine().registryFactory);
+ if (instance.config.backend === "humangl" && !available.includes("humangl")) {
+ register(instance);
+ available = Object.keys(tfjs_esm_exports.engine().registryFactory);
+ }
+ if (instance.config.debug)
+ log("available backends:", available);
+ if (!available.includes(instance.config.backend)) {
+ log(`error: backend ${instance.config.backend} not found in registry`);
+ instance.config.backend = env.node ? "tensorflow" : "webgl";
+ if (instance.config.debug)
+ log(`override: setting backend ${instance.config.backend}`);
+ }
+ if (instance.config.debug)
+ log("setting backend:", [instance.config.backend]);
+ if (instance.config.backend === "wasm") {
+ if (tfjs_esm_exports.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY)
+ tfjs_esm_exports.env().set("CANVAS2D_WILL_READ_FREQUENTLY", true);
+ if (instance.config.debug)
+ log("wasm path:", instance.config.wasmPath);
+ if (typeof tfjs_esm_exports.setWasmPaths !== "undefined")
+ tfjs_esm_exports.setWasmPaths(instance.config.wasmPath, instance.config.wasmPlatformFetch);
+ else
+ throw new Error("backend error: attempting to use wasm backend but wasm path is not set");
+ let mt = false;
+ let simd = false;
+ try {
+ mt = await tfjs_esm_exports.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");
+ simd = await tfjs_esm_exports.env().getAsync("WASM_HAS_SIMD_SUPPORT");
+ if (instance.config.debug)
+ log(`wasm execution: ${simd ? "simd" : "no simd"} ${mt ? "multithreaded" : "singlethreaded"}`);
+ if (instance.config.debug && !simd)
+ log("warning: wasm simd support is not enabled");
+ } catch (e) {
+ log("wasm detection failed");
+ }
+ }
+ try {
+ await tfjs_esm_exports.setBackend(instance.config.backend);
+ await tfjs_esm_exports.ready();
+ } catch (err) {
+ log("error: cannot set backend:", instance.config.backend, err);
+ return false;
+ }
+ if (instance.config.debug)
+ defaultFlags = JSON.parse(JSON.stringify(tfjs_esm_exports.env().flags));
+ }
+ if (tfjs_esm_exports.getBackend() === "humangl" || tfjs_esm_exports.getBackend() === "webgl") {
+ if (tfjs_esm_exports.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS)
+ tfjs_esm_exports.env().set("WEBGL_USE_SHAPES_UNIFORMS", true);
+ if (tfjs_esm_exports.env().flagRegistry.WEBGL_EXP_CONV)
+ tfjs_esm_exports.env().set("WEBGL_EXP_CONV", true);
+ if (instance.config.debug && typeof instance.config.deallocate !== "undefined" && instance.config.deallocate) {
+ log("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:", true);
+ tfjs_esm_exports.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD", 0);
+ }
+ }
+ if (tfjs_esm_exports.getBackend() === "webgpu") {
+ }
+ if (instance.config.debug) {
+ const newFlags = tfjs_esm_exports.env().flags;
+ const updatedFlags = {};
+ for (const key of Object.keys(newFlags)) {
+ if (defaultFlags[key] === newFlags[key])
+ continue;
+ updatedFlags[key] = newFlags[key];
+ }
+ if (instance.config.debug && Object.keys(updatedFlags).length > 0)
+ log("backend:", tfjs_esm_exports.getBackend(), "flags:", updatedFlags);
+ }
+ if (instance.config.flags && Object.keys(instance.config.flags).length > 0) {
+ if (instance.config.debug)
+ log("flags:", instance.config["flags"]);
+ for (const [key, val] of Object.entries(instance.config.flags)) {
+ tfjs_esm_exports.env().set(key, val);
+ }
+ }
+ tfjs_esm_exports.enableProdMode();
+ init();
+ instance.performance.initBackend = Math.trunc(now() - timeStamp);
+ instance.config.backend = tfjs_esm_exports.getBackend();
+ await env.updateBackend();
+ registerCustomOps(instance.config);
+ env.initial = false;
+ }
+ return true;
+}
+function fakeOps(kernelNames, config3) {
+ for (const kernelName of kernelNames) {
+ const kernelConfig = {
+ kernelName,
+ backendName: config3.backend,
+ kernelFunc: (param) => {
+ var _a;
+ if (config3.debug)
+ log("kernelFunc", kernelName, config3.backend, param);
+ return (_a = param == null ? void 0 : param.inputs) == null ? void 0 : _a.info;
+ }
+ };
+ tfjs_esm_exports.registerKernel(kernelConfig);
+ }
+ env.kernels = tfjs_esm_exports.getKernelsForBackend(tfjs_esm_exports.getBackend()).map((kernel) => kernel.kernelName.toLowerCase());
+}
+
+// src/draw/draw.ts
+var draw_exports = {};
+__export(draw_exports, {
+ all: () => all,
+ body: () => body,
+ canvas: () => canvas2,
+ face: () => face,
+ gesture: () => gesture,
+ hand: () => hand,
+ init: () => init2,
+ object: () => object,
+ options: () => options2,
+ person: () => person
+});
+
+// src/draw/primitives.ts
+var getCanvasContext = (input) => {
+ if (!input)
+ log("draw error: invalid canvas");
+ else if (!input.getContext)
+ log("draw error: canvas context not defined");
+ else {
+ const ctx = input.getContext("2d");
+ if (!ctx)
+ log("draw error: cannot get canvas context");
+ else
+ return ctx;
+ }
+ return null;
+};
+var rad2deg = (theta) => Math.round(theta * 180 / Math.PI);
+var replace = (str, source, target) => str.replace(source, typeof target === "number" ? target.toFixed(1) : target);
+var colorDepth = (z, opt) => {
+ if (!opt.useDepth || typeof z === "undefined")
+ return opt.color;
+ const rgb2 = Uint8ClampedArray.from([127 + 2 * z, 127 - 2 * z, 255]);
+ return `rgba(${rgb2[0]}, ${rgb2[1]}, ${rgb2[2]}, ${opt.alpha})`;
+};
+function labels(ctx, str, startX, startY, localOptions2) {
+ const line = str.replace(/\[.*\]/g, "").split("\n").map((l) => l.trim());
+ const x = Math.max(0, startX);
+ for (let i = line.length - 1; i >= 0; i--) {
+ const y = i * localOptions2.lineHeight + startY;
+ if (localOptions2.shadowColor && localOptions2.shadowColor !== "") {
+ ctx.fillStyle = localOptions2.shadowColor;
+ ctx.fillText(line[i], x + 5, y + 16);
+ }
+ ctx.fillStyle = localOptions2.labelColor;
+ ctx.fillText(line[i], x + 4, y + 15);
+ }
+}
+function point(ctx, x, y, z, localOptions2) {
+ ctx.fillStyle = colorDepth(z, localOptions2);
+ ctx.beginPath();
+ ctx.arc(x, y, localOptions2.pointSize, 0, 2 * Math.PI);
+ ctx.fill();
+}
+function rect(ctx, x, y, width, height, localOptions2) {
+ ctx.beginPath();
+ ctx.lineWidth = localOptions2.lineWidth;
+ if (localOptions2.useCurves) {
+ const cx = (x + x + width) / 2;
+ const cy = (y + y + height) / 2;
+ ctx.ellipse(cx, cy, width / 2, height / 2, 0, 0, 2 * Math.PI);
+ } else {
+ ctx.moveTo(x + localOptions2.roundRect, y);
+ ctx.lineTo(x + width - localOptions2.roundRect, y);
+ ctx.quadraticCurveTo(x + width, y, x + width, y + localOptions2.roundRect);
+ ctx.lineTo(x + width, y + height - localOptions2.roundRect);
+ ctx.quadraticCurveTo(x + width, y + height, x + width - localOptions2.roundRect, y + height);
+ ctx.lineTo(x + localOptions2.roundRect, y + height);
+ ctx.quadraticCurveTo(x, y + height, x, y + height - localOptions2.roundRect);
+ ctx.lineTo(x, y + localOptions2.roundRect);
+ ctx.quadraticCurveTo(x, y, x + localOptions2.roundRect, y);
+ ctx.closePath();
+ }
+ ctx.stroke();
+}
+function lines(ctx, points, localOptions2) {
+ if (points.length < 2)
+ return;
+ ctx.beginPath();
+ ctx.moveTo(points[0][0], points[0][1]);
+ for (const pt of points) {
+ ctx.strokeStyle = colorDepth(pt[2] || 0, localOptions2);
+ ctx.lineTo(Math.trunc(pt[0]), Math.trunc(pt[1]));
+ }
+ ctx.stroke();
+ if (localOptions2.fillPolygons) {
+ ctx.closePath();
+ ctx.fill();
+ }
+}
+function curves(ctx, points, localOptions2) {
+ if (points.length < 2)
+ return;
+ ctx.lineWidth = localOptions2.lineWidth;
+ if (!localOptions2.useCurves || points.length <= 2) {
+ lines(ctx, points, localOptions2);
+ return;
+ }
+ ctx.moveTo(points[0][0], points[0][1]);
+ for (let i = 0; i < points.length - 2; i++) {
+ const xc = (points[i][0] + points[i + 1][0]) / 2;
+ const yc = (points[i][1] + points[i + 1][1]) / 2;
+ ctx.quadraticCurveTo(points[i][0], points[i][1], xc, yc);
+ }
+ ctx.quadraticCurveTo(points[points.length - 2][0], points[points.length - 2][1], points[points.length - 1][0], points[points.length - 1][1]);
+ ctx.stroke();
+ if (localOptions2.fillPolygons) {
+ ctx.closePath();
+ ctx.fill();
+ }
+}
+function arrow(ctx, from, to, radius = 5) {
+ let angle;
+ let x;
+ let y;
+ ctx.beginPath();
+ ctx.moveTo(from[0], from[1]);
+ ctx.lineTo(to[0], to[1]);
+ angle = Math.atan2(to[1] - from[1], to[0] - from[0]);
+ x = radius * Math.cos(angle) + to[0];
+ y = radius * Math.sin(angle) + to[1];
+ ctx.moveTo(x, y);
+ angle += 1 / 3 * (2 * Math.PI);
+ x = radius * Math.cos(angle) + to[0];
+ y = radius * Math.sin(angle) + to[1];
+ ctx.lineTo(x, y);
+ angle += 1 / 3 * (2 * Math.PI);
+ x = radius * Math.cos(angle) + to[0];
+ y = radius * Math.sin(angle) + to[1];
+ ctx.lineTo(x, y);
+ ctx.closePath();
+ ctx.stroke();
+ ctx.fill();
+}
+
+// src/draw/options.ts
+var options2 = {
+ color: "rgba(173, 216, 230, 0.6)",
+ labelColor: "rgba(173, 216, 230, 1)",
+ shadowColor: "black",
+ alpha: 0.5,
+ font: 'small-caps 16px "Segoe UI"',
+ lineHeight: 18,
+ lineWidth: 4,
+ pointSize: 2,
+ roundRect: 8,
+ drawPoints: false,
+ drawLabels: true,
+ drawBoxes: true,
+ drawAttention: true,
+ drawGestures: true,
+ drawPolygons: true,
+ drawGaze: true,
+ fillPolygons: false,
+ useDepth: true,
+ useCurves: false,
+ faceLabels: "",
+ bodyLabels: "",
+ bodyPartLabels: "",
+ objectLabels: "",
+ handLabels: "",
+ fingerLabels: "",
+ gestureLabels: ""
+};
+
+// src/face/facemeshcoords.ts
+var meshAnnotations = {
+ silhouette: [
+ 10,
+ 338,
+ 297,
+ 332,
+ 284,
+ 251,
+ 389,
+ 356,
+ 454,
+ 323,
+ 361,
+ 288,
+ 397,
+ 365,
+ 379,
+ 378,
+ 400,
+ 377,
+ 152,
+ 148,
+ 176,
+ 149,
+ 150,
+ 136,
+ 172,
+ 58,
+ 132,
+ 93,
+ 234,
+ 127,
+ 162,
+ 21,
+ 54,
+ 103,
+ 67,
+ 109
+ ],
+ lipsUpperOuter: [185, 40, 39, 37, 0, 267, 269, 270, 409],
+ lipsLowerOuter: [61, 146, 91, 181, 84, 17, 314, 405, 321, 375, 291],
+ lipsUpperInner: [191, 80, 81, 82, 13, 312, 311, 310, 415],
+ lipsLowerInner: [78, 95, 88, 178, 87, 14, 317, 402, 318, 324, 308],
+ lipsLowerSemiOuter: [76, 77, 90, 180, 85, 16, 315, 404, 320, 307, 306],
+ lipsUpperSemiOuter: [184, 74, 73, 72, 11, 302, 303, 304, 408],
+ lipsLowerSemiInner: [62, 96, 89, 179, 86, 15, 316, 403, 319, 325, 292],
+ lipsUpperSemiInner: [183, 42, 41, 38, 12, 268, 271, 272, 407],
+ rightEyeUpper0: [246, 161, 160, 159, 158, 157, 173],
+ rightEyeLower0: [33, 7, 163, 144, 145, 153, 154, 155, 133],
+ rightEyeUpper1: [247, 30, 29, 27, 28, 56, 190],
+ rightEyeLower1: [130, 25, 110, 24, 23, 22, 26, 112, 243],
+ rightEyeUpper2: [113, 225, 224, 223, 222, 221, 189],
+ rightEyeLower2: [226, 31, 228, 229, 230, 231, 232, 233, 244],
+ rightEyeLower3: [143, 111, 117, 118, 119, 120, 121, 128, 245],
+ rightEyebrowUpper: [156, 70, 63, 105, 66, 107, 55, 193],
+ rightEyebrowLower: [35, 124, 46, 53, 52, 65],
+ rightEyeIris: [473, 474, 475, 476, 477],
+ leftEyeUpper0: [466, 388, 387, 386, 385, 384, 398],
+ leftEyeLower0: [263, 249, 390, 373, 374, 380, 381, 382, 362],
+ leftEyeUpper1: [467, 260, 259, 257, 258, 286, 414],
+ leftEyeLower1: [359, 255, 339, 254, 253, 252, 256, 341, 463],
+ leftEyeUpper2: [342, 445, 444, 443, 442, 441, 413],
+ leftEyeLower2: [446, 261, 448, 449, 450, 451, 452, 453, 464],
+ leftEyeLower3: [372, 340, 346, 347, 348, 349, 350, 357, 465],
+ leftEyebrowUpper: [383, 300, 293, 334, 296, 336, 285, 417],
+ leftEyebrowLower: [265, 353, 276, 283, 282, 295],
+ leftEyeIris: [468, 469, 470, 471, 472],
+ midwayBetweenEyes: [168],
+ noseTip: [1],
+ noseBottom: [2],
+ noseRightCorner: [98],
+ noseLeftCorner: [327],
+ rightCheek: [205],
+ leftCheek: [425]
+};
+var meshLandmarks = {
+ count: 468,
+ mouth: 13,
+ symmetryLine: [13, meshAnnotations.midwayBetweenEyes[0]]
+};
+var blazeFaceLandmarks = {
+ leftEye: 0,
+ rightEye: 1,
+ nose: 2,
+ mouth: 3,
+ leftEar: 4,
+ rightEar: 5,
+ symmetryLine: [3, 2]
+};
+var irisIndices = [
+ { key: "EyeUpper0", indices: [9, 10, 11, 12, 13, 14, 15] },
+ { key: "EyeUpper1", indices: [25, 26, 27, 28, 29, 30, 31] },
+ { key: "EyeUpper2", indices: [41, 42, 43, 44, 45, 46, 47] },
+ { key: "EyeLower0", indices: [0, 1, 2, 3, 4, 5, 6, 7, 8] },
+ { key: "EyeLower1", indices: [16, 17, 18, 19, 20, 21, 22, 23, 24] },
+ { key: "EyeLower2", indices: [32, 33, 34, 35, 36, 37, 38, 39, 40] },
+ { key: "EyeLower3", indices: [54, 55, 56, 57, 58, 59, 60, 61, 62] },
+ { key: "EyebrowUpper", indices: [63, 64, 65, 66, 67, 68, 69, 70] },
+ { key: "EyebrowLower", indices: [48, 49, 50, 51, 52, 53] }
+];
+var UV468 = [
+ [0.499976992607117, 0.652534008026123],
+ [0.500025987625122, 0.547487020492554],
+ [0.499974012374878, 0.602371990680695],
+ [0.482113003730774, 0.471979022026062],
+ [0.500150978565216, 0.527155995368958],
+ [0.499909996986389, 0.498252987861633],
+ [0.499523013830185, 0.40106201171875],
+ [0.289712011814117, 0.380764007568359],
+ [0.499954998493195, 0.312398016452789],
+ [0.499987006187439, 0.269918978214264],
+ [0.500023007392883, 0.107050001621246],
+ [0.500023007392883, 0.666234016418457],
+ [0.5000159740448, 0.679224014282227],
+ [0.500023007392883, 0.692348003387451],
+ [0.499976992607117, 0.695277988910675],
+ [0.499976992607117, 0.70593398809433],
+ [0.499976992607117, 0.719385027885437],
+ [0.499976992607117, 0.737019002437592],
+ [0.499967992305756, 0.781370997428894],
+ [0.499816000461578, 0.562981009483337],
+ [0.473773002624512, 0.573909997940063],
+ [0.104906998574734, 0.254140973091125],
+ [0.365929991006851, 0.409575998783112],
+ [0.338757991790771, 0.41302502155304],
+ [0.311120003461838, 0.409460008144379],
+ [0.274657994508743, 0.389131009578705],
+ [0.393361985683441, 0.403706014156342],
+ [0.345234006643295, 0.344011008739471],
+ [0.370094001293182, 0.346076011657715],
+ [0.319321990013123, 0.347265005111694],
+ [0.297903001308441, 0.353591024875641],
+ [0.24779200553894, 0.410809993743896],
+ [0.396889001131058, 0.842755019664764],
+ [0.280097991228104, 0.375599980354309],
+ [0.106310002505779, 0.399955987930298],
+ [0.2099249958992, 0.391353011131287],
+ [0.355807989835739, 0.534406006336212],
+ [0.471751004457474, 0.65040397644043],
+ [0.474155008792877, 0.680191993713379],
+ [0.439785003662109, 0.657229006290436],
+ [0.414617002010345, 0.66654098033905],
+ [0.450374007225037, 0.680860996246338],
+ [0.428770989179611, 0.682690978050232],
+ [0.374971002340317, 0.727805018424988],
+ [0.486716985702515, 0.547628998756409],
+ [0.485300987958908, 0.527395009994507],
+ [0.257764995098114, 0.314490020275116],
+ [0.401223003864288, 0.455172002315521],
+ [0.429818987846375, 0.548614978790283],
+ [0.421351999044418, 0.533740997314453],
+ [0.276895999908447, 0.532056987285614],
+ [0.483370006084442, 0.499586999416351],
+ [0.33721199631691, 0.282882988452911],
+ [0.296391993761063, 0.293242990970612],
+ [0.169294998049736, 0.193813979625702],
+ [0.447580009698868, 0.302609980106354],
+ [0.392390012741089, 0.353887975215912],
+ [0.354490011930466, 0.696784019470215],
+ [0.067304998636246, 0.730105042457581],
+ [0.442739009857178, 0.572826027870178],
+ [0.457098007202148, 0.584792017936707],
+ [0.381974011659622, 0.694710969924927],
+ [0.392388999462128, 0.694203019142151],
+ [0.277076005935669, 0.271932005882263],
+ [0.422551989555359, 0.563233017921448],
+ [0.385919004678726, 0.281364023685455],
+ [0.383103013038635, 0.255840003490448],
+ [0.331431001424789, 0.119714021682739],
+ [0.229923993349075, 0.232002973556519],
+ [0.364500999450684, 0.189113974571228],
+ [0.229622006416321, 0.299540996551514],
+ [0.173287004232407, 0.278747975826263],
+ [0.472878992557526, 0.666198015213013],
+ [0.446828007698059, 0.668527007102966],
+ [0.422762006521225, 0.673889994621277],
+ [0.445307999849319, 0.580065965652466],
+ [0.388103008270264, 0.693961024284363],
+ [0.403039008378983, 0.706539988517761],
+ [0.403629004955292, 0.693953037261963],
+ [0.460041999816895, 0.557139039039612],
+ [0.431158006191254, 0.692366003990173],
+ [0.452181994915009, 0.692366003990173],
+ [0.475387006998062, 0.692366003990173],
+ [0.465828001499176, 0.779190003871918],
+ [0.472328990697861, 0.736225962638855],
+ [0.473087012767792, 0.717857003211975],
+ [0.473122000694275, 0.704625964164734],
+ [0.473033010959625, 0.695277988910675],
+ [0.427942007780075, 0.695277988910675],
+ [0.426479011774063, 0.703539967536926],
+ [0.423162013292313, 0.711845993995667],
+ [0.4183090031147, 0.720062971115112],
+ [0.390094995498657, 0.639572978019714],
+ [0.013953999616206, 0.560034036636353],
+ [0.499913990497589, 0.58014702796936],
+ [0.413199990987778, 0.69539999961853],
+ [0.409626007080078, 0.701822996139526],
+ [0.468080013990402, 0.601534962654114],
+ [0.422728985548019, 0.585985004901886],
+ [0.463079988956451, 0.593783974647522],
+ [0.37211999297142, 0.47341400384903],
+ [0.334562003612518, 0.496073007583618],
+ [0.411671012639999, 0.546965003013611],
+ [0.242175996303558, 0.14767599105835],
+ [0.290776997804642, 0.201445996761322],
+ [0.327338010072708, 0.256527006626129],
+ [0.399509996175766, 0.748921036720276],
+ [0.441727995872498, 0.261676013469696],
+ [0.429764986038208, 0.187834024429321],
+ [0.412198007106781, 0.108901023864746],
+ [0.288955003023148, 0.398952007293701],
+ [0.218936994671822, 0.435410976409912],
+ [0.41278201341629, 0.398970007896423],
+ [0.257135003805161, 0.355440020561218],
+ [0.427684992551804, 0.437960982322693],
+ [0.448339998722076, 0.536936044692993],
+ [0.178560003638268, 0.45755398273468],
+ [0.247308000922203, 0.457193970680237],
+ [0.286267012357712, 0.467674970626831],
+ [0.332827985286713, 0.460712015628815],
+ [0.368755996227264, 0.447206974029541],
+ [0.398963987827301, 0.432654976844788],
+ [0.476410001516342, 0.405806005001068],
+ [0.189241006970406, 0.523923993110657],
+ [0.228962004184723, 0.348950982093811],
+ [0.490725994110107, 0.562400996685028],
+ [0.404670000076294, 0.485132992267609],
+ [0.019469000399113, 0.401564002037048],
+ [0.426243007183075, 0.420431017875671],
+ [0.396993011236191, 0.548797011375427],
+ [0.266469985246658, 0.376977026462555],
+ [0.439121007919312, 0.51895797252655],
+ [0.032313998788595, 0.644356966018677],
+ [0.419054001569748, 0.387154996395111],
+ [0.462783008813858, 0.505746960639954],
+ [0.238978996872902, 0.779744982719421],
+ [0.198220998048782, 0.831938028335571],
+ [0.107550002634525, 0.540755033493042],
+ [0.183610007166862, 0.740257024765015],
+ [0.134409993886948, 0.333683013916016],
+ [0.385764002799988, 0.883153975009918],
+ [0.490967005491257, 0.579378008842468],
+ [0.382384985685349, 0.508572995662689],
+ [0.174399003386497, 0.397670984268188],
+ [0.318785011768341, 0.39623498916626],
+ [0.343364000320435, 0.400596976280212],
+ [0.396100014448166, 0.710216999053955],
+ [0.187885001301765, 0.588537991046906],
+ [0.430987000465393, 0.944064974784851],
+ [0.318993002176285, 0.898285031318665],
+ [0.266247987747192, 0.869701027870178],
+ [0.500023007392883, 0.190576016902924],
+ [0.499976992607117, 0.954452991485596],
+ [0.366169989109039, 0.398822009563446],
+ [0.393207013607025, 0.39553701877594],
+ [0.410373002290726, 0.391080021858215],
+ [0.194993004202843, 0.342101991176605],
+ [0.388664990663528, 0.362284004688263],
+ [0.365961998701096, 0.355970978736877],
+ [0.343364000320435, 0.355356991291046],
+ [0.318785011768341, 0.35834002494812],
+ [0.301414996385574, 0.363156020641327],
+ [0.058132998645306, 0.319076001644135],
+ [0.301414996385574, 0.387449026107788],
+ [0.499987989664078, 0.618434011936188],
+ [0.415838003158569, 0.624195992946625],
+ [0.445681989192963, 0.566076993942261],
+ [0.465844005346298, 0.620640993118286],
+ [0.49992299079895, 0.351523995399475],
+ [0.288718998432159, 0.819945991039276],
+ [0.335278987884521, 0.852819979190826],
+ [0.440512001514435, 0.902418971061707],
+ [0.128294005990028, 0.791940987110138],
+ [0.408771991729736, 0.373893976211548],
+ [0.455606997013092, 0.451801002025604],
+ [0.499877005815506, 0.908990025520325],
+ [0.375436991453171, 0.924192011356354],
+ [0.11421000212431, 0.615022003650665],
+ [0.448662012815475, 0.695277988910675],
+ [0.4480200111866, 0.704632043838501],
+ [0.447111994028091, 0.715808033943176],
+ [0.444831997156143, 0.730794012546539],
+ [0.430011987686157, 0.766808986663818],
+ [0.406787008047104, 0.685672998428345],
+ [0.400738000869751, 0.681069016456604],
+ [0.392399996519089, 0.677703022956848],
+ [0.367855995893478, 0.663918972015381],
+ [0.247923001646996, 0.601333022117615],
+ [0.452769994735718, 0.420849978923798],
+ [0.43639200925827, 0.359887003898621],
+ [0.416164010763168, 0.368713974952698],
+ [0.413385987281799, 0.692366003990173],
+ [0.228018000721931, 0.683571994304657],
+ [0.468268007040024, 0.352671027183533],
+ [0.411361992359161, 0.804327011108398],
+ [0.499989002943039, 0.469825029373169],
+ [0.479153990745544, 0.442654013633728],
+ [0.499974012374878, 0.439637005329132],
+ [0.432112008333206, 0.493588984012604],
+ [0.499886006116867, 0.866917014122009],
+ [0.49991300702095, 0.821729004383087],
+ [0.456548988819122, 0.819200992584229],
+ [0.344549000263214, 0.745438992977142],
+ [0.37890899181366, 0.574010014533997],
+ [0.374292999505997, 0.780184984207153],
+ [0.319687992334366, 0.570737957954407],
+ [0.357154995203018, 0.604269981384277],
+ [0.295284003019333, 0.621580958366394],
+ [0.447750002145767, 0.862477004528046],
+ [0.410986006259918, 0.508723020553589],
+ [0.31395098567009, 0.775308012962341],
+ [0.354128003120422, 0.812552988529205],
+ [0.324548006057739, 0.703992962837219],
+ [0.189096003770828, 0.646299958229065],
+ [0.279776990413666, 0.71465802192688],
+ [0.1338230073452, 0.682700991630554],
+ [0.336768001317978, 0.644733011722565],
+ [0.429883986711502, 0.466521978378296],
+ [0.455527991056442, 0.548622965812683],
+ [0.437114000320435, 0.558896005153656],
+ [0.467287987470627, 0.529924988746643],
+ [0.414712011814117, 0.335219979286194],
+ [0.37704598903656, 0.322777986526489],
+ [0.344107985496521, 0.320150971412659],
+ [0.312875986099243, 0.32233202457428],
+ [0.283526003360748, 0.333190023899078],
+ [0.241245999932289, 0.382785975933075],
+ [0.102986000478268, 0.468762993812561],
+ [0.267612010240555, 0.424560010433197],
+ [0.297879010438919, 0.433175981044769],
+ [0.333433985710144, 0.433878004550934],
+ [0.366427004337311, 0.426115989685059],
+ [0.396012008190155, 0.416696012020111],
+ [0.420121014118195, 0.41022801399231],
+ [0.007561000064015, 0.480777025222778],
+ [0.432949006557465, 0.569517970085144],
+ [0.458638995885849, 0.479089021682739],
+ [0.473466008901596, 0.545744001865387],
+ [0.476087987422943, 0.563830018043518],
+ [0.468472003936768, 0.555056989192963],
+ [0.433990985155106, 0.582361996173859],
+ [0.483518004417419, 0.562983989715576],
+ [0.482482999563217, 0.57784903049469],
+ [0.42645001411438, 0.389798998832703],
+ [0.438998997211456, 0.39649498462677],
+ [0.450067013502121, 0.400434017181396],
+ [0.289712011814117, 0.368252992630005],
+ [0.276670008897781, 0.363372981548309],
+ [0.517862021923065, 0.471948027610779],
+ [0.710287988185883, 0.380764007568359],
+ [0.526226997375488, 0.573909997940063],
+ [0.895093023777008, 0.254140973091125],
+ [0.634069979190826, 0.409575998783112],
+ [0.661242008209229, 0.41302502155304],
+ [0.688880026340485, 0.409460008144379],
+ [0.725341975688934, 0.389131009578705],
+ [0.606630027294159, 0.40370500087738],
+ [0.654766023159027, 0.344011008739471],
+ [0.629905998706818, 0.346076011657715],
+ [0.680678009986877, 0.347265005111694],
+ [0.702096998691559, 0.353591024875641],
+ [0.75221198797226, 0.410804986953735],
+ [0.602918028831482, 0.842862963676453],
+ [0.719901978969574, 0.375599980354309],
+ [0.893692970275879, 0.399959981441498],
+ [0.790081977844238, 0.391354024410248],
+ [0.643998026847839, 0.534487962722778],
+ [0.528249025344849, 0.65040397644043],
+ [0.525849997997284, 0.680191040039062],
+ [0.560214996337891, 0.657229006290436],
+ [0.585384011268616, 0.66654098033905],
+ [0.549625992774963, 0.680860996246338],
+ [0.57122802734375, 0.682691991329193],
+ [0.624852001667023, 0.72809898853302],
+ [0.513050019741058, 0.547281980514526],
+ [0.51509702205658, 0.527251958847046],
+ [0.742246985435486, 0.314507007598877],
+ [0.598631024360657, 0.454979002475739],
+ [0.570338010787964, 0.548575043678284],
+ [0.578631997108459, 0.533622980117798],
+ [0.723087012767792, 0.532054007053375],
+ [0.516445994377136, 0.499638974666595],
+ [0.662801027297974, 0.282917976379395],
+ [0.70362401008606, 0.293271005153656],
+ [0.830704987049103, 0.193813979625702],
+ [0.552385985851288, 0.302568018436432],
+ [0.607609987258911, 0.353887975215912],
+ [0.645429015159607, 0.696707010269165],
+ [0.932694971561432, 0.730105042457581],
+ [0.557260990142822, 0.572826027870178],
+ [0.542901992797852, 0.584792017936707],
+ [0.6180260181427, 0.694710969924927],
+ [0.607590973377228, 0.694203019142151],
+ [0.722943007946014, 0.271963000297546],
+ [0.577413976192474, 0.563166975975037],
+ [0.614082992076874, 0.281386971473694],
+ [0.616907000541687, 0.255886018276215],
+ [0.668509006500244, 0.119913995265961],
+ [0.770092010498047, 0.232020974159241],
+ [0.635536015033722, 0.189248979091644],
+ [0.77039098739624, 0.299556016921997],
+ [0.826722025871277, 0.278755009174347],
+ [0.527121007442474, 0.666198015213013],
+ [0.553171992301941, 0.668527007102966],
+ [0.577238023281097, 0.673889994621277],
+ [0.554691970348358, 0.580065965652466],
+ [0.611896991729736, 0.693961024284363],
+ [0.59696102142334, 0.706539988517761],
+ [0.596370995044708, 0.693953037261963],
+ [0.539958000183105, 0.557139039039612],
+ [0.568841993808746, 0.692366003990173],
+ [0.547818005084991, 0.692366003990173],
+ [0.52461302280426, 0.692366003990173],
+ [0.534089982509613, 0.779141008853912],
+ [0.527670979499817, 0.736225962638855],
+ [0.526912987232208, 0.717857003211975],
+ [0.526877999305725, 0.704625964164734],
+ [0.526966989040375, 0.695277988910675],
+ [0.572058022022247, 0.695277988910675],
+ [0.573521018028259, 0.703539967536926],
+ [0.57683801651001, 0.711845993995667],
+ [0.581691026687622, 0.720062971115112],
+ [0.609944999217987, 0.639909982681274],
+ [0.986046016216278, 0.560034036636353],
+ [0.5867999792099, 0.69539999961853],
+ [0.590372025966644, 0.701822996139526],
+ [0.531915009021759, 0.601536989212036],
+ [0.577268004417419, 0.585934996604919],
+ [0.536915004253387, 0.593786001205444],
+ [0.627542972564697, 0.473352015018463],
+ [0.665585994720459, 0.495950996875763],
+ [0.588353991508484, 0.546862006187439],
+ [0.757824003696442, 0.14767599105835],
+ [0.709249973297119, 0.201507985591888],
+ [0.672684013843536, 0.256581008434296],
+ [0.600408971309662, 0.74900496006012],
+ [0.55826598405838, 0.261672019958496],
+ [0.570303976535797, 0.187870979309082],
+ [0.588165998458862, 0.109044015407562],
+ [0.711045026779175, 0.398952007293701],
+ [0.781069993972778, 0.435405015945435],
+ [0.587247014045715, 0.398931980133057],
+ [0.742869973182678, 0.355445981025696],
+ [0.572156012058258, 0.437651991844177],
+ [0.55186802148819, 0.536570012569427],
+ [0.821442008018494, 0.457556009292603],
+ [0.752701997756958, 0.457181990146637],
+ [0.71375697851181, 0.467626988887787],
+ [0.66711300611496, 0.460672974586487],
+ [0.631101012229919, 0.447153985500336],
+ [0.6008620262146, 0.432473003864288],
+ [0.523481011390686, 0.405627012252808],
+ [0.810747981071472, 0.523926019668579],
+ [0.771045982837677, 0.348959028720856],
+ [0.509127020835876, 0.562718033790588],
+ [0.595292985439301, 0.485023975372314],
+ [0.980530977249146, 0.401564002037048],
+ [0.573499977588654, 0.420000016689301],
+ [0.602994978427887, 0.548687994480133],
+ [0.733529984951019, 0.376977026462555],
+ [0.560611009597778, 0.519016981124878],
+ [0.967685997486115, 0.644356966018677],
+ [0.580985009670258, 0.387160003185272],
+ [0.537728011608124, 0.505385041236877],
+ [0.760966002941132, 0.779752969741821],
+ [0.801778972148895, 0.831938028335571],
+ [0.892440974712372, 0.54076099395752],
+ [0.816350996494293, 0.740260004997253],
+ [0.865594983100891, 0.333687007427216],
+ [0.614073991775513, 0.883246004581451],
+ [0.508952975273132, 0.579437971115112],
+ [0.617941975593567, 0.508316040039062],
+ [0.825608015060425, 0.397674977779388],
+ [0.681214988231659, 0.39623498916626],
+ [0.656635999679565, 0.400596976280212],
+ [0.603900015354156, 0.710216999053955],
+ [0.81208598613739, 0.588539004325867],
+ [0.56801301240921, 0.944564998149872],
+ [0.681007981300354, 0.898285031318665],
+ [0.733752012252808, 0.869701027870178],
+ [0.633830010890961, 0.398822009563446],
+ [0.606792986392975, 0.39553701877594],
+ [0.589659988880157, 0.391062021255493],
+ [0.805015981197357, 0.342108011245728],
+ [0.611334979534149, 0.362284004688263],
+ [0.634037971496582, 0.355970978736877],
+ [0.656635999679565, 0.355356991291046],
+ [0.681214988231659, 0.35834002494812],
+ [0.698584973812103, 0.363156020641327],
+ [0.941866993904114, 0.319076001644135],
+ [0.698584973812103, 0.387449026107788],
+ [0.584177017211914, 0.624107003211975],
+ [0.554318010807037, 0.566076993942261],
+ [0.534153997898102, 0.62064003944397],
+ [0.711217999458313, 0.819975018501282],
+ [0.664629995822906, 0.852871000766754],
+ [0.559099972248077, 0.902631998062134],
+ [0.871706008911133, 0.791940987110138],
+ [0.591234028339386, 0.373893976211548],
+ [0.544341027736664, 0.451583981513977],
+ [0.624562978744507, 0.924192011356354],
+ [0.88577002286911, 0.615028977394104],
+ [0.551338016986847, 0.695277988910675],
+ [0.551980018615723, 0.704632043838501],
+ [0.552887976169586, 0.715808033943176],
+ [0.555167973041534, 0.730794012546539],
+ [0.569944024085999, 0.767035007476807],
+ [0.593203008174896, 0.685675978660583],
+ [0.599261999130249, 0.681069016456604],
+ [0.607599973678589, 0.677703022956848],
+ [0.631937980651855, 0.663500010967255],
+ [0.752032995223999, 0.601315021514893],
+ [0.547226011753082, 0.420395016670227],
+ [0.563543975353241, 0.359827995300293],
+ [0.583841025829315, 0.368713974952698],
+ [0.586614012718201, 0.692366003990173],
+ [0.771915018558502, 0.683578014373779],
+ [0.531597018241882, 0.352482974529266],
+ [0.588370978832245, 0.804440975189209],
+ [0.52079701423645, 0.442565023899078],
+ [0.567984998226166, 0.493479013442993],
+ [0.543282985687256, 0.819254994392395],
+ [0.655317008495331, 0.745514988899231],
+ [0.621008992195129, 0.574018001556396],
+ [0.625559985637665, 0.78031200170517],
+ [0.680198013782501, 0.570719003677368],
+ [0.64276397228241, 0.604337990283966],
+ [0.704662978649139, 0.621529996395111],
+ [0.552012026309967, 0.862591981887817],
+ [0.589071989059448, 0.508637011051178],
+ [0.685944974422455, 0.775357007980347],
+ [0.645735025405884, 0.812640011310577],
+ [0.675342977046967, 0.703978002071381],
+ [0.810858011245728, 0.646304965019226],
+ [0.72012197971344, 0.714666962623596],
+ [0.866151988506317, 0.682704985141754],
+ [0.663187026977539, 0.644596993923187],
+ [0.570082008838654, 0.466325998306274],
+ [0.544561982154846, 0.548375964164734],
+ [0.562758982181549, 0.558784961700439],
+ [0.531987011432648, 0.530140042304993],
+ [0.585271000862122, 0.335177004337311],
+ [0.622952997684479, 0.32277899980545],
+ [0.655896008014679, 0.320163011550903],
+ [0.687132000923157, 0.322345972061157],
+ [0.716481983661652, 0.333200991153717],
+ [0.758756995201111, 0.382786989212036],
+ [0.897013008594513, 0.468769013881683],
+ [0.732392013072968, 0.424547016620636],
+ [0.70211398601532, 0.433162987232208],
+ [0.66652500629425, 0.433866024017334],
+ [0.633504986763, 0.426087975502014],
+ [0.603875994682312, 0.416586995124817],
+ [0.579657971858978, 0.409945011138916],
+ [0.992439985275269, 0.480777025222778],
+ [0.567192018032074, 0.569419980049133],
+ [0.54136598110199, 0.478899002075195],
+ [0.526564002037048, 0.546118021011353],
+ [0.523913025856018, 0.563830018043518],
+ [0.531529009342194, 0.555056989192963],
+ [0.566035985946655, 0.582329034805298],
+ [0.51631098985672, 0.563053965568542],
+ [0.5174720287323, 0.577877044677734],
+ [0.573594987392426, 0.389806985855103],
+ [0.560697972774506, 0.395331978797913],
+ [0.549755990505219, 0.399751007556915],
+ [0.710287988185883, 0.368252992630005],
+ [0.723330020904541, 0.363372981548309]
+];
+var TRI468 = [
+ 127,
+ 34,
+ 139,
+ 11,
+ 0,
+ 37,
+ 232,
+ 231,
+ 120,
+ 72,
+ 37,
+ 39,
+ 128,
+ 121,
+ 47,
+ 232,
+ 121,
+ 128,
+ 104,
+ 69,
+ 67,
+ 175,
+ 171,
+ 148,
+ 157,
+ 154,
+ 155,
+ 118,
+ 50,
+ 101,
+ 73,
+ 39,
+ 40,
+ 9,
+ 151,
+ 108,
+ 48,
+ 115,
+ 131,
+ 194,
+ 204,
+ 211,
+ 74,
+ 40,
+ 185,
+ 80,
+ 42,
+ 183,
+ 40,
+ 92,
+ 186,
+ 230,
+ 229,
+ 118,
+ 202,
+ 212,
+ 214,
+ 83,
+ 18,
+ 17,
+ 76,
+ 61,
+ 146,
+ 160,
+ 29,
+ 30,
+ 56,
+ 157,
+ 173,
+ 106,
+ 204,
+ 194,
+ 135,
+ 214,
+ 192,
+ 203,
+ 165,
+ 98,
+ 21,
+ 71,
+ 68,
+ 51,
+ 45,
+ 4,
+ 144,
+ 24,
+ 23,
+ 77,
+ 146,
+ 91,
+ 205,
+ 50,
+ 187,
+ 201,
+ 200,
+ 18,
+ 91,
+ 106,
+ 182,
+ 90,
+ 91,
+ 181,
+ 85,
+ 84,
+ 17,
+ 206,
+ 203,
+ 36,
+ 148,
+ 171,
+ 140,
+ 92,
+ 40,
+ 39,
+ 193,
+ 189,
+ 244,
+ 159,
+ 158,
+ 28,
+ 247,
+ 246,
+ 161,
+ 236,
+ 3,
+ 196,
+ 54,
+ 68,
+ 104,
+ 193,
+ 168,
+ 8,
+ 117,
+ 228,
+ 31,
+ 189,
+ 193,
+ 55,
+ 98,
+ 97,
+ 99,
+ 126,
+ 47,
+ 100,
+ 166,
+ 79,
+ 218,
+ 155,
+ 154,
+ 26,
+ 209,
+ 49,
+ 131,
+ 135,
+ 136,
+ 150,
+ 47,
+ 126,
+ 217,
+ 223,
+ 52,
+ 53,
+ 45,
+ 51,
+ 134,
+ 211,
+ 170,
+ 140,
+ 67,
+ 69,
+ 108,
+ 43,
+ 106,
+ 91,
+ 230,
+ 119,
+ 120,
+ 226,
+ 130,
+ 247,
+ 63,
+ 53,
+ 52,
+ 238,
+ 20,
+ 242,
+ 46,
+ 70,
+ 156,
+ 78,
+ 62,
+ 96,
+ 46,
+ 53,
+ 63,
+ 143,
+ 34,
+ 227,
+ 173,
+ 155,
+ 133,
+ 123,
+ 117,
+ 111,
+ 44,
+ 125,
+ 19,
+ 236,
+ 134,
+ 51,
+ 216,
+ 206,
+ 205,
+ 154,
+ 153,
+ 22,
+ 39,
+ 37,
+ 167,
+ 200,
+ 201,
+ 208,
+ 36,
+ 142,
+ 100,
+ 57,
+ 212,
+ 202,
+ 20,
+ 60,
+ 99,
+ 28,
+ 158,
+ 157,
+ 35,
+ 226,
+ 113,
+ 160,
+ 159,
+ 27,
+ 204,
+ 202,
+ 210,
+ 113,
+ 225,
+ 46,
+ 43,
+ 202,
+ 204,
+ 62,
+ 76,
+ 77,
+ 137,
+ 123,
+ 116,
+ 41,
+ 38,
+ 72,
+ 203,
+ 129,
+ 142,
+ 64,
+ 98,
+ 240,
+ 49,
+ 102,
+ 64,
+ 41,
+ 73,
+ 74,
+ 212,
+ 216,
+ 207,
+ 42,
+ 74,
+ 184,
+ 169,
+ 170,
+ 211,
+ 170,
+ 149,
+ 176,
+ 105,
+ 66,
+ 69,
+ 122,
+ 6,
+ 168,
+ 123,
+ 147,
+ 187,
+ 96,
+ 77,
+ 90,
+ 65,
+ 55,
+ 107,
+ 89,
+ 90,
+ 180,
+ 101,
+ 100,
+ 120,
+ 63,
+ 105,
+ 104,
+ 93,
+ 137,
+ 227,
+ 15,
+ 86,
+ 85,
+ 129,
+ 102,
+ 49,
+ 14,
+ 87,
+ 86,
+ 55,
+ 8,
+ 9,
+ 100,
+ 47,
+ 121,
+ 145,
+ 23,
+ 22,
+ 88,
+ 89,
+ 179,
+ 6,
+ 122,
+ 196,
+ 88,
+ 95,
+ 96,
+ 138,
+ 172,
+ 136,
+ 215,
+ 58,
+ 172,
+ 115,
+ 48,
+ 219,
+ 42,
+ 80,
+ 81,
+ 195,
+ 3,
+ 51,
+ 43,
+ 146,
+ 61,
+ 171,
+ 175,
+ 199,
+ 81,
+ 82,
+ 38,
+ 53,
+ 46,
+ 225,
+ 144,
+ 163,
+ 110,
+ 246,
+ 33,
+ 7,
+ 52,
+ 65,
+ 66,
+ 229,
+ 228,
+ 117,
+ 34,
+ 127,
+ 234,
+ 107,
+ 108,
+ 69,
+ 109,
+ 108,
+ 151,
+ 48,
+ 64,
+ 235,
+ 62,
+ 78,
+ 191,
+ 129,
+ 209,
+ 126,
+ 111,
+ 35,
+ 143,
+ 163,
+ 161,
+ 246,
+ 117,
+ 123,
+ 50,
+ 222,
+ 65,
+ 52,
+ 19,
+ 125,
+ 141,
+ 221,
+ 55,
+ 65,
+ 3,
+ 195,
+ 197,
+ 25,
+ 7,
+ 33,
+ 220,
+ 237,
+ 44,
+ 70,
+ 71,
+ 139,
+ 122,
+ 193,
+ 245,
+ 247,
+ 130,
+ 33,
+ 71,
+ 21,
+ 162,
+ 153,
+ 158,
+ 159,
+ 170,
+ 169,
+ 150,
+ 188,
+ 174,
+ 196,
+ 216,
+ 186,
+ 92,
+ 144,
+ 160,
+ 161,
+ 2,
+ 97,
+ 167,
+ 141,
+ 125,
+ 241,
+ 164,
+ 167,
+ 37,
+ 72,
+ 38,
+ 12,
+ 145,
+ 159,
+ 160,
+ 38,
+ 82,
+ 13,
+ 63,
+ 68,
+ 71,
+ 226,
+ 35,
+ 111,
+ 158,
+ 153,
+ 154,
+ 101,
+ 50,
+ 205,
+ 206,
+ 92,
+ 165,
+ 209,
+ 198,
+ 217,
+ 165,
+ 167,
+ 97,
+ 220,
+ 115,
+ 218,
+ 133,
+ 112,
+ 243,
+ 239,
+ 238,
+ 241,
+ 214,
+ 135,
+ 169,
+ 190,
+ 173,
+ 133,
+ 171,
+ 208,
+ 32,
+ 125,
+ 44,
+ 237,
+ 86,
+ 87,
+ 178,
+ 85,
+ 86,
+ 179,
+ 84,
+ 85,
+ 180,
+ 83,
+ 84,
+ 181,
+ 201,
+ 83,
+ 182,
+ 137,
+ 93,
+ 132,
+ 76,
+ 62,
+ 183,
+ 61,
+ 76,
+ 184,
+ 57,
+ 61,
+ 185,
+ 212,
+ 57,
+ 186,
+ 214,
+ 207,
+ 187,
+ 34,
+ 143,
+ 156,
+ 79,
+ 239,
+ 237,
+ 123,
+ 137,
+ 177,
+ 44,
+ 1,
+ 4,
+ 201,
+ 194,
+ 32,
+ 64,
+ 102,
+ 129,
+ 213,
+ 215,
+ 138,
+ 59,
+ 166,
+ 219,
+ 242,
+ 99,
+ 97,
+ 2,
+ 94,
+ 141,
+ 75,
+ 59,
+ 235,
+ 24,
+ 110,
+ 228,
+ 25,
+ 130,
+ 226,
+ 23,
+ 24,
+ 229,
+ 22,
+ 23,
+ 230,
+ 26,
+ 22,
+ 231,
+ 112,
+ 26,
+ 232,
+ 189,
+ 190,
+ 243,
+ 221,
+ 56,
+ 190,
+ 28,
+ 56,
+ 221,
+ 27,
+ 28,
+ 222,
+ 29,
+ 27,
+ 223,
+ 30,
+ 29,
+ 224,
+ 247,
+ 30,
+ 225,
+ 238,
+ 79,
+ 20,
+ 166,
+ 59,
+ 75,
+ 60,
+ 75,
+ 240,
+ 147,
+ 177,
+ 215,
+ 20,
+ 79,
+ 166,
+ 187,
+ 147,
+ 213,
+ 112,
+ 233,
+ 244,
+ 233,
+ 128,
+ 245,
+ 128,
+ 114,
+ 188,
+ 114,
+ 217,
+ 174,
+ 131,
+ 115,
+ 220,
+ 217,
+ 198,
+ 236,
+ 198,
+ 131,
+ 134,
+ 177,
+ 132,
+ 58,
+ 143,
+ 35,
+ 124,
+ 110,
+ 163,
+ 7,
+ 228,
+ 110,
+ 25,
+ 356,
+ 389,
+ 368,
+ 11,
+ 302,
+ 267,
+ 452,
+ 350,
+ 349,
+ 302,
+ 303,
+ 269,
+ 357,
+ 343,
+ 277,
+ 452,
+ 453,
+ 357,
+ 333,
+ 332,
+ 297,
+ 175,
+ 152,
+ 377,
+ 384,
+ 398,
+ 382,
+ 347,
+ 348,
+ 330,
+ 303,
+ 304,
+ 270,
+ 9,
+ 336,
+ 337,
+ 278,
+ 279,
+ 360,
+ 418,
+ 262,
+ 431,
+ 304,
+ 408,
+ 409,
+ 310,
+ 415,
+ 407,
+ 270,
+ 409,
+ 410,
+ 450,
+ 348,
+ 347,
+ 422,
+ 430,
+ 434,
+ 313,
+ 314,
+ 17,
+ 306,
+ 307,
+ 375,
+ 387,
+ 388,
+ 260,
+ 286,
+ 414,
+ 398,
+ 335,
+ 406,
+ 418,
+ 364,
+ 367,
+ 416,
+ 423,
+ 358,
+ 327,
+ 251,
+ 284,
+ 298,
+ 281,
+ 5,
+ 4,
+ 373,
+ 374,
+ 253,
+ 307,
+ 320,
+ 321,
+ 425,
+ 427,
+ 411,
+ 421,
+ 313,
+ 18,
+ 321,
+ 405,
+ 406,
+ 320,
+ 404,
+ 405,
+ 315,
+ 16,
+ 17,
+ 426,
+ 425,
+ 266,
+ 377,
+ 400,
+ 369,
+ 322,
+ 391,
+ 269,
+ 417,
+ 465,
+ 464,
+ 386,
+ 257,
+ 258,
+ 466,
+ 260,
+ 388,
+ 456,
+ 399,
+ 419,
+ 284,
+ 332,
+ 333,
+ 417,
+ 285,
+ 8,
+ 346,
+ 340,
+ 261,
+ 413,
+ 441,
+ 285,
+ 327,
+ 460,
+ 328,
+ 355,
+ 371,
+ 329,
+ 392,
+ 439,
+ 438,
+ 382,
+ 341,
+ 256,
+ 429,
+ 420,
+ 360,
+ 364,
+ 394,
+ 379,
+ 277,
+ 343,
+ 437,
+ 443,
+ 444,
+ 283,
+ 275,
+ 440,
+ 363,
+ 431,
+ 262,
+ 369,
+ 297,
+ 338,
+ 337,
+ 273,
+ 375,
+ 321,
+ 450,
+ 451,
+ 349,
+ 446,
+ 342,
+ 467,
+ 293,
+ 334,
+ 282,
+ 458,
+ 461,
+ 462,
+ 276,
+ 353,
+ 383,
+ 308,
+ 324,
+ 325,
+ 276,
+ 300,
+ 293,
+ 372,
+ 345,
+ 447,
+ 382,
+ 398,
+ 362,
+ 352,
+ 345,
+ 340,
+ 274,
+ 1,
+ 19,
+ 456,
+ 248,
+ 281,
+ 436,
+ 427,
+ 425,
+ 381,
+ 256,
+ 252,
+ 269,
+ 391,
+ 393,
+ 200,
+ 199,
+ 428,
+ 266,
+ 330,
+ 329,
+ 287,
+ 273,
+ 422,
+ 250,
+ 462,
+ 328,
+ 258,
+ 286,
+ 384,
+ 265,
+ 353,
+ 342,
+ 387,
+ 259,
+ 257,
+ 424,
+ 431,
+ 430,
+ 342,
+ 353,
+ 276,
+ 273,
+ 335,
+ 424,
+ 292,
+ 325,
+ 307,
+ 366,
+ 447,
+ 345,
+ 271,
+ 303,
+ 302,
+ 423,
+ 266,
+ 371,
+ 294,
+ 455,
+ 460,
+ 279,
+ 278,
+ 294,
+ 271,
+ 272,
+ 304,
+ 432,
+ 434,
+ 427,
+ 272,
+ 407,
+ 408,
+ 394,
+ 430,
+ 431,
+ 395,
+ 369,
+ 400,
+ 334,
+ 333,
+ 299,
+ 351,
+ 417,
+ 168,
+ 352,
+ 280,
+ 411,
+ 325,
+ 319,
+ 320,
+ 295,
+ 296,
+ 336,
+ 319,
+ 403,
+ 404,
+ 330,
+ 348,
+ 349,
+ 293,
+ 298,
+ 333,
+ 323,
+ 454,
+ 447,
+ 15,
+ 16,
+ 315,
+ 358,
+ 429,
+ 279,
+ 14,
+ 15,
+ 316,
+ 285,
+ 336,
+ 9,
+ 329,
+ 349,
+ 350,
+ 374,
+ 380,
+ 252,
+ 318,
+ 402,
+ 403,
+ 6,
+ 197,
+ 419,
+ 318,
+ 319,
+ 325,
+ 367,
+ 364,
+ 365,
+ 435,
+ 367,
+ 397,
+ 344,
+ 438,
+ 439,
+ 272,
+ 271,
+ 311,
+ 195,
+ 5,
+ 281,
+ 273,
+ 287,
+ 291,
+ 396,
+ 428,
+ 199,
+ 311,
+ 271,
+ 268,
+ 283,
+ 444,
+ 445,
+ 373,
+ 254,
+ 339,
+ 263,
+ 466,
+ 249,
+ 282,
+ 334,
+ 296,
+ 449,
+ 347,
+ 346,
+ 264,
+ 447,
+ 454,
+ 336,
+ 296,
+ 299,
+ 338,
+ 10,
+ 151,
+ 278,
+ 439,
+ 455,
+ 292,
+ 407,
+ 415,
+ 358,
+ 371,
+ 355,
+ 340,
+ 345,
+ 372,
+ 390,
+ 249,
+ 466,
+ 346,
+ 347,
+ 280,
+ 442,
+ 443,
+ 282,
+ 19,
+ 94,
+ 370,
+ 441,
+ 442,
+ 295,
+ 248,
+ 419,
+ 197,
+ 263,
+ 255,
+ 359,
+ 440,
+ 275,
+ 274,
+ 300,
+ 383,
+ 368,
+ 351,
+ 412,
+ 465,
+ 263,
+ 467,
+ 466,
+ 301,
+ 368,
+ 389,
+ 380,
+ 374,
+ 386,
+ 395,
+ 378,
+ 379,
+ 412,
+ 351,
+ 419,
+ 436,
+ 426,
+ 322,
+ 373,
+ 390,
+ 388,
+ 2,
+ 164,
+ 393,
+ 370,
+ 462,
+ 461,
+ 164,
+ 0,
+ 267,
+ 302,
+ 11,
+ 12,
+ 374,
+ 373,
+ 387,
+ 268,
+ 12,
+ 13,
+ 293,
+ 300,
+ 301,
+ 446,
+ 261,
+ 340,
+ 385,
+ 384,
+ 381,
+ 330,
+ 266,
+ 425,
+ 426,
+ 423,
+ 391,
+ 429,
+ 355,
+ 437,
+ 391,
+ 327,
+ 326,
+ 440,
+ 457,
+ 438,
+ 341,
+ 382,
+ 362,
+ 459,
+ 457,
+ 461,
+ 434,
+ 430,
+ 394,
+ 414,
+ 463,
+ 362,
+ 396,
+ 369,
+ 262,
+ 354,
+ 461,
+ 457,
+ 316,
+ 403,
+ 402,
+ 315,
+ 404,
+ 403,
+ 314,
+ 405,
+ 404,
+ 313,
+ 406,
+ 405,
+ 421,
+ 418,
+ 406,
+ 366,
+ 401,
+ 361,
+ 306,
+ 408,
+ 407,
+ 291,
+ 409,
+ 408,
+ 287,
+ 410,
+ 409,
+ 432,
+ 436,
+ 410,
+ 434,
+ 416,
+ 411,
+ 264,
+ 368,
+ 383,
+ 309,
+ 438,
+ 457,
+ 352,
+ 376,
+ 401,
+ 274,
+ 275,
+ 4,
+ 421,
+ 428,
+ 262,
+ 294,
+ 327,
+ 358,
+ 433,
+ 416,
+ 367,
+ 289,
+ 455,
+ 439,
+ 462,
+ 370,
+ 326,
+ 2,
+ 326,
+ 370,
+ 305,
+ 460,
+ 455,
+ 254,
+ 449,
+ 448,
+ 255,
+ 261,
+ 446,
+ 253,
+ 450,
+ 449,
+ 252,
+ 451,
+ 450,
+ 256,
+ 452,
+ 451,
+ 341,
+ 453,
+ 452,
+ 413,
+ 464,
+ 463,
+ 441,
+ 413,
+ 414,
+ 258,
+ 442,
+ 441,
+ 257,
+ 443,
+ 442,
+ 259,
+ 444,
+ 443,
+ 260,
+ 445,
+ 444,
+ 467,
+ 342,
+ 445,
+ 459,
+ 458,
+ 250,
+ 289,
+ 392,
+ 290,
+ 290,
+ 328,
+ 460,
+ 376,
+ 433,
+ 435,
+ 250,
+ 290,
+ 392,
+ 411,
+ 416,
+ 433,
+ 341,
+ 463,
+ 464,
+ 453,
+ 464,
+ 465,
+ 357,
+ 465,
+ 412,
+ 343,
+ 412,
+ 399,
+ 360,
+ 363,
+ 440,
+ 437,
+ 399,
+ 456,
+ 420,
+ 456,
+ 363,
+ 401,
+ 435,
+ 288,
+ 372,
+ 383,
+ 353,
+ 339,
+ 255,
+ 249,
+ 448,
+ 261,
+ 255,
+ 133,
+ 243,
+ 190,
+ 133,
+ 155,
+ 112,
+ 33,
+ 246,
+ 247,
+ 33,
+ 130,
+ 25,
+ 398,
+ 384,
+ 286,
+ 362,
+ 398,
+ 414,
+ 362,
+ 463,
+ 341,
+ 263,
+ 359,
+ 467,
+ 263,
+ 249,
+ 255,
+ 466,
+ 467,
+ 260,
+ 75,
+ 60,
+ 166,
+ 238,
+ 239,
+ 79,
+ 162,
+ 127,
+ 139,
+ 72,
+ 11,
+ 37,
+ 121,
+ 232,
+ 120,
+ 73,
+ 72,
+ 39,
+ 114,
+ 128,
+ 47,
+ 233,
+ 232,
+ 128,
+ 103,
+ 104,
+ 67,
+ 152,
+ 175,
+ 148,
+ 173,
+ 157,
+ 155,
+ 119,
+ 118,
+ 101,
+ 74,
+ 73,
+ 40,
+ 107,
+ 9,
+ 108,
+ 49,
+ 48,
+ 131,
+ 32,
+ 194,
+ 211,
+ 184,
+ 74,
+ 185,
+ 191,
+ 80,
+ 183,
+ 185,
+ 40,
+ 186,
+ 119,
+ 230,
+ 118,
+ 210,
+ 202,
+ 214,
+ 84,
+ 83,
+ 17,
+ 77,
+ 76,
+ 146,
+ 161,
+ 160,
+ 30,
+ 190,
+ 56,
+ 173,
+ 182,
+ 106,
+ 194,
+ 138,
+ 135,
+ 192,
+ 129,
+ 203,
+ 98,
+ 54,
+ 21,
+ 68,
+ 5,
+ 51,
+ 4,
+ 145,
+ 144,
+ 23,
+ 90,
+ 77,
+ 91,
+ 207,
+ 205,
+ 187,
+ 83,
+ 201,
+ 18,
+ 181,
+ 91,
+ 182,
+ 180,
+ 90,
+ 181,
+ 16,
+ 85,
+ 17,
+ 205,
+ 206,
+ 36,
+ 176,
+ 148,
+ 140,
+ 165,
+ 92,
+ 39,
+ 245,
+ 193,
+ 244,
+ 27,
+ 159,
+ 28,
+ 30,
+ 247,
+ 161,
+ 174,
+ 236,
+ 196,
+ 103,
+ 54,
+ 104,
+ 55,
+ 193,
+ 8,
+ 111,
+ 117,
+ 31,
+ 221,
+ 189,
+ 55,
+ 240,
+ 98,
+ 99,
+ 142,
+ 126,
+ 100,
+ 219,
+ 166,
+ 218,
+ 112,
+ 155,
+ 26,
+ 198,
+ 209,
+ 131,
+ 169,
+ 135,
+ 150,
+ 114,
+ 47,
+ 217,
+ 224,
+ 223,
+ 53,
+ 220,
+ 45,
+ 134,
+ 32,
+ 211,
+ 140,
+ 109,
+ 67,
+ 108,
+ 146,
+ 43,
+ 91,
+ 231,
+ 230,
+ 120,
+ 113,
+ 226,
+ 247,
+ 105,
+ 63,
+ 52,
+ 241,
+ 238,
+ 242,
+ 124,
+ 46,
+ 156,
+ 95,
+ 78,
+ 96,
+ 70,
+ 46,
+ 63,
+ 116,
+ 143,
+ 227,
+ 116,
+ 123,
+ 111,
+ 1,
+ 44,
+ 19,
+ 3,
+ 236,
+ 51,
+ 207,
+ 216,
+ 205,
+ 26,
+ 154,
+ 22,
+ 165,
+ 39,
+ 167,
+ 199,
+ 200,
+ 208,
+ 101,
+ 36,
+ 100,
+ 43,
+ 57,
+ 202,
+ 242,
+ 20,
+ 99,
+ 56,
+ 28,
+ 157,
+ 124,
+ 35,
+ 113,
+ 29,
+ 160,
+ 27,
+ 211,
+ 204,
+ 210,
+ 124,
+ 113,
+ 46,
+ 106,
+ 43,
+ 204,
+ 96,
+ 62,
+ 77,
+ 227,
+ 137,
+ 116,
+ 73,
+ 41,
+ 72,
+ 36,
+ 203,
+ 142,
+ 235,
+ 64,
+ 240,
+ 48,
+ 49,
+ 64,
+ 42,
+ 41,
+ 74,
+ 214,
+ 212,
+ 207,
+ 183,
+ 42,
+ 184,
+ 210,
+ 169,
+ 211,
+ 140,
+ 170,
+ 176,
+ 104,
+ 105,
+ 69,
+ 193,
+ 122,
+ 168,
+ 50,
+ 123,
+ 187,
+ 89,
+ 96,
+ 90,
+ 66,
+ 65,
+ 107,
+ 179,
+ 89,
+ 180,
+ 119,
+ 101,
+ 120,
+ 68,
+ 63,
+ 104,
+ 234,
+ 93,
+ 227,
+ 16,
+ 15,
+ 85,
+ 209,
+ 129,
+ 49,
+ 15,
+ 14,
+ 86,
+ 107,
+ 55,
+ 9,
+ 120,
+ 100,
+ 121,
+ 153,
+ 145,
+ 22,
+ 178,
+ 88,
+ 179,
+ 197,
+ 6,
+ 196,
+ 89,
+ 88,
+ 96,
+ 135,
+ 138,
+ 136,
+ 138,
+ 215,
+ 172,
+ 218,
+ 115,
+ 219,
+ 41,
+ 42,
+ 81,
+ 5,
+ 195,
+ 51,
+ 57,
+ 43,
+ 61,
+ 208,
+ 171,
+ 199,
+ 41,
+ 81,
+ 38,
+ 224,
+ 53,
+ 225,
+ 24,
+ 144,
+ 110,
+ 105,
+ 52,
+ 66,
+ 118,
+ 229,
+ 117,
+ 227,
+ 34,
+ 234,
+ 66,
+ 107,
+ 69,
+ 10,
+ 109,
+ 151,
+ 219,
+ 48,
+ 235,
+ 183,
+ 62,
+ 191,
+ 142,
+ 129,
+ 126,
+ 116,
+ 111,
+ 143,
+ 7,
+ 163,
+ 246,
+ 118,
+ 117,
+ 50,
+ 223,
+ 222,
+ 52,
+ 94,
+ 19,
+ 141,
+ 222,
+ 221,
+ 65,
+ 196,
+ 3,
+ 197,
+ 45,
+ 220,
+ 44,
+ 156,
+ 70,
+ 139,
+ 188,
+ 122,
+ 245,
+ 139,
+ 71,
+ 162,
+ 145,
+ 153,
+ 159,
+ 149,
+ 170,
+ 150,
+ 122,
+ 188,
+ 196,
+ 206,
+ 216,
+ 92,
+ 163,
+ 144,
+ 161,
+ 164,
+ 2,
+ 167,
+ 242,
+ 141,
+ 241,
+ 0,
+ 164,
+ 37,
+ 11,
+ 72,
+ 12,
+ 144,
+ 145,
+ 160,
+ 12,
+ 38,
+ 13,
+ 70,
+ 63,
+ 71,
+ 31,
+ 226,
+ 111,
+ 157,
+ 158,
+ 154,
+ 36,
+ 101,
+ 205,
+ 203,
+ 206,
+ 165,
+ 126,
+ 209,
+ 217,
+ 98,
+ 165,
+ 97,
+ 237,
+ 220,
+ 218,
+ 237,
+ 239,
+ 241,
+ 210,
+ 214,
+ 169,
+ 140,
+ 171,
+ 32,
+ 241,
+ 125,
+ 237,
+ 179,
+ 86,
+ 178,
+ 180,
+ 85,
+ 179,
+ 181,
+ 84,
+ 180,
+ 182,
+ 83,
+ 181,
+ 194,
+ 201,
+ 182,
+ 177,
+ 137,
+ 132,
+ 184,
+ 76,
+ 183,
+ 185,
+ 61,
+ 184,
+ 186,
+ 57,
+ 185,
+ 216,
+ 212,
+ 186,
+ 192,
+ 214,
+ 187,
+ 139,
+ 34,
+ 156,
+ 218,
+ 79,
+ 237,
+ 147,
+ 123,
+ 177,
+ 45,
+ 44,
+ 4,
+ 208,
+ 201,
+ 32,
+ 98,
+ 64,
+ 129,
+ 192,
+ 213,
+ 138,
+ 235,
+ 59,
+ 219,
+ 141,
+ 242,
+ 97,
+ 97,
+ 2,
+ 141,
+ 240,
+ 75,
+ 235,
+ 229,
+ 24,
+ 228,
+ 31,
+ 25,
+ 226,
+ 230,
+ 23,
+ 229,
+ 231,
+ 22,
+ 230,
+ 232,
+ 26,
+ 231,
+ 233,
+ 112,
+ 232,
+ 244,
+ 189,
+ 243,
+ 189,
+ 221,
+ 190,
+ 222,
+ 28,
+ 221,
+ 223,
+ 27,
+ 222,
+ 224,
+ 29,
+ 223,
+ 225,
+ 30,
+ 224,
+ 113,
+ 247,
+ 225,
+ 99,
+ 60,
+ 240,
+ 213,
+ 147,
+ 215,
+ 60,
+ 20,
+ 166,
+ 192,
+ 187,
+ 213,
+ 243,
+ 112,
+ 244,
+ 244,
+ 233,
+ 245,
+ 245,
+ 128,
+ 188,
+ 188,
+ 114,
+ 174,
+ 134,
+ 131,
+ 220,
+ 174,
+ 217,
+ 236,
+ 236,
+ 198,
+ 134,
+ 215,
+ 177,
+ 58,
+ 156,
+ 143,
+ 124,
+ 25,
+ 110,
+ 7,
+ 31,
+ 228,
+ 25,
+ 264,
+ 356,
+ 368,
+ 0,
+ 11,
+ 267,
+ 451,
+ 452,
+ 349,
+ 267,
+ 302,
+ 269,
+ 350,
+ 357,
+ 277,
+ 350,
+ 452,
+ 357,
+ 299,
+ 333,
+ 297,
+ 396,
+ 175,
+ 377,
+ 381,
+ 384,
+ 382,
+ 280,
+ 347,
+ 330,
+ 269,
+ 303,
+ 270,
+ 151,
+ 9,
+ 337,
+ 344,
+ 278,
+ 360,
+ 424,
+ 418,
+ 431,
+ 270,
+ 304,
+ 409,
+ 272,
+ 310,
+ 407,
+ 322,
+ 270,
+ 410,
+ 449,
+ 450,
+ 347,
+ 432,
+ 422,
+ 434,
+ 18,
+ 313,
+ 17,
+ 291,
+ 306,
+ 375,
+ 259,
+ 387,
+ 260,
+ 424,
+ 335,
+ 418,
+ 434,
+ 364,
+ 416,
+ 391,
+ 423,
+ 327,
+ 301,
+ 251,
+ 298,
+ 275,
+ 281,
+ 4,
+ 254,
+ 373,
+ 253,
+ 375,
+ 307,
+ 321,
+ 280,
+ 425,
+ 411,
+ 200,
+ 421,
+ 18,
+ 335,
+ 321,
+ 406,
+ 321,
+ 320,
+ 405,
+ 314,
+ 315,
+ 17,
+ 423,
+ 426,
+ 266,
+ 396,
+ 377,
+ 369,
+ 270,
+ 322,
+ 269,
+ 413,
+ 417,
+ 464,
+ 385,
+ 386,
+ 258,
+ 248,
+ 456,
+ 419,
+ 298,
+ 284,
+ 333,
+ 168,
+ 417,
+ 8,
+ 448,
+ 346,
+ 261,
+ 417,
+ 413,
+ 285,
+ 326,
+ 327,
+ 328,
+ 277,
+ 355,
+ 329,
+ 309,
+ 392,
+ 438,
+ 381,
+ 382,
+ 256,
+ 279,
+ 429,
+ 360,
+ 365,
+ 364,
+ 379,
+ 355,
+ 277,
+ 437,
+ 282,
+ 443,
+ 283,
+ 281,
+ 275,
+ 363,
+ 395,
+ 431,
+ 369,
+ 299,
+ 297,
+ 337,
+ 335,
+ 273,
+ 321,
+ 348,
+ 450,
+ 349,
+ 359,
+ 446,
+ 467,
+ 283,
+ 293,
+ 282,
+ 250,
+ 458,
+ 462,
+ 300,
+ 276,
+ 383,
+ 292,
+ 308,
+ 325,
+ 283,
+ 276,
+ 293,
+ 264,
+ 372,
+ 447,
+ 346,
+ 352,
+ 340,
+ 354,
+ 274,
+ 19,
+ 363,
+ 456,
+ 281,
+ 426,
+ 436,
+ 425,
+ 380,
+ 381,
+ 252,
+ 267,
+ 269,
+ 393,
+ 421,
+ 200,
+ 428,
+ 371,
+ 266,
+ 329,
+ 432,
+ 287,
+ 422,
+ 290,
+ 250,
+ 328,
+ 385,
+ 258,
+ 384,
+ 446,
+ 265,
+ 342,
+ 386,
+ 387,
+ 257,
+ 422,
+ 424,
+ 430,
+ 445,
+ 342,
+ 276,
+ 422,
+ 273,
+ 424,
+ 306,
+ 292,
+ 307,
+ 352,
+ 366,
+ 345,
+ 268,
+ 271,
+ 302,
+ 358,
+ 423,
+ 371,
+ 327,
+ 294,
+ 460,
+ 331,
+ 279,
+ 294,
+ 303,
+ 271,
+ 304,
+ 436,
+ 432,
+ 427,
+ 304,
+ 272,
+ 408,
+ 395,
+ 394,
+ 431,
+ 378,
+ 395,
+ 400,
+ 296,
+ 334,
+ 299,
+ 6,
+ 351,
+ 168,
+ 376,
+ 352,
+ 411,
+ 307,
+ 325,
+ 320,
+ 285,
+ 295,
+ 336,
+ 320,
+ 319,
+ 404,
+ 329,
+ 330,
+ 349,
+ 334,
+ 293,
+ 333,
+ 366,
+ 323,
+ 447,
+ 316,
+ 15,
+ 315,
+ 331,
+ 358,
+ 279,
+ 317,
+ 14,
+ 316,
+ 8,
+ 285,
+ 9,
+ 277,
+ 329,
+ 350,
+ 253,
+ 374,
+ 252,
+ 319,
+ 318,
+ 403,
+ 351,
+ 6,
+ 419,
+ 324,
+ 318,
+ 325,
+ 397,
+ 367,
+ 365,
+ 288,
+ 435,
+ 397,
+ 278,
+ 344,
+ 439,
+ 310,
+ 272,
+ 311,
+ 248,
+ 195,
+ 281,
+ 375,
+ 273,
+ 291,
+ 175,
+ 396,
+ 199,
+ 312,
+ 311,
+ 268,
+ 276,
+ 283,
+ 445,
+ 390,
+ 373,
+ 339,
+ 295,
+ 282,
+ 296,
+ 448,
+ 449,
+ 346,
+ 356,
+ 264,
+ 454,
+ 337,
+ 336,
+ 299,
+ 337,
+ 338,
+ 151,
+ 294,
+ 278,
+ 455,
+ 308,
+ 292,
+ 415,
+ 429,
+ 358,
+ 355,
+ 265,
+ 340,
+ 372,
+ 388,
+ 390,
+ 466,
+ 352,
+ 346,
+ 280,
+ 295,
+ 442,
+ 282,
+ 354,
+ 19,
+ 370,
+ 285,
+ 441,
+ 295,
+ 195,
+ 248,
+ 197,
+ 457,
+ 440,
+ 274,
+ 301,
+ 300,
+ 368,
+ 417,
+ 351,
+ 465,
+ 251,
+ 301,
+ 389,
+ 385,
+ 380,
+ 386,
+ 394,
+ 395,
+ 379,
+ 399,
+ 412,
+ 419,
+ 410,
+ 436,
+ 322,
+ 387,
+ 373,
+ 388,
+ 326,
+ 2,
+ 393,
+ 354,
+ 370,
+ 461,
+ 393,
+ 164,
+ 267,
+ 268,
+ 302,
+ 12,
+ 386,
+ 374,
+ 387,
+ 312,
+ 268,
+ 13,
+ 298,
+ 293,
+ 301,
+ 265,
+ 446,
+ 340,
+ 380,
+ 385,
+ 381,
+ 280,
+ 330,
+ 425,
+ 322,
+ 426,
+ 391,
+ 420,
+ 429,
+ 437,
+ 393,
+ 391,
+ 326,
+ 344,
+ 440,
+ 438,
+ 458,
+ 459,
+ 461,
+ 364,
+ 434,
+ 394,
+ 428,
+ 396,
+ 262,
+ 274,
+ 354,
+ 457,
+ 317,
+ 316,
+ 402,
+ 316,
+ 315,
+ 403,
+ 315,
+ 314,
+ 404,
+ 314,
+ 313,
+ 405,
+ 313,
+ 421,
+ 406,
+ 323,
+ 366,
+ 361,
+ 292,
+ 306,
+ 407,
+ 306,
+ 291,
+ 408,
+ 291,
+ 287,
+ 409,
+ 287,
+ 432,
+ 410,
+ 427,
+ 434,
+ 411,
+ 372,
+ 264,
+ 383,
+ 459,
+ 309,
+ 457,
+ 366,
+ 352,
+ 401,
+ 1,
+ 274,
+ 4,
+ 418,
+ 421,
+ 262,
+ 331,
+ 294,
+ 358,
+ 435,
+ 433,
+ 367,
+ 392,
+ 289,
+ 439,
+ 328,
+ 462,
+ 326,
+ 94,
+ 2,
+ 370,
+ 289,
+ 305,
+ 455,
+ 339,
+ 254,
+ 448,
+ 359,
+ 255,
+ 446,
+ 254,
+ 253,
+ 449,
+ 253,
+ 252,
+ 450,
+ 252,
+ 256,
+ 451,
+ 256,
+ 341,
+ 452,
+ 414,
+ 413,
+ 463,
+ 286,
+ 441,
+ 414,
+ 286,
+ 258,
+ 441,
+ 258,
+ 257,
+ 442,
+ 257,
+ 259,
+ 443,
+ 259,
+ 260,
+ 444,
+ 260,
+ 467,
+ 445,
+ 309,
+ 459,
+ 250,
+ 305,
+ 289,
+ 290,
+ 305,
+ 290,
+ 460,
+ 401,
+ 376,
+ 435,
+ 309,
+ 250,
+ 392,
+ 376,
+ 411,
+ 433,
+ 453,
+ 341,
+ 464,
+ 357,
+ 453,
+ 465,
+ 343,
+ 357,
+ 412,
+ 437,
+ 343,
+ 399,
+ 344,
+ 360,
+ 440,
+ 420,
+ 437,
+ 456,
+ 360,
+ 420,
+ 363,
+ 361,
+ 401,
+ 288,
+ 265,
+ 372,
+ 353,
+ 390,
+ 339,
+ 249,
+ 339,
+ 448,
+ 255
+];
+var VTX68 = [
+ 127,
+ 234,
+ 132,
+ 58,
+ 172,
+ 150,
+ 149,
+ 148,
+ 152,
+ 377,
+ 378,
+ 379,
+ 397,
+ 288,
+ 361,
+ 454,
+ 356,
+ 70,
+ 63,
+ 105,
+ 66,
+ 107,
+ 336,
+ 296,
+ 334,
+ 293,
+ 300,
+ 168,
+ 6,
+ 195,
+ 4,
+ 98,
+ 97,
+ 2,
+ 326,
+ 327,
+ 33,
+ 160,
+ 158,
+ 133,
+ 153,
+ 144,
+ 362,
+ 385,
+ 387,
+ 263,
+ 373,
+ 380,
+ 57,
+ 40,
+ 37,
+ 0,
+ 267,
+ 270,
+ 287,
+ 321,
+ 314,
+ 17,
+ 84,
+ 91,
+ 78,
+ 81,
+ 13,
+ 311,
+ 308,
+ 402,
+ 14,
+ 178
+];
+var VTX33 = [33, 133, 362, 263, 1, 62, 308, 159, 145, 386, 374, 6, 102, 331, 2, 13, 14, 70, 105, 107, 336, 334, 300, 54, 10, 284, 50, 280, 234, 454, 58, 288, 152];
+var VTX7 = [33, 133, 362, 263, 1, 78, 308];
+var UV68 = VTX68.map((x) => UV468[x]);
+var UV33 = VTX33.map((x) => UV468[x]);
+var UV7 = VTX7.map((x) => UV468[x]);
+function connectionsToIndices(connections) {
+ const indices = connections.map((connection) => connection[0]);
+ indices.push(connections[connections.length - 1][1]);
+ return indices;
+}
+var pairsLips = [
+ [61, 146],
+ [146, 91],
+ [91, 181],
+ [181, 84],
+ [84, 17],
+ [17, 314],
+ [314, 405],
+ [405, 321],
+ [321, 375],
+ [375, 291],
+ [61, 185],
+ [185, 40],
+ [40, 39],
+ [39, 37],
+ [37, 0],
+ [0, 267],
+ [267, 269],
+ [269, 270],
+ [270, 409],
+ [409, 291],
+ [78, 95],
+ [95, 88],
+ [88, 178],
+ [178, 87],
+ [87, 14],
+ [14, 317],
+ [317, 402],
+ [402, 318],
+ [318, 324],
+ [324, 308],
+ [78, 191],
+ [191, 80],
+ [80, 81],
+ [81, 82],
+ [82, 13],
+ [13, 312],
+ [312, 311],
+ [311, 310],
+ [310, 415],
+ [415, 308]
+];
+var pairsLeftEye = [[263, 249], [249, 390], [390, 373], [373, 374], [374, 380], [380, 381], [381, 382], [382, 362], [263, 466], [466, 388], [388, 387], [387, 386], [386, 385], [385, 384], [384, 398], [398, 362]];
+var pairsLeftEyebrow = [[276, 283], [283, 282], [282, 295], [295, 285], [300, 293], [293, 334], [334, 296], [296, 336]];
+var pairsLeftIris = [[474, 475], [475, 476], [476, 477], [477, 474]];
+var pairsRightEye = [[33, 7], [7, 163], [163, 144], [144, 145], [145, 153], [153, 154], [154, 155], [155, 133], [33, 246], [246, 161], [161, 160], [160, 159], [159, 158], [158, 157], [157, 173], [173, 133]];
+var pairsRightEyebrow = [[46, 53], [53, 52], [52, 65], [65, 55], [70, 63], [63, 105], [105, 66], [66, 107]];
+var pairsRightIris = [[469, 470], [470, 471], [471, 472], [472, 469]];
+var pairsFaceContour = [
+ [10, 338],
+ [338, 297],
+ [297, 332],
+ [332, 284],
+ [284, 251],
+ [251, 389],
+ [389, 356],
+ [356, 454],
+ [454, 323],
+ [323, 361],
+ [361, 288],
+ [288, 397],
+ [397, 365],
+ [365, 379],
+ [379, 378],
+ [378, 400],
+ [400, 377],
+ [377, 152],
+ [152, 148],
+ [148, 176],
+ [176, 149],
+ [149, 150],
+ [150, 136],
+ [136, 172],
+ [172, 58],
+ [58, 132],
+ [132, 93],
+ [93, 234],
+ [234, 127],
+ [127, 162],
+ [162, 21],
+ [21, 54],
+ [54, 103],
+ [103, 67],
+ [67, 109],
+ [109, 10]
+];
+var contourKeypoints = {
+ lips: connectionsToIndices(pairsLips),
+ leftEye: connectionsToIndices(pairsLeftEye),
+ leftEyebrow: connectionsToIndices(pairsLeftEyebrow),
+ leftIris: connectionsToIndices(pairsLeftIris),
+ rightEye: connectionsToIndices(pairsRightEye),
+ rightEyebrow: connectionsToIndices(pairsRightEyebrow),
+ rightIris: connectionsToIndices(pairsRightIris),
+ faceOval: connectionsToIndices(pairsFaceContour)
+};
+
+// src/face/constants.ts
+var LIPS_CONNECTIONS = [
+ [61, 146],
+ [146, 91],
+ [91, 181],
+ [181, 84],
+ [84, 17],
+ [17, 314],
+ [314, 405],
+ [405, 321],
+ [321, 375],
+ [375, 291],
+ [61, 185],
+ [185, 40],
+ [40, 39],
+ [39, 37],
+ [37, 0],
+ [0, 267],
+ [267, 269],
+ [269, 270],
+ [270, 409],
+ [409, 291],
+ [78, 95],
+ [95, 88],
+ [88, 178],
+ [178, 87],
+ [87, 14],
+ [14, 317],
+ [317, 402],
+ [402, 318],
+ [318, 324],
+ [324, 308],
+ [78, 191],
+ [191, 80],
+ [80, 81],
+ [81, 82],
+ [82, 13],
+ [13, 312],
+ [312, 311],
+ [311, 310],
+ [310, 415],
+ [415, 308]
+];
+var LEFT_EYE_CONNECTIONS = [[263, 249], [249, 390], [390, 373], [373, 374], [374, 380], [380, 381], [381, 382], [382, 362], [263, 466], [466, 388], [388, 387], [387, 386], [386, 385], [385, 384], [384, 398], [398, 362]];
+var LEFT_EYEBROW_CONNECTIONS = [[276, 283], [283, 282], [282, 295], [295, 285], [300, 293], [293, 334], [334, 296], [296, 336]];
+var LEFT_IRIS_CONNECTIONS = [[474, 475], [475, 476], [476, 477], [477, 474]];
+var RIGHT_EYE_CONNECTIONS = [[33, 7], [7, 163], [163, 144], [144, 145], [145, 153], [153, 154], [154, 155], [155, 133], [33, 246], [246, 161], [161, 160], [160, 159], [159, 158], [158, 157], [157, 173], [173, 133]];
+var RIGHT_EYEBROW_CONNECTIONS = [[46, 53], [53, 52], [52, 65], [65, 55], [70, 63], [63, 105], [105, 66], [66, 107]];
+var RIGHT_IRIS_CONNECTIONS = [[469, 470], [470, 471], [471, 472], [472, 469]];
+var FACE_OVAL_CONNECTIONS = [
+ [10, 338],
+ [338, 297],
+ [297, 332],
+ [332, 284],
+ [284, 251],
+ [251, 389],
+ [389, 356],
+ [356, 454],
+ [454, 323],
+ [323, 361],
+ [361, 288],
+ [288, 397],
+ [397, 365],
+ [365, 379],
+ [379, 378],
+ [378, 400],
+ [400, 377],
+ [377, 152],
+ [152, 148],
+ [148, 176],
+ [176, 149],
+ [149, 150],
+ [150, 136],
+ [136, 172],
+ [172, 58],
+ [58, 132],
+ [132, 93],
+ [93, 234],
+ [234, 127],
+ [127, 162],
+ [162, 21],
+ [21, 54],
+ [54, 103],
+ [103, 67],
+ [67, 109],
+ [109, 10]
+];
+function connectionsToIndices2(connections) {
+ const indices = connections.map((connection) => connection[0]);
+ indices.push(connections[connections.length - 1][1]);
+ return indices;
+}
+var MEDIAPIPE_FACE_MESH_KEYPOINTS_BY_CONTOUR = {
+ lips: connectionsToIndices2(LIPS_CONNECTIONS),
+ leftEye: connectionsToIndices2(LEFT_EYE_CONNECTIONS),
+ leftEyebrow: connectionsToIndices2(LEFT_EYEBROW_CONNECTIONS),
+ leftIris: connectionsToIndices2(LEFT_IRIS_CONNECTIONS),
+ rightEye: connectionsToIndices2(RIGHT_EYE_CONNECTIONS),
+ rightEyebrow: connectionsToIndices2(RIGHT_EYEBROW_CONNECTIONS),
+ rightIris: connectionsToIndices2(RIGHT_IRIS_CONNECTIONS),
+ faceOval: connectionsToIndices2(FACE_OVAL_CONNECTIONS)
+};
+var indexLabelPairs = Object.entries(MEDIAPIPE_FACE_MESH_KEYPOINTS_BY_CONTOUR).map(([label, indices]) => indices.map((index2) => [index2, label])).flat();
+var MEDIAPIPE_FACE_MESH_KEYPOINTS = new Map(indexLabelPairs);
+var LANDMARKS_REFINEMENT_LIPS_CONFIG = [
+ 61,
+ 146,
+ 91,
+ 181,
+ 84,
+ 17,
+ 314,
+ 405,
+ 321,
+ 375,
+ 291,
+ 185,
+ 40,
+ 39,
+ 37,
+ 0,
+ 267,
+ 269,
+ 270,
+ 409,
+ 78,
+ 95,
+ 88,
+ 178,
+ 87,
+ 14,
+ 317,
+ 402,
+ 318,
+ 324,
+ 308,
+ 191,
+ 80,
+ 81,
+ 82,
+ 13,
+ 312,
+ 311,
+ 310,
+ 415,
+ 76,
+ 77,
+ 90,
+ 180,
+ 85,
+ 16,
+ 315,
+ 404,
+ 320,
+ 307,
+ 306,
+ 184,
+ 74,
+ 73,
+ 72,
+ 11,
+ 302,
+ 303,
+ 304,
+ 408,
+ 62,
+ 96,
+ 89,
+ 179,
+ 86,
+ 15,
+ 316,
+ 403,
+ 319,
+ 325,
+ 292,
+ 183,
+ 42,
+ 41,
+ 38,
+ 12,
+ 268,
+ 271,
+ 272,
+ 407
+];
+var LANDMARKS_REFINEMENT_LEFT_EYE_CONFIG = [
+ 33,
+ 7,
+ 163,
+ 144,
+ 145,
+ 153,
+ 154,
+ 155,
+ 133,
+ 246,
+ 161,
+ 160,
+ 159,
+ 158,
+ 157,
+ 173,
+ 130,
+ 25,
+ 110,
+ 24,
+ 23,
+ 22,
+ 26,
+ 112,
+ 243,
+ 247,
+ 30,
+ 29,
+ 27,
+ 28,
+ 56,
+ 190,
+ 226,
+ 31,
+ 228,
+ 229,
+ 230,
+ 231,
+ 232,
+ 233,
+ 244,
+ 113,
+ 225,
+ 224,
+ 223,
+ 222,
+ 221,
+ 189,
+ 35,
+ 124,
+ 46,
+ 53,
+ 52,
+ 65,
+ 143,
+ 111,
+ 117,
+ 118,
+ 119,
+ 120,
+ 121,
+ 128,
+ 245,
+ 156,
+ 70,
+ 63,
+ 105,
+ 66,
+ 107,
+ 55,
+ 193
+];
+var LANDMARKS_REFINEMENT_RIGHT_EYE_CONFIG = [
+ 263,
+ 249,
+ 390,
+ 373,
+ 374,
+ 380,
+ 381,
+ 382,
+ 362,
+ 466,
+ 388,
+ 387,
+ 386,
+ 385,
+ 384,
+ 398,
+ 359,
+ 255,
+ 339,
+ 254,
+ 253,
+ 252,
+ 256,
+ 341,
+ 463,
+ 467,
+ 260,
+ 259,
+ 257,
+ 258,
+ 286,
+ 414,
+ 446,
+ 261,
+ 448,
+ 449,
+ 450,
+ 451,
+ 452,
+ 453,
+ 464,
+ 342,
+ 445,
+ 444,
+ 443,
+ 442,
+ 441,
+ 413,
+ 265,
+ 353,
+ 276,
+ 283,
+ 282,
+ 295,
+ 372,
+ 340,
+ 346,
+ 347,
+ 348,
+ 349,
+ 350,
+ 357,
+ 465,
+ 383,
+ 300,
+ 293,
+ 334,
+ 296,
+ 336,
+ 285,
+ 417
+];
+
+// src/draw/face.ts
+var localOptions;
+function drawLabels(f, ctx) {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
+ if (!localOptions.drawLabels || ((_a = localOptions.faceLabels) == null ? void 0 : _a.length) === 0)
+ return;
+ let l = localOptions.faceLabels.slice();
+ if (f.score)
+ l = replace(l, "[score]", 100 * f.score);
+ if (f.gender)
+ l = replace(l, "[gender]", f.gender);
+ if (f.genderScore)
+ l = replace(l, "[genderScore]", 100 * f.genderScore);
+ if (f.age)
+ l = replace(l, "[age]", f.age);
+ if (f.distance)
+ l = replace(l, "[distance]", 100 * f.distance);
+ if (f.real)
+ l = replace(l, "[real]", 100 * f.real);
+ if (f.live)
+ l = replace(l, "[live]", 100 * f.live);
+ if (f.emotion && f.emotion.length > 0) {
+ const emotion2 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`);
+ if (emotion2.length > 3)
+ emotion2.length = 3;
+ l = replace(l, "[emotions]", emotion2.join(" "));
+ }
+ if ((_c = (_b = f.rotation) == null ? void 0 : _b.angle) == null ? void 0 : _c.roll)
+ l = replace(l, "[roll]", rad2deg(f.rotation.angle.roll));
+ if ((_e = (_d = f.rotation) == null ? void 0 : _d.angle) == null ? void 0 : _e.yaw)
+ l = replace(l, "[yaw]", rad2deg(f.rotation.angle.yaw));
+ if ((_g = (_f = f.rotation) == null ? void 0 : _f.angle) == null ? void 0 : _g.pitch)
+ l = replace(l, "[pitch]", rad2deg(f.rotation.angle.pitch));
+ if ((_i = (_h = f.rotation) == null ? void 0 : _h.gaze) == null ? void 0 : _i.bearing)
+ l = replace(l, "[gaze]", rad2deg(f.rotation.gaze.bearing));
+ labels(ctx, l, f.box[0], f.box[1], localOptions);
+}
+function drawIrisElipse(f, ctx) {
+ var _a, _b, _c, _d;
+ if (((_a = f.annotations) == null ? void 0 : _a.leftEyeIris) && ((_b = f.annotations) == null ? void 0 : _b.leftEyeIris[0])) {
+ ctx.strokeStyle = localOptions.useDepth ? "rgba(255, 200, 255, 0.3)" : localOptions.color;
+ ctx.beginPath();
+ const sizeX = Math.abs(f.annotations.leftEyeIris[3][0] - f.annotations.leftEyeIris[1][0]) / 2;
+ const sizeY = Math.abs(f.annotations.leftEyeIris[4][1] - f.annotations.leftEyeIris[2][1]) / 2;
+ ctx.ellipse(f.annotations.leftEyeIris[0][0], f.annotations.leftEyeIris[0][1], sizeX, sizeY, 0, 0, 2 * Math.PI);
+ ctx.stroke();
+ if (localOptions.fillPolygons) {
+ ctx.fillStyle = localOptions.useDepth ? "rgba(255, 255, 200, 0.3)" : localOptions.color;
+ ctx.fill();
+ }
+ }
+ if (((_c = f.annotations) == null ? void 0 : _c.rightEyeIris) && ((_d = f.annotations) == null ? void 0 : _d.rightEyeIris[0])) {
+ ctx.strokeStyle = localOptions.useDepth ? "rgba(255, 200, 255, 0.3)" : localOptions.color;
+ ctx.beginPath();
+ const sizeX = Math.abs(f.annotations.rightEyeIris[3][0] - f.annotations.rightEyeIris[1][0]) / 2;
+ const sizeY = Math.abs(f.annotations.rightEyeIris[4][1] - f.annotations.rightEyeIris[2][1]) / 2;
+ ctx.ellipse(f.annotations.rightEyeIris[0][0], f.annotations.rightEyeIris[0][1], sizeX, sizeY, 0, 0, 2 * Math.PI);
+ ctx.stroke();
+ if (localOptions.fillPolygons) {
+ ctx.fillStyle = localOptions.useDepth ? "rgba(255, 255, 200, 0.3)" : localOptions.color;
+ ctx.fill();
+ }
+ }
+}
+function drawGazeSpheres(f, ctx) {
+ var _a;
+ if (localOptions.drawGaze && ((_a = f.rotation) == null ? void 0 : _a.angle) && typeof Path2D !== "undefined") {
+ ctx.strokeStyle = "pink";
+ const valX = f.box[0] + f.box[2] / 2 - f.box[3] * rad2deg(f.rotation.angle.yaw) / 90;
+ const valY = f.box[1] + f.box[3] / 2 + f.box[2] * rad2deg(f.rotation.angle.pitch) / 90;
+ const pathV = new Path2D(`
+ M ${f.box[0] + f.box[2] / 2} ${f.box[1]}
C
- ${o} ${e.box[1]},
- ${o} ${e.box[1]+e.box[3]},
- ${e.box[0]+e.box[2]/2} ${e.box[1]+e.box[3]}
- `),a=new Path2D(`
- M ${e.box[0]} ${e.box[1]+e.box[3]/2}
+ ${valX} ${f.box[1]},
+ ${valX} ${f.box[1] + f.box[3]},
+ ${f.box[0] + f.box[2] / 2} ${f.box[1] + f.box[3]}
+ `);
+ const pathH = new Path2D(`
+ M ${f.box[0]} ${f.box[1] + f.box[3] / 2}
C
- ${e.box[0]} ${s},
- ${e.box[0]+e.box[2]} ${s},
- ${e.box[0]+e.box[2]} ${e.box[1]+e.box[3]/2}
- `);t.stroke(a),t.stroke(A)}}function Wr(e,t){var n;if(G.drawGaze&&((n=e.rotation)==null?void 0:n.gaze.strength)&&e.rotation.gaze.bearing&&e.annotations.leftEyeIris&&e.annotations.rightEyeIris&&e.annotations.leftEyeIris[0]&&e.annotations.rightEyeIris[0]){t.strokeStyle="pink",t.fillStyle="pink";let o=[e.annotations.leftEyeIris[0][0]+Math.sin(e.rotation.gaze.bearing)*e.rotation.gaze.strength*e.box[3],e.annotations.leftEyeIris[0][1]+Math.cos(e.rotation.gaze.bearing)*e.rotation.gaze.strength*e.box[2]];ct(t,[e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1]],[o[0],o[1]],4);let s=[e.annotations.rightEyeIris[0][0]+Math.sin(e.rotation.gaze.bearing)*e.rotation.gaze.strength*e.box[3],e.annotations.rightEyeIris[0][1]+Math.cos(e.rotation.gaze.bearing)*e.rotation.gaze.strength*e.box[2]];ct(t,[e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1]],[s[0],s[1]],4)}}function Dr(e,t){if(G.drawPolygons&&e.mesh.length>=468){t.lineWidth=1;for(let n=0;ne.mesh[s]);lt(t,o,G)}Or(e,t)}}function Fr(e,t){if(G.drawPoints&&e.mesh.length>=468)for(let n=0;n0&&(Fr(s,o),Dr(s,o),Cr(s,o),Wr(s,o))}}function p2(e,t,n){var A,a;let o=J($,n);if(!t||!e)return;let s=z0(e);if(!!s){s.lineJoin="round";for(let i=0;i0)){let c=o.bodyLabels.slice();c=V(c,"[score]",100*t[i].score),L0(s,c,t[i].box[0],t[i].box[1],o)}if(o.drawPoints&&t[i].keypoints)for(let c=0;c0&&t[i].keypoints){s.font=o.font;for(let c of t[i].keypoints){if(!c.score||c.score===0)continue;let x=o.bodyPartLabels.slice();x=V(x,"[label]",c.part),x=V(x,"[score]",100*c.score),L0(s,x,c.position[0],c.position[1],o)}}if(o.drawPolygons&&t[i].keypoints&&t[i].annotations)for(let c of Object.values(t[i].annotations))for(let x of c)e1(s,x,o)}}}function u2(e,t,n){var A,a;let o=J($,n);if(!t||!e)return;let s=z0(e);if(!!s){s.lineJoin="round",s.font=o.font;for(let i of t){if(o.drawBoxes){if(s.strokeStyle=o.color,s.fillStyle=o.color,Z0(s,i.box[0],i.box[1],i.box[2],i.box[3],o),o.drawLabels&&((A=o.handLabels)==null?void 0:A.length)>0){let c=o.handLabels.slice();c=V(c,"[label]",i.label),c=V(c,"[score]",100*i.score),L0(s,c,i.box[0],i.box[1],o)}s.stroke()}if(o.drawPoints&&i.keypoints&&i.keypoints.length>0)for(let c of i.keypoints)s.fillStyle=he(c[2],o),U0(s,c[0],c[1],0,o);if(o.drawLabels&&i.annotations&&((a=o.fingerLabels)==null?void 0:a.length)>0)for(let[c,x]of Object.entries(i.annotations)){let y=o.fingerLabels.slice();y=V(y,"[label]",c),L0(s,y,x[x.length-1][0],x[x.length-1][1],o)}if(o.drawPolygons&&i.annotations){let c=x=>{if(!(!x||x.length===0||!x[0]))for(let y=0;y0?y-1:0][0],x[y>0?y-1:0][1]),s.lineTo(x[y][0],x[y][1]),s.stroke()}};s.lineWidth=o.lineWidth,c(i.annotations.index),c(i.annotations.middle),c(i.annotations.ring),c(i.annotations.pinky),c(i.annotations.thumb)}}}}function h2(e,t,n){var A;let o=J($,n);if(!t||!e)return;let s=z0(e);if(!!s){s.lineJoin="round",s.font=o.font;for(let a of t)if(o.drawBoxes){if(s.strokeStyle=o.color,s.fillStyle=o.color,Z0(s,a.box[0],a.box[1],a.box[2],a.box[3],o),o.drawLabels&&((A=o.objectLabels)==null?void 0:A.length)>0){let i=o.objectLabels.slice();i=V(i,"[label]",a.label),i=V(i,"[score]",100*a.score),L0(s,i,a.box[0],a.box[1],o)}s.stroke()}}}function b2(e,t,n){var s;let o=J($,n);if(!(!t||!e)&&o.drawGestures&&((s=o.gestureLabels)==null?void 0:s.length)>0){let A=z0(e);if(!A)return;A.font=o.font,A.fillStyle=o.color;let a=1;for(let i=0;i1&&x[1].length>0){let y=c[1]>0?`#${c[1]}`:"",l=o.gestureLabels.slice();l=V(l,"[where]",c[0]),l=V(l,"[who]",y),l=V(l,"[what]",x[1]),L0(A,l,8,2+a*o.lineHeight,o),a+=1}}}}var re={face:`face
+ ${f.box[0]} ${valY},
+ ${f.box[0] + f.box[2]} ${valY},
+ ${f.box[0] + f.box[2]} ${f.box[1] + f.box[3] / 2}
+ `);
+ ctx.stroke(pathH);
+ ctx.stroke(pathV);
+ }
+}
+function drawGazeArrows(f, ctx) {
+ var _a;
+ if (localOptions.drawGaze && ((_a = f.rotation) == null ? void 0 : _a.gaze.strength) && f.rotation.gaze.bearing && f.annotations.leftEyeIris && f.annotations.rightEyeIris && f.annotations.leftEyeIris[0] && f.annotations.rightEyeIris[0]) {
+ ctx.strokeStyle = "pink";
+ ctx.fillStyle = "pink";
+ const leftGaze = [
+ f.annotations.leftEyeIris[0][0] + Math.sin(f.rotation.gaze.bearing) * f.rotation.gaze.strength * f.box[3],
+ f.annotations.leftEyeIris[0][1] + Math.cos(f.rotation.gaze.bearing) * f.rotation.gaze.strength * f.box[2]
+ ];
+ arrow(ctx, [f.annotations.leftEyeIris[0][0], f.annotations.leftEyeIris[0][1]], [leftGaze[0], leftGaze[1]], 4);
+ const rightGaze = [
+ f.annotations.rightEyeIris[0][0] + Math.sin(f.rotation.gaze.bearing) * f.rotation.gaze.strength * f.box[3],
+ f.annotations.rightEyeIris[0][1] + Math.cos(f.rotation.gaze.bearing) * f.rotation.gaze.strength * f.box[2]
+ ];
+ arrow(ctx, [f.annotations.rightEyeIris[0][0], f.annotations.rightEyeIris[0][1]], [rightGaze[0], rightGaze[1]], 4);
+ }
+}
+function drawFacePolygons(f, ctx) {
+ if (localOptions.drawPolygons && f.mesh.length >= 468) {
+ ctx.lineWidth = 1;
+ for (let i = 0; i < TRI468.length / 3; i++) {
+ const points = [TRI468[i * 3 + 0], TRI468[i * 3 + 1], TRI468[i * 3 + 2]].map((index2) => f.mesh[index2]);
+ lines(ctx, points, localOptions);
+ }
+ drawIrisElipse(f, ctx);
+ }
+}
+function drawFacePoints(f, ctx) {
+ if (localOptions.drawPoints && f.mesh.length >= 468) {
+ for (let i = 0; i < f.mesh.length; i++) {
+ point(ctx, f.mesh[i][0], f.mesh[i][1], f.mesh[i][2], localOptions);
+ if (localOptions.drawAttention) {
+ if (LANDMARKS_REFINEMENT_LIPS_CONFIG.includes(i))
+ point(ctx, f.mesh[i][0], f.mesh[i][1], f.mesh[i][2] + 127, localOptions);
+ if (LANDMARKS_REFINEMENT_LEFT_EYE_CONFIG.includes(i))
+ point(ctx, f.mesh[i][0], f.mesh[i][1], f.mesh[i][2] - 127, localOptions);
+ if (LANDMARKS_REFINEMENT_RIGHT_EYE_CONFIG.includes(i))
+ point(ctx, f.mesh[i][0], f.mesh[i][1], f.mesh[i][2] - 127, localOptions);
+ }
+ }
+ }
+}
+function drawFaceBoxes(f, ctx) {
+ if (localOptions.drawBoxes) {
+ rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions);
+ }
+}
+function face(inCanvas2, result, drawOptions) {
+ localOptions = mergeDeep(options2, drawOptions);
+ if (!result || !inCanvas2)
+ return;
+ const ctx = getCanvasContext(inCanvas2);
+ if (!ctx)
+ return;
+ ctx.font = localOptions.font;
+ ctx.strokeStyle = localOptions.color;
+ ctx.fillStyle = localOptions.color;
+ for (const f of result) {
+ drawFaceBoxes(f, ctx);
+ drawLabels(f, ctx);
+ if (f.mesh && f.mesh.length > 0) {
+ drawFacePoints(f, ctx);
+ drawFacePolygons(f, ctx);
+ drawGazeSpheres(f, ctx);
+ drawGazeArrows(f, ctx);
+ }
+ }
+}
+
+// src/draw/body.ts
+function body(inCanvas2, result, drawOptions) {
+ var _a, _b;
+ const localOptions2 = mergeDeep(options2, drawOptions);
+ if (!result || !inCanvas2)
+ return;
+ const ctx = getCanvasContext(inCanvas2);
+ if (!ctx)
+ return;
+ ctx.lineJoin = "round";
+ for (let i = 0; i < result.length; i++) {
+ ctx.strokeStyle = localOptions2.color;
+ ctx.fillStyle = localOptions2.color;
+ ctx.lineWidth = localOptions2.lineWidth;
+ ctx.font = localOptions2.font;
+ if (localOptions2.drawBoxes && result[i].box && result[i].box.length === 4) {
+ rect(ctx, result[i].box[0], result[i].box[1], result[i].box[2], result[i].box[3], localOptions2);
+ if (localOptions2.drawLabels && ((_a = localOptions2.bodyLabels) == null ? void 0 : _a.length) > 0) {
+ let l = localOptions2.bodyLabels.slice();
+ l = replace(l, "[score]", 100 * result[i].score);
+ labels(ctx, l, result[i].box[0], result[i].box[1], localOptions2);
+ }
+ }
+ if (localOptions2.drawPoints && result[i].keypoints) {
+ for (let pt = 0; pt < result[i].keypoints.length; pt++) {
+ if (!result[i].keypoints[pt].score || result[i].keypoints[pt].score === 0)
+ continue;
+ ctx.fillStyle = colorDepth(result[i].keypoints[pt].position[2], localOptions2);
+ point(ctx, result[i].keypoints[pt].position[0], result[i].keypoints[pt].position[1], 0, localOptions2);
+ }
+ }
+ if (localOptions2.drawLabels && ((_b = localOptions2.bodyPartLabels) == null ? void 0 : _b.length) > 0 && result[i].keypoints) {
+ ctx.font = localOptions2.font;
+ for (const pt of result[i].keypoints) {
+ if (!pt.score || pt.score === 0)
+ continue;
+ let l = localOptions2.bodyPartLabels.slice();
+ l = replace(l, "[label]", pt.part);
+ l = replace(l, "[score]", 100 * pt.score);
+ labels(ctx, l, pt.position[0], pt.position[1], localOptions2);
+ }
+ }
+ if (localOptions2.drawPolygons && result[i].keypoints && result[i].annotations) {
+ for (const part of Object.values(result[i].annotations)) {
+ for (const connected4 of part)
+ curves(ctx, connected4, localOptions2);
+ }
+ }
+ }
+}
+
+// src/draw/hand.ts
+function hand(inCanvas2, result, drawOptions) {
+ var _a, _b;
+ const localOptions2 = mergeDeep(options2, drawOptions);
+ if (!result || !inCanvas2)
+ return;
+ const ctx = getCanvasContext(inCanvas2);
+ if (!ctx)
+ return;
+ ctx.lineJoin = "round";
+ ctx.font = localOptions2.font;
+ for (const h of result) {
+ if (localOptions2.drawBoxes) {
+ ctx.strokeStyle = localOptions2.color;
+ ctx.fillStyle = localOptions2.color;
+ rect(ctx, h.box[0], h.box[1], h.box[2], h.box[3], localOptions2);
+ if (localOptions2.drawLabels && ((_a = localOptions2.handLabels) == null ? void 0 : _a.length) > 0) {
+ let l = localOptions2.handLabels.slice();
+ l = replace(l, "[label]", h.label);
+ l = replace(l, "[score]", 100 * h.score);
+ labels(ctx, l, h.box[0], h.box[1], localOptions2);
+ }
+ ctx.stroke();
+ }
+ if (localOptions2.drawPoints) {
+ if (h.keypoints && h.keypoints.length > 0) {
+ for (const pt of h.keypoints) {
+ ctx.fillStyle = colorDepth(pt[2], localOptions2);
+ point(ctx, pt[0], pt[1], 0, localOptions2);
+ }
+ }
+ }
+ if (localOptions2.drawLabels && h.annotations && ((_b = localOptions2.fingerLabels) == null ? void 0 : _b.length) > 0) {
+ for (const [part, pt] of Object.entries(h.annotations)) {
+ let l = localOptions2.fingerLabels.slice();
+ l = replace(l, "[label]", part);
+ labels(ctx, l, pt[pt.length - 1][0], pt[pt.length - 1][1], localOptions2);
+ }
+ }
+ if (localOptions2.drawPolygons && h.annotations) {
+ const addHandLine = (part) => {
+ if (!part || part.length === 0 || !part[0])
+ return;
+ for (let i = 0; i < part.length; i++) {
+ ctx.beginPath();
+ const z = part[i][2] || 0;
+ ctx.strokeStyle = colorDepth(i * z, localOptions2);
+ ctx.moveTo(part[i > 0 ? i - 1 : 0][0], part[i > 0 ? i - 1 : 0][1]);
+ ctx.lineTo(part[i][0], part[i][1]);
+ ctx.stroke();
+ }
+ };
+ ctx.lineWidth = localOptions2.lineWidth;
+ addHandLine(h.annotations.index);
+ addHandLine(h.annotations.middle);
+ addHandLine(h.annotations.ring);
+ addHandLine(h.annotations.pinky);
+ addHandLine(h.annotations.thumb);
+ }
+ }
+}
+
+// src/draw/object.ts
+function object(inCanvas2, result, drawOptions) {
+ var _a;
+ const localOptions2 = mergeDeep(options2, drawOptions);
+ if (!result || !inCanvas2)
+ return;
+ const ctx = getCanvasContext(inCanvas2);
+ if (!ctx)
+ return;
+ ctx.lineJoin = "round";
+ ctx.font = localOptions2.font;
+ for (const h of result) {
+ if (localOptions2.drawBoxes) {
+ ctx.strokeStyle = localOptions2.color;
+ ctx.fillStyle = localOptions2.color;
+ rect(ctx, h.box[0], h.box[1], h.box[2], h.box[3], localOptions2);
+ if (localOptions2.drawLabels && ((_a = localOptions2.objectLabels) == null ? void 0 : _a.length) > 0) {
+ let l = localOptions2.objectLabels.slice();
+ l = replace(l, "[label]", h.label);
+ l = replace(l, "[score]", 100 * h.score);
+ labels(ctx, l, h.box[0], h.box[1], localOptions2);
+ }
+ ctx.stroke();
+ }
+ }
+}
+
+// src/draw/gesture.ts
+function gesture(inCanvas2, result, drawOptions) {
+ var _a;
+ const localOptions2 = mergeDeep(options2, drawOptions);
+ if (!result || !inCanvas2)
+ return;
+ if (localOptions2.drawGestures && ((_a = localOptions2.gestureLabels) == null ? void 0 : _a.length) > 0) {
+ const ctx = getCanvasContext(inCanvas2);
+ if (!ctx)
+ return;
+ ctx.font = localOptions2.font;
+ ctx.fillStyle = localOptions2.color;
+ let i = 1;
+ for (let j = 0; j < result.length; j++) {
+ const [where, what] = Object.entries(result[j]);
+ if (what.length > 1 && what[1].length > 0) {
+ const who = where[1] > 0 ? `#${where[1]}` : "";
+ let l = localOptions2.gestureLabels.slice();
+ l = replace(l, "[where]", where[0]);
+ l = replace(l, "[who]", who);
+ l = replace(l, "[what]", what[1]);
+ labels(ctx, l, 8, 2 + i * localOptions2.lineHeight, localOptions2);
+ i += 1;
+ }
+ }
+ }
+}
+
+// src/draw/labels.ts
+var defaultLabels = {
+ face: `face
confidence: [score]%
[gender] [genderScore]%
age: [age] years
@@ -118,7 +6393,7471 @@ var nt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Gn=Objec
live: [live]%
[emotions]
roll: [roll]\xB0 yaw:[yaw]\xB0 pitch:[pitch]\xB0
- gaze: [gaze]\xB0`,body:"body [score]%",bodyPart:"[label] [score]%",object:"[label] [score]%",hand:"[label] [score]%",finger:"[label]",gesture:"[where] [who]: [what]"};var ft=0;function Hr(e,t,n){let o=J($,n);if(!t||!e)return;let s=z0(e);if(!!s){s.lineJoin="round",s.font=o.font;for(let A=0;Aht,kpt:()=>ut});var ut=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],ht={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var S0,Re=224,o1,Zr=5,T2=[8,16,32,32,32];function Xr(){let e=[],t=0;for(;tn.x)),y:r.tensor1d(e.map(n=>n.y))}}async function r1(e){if(M.initial&&(S0=null),!S0&&e.body.detector&&e.body.detector.modelPath){S0=await L(e.body.detector.modelPath);let t=S0!=null&&S0.executor?Object.values(S0.modelSignature.inputs):void 0;Re=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0}else e.debug&&S0&&h("cached model:",S0.modelUrl);return Xr(),S0}var n1=[5,5];function qr(e,t){return r.tidy(()=>{let n=r.split(e,12,1),o=r.squeeze(n[0]),s=r.squeeze(n[1]),A=r.squeeze(n[2]),a=r.squeeze(n[3]);o=r.add(r.div(o,Re),t.x),s=r.add(r.div(s,Re),t.y),A=r.mul(r.div(A,Re),n1[0]),a=r.mul(r.div(a,Re),n1[1]);let i=r.sub(o,r.div(A,2)),c=r.sub(s,r.div(a,2)),x=r.add(i,A),y=r.add(c,a);return r.stack([i,c,x,y],1)})}async function Ur(e,t,n,o){var x,y;let s=[],A={};A.boxes=qr(e,o1),A.scores=r.sigmoid(t),A.nms=await r.image.nonMaxSuppressionAsync(A.boxes,A.scores,1,((x=n.body.detector)==null?void 0:x.minConfidence)||.1,((y=n.body.detector)==null?void 0:y.iouThreshold)||.1);let a=await A.nms.data(),i=await A.scores.data(),c=await A.boxes.array();for(let l of Array.from(a)){let f=i[l],d=c[l],u=[Math.round(d[0]*o[0]),Math.round(d[1]*o[1]),Math.round(d[2]*o[0]),Math.round(d[3]*o[1])],m={score:f,boxRaw:d,box:u};s.push(m)}return Object.keys(A).forEach(l=>r.dispose(A[l])),s}async function s1(e,t,n){let o={};o.res=S0==null?void 0:S0.execute(e,["Identity"]),o.logitsRaw=r.slice(o.res,[0,0,0],[1,-1,1]),o.boxesRaw=r.slice(o.res,[0,0,1],[1,-1,-1]),o.logits=r.squeeze(o.logitsRaw),o.boxes=r.squeeze(o.boxesRaw);let s=await Ur(o.boxes,o.logits,t,n);return Object.keys(o).forEach(A=>r.dispose(o[A])),s}function Y0(e,t=[1,1]){let n=[e.map(i=>i[0]),e.map(i=>i[1])],o=[Math.min(...n[0]),Math.min(...n[1])],s=[Math.max(...n[0]),Math.max(...n[1])],A=[o[0],o[1],s[0]-o[0],s[1]-o[1]],a=[A[0]/t[0],A[1]/t[1],A[2]/t[0],A[3]/t[1]];return{box:A,boxRaw:a}}function A1(e,t=[1,1]){let n=[e.map(x=>x[0]),e.map(x=>x[1])],o=[Math.min(...n[0]),Math.min(...n[1])],s=[Math.max(...n[0]),Math.max(...n[1])],A=[(o[0]+s[0])/2,(o[1]+s[1])/2],a=Math.max(A[0]-o[0],A[1]-o[1],-A[0]+s[0],-A[1]+s[1]),i=[Math.trunc(A[0]-a),Math.trunc(A[1]-a),Math.trunc(2*a),Math.trunc(2*a)],c=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:c}}function v2(e,t){let n=[e[2]*t,e[3]*t];return[e[0]-(n[0]-e[2])/2,e[1]-(n[1]-e[3])/2,n[0],n[1]]}var g0,gt=256,bt=Number.MAX_SAFE_INTEGER,Yr={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},M2=[],se=[[0,0],[0,0],[0,0],[0,0]],a1=0,i1=e=>1-1/(1+Math.exp(e)),c1=e=>r1(e);async function x1(e){if(M.initial&&(g0=null),g0)e.debug&&h("cached model:",g0.modelUrl);else{g0=await L(e.body.modelPath);let t=g0!=null&&g0.executor?Object.values(g0.modelSignature.inputs):void 0;gt=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0}return g0}function l1(e,t,n){var A,a;let o={};if(!((A=e==null?void 0:e.shape)!=null&&A[1])||!((a=e==null?void 0:e.shape)!=null&&a[2]))return e;let s;if(n&&(o.cropped=r.image.cropAndResize(e,[n],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let i=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],c=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];se=[[0,0],i,c,[0,0]],o.pad=r.pad(o.cropped||e,se),o.resize=r.image.resizeBilinear(o.pad,[t,t]),s=r.div(o.resize,O.tf255)}else e.shape[1]!==t?(o.resize=r.image.resizeBilinear(o.cropped||e,[t,t]),s=r.div(o.resize,O.tf255)):s=r.div(o.cropped||e,O.tf255);return Object.keys(o).forEach(i=>r.dispose(o[i])),s}function Kr(e,t,n){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+se[2][0]+se[2][1])/t[0]-se[2][0]),Math.trunc(o.position[1]*(t[1]+se[1][0]+se[1][1])/t[1]-se[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(n){let o=n[2]-n[0],s=n[3]-n[1];for(let A of e)A.positionRaw=[A.positionRaw[0]/s+n[1],A.positionRaw[1]/o+n[0],A.positionRaw[2]],A.position=[Math.trunc(A.positionRaw[0]*t[0]),Math.trunc(A.positionRaw[1]*t[1]),A.positionRaw[2]]}return e}function Jr(e){let t=e.find(i=>i.part==="leftPalm"),n=e.find(i=>i.part==="leftWrist"),o=e.find(i=>i.part==="leftIndex");t.position[2]=((n.position[2]||0)+(o.position[2]||0))/2;let s=e.find(i=>i.part==="rightPalm"),A=e.find(i=>i.part==="rightWrist"),a=e.find(i=>i.part==="rightIndex");s.position[2]=((A.position[2]||0)+(a.position[2]||0))/2}async function Qr(e,t,n){if(!(g0!=null&&g0.executor))return null;let o={};[o.ld,o.segmentation,o.heatmap,o.world,o.poseflag]=g0==null?void 0:g0.execute(e,Yr.landmarks);let s=(await o.poseflag.data())[0],A=await o.ld.data(),a=await o.world.data();Object.keys(o).forEach(u=>r.dispose(o[u]));let i=[],c=5;for(let u=0;uu.position),l=Y0(y,[n[0],n[1]]),f={};for(let[u,m]of Object.entries(ht)){let g=[];for(let P=0;Pb.part===m[P]),p=x.find(b=>b.part===m[P+1]);v&&p&&g.push([v.position,p.position])}f[u]=g}return{id:0,score:Math.trunc(100*s)/100,box:l.box,boxRaw:l.boxRaw,keypoints:x,annotations:f}}async function Tt(e,t){var A,a,i;let n=[e.shape[2]||0,e.shape[1]||0],o=(t.body.skipTime||0)>T()-a1,s=bt<(t.body.skipFrames||0);if(t.skipAllowed&&o&&s&&M2!==null)bt++;else{let c=[];if((a=(A=t.body)==null?void 0:A.detector)!=null&&a.enabled){let x=l1(e,224);c=await s1(x,t,n),r.dispose(x)}else c=[{box:[0,0,0,0],boxRaw:[0,0,1,1],score:0}];for(let x=0;xr.dispose(o[x])),s}async function Mt(e,t){if(!(T0!=null&&T0.executor))return[];let n=(t.object.skipTime||0)>T()-y1,o=Rt<(t.object.skipFrames||0);return t.skipAllowed&&n&&o&&vt.length>0?(Rt++,vt):(Rt=0,new Promise(async s=>{let A=[e.shape[2]||0,e.shape[1]||0],a=r.image.resizeBilinear(e,[Me,Me]),i=t.object.enabled?T0==null?void 0:T0.execute(a,["tower_0/detections"]):null;y1=T(),r.dispose(a);let c=await _r(i,A,t);vt=c,s(c)}))}var P2={};te(P2,{connected:()=>kt,kpt:()=>Pt});var Pt=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],kt={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Q,p1=0,h0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},wt=Number.MAX_SAFE_INTEGER;async function u1(e){return M.initial&&(Q=null),Q?e.debug&&h("cached model:",Q.modelUrl):Q=await L(e.body.modelPath),Q}async function $r(e,t){let[n,o]=e.shape,s=r.reshape(e,[o*n]),A=r.max(s,0),a=(await A.data())[0];if(a>t){let i=r.argMax(s,0),c=r.mod(i,n),x=(await c.data())[0],y=r.div(i,n),l=(await y.data())[0];return r.dispose([s,A,i,c,y]),[x,l,a]}return r.dispose([s,A]),[0,0,a]}async function Et(e,t){if(!(Q!=null&&Q.executor)||!(Q!=null&&Q.inputs[0].shape))return[];let n=(t.body.skipTime||0)>T()-p1,o=wt<(t.body.skipFrames||0);return t.skipAllowed&&n&&o&&Object.keys(h0.keypoints).length>0?(wt++,[h0]):(wt=0,new Promise(async s=>{let A=r.tidy(()=>{var u,m;let l=r.image.resizeBilinear(e,[((u=Q==null?void 0:Q.inputs[0].shape)==null?void 0:u[2])||0,((m=Q==null?void 0:Q.inputs[0].shape)==null?void 0:m[1])||0],!1),f=r.mul(l,O.tf2);return r.sub(f,O.tf1)}),a;if(t.body.enabled&&(a=Q==null?void 0:Q.execute(A)),p1=T(),r.dispose(A),a){h0.keypoints.length=0;let l=r.squeeze(a);r.dispose(a);let f=r.unstack(l,2);r.dispose(l);for(let d=0;d(t.body.minConfidence||0)&&h0.keypoints.push({score:Math.round(100*g)/100,part:Pt[d],positionRaw:[u/Q.inputs[0].shape[2],m/Q.inputs[0].shape[1]],position:[Math.round(e.shape[2]*u/Q.inputs[0].shape[2]),Math.round(e.shape[1]*m/Q.inputs[0].shape[1])]})}f.forEach(d=>r.dispose(d))}h0.score=h0.keypoints.reduce((l,f)=>f.score>l?f.score:l,0);let i=h0.keypoints.map(l=>l.position[0]),c=h0.keypoints.map(l=>l.position[1]);h0.box=[Math.min(...i),Math.min(...c),Math.max(...i)-Math.min(...i),Math.max(...c)-Math.min(...c)];let x=h0.keypoints.map(l=>l.positionRaw[0]),y=h0.keypoints.map(l=>l.positionRaw[1]);h0.boxRaw=[Math.min(...x),Math.min(...y),Math.max(...x)-Math.min(...x),Math.max(...y)-Math.min(...y)];for(let[l,f]of Object.entries(kt)){let d=[];for(let u=0;uP.part===f[u]),g=h0.keypoints.find(P=>P.part===f[u+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&d.push([m.position,g.position])}h0.annotations[l]=d}s([h0])}))}var Ce=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],k2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],w2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],E2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],T1=(e,t)=>{let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],o=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:n,endPoint:o,landmarks:e.landmarks,confidence:e.confidence}},zt=(e,t,n)=>{let o=t.shape[1],s=t.shape[2],A=[e.startPoint[1]/o,e.startPoint[0]/s,e.endPoint[1]/o,e.endPoint[0]/s],a=r.image.cropAndResize(t,[A],[0],n),i=r.div(a,O.tf255);return r.dispose(a),i},z2=(e,t)=>{let n=k2(e),o=Ce(e),s=[t*o[0]/2,t*o[1]/2];return{startPoint:[n[0]-s[0],n[1]-s[1]],endPoint:[n[0]+s[0],n[1]+s[1]],landmarks:e.landmarks,confidence:e.confidence}},S2=e=>{let t=k2(e),n=Ce(e),o=Math.max(...n)/2;return{startPoint:[Math.round(t[0]-o),Math.round(t[1]-o)],endPoint:[Math.round(t[0]+o),Math.round(t[1]+o)],landmarks:e.landmarks,confidence:e.confidence}},v1=e=>{let t=e.map(o=>o[0]),n=e.map(o=>o[1]);return{startPoint:[Math.min(...t),Math.min(...n)],endPoint:[Math.max(...t),Math.max(...n)],landmarks:e}},St=[[1,0,0],[0,1,0],[0,0,1]],es=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),ts=(e,t)=>es(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var b1=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Pe=(e,t)=>{let n=0;for(let o=0;o{let n=[];for(let o=0;o{let n=[],o=e.length;for(let s=0;s{let n=Math.cos(e),o=Math.sin(e),s=[[n,-o,0],[o,n,0],[0,0,1]],A=b1(t[0],t[1]),a=g1(A,s),i=b1(-t[0],-t[1]);return g1(a,i)},os=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],o=[-Pe(t[0],n),-Pe(t[1],n)];return[t[0].concat(o[0]),t[1].concat(o[1]),[0,0,1]]},rs=(e,t)=>[Pe(e,t[0]),Pe(e,t[1])];function M1(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},n=[];for(let o=0;o[A[0]/s*(d[0]-s/2),A[1]/s*(d[1]-s/2),d[2]||0]),i=n&&n!==0&&Math.abs(n)>.2,c=i?R1(n,[0,0]):St,x=i?a.map(d=>[...rs(d,c),d[2]]):a,y=i?os(o):St,l=k2(t),f=[Pe(l,y[0]),Pe(l,y[1])];return x.map(d=>[Math.trunc(d[0]+f[0]),Math.trunc(d[1]+f[1]),Math.trunc(d[2]||0)])}function k1(e,t,n,o){let s=t.landmarks.length>=xt.count?xt.symmetryLine:be.symmetryLine,A=0,a=St,i;if(e&&M.kernels.includes("rotatewithoffset"))if(A=ts(t.landmarks[s[0]],t.landmarks[s[1]]),A&&A!==0&&Math.abs(A)>.2){let x=k2(t),y=[x[0]/n.shape[2],x[1]/n.shape[1]],l=r.image.rotateWithOffset(n,A,0,[y[0],y[1]]);a=R1(-A,x),i=zt(t,l,[o,o]),r.dispose(l)}else i=zt(t,n,[o,o]);else i=zt(t,n,[o,o]);return[A,a,i]}var ss=e=>{let t=e.map(o=>o[0]),n=e.map(o=>o[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...n)+(Math.max(...n)-Math.min(...n))/2]},w1=(e,t)=>{let n=ss(e),o=Ce(t);return{startPoint:[n[0]-o[0]/2,n[1]-o[1]/2],endPoint:[n[0]+o[0]/2,n[1]+o[1]/2]}};var E1=6,As=1.4,F0,Nt=null,Ae=0,We=null,De=()=>Ae;async function z1(e){var t;return M.initial&&(F0=null),F0?e.debug&&h("cached model:",F0.modelUrl):F0=await L((t=e.face.detector)==null?void 0:t.modelPath),Ae=F0.executor&&F0.inputs[0].shape?F0.inputs[0].shape[2]:256,We=r.scalar(Ae,"int32"),Nt=r.tensor2d(M1(Ae)),F0}function as(e){if(!Nt||!We)return r.zeros([0,0]);let t={};t.boxStarts=r.slice(e,[0,1],[-1,2]),t.centers=r.add(t.boxStarts,Nt),t.boxSizes=r.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=r.div(t.boxSizes,We),t.centersNormalized=r.div(t.centers,We),t.halfBoxSize=r.div(t.boxSizesNormalized,O.tf2),t.starts=r.sub(t.centersNormalized,t.halfBoxSize),t.ends=r.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=r.mul(t.starts,We),t.endNormalized=r.mul(t.ends,We);let n=r.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(o=>r.dispose(t[o])),n}async function S1(e,t){var i,c,x,y;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let n={};n.resized=r.image.resizeBilinear(e,[Ae,Ae]),n.div=r.div(n.resized,O.tf127),n.normalized=r.sub(n.div,O.tf05);let o=F0==null?void 0:F0.execute(n.normalized);if(Array.isArray(o)&&o.length>2){let l=o.sort((f,d)=>f.size-d.size);n.concat384=r.concat([l[0],l[2]],2),n.concat512=r.concat([l[1],l[3]],2),n.concat=r.concat([n.concat512,n.concat384],1),n.batch=r.squeeze(n.concat,[0])}else Array.isArray(o)?n.batch=r.squeeze(o[0]):n.batch=r.squeeze(o);r.dispose(o),n.boxes=as(n.batch),n.logits=r.slice(n.batch,[0,0],[-1,1]),n.sigmoid=r.sigmoid(n.logits),n.scores=r.squeeze(n.sigmoid),n.nms=await r.image.nonMaxSuppressionAsync(n.boxes,n.scores,((i=t.face.detector)==null?void 0:i.maxDetected)||0,((c=t.face.detector)==null?void 0:c.iouThreshold)||0,((x=t.face.detector)==null?void 0:x.minConfidence)||0);let s=await n.nms.array(),A=[],a=await n.scores.data();for(let l=0;l(((y=t.face.detector)==null?void 0:y.minConfidence)||0)){let d={};d.bbox=r.slice(n.boxes,[s[l],0],[1,-1]),d.slice=r.slice(n.batch,[s[l],E1-1],[1,-1]),d.squeeze=r.squeeze(d.slice),d.landmarks=r.reshape(d.squeeze,[E1,-1]);let u=await d.bbox.data(),m={startPoint:[u[0],u[1]],endPoint:[u[2],u[3]],landmarks:await d.landmarks.array(),confidence:f},g=T1(m,[(e.shape[2]||0)/Ae,(e.shape[1]||0)/Ae]),P=z2(g,t.face.scale||As),v=S2(P);A.push(v),Object.keys(d).forEach(p=>r.dispose(d[p]))}}return Object.keys(n).forEach(l=>r.dispose(n[l])),A}var v0,ae=0,is=2.3,It=O0.leftEyeLower0,Lt=O0.rightEyeLower0,Fe={leftBounds:[It[0],It[It.length-1]],rightBounds:[Lt[0],Lt[Lt.length-1]]},Be={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function O1(e){var t,n;return M.initial&&(v0=null),v0?e.debug&&h("cached model:",v0.modelUrl):v0=await L((t=e.face.iris)==null?void 0:t.modelPath),ae=(v0==null?void 0:v0.executor)&&((n=v0.inputs)==null?void 0:n[0].shape)?v0.inputs[0].shape[2]:0,ae===-1&&(ae=64),v0}function j2(e,t,n,o){for(let s=0;s{let t=e[Fe.leftBounds[0]][2],n=e[Fe.rightBounds[0]][2];return t-n},N1=(e,t,n,o,s,A=!1)=>{let a=S2(z2(v1([e[n],e[o]]),is)),i=Ce(a),c=r.image.cropAndResize(t,[[a.startPoint[1]/s,a.startPoint[0]/s,a.endPoint[1]/s,a.endPoint[0]/s]],[0],[ae,ae]);if(A&&M.kernels.includes("flipleftright")){let x=r.image.flipLeftRight(c);r.dispose(c),c=x}return{box:a,boxSize:i,crop:c}},I1=(e,t,n,o=!1)=>{let s=[];for(let A=0;A{let o=e[O0[`${n}EyeUpper0`][Be.upperCenter]][2],s=e[O0[`${n}EyeLower0`][Be.lowerCenter]][2],A=(o+s)/2;return t.map((a,i)=>{let c=A;return i===2?c=o:i===4&&(c=s),[a[0],a[1],c]})};async function C1(e,t,n){if(!(v0!=null&&v0.executor))return e;let{box:o,boxSize:s,crop:A}=N1(e,t,Fe.leftBounds[0],Fe.leftBounds[1],n,!0),{box:a,boxSize:i,crop:c}=N1(e,t,Fe.rightBounds[0],Fe.rightBounds[1],n,!0),x=r.concat([A,c]);r.dispose(A),r.dispose(c);let y=v0.execute(x);r.dispose(x);let l=await y.data();r.dispose(y);let f=l.slice(0,Be.numCoordinates*3),{rawCoords:d,iris:u}=I1(f,o,s,!0),m=l.slice(Be.numCoordinates*3),{rawCoords:g,iris:P}=I1(m,a,i,!1),v=ls(e);Math.abs(v)<30?(j2(e,d,"left",null),j2(e,g,"right",null)):v<1?j2(e,d,"left",["EyeUpper0","EyeLower0"]):j2(e,g,"right",["EyeUpper0","EyeLower0"]);let p=L1(e,u,"left"),b=L1(e,P,"right");return e.concat(p).concat(b)}async function D1(e,t){var A,a,i,c,x,y,l,f,d,u;let n={lips:await((a=(A=t.filter(m=>m.size===160))==null?void 0:A[0])==null?void 0:a.data()),irisL:await((c=(i=t.filter(m=>m.size===10))==null?void 0:i[0])==null?void 0:c.data()),eyeL:await((y=(x=t.filter(m=>m.size===142))==null?void 0:x[0])==null?void 0:y.data()),irisR:await((f=(l=t.filter(m=>m.size===10))==null?void 0:l[1])==null?void 0:f.data()),eyeR:await((u=(d=t.filter(m=>m.size===142))==null?void 0:d[1])==null?void 0:u.data())};for(let m of Object.values(n))if(!m)return e;let o=Te.reduce((m,g)=>m+=e[g][2],0)/Te.length;for(let m=0;mm+=e[g][2],0)/ve.length;for(let m=0;mT()-X0.timestamp,o=X0.skipped<(((x=t.face.detector)==null?void 0:x.skipFrames)||0);!t.skipAllowed||!n||!o||X0.boxes.length===0?(X0.boxes=await S1(e,t),X0.timestamp=T(),X0.skipped=0):X0.skipped++;let s=[],A=[],a=0,i=$e;for(let v=0;vW.shape[W.shape.length-1]===1).data();if(k.faceScore=Math.round(100*q[0])/100,k.faceScore<(((u=t.face.detector)==null?void 0:u.minConfidence)||1)){if(p.confidence=k.faceScore,t.face.mesh.keepInvalid){k.box=w2(p,e),k.boxRaw=E2(p,e),k.score=k.boxScore,k.mesh=p.landmarks.map(W=>[(p.startPoint[0]+p.endPoint[0])/2+(p.endPoint[0]+p.startPoint[0])*W[0]/De(),(p.startPoint[1]+p.endPoint[1])/2+(p.endPoint[1]+p.startPoint[1])*W[1]/De()]),k.meshRaw=k.mesh.map(W=>[W[0]/(e.shape[2]||1),W[1]/(e.shape[1]||1),(W[2]||0)/i]);for(let W of Object.keys(be))k.annotations[W]=[k.mesh[be[W]]]}}else{let W=I.find(D=>D.shape[D.shape.length-1]===1404),Z=r.reshape(W,[-1,3]),K=await Z.array();r.dispose(Z),(m=t.face.attention)!=null&&m.enabled?K=await D1(K,I):(g=t.face.iris)!=null&&g.enabled&&(K=await C1(K,k.tensor,$e)),k.mesh=P1(K,p,b,j,$e),k.meshRaw=k.mesh.map(D=>[D[0]/(e.shape[2]||0),D[1]/(e.shape[1]||0),(D[2]||0)/i]);for(let D of Object.keys(O0))k.annotations[D]=O0[D].map(A0=>k.mesh[A0]);k.score=k.faceScore;let R={...w1(k.mesh,p),confidence:p.confidence,landmarks:p.landmarks};k.box=w2(R,e),k.boxRaw=E2(R,e),A.push(R)}r.dispose(I)}else{k.box=w2(p,e),k.boxRaw=E2(p,e),k.score=k.boxScore,k.mesh=p.landmarks.map(I=>[(p.startPoint[0]+p.endPoint[0])/2+(p.endPoint[0]+p.startPoint[0])*I[0]/De(),(p.startPoint[1]+p.endPoint[1])/2+(p.endPoint[1]+p.startPoint[1])*I[1]/De()]),k.meshRaw=k.mesh.map(I=>[I[0]/(e.shape[2]||0),I[1]/(e.shape[1]||0),(I[2]||0)/i]);for(let I of Object.keys(be))k.annotations[I]=[k.mesh[be[I]]]}k.score>(((P=t.face.detector)==null?void 0:P.minConfidence)||1)?s.push(k):r.dispose(k.tensor)}return X0.boxes=A,s}async function B1(e){var t,n,o,s,A,a;return M.initial&&(Y=null),((t=e.face.attention)==null?void 0:t.enabled)&&(Y==null?void 0:Y.signature)&&Object.keys(((n=Y==null?void 0:Y.signature)==null?void 0:n.outputs)||{}).length<6&&(Y=null),Y?e.debug&&h("cached model:",Y.modelUrl):(o=e.face.attention)!=null&&o.enabled?Y=await L(e.face.attention.modelPath):Y=await L((s=e.face.mesh)==null?void 0:s.modelPath),$e=Y.executor&&((A=Y==null?void 0:Y.inputs)==null?void 0:A[0].shape)?(a=Y==null?void 0:Y.inputs)==null?void 0:a[0].shape[2]:256,Y}var H1=ge,G1=Qe;var xs=["angry","disgust","fear","happy","sad","surprise","neutral"],j0,N2=[],V1=0,Z1=0,Ct=Number.MAX_SAFE_INTEGER;async function X1(e){var t;return M.initial&&(j0=null),j0?e.debug&&h("cached model:",j0.modelUrl):j0=await L((t=e.face.emotion)==null?void 0:t.modelPath),j0}async function Wt(e,t,n,o){var a,i;if(!j0)return[];let s=Ct<(((a=t.face.emotion)==null?void 0:a.skipFrames)||0),A=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>T()-Z1;return t.skipAllowed&&A&&s&&V1===o&&N2[n]&&N2[n].length>0?(Ct++,N2[n]):(Ct=0,new Promise(async c=>{var y;let x=[];if((y=t.face.emotion)!=null&&y.enabled){let l={},f=j0!=null&&j0.inputs[0].shape?j0.inputs[0].shape[2]:0;l.resize=r.image.resizeBilinear(e,[f,f],!1),l.channels=r.mul(l.resize,O.rgb),l.grayscale=r.sum(l.channels,3,!0),l.grayscaleSub=r.sub(l.grayscale,O.tf05),l.grayscaleMul=r.mul(l.grayscaleSub,O.tf2),l.emotion=j0==null?void 0:j0.execute(l.grayscaleMul),Z1=T();let d=await l.emotion.data();for(let u=0;u(t.face.emotion.minConfidence||0)&&x.push({score:Math.min(.99,Math.trunc(100*d[u])/100),emotion:xs[u]});x.sort((u,m)=>m.score-u.score),Object.keys(l).forEach(u=>r.dispose(l[u]))}N2[n]=x,V1=o,c(x)}))}var f0,ie=[],U1=0,Y1=0,Dt=Number.MAX_SAFE_INTEGER;async function K1(e){var t;return M.initial&&(f0=null),f0?e.debug&&h("cached model:",f0.modelUrl):f0=await L((t=e.face.description)==null?void 0:t.modelPath),f0}function ds(e){let t=e.image||e.tensor||e;if(!(f0!=null&&f0.inputs[0].shape))return t;let n=r.image.resizeBilinear(t,[f0.inputs[0].shape[2],f0.inputs[0].shape[1]],!1),o=r.mul(n,O.tf255);return r.dispose(n),o}async function Ft(e,t,n,o){var i,c,x,y;let s={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(f0!=null&&f0.executor))return s;let A=Dt<(((i=t.face.description)==null?void 0:i.skipFrames)||0),a=(((c=t.face.description)==null?void 0:c.skipTime)||0)>T()-U1;return t.skipAllowed&&A&&a&&Y1===o&&((x=ie==null?void 0:ie[n])==null?void 0:x.age)>0&&((y=ie==null?void 0:ie[n])==null?void 0:y.genderScore)>0?(Dt++,ie[n]):(Dt=0,new Promise(async l=>{var f;if((f=t.face.description)!=null&&f.enabled){let d=ds(e),u=f0==null?void 0:f0.execute(d);U1=T(),r.dispose(d);let g=await u.find(B=>B.shape[1]===1).data(),P=Math.trunc(200*Math.abs(g[0]-.5))/100;P>(t.face.description.minConfidence||0)&&(s.gender=g[0]<=.5?"female":"male",s.genderScore=Math.min(.99,P));let v=r.argMax(u.find(B=>B.shape[1]===100),1),p=(await v.data())[0];r.dispose(v);let j=await u.find(B=>B.shape[1]===100).data();s.age=Math.round(j[p-1]>j[p+1]?10*p-100*j[p-1]:10*p+100*j[p+1])/10,(Number.isNaN(g[0])||Number.isNaN(j[0]))&&h("faceres error:",{model:f0,result:u});let k=u.find(B=>B.shape[1]===1024),I=k?await k.data():[];s.descriptor=Array.from(I),u.forEach(B=>r.dispose(B))}ie[n]=s,Y1=o,l(s)}))}var He=.1,Bt=.5;function ys(e,t,n){let o=!1,s=n.length-1;for(let A=0;At!=n[s].y>t&&e<(n[s].x-n[A].x)*(t-n[A].y)/(n[s].y-n[A].y)+n[A].x&&(o=!o);return o}async function Q1(e){if(!e.tensor||!e.mesh||e.mesh.length<100)return e.tensor;let t=e.tensor.shape[2]||0,n=e.tensor.shape[1]||0,o=await e.tensor.buffer(),s=[];for(let a of O0.silhouette)s.push({x:(e.mesh[a][0]-e.box[0])/e.box[2],y:(e.mesh[a][1]-e.box[1])/e.box[3]});He&&He>0&&(s=s.map(a=>({x:a.x>.5?a.x+He:a.x-He,y:a.y>.5?a.y+He:a.y-He})));for(let a=0;aT()-$1,A=Ht<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&s&&A&&_1===o&&I2[n]?(Ht++,I2[n]):(Ht=0,new Promise(async c=>{let x=r.image.resizeBilinear(e,[x0!=null&&x0.inputs[0].shape?x0.inputs[0].shape[2]:0,x0!=null&&x0.inputs[0].shape?x0.inputs[0].shape[1]:0],!1),y=x0==null?void 0:x0.execute(x),l=(await y.data())[0];I2[n]=Math.round(100*l)/100,_1=o,$1=T(),r.dispose([x,y]),c(I2[n])}))}var d0,L2=[],Vt=Number.MAX_SAFE_INTEGER,n3=0,o3=0;async function r3(e){var t;return M.initial&&(d0=null),d0?e.debug&&h("cached model:",d0.modelUrl):d0=await L((t=e.face.liveness)==null?void 0:t.modelPath),d0}async function Zt(e,t,n,o){var a,i;if(!(d0!=null&&d0.executor))return 0;let s=(((a=t.face.liveness)==null?void 0:a.skipTime)||0)>T()-o3,A=Vt<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&s&&A&&n3===o&&L2[n]?(Vt++,L2[n]):(Vt=0,new Promise(async c=>{let x=r.image.resizeBilinear(e,[d0!=null&&d0.inputs[0].shape?d0.inputs[0].shape[2]:0,d0!=null&&d0.inputs[0].shape?d0.inputs[0].shape[1]:0],!1),y=d0==null?void 0:d0.execute(x),l=(await y.data())[0];L2[n]=Math.round(100*l)/100,n3=o,o3=T(),r.dispose([x,y]),c(L2[n])}))}var C0,Xt=[],ms=["white","black","asian","indian","other"],ps=[15,23,28,35.5,45.5,55.5,65],A3=0,a3=0,qt=Number.MAX_SAFE_INTEGER;async function i3(e){var t;return M.initial&&(C0=null),C0?e.debug&&h("cached model:",C0.modelUrl):C0=await L((t=e.face.gear)==null?void 0:t.modelPath),C0}async function Ut(e,t,n,o){var a,i;if(!C0)return{age:0,gender:"unknown",genderScore:0,race:[]};let s=qt<(((a=t.face.gear)==null?void 0:a.skipFrames)||0),A=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>T()-a3;return t.skipAllowed&&A&&s&&A3===o&&Xt[n]?(qt++,Xt[n]):(qt=0,new Promise(async c=>{var P,v;if(!(C0!=null&&C0.inputs[0].shape))return;let x={},y=[[0,.1,.9,.9]];x.resize=r.image.cropAndResize(e,y,[0],[C0.inputs[0].shape[2],C0.inputs[0].shape[1]]);let l={age:0,gender:"unknown",genderScore:0,race:[]};(P=t.face.gear)!=null&&P.enabled&&([x.age,x.gender,x.race]=C0.execute(x.resize,["age_output","gender_output","race_output"]));let f=await x.gender.data();l.gender=f[0]>f[1]?"male":"female",l.genderScore=Math.round(100*(f[0]>f[1]?f[0]:f[1]))/100;let d=await x.race.data();for(let p=0;p(((v=t.face.gear)==null?void 0:v.minConfidence)||.2)&&l.race.push({score:Math.round(100*d[p])/100,race:ms[p]});l.race.sort((p,b)=>b.score-p.score);let m=Array.from(await x.age.data()).map((p,b)=>[ps[b],p]).sort((p,b)=>b[1]-p[1]),g=m[0][0];for(let p=1;pr.dispose(x[p])),Xt[n]=l,A3=o,a3=T(),c(l)}))}var R0,O2=[],c3=0,x3=0,Yt=Number.MAX_SAFE_INTEGER;async function d3(e){return M.initial&&(R0=null),R0?e.debug&&h("cached model:",R0.modelUrl):R0=await L(e.face.ssrnet.modelPathAge),R0}async function Kt(e,t,n,o){var a,i,c,x;if(!R0)return{age:0};let s=Yt<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),A=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>T()-x3;return t.skipAllowed&&s&&A&&c3===o&&((c=O2[n])==null?void 0:c.age)&&((x=O2[n])==null?void 0:x.age)>0?(Yt++,O2[n]):(Yt=0,new Promise(async y=>{var d;if(!(R0!=null&&R0.inputs)||!R0.inputs[0]||!R0.inputs[0].shape)return;let l={};l.resize=r.image.resizeBilinear(e,[R0.inputs[0].shape[2],R0.inputs[0].shape[1]],!1),l.enhance=r.mul(l.resize,O.tf255);let f={age:0};if((d=t.face.ssrnet)!=null&&d.enabled&&(l.age=R0.execute(l.enhance)),l.age){let u=await l.age.data();f.age=Math.trunc(10*u[0])/10}Object.keys(l).forEach(u=>r.dispose(l[u])),O2[n]=f,c3=o,x3=T(),y(f)}))}var W0,C2=[],f3=0,m3=0,Jt=Number.MAX_SAFE_INTEGER,Qt=[.2989,.587,.114];async function p3(e){var t;return M.initial&&(W0=null),W0?e.debug&&h("cached model:",W0.modelUrl):W0=await L((t=e.face.ssrnet)==null?void 0:t.modelPathGender),W0}async function _t(e,t,n,o){var a,i,c,x;if(!W0)return{gender:"unknown",genderScore:0};let s=Jt<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),A=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>T()-m3;return t.skipAllowed&&s&&A&&f3===o&&((c=C2[n])==null?void 0:c.gender)&&((x=C2[n])==null?void 0:x.genderScore)>0?(Jt++,C2[n]):(Jt=0,new Promise(async y=>{var u;if(!(W0!=null&&W0.inputs[0].shape))return;let l={};l.resize=r.image.resizeBilinear(e,[W0.inputs[0].shape[2],W0.inputs[0].shape[1]],!1),l.enhance=r.tidy(()=>{let[m,g,P]=r.split(l.resize,3,3),v=r.mul(m,Qt[0]),p=r.mul(g,Qt[1]),b=r.mul(P,Qt[2]),j=r.addN([v,p,b]);return r.mul(r.sub(j,O.tf05),2)});let f={gender:"unknown",genderScore:0};(u=t.face.ssrnet)!=null&&u.enabled&&(l.gender=W0.execute(l.enhance));let d=await l.gender.data();f.gender=d[0]>d[1]?"female":"male",f.genderScore=d[0]>d[1]?Math.trunc(100*d[0])/100:Math.trunc(100*d[1])/100,Object.keys(l).forEach(m=>r.dispose(l[m])),C2[n]=f,f3=o,m3=T(),y(f)}))}var M0,$t=[],h3=0,b3=0,g3=Number.MAX_SAFE_INTEGER;async function T3(e){var t;return M.initial&&(M0=null),M0?e.debug&&h("cached model:",M0.modelUrl):M0=await L((t=e.face.mobilefacenet)==null?void 0:t.modelPath),M0}async function e5(e,t,n,o){var a,i;if(!(M0!=null&&M0.executor))return[];let s=g3<(((a=t.face.mobilefacenet)==null?void 0:a.skipFrames)||0),A=(((i=t.face.mobilefacenet)==null?void 0:i.skipTime)||0)>T()-b3;return t.skipAllowed&&A&&s&&h3===o&&$t[n]?(g3++,$t[n]):new Promise(async c=>{var y;let x=[];if(((y=t.face.mobilefacenet)==null?void 0:y.enabled)&&(M0==null?void 0:M0.inputs[0].shape)){let l={};l.crop=r.image.resizeBilinear(e,[M0.inputs[0].shape[2],M0.inputs[0].shape[1]],!1),l.data=M0.execute(l.crop);let f=await l.data.data();x=Array.from(f),Object.keys(l).forEach(d=>r.dispose(l[d]))}$t[n]=x,h3=o,b3=T(),c(x)})}var P0,t5=[],R3=0,M3=0,P3=Number.MAX_SAFE_INTEGER;async function k3(e){return M.initial&&(P0=null),P0?e.debug&&h("cached model:",P0.modelUrl):P0=await L(e.face.insightface.modelPath),P0}async function n5(e,t,n,o){var a,i;if(!(P0!=null&&P0.executor))return[];let s=P3<(((a=t.face.insightface)==null?void 0:a.skipFrames)||0),A=(((i=t.face.insightface)==null?void 0:i.skipTime)||0)>T()-M3;return t.skipAllowed&&A&&s&&R3===o&&t5[n]?(P3++,t5[n]):new Promise(async c=>{var y;let x=[];if(((y=t.face.insightface)==null?void 0:y.enabled)&&(P0==null?void 0:P0.inputs[0].shape)){let l={};l.crop=r.image.resizeBilinear(e,[P0.inputs[0].shape[2],P0.inputs[0].shape[1]],!1),l.data=P0.execute(l.crop);let f=await l.data.data();x=Array.from(f),Object.keys(l).forEach(d=>r.dispose(l[d]))}t5[n]=x,R3=o,M3=T(),c(x)})}var us=e=>{let t=(l,f)=>Math.atan2(l[1]-f[1],l[0]-f[0]);if(!e.annotations.rightEyeIris||!e.annotations.leftEyeIris)return{bearing:0,strength:0};let n=[0,-.1],o=1,s=(e.mesh[33][2]||0)>(e.mesh[263][2]||0),A=s?e.mesh[473]:e.mesh[468],a=s?[(e.mesh[133][0]+e.mesh[33][0])/2,(e.mesh[133][1]+e.mesh[33][1])/2]:[(e.mesh[263][0]+e.mesh[362][0])/2,(e.mesh[263][1]+e.mesh[362][1])/2],i=s?[e.mesh[133][0]-e.mesh[33][0],e.mesh[23][1]-e.mesh[27][1]]:[e.mesh[263][0]-e.mesh[362][0],e.mesh[253][1]-e.mesh[257][1]],c=[(a[0]-A[0])/i[0]-n[0],o*(A[1]-a[1])/i[1]-n[1]],x=Math.sqrt(c[0]*c[0]+c[1]*c[1]);return x=Math.min(x,e.boxRaw[2]/2,e.boxRaw[3]/2),{bearing:(t([0,0],c)+Math.PI/2)%Math.PI,strength:x}},E3=(e,t)=>{let n=m=>{let g=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);return m[0]/=g,m[1]/=g,m[2]/=g,m},o=(m,g)=>{let P=m[0]-g[0],v=m[1]-g[1],p=m[2]-g[2];return[P,v,p]},s=(m,g)=>{let P=m[1]*g[2]-m[2]*g[1],v=m[2]*g[0]-m[0]*g[2],p=m[0]*g[1]-m[1]*g[0];return[P,v,p]},A=m=>{let[g,P,v,p,b,j,k,I,B]=m,q,W,Z;return p<1?p>-1?(Z=Math.asin(p),W=Math.atan2(-k,g),q=Math.atan2(-j,b)):(Z=-Math.PI/2,W=-Math.atan2(I,B),q=0):(Z=Math.PI/2,W=Math.atan2(I,B),q=0),Number.isNaN(q)&&(q=0),Number.isNaN(W)&&(W=0),Number.isNaN(Z)&&(Z=0),{pitch:2*-q,yaw:2*-W,roll:2*-Z}},a=e.meshRaw;if(!a||a.length<300)return{angle:{pitch:0,yaw:0,roll:0},matrix:[1,0,0,0,1,0,0,0,1],gaze:{bearing:0,strength:0}};let i=Math.max(e.boxRaw[2]*t[0],e.boxRaw[3]*t[1])/1.5,c=[a[10],a[152],a[234],a[454]].map(m=>[m[0]*t[0]/i,m[1]*t[1]/i,m[2]]),x=n(o(c[1],c[0])),y=n(o(c[3],c[2])),l=n(s(y,x));y=s(x,l);let f=[y[0],y[1],y[2],x[0],x[1],x[2],l[0],l[1],l[2]],d=A(f),u=a.length===478?us(e):{bearing:0,strength:0};return{angle:d,matrix:f,gaze:u}};function z3(e,t){let n=e==null?void 0:e.annotations;if(!n)return 0;let o=Math.max(Math.abs(n.leftEyeIris[3][0]-n.leftEyeIris[1][0]),Math.abs(n.rightEyeIris[3][0]-n.rightEyeIris[1][0]))/t;return Math.round(1.17/o)/100}var o5=async(e,t)=>{var u,m,g,P,v,p,b,j,k,I,B,q,W,Z,K,R,D,A0,H,a0,n0,C,F;let n=T(),o,s,A,a,i,c,x,y,l,f=[];e.state="run:face";let d=await F1(t,e.config);if(e.performance.face=M.perfadd?(e.performance.face||0)+Math.trunc(T()-n):Math.trunc(T()-n),!t.shape||t.shape.length!==4)return[];if(!d)return[];for(let S=0;S200?E3(d[S],[t.shape[2],t.shape[1]]):null;e.analyze("Start Emotion:"),e.config.async?a=(m=e.config.face.emotion)!=null&&m.enabled?Wt(d[S].tensor||r.tensor([]),e.config,S,d.length):[]:(e.state="run:emotion",n=T(),a=(g=e.config.face.emotion)!=null&&g.enabled?await Wt(d[S].tensor||r.tensor([]),e.config,S,d.length):[],e.performance.emotion=M.perfadd?(e.performance.emotion||0)+Math.trunc(T()-n):Math.trunc(T()-n)),e.analyze("End Emotion:"),e.analyze("Start AntiSpoof:"),e.config.async?x=(P=e.config.face.antispoof)!=null&&P.enabled?Gt(d[S].tensor||r.tensor([]),e.config,S,d.length):0:(e.state="run:antispoof",n=T(),x=(v=e.config.face.antispoof)!=null&&v.enabled?await Gt(d[S].tensor||r.tensor([]),e.config,S,d.length):0,e.performance.antispoof=M.perfadd?(e.performance.antispoof||0)+Math.trunc(T()-n):Math.trunc(T()-n)),e.analyze("End AntiSpoof:"),e.analyze("Start Liveness:"),e.config.async?y=(p=e.config.face.liveness)!=null&&p.enabled?Zt(d[S].tensor||r.tensor([]),e.config,S,d.length):0:(e.state="run:liveness",n=T(),y=(b=e.config.face.liveness)!=null&&b.enabled?await Zt(d[S].tensor||r.tensor([]),e.config,S,d.length):0,e.performance.liveness=M.perfadd?(e.performance.antispoof||0)+Math.trunc(T()-n):Math.trunc(T()-n)),e.analyze("End Liveness:"),e.analyze("Start GEAR:"),e.config.async?s=(j=e.config.face.gear)!=null&&j.enabled?Ut(d[S].tensor||r.tensor([]),e.config,S,d.length):null:(e.state="run:gear",n=T(),s=(k=e.config.face.gear)!=null&&k.enabled?await Ut(d[S].tensor||r.tensor([]),e.config,S,d.length):null,e.performance.gear=Math.trunc(T()-n)),e.analyze("End GEAR:"),e.analyze("Start SSRNet:"),e.config.async?(o=(I=e.config.face.ssrnet)!=null&&I.enabled?Kt(d[S].tensor||r.tensor([]),e.config,S,d.length):null,A=(B=e.config.face.ssrnet)!=null&&B.enabled?_t(d[S].tensor||r.tensor([]),e.config,S,d.length):null):(e.state="run:ssrnet",n=T(),o=(q=e.config.face.ssrnet)!=null&&q.enabled?await Kt(d[S].tensor||r.tensor([]),e.config,S,d.length):null,A=(W=e.config.face.ssrnet)!=null&&W.enabled?await _t(d[S].tensor||r.tensor([]),e.config,S,d.length):null,e.performance.ssrnet=Math.trunc(T()-n)),e.analyze("End SSRNet:"),e.analyze("Start MobileFaceNet:"),e.config.async?i=(Z=e.config.face.mobilefacenet)!=null&&Z.enabled?e5(d[S].tensor||r.tensor([]),e.config,S,d.length):null:(e.state="run:mobilefacenet",n=T(),i=(K=e.config.face.mobilefacenet)!=null&&K.enabled?await e5(d[S].tensor||r.tensor([]),e.config,S,d.length):null,e.performance.mobilefacenet=Math.trunc(T()-n)),e.analyze("End MobileFaceNet:"),e.analyze("Start InsightFace:"),e.config.async?c=(R=e.config.face.insightface)!=null&&R.enabled?n5(d[S].tensor||r.tensor([]),e.config,S,d.length):null:(e.state="run:mobilefacenet",n=T(),c=(D=e.config.face.insightface)!=null&&D.enabled?await n5(d[S].tensor||r.tensor([]),e.config,S,d.length):null,e.performance.mobilefacenet=Math.trunc(T()-n)),e.analyze("End InsightFace:"),e.analyze("Start Description:"),e.config.async?l=Ft(d[S].tensor||r.tensor([]),e.config,S,d.length):(e.state="run:description",n=T(),l=await Ft(d[S].tensor||r.tensor([]),e.config,S,d.length),e.performance.description=M.perfadd?(e.performance.description||0)+Math.trunc(T()-n):Math.trunc(T()-n)),e.analyze("End Description:"),e.config.async&&([o,A,a,i,c,l,s,x,y]=await Promise.all([o,A,a,i,c,l,s,x,y])),e.analyze("Finish Face:"),((A0=e.config.face.ssrnet)==null?void 0:A0.enabled)&&o&&A&&(l={...l,age:o.age,gender:A.gender,genderScore:A.genderScore}),((H=e.config.face.gear)==null?void 0:H.enabled)&&s&&(l={...l,age:s.age,gender:s.gender,genderScore:s.genderScore,race:s.race}),((a0=e.config.face.mobilefacenet)==null?void 0:a0.enabled)&&i&&(l.descriptor=i),((n0=e.config.face.insightface)==null?void 0:n0.enabled)&&c&&(l.descriptor=c);let $0=(C=e.config.face.iris)!=null&&C.enabled?z3(d[S],t.shape[2]):0,ee=(F=e.config.face.detector)!=null&&F.return?r.squeeze(d[S].tensor):null;r.dispose(d[S].tensor),d[S].tensor&&delete d[S].tensor;let i0={...d[S],id:S};l.age&&(i0.age=l.age),l.gender&&(i0.gender=l.gender),l.genderScore&&(i0.genderScore=l.genderScore),l.descriptor&&(i0.embedding=l.descriptor),l.race&&(i0.race=l.race),a&&(i0.emotion=a),x&&(i0.real=x),y&&(i0.live=y),$0>0&&(i0.distance=$0),N0&&(i0.rotation=N0),ee&&(i0.tensor=ee),f.push(i0),e.analyze("End Face")}return e.analyze("End FaceMesh:"),e.config.async&&(e.performance.face&&delete e.performance.face,e.performance.age&&delete e.performance.age,e.performance.gender&&delete e.performance.gender,e.performance.emotion&&delete e.performance.emotion),f};var b0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>b0.nameMapping[e],getPoints:e=>b0.pointsMapping[e]},ce={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>ce.nameMapping[e]},_={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>_.nameMapping[e]},le=class{constructor(t){E(this,"name");E(this,"curls");E(this,"directions");E(this,"weights");E(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,n,o){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([n,o])}direction(t,n,o){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([n,o])}weight(t,n){this.weights[t]=n;let o=this.weights.reduce((s,A)=>s+A,0);this.weightsRelative=this.weights.map(s=>s*5/o)}matchAgainst(t,n){let o=0;for(let s in t){let A=t[s],a=this.curls[s];if(typeof a=="undefined"){o+=this.weightsRelative[s];continue}for(let[i,c]of a)if(A===i){o+=c*this.weightsRelative[s];break}}for(let s in n){let A=n[s],a=this.directions[s];if(typeof a=="undefined"){o+=this.weightsRelative[s];continue}for(let[i,c]of a)if(A===i){o+=c*this.weightsRelative[s];break}}return o/10}};var{thumb:B0,index:K0,middle:J0,ring:ke,pinky:we}=b0,{none:H0,half:bs,full:G0}=ce,{verticalUp:Ge,verticalDown:Ya,horizontalLeft:r5,horizontalRight:gs,diagonalUpRight:Ts,diagonalUpLeft:Ve,diagonalDownRight:Ka,diagonalDownLeft:Ja}=_,xe=new le("thumbs up");xe.curl(B0,H0,1);xe.direction(B0,Ge,1);xe.direction(B0,Ve,.25);xe.direction(B0,Ts,.25);for(let e of[b0.index,b0.middle,b0.ring,b0.pinky])xe.curl(e,G0,1),xe.direction(e,r5,1),xe.direction(e,gs,1);var o0=new le("victory");o0.curl(B0,bs,.5);o0.curl(B0,H0,.5);o0.direction(B0,Ge,1);o0.direction(B0,Ve,1);o0.curl(K0,H0,1);o0.direction(K0,Ge,.75);o0.direction(K0,Ve,1);o0.curl(J0,H0,1);o0.direction(J0,Ge,1);o0.direction(J0,Ve,.75);o0.curl(ke,G0,1);o0.direction(ke,Ge,.2);o0.direction(ke,Ve,1);o0.direction(ke,r5,.2);o0.curl(we,G0,1);o0.direction(we,Ge,.2);o0.direction(we,Ve,1);o0.direction(we,r5,.2);o0.weight(K0,2);o0.weight(J0,2);var de=new le("point");de.curl(B0,G0,1);de.curl(K0,H0,.5);de.curl(J0,G0,.5);de.curl(ke,G0,.5);de.curl(we,G0,.5);de.weight(K0,2);de.weight(J0,2);var ye=new le("middle finger");ye.curl(B0,H0,1);ye.curl(K0,G0,.5);ye.curl(J0,G0,.5);ye.curl(ke,G0,.5);ye.curl(we,G0,.5);ye.weight(K0,2);ye.weight(J0,2);var Ze=new le("open palm");Ze.curl(B0,H0,.75);Ze.curl(K0,H0,.75);Ze.curl(J0,H0,.75);Ze.curl(ke,H0,.75);Ze.curl(we,H0,.75);var S3=[xe,o0,de,ye,Ze];var vs=.7,Ee={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function j3(e,t,n,o){let s=(t-o)/(e-n),A=Math.atan(s)*180/Math.PI;return A<=0?A=-A:A>0&&(A=180-A),A}function I3(e,t){if(!e||!t)return[0,0];let n=j3(e[0],e[1],t[0],t[1]);if(e.length===2)return n;let o=j3(e[1],e[2],t[1],t[2]);return[n,o]}function N3(e,t=1){let n=0,o=0,s=0;return e>=75&&e<=105?n=1*t:e>=25&&e<=155?o=1*t:s=1*t,[n,o,s]}function Rs(e,t,n){let o=e[0]-t[0],s=e[0]-n[0],A=t[0]-n[0],a=e[1]-t[1],i=e[1]-n[1],c=t[1]-n[1],x=e[2]-t[2],y=e[2]-n[2],l=t[2]-n[2],f=Math.sqrt(o*o+a*a+x*x),d=Math.sqrt(s*s+i*i+y*y),u=Math.sqrt(A*A+c*c+l*l),m=(u*u+f*f-d*d)/(2*u*f);m>1?m=1:m<-1&&(m=-1);let g=Math.acos(m);g=57.2958*g%180;let P;return g>Ee.NO_CURL_START_LIMIT?P=ce.none:g>Ee.HALF_CURL_START_LIMIT?P=ce.half:P=ce.full,P}function L3(e,t,n,o){let s;return o===Math.abs(e)?e>0?s=_.horizontalLeft:s=_.horizontalRight:o===Math.abs(t)?t>0?s=_.horizontalLeft:s=_.horizontalRight:n>0?s=_.horizontalLeft:s=_.horizontalRight,s}function O3(e,t,n,o){let s;return o===Math.abs(e)?e<0?s=_.verticalDown:s=_.verticalUp:o===Math.abs(t)?t<0?s=_.verticalDown:s=_.verticalUp:n<0?s=_.verticalDown:s=_.verticalUp,s}function Ms(e,t,n,o,s,A,a,i){let c,x=O3(e,t,n,o),y=L3(s,A,a,i);return x===_.verticalUp?y===_.horizontalLeft?c=_.diagonalUpLeft:c=_.diagonalUpRight:y===_.horizontalLeft?c=_.diagonalDownLeft:c=_.diagonalDownRight,c}function Ps(e,t,n,o){let s=e[0]-t[0],A=e[0]-n[0],a=t[0]-n[0],i=e[1]-t[1],c=e[1]-n[1],x=t[1]-n[1],y=Math.max(Math.abs(s),Math.abs(A),Math.abs(a)),l=Math.max(Math.abs(i),Math.abs(c),Math.abs(x)),f=0,d=0,u=0,m=l/(y+1e-5);m>1.5?f+=Ee.DISTANCE_VOTE_POWER:m>.66?d+=Ee.DISTANCE_VOTE_POWER:u+=Ee.DISTANCE_VOTE_POWER;let g=Math.sqrt(s*s+i*i),P=Math.sqrt(A*A+c*c),v=Math.sqrt(a*a+x*x),p=Math.max(g,P,v),b=e[0],j=e[1],k=n[0],I=n[1];p===g?(k=n[0],I=n[1]):p===v&&(b=t[0],j=t[1]);let W=I3([b,j],[k,I]),Z=N3(W,Ee.TOTAL_ANGLE_VOTE_POWER);f+=Z[0],d+=Z[1],u+=Z[2];for(let R of o){let D=N3(R,Ee.SINGLE_ANGLE_VOTE_POWER);f+=D[0],d+=D[1],u+=D[2]}let K;return f===Math.max(f,d,u)?K=O3(c,i,x,l):u===Math.max(d,u)?K=L3(A,s,a,y):K=Ms(c,i,x,l,A,s,a,y),K}function C3(e){let t=[],n=[],o=[],s=[];if(!e)return{curls:o,directions:s};for(let A of b0.all){let a=b0.getPoints(A),i=[],c=[];for(let x of a){let y=e[x[0]],l=e[x[1]],f=I3(y,l),d=f[0],u=f[1];i.push(d),c.push(u)}t.push(i),n.push(c)}for(let A of b0.all){let a=A===b0.thumb?1:0,i=b0.getPoints(A),c=e[i[a][0]],x=e[i[a+1][1]],y=e[i[3][1]],l=Rs(c,x,y),f=Ps(c,x,y,t[A].slice(a));o[A]=l,s[A]=f}return{curls:o,directions:s}}function W2(e){if(!e||e.length===0)return null;let t=C3(e),n={};for(let o of b0.all)n[b0.getName(o)]={curl:ce.getName(t.curls[o]),direction:_.getName(t.directions[o])};return n}function W3(e){let t=[];if(!e||e.length===0)return t;let n=C3(e);for(let o of S3){let s=o.matchAgainst(n.curls,n.directions);s>=vs&&t.push({name:o.name,confidence:s})}return t}var D3=e=>{if(!e)return[];let t=[];for(let n=0;nc.part==="leftWrist"),s=e[n].keypoints.find(c=>c.part==="rightWrist"),A=e[n].keypoints.find(c=>c.part==="nose");A&&o&&s&&o.position[1]c.part==="leftShoulder"),i=e[n].keypoints.find(c=>c.part==="rightShoulder");a&&i&&Math.abs(a.positionRaw[1]-i.positionRaw[1])>.1&&t.push({body:n,gesture:`leaning ${a.position[1]>i.position[1]?"left":"right"}`})}return t},F3=e=>{if(!e)return[];let t=[];for(let n=0;n450){let o=(e[n].mesh[33][2]||0)-(e[n].mesh[263][2]||0),s=e[n].mesh[33][0]-e[n].mesh[263][0];Math.abs(o/s)<=.15?t.push({face:n,gesture:"facing center"}):t.push({face:n,gesture:`facing ${o<0?"left":"right"}`}),Math.abs(e[n].mesh[374][1]-e[n].mesh[386][1])/Math.abs(e[n].mesh[443][1]-e[n].mesh[450][1])<.2&&t.push({face:n,gesture:"blink left eye"}),Math.abs(e[n].mesh[145][1]-e[n].mesh[159][1])/Math.abs(e[n].mesh[223][1]-e[n].mesh[230][1])<.2&&t.push({face:n,gesture:"blink right eye"});let i=Math.min(100,500*Math.abs(e[n].mesh[13][1]-e[n].mesh[14][1])/Math.abs(e[n].mesh[10][1]-e[n].mesh[152][1]));i>10&&t.push({face:n,gesture:`mouth ${Math.trunc(i)}% open`});let c=e[n].mesh[152][2]||0;Math.abs(c)>10&&t.push({face:n,gesture:`head ${c<0?"up":"down"}`})}return t},B3=e=>{var n,o,s,A;if(!e)return[];let t=[];for(let a=0;a.06||g>.06)&&(d=!1),m>g?m>.05&&t.push({iris:a,gesture:"looking right"}):g>.05&&t.push({iris:a,gesture:"looking left"});let P=Math.abs(e[a].mesh[145][1]-e[a].annotations.rightEyeIris[0][1])/e[a].box[3],v=Math.abs(e[a].mesh[374][1]-e[a].annotations.leftEyeIris[0][1])/e[a].box[3];(v<.01||P<.01||v>.022||P>.022)&&(d=!1),(v<.01||P<.01)&&t.push({iris:a,gesture:"looking down"}),(v>.022||P>.022)&&t.push({iris:a,gesture:"looking up"}),d&&t.push({iris:a,gesture:"looking center"})}return t},H3=e=>{if(!e)return[];let t=[];for(let n=0;n0){let s=o.reduce((a,i)=>(a.position[2]||0)<(i.position[2]||0)?a:i);t.push({hand:n,gesture:`${s.name} forward`});let A=o.reduce((a,i)=>a.position[1][A[0]*t[0],A[1]*t[1]]);return{startPoint:n,endPoint:o,palmLandmarks:s,confidence:e.confidence}}function F2(e,t=1.5){let n=e2(e),o=D2(e),s=[t*o[0]/2,t*o[1]/2],A=[n[0]-s[0],n[1]-s[1]],a=[n[0]+s[0],n[1]+s[1]];return{startPoint:A,endPoint:a,palmLandmarks:e.palmLandmarks}}function B2(e){let t=e2(e),n=D2(e),s=Math.max(...n)/2,A=[t[0]-s,t[1]-s],a=[t[0]+s,t[1]+s];return{startPoint:A,endPoint:a,palmLandmarks:e.palmLandmarks}}function ws(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function q3(e,t){let n=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return ws(n)}var G3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function fe(e,t){let n=0;for(let o=0;o[a.x,a.y]),this.anchorsTensor=r.tensor2d(this.anchors),this.inputSize=((A=(s=(o=(n=this==null?void 0:this.model)==null?void 0:n.inputs)==null?void 0:o[0])==null?void 0:s.shape)==null?void 0:A[2])||0,this.inputSizeTensor=r.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=r.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let n={};n.boxOffsets=r.slice(t,[0,0],[-1,2]),n.boxSizes=r.slice(t,[0,2],[-1,2]),n.div=r.div(n.boxOffsets,this.inputSizeTensor),n.boxCenterPoints=r.add(n.div,this.anchorsTensor),n.halfBoxSizes=r.div(n.boxSizes,this.doubleInputSizeTensor),n.sub=r.sub(n.boxCenterPoints,n.halfBoxSizes),n.startPoints=r.mul(n.sub,this.inputSizeTensor),n.add=r.add(n.boxCenterPoints,n.halfBoxSizes),n.endPoints=r.mul(n.add,this.inputSizeTensor);let o=r.concat2d([n.startPoints,n.endPoints],1);return Object.keys(n).forEach(s=>r.dispose(n[s])),o}normalizeLandmarks(t,n){let o={};o.reshape=r.reshape(t,[-1,7,2]),o.div=r.div(o.reshape,this.inputSizeTensor),o.landmarks=r.add(o.div,this.anchors[n]?this.anchors[n]:0);let s=r.mul(o.landmarks,this.inputSizeTensor);return Object.keys(o).forEach(A=>r.dispose(o[A])),s}async predict(t,n){var i;let o={};o.resize=r.image.resizeBilinear(t,[this.inputSize,this.inputSize]),o.div=r.div(o.resize,O.tf127),o.image=r.sub(o.div,O.tf1),o.batched=this.model.execute(o.image),o.predictions=r.squeeze(o.batched),o.slice=r.slice(o.predictions,[0,0],[-1,1]),o.sigmoid=r.sigmoid(o.slice),o.scores=r.squeeze(o.sigmoid);let s=await o.scores.data();o.boxes=r.slice(o.predictions,[0,1],[-1,4]),o.norm=this.normalizeBoxes(o.boxes),o.nms=await r.image.nonMaxSuppressionAsync(o.norm,o.scores,3*(((i=n.hand)==null?void 0:i.maxDetected)||1),n.hand.iouThreshold,n.hand.minConfidence);let A=await o.nms.array(),a=[];for(let c of A){let x={};x.box=r.slice(o.norm,[c,0],[1,-1]),x.slice=r.slice(o.predictions,[c,5],[1,14]),x.norm=this.normalizeLandmarks(x.slice,c),x.palmLandmarks=r.reshape(x.norm,[-1,2]);let y=await x.box.data(),l=y.slice(0,2),f=y.slice(2,4),d=await x.palmLandmarks.array(),u={startPoint:l,endPoint:f,palmLandmarks:d,confidence:s[c]},m=X3(u,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);a.push(m),Object.keys(x).forEach(g=>r.dispose(x[g]))}return Object.keys(o).forEach(c=>r.dispose(o[c])),a}};var js=5,J3=1.65,Q3=[0,5,9,13,17,1,2],Ns=0,Is=2,_3=0,G2=class{constructor(t,n){E(this,"handDetector");E(this,"handPoseModel");E(this,"inputSize");E(this,"storedBoxes");E(this,"skipped");E(this,"detectedHands");var o,s,A;this.handDetector=t,this.handPoseModel=n,this.inputSize=((A=(s=(o=this.handPoseModel)==null?void 0:o.inputs)==null?void 0:s[0].shape)==null?void 0:A[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let n=t.map(a=>a[0]),o=t.map(a=>a[1]),s=[Math.min(...n),Math.min(...o)],A=[Math.max(...n),Math.max(...o)];return{startPoint:s,endPoint:A}}getBoxForPalmLandmarks(t,n){let o=t.map(A=>a5([...A,1],n)),s=this.calculateLandmarksBoundingBox(o);return F2(B2(s),js)}getBoxForHandLandmarks(t){let n=this.calculateLandmarksBoundingBox(t),o=F2(B2(n),J3);o.palmLandmarks=[];for(let s=0;s[a[0]*(d[0]-this.inputSize/2),a[1]*(d[1]-this.inputSize/2),a[2]*d[2]]),c=A5(o,[0,0]),x=i.map(d=>[...a5(d,c),d[2]]),y=U3(s),l=[...e2(n),1],f=[fe(l,y[0]),fe(l,y[1])];return x.map(d=>[Math.trunc(d[0]+f[0]),Math.trunc(d[1]+f[1]),Math.trunc(d[2])])}async estimateHands(t,n){let o=!1,s,A=(n.hand.skipTime||0)>T()-_3,a=this.skipped<(n.hand.skipFrames||0);n.skipAllowed&&A&&a&&(s=await this.handDetector.predict(t,n),this.skipped=0),n.skipAllowed&&this.skipped++,s&&s.length>0&&(s.length!==this.detectedHands&&this.detectedHands!==n.hand.maxDetected||!n.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...s],this.storedBoxes.length>0&&(o=!0));let i=[];for(let c=0;c=n.hand.minConfidence/4){let j=r.reshape(p,[-1,3]),k=await j.array();r.dispose(p),r.dispose(j);let I=this.transformRawCoords(k,m,y,u),B=this.getBoxForHandLandmarks(I);this.storedBoxes[c]={...B,confidence:b};let q={landmarks:I,confidence:b,boxConfidence:x.confidence,fingerConfidence:b,box:{topLeft:B.startPoint,bottomRight:B.endPoint}};i.push(q)}else this.storedBoxes[c]=null;r.dispose(p)}else{let y=F2(B2(x),J3),l={confidence:x.confidence,boxConfidence:x.confidence,fingerConfidence:0,box:{topLeft:y.startPoint,bottomRight:y.endPoint},landmarks:[]};i.push(l)}}return this.storedBoxes=this.storedBoxes.filter(c=>c!==null),this.detectedHands=i.length,i.length>n.hand.maxDetected&&(i.length=n.hand.maxDetected),i}};var $3={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},ze,Se,en;async function i5(e,t){let n=await en.estimateHands(e,t);if(!n)return[];let o=[];for(let s=0;sn[s].landmarks[l]);let a=n[s].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],c=[0,0,0,0];if(a&&a.length>0){for(let y of a)y[0]i[2]&&(i[2]=y[0]),y[1]>i[3]&&(i[3]=y[1]);i[2]-=i[0],i[3]-=i[1],c=[i[0]/(e.shape[2]||0),i[1]/(e.shape[1]||0),i[2]/(e.shape[2]||0),i[3]/(e.shape[1]||0)]}else i=n[s].box?[Math.trunc(Math.max(0,n[s].box.topLeft[0])),Math.trunc(Math.max(0,n[s].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,n[s].box.bottomRight[0])-Math.max(0,n[s].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,n[s].box.bottomRight[1])-Math.max(0,n[s].box.topLeft[1]))]:[0,0,0,0],c=[n[s].box.topLeft[0]/(e.shape[2]||0),n[s].box.topLeft[1]/(e.shape[1]||0),(n[s].box.bottomRight[0]-n[s].box.topLeft[0])/(e.shape[2]||0),(n[s].box.bottomRight[1]-n[s].box.topLeft[1])/(e.shape[1]||0)];let x=W2(a);o.push({id:s,score:Math.round(100*n[s].confidence)/100,boxScore:Math.round(100*n[s].boxConfidence)/100,fingerScore:Math.round(100*n[s].fingerConfidence)/100,label:"hand",box:i,boxRaw:c,keypoints:a,annotations:A,landmarks:x})}return o}async function tn(e){var n,o;M.initial&&(ze=null,Se=null),!ze||!Se?[ze,Se]=await Promise.all([e.hand.enabled?L((n=e.hand.detector)==null?void 0:n.modelPath):null,e.hand.landmarks?L((o=e.hand.skeleton)==null?void 0:o.modelPath):null]):(e.debug&&h("cached model:",ze.modelUrl),e.debug&&h("cached model:",Se.modelUrl));let t=ze?new H2(ze):void 0;return t&&Se&&(en=new G2(t,Se)),[ze,Se]}var t0=[null,null],Os=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],me=[[0,0],[0,0]],Cs=["hand","fist","pinch","point","face","tip","pinchtip"],on=4,rn=1.6,Ws=512,Ds=1.4,V2=Number.MAX_SAFE_INTEGER,l5=0,Q0=[0,0],e0={boxes:[],hands:[]},sn={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function An(e){var t;if(M.initial&&(t0[0]=null),t0[0])e.debug&&h("cached model:",t0[0].modelUrl);else{f2(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),t0[0]=await L((t=e.hand.detector)==null?void 0:t.modelPath);let n=t0[0].executor?Object.values(t0[0].modelSignature.inputs):void 0;me[0][0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,me[0][1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}return t0[0]}async function an(e){var t;if(M.initial&&(t0[1]=null),t0[1])e.debug&&h("cached model:",t0[1].modelUrl);else{t0[1]=await L((t=e.hand.skeleton)==null?void 0:t.modelPath);let n=t0[1].executor?Object.values(t0[1].modelSignature.inputs):void 0;me[1][0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,me[1][1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}return t0[1]}async function Fs(e,t){let n=[];if(!e||!t0[0])return n;let o={},s=(e.shape[2]||1)/(e.shape[1]||1),A=Math.min(Math.round((e.shape[1]||0)/8)*8,Ws),a=Math.round(A*s/8)*8;o.resize=r.image.resizeBilinear(e,[A,a]),o.cast=r.cast(o.resize,"int32"),[o.rawScores,o.rawBoxes]=await t0[0].executeAsync(o.cast,Os),o.boxes=r.squeeze(o.rawBoxes,[0,2]),o.scores=r.squeeze(o.rawScores,[0]);let i=r.unstack(o.scores,1);r.dispose(i[on]),i.splice(on,1),o.filtered=r.stack(i,1),r.dispose(i),o.max=r.max(o.filtered,1),o.argmax=r.argMax(o.filtered,1);let c=0;o.nms=await r.image.nonMaxSuppressionAsync(o.boxes,o.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let x=await o.nms.data(),y=await o.max.data(),l=await o.argmax.data();for(let f of Array.from(x)){let d=r.slice(o.boxes,f,1),u=await d.data();r.dispose(d);let m=[u[1],u[0],u[3]-u[1],u[2]-u[0]],g=v2(m,Ds),P=[Math.trunc(m[0]*Q0[0]),Math.trunc(m[1]*Q0[1]),Math.trunc(m[2]*Q0[0]),Math.trunc(m[3]*Q0[1])],v=y[f],p=Cs[l[f]],b={id:c++,score:v,box:P,boxRaw:g,label:p};n.push(b)}return Object.keys(o).forEach(f=>r.dispose(o[f])),n.sort((f,d)=>d.score-f.score),n.length>(t.hand.maxDetected||1)&&(n.length=t.hand.maxDetected||1),n}async function c5(e,t,n){let o={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&t0[1]&&n.hand.landmarks&&t.score>(n.hand.minConfidence||0)){let s={},A=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];s.crop=r.image.cropAndResize(e,[A],[0],[me[1][0],me[1][1]],"bilinear"),s.div=r.div(s.crop,O.tf255),[s.score,s.keypoints]=t0[1].execute(s.div,["Identity_1","Identity"]);let a=(await s.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(a))))/100;if(i>=(n.hand.minConfidence||0)){o.fingerScore=i,s.reshaped=r.reshape(s.keypoints,[-1,3]);let y=(await s.reshaped.array()).map(l=>[l[0]/me[1][1],l[1]/me[1][0],l[2]||0]).map(l=>[l[0]*t.boxRaw[2],l[1]*t.boxRaw[3],l[2]||0]);o.keypoints=y.map(l=>[Q0[0]*(l[0]+t.boxRaw[0]),Q0[1]*(l[1]+t.boxRaw[1]),l[2]||0]),o.landmarks=W2(o.keypoints);for(let l of Object.keys(sn))o.annotations[l]=sn[l].map(f=>o.landmarks&&o.keypoints[f]?o.keypoints[f]:null)}Object.keys(s).forEach(c=>r.dispose(s[c]))}return o}async function x5(e,t){var s,A;if(!((s=t0[0])!=null&&s.executor)||!((A=t0[1])!=null&&A.executor)||!t0[0].inputs[0].shape||!t0[1].inputs[0].shape)return[];Q0=[e.shape[2]||0,e.shape[1]||0],V2++;let n=(t.hand.skipTime||0)>T()-l5,o=V2<(t.hand.skipFrames||0);return t.skipAllowed&&n&&o?e0.hands:new Promise(async a=>{let i=3*(t.hand.skipTime||0)>T()-l5,c=V2<3*(t.hand.skipFrames||0);t.skipAllowed&&e0.hands.length===t.hand.maxDetected?e0.hands=await Promise.all(e0.boxes.map(y=>c5(e,y,t))):t.skipAllowed&&i&&c&&e0.hands.length>0?e0.hands=await Promise.all(e0.boxes.map(y=>c5(e,y,t))):(e0.boxes=await Fs(e,t),l5=T(),e0.hands=await Promise.all(e0.boxes.map(y=>c5(e,y,t))),V2=0);let x=[...e0.boxes];if(e0.boxes.length=0,t.cacheSensitivity>0)for(let y=0;y.05&&l.box[3]/(e.shape[1]||1)>.05&&e0.hands[y].fingerScore&&e0.hands[y].fingerScore>(t.hand.minConfidence||0)){let f=v2(l.box,rn),d=v2(l.boxRaw,rn);e0.boxes.push({...x[y],box:f,boxRaw:d})}}for(let y=0;y({face:[],body:[],hand:[],gesture:[],object:[],persons:[],performance:{},timestamp:0,width:0,height:0,error:e});var t2={};te(t2,{connected:()=>X2,horizontal:()=>d5,kpt:()=>Z2,relative:()=>f5,vertical:()=>y5});var Z2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],d5=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],y5=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],f5=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],X2={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var z=_0(),m5=0;function cn(e,t){var a,i,c,x,y,l,f,d,u,m,g,P,v,p,b,j,k,I,B,q,W,Z,K;let n=T();if(!e)return _0();let o=Date.now()-e.timestamp,s=o<1e3?8-Math.log(o+1):1;if(e.canvas&&(z.canvas=e.canvas),e.error&&(z.error=e.error),!z.body||e.body.length!==z.body.length)z.body=JSON.parse(JSON.stringify(e.body));else for(let R=0;R((s-1)*z.body[R].box[F]+C)/s),A0=e.body[R].boxRaw.map((C,F)=>((s-1)*z.body[R].boxRaw[F]+C)/s),H=e.body[R].keypoints.map((C,F)=>{var S,N0,$0,ee,i0,Ue,I5,L5,O5;return{score:C.score,part:C.part,position:[z.body[R].keypoints[F]?((s-1)*(z.body[R].keypoints[F].position[0]||0)+(C.position[0]||0))/s:C.position[0],z.body[R].keypoints[F]?((s-1)*(z.body[R].keypoints[F].position[1]||0)+(C.position[1]||0))/s:C.position[1],z.body[R].keypoints[F]?((s-1)*(z.body[R].keypoints[F].position[2]||0)+(C.position[2]||0))/s:C.position[2]],positionRaw:[z.body[R].keypoints[F]?((s-1)*(z.body[R].keypoints[F].positionRaw[0]||0)+(C.positionRaw[0]||0))/s:C.positionRaw[0],z.body[R].keypoints[F]?((s-1)*(z.body[R].keypoints[F].positionRaw[1]||0)+(C.positionRaw[1]||0))/s:C.positionRaw[1],z.body[R].keypoints[F]?((s-1)*(z.body[R].keypoints[F].positionRaw[2]||0)+(C.positionRaw[2]||0))/s:C.positionRaw[2]],distance:[z.body[R].keypoints[F]?((s-1)*(((S=z.body[R].keypoints[F].distance)==null?void 0:S[0])||0)+(((N0=C.distance)==null?void 0:N0[0])||0))/s:($0=C.distance)==null?void 0:$0[0],z.body[R].keypoints[F]?((s-1)*(((ee=z.body[R].keypoints[F].distance)==null?void 0:ee[1])||0)+(((i0=C.distance)==null?void 0:i0[1])||0))/s:(Ue=C.distance)==null?void 0:Ue[1],z.body[R].keypoints[F]?((s-1)*(((I5=z.body[R].keypoints[F].distance)==null?void 0:I5[2])||0)+(((L5=C.distance)==null?void 0:L5[2])||0))/s:(O5=C.distance)==null?void 0:O5[2]]}}),a0={},n0={connected:{}};(a=t.body.modelPath)!=null&&a.includes("efficientpose")?n0=P2:(i=t.body.modelPath)!=null&&i.includes("blazepose")?n0=g2:(c=t.body.modelPath)!=null&&c.includes("movenet")&&(n0=t2);for(let[C,F]of Object.entries(n0.connected)){let S=[];for(let N0=0;N0i0.part===F[N0]),ee=H.find(i0=>i0.part===F[N0+1]);$0&&ee&&S.push([$0.position,ee.position])}a0[C]=S}z.body[R]={...e.body[R],box:D,boxRaw:A0,keypoints:H,annotations:a0}}if(!z.hand||e.hand.length!==z.hand.length)z.hand=JSON.parse(JSON.stringify(e.hand));else for(let R=0;R((s-1)*z.hand[R].box[C]+n0)/s),A0=e.hand[R].boxRaw.map((n0,C)=>((s-1)*z.hand[R].boxRaw[C]+n0)/s);z.hand[R].keypoints.length!==e.hand[R].keypoints.length&&(z.hand[R].keypoints=e.hand[R].keypoints);let H=e.hand[R].keypoints&&e.hand[R].keypoints.length>0?e.hand[R].keypoints.map((n0,C)=>n0.map((F,S)=>((s-1)*(z.hand[R].keypoints[C][S]||1)+(F||0))/s)):[],a0={};if(Object.keys(z.hand[R].annotations).length!==Object.keys(e.hand[R].annotations).length)z.hand[R].annotations=e.hand[R].annotations,a0=z.hand[R].annotations;else if(e.hand[R].annotations)for(let n0 of Object.keys(e.hand[R].annotations))a0[n0]=(l=(y=(x=e.hand[R])==null?void 0:x.annotations)==null?void 0:y[n0])!=null&&l[0]?e.hand[R].annotations[n0].map((C,F)=>C.map((S,N0)=>((s-1)*z.hand[R].annotations[n0][F][N0]+S)/s)):null;z.hand[R]={...e.hand[R],box:D,boxRaw:A0,keypoints:H,annotations:a0}}if(!z.face||e.face.length!==z.face.length)z.face=JSON.parse(JSON.stringify(e.face));else for(let R=0;R((s-1)*z.face[R].box[a0]+H)/s),A0=e.face[R].boxRaw.map((H,a0)=>((s-1)*z.face[R].boxRaw[a0]+H)/s);if(e.face[R].rotation){let H={matrix:[0,0,0,0,0,0,0,0,0],angle:{roll:0,yaw:0,pitch:0},gaze:{bearing:0,strength:0}};H.matrix=(f=e.face[R].rotation)==null?void 0:f.matrix,H.angle={roll:((s-1)*(((u=(d=z.face[R].rotation)==null?void 0:d.angle)==null?void 0:u.roll)||0)+(((g=(m=e.face[R].rotation)==null?void 0:m.angle)==null?void 0:g.roll)||0))/s,yaw:((s-1)*(((v=(P=z.face[R].rotation)==null?void 0:P.angle)==null?void 0:v.yaw)||0)+(((b=(p=e.face[R].rotation)==null?void 0:p.angle)==null?void 0:b.yaw)||0))/s,pitch:((s-1)*(((k=(j=z.face[R].rotation)==null?void 0:j.angle)==null?void 0:k.pitch)||0)+(((B=(I=e.face[R].rotation)==null?void 0:I.angle)==null?void 0:B.pitch)||0))/s},H.gaze={bearing:((s-1)*(((q=z.face[R].rotation)==null?void 0:q.gaze.bearing)||0)+(((W=e.face[R].rotation)==null?void 0:W.gaze.bearing)||0))/s,strength:((s-1)*(((Z=z.face[R].rotation)==null?void 0:Z.gaze.strength)||0)+(((K=e.face[R].rotation)==null?void 0:K.gaze.strength)||0))/s},z.face[R]={...e.face[R],rotation:H,box:D,boxRaw:A0}}else z.face[R]={...e.face[R],box:D,boxRaw:A0}}if(!z.object||e.object.length!==z.object.length)z.object=JSON.parse(JSON.stringify(e.object));else for(let R=0;R((s-1)*z.object[R].box[a0]+H)/s),A0=e.object[R].boxRaw.map((H,a0)=>((s-1)*z.object[R].boxRaw[a0]+H)/s);z.object[R]={...e.object[R],box:D,boxRaw:A0}}if(e.persons){let R=e.persons;if(!z.persons||R.length!==z.persons.length)z.persons=JSON.parse(JSON.stringify(R));else for(let D=0;D((s-1)*z.persons[D].box[H]+A0)/s)}e.gesture&&(z.gesture=e.gesture),z.width=e.width,z.height=e.height;let A=T();return m5=M.perfadd?m5+Math.round(A-n):Math.round(A-n),e.performance&&(z.performance={...e.performance,interpolate:m5}),z}var m0;async function p5(e){return!m0||M.initial?m0=await L(e.segmentation.modelPath):e.debug&&h("cached model:",m0.modelUrl),m0}async function xn(e,t){var s;if(m0||(m0=await p5(t)),!(m0!=null&&m0.executor)||!((s=m0==null?void 0:m0.inputs)!=null&&s[0].shape))return null;let n={};n.resize=r.image.resizeBilinear(e,[m0.inputs[0].shape?m0.inputs[0].shape[1]:0,m0.inputs[0].shape?m0.inputs[0].shape[2]:0],!1),n.norm=r.div(n.resize,O.tf255),n.res=m0.execute(n.norm),n.squeeze=r.squeeze(n.res,[0]),[n.bgRaw,n.fgRaw]=r.unstack(n.squeeze,2),n.fg=r.softmax(n.fgRaw),n.mul=r.mul(n.fg,O.tf255),n.expand=r.expandDims(n.mul,2),n.output=r.image.resizeBilinear(n.expand,[e.shape[1]||0,e.shape[2]||0]);let o;switch(t.segmentation.mode||"default"){case"default":n.input=r.squeeze(e),n.concat=r.concat([n.input,n.output],-1),o=r.cast(n.concat,"int32");break;case"alpha":o=r.cast(n.output,"int32");break;default:o=r.tensor(0)}return Object.keys(n).forEach(A=>r.dispose(n[A])),o}var h5={};te(h5,{distance:()=>u5,find:()=>Gs,similarity:()=>Hs});function u5(e,t,n={order:2,multiplier:25}){if(!e||!e)return Number.MAX_SAFE_INTEGER;let o=0;for(let s=0;s{if(e===0)return 1;let A=(1-(t===2?Math.sqrt(e):e**(1/t))/100-n)/(o-n);return Math.max(Math.min(A,1),0)};function Hs(e,t,n={order:2,multiplier:25,min:.2,max:.8}){let o=u5(e,t,n);return yn(o,n.order||2,n.min||0,n.max||1)}function Gs(e,t,n={order:2,multiplier:25,threshold:0,min:.2,max:.8}){if(!Array.isArray(e)||!Array.isArray(t)||e.length<64||t.length===0)return{index:-1,distance:Number.POSITIVE_INFINITY,similarity:0};let o=Number.MAX_SAFE_INTEGER,s=-1;for(let a=0;ar2,validateModel:()=>_2});var fn=.005,k0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function b5(e){for(let t of d5){let n=e.keypoints.findIndex(s=>s.part===t[0]),o=e.keypoints.findIndex(s=>s.part===t[1]);if(e.keypoints[n]&&e.keypoints[o]&&e.keypoints[n].position[0]s&&s.part===t[0]),o=e.keypoints.findIndex(s=>s&&s.part===t[1]);e.keypoints[n]&&e.keypoints[o]&&e.keypoints[n].position[1]x&&x.part===t[0]),s=e.keypoints.findIndex(x=>x&&x.part===t[1]),A=e.keypoints.findIndex(x=>x&&x.part===n[0]),a=e.keypoints.findIndex(x=>x&&x.part===n[1]);if(!e.keypoints[A]||!e.keypoints[a])continue;let i=e.keypoints[o]?[Math.abs(e.keypoints[A].position[0]-e.keypoints[o].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[o].position[0])]:[0,0],c=e.keypoints[s]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[s].position[0]),Math.abs(e.keypoints[A].position[0]-e.keypoints[s].position[0])]:[0,0];if(i[0]>i[1]||c[0]>c[1]){let x=e.keypoints[o];e.keypoints[o]=e.keypoints[s],e.keypoints[s]=x}}}function mn(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],n.pad=r.pad(e,k0.padding),n.resize=r.image.resizeBilinear(n.pad,[t,t]);let o=r.cast(n.resize,"int32");return Object.keys(n).forEach(a=>r.dispose(n[a])),o}function un(e,t){e.keypoints=e.keypoints.filter(o=>o==null?void 0:o.position);for(let o of e.keypoints)o.position=[o.position[0]*(t[0]+k0.padding[2][0]+k0.padding[2][1])/t[0]-k0.padding[2][0],o.position[1]*(t[1]+k0.padding[1][0]+k0.padding[1][1])/t[1]-k0.padding[1][0]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1]];let n=Y0(e.keypoints.map(o=>o.position),t);return e.box=n.box,e.boxRaw=n.boxRaw,e}var r0,q2=0,g5=Number.MAX_SAFE_INTEGER,je={boxes:[],bodies:[],last:0};async function hn(e){var t;return M.initial&&(r0=null),r0?e.debug&&h("cached model:",r0.modelUrl):(f2(["size"],e),r0=await L(e.body.modelPath)),q2=(r0==null?void 0:r0.executor)&&((t=r0==null?void 0:r0.inputs)==null?void 0:t[0].shape)?r0.inputs[0].shape[2]:0,q2<64&&(q2=256),r0}function Zs(e,t,n){let o=e[0][0],s=[],A=0;for(let y=0;yt.body.minConfidence){let l=[o[y][1],o[y][0]];s.push({score:Math.round(100*A)/100,part:Z2[y],positionRaw:l,position:[Math.round((n.shape[2]||0)*l[0]),Math.round((n.shape[1]||0)*l[1])]})}A=s.reduce((y,l)=>l.score>y?l.score:y,0);let a=[],i=Y0(s.map(y=>y.position),[n.shape[2],n.shape[1]]),c={};for(let[y,l]of Object.entries(X2)){let f=[];for(let d=0;dg.part===l[d]),m=s.find(g=>g.part===l[d+1]);u&&m&&u.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&f.push([u.position,m.position])}c[y]=f}let x={id:0,score:A,box:i.box,boxRaw:i.boxRaw,keypoints:s,annotations:c};return b5(x),a.push(x),a}function Xs(e,t,n){let o=[];for(let s=0;st.body.minConfidence){let i=[];for(let l=0;l<17;l++){let f=A[3*l+2];if(f>t.body.minConfidence){let d=[A[3*l+1],A[3*l+0]];i.push({part:Z2[l],score:Math.round(100*f)/100,positionRaw:d,position:[Math.round((n.shape[2]||0)*d[0]),Math.round((n.shape[1]||0)*d[1])]})}}let c=Y0(i.map(l=>l.position),[n.shape[2],n.shape[1]]),x={};for(let[l,f]of Object.entries(X2)){let d=[];for(let u=0;uP.part===f[u]),g=i.find(P=>P.part===f[u+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&d.push([m.position,g.position])}x[l]=d}let y={id:s,score:a,box:c.box,boxRaw:c.boxRaw,keypoints:[...i],annotations:x};b5(y),o.push(y)}}return o.sort((s,A)=>A.score-s.score),o.length>t.body.maxDetected&&(o.length=t.body.maxDetected),o}async function T5(e,t){var s;if(!(r0!=null&&r0.executor)||!((s=r0==null?void 0:r0.inputs)!=null&&s[0].shape))return[];t.skipAllowed||(je.boxes.length=0),g5++;let n=(t.body.skipTime||0)>T()-je.last,o=g5<(t.body.skipFrames||0);return t.skipAllowed&&n&&o?je.bodies:new Promise(async A=>{let a={};g5=0,a.input=pn(e,q2),a.res=r0==null?void 0:r0.execute(a.input),je.last=T();let i=await a.res.array();je.bodies=a.res.shape[2]===17?Zs(i,t,e):Xs(i,t,e);for(let c of je.bodies)un(c,[e.shape[2]||1,e.shape[1]||1]),mn(c.keypoints);Object.keys(a).forEach(c=>r.dispose(a[c])),A(je.bodies)})}var D0,U2=[],gn=0,v5=Number.MAX_SAFE_INTEGER,K2=0,Y2=2.5;async function Tn(e){if(!D0||M.initial){D0=await L(e.object.modelPath);let t=D0!=null&&D0.executor?Object.values(D0.modelSignature.inputs):void 0;K2=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&h("cached model:",D0.modelUrl);return D0}async function qs(e,t,n){var x,y;let o=0,s=[],A=K2;for(let l of[1,2,4]){let f=l*13,d=r.squeeze(e.find(p=>p.shape[1]===f**2&&(p.shape[2]||0)===Oe.length)),u=await d.array(),m=r.squeeze(e.find(p=>p.shape[1]===f**2&&(p.shape[2]||0)(n.object.minConfidence||0)&&b!==61){let k=(.5+Math.trunc(p%f))/f,I=(.5+Math.trunc(p/f))/f,B=v[p].map(H=>H*(f/l/A)),[q,W]=[k-Y2/l*B[0],I-Y2/l*B[1]],[Z,K]=[k+Y2/l*B[2]-q,I+Y2/l*B[3]-W],R=[q,W,Z,K];R=R.map(H=>Math.max(0,Math.min(H,1)));let D=[R[0]*t[0],R[1]*t[1],R[2]*t[0],R[3]*t[1]],A0={id:o++,score:Math.round(100*j)/100,class:b+1,label:Oe[b].label,box:D.map(H=>Math.trunc(H)),boxRaw:R};s.push(A0)}}r.dispose([d,m,g,P])}let a=s.map(l=>[l.boxRaw[1],l.boxRaw[0],l.boxRaw[3],l.boxRaw[2]]),i=s.map(l=>l.score),c=[];if(a&&a.length>0){let l=await r.image.nonMaxSuppressionAsync(a,i,n.object.maxDetected||0,n.object.iouThreshold,n.object.minConfidence);c=Array.from(await l.data()),r.dispose(l)}return s=s.filter((l,f)=>c.includes(f)).sort((l,f)=>f.score-l.score),s}async function R5(e,t){if(!(D0!=null&&D0.executor))return[];let n=(t.object.skipTime||0)>T()-gn,o=v5<(t.object.skipFrames||0);return t.skipAllowed&&n&&o&&U2.length>0?(v5++,U2):(v5=0,!M.kernels.includes("mod")||!M.kernels.includes("sparsetodense")?U2:new Promise(async s=>{let A=[e.shape[2]||0,e.shape[1]||0],a=r.image.resizeBilinear(e,[K2,K2],!1),i=r.div(a,O.tf255),c=r.transpose(i,[0,3,1,2]),x;t.object.enabled&&(x=D0.execute(c)),gn=T();let y=await qs(x,A,t);U2=y,r.dispose([a,i,c,...x]),s(y)}))}var o2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Us=o2.length,n2=o2.reduce((e,t,n)=>(e[t]=n,e),{}),Ys=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],H7=Ys.map(([e,t])=>[n2[e],n2[t]]),Rn=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function Mn(e){let t=e.reduce(({maxX:n,maxY:o,minX:s,minY:A},{position:{x:a,y:i}})=>({maxX:Math.max(n,a),maxY:Math.max(o,i),minX:Math.min(s,a),minY:Math.min(A,i)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function Pn(e,[t,n],[o,s]){let A=t/o,a=n/s,i=(x,y)=>({id:y,score:x.score,boxRaw:[x.box[0]/s,x.box[1]/o,x.box[2]/s,x.box[3]/o],box:[Math.trunc(x.box[0]*a),Math.trunc(x.box[1]*A),Math.trunc(x.box[2]*a),Math.trunc(x.box[3]*A)],keypoints:x.keypoints.map(({score:l,part:f,position:d})=>({score:l,part:f,position:[Math.trunc(d.x*a),Math.trunc(d.y*A)],positionRaw:[d.x/o,d.y/o]})),annotations:{}});return e.map((x,y)=>i(x,y))}var J2=class{constructor(t,n){E(this,"priorityQueue");E(this,"numberOfElements");E(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=n}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let n=2*t;if(nn?n:e}function kn(e,t,n,o){let s=n-e,A=o-t;return s*s+A*A}function w5(e,t){return{x:e.x+t.x,y:e.y+t.y}}var w0,Js=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],Q2=1,Xe=16,Qs=50**2;function wn(e,t,n,o,s,A,a=2){let i=P=>({y:A.get(P.y,P.x,e),x:A.get(P.y,P.x,A.shape[2]/2+e)}),c=(P,v,p)=>({y:k5(Math.round(P.y/Xe),0,v-1),x:k5(Math.round(P.x/Xe),0,p-1)}),[x,y]=o.shape,l=c(t.position,x,y),f=i(l),u=w5(t.position,f);for(let P=0;P[n2[f],n2[d]]),a=A.map(([,f])=>f),i=A.map(([f])=>f),c=t.shape[2],x=a.length,y=new Array(c),l=P5(e.part,Xe,n);y[e.part.id]={score:e.score,part:o2[e.part.id],position:l};for(let f=x-1;f>=0;--f){let d=a[f],u=i[f];y[d]&&!y[u]&&(y[u]=wn(f,y[d],u,t,n,s))}for(let f=0;ft){i=!1;break}if(!i)break}return i}function eA(e,t){let[n,o,s]=t.shape,A=new J2(n*o*s,({score:a})=>a);for(let a=0;a{var a;let A=(a=s[o])==null?void 0:a.position;return A?kn(n,t,A.y,A.x)<=Qs:!1})}function tA(e,t){return t.reduce((o,{position:s,score:A},a)=>(En(e,s,a)||(o+=A),o),0)/t.length}function nA(e,t,n,o,s,A){let a=[],i=eA(A,t);for(;a.lengthd.score>A);let l=tA(a,y),f=Mn(y);l>A&&a.push({keypoints:y,box:f,score:Math.round(100*l)/100})}return a}async function E5(e,t){if(!(w0!=null&&w0.executor))return[];let n=r.tidy(()=>{if(!w0.inputs[0].shape)return[];let a=r.image.resizeBilinear(e,[w0.inputs[0].shape[2],w0.inputs[0].shape[1]]),i=r.sub(r.div(r.cast(a,"float32"),127.5),1),x=w0.execute(i,Js).map(y=>r.squeeze(y,[0]));return x[1]=r.sigmoid(x[1]),x}),o=await Promise.all(n.map(a=>a.buffer()));for(let a of n)r.dispose(a);let s=nA(o[0],o[1],o[2],o[3],t.body.maxDetected,t.body.minConfidence);return w0.inputs[0].shape?Pn(s,[e.shape[1],e.shape[2]],[w0.inputs[0].shape[2],w0.inputs[0].shape[1]]):[]}async function zn(e){return!w0||M.initial?w0=await L(e.body.modelPath):e.debug&&h("cached model:",w0.modelUrl),w0}var q0,oA=["fgr","pha","r1o","r2o","r3o","r4o"],s0={},S5=0;function Nn(e){r.dispose([s0.r1i,s0.r2i,s0.r3i,s0.r4i,s0.downsample_ratio]),s0.r1i=r.tensor(0),s0.r2i=r.tensor(0),s0.r3i=r.tensor(0),s0.r4i=r.tensor(0),S5=e.segmentation.ratio||.5,s0.downsample_ratio=r.tensor(S5)}async function j5(e){return!q0||M.initial?q0=await L(e.segmentation.modelPath):e.debug&&h("cached model:",q0.modelUrl),Nn(e),q0}var jn=e=>r.tidy(()=>{let t=r.squeeze(e,[0]),n=r.mul(t,O.tf255);return r.cast(n,"int32")});function z5(e,t){let n=e?jn(e):r.fill([t.shape[1]||0,t.shape[2]||0,3],255,"int32"),o=t?jn(t):r.fill([e.shape[1]||0,e.shape[2]||0,1],255,"int32"),s=r.concat([n,o],-1);return r.dispose([n,o]),s}function rA(e){return r.tidy(()=>{let t={};return t.unstack=r.unstack(e,-1),t.concat=r.concat(t.unstack,1),t.split=r.split(t.concat,4,1),t.stack=r.concat(t.split,2),t.squeeze=r.squeeze(t.stack,[0]),t.expand=r.expandDims(t.squeeze,-1),t.add=r.add(t.expand,1),t.mul=r.mul(t.add,127.5),t.cast=r.cast(t.mul,"int32"),t.tile=r.tile(t.cast,[1,1,3]),t.alpha=r.fill([t.tile.shape[0]||0,t.tile.shape[1]||0,1],255,"int32"),r.concat([t.tile,t.alpha],-1)})}async function In(e,t){if(q0||(q0=await j5(t)),!(q0!=null&&q0.executor))return null;s0.src=r.div(e,255),S5!==t.segmentation.ratio&&Nn(t);let[n,o,s,A,a,i]=await q0.executeAsync(s0,oA),c;switch(t.segmentation.mode||"default"){case"default":c=z5(n,o);break;case"alpha":c=z5(null,o);break;case"foreground":c=z5(n,null);break;case"state":c=rA(s);break;default:c=r.tensor(0)}return r.dispose([s0.src,n,o,s0.r1i,s0.r2i,s0.r3i,s0.r4i]),[s0.r1i,s0.r2i,s0.r3i,s0.r4i]=[s,A,a,i],c}var p0;async function N5(e){return!p0||M.initial?p0=await L(e.segmentation.modelPath):e.debug&&h("cached model:",p0.modelUrl),p0}async function On(e,t){var s;if(p0||(p0=await N5(t)),!(p0!=null&&p0.executor)||!((s=p0==null?void 0:p0.inputs)!=null&&s[0].shape))return null;let n={};n.resize=r.image.resizeBilinear(e,[p0.inputs[0].shape?p0.inputs[0].shape[1]:0,p0.inputs[0].shape?p0.inputs[0].shape[2]:0],!1),n.norm=r.div(n.resize,O.tf255),n.res=p0.execute(n.norm),n.squeeze=r.squeeze(n.res,[0]),n.alpha=r.image.resizeBilinear(n.squeeze,[e.shape[1]||0,e.shape[2]||0]),n.mul=r.mul(n.alpha,O.tf255);let o;switch(t.segmentation.mode||"default"){case"default":n.input=r.squeeze(e),n.concat=r.concat([n.input,n.mul],-1),o=r.cast(n.concat,"int32");break;case"alpha":o=r.cast(n.mul,"int32");break;default:o=r.tensor(0)}return Object.keys(n).forEach(A=>r.dispose(n[A])),o}function _2(e,t,n){var x,y;if(!t||!((x=e==null?void 0:e.config)!=null&&x.validateModels))return null;let o=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],s=["biasadd","fusedbatchnormv3","matmul","switch","shape","merge","split","broadcastto"],A=[],a=[],i=t.modelUrl,c=t.executor;if((y=c==null?void 0:c.graph)!=null&&y.nodes)for(let l of Object.values(c.graph.nodes)){let f=l.op.toLowerCase();A.includes(f)||A.push(f)}else!c&&e.config.debug&&h("model not loaded",n);for(let l of A)!o.includes(l)&&!s.includes(l)&&!e.env.kernels.includes(l)&&!e.env.kernels.includes(l.replace("_",""))&&!e.env.kernels.includes(l.replace("native",""))&&!e.env.kernels.includes(l.replace("v2",""))&&a.push(l);return e.config.debug&&a.length>0&&h("model validation failed:",n,a),a.length>0?{name:n,missing:a,ops:A,url:i}:null}var r2=class{constructor(t){E(this,"instance");E(this,"models");this.models={},this.instance=t}stats(){let t=0,n=0,o=0;for(let A of Object.values(y0))t+=A.sizeFromManifest,n+=A.sizeLoadedWeights,o+=A.sizeDesired;let s=o>0?n/o:0;return{numLoadedModels:Object.values(y0).length,numDefinedModels:Object.keys(this.models).length,percentageLoaded:s,totalSizeFromManifest:t,totalSizeWeights:n,totalSizeLoading:o,modelStats:Object.values(y0)}}reset(){for(let t of Object.keys(this.models))this.models[t]=null}async load(){var n,o,s,A,a,i,c,x,y,l,f,d,u,m,g,P,v,p,b,j,k,I,B,q,W,Z,K;M.initial&&this.reset();let t={};t.blazeface=this.instance.config.face.enabled&&!this.models.blazeface?z1(this.instance.config):null,t.antispoof=this.instance.config.face.enabled&&((n=this.instance.config.face.antispoof)==null?void 0:n.enabled)&&!this.models.antispoof?e3(this.instance.config):null,t.liveness=this.instance.config.face.enabled&&((o=this.instance.config.face.liveness)==null?void 0:o.enabled)&&!this.models.liveness?r3(this.instance.config):null,t.faceres=this.instance.config.face.enabled&&((s=this.instance.config.face.description)==null?void 0:s.enabled)&&!this.models.faceres?K1(this.instance.config):null,t.emotion=this.instance.config.face.enabled&&((A=this.instance.config.face.emotion)==null?void 0:A.enabled)&&!this.models.emotion?X1(this.instance.config):null,t.iris=this.instance.config.face.enabled&&((a=this.instance.config.face.iris)==null?void 0:a.enabled)&&!((i=this.instance.config.face.attention)!=null&&i.enabled)&&!this.models.iris?O1(this.instance.config):null,t.facemesh=this.instance.config.face.enabled&&((c=this.instance.config.face.mesh)==null?void 0:c.enabled)&&!this.models.facemesh?B1(this.instance.config):null,t.gear=this.instance.config.face.enabled&&((x=this.instance.config.face.gear)==null?void 0:x.enabled)&&!this.models.gear?i3(this.instance.config):null,t.ssrnetage=this.instance.config.face.enabled&&((y=this.instance.config.face.ssrnet)==null?void 0:y.enabled)&&!this.models.ssrnetage?d3(this.instance.config):null,t.ssrnetgender=this.instance.config.face.enabled&&((l=this.instance.config.face.ssrnet)==null?void 0:l.enabled)&&!this.models.ssrnetgender?p3(this.instance.config):null,t.mobilefacenet=this.instance.config.face.enabled&&((f=this.instance.config.face.mobilefacenet)==null?void 0:f.enabled)&&!this.models.mobilefacenet?T3(this.instance.config):null,t.insightface=this.instance.config.face.enabled&&((d=this.instance.config.face.insightface)==null?void 0:d.enabled)&&!this.models.insightface?k3(this.instance.config):null,t.blazepose=this.instance.config.body.enabled&&!this.models.blazepose&&((u=this.instance.config.body.modelPath)==null?void 0:u.includes("blazepose"))?x1(this.instance.config):null,t.blazeposedetect=this.instance.config.body.enabled&&!this.models.blazeposedetect&&this.instance.config.body.detector&&this.instance.config.body.detector.modelPath?c1(this.instance.config):null,t.efficientpose=this.instance.config.body.enabled&&!this.models.efficientpose&&((m=this.instance.config.body.modelPath)==null?void 0:m.includes("efficientpose"))?u1(this.instance.config):null,t.movenet=this.instance.config.body.enabled&&!this.models.movenet&&((g=this.instance.config.body.modelPath)==null?void 0:g.includes("movenet"))?hn(this.instance.config):null,t.posenet=this.instance.config.body.enabled&&!this.models.posenet&&((P=this.instance.config.body.modelPath)==null?void 0:P.includes("posenet"))?zn(this.instance.config):null,t.handtrack=this.instance.config.hand.enabled&&!this.models.handtrack&&((p=(v=this.instance.config.hand.detector)==null?void 0:v.modelPath)==null?void 0:p.includes("handtrack"))?An(this.instance.config):null,t.handskeleton=this.instance.config.hand.enabled&&this.instance.config.hand.landmarks&&!this.models.handskeleton&&((j=(b=this.instance.config.hand.detector)==null?void 0:b.modelPath)==null?void 0:j.includes("handtrack"))?an(this.instance.config):null,(I=(k=this.instance.config.hand.detector)==null?void 0:k.modelPath)!=null&&I.includes("handdetect")&&([t.handpose,t.handskeleton]=this.models.handpose?[null,null]:await tn(this.instance.config)),t.centernet=this.instance.config.object.enabled&&!this.models.centernet&&((B=this.instance.config.object.modelPath)==null?void 0:B.includes("centernet"))?f1(this.instance.config):null,t.nanodet=this.instance.config.object.enabled&&!this.models.nanodet&&((q=this.instance.config.object.modelPath)==null?void 0:q.includes("nanodet"))?Tn(this.instance.config):null,t.selfie=this.instance.config.segmentation.enabled&&!this.models.selfie&&((W=this.instance.config.segmentation.modelPath)==null?void 0:W.includes("selfie"))?N5(this.instance.config):null,t.meet=this.instance.config.segmentation.enabled&&!this.models.meet&&((Z=this.instance.config.segmentation.modelPath)==null?void 0:Z.includes("meet"))?p5(this.instance.config):null,t.rvm=this.instance.config.segmentation.enabled&&!this.models.rvm&&((K=this.instance.config.segmentation.modelPath)==null?void 0:K.includes("rvm"))?j5(this.instance.config):null,await Promise.all([...Object.values(t)]);for(let R of Object.keys(t))this.models[R]=t[R]||this.models[R]||null}list(){let t=Object.keys(this.models).map(n=>{var o;return{name:n,loaded:this.models[n]!==null,size:0,url:this.models[n]?(o=this.models[n])==null?void 0:o.modelUrl:null}});for(let n of t){let o=Object.keys(y0).find(s=>s.startsWith(n.name));!o||(n.size=y0[o].sizeLoadedWeights,n.url=y0[o].url)}return t}loaded(){return this.list().filter(o=>o.loaded).map(o=>o.name)}validate(){let t=[];for(let n of Object.keys(this.models)){let o=this.models[n];if(!o)continue;let s=_2(this.instance,o,n);s&&t.push(s)}return t}};function Dn(e,t,n,o,s){var i,c,x,y,l,f;let A=0,a=[];for(let d of e){let u={id:A++,face:d,body:null,hands:{left:null,right:null},gestures:[],box:[0,0,0,0]};for(let b of t)d.box[0]>b.box[0]&&d.box[0]b.box[1]&&d.box[1]+d.box[3]u.body.box[0]&&b.box[0]+b.box[2]u.body.box[1]&&b.box[1]+b.box[3]u.body.box[0]&&b.box[1]+b.box[3]>u.body.box[1]&&b.box[1]+b.box[3]{b&&b.length===4&&(m.push(b[0],b[0]+b[2]),g.push(b[1],b[1]+b[3]))};P(u.face.box),P((y=u.body)==null?void 0:y.box),P((l=u.hands.left)==null?void 0:l.box),P((f=u.hands.right)==null?void 0:f.box);let v=Math.min(...m),p=Math.min(...g);u.box=[v,p,Math.max(...m)-v,Math.max(...g)-p],(s==null?void 0:s[1])&&(s==null?void 0:s[2])&&(u.boxRaw=[u.box[0]/s[2],u.box[1]/s[1],u.box[2]/s[2],u.box[3]/s[1]]),a.push(u)}return a}var $2=`
+ gaze: [gaze]\xB0`,
+ body: "body [score]%",
+ bodyPart: "[label] [score]%",
+ object: "[label] [score]%",
+ hand: "[label] [score]%",
+ finger: "[label]",
+ gesture: "[where] [who]: [what]"
+};
+
+// src/draw/draw.ts
+var drawTime = 0;
+function person(inCanvas2, result, drawOptions) {
+ const localOptions2 = mergeDeep(options2, drawOptions);
+ if (!result || !inCanvas2)
+ return;
+ const ctx = getCanvasContext(inCanvas2);
+ if (!ctx)
+ return;
+ ctx.lineJoin = "round";
+ ctx.font = localOptions2.font;
+ for (let i = 0; i < result.length; i++) {
+ if (localOptions2.drawBoxes) {
+ ctx.strokeStyle = localOptions2.color;
+ ctx.fillStyle = localOptions2.color;
+ rect(ctx, result[i].box[0], result[i].box[1], result[i].box[2], result[i].box[3], localOptions2);
+ if (localOptions2.drawLabels) {
+ const label = `person #${i}`;
+ if (localOptions2.shadowColor && localOptions2.shadowColor !== "") {
+ ctx.fillStyle = localOptions2.shadowColor;
+ ctx.fillText(label, result[i].box[0] + 3, 1 + result[i].box[1] + localOptions2.lineHeight, result[i].box[2]);
+ }
+ ctx.fillStyle = localOptions2.labelColor;
+ ctx.fillText(label, result[i].box[0] + 2, 0 + result[i].box[1] + localOptions2.lineHeight, result[i].box[2]);
+ }
+ ctx.stroke();
+ }
+ }
+}
+function canvas2(input, output) {
+ if (!input || !output)
+ return;
+ const ctx = getCanvasContext(output);
+ if (!ctx)
+ return;
+ ctx.drawImage(input, 0, 0);
+}
+async function all(inCanvas2, result, drawOptions) {
+ if (!(result == null ? void 0 : result.performance) || !inCanvas2)
+ return null;
+ const timeStamp = now();
+ const localOptions2 = mergeDeep(options2, drawOptions);
+ const promise = Promise.all([
+ face(inCanvas2, result.face, localOptions2),
+ body(inCanvas2, result.body, localOptions2),
+ hand(inCanvas2, result.hand, localOptions2),
+ object(inCanvas2, result.object, localOptions2),
+ gesture(inCanvas2, result.gesture, localOptions2)
+ ]);
+ drawTime = env.perfadd ? drawTime + Math.round(now() - timeStamp) : Math.round(now() - timeStamp);
+ result.performance.draw = drawTime;
+ return promise;
+}
+function init2() {
+ options2.faceLabels = defaultLabels.face;
+ options2.bodyLabels = defaultLabels.body;
+ options2.bodyPartLabels = defaultLabels.bodyPart;
+ options2.handLabels = defaultLabels.hand;
+ options2.fingerLabels = defaultLabels.finger;
+ options2.objectLabels = defaultLabels.object;
+ options2.gestureLabels = defaultLabels.gesture;
+}
+
+// src/body/blazeposecoords.ts
+var blazeposecoords_exports = {};
+__export(blazeposecoords_exports, {
+ connected: () => connected,
+ kpt: () => kpt
+});
+var kpt = [
+ "nose",
+ "leftEyeInside",
+ "leftEye",
+ "leftEyeOutside",
+ "rightEyeInside",
+ "rightEye",
+ "rightEyeOutside",
+ "leftEar",
+ "rightEar",
+ "leftMouth",
+ "rightMouth",
+ "leftShoulder",
+ "rightShoulder",
+ "leftElbow",
+ "rightElbow",
+ "leftWrist",
+ "rightWrist",
+ "leftPinky",
+ "rightPinky",
+ "leftIndex",
+ "rightIndex",
+ "leftThumb",
+ "rightThumb",
+ "leftHip",
+ "rightHip",
+ "leftKnee",
+ "rightKnee",
+ "leftAnkle",
+ "rightAnkle",
+ "leftHeel",
+ "rightHeel",
+ "leftFoot",
+ "rightFoot",
+ "bodyCenter",
+ "bodyTop",
+ "leftPalm",
+ "leftHand",
+ "rightPalm",
+ "rightHand"
+];
+var connected = {
+ shoulders: ["leftShoulder", "rightShoulder"],
+ hips: ["rightHip", "leftHip"],
+ mouth: ["leftMouth", "rightMouth"],
+ leftLegUpper: ["leftHip", "leftKnee"],
+ leftLegLower: ["leftKnee", "leftAnkle"],
+ leftFoot: ["leftAnkle", "leftHeel", "leftFoot"],
+ leftTorso: ["leftShoulder", "leftHip"],
+ leftArmUpper: ["leftShoulder", "leftElbow"],
+ leftArmLower: ["leftElbow", "leftWrist"],
+ leftHand: ["leftWrist", "leftPalm"],
+ leftHandPinky: ["leftPalm", "leftPinky"],
+ leftHandIndex: ["leftPalm", "leftIndex"],
+ leftHandThumb: ["leftPalm", "leftThumb"],
+ leftEyeOutline: ["leftEyeInside", "leftEyeOutside"],
+ rightLegUpper: ["rightHip", "rightKnee"],
+ rightLegLower: ["rightKnee", "rightAnkle"],
+ rightFoot: ["rightAnkle", "rightHeel", "rightFoot"],
+ rightTorso: ["rightShoulder", "rightHip"],
+ rightArmUpper: ["rightShoulder", "rightElbow"],
+ rightArmLower: ["rightElbow", "rightWrist"],
+ rightHand: ["rightWrist", "rightPalm"],
+ rightHandPinky: ["rightPalm", "rightPinky"],
+ rightHandIndex: ["rightPalm", "rightIndex"],
+ rightHandThumb: ["rightPalm", "rightThumb"],
+ rightEyeOutline: ["rightEyeInside", "rightEyeOutside"]
+};
+
+// src/body/blazeposedetector.ts
+var model;
+var inputSize = 224;
+var anchorTensor;
+var numLayers = 5;
+var strides = [8, 16, 32, 32, 32];
+function createAnchors() {
+ const anchors3 = [];
+ let layerId = 0;
+ while (layerId < numLayers) {
+ let anchorCount = 0;
+ let lastSameStrideLayer = layerId;
+ while (lastSameStrideLayer < strides.length && strides[lastSameStrideLayer] === strides[layerId]) {
+ anchorCount += 2;
+ lastSameStrideLayer++;
+ }
+ const stride = strides[layerId];
+ const featureMapHeight = Math.ceil(inputSize / stride);
+ const featureMapWidth = Math.ceil(inputSize / stride);
+ for (let y = 0; y < featureMapHeight; ++y) {
+ for (let x = 0; x < featureMapWidth; ++x) {
+ for (let anchorId = 0; anchorId < anchorCount; ++anchorId) {
+ anchors3.push({ x: (x + 0.5) / featureMapWidth, y: (y + 0.5) / featureMapHeight });
+ }
+ }
+ }
+ layerId = lastSameStrideLayer;
+ }
+ anchorTensor = { x: tfjs_esm_exports.tensor1d(anchors3.map((a) => a.x)), y: tfjs_esm_exports.tensor1d(anchors3.map((a) => a.y)) };
+}
+async function loadDetector(config3) {
+ if (env.initial)
+ model = null;
+ if (!model && config3.body["detector"] && config3.body["detector"].modelPath || "") {
+ model = await loadModel(config3.body["detector"].modelPath);
+ const inputs = (model == null ? void 0 : model["executor"]) ? Object.values(model.modelSignature["inputs"]) : void 0;
+ inputSize = Array.isArray(inputs) ? parseInt(inputs[0].tensorShape.dim[1].size) : 0;
+ } else if (config3.debug && model)
+ log("cached model:", model["modelUrl"]);
+ createAnchors();
+ return model;
+}
+var cropFactor = [5, 5];
+function decodeBoxes(boxesTensor, anchor) {
+ return tfjs_esm_exports.tidy(() => {
+ const split6 = tfjs_esm_exports.split(boxesTensor, 12, 1);
+ let xCenter = tfjs_esm_exports.squeeze(split6[0]);
+ let yCenter = tfjs_esm_exports.squeeze(split6[1]);
+ let width = tfjs_esm_exports.squeeze(split6[2]);
+ let height = tfjs_esm_exports.squeeze(split6[3]);
+ xCenter = tfjs_esm_exports.add(tfjs_esm_exports.div(xCenter, inputSize), anchor.x);
+ yCenter = tfjs_esm_exports.add(tfjs_esm_exports.div(yCenter, inputSize), anchor.y);
+ width = tfjs_esm_exports.mul(tfjs_esm_exports.div(width, inputSize), cropFactor[0]);
+ height = tfjs_esm_exports.mul(tfjs_esm_exports.div(height, inputSize), cropFactor[1]);
+ const xMin = tfjs_esm_exports.sub(xCenter, tfjs_esm_exports.div(width, 2));
+ const yMin = tfjs_esm_exports.sub(yCenter, tfjs_esm_exports.div(height, 2));
+ const xMax = tfjs_esm_exports.add(xMin, width);
+ const yMax = tfjs_esm_exports.add(yMin, height);
+ const boxes = tfjs_esm_exports.stack([xMin, yMin, xMax, yMax], 1);
+ return boxes;
+ });
+}
+async function decodeResults(boxesTensor, logitsTensor, config3, outputSize2) {
+ var _a, _b;
+ const detectedBoxes = [];
+ const t2 = {};
+ t2.boxes = decodeBoxes(boxesTensor, anchorTensor);
+ t2.scores = tfjs_esm_exports.sigmoid(logitsTensor);
+ t2.nms = await tfjs_esm_exports.image.nonMaxSuppressionAsync(t2.boxes, t2.scores, 1, ((_a = config3.body["detector"]) == null ? void 0 : _a.minConfidence) || 0.1, ((_b = config3.body["detector"]) == null ? void 0 : _b.iouThreshold) || 0.1);
+ const nms = await t2.nms.data();
+ const scores = await t2.scores.data();
+ const boxes = await t2.boxes.array();
+ for (const i of Array.from(nms)) {
+ const score = scores[i];
+ const boxRaw = boxes[i];
+ const box = [Math.round(boxRaw[0] * outputSize2[0]), Math.round(boxRaw[1] * outputSize2[1]), Math.round(boxRaw[2] * outputSize2[0]), Math.round(boxRaw[3] * outputSize2[1])];
+ const detectedBox = { score, boxRaw, box };
+ detectedBoxes.push(detectedBox);
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return detectedBoxes;
+}
+async function detectBoxes(input, config3, outputSize2) {
+ const t2 = {};
+ t2.res = model == null ? void 0 : model.execute(input, ["Identity"]);
+ t2.logitsRaw = tfjs_esm_exports.slice(t2.res, [0, 0, 0], [1, -1, 1]);
+ t2.boxesRaw = tfjs_esm_exports.slice(t2.res, [0, 0, 1], [1, -1, -1]);
+ t2.logits = tfjs_esm_exports.squeeze(t2.logitsRaw);
+ t2.boxes = tfjs_esm_exports.squeeze(t2.boxesRaw);
+ const boxes = await decodeResults(t2.boxes, t2.logits, config3, outputSize2);
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return boxes;
+}
+
+// src/util/box.ts
+function calc(keypoints, outputSize2 = [1, 1]) {
+ const coords = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
+ const min2 = [Math.min(...coords[0]), Math.min(...coords[1])];
+ const max5 = [Math.max(...coords[0]), Math.max(...coords[1])];
+ const box = [min2[0], min2[1], max5[0] - min2[0], max5[1] - min2[1]];
+ const boxRaw = [box[0] / outputSize2[0], box[1] / outputSize2[1], box[2] / outputSize2[0], box[3] / outputSize2[1]];
+ return { box, boxRaw };
+}
+function square(keypoints, outputSize2 = [1, 1]) {
+ const coords = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
+ const min2 = [Math.min(...coords[0]), Math.min(...coords[1])];
+ const max5 = [Math.max(...coords[0]), Math.max(...coords[1])];
+ const center = [(min2[0] + max5[0]) / 2, (min2[1] + max5[1]) / 2];
+ const dist = Math.max(center[0] - min2[0], center[1] - min2[1], -center[0] + max5[0], -center[1] + max5[1]);
+ const box = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
+ const boxRaw = [box[0] / outputSize2[0], box[1] / outputSize2[1], box[2] / outputSize2[0], box[3] / outputSize2[1]];
+ return { box, boxRaw };
+}
+function scale(box, scaleFact) {
+ const dist = [box[2] * scaleFact, box[3] * scaleFact];
+ const newBox = [
+ box[0] - (dist[0] - box[2]) / 2,
+ box[1] - (dist[1] - box[3]) / 2,
+ dist[0],
+ dist[1]
+ ];
+ return newBox;
+}
+
+// src/body/blazepose.ts
+var model2;
+var inputSize2 = 256;
+var skipped = Number.MAX_SAFE_INTEGER;
+var outputNodes = {
+ landmarks: ["ld_3d", "activation_segmentation", "activation_heatmap", "world_3d", "output_poseflag"],
+ detector: []
+};
+var cache = [];
+var padding = [[0, 0], [0, 0], [0, 0], [0, 0]];
+var lastTime = 0;
+var sigmoid2 = (x) => 1 - 1 / (1 + Math.exp(x));
+var loadDetect = (config3) => loadDetector(config3);
+async function loadPose(config3) {
+ if (env.initial)
+ model2 = null;
+ if (!model2) {
+ model2 = await loadModel(config3.body.modelPath);
+ const inputs = (model2 == null ? void 0 : model2["executor"]) ? Object.values(model2.modelSignature["inputs"]) : void 0;
+ inputSize2 = Array.isArray(inputs) ? parseInt(inputs[0].tensorShape.dim[1].size) : 0;
+ } else if (config3.debug)
+ log("cached model:", model2["modelUrl"]);
+ return model2;
+}
+function prepareImage(input, size2, cropBox) {
+ var _a, _b;
+ const t2 = {};
+ if (!((_a = input == null ? void 0 : input.shape) == null ? void 0 : _a[1]) || !((_b = input == null ? void 0 : input.shape) == null ? void 0 : _b[2]))
+ return input;
+ let final;
+ if (cropBox) {
+ t2.cropped = tfjs_esm_exports.image.cropAndResize(input, [cropBox], [0], [input.shape[1], input.shape[2]]);
+ }
+ if (input.shape[1] !== input.shape[2]) {
+ const height = [
+ input.shape[2] > input.shape[1] ? Math.trunc((input.shape[2] - input.shape[1]) / 2) : 0,
+ input.shape[2] > input.shape[1] ? Math.trunc((input.shape[2] - input.shape[1]) / 2) : 0
+ ];
+ const width = [
+ input.shape[1] > input.shape[2] ? Math.trunc((input.shape[1] - input.shape[2]) / 2) : 0,
+ input.shape[1] > input.shape[2] ? Math.trunc((input.shape[1] - input.shape[2]) / 2) : 0
+ ];
+ padding = [
+ [0, 0],
+ height,
+ width,
+ [0, 0]
+ ];
+ t2.pad = tfjs_esm_exports.pad(t2.cropped || input, padding);
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(t2.pad, [size2, size2]);
+ final = tfjs_esm_exports.div(t2.resize, constants.tf255);
+ } else if (input.shape[1] !== size2) {
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(t2.cropped || input, [size2, size2]);
+ final = tfjs_esm_exports.div(t2.resize, constants.tf255);
+ } else {
+ final = tfjs_esm_exports.div(t2.cropped || input, constants.tf255);
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return final;
+}
+function rescaleKeypoints(keypoints, outputSize2, cropBox) {
+ for (const kpt4 of keypoints) {
+ kpt4.position = [
+ Math.trunc(kpt4.position[0] * (outputSize2[0] + padding[2][0] + padding[2][1]) / outputSize2[0] - padding[2][0]),
+ Math.trunc(kpt4.position[1] * (outputSize2[1] + padding[1][0] + padding[1][1]) / outputSize2[1] - padding[1][0]),
+ kpt4.position[2]
+ ];
+ kpt4.positionRaw = [kpt4.position[0] / outputSize2[0], kpt4.position[1] / outputSize2[1], 2 * kpt4.position[2] / (outputSize2[0] + outputSize2[1])];
+ }
+ if (cropBox) {
+ const width = cropBox[2] - cropBox[0];
+ const height = cropBox[3] - cropBox[1];
+ for (const kpt4 of keypoints) {
+ kpt4.positionRaw = [
+ kpt4.positionRaw[0] / height + cropBox[1],
+ kpt4.positionRaw[1] / width + cropBox[0],
+ kpt4.positionRaw[2]
+ ];
+ kpt4.position = [
+ Math.trunc(kpt4.positionRaw[0] * outputSize2[0]),
+ Math.trunc(kpt4.positionRaw[1] * outputSize2[1]),
+ kpt4.positionRaw[2]
+ ];
+ }
+ }
+ return keypoints;
+}
+function fixKeypoints(keypoints) {
+ const leftPalm = keypoints.find((k) => k.part === "leftPalm");
+ const leftWrist = keypoints.find((k) => k.part === "leftWrist");
+ const leftIndex = keypoints.find((k) => k.part === "leftIndex");
+ leftPalm.position[2] = ((leftWrist.position[2] || 0) + (leftIndex.position[2] || 0)) / 2;
+ const rightPalm = keypoints.find((k) => k.part === "rightPalm");
+ const rightWrist = keypoints.find((k) => k.part === "rightWrist");
+ const rightIndex = keypoints.find((k) => k.part === "rightIndex");
+ rightPalm.position[2] = ((rightWrist.position[2] || 0) + (rightIndex.position[2] || 0)) / 2;
+}
+async function detectLandmarks(input, config3, outputSize2) {
+ if (!(model2 == null ? void 0 : model2["executor"]))
+ return null;
+ const t2 = {};
+ [t2.ld, t2.segmentation, t2.heatmap, t2.world, t2.poseflag] = model2 == null ? void 0 : model2.execute(input, outputNodes.landmarks);
+ const poseScore = (await t2.poseflag.data())[0];
+ const points = await t2.ld.data();
+ const distances = await t2.world.data();
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ const keypointsRelative = [];
+ const depth = 5;
+ for (let i = 0; i < points.length / depth; i++) {
+ const score = sigmoid2(points[depth * i + 3]);
+ const presence = sigmoid2(points[depth * i + 4]);
+ const adjScore = Math.trunc(100 * score * presence * poseScore) / 100;
+ const positionRaw = [points[depth * i + 0] / inputSize2, points[depth * i + 1] / inputSize2, points[depth * i + 2] + 0];
+ const position = [Math.trunc(outputSize2[0] * positionRaw[0]), Math.trunc(outputSize2[1] * positionRaw[1]), positionRaw[2]];
+ const distance2 = [distances[depth * i + 0], distances[depth * i + 1], distances[depth * i + 2] + 0];
+ keypointsRelative.push({ part: kpt[i], positionRaw, position, distance: distance2, score: adjScore });
+ }
+ if (poseScore < (config3.body.minConfidence || 0))
+ return null;
+ fixKeypoints(keypointsRelative);
+ const keypoints = rescaleKeypoints(keypointsRelative, outputSize2);
+ const kpts = keypoints.map((k) => k.position);
+ const boxes = calc(kpts, [outputSize2[0], outputSize2[1]]);
+ const annotations2 = {};
+ for (const [name, indexes] of Object.entries(connected)) {
+ const pt = [];
+ for (let i = 0; i < indexes.length - 1; i++) {
+ const pt0 = keypoints.find((kpt4) => kpt4.part === indexes[i]);
+ const pt1 = keypoints.find((kpt4) => kpt4.part === indexes[i + 1]);
+ if (pt0 && pt1)
+ pt.push([pt0.position, pt1.position]);
+ }
+ annotations2[name] = pt;
+ }
+ const body4 = { id: 0, score: Math.trunc(100 * poseScore) / 100, box: boxes.box, boxRaw: boxes.boxRaw, keypoints, annotations: annotations2 };
+ return body4;
+}
+async function predict(input, config3) {
+ var _a, _b, _c;
+ const outputSize2 = [input.shape[2] || 0, input.shape[1] || 0];
+ const skipTime = (config3.body.skipTime || 0) > now() - lastTime;
+ const skipFrame = skipped < (config3.body.skipFrames || 0);
+ if (config3.skipAllowed && skipTime && skipFrame && cache !== null) {
+ skipped++;
+ } else {
+ let boxes = [];
+ if ((_b = (_a = config3.body) == null ? void 0 : _a["detector"]) == null ? void 0 : _b["enabled"]) {
+ const preparedImage = prepareImage(input, 224);
+ boxes = await detectBoxes(preparedImage, config3, outputSize2);
+ tfjs_esm_exports.dispose(preparedImage);
+ } else {
+ boxes = [{ box: [0, 0, 0, 0], boxRaw: [0, 0, 1, 1], score: 0 }];
+ }
+ for (let i = 0; i < boxes.length; i++) {
+ const preparedBox = prepareImage(input, 256, (_c = boxes[i]) == null ? void 0 : _c.boxRaw);
+ cache.length = 0;
+ const bodyResult = await detectLandmarks(preparedBox, config3, outputSize2);
+ tfjs_esm_exports.dispose(preparedBox);
+ if (!bodyResult)
+ continue;
+ bodyResult.id = i;
+ cache.push(bodyResult);
+ }
+ lastTime = now();
+ skipped = 0;
+ }
+ return cache;
+}
+
+// src/object/labels.ts
+var labels2 = [
+ { class: 1, label: "person" },
+ { class: 2, label: "bicycle" },
+ { class: 3, label: "car" },
+ { class: 4, label: "motorcycle" },
+ { class: 5, label: "airplane" },
+ { class: 6, label: "bus" },
+ { class: 7, label: "train" },
+ { class: 8, label: "truck" },
+ { class: 9, label: "boat" },
+ { class: 10, label: "traffic light" },
+ { class: 11, label: "fire hydrant" },
+ { class: 12, label: "stop sign" },
+ { class: 13, label: "parking meter" },
+ { class: 14, label: "bench" },
+ { class: 15, label: "bird" },
+ { class: 16, label: "cat" },
+ { class: 17, label: "dog" },
+ { class: 18, label: "horse" },
+ { class: 19, label: "sheep" },
+ { class: 20, label: "cow" },
+ { class: 21, label: "elephant" },
+ { class: 22, label: "bear" },
+ { class: 23, label: "zebra" },
+ { class: 24, label: "giraffe" },
+ { class: 25, label: "backpack" },
+ { class: 26, label: "umbrella" },
+ { class: 27, label: "handbag" },
+ { class: 28, label: "tie" },
+ { class: 29, label: "suitcase" },
+ { class: 30, label: "frisbee" },
+ { class: 31, label: "skis" },
+ { class: 32, label: "snowboard" },
+ { class: 33, label: "sports ball" },
+ { class: 34, label: "kite" },
+ { class: 35, label: "baseball bat" },
+ { class: 36, label: "baseball glove" },
+ { class: 37, label: "skateboard" },
+ { class: 38, label: "surfboard" },
+ { class: 39, label: "tennis racket" },
+ { class: 40, label: "bottle" },
+ { class: 41, label: "wine glass" },
+ { class: 42, label: "cup" },
+ { class: 43, label: "fork" },
+ { class: 44, label: "knife" },
+ { class: 45, label: "spoon" },
+ { class: 46, label: "bowl" },
+ { class: 47, label: "banana" },
+ { class: 48, label: "apple" },
+ { class: 49, label: "sandwich" },
+ { class: 50, label: "orange" },
+ { class: 51, label: "broccoli" },
+ { class: 52, label: "carrot" },
+ { class: 53, label: "hot dog" },
+ { class: 54, label: "pizza" },
+ { class: 55, label: "donut" },
+ { class: 56, label: "cake" },
+ { class: 57, label: "chair" },
+ { class: 58, label: "couch" },
+ { class: 59, label: "potted plant" },
+ { class: 60, label: "bed" },
+ { class: 61, label: "dining table" },
+ { class: 62, label: "toilet" },
+ { class: 63, label: "tv" },
+ { class: 64, label: "laptop" },
+ { class: 65, label: "mouse" },
+ { class: 66, label: "remote" },
+ { class: 67, label: "keyboard" },
+ { class: 68, label: "cell phone" },
+ { class: 69, label: "microwave" },
+ { class: 70, label: "oven" },
+ { class: 71, label: "toaster" },
+ { class: 72, label: "sink" },
+ { class: 73, label: "refrigerator" },
+ { class: 74, label: "book" },
+ { class: 75, label: "clock" },
+ { class: 76, label: "vase" },
+ { class: 77, label: "scissors" },
+ { class: 78, label: "teddy bear" },
+ { class: 79, label: "hair drier" },
+ { class: 80, label: "toothbrush" }
+];
+
+// src/object/centernet.ts
+var model3;
+var inputSize3 = 0;
+var last2 = [];
+var lastTime2 = 0;
+var skipped2 = Number.MAX_SAFE_INTEGER;
+async function load(config3) {
+ if (env.initial)
+ model3 = null;
+ if (!model3) {
+ model3 = await loadModel(config3.object.modelPath);
+ const inputs = (model3 == null ? void 0 : model3["executor"]) ? Object.values(model3.modelSignature["inputs"]) : void 0;
+ inputSize3 = Array.isArray(inputs) ? parseInt(inputs[0].tensorShape.dim[2].size) : 0;
+ } else if (config3.debug)
+ log("cached model:", model3["modelUrl"]);
+ return model3;
+}
+async function process3(res, outputShape, config3) {
+ if (!res)
+ return [];
+ const t2 = {};
+ const results = [];
+ const detections = await res.array();
+ t2.squeeze = tfjs_esm_exports.squeeze(res);
+ const arr = tfjs_esm_exports.split(t2.squeeze, 6, 1);
+ t2.stack = tfjs_esm_exports.stack([arr[1], arr[0], arr[3], arr[2]], 1);
+ t2.boxes = tfjs_esm_exports.squeeze(t2.stack);
+ t2.scores = tfjs_esm_exports.squeeze(arr[4]);
+ t2.classes = tfjs_esm_exports.squeeze(arr[5]);
+ tfjs_esm_exports.dispose([res, ...arr]);
+ t2.nms = await tfjs_esm_exports.image.nonMaxSuppressionAsync(t2.boxes, t2.scores, config3.object.maxDetected || 0, config3.object.iouThreshold, config3.object.minConfidence || 0);
+ const nms = await t2.nms.data();
+ let i = 0;
+ for (const id of Array.from(nms)) {
+ const score = Math.trunc(100 * detections[0][id][4]) / 100;
+ const classVal = detections[0][id][5];
+ if (Number.isNaN(classVal))
+ continue;
+ const label = labels2[classVal].label;
+ const [x, y] = [
+ detections[0][id][0] / inputSize3,
+ detections[0][id][1] / inputSize3
+ ];
+ const boxRaw = [
+ x,
+ y,
+ detections[0][id][2] / inputSize3 - x,
+ detections[0][id][3] / inputSize3 - y
+ ];
+ const box = [
+ Math.trunc(boxRaw[0] * outputShape[0]),
+ Math.trunc(boxRaw[1] * outputShape[1]),
+ Math.trunc(boxRaw[2] * outputShape[0]),
+ Math.trunc(boxRaw[3] * outputShape[1])
+ ];
+ results.push({ id: i++, score, class: classVal, label, box, boxRaw });
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return results;
+}
+async function predict2(input, config3) {
+ if (!(model3 == null ? void 0 : model3["executor"]))
+ return [];
+ const skipTime = (config3.object.skipTime || 0) > now() - lastTime2;
+ const skipFrame = skipped2 < (config3.object.skipFrames || 0);
+ if (config3.skipAllowed && skipTime && skipFrame && last2.length > 0) {
+ skipped2++;
+ return last2;
+ }
+ skipped2 = 0;
+ return new Promise(async (resolve) => {
+ const outputSize2 = [input.shape[2] || 0, input.shape[1] || 0];
+ const resize = tfjs_esm_exports.image.resizeBilinear(input, [inputSize3, inputSize3]);
+ const objectT = config3.object.enabled ? model3 == null ? void 0 : model3.execute(resize, ["tower_0/detections"]) : null;
+ lastTime2 = now();
+ tfjs_esm_exports.dispose(resize);
+ const obj = await process3(objectT, outputSize2, config3);
+ last2 = obj;
+ resolve(obj);
+ });
+}
+
+// src/body/efficientposecoords.ts
+var efficientposecoords_exports = {};
+__export(efficientposecoords_exports, {
+ connected: () => connected2,
+ kpt: () => kpt2
+});
+var kpt2 = [
+ "head",
+ "neck",
+ "rightShoulder",
+ "rightElbow",
+ "rightWrist",
+ "chest",
+ "leftShoulder",
+ "leftElbow",
+ "leftWrist",
+ "bodyCenter",
+ "rightHip",
+ "rightKnee",
+ "rightAnkle",
+ "leftHip",
+ "leftKnee",
+ "leftAnkle"
+];
+var connected2 = {
+ leftLeg: ["leftHip", "leftKnee", "leftAnkle"],
+ rightLeg: ["rightHip", "rightKnee", "rightAnkle"],
+ torso: ["leftShoulder", "rightShoulder", "rightHip", "leftHip", "leftShoulder"],
+ leftArm: ["leftShoulder", "leftElbow", "leftWrist"],
+ rightArm: ["rightShoulder", "rightElbow", "rightWrist"],
+ head: []
+};
+
+// src/body/efficientpose.ts
+var model4;
+var lastTime3 = 0;
+var cache2 = { id: 0, keypoints: [], box: [0, 0, 0, 0], boxRaw: [0, 0, 0, 0], score: 0, annotations: {} };
+var skipped3 = Number.MAX_SAFE_INTEGER;
+async function load2(config3) {
+ if (env.initial)
+ model4 = null;
+ if (!model4)
+ model4 = await loadModel(config3.body.modelPath);
+ else if (config3.debug)
+ log("cached model:", model4["modelUrl"]);
+ return model4;
+}
+async function max2d(inputs, minScore) {
+ const [width, height] = inputs.shape;
+ const reshaped = tfjs_esm_exports.reshape(inputs, [height * width]);
+ const max5 = tfjs_esm_exports.max(reshaped, 0);
+ const newScore = (await max5.data())[0];
+ if (newScore > minScore) {
+ const coordinates = tfjs_esm_exports.argMax(reshaped, 0);
+ const mod3 = tfjs_esm_exports.mod(coordinates, width);
+ const x = (await mod3.data())[0];
+ const div15 = tfjs_esm_exports.div(coordinates, width);
+ const y = (await div15.data())[0];
+ tfjs_esm_exports.dispose([reshaped, max5, coordinates, mod3, div15]);
+ return [x, y, newScore];
+ }
+ tfjs_esm_exports.dispose([reshaped, max5]);
+ return [0, 0, newScore];
+}
+async function predict3(image28, config3) {
+ if (!(model4 == null ? void 0 : model4["executor"]) || !(model4 == null ? void 0 : model4.inputs[0].shape))
+ return [];
+ const skipTime = (config3.body.skipTime || 0) > now() - lastTime3;
+ const skipFrame = skipped3 < (config3.body.skipFrames || 0);
+ if (config3.skipAllowed && skipTime && skipFrame && Object.keys(cache2.keypoints).length > 0) {
+ skipped3++;
+ return [cache2];
+ }
+ skipped3 = 0;
+ return new Promise(async (resolve) => {
+ const tensor6 = tfjs_esm_exports.tidy(() => {
+ var _a, _b;
+ const resize = tfjs_esm_exports.image.resizeBilinear(image28, [((_a = model4 == null ? void 0 : model4.inputs[0].shape) == null ? void 0 : _a[2]) || 0, ((_b = model4 == null ? void 0 : model4.inputs[0].shape) == null ? void 0 : _b[1]) || 0], false);
+ const enhance2 = tfjs_esm_exports.mul(resize, constants.tf2);
+ const norm = tfjs_esm_exports.sub(enhance2, constants.tf1);
+ return norm;
+ });
+ let resT;
+ if (config3.body.enabled)
+ resT = model4 == null ? void 0 : model4.execute(tensor6);
+ lastTime3 = now();
+ tfjs_esm_exports.dispose(tensor6);
+ if (resT) {
+ cache2.keypoints.length = 0;
+ const squeeze14 = tfjs_esm_exports.squeeze(resT);
+ tfjs_esm_exports.dispose(resT);
+ const stack5 = tfjs_esm_exports.unstack(squeeze14, 2);
+ tfjs_esm_exports.dispose(squeeze14);
+ for (let id = 0; id < stack5.length; id++) {
+ const [x2, y2, partScore] = await max2d(stack5[id], config3.body.minConfidence);
+ if (partScore > (config3.body.minConfidence || 0)) {
+ cache2.keypoints.push({
+ score: Math.round(100 * partScore) / 100,
+ part: kpt2[id],
+ positionRaw: [
+ x2 / model4.inputs[0].shape[2],
+ y2 / model4.inputs[0].shape[1]
+ ],
+ position: [
+ Math.round(image28.shape[2] * x2 / model4.inputs[0].shape[2]),
+ Math.round(image28.shape[1] * y2 / model4.inputs[0].shape[1])
+ ]
+ });
+ }
+ }
+ stack5.forEach((s) => tfjs_esm_exports.dispose(s));
+ }
+ cache2.score = cache2.keypoints.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
+ const x = cache2.keypoints.map((a) => a.position[0]);
+ const y = cache2.keypoints.map((a) => a.position[1]);
+ cache2.box = [
+ Math.min(...x),
+ Math.min(...y),
+ Math.max(...x) - Math.min(...x),
+ Math.max(...y) - Math.min(...y)
+ ];
+ const xRaw = cache2.keypoints.map((a) => a.positionRaw[0]);
+ const yRaw = cache2.keypoints.map((a) => a.positionRaw[1]);
+ cache2.boxRaw = [
+ Math.min(...xRaw),
+ Math.min(...yRaw),
+ Math.max(...xRaw) - Math.min(...xRaw),
+ Math.max(...yRaw) - Math.min(...yRaw)
+ ];
+ for (const [name, indexes] of Object.entries(connected2)) {
+ const pt = [];
+ for (let i = 0; i < indexes.length - 1; i++) {
+ const pt0 = cache2.keypoints.find((kpt4) => kpt4.part === indexes[i]);
+ const pt1 = cache2.keypoints.find((kpt4) => kpt4.part === indexes[i + 1]);
+ if (pt0 && pt1 && pt0.score > (config3.body.minConfidence || 0) && pt1.score > (config3.body.minConfidence || 0))
+ pt.push([pt0.position, pt1.position]);
+ }
+ cache2.annotations[name] = pt;
+ }
+ resolve([cache2]);
+ });
+}
+
+// src/face/facemeshutil.ts
+var getBoxSize = (box) => [Math.abs(box.endPoint[0] - box.startPoint[0]), Math.abs(box.endPoint[1] - box.startPoint[1])];
+var getBoxCenter = (box) => [box.startPoint[0] + (box.endPoint[0] - box.startPoint[0]) / 2, box.startPoint[1] + (box.endPoint[1] - box.startPoint[1]) / 2, 1];
+var clampBox = (box, input) => box ? [
+ Math.trunc(Math.max(0, box.startPoint[0])),
+ Math.trunc(Math.max(0, box.startPoint[1])),
+ Math.trunc(Math.min(input.shape[2] || 0, box.endPoint[0]) - Math.max(0, box.startPoint[0])),
+ Math.trunc(Math.min(input.shape[1] || 0, box.endPoint[1]) - Math.max(0, box.startPoint[1]))
+] : [0, 0, 0, 0];
+var getRawBox = (box, input) => box ? [
+ box.startPoint[0] / (input.shape[2] || 0),
+ box.startPoint[1] / (input.shape[1] || 0),
+ (box.endPoint[0] - box.startPoint[0]) / (input.shape[2] || 0),
+ (box.endPoint[1] - box.startPoint[1]) / (input.shape[1] || 0)
+] : [0, 0, 0, 0];
+var scaleBoxCoordinates = (box, factor) => {
+ const startPoint = [box.startPoint[0] * factor[0], box.startPoint[1] * factor[1]];
+ const endPoint = [box.endPoint[0] * factor[0], box.endPoint[1] * factor[1]];
+ return { startPoint, endPoint, landmarks: box.landmarks, confidence: box.confidence };
+};
+var cutAndResize = (box, image28, cropSize) => {
+ const h = image28.shape[1];
+ const w = image28.shape[2];
+ const cutBox = [box.startPoint[1] / h, box.startPoint[0] / w, box.endPoint[1] / h, box.endPoint[0] / w];
+ const crop = tfjs_esm_exports.image.cropAndResize(image28, [cutBox], [0], cropSize);
+ const norm = tfjs_esm_exports.div(crop, constants.tf255);
+ tfjs_esm_exports.dispose(crop);
+ return norm;
+};
+var enlargeBox = (box, factor) => {
+ const center = getBoxCenter(box);
+ const size2 = getBoxSize(box);
+ const halfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
+ return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box.landmarks, confidence: box.confidence };
+};
+var squarifyBox = (box) => {
+ const centers = getBoxCenter(box);
+ const size2 = getBoxSize(box);
+ const halfSize = Math.max(...size2) / 2;
+ return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box.landmarks, confidence: box.confidence };
+};
+var calculateLandmarksBoundingBox = (landmarks) => {
+ const x = landmarks.map((d) => d[0]);
+ const y = landmarks.map((d) => d[1]);
+ return { startPoint: [Math.min(...x), Math.min(...y)], endPoint: [Math.max(...x), Math.max(...y)], landmarks };
+};
+var fixedRotationMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
+var normalizeRadians = (angle) => angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
+var computeRotation = (point1, point2) => normalizeRadians(Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]));
+var buildTranslationMatrix = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
+var dot = (v1, v2) => {
+ let product = 0;
+ for (let i = 0; i < v1.length; i++)
+ product += v1[i] * v2[i];
+ return product;
+};
+var getColumnFrom2DArr = (arr, columnIndex) => {
+ const column = [];
+ for (let i = 0; i < arr.length; i++)
+ column.push(arr[i][columnIndex]);
+ return column;
+};
+var multiplyTransformMatrices = (mat1, mat2) => {
+ const product = [];
+ const size2 = mat1.length;
+ for (let row = 0; row < size2; row++) {
+ product.push([]);
+ for (let col = 0; col < size2; col++)
+ product[row].push(dot(mat1[row], getColumnFrom2DArr(mat2, col)));
+ }
+ return product;
+};
+var buildRotationMatrix = (rotation, center) => {
+ const cosA = Math.cos(rotation);
+ const sinA = Math.sin(rotation);
+ const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
+ const translationMatrix = buildTranslationMatrix(center[0], center[1]);
+ const translationTimesRotation = multiplyTransformMatrices(translationMatrix, rotationMatrix);
+ const negativeTranslationMatrix = buildTranslationMatrix(-center[0], -center[1]);
+ return multiplyTransformMatrices(translationTimesRotation, negativeTranslationMatrix);
+};
+var invertTransformMatrix = (matrix) => {
+ const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
+ const translationComponent = [matrix[0][2], matrix[1][2]];
+ const invertedTranslation = [-dot(rotationComponent[0], translationComponent), -dot(rotationComponent[1], translationComponent)];
+ return [rotationComponent[0].concat(invertedTranslation[0]), rotationComponent[1].concat(invertedTranslation[1]), [0, 0, 1]];
+};
+var rotatePoint = (homogeneousCoordinate, rotationMatrix) => [dot(homogeneousCoordinate, rotationMatrix[0]), dot(homogeneousCoordinate, rotationMatrix[1])];
+function generateAnchors(inputSize10) {
+ const spec = inputSize10 === 192 ? { strides: [4], anchors: [1] } : { strides: [inputSize10 / 16, inputSize10 / 8], anchors: [2, 6] };
+ const anchors3 = [];
+ for (let i = 0; i < spec.strides.length; i++) {
+ const stride = spec.strides[i];
+ const gridRows = Math.floor((inputSize10 + stride - 1) / stride);
+ const gridCols = Math.floor((inputSize10 + stride - 1) / stride);
+ const anchorsNum = spec.anchors[i];
+ for (let gridY = 0; gridY < gridRows; gridY++) {
+ const anchorY = stride * (gridY + 0.5);
+ for (let gridX = 0; gridX < gridCols; gridX++) {
+ const anchorX = stride * (gridX + 0.5);
+ for (let n = 0; n < anchorsNum; n++)
+ anchors3.push([anchorX, anchorY]);
+ }
+ }
+ }
+ return anchors3;
+}
+function transformRawCoords(coordsRaw, box, angle, rotationMatrix, inputSize10) {
+ const boxSize = getBoxSize(box);
+ const coordsScaled = coordsRaw.map((coord) => [
+ boxSize[0] / inputSize10 * (coord[0] - inputSize10 / 2),
+ boxSize[1] / inputSize10 * (coord[1] - inputSize10 / 2),
+ coord[2] || 0
+ ]);
+ const largeAngle = angle && angle !== 0 && Math.abs(angle) > 0.2;
+ const coordsRotationMatrix = largeAngle ? buildRotationMatrix(angle, [0, 0]) : fixedRotationMatrix;
+ const coordsRotated = largeAngle ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
+ const inverseRotationMatrix = largeAngle ? invertTransformMatrix(rotationMatrix) : fixedRotationMatrix;
+ const boxCenter = getBoxCenter(box);
+ const offsets = [dot(boxCenter, inverseRotationMatrix[0]), dot(boxCenter, inverseRotationMatrix[1])];
+ return coordsRotated.map((coord) => [
+ Math.trunc(coord[0] + offsets[0]),
+ Math.trunc(coord[1] + offsets[1]),
+ Math.trunc(coord[2] || 0)
+ ]);
+}
+function correctFaceRotation(rotate, box, input, inputSize10) {
+ const symmetryLine = box.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
+ let angle = 0;
+ let rotationMatrix = fixedRotationMatrix;
+ let face4;
+ if (rotate && env.kernels.includes("rotatewithoffset")) {
+ angle = computeRotation(box.landmarks[symmetryLine[0]], box.landmarks[symmetryLine[1]]);
+ const largeAngle = angle && angle !== 0 && Math.abs(angle) > 0.2;
+ if (largeAngle) {
+ const center = getBoxCenter(box);
+ const centerRaw = [center[0] / input.shape[2], center[1] / input.shape[1]];
+ const rotated = tfjs_esm_exports.image.rotateWithOffset(input, angle, 0, [centerRaw[0], centerRaw[1]]);
+ rotationMatrix = buildRotationMatrix(-angle, center);
+ face4 = cutAndResize(box, rotated, [inputSize10, inputSize10]);
+ tfjs_esm_exports.dispose(rotated);
+ } else {
+ face4 = cutAndResize(box, input, [inputSize10, inputSize10]);
+ }
+ } else {
+ face4 = cutAndResize(box, input, [inputSize10, inputSize10]);
+ }
+ return [angle, rotationMatrix, face4];
+}
+var findFaceCenter = (mesh) => {
+ const x = mesh.map((m) => m[0]);
+ const y = mesh.map((m) => m[1]);
+ return [Math.min(...x) + (Math.max(...x) - Math.min(...x)) / 2, Math.min(...y) + (Math.max(...y) - Math.min(...y)) / 2];
+};
+var calculateFaceBox = (mesh, previousBox) => {
+ const center = findFaceCenter(mesh);
+ const boxSize = getBoxSize(previousBox);
+ const calculatedBox = {
+ startPoint: [center[0] - boxSize[0] / 2, center[1] - boxSize[1] / 2],
+ endPoint: [center[0] + boxSize[0] / 2, center[1] + boxSize[1] / 2]
+ };
+ return calculatedBox;
+};
+
+// src/face/blazeface.ts
+var keypointsCount = 6;
+var faceBoxScaleFactor = 1.4;
+var model5;
+var anchors = null;
+var inputSize4 = 0;
+var inputSizeT = null;
+var size = () => inputSize4;
+async function load3(config3) {
+ var _a;
+ if (env.initial)
+ model5 = null;
+ if (!model5)
+ model5 = await loadModel((_a = config3.face.detector) == null ? void 0 : _a.modelPath);
+ else if (config3.debug)
+ log("cached model:", model5["modelUrl"]);
+ inputSize4 = model5["executor"] && model5.inputs[0].shape ? model5.inputs[0].shape[2] : 256;
+ inputSizeT = tfjs_esm_exports.scalar(inputSize4, "int32");
+ anchors = tfjs_esm_exports.tensor2d(generateAnchors(inputSize4));
+ return model5;
+}
+function decodeBoxes2(boxOutputs) {
+ if (!anchors || !inputSizeT)
+ return tfjs_esm_exports.zeros([0, 0]);
+ const t2 = {};
+ t2.boxStarts = tfjs_esm_exports.slice(boxOutputs, [0, 1], [-1, 2]);
+ t2.centers = tfjs_esm_exports.add(t2.boxStarts, anchors);
+ t2.boxSizes = tfjs_esm_exports.slice(boxOutputs, [0, 3], [-1, 2]);
+ t2.boxSizesNormalized = tfjs_esm_exports.div(t2.boxSizes, inputSizeT);
+ t2.centersNormalized = tfjs_esm_exports.div(t2.centers, inputSizeT);
+ t2.halfBoxSize = tfjs_esm_exports.div(t2.boxSizesNormalized, constants.tf2);
+ t2.starts = tfjs_esm_exports.sub(t2.centersNormalized, t2.halfBoxSize);
+ t2.ends = tfjs_esm_exports.add(t2.centersNormalized, t2.halfBoxSize);
+ t2.startNormalized = tfjs_esm_exports.mul(t2.starts, inputSizeT);
+ t2.endNormalized = tfjs_esm_exports.mul(t2.ends, inputSizeT);
+ const boxes = tfjs_esm_exports.concat2d([t2.startNormalized, t2.endNormalized], 1);
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return boxes;
+}
+async function getBoxes(inputImage, config3) {
+ var _a, _b, _c, _d;
+ if (!inputImage || inputImage["isDisposedInternal"] || inputImage.shape.length !== 4 || inputImage.shape[1] < 1 || inputImage.shape[2] < 1)
+ return [];
+ const t2 = {};
+ t2.resized = tfjs_esm_exports.image.resizeBilinear(inputImage, [inputSize4, inputSize4]);
+ t2.div = tfjs_esm_exports.div(t2.resized, constants.tf127);
+ t2.normalized = tfjs_esm_exports.sub(t2.div, constants.tf05);
+ const res = model5 == null ? void 0 : model5.execute(t2.normalized);
+ if (Array.isArray(res) && res.length > 2) {
+ const sorted = res.sort((a, b) => a.size - b.size);
+ t2.concat384 = tfjs_esm_exports.concat([sorted[0], sorted[2]], 2);
+ t2.concat512 = tfjs_esm_exports.concat([sorted[1], sorted[3]], 2);
+ t2.concat = tfjs_esm_exports.concat([t2.concat512, t2.concat384], 1);
+ t2.batch = tfjs_esm_exports.squeeze(t2.concat, [0]);
+ } else if (Array.isArray(res)) {
+ t2.batch = tfjs_esm_exports.squeeze(res[0]);
+ } else {
+ t2.batch = tfjs_esm_exports.squeeze(res);
+ }
+ tfjs_esm_exports.dispose(res);
+ t2.boxes = decodeBoxes2(t2.batch);
+ t2.logits = tfjs_esm_exports.slice(t2.batch, [0, 0], [-1, 1]);
+ t2.sigmoid = tfjs_esm_exports.sigmoid(t2.logits);
+ t2.scores = tfjs_esm_exports.squeeze(t2.sigmoid);
+ t2.nms = await tfjs_esm_exports.image.nonMaxSuppressionAsync(t2.boxes, t2.scores, ((_a = config3.face.detector) == null ? void 0 : _a.maxDetected) || 0, ((_b = config3.face.detector) == null ? void 0 : _b.iouThreshold) || 0, ((_c = config3.face.detector) == null ? void 0 : _c.minConfidence) || 0);
+ const nms = await t2.nms.array();
+ const boxes = [];
+ const scores = await t2.scores.data();
+ for (let i = 0; i < nms.length; i++) {
+ const confidence = scores[nms[i]];
+ if (confidence > (((_d = config3.face.detector) == null ? void 0 : _d.minConfidence) || 0)) {
+ const b = {};
+ b.bbox = tfjs_esm_exports.slice(t2.boxes, [nms[i], 0], [1, -1]);
+ b.slice = tfjs_esm_exports.slice(t2.batch, [nms[i], keypointsCount - 1], [1, -1]);
+ b.squeeze = tfjs_esm_exports.squeeze(b.slice);
+ b.landmarks = tfjs_esm_exports.reshape(b.squeeze, [keypointsCount, -1]);
+ const points = await b.bbox.data();
+ const rawBox = {
+ startPoint: [points[0], points[1]],
+ endPoint: [points[2], points[3]],
+ landmarks: await b.landmarks.array(),
+ confidence
+ };
+ const scaledBox = scaleBoxCoordinates(rawBox, [(inputImage.shape[2] || 0) / inputSize4, (inputImage.shape[1] || 0) / inputSize4]);
+ const enlargedBox = enlargeBox(scaledBox, config3.face["scale"] || faceBoxScaleFactor);
+ const squaredBox = squarifyBox(enlargedBox);
+ boxes.push(squaredBox);
+ Object.keys(b).forEach((tensor6) => tfjs_esm_exports.dispose(b[tensor6]));
+ }
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return boxes;
+}
+
+// src/face/iris.ts
+var model6;
+var inputSize5 = 0;
+var irisEnlarge = 2.3;
+var leftOutline = meshAnnotations.leftEyeLower0;
+var rightOutline = meshAnnotations.rightEyeLower0;
+var eyeLandmarks = {
+ leftBounds: [leftOutline[0], leftOutline[leftOutline.length - 1]],
+ rightBounds: [rightOutline[0], rightOutline[rightOutline.length - 1]]
+};
+var irisLandmarks = {
+ upperCenter: 3,
+ lowerCenter: 4,
+ index: 71,
+ numCoordinates: 76
+};
+async function load4(config3) {
+ var _a, _b;
+ if (env.initial)
+ model6 = null;
+ if (!model6)
+ model6 = await loadModel((_a = config3.face.iris) == null ? void 0 : _a.modelPath);
+ else if (config3.debug)
+ log("cached model:", model6["modelUrl"]);
+ inputSize5 = (model6 == null ? void 0 : model6["executor"]) && ((_b = model6.inputs) == null ? void 0 : _b[0].shape) ? model6.inputs[0].shape[2] : 0;
+ if (inputSize5 === -1)
+ inputSize5 = 64;
+ return model6;
+}
+function replaceIrisCoords(rawCoords, newCoords, prefix, keys) {
+ for (let i = 0; i < irisIndices.length; i++) {
+ const { key, indices } = irisIndices[i];
+ const originalIndices = meshAnnotations[`${prefix}${key}`];
+ if (!keys || keys.includes(key)) {
+ for (let j = 0; j < indices.length; j++) {
+ const index2 = indices[j];
+ rawCoords[originalIndices[j]] = [
+ newCoords[index2][0],
+ newCoords[index2][1],
+ (newCoords[index2][2] + rawCoords[originalIndices[j]][2]) / 2
+ ];
+ }
+ }
+ }
+}
+var getLeftToRightEyeDepthDifference = (rawCoords) => {
+ const leftEyeZ = rawCoords[eyeLandmarks.leftBounds[0]][2];
+ const rightEyeZ = rawCoords[eyeLandmarks.rightBounds[0]][2];
+ return leftEyeZ - rightEyeZ;
+};
+var getEyeBox = (rawCoords, face4, eyeInnerCornerIndex, eyeOuterCornerIndex, meshSize, flip = false) => {
+ const box = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
+ const boxSize = getBoxSize(box);
+ let crop = tfjs_esm_exports.image.cropAndResize(face4, [[
+ box.startPoint[1] / meshSize,
+ box.startPoint[0] / meshSize,
+ box.endPoint[1] / meshSize,
+ box.endPoint[0] / meshSize
+ ]], [0], [inputSize5, inputSize5]);
+ if (flip && env.kernels.includes("flipleftright")) {
+ const flipped = tfjs_esm_exports.image.flipLeftRight(crop);
+ tfjs_esm_exports.dispose(crop);
+ crop = flipped;
+ }
+ return { box, boxSize, crop };
+};
+var getEyeCoords = (eyeData, eyeBox, eyeBoxSize, flip = false) => {
+ const eyeRawCoords = [];
+ for (let i = 0; i < irisLandmarks.numCoordinates; i++) {
+ const x = eyeData[i * 3];
+ const y = eyeData[i * 3 + 1];
+ const z = eyeData[i * 3 + 2];
+ eyeRawCoords.push([
+ (flip ? 1 - x / inputSize5 : x / inputSize5) * eyeBoxSize[0] + eyeBox.startPoint[0],
+ y / inputSize5 * eyeBoxSize[1] + eyeBox.startPoint[1],
+ z
+ ]);
+ }
+ return { rawCoords: eyeRawCoords, iris: eyeRawCoords.slice(irisLandmarks.index) };
+};
+var getAdjustedIrisCoords = (rawCoords, irisCoords, direction) => {
+ const upperCenterZ = rawCoords[meshAnnotations[`${direction}EyeUpper0`][irisLandmarks.upperCenter]][2];
+ const lowerCenterZ = rawCoords[meshAnnotations[`${direction}EyeLower0`][irisLandmarks.lowerCenter]][2];
+ const averageZ = (upperCenterZ + lowerCenterZ) / 2;
+ return irisCoords.map((coord, i) => {
+ let z = averageZ;
+ if (i === 2) {
+ z = upperCenterZ;
+ } else if (i === 4) {
+ z = lowerCenterZ;
+ }
+ return [coord[0], coord[1], z];
+ });
+};
+async function augmentIris(rawCoords, face4, meshSize) {
+ if (!(model6 == null ? void 0 : model6["executor"]))
+ return rawCoords;
+ const { box: leftEyeBox, boxSize: leftEyeBoxSize, crop: leftEyeCrop } = getEyeBox(rawCoords, face4, eyeLandmarks.leftBounds[0], eyeLandmarks.leftBounds[1], meshSize, true);
+ const { box: rightEyeBox, boxSize: rightEyeBoxSize, crop: rightEyeCrop } = getEyeBox(rawCoords, face4, eyeLandmarks.rightBounds[0], eyeLandmarks.rightBounds[1], meshSize, true);
+ const combined = tfjs_esm_exports.concat([leftEyeCrop, rightEyeCrop]);
+ tfjs_esm_exports.dispose(leftEyeCrop);
+ tfjs_esm_exports.dispose(rightEyeCrop);
+ const eyePredictions = model6.execute(combined);
+ tfjs_esm_exports.dispose(combined);
+ const eyePredictionsData = await eyePredictions.data();
+ tfjs_esm_exports.dispose(eyePredictions);
+ const leftEyeData = eyePredictionsData.slice(0, irisLandmarks.numCoordinates * 3);
+ const { rawCoords: leftEyeRawCoords, iris: leftIrisRawCoords } = getEyeCoords(leftEyeData, leftEyeBox, leftEyeBoxSize, true);
+ const rightEyeData = eyePredictionsData.slice(irisLandmarks.numCoordinates * 3);
+ const { rawCoords: rightEyeRawCoords, iris: rightIrisRawCoords } = getEyeCoords(rightEyeData, rightEyeBox, rightEyeBoxSize, false);
+ const leftToRightEyeDepthDifference = getLeftToRightEyeDepthDifference(rawCoords);
+ if (Math.abs(leftToRightEyeDepthDifference) < 30) {
+ replaceIrisCoords(rawCoords, leftEyeRawCoords, "left", null);
+ replaceIrisCoords(rawCoords, rightEyeRawCoords, "right", null);
+ } else if (leftToRightEyeDepthDifference < 1) {
+ replaceIrisCoords(rawCoords, leftEyeRawCoords, "left", ["EyeUpper0", "EyeLower0"]);
+ } else {
+ replaceIrisCoords(rawCoords, rightEyeRawCoords, "right", ["EyeUpper0", "EyeLower0"]);
+ }
+ const adjustedLeftIrisCoords = getAdjustedIrisCoords(rawCoords, leftIrisRawCoords, "left");
+ const adjustedRightIrisCoords = getAdjustedIrisCoords(rawCoords, rightIrisRawCoords, "right");
+ const newCoords = rawCoords.concat(adjustedLeftIrisCoords).concat(adjustedRightIrisCoords);
+ return newCoords;
+}
+
+// src/face/attention.ts
+async function augment(rawCoords, results) {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
+ const t2 = {
+ lips: await ((_b = (_a = results.filter((r) => r.size === 160)) == null ? void 0 : _a[0]) == null ? void 0 : _b.data()),
+ irisL: await ((_d = (_c = results.filter((r) => r.size === 10)) == null ? void 0 : _c[0]) == null ? void 0 : _d.data()),
+ eyeL: await ((_f = (_e = results.filter((r) => r.size === 142)) == null ? void 0 : _e[0]) == null ? void 0 : _f.data()),
+ irisR: await ((_h = (_g = results.filter((r) => r.size === 10)) == null ? void 0 : _g[1]) == null ? void 0 : _h.data()),
+ eyeR: await ((_j = (_i = results.filter((r) => r.size === 142)) == null ? void 0 : _i[1]) == null ? void 0 : _j.data())
+ };
+ for (const val of Object.values(t2)) {
+ if (!val)
+ return rawCoords;
+ }
+ const irisLDepth = LANDMARKS_REFINEMENT_LEFT_EYE_CONFIG.reduce((prev, curr) => prev += rawCoords[curr][2], 0) / LANDMARKS_REFINEMENT_LEFT_EYE_CONFIG.length;
+ for (let i = 0; i < t2.irisL.length / 2; i++)
+ rawCoords.push([t2.irisL[2 * i + 0], t2.irisL[2 * i + 1], irisLDepth]);
+ const irisRDepth = LANDMARKS_REFINEMENT_RIGHT_EYE_CONFIG.reduce((prev, curr) => prev += rawCoords[curr][2], 0) / LANDMARKS_REFINEMENT_RIGHT_EYE_CONFIG.length;
+ for (let i = 0; i < t2.irisR.length / 2; i++)
+ rawCoords.push([t2.irisR[2 * i + 0], t2.irisR[2 * i + 1], irisRDepth]);
+ for (let i = 0; i < t2.eyeL.length / 2; i++)
+ rawCoords[LANDMARKS_REFINEMENT_LEFT_EYE_CONFIG[i]] = [t2.eyeL[2 * i + 0], t2.eyeL[2 * i + 1], rawCoords[LANDMARKS_REFINEMENT_LEFT_EYE_CONFIG[i]][2]];
+ for (let i = 0; i < t2.eyeR.length / 2; i++)
+ rawCoords[LANDMARKS_REFINEMENT_RIGHT_EYE_CONFIG[i]] = [t2.eyeR[2 * i + 0], t2.eyeR[2 * i + 1], rawCoords[LANDMARKS_REFINEMENT_RIGHT_EYE_CONFIG[i]][2]];
+ for (let i = 0; i < t2.lips.length / 2; i++)
+ rawCoords[LANDMARKS_REFINEMENT_LIPS_CONFIG[i]] = [t2.lips[2 * i + 0], t2.lips[2 * i + 1], rawCoords[LANDMARKS_REFINEMENT_LIPS_CONFIG[i]][2]];
+ return rawCoords;
+}
+
+// src/face/facemesh.ts
+var cache3 = {
+ boxes: [],
+ skipped: Number.MAX_SAFE_INTEGER,
+ timestamp: 0
+};
+var model7 = null;
+var inputSize6 = 0;
+async function predict4(input, config3) {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
+ if (!(model7 == null ? void 0 : model7["executor"]))
+ return [];
+ const skipTime = (((_a = config3.face.detector) == null ? void 0 : _a.skipTime) || 0) > now() - cache3.timestamp;
+ const skipFrame = cache3.skipped < (((_b = config3.face.detector) == null ? void 0 : _b.skipFrames) || 0);
+ if (!config3.skipAllowed || !skipTime || !skipFrame || cache3.boxes.length === 0) {
+ cache3.boxes = await getBoxes(input, config3);
+ cache3.timestamp = now();
+ cache3.skipped = 0;
+ } else {
+ cache3.skipped++;
+ }
+ const faces = [];
+ const newCache = [];
+ let id = 0;
+ const size2 = inputSize6;
+ for (let i = 0; i < cache3.boxes.length; i++) {
+ const box = cache3.boxes[i];
+ let angle = 0;
+ let rotationMatrix;
+ const face4 = {
+ id: id++,
+ mesh: [],
+ meshRaw: [],
+ box: [0, 0, 0, 0],
+ boxRaw: [0, 0, 0, 0],
+ score: 0,
+ boxScore: 0,
+ faceScore: 0,
+ annotations: {}
+ };
+ [angle, rotationMatrix, face4.tensor] = correctFaceRotation((_c = config3.face.detector) == null ? void 0 : _c.rotation, box, input, ((_d = config3.face.mesh) == null ? void 0 : _d.enabled) ? inputSize6 : size());
+ if (config3.filter.equalization) {
+ const equilized = face4.tensor ? await histogramEqualization(face4.tensor) : void 0;
+ tfjs_esm_exports.dispose(face4.tensor);
+ if (equilized)
+ face4.tensor = equilized;
+ }
+ face4.boxScore = Math.round(100 * box.confidence) / 100;
+ if (!((_e = config3.face.mesh) == null ? void 0 : _e.enabled)) {
+ face4.box = clampBox(box, input);
+ face4.boxRaw = getRawBox(box, input);
+ face4.score = face4.boxScore;
+ face4.mesh = box.landmarks.map((pt) => [
+ (box.startPoint[0] + box.endPoint[0]) / 2 + (box.endPoint[0] + box.startPoint[0]) * pt[0] / size(),
+ (box.startPoint[1] + box.endPoint[1]) / 2 + (box.endPoint[1] + box.startPoint[1]) * pt[1] / size()
+ ]);
+ face4.meshRaw = face4.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / size2]);
+ for (const key of Object.keys(blazeFaceLandmarks)) {
+ face4.annotations[key] = [face4.mesh[blazeFaceLandmarks[key]]];
+ }
+ } else if (!model7) {
+ if (config3.debug)
+ log("face mesh detection requested, but model is not loaded");
+ } else {
+ if (((_f = config3.face.attention) == null ? void 0 : _f.enabled) && !env.kernels.includes("atan2")) {
+ config3.face.attention.enabled = false;
+ tfjs_esm_exports.dispose(face4.tensor);
+ return faces;
+ }
+ const results = model7.execute(face4.tensor);
+ const confidenceT = results.find((t2) => t2.shape[t2.shape.length - 1] === 1);
+ const faceConfidence = await confidenceT.data();
+ face4.faceScore = Math.round(100 * faceConfidence[0]) / 100;
+ if (face4.faceScore < (((_g = config3.face.detector) == null ? void 0 : _g.minConfidence) || 1)) {
+ box.confidence = face4.faceScore;
+ if (config3.face.mesh.keepInvalid) {
+ face4.box = clampBox(box, input);
+ face4.boxRaw = getRawBox(box, input);
+ face4.score = face4.boxScore;
+ face4.mesh = box.landmarks.map((pt) => [
+ (box.startPoint[0] + box.endPoint[0]) / 2 + (box.endPoint[0] + box.startPoint[0]) * pt[0] / size(),
+ (box.startPoint[1] + box.endPoint[1]) / 2 + (box.endPoint[1] + box.startPoint[1]) * pt[1] / size()
+ ]);
+ face4.meshRaw = face4.mesh.map((pt) => [pt[0] / (input.shape[2] || 1), pt[1] / (input.shape[1] || 1), (pt[2] || 0) / size2]);
+ for (const key of Object.keys(blazeFaceLandmarks)) {
+ face4.annotations[key] = [face4.mesh[blazeFaceLandmarks[key]]];
+ }
+ }
+ } else {
+ const meshT = results.find((t2) => t2.shape[t2.shape.length - 1] === 1404);
+ const coordsReshaped = tfjs_esm_exports.reshape(meshT, [-1, 3]);
+ let rawCoords = await coordsReshaped.array();
+ tfjs_esm_exports.dispose(coordsReshaped);
+ if ((_h = config3.face.attention) == null ? void 0 : _h.enabled) {
+ rawCoords = await augment(rawCoords, results);
+ } else if ((_i = config3.face.iris) == null ? void 0 : _i.enabled) {
+ rawCoords = await augmentIris(rawCoords, face4.tensor, inputSize6);
+ }
+ face4.mesh = transformRawCoords(rawCoords, box, angle, rotationMatrix, inputSize6);
+ face4.meshRaw = face4.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / size2]);
+ for (const key of Object.keys(meshAnnotations))
+ face4.annotations[key] = meshAnnotations[key].map((index2) => face4.mesh[index2]);
+ face4.score = face4.faceScore;
+ const calculatedBox = { ...calculateFaceBox(face4.mesh, box), confidence: box.confidence, landmarks: box.landmarks };
+ face4.box = clampBox(calculatedBox, input);
+ face4.boxRaw = getRawBox(calculatedBox, input);
+ newCache.push(calculatedBox);
+ }
+ tfjs_esm_exports.dispose(results);
+ }
+ if (face4.score > (((_j = config3.face.detector) == null ? void 0 : _j.minConfidence) || 1))
+ faces.push(face4);
+ else
+ tfjs_esm_exports.dispose(face4.tensor);
+ }
+ cache3.boxes = newCache;
+ return faces;
+}
+async function load5(config3) {
+ var _a, _b, _c, _d, _e, _f;
+ if (env.initial)
+ model7 = null;
+ if (((_a = config3.face.attention) == null ? void 0 : _a.enabled) && (model7 == null ? void 0 : model7["signature"])) {
+ if (Object.keys(((_b = model7 == null ? void 0 : model7["signature"]) == null ? void 0 : _b.outputs) || {}).length < 6)
+ model7 = null;
+ }
+ if (!model7) {
+ if ((_c = config3.face.attention) == null ? void 0 : _c.enabled)
+ model7 = await loadModel(config3.face.attention.modelPath);
+ else
+ model7 = await loadModel((_d = config3.face.mesh) == null ? void 0 : _d.modelPath);
+ } else if (config3.debug) {
+ log("cached model:", model7["modelUrl"]);
+ }
+ inputSize6 = model7["executor"] && ((_e = model7 == null ? void 0 : model7.inputs) == null ? void 0 : _e[0].shape) ? (_f = model7 == null ? void 0 : model7.inputs) == null ? void 0 : _f[0].shape[2] : 256;
+ return model7;
+}
+var triangulation = TRI468;
+var uvmap = UV468;
+
+// src/gear/emotion.ts
+var annotations = ["angry", "disgust", "fear", "happy", "sad", "surprise", "neutral"];
+var model8;
+var last3 = [];
+var lastCount = 0;
+var lastTime4 = 0;
+var skipped4 = Number.MAX_SAFE_INTEGER;
+async function load6(config3) {
+ var _a;
+ if (env.initial)
+ model8 = null;
+ if (!model8)
+ model8 = await loadModel((_a = config3.face.emotion) == null ? void 0 : _a.modelPath);
+ else if (config3.debug)
+ log("cached model:", model8["modelUrl"]);
+ return model8;
+}
+async function predict5(image28, config3, idx, count2) {
+ var _a, _b;
+ if (!model8)
+ return [];
+ const skipFrame = skipped4 < (((_a = config3.face.emotion) == null ? void 0 : _a.skipFrames) || 0);
+ const skipTime = (((_b = config3.face.emotion) == null ? void 0 : _b.skipTime) || 0) > now() - lastTime4;
+ if (config3.skipAllowed && skipTime && skipFrame && lastCount === count2 && last3[idx] && last3[idx].length > 0) {
+ skipped4++;
+ return last3[idx];
+ }
+ skipped4 = 0;
+ return new Promise(async (resolve) => {
+ var _a2;
+ const obj = [];
+ if ((_a2 = config3.face.emotion) == null ? void 0 : _a2.enabled) {
+ const t2 = {};
+ const inputSize10 = (model8 == null ? void 0 : model8.inputs[0].shape) ? model8.inputs[0].shape[2] : 0;
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(image28, [inputSize10, inputSize10], false);
+ t2.channels = tfjs_esm_exports.mul(t2.resize, constants.rgb);
+ t2.grayscale = tfjs_esm_exports.sum(t2.channels, 3, true);
+ t2.grayscaleSub = tfjs_esm_exports.sub(t2.grayscale, constants.tf05);
+ t2.grayscaleMul = tfjs_esm_exports.mul(t2.grayscaleSub, constants.tf2);
+ t2.emotion = model8 == null ? void 0 : model8.execute(t2.grayscaleMul);
+ lastTime4 = now();
+ const data = await t2.emotion.data();
+ for (let i = 0; i < data.length; i++) {
+ if (data[i] > (config3.face.emotion.minConfidence || 0))
+ obj.push({ score: Math.min(0.99, Math.trunc(100 * data[i]) / 100), emotion: annotations[i] });
+ }
+ obj.sort((a, b) => b.score - a.score);
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ }
+ last3[idx] = obj;
+ lastCount = count2;
+ resolve(obj);
+ });
+}
+
+// src/face/faceres.ts
+var model9;
+var last4 = [];
+var lastTime5 = 0;
+var lastCount2 = 0;
+var skipped5 = Number.MAX_SAFE_INTEGER;
+async function load7(config3) {
+ var _a;
+ if (env.initial)
+ model9 = null;
+ if (!model9)
+ model9 = await loadModel((_a = config3.face.description) == null ? void 0 : _a.modelPath);
+ else if (config3.debug)
+ log("cached model:", model9["modelUrl"]);
+ return model9;
+}
+function enhance(input) {
+ const tensor6 = input.image || input.tensor || input;
+ if (!(model9 == null ? void 0 : model9.inputs[0].shape))
+ return tensor6;
+ const crop = tfjs_esm_exports.image.resizeBilinear(tensor6, [model9.inputs[0].shape[2], model9.inputs[0].shape[1]], false);
+ const norm = tfjs_esm_exports.mul(crop, constants.tf255);
+ tfjs_esm_exports.dispose(crop);
+ return norm;
+}
+async function predict6(image28, config3, idx, count2) {
+ var _a, _b, _c, _d;
+ const obj = {
+ age: 0,
+ gender: "unknown",
+ genderScore: 0,
+ descriptor: []
+ };
+ if (!(model9 == null ? void 0 : model9["executor"]))
+ return obj;
+ const skipFrame = skipped5 < (((_a = config3.face.description) == null ? void 0 : _a.skipFrames) || 0);
+ const skipTime = (((_b = config3.face.description) == null ? void 0 : _b.skipTime) || 0) > now() - lastTime5;
+ if (config3.skipAllowed && skipFrame && skipTime && lastCount2 === count2 && ((_c = last4 == null ? void 0 : last4[idx]) == null ? void 0 : _c.age) > 0 && ((_d = last4 == null ? void 0 : last4[idx]) == null ? void 0 : _d.genderScore) > 0) {
+ skipped5++;
+ return last4[idx];
+ }
+ skipped5 = 0;
+ return new Promise(async (resolve) => {
+ var _a2;
+ if ((_a2 = config3.face.description) == null ? void 0 : _a2.enabled) {
+ const enhanced = enhance(image28);
+ const resT = model9 == null ? void 0 : model9.execute(enhanced);
+ lastTime5 = now();
+ tfjs_esm_exports.dispose(enhanced);
+ const genderT = resT.find((t2) => t2.shape[1] === 1);
+ const gender2 = await genderT.data();
+ const confidence = Math.trunc(200 * Math.abs(gender2[0] - 0.5)) / 100;
+ if (confidence > (config3.face.description.minConfidence || 0)) {
+ obj.gender = gender2[0] <= 0.5 ? "female" : "male";
+ obj.genderScore = Math.min(0.99, confidence);
+ }
+ const argmax = tfjs_esm_exports.argMax(resT.find((t2) => t2.shape[1] === 100), 1);
+ const ageIdx = (await argmax.data())[0];
+ tfjs_esm_exports.dispose(argmax);
+ const ageT = resT.find((t2) => t2.shape[1] === 100);
+ const all2 = await ageT.data();
+ obj.age = Math.round(all2[ageIdx - 1] > all2[ageIdx + 1] ? 10 * ageIdx - 100 * all2[ageIdx - 1] : 10 * ageIdx + 100 * all2[ageIdx + 1]) / 10;
+ if (Number.isNaN(gender2[0]) || Number.isNaN(all2[0]))
+ log("faceres error:", { model: model9, result: resT });
+ const desc = resT.find((t2) => t2.shape[1] === 1024);
+ const descriptor = desc ? await desc.data() : [];
+ obj.descriptor = Array.from(descriptor);
+ resT.forEach((t2) => tfjs_esm_exports.dispose(t2));
+ }
+ last4[idx] = obj;
+ lastCount2 = count2;
+ resolve(obj);
+ });
+}
+
+// src/face/mask.ts
+var expandFact = 0.1;
+var alpha = 0.5;
+function insidePoly(x, y, polygon) {
+ let inside = false;
+ let j = polygon.length - 1;
+ for (let i = 0; i < polygon.length; j = i++) {
+ if (polygon[i].y > y !== polygon[j].y > y && x < (polygon[j].x - polygon[i].x) * (y - polygon[i].y) / (polygon[j].y - polygon[i].y) + polygon[i].x)
+ inside = !inside;
+ }
+ return inside;
+}
+async function mask(face4) {
+ if (!face4.tensor)
+ return face4.tensor;
+ if (!face4.mesh || face4.mesh.length < 100)
+ return face4.tensor;
+ const width = face4.tensor.shape[2] || 0;
+ const height = face4.tensor.shape[1] || 0;
+ const buffer = await face4.tensor.buffer();
+ let silhouette = [];
+ for (const pt of meshAnnotations.silhouette)
+ silhouette.push({ x: (face4.mesh[pt][0] - face4.box[0]) / face4.box[2], y: (face4.mesh[pt][1] - face4.box[1]) / face4.box[3] });
+ if (expandFact && expandFact > 0)
+ silhouette = silhouette.map((pt) => ({ x: pt.x > 0.5 ? pt.x + expandFact : pt.x - expandFact, y: pt.y > 0.5 ? pt.y + expandFact : pt.y - expandFact }));
+ for (let x = 0; x < width; x++) {
+ for (let y = 0; y < height; y++) {
+ const inside = insidePoly(x / width, y / width, silhouette);
+ if (!inside) {
+ buffer.set(alpha * buffer.get(0, y, x, 0), 0, y, x, 0);
+ buffer.set(alpha * buffer.get(0, y, x, 1), 0, y, x, 1);
+ buffer.set(alpha * buffer.get(0, y, x, 2), 0, y, x, 2);
+ }
+ }
+ }
+ const output = buffer.toTensor();
+ return output;
+}
+
+// src/face/antispoof.ts
+var model10;
+var cached = [];
+var skipped6 = Number.MAX_SAFE_INTEGER;
+var lastCount3 = 0;
+var lastTime6 = 0;
+async function load8(config3) {
+ var _a;
+ if (env.initial)
+ model10 = null;
+ if (!model10)
+ model10 = await loadModel((_a = config3.face.antispoof) == null ? void 0 : _a.modelPath);
+ else if (config3.debug)
+ log("cached model:", model10["modelUrl"]);
+ return model10;
+}
+async function predict7(image28, config3, idx, count2) {
+ var _a, _b;
+ if (!(model10 == null ? void 0 : model10["executor"]))
+ return 0;
+ const skipTime = (((_a = config3.face.antispoof) == null ? void 0 : _a.skipTime) || 0) > now() - lastTime6;
+ const skipFrame = skipped6 < (((_b = config3.face.antispoof) == null ? void 0 : _b.skipFrames) || 0);
+ if (config3.skipAllowed && skipTime && skipFrame && lastCount3 === count2 && cached[idx]) {
+ skipped6++;
+ return cached[idx];
+ }
+ skipped6 = 0;
+ return new Promise(async (resolve) => {
+ const resize = tfjs_esm_exports.image.resizeBilinear(image28, [(model10 == null ? void 0 : model10.inputs[0].shape) ? model10.inputs[0].shape[2] : 0, (model10 == null ? void 0 : model10.inputs[0].shape) ? model10.inputs[0].shape[1] : 0], false);
+ const res = model10 == null ? void 0 : model10.execute(resize);
+ const num = (await res.data())[0];
+ cached[idx] = Math.round(100 * num) / 100;
+ lastCount3 = count2;
+ lastTime6 = now();
+ tfjs_esm_exports.dispose([resize, res]);
+ resolve(cached[idx]);
+ });
+}
+
+// src/face/liveness.ts
+var model11;
+var cached2 = [];
+var skipped7 = Number.MAX_SAFE_INTEGER;
+var lastCount4 = 0;
+var lastTime7 = 0;
+async function load9(config3) {
+ var _a;
+ if (env.initial)
+ model11 = null;
+ if (!model11)
+ model11 = await loadModel((_a = config3.face.liveness) == null ? void 0 : _a.modelPath);
+ else if (config3.debug)
+ log("cached model:", model11["modelUrl"]);
+ return model11;
+}
+async function predict8(image28, config3, idx, count2) {
+ var _a, _b;
+ if (!(model11 == null ? void 0 : model11["executor"]))
+ return 0;
+ const skipTime = (((_a = config3.face.liveness) == null ? void 0 : _a.skipTime) || 0) > now() - lastTime7;
+ const skipFrame = skipped7 < (((_b = config3.face.liveness) == null ? void 0 : _b.skipFrames) || 0);
+ if (config3.skipAllowed && skipTime && skipFrame && lastCount4 === count2 && cached2[idx]) {
+ skipped7++;
+ return cached2[idx];
+ }
+ skipped7 = 0;
+ return new Promise(async (resolve) => {
+ const resize = tfjs_esm_exports.image.resizeBilinear(image28, [(model11 == null ? void 0 : model11.inputs[0].shape) ? model11.inputs[0].shape[2] : 0, (model11 == null ? void 0 : model11.inputs[0].shape) ? model11.inputs[0].shape[1] : 0], false);
+ const res = model11 == null ? void 0 : model11.execute(resize);
+ const num = (await res.data())[0];
+ cached2[idx] = Math.round(100 * num) / 100;
+ lastCount4 = count2;
+ lastTime7 = now();
+ tfjs_esm_exports.dispose([resize, res]);
+ resolve(cached2[idx]);
+ });
+}
+
+// src/gear/gear.ts
+var model12;
+var last5 = [];
+var raceNames = ["white", "black", "asian", "indian", "other"];
+var ageWeights = [15, 23, 28, 35.5, 45.5, 55.5, 65];
+var lastCount5 = 0;
+var lastTime8 = 0;
+var skipped8 = Number.MAX_SAFE_INTEGER;
+async function load10(config3) {
+ var _a;
+ if (env.initial)
+ model12 = null;
+ if (!model12)
+ model12 = await loadModel((_a = config3.face.gear) == null ? void 0 : _a.modelPath);
+ else if (config3.debug)
+ log("cached model:", model12["modelUrl"]);
+ return model12;
+}
+async function predict9(image28, config3, idx, count2) {
+ var _a, _b;
+ if (!model12)
+ return { age: 0, gender: "unknown", genderScore: 0, race: [] };
+ const skipFrame = skipped8 < (((_a = config3.face.gear) == null ? void 0 : _a.skipFrames) || 0);
+ const skipTime = (((_b = config3.face.gear) == null ? void 0 : _b.skipTime) || 0) > now() - lastTime8;
+ if (config3.skipAllowed && skipTime && skipFrame && lastCount5 === count2 && last5[idx]) {
+ skipped8++;
+ return last5[idx];
+ }
+ skipped8 = 0;
+ return new Promise(async (resolve) => {
+ var _a2, _b2;
+ if (!(model12 == null ? void 0 : model12.inputs[0].shape))
+ return;
+ const t2 = {};
+ const box = [[0, 0.1, 0.9, 0.9]];
+ t2.resize = tfjs_esm_exports.image.cropAndResize(image28, box, [0], [model12.inputs[0].shape[2], model12.inputs[0].shape[1]]);
+ const obj = { age: 0, gender: "unknown", genderScore: 0, race: [] };
+ if ((_a2 = config3.face.gear) == null ? void 0 : _a2.enabled)
+ [t2.age, t2.gender, t2.race] = model12.execute(t2.resize, ["age_output", "gender_output", "race_output"]);
+ const gender2 = await t2.gender.data();
+ obj.gender = gender2[0] > gender2[1] ? "male" : "female";
+ obj.genderScore = Math.round(100 * (gender2[0] > gender2[1] ? gender2[0] : gender2[1])) / 100;
+ const race = await t2.race.data();
+ for (let i = 0; i < race.length; i++) {
+ if (race[i] > (((_b2 = config3.face.gear) == null ? void 0 : _b2.minConfidence) || 0.2))
+ obj.race.push({ score: Math.round(100 * race[i]) / 100, race: raceNames[i] });
+ }
+ obj.race.sort((a, b) => b.score - a.score);
+ const ageDistribution = Array.from(await t2.age.data());
+ const ageSorted = ageDistribution.map((a, i) => [ageWeights[i], a]).sort((a, b) => b[1] - a[1]);
+ let age2 = ageSorted[0][0];
+ for (let i = 1; i < ageSorted.length; i++)
+ age2 += ageSorted[i][1] * (ageSorted[i][0] - age2);
+ obj.age = Math.round(10 * age2) / 10;
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ last5[idx] = obj;
+ lastCount5 = count2;
+ lastTime8 = now();
+ resolve(obj);
+ });
+}
+
+// src/gear/ssrnet-age.ts
+var model13;
+var last6 = [];
+var lastCount6 = 0;
+var lastTime9 = 0;
+var skipped9 = Number.MAX_SAFE_INTEGER;
+async function load11(config3) {
+ if (env.initial)
+ model13 = null;
+ if (!model13)
+ model13 = await loadModel(config3.face["ssrnet"].modelPathAge);
+ else if (config3.debug)
+ log("cached model:", model13["modelUrl"]);
+ return model13;
+}
+async function predict10(image28, config3, idx, count2) {
+ var _a, _b, _c, _d;
+ if (!model13)
+ return { age: 0 };
+ const skipFrame = skipped9 < (((_a = config3.face["ssrnet"]) == null ? void 0 : _a.skipFrames) || 0);
+ const skipTime = (((_b = config3.face["ssrnet"]) == null ? void 0 : _b.skipTime) || 0) > now() - lastTime9;
+ if (config3.skipAllowed && skipFrame && skipTime && lastCount6 === count2 && ((_c = last6[idx]) == null ? void 0 : _c.age) && ((_d = last6[idx]) == null ? void 0 : _d.age) > 0) {
+ skipped9++;
+ return last6[idx];
+ }
+ skipped9 = 0;
+ return new Promise(async (resolve) => {
+ var _a2;
+ if (!(model13 == null ? void 0 : model13.inputs) || !model13.inputs[0] || !model13.inputs[0].shape)
+ return;
+ const t2 = {};
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(image28, [model13.inputs[0].shape[2], model13.inputs[0].shape[1]], false);
+ t2.enhance = tfjs_esm_exports.mul(t2.resize, constants.tf255);
+ const obj = { age: 0 };
+ if ((_a2 = config3.face["ssrnet"]) == null ? void 0 : _a2.enabled)
+ t2.age = model13.execute(t2.enhance);
+ if (t2.age) {
+ const data = await t2.age.data();
+ obj.age = Math.trunc(10 * data[0]) / 10;
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ last6[idx] = obj;
+ lastCount6 = count2;
+ lastTime9 = now();
+ resolve(obj);
+ });
+}
+
+// src/gear/ssrnet-gender.ts
+var model14;
+var last7 = [];
+var lastCount7 = 0;
+var lastTime10 = 0;
+var skipped10 = Number.MAX_SAFE_INTEGER;
+var rgb = [0.2989, 0.587, 0.114];
+async function load12(config3) {
+ var _a;
+ if (env.initial)
+ model14 = null;
+ if (!model14)
+ model14 = await loadModel((_a = config3.face["ssrnet"]) == null ? void 0 : _a.modelPathGender);
+ else if (config3.debug)
+ log("cached model:", model14["modelUrl"]);
+ return model14;
+}
+async function predict11(image28, config3, idx, count2) {
+ var _a, _b, _c, _d;
+ if (!model14)
+ return { gender: "unknown", genderScore: 0 };
+ const skipFrame = skipped10 < (((_a = config3.face["ssrnet"]) == null ? void 0 : _a.skipFrames) || 0);
+ const skipTime = (((_b = config3.face["ssrnet"]) == null ? void 0 : _b.skipTime) || 0) > now() - lastTime10;
+ if (config3.skipAllowed && skipFrame && skipTime && lastCount7 === count2 && ((_c = last7[idx]) == null ? void 0 : _c.gender) && ((_d = last7[idx]) == null ? void 0 : _d.genderScore) > 0) {
+ skipped10++;
+ return last7[idx];
+ }
+ skipped10 = 0;
+ return new Promise(async (resolve) => {
+ var _a2;
+ if (!(model14 == null ? void 0 : model14.inputs[0].shape))
+ return;
+ const t2 = {};
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(image28, [model14.inputs[0].shape[2], model14.inputs[0].shape[1]], false);
+ t2.enhance = tfjs_esm_exports.tidy(() => {
+ const [red, green, blue] = tfjs_esm_exports.split(t2.resize, 3, 3);
+ const redNorm = tfjs_esm_exports.mul(red, rgb[0]);
+ const greenNorm = tfjs_esm_exports.mul(green, rgb[1]);
+ const blueNorm = tfjs_esm_exports.mul(blue, rgb[2]);
+ const grayscale = tfjs_esm_exports.addN([redNorm, greenNorm, blueNorm]);
+ const normalize2 = tfjs_esm_exports.mul(tfjs_esm_exports.sub(grayscale, constants.tf05), 2);
+ return normalize2;
+ });
+ const obj = { gender: "unknown", genderScore: 0 };
+ if ((_a2 = config3.face["ssrnet"]) == null ? void 0 : _a2.enabled)
+ t2.gender = model14.execute(t2.enhance);
+ const data = await t2.gender.data();
+ obj.gender = data[0] > data[1] ? "female" : "male";
+ obj.genderScore = data[0] > data[1] ? Math.trunc(100 * data[0]) / 100 : Math.trunc(100 * data[1]) / 100;
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ last7[idx] = obj;
+ lastCount7 = count2;
+ lastTime10 = now();
+ resolve(obj);
+ });
+}
+
+// src/face/mobilefacenet.ts
+var model15;
+var last8 = [];
+var lastCount8 = 0;
+var lastTime11 = 0;
+var skipped11 = Number.MAX_SAFE_INTEGER;
+async function load13(config3) {
+ var _a;
+ if (env.initial)
+ model15 = null;
+ if (!model15)
+ model15 = await loadModel((_a = config3.face["mobilefacenet"]) == null ? void 0 : _a.modelPath);
+ else if (config3.debug)
+ log("cached model:", model15["modelUrl"]);
+ return model15;
+}
+async function predict12(input, config3, idx, count2) {
+ var _a, _b;
+ if (!(model15 == null ? void 0 : model15["executor"]))
+ return [];
+ const skipFrame = skipped11 < (((_a = config3.face["mobilefacenet"]) == null ? void 0 : _a.skipFrames) || 0);
+ const skipTime = (((_b = config3.face["mobilefacenet"]) == null ? void 0 : _b.skipTime) || 0) > now() - lastTime11;
+ if (config3.skipAllowed && skipTime && skipFrame && lastCount8 === count2 && last8[idx]) {
+ skipped11++;
+ return last8[idx];
+ }
+ return new Promise(async (resolve) => {
+ var _a2;
+ let data = [];
+ if (((_a2 = config3.face["mobilefacenet"]) == null ? void 0 : _a2.enabled) && (model15 == null ? void 0 : model15.inputs[0].shape)) {
+ const t2 = {};
+ t2.crop = tfjs_esm_exports.image.resizeBilinear(input, [model15.inputs[0].shape[2], model15.inputs[0].shape[1]], false);
+ t2.data = model15.execute(t2.crop);
+ const output = await t2.data.data();
+ data = Array.from(output);
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ }
+ last8[idx] = data;
+ lastCount8 = count2;
+ lastTime11 = now();
+ resolve(data);
+ });
+}
+
+// src/face/insightface.ts
+var model16;
+var last9 = [];
+var lastCount9 = 0;
+var lastTime12 = 0;
+var skipped12 = Number.MAX_SAFE_INTEGER;
+async function load14(config3) {
+ if (env.initial)
+ model16 = null;
+ if (!model16)
+ model16 = await loadModel(config3.face["insightface"].modelPath);
+ else if (config3.debug)
+ log("cached model:", model16["modelUrl"]);
+ return model16;
+}
+async function predict13(input, config3, idx, count2) {
+ var _a, _b;
+ if (!(model16 == null ? void 0 : model16["executor"]))
+ return [];
+ const skipFrame = skipped12 < (((_a = config3.face["insightface"]) == null ? void 0 : _a.skipFrames) || 0);
+ const skipTime = (((_b = config3.face["insightface"]) == null ? void 0 : _b.skipTime) || 0) > now() - lastTime12;
+ if (config3.skipAllowed && skipTime && skipFrame && lastCount9 === count2 && last9[idx]) {
+ skipped12++;
+ return last9[idx];
+ }
+ return new Promise(async (resolve) => {
+ var _a2;
+ let data = [];
+ if (((_a2 = config3.face["insightface"]) == null ? void 0 : _a2.enabled) && (model16 == null ? void 0 : model16.inputs[0].shape)) {
+ const t2 = {};
+ t2.crop = tfjs_esm_exports.image.resizeBilinear(input, [model16.inputs[0].shape[2], model16.inputs[0].shape[1]], false);
+ t2.data = model16.execute(t2.crop);
+ const output = await t2.data.data();
+ data = Array.from(output);
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ }
+ last9[idx] = data;
+ lastCount9 = count2;
+ lastTime12 = now();
+ resolve(data);
+ });
+}
+
+// src/face/angles.ts
+var calculateGaze = (face4) => {
+ const radians = (pt1, pt2) => Math.atan2(pt1[1] - pt2[1], pt1[0] - pt2[0]);
+ if (!face4.annotations.rightEyeIris || !face4.annotations.leftEyeIris)
+ return { bearing: 0, strength: 0 };
+ const offsetIris = [0, -0.1];
+ const eyeRatio = 1;
+ const left = (face4.mesh[33][2] || 0) > (face4.mesh[263][2] || 0);
+ const irisCenter = left ? face4.mesh[473] : face4.mesh[468];
+ const eyeCenter = left ? [(face4.mesh[133][0] + face4.mesh[33][0]) / 2, (face4.mesh[133][1] + face4.mesh[33][1]) / 2] : [(face4.mesh[263][0] + face4.mesh[362][0]) / 2, (face4.mesh[263][1] + face4.mesh[362][1]) / 2];
+ const eyeSize = left ? [face4.mesh[133][0] - face4.mesh[33][0], face4.mesh[23][1] - face4.mesh[27][1]] : [face4.mesh[263][0] - face4.mesh[362][0], face4.mesh[253][1] - face4.mesh[257][1]];
+ const eyeDiff = [
+ (eyeCenter[0] - irisCenter[0]) / eyeSize[0] - offsetIris[0],
+ eyeRatio * (irisCenter[1] - eyeCenter[1]) / eyeSize[1] - offsetIris[1]
+ ];
+ let strength = Math.sqrt(eyeDiff[0] * eyeDiff[0] + eyeDiff[1] * eyeDiff[1]);
+ strength = Math.min(strength, face4.boxRaw[2] / 2, face4.boxRaw[3] / 2);
+ const bearing = (radians([0, 0], eyeDiff) + Math.PI / 2) % Math.PI;
+ return { bearing, strength };
+};
+var calculateFaceAngle = (face4, imageSize) => {
+ const normalize2 = (v) => {
+ const length = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
+ v[0] /= length;
+ v[1] /= length;
+ v[2] /= length;
+ return v;
+ };
+ const subVectors = (a, b) => {
+ const x = a[0] - b[0];
+ const y = a[1] - b[1];
+ const z = a[2] - b[2];
+ return [x, y, z];
+ };
+ const crossVectors = (a, b) => {
+ const x = a[1] * b[2] - a[2] * b[1];
+ const y = a[2] * b[0] - a[0] * b[2];
+ const z = a[0] * b[1] - a[1] * b[0];
+ return [x, y, z];
+ };
+ const rotationMatrixToEulerAngle = (r) => {
+ const [r00, _r01, _r02, r10, r11, r12, r20, r21, r22] = r;
+ let thetaX;
+ let thetaY;
+ let thetaZ;
+ if (r10 < 1) {
+ if (r10 > -1) {
+ thetaZ = Math.asin(r10);
+ thetaY = Math.atan2(-r20, r00);
+ thetaX = Math.atan2(-r12, r11);
+ } else {
+ thetaZ = -Math.PI / 2;
+ thetaY = -Math.atan2(r21, r22);
+ thetaX = 0;
+ }
+ } else {
+ thetaZ = Math.PI / 2;
+ thetaY = Math.atan2(r21, r22);
+ thetaX = 0;
+ }
+ if (Number.isNaN(thetaX))
+ thetaX = 0;
+ if (Number.isNaN(thetaY))
+ thetaY = 0;
+ if (Number.isNaN(thetaZ))
+ thetaZ = 0;
+ return { pitch: 2 * -thetaX, yaw: 2 * -thetaY, roll: 2 * -thetaZ };
+ };
+ const mesh = face4.meshRaw;
+ if (!mesh || mesh.length < 300)
+ return { angle: { pitch: 0, yaw: 0, roll: 0 }, matrix: [1, 0, 0, 0, 1, 0, 0, 0, 1], gaze: { bearing: 0, strength: 0 } };
+ const size2 = Math.max(face4.boxRaw[2] * imageSize[0], face4.boxRaw[3] * imageSize[1]) / 1.5;
+ const pts = [mesh[10], mesh[152], mesh[234], mesh[454]].map((pt) => [pt[0] * imageSize[0] / size2, pt[1] * imageSize[1] / size2, pt[2]]);
+ const yAxis = normalize2(subVectors(pts[1], pts[0]));
+ let xAxis = normalize2(subVectors(pts[3], pts[2]));
+ const zAxis = normalize2(crossVectors(xAxis, yAxis));
+ xAxis = crossVectors(yAxis, zAxis);
+ const matrix = [
+ xAxis[0],
+ xAxis[1],
+ xAxis[2],
+ yAxis[0],
+ yAxis[1],
+ yAxis[2],
+ zAxis[0],
+ zAxis[1],
+ zAxis[2]
+ ];
+ const angle = rotationMatrixToEulerAngle(matrix);
+ const gaze = mesh.length === 478 ? calculateGaze(face4) : { bearing: 0, strength: 0 };
+ return { angle, matrix, gaze };
+};
+
+// src/face/anthropometry.ts
+function calculateCameraDistance(face4, width) {
+ const f = face4 == null ? void 0 : face4.annotations;
+ if (!f)
+ return 0;
+ const irisSize = Math.max(Math.abs(f.leftEyeIris[3][0] - f.leftEyeIris[1][0]), Math.abs(f.rightEyeIris[3][0] - f.rightEyeIris[1][0])) / width;
+ const cameraDistance = Math.round(1.17 / irisSize) / 100;
+ return cameraDistance;
+}
+
+// src/face/face.ts
+var detectFace = async (instance, input) => {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
+ let timeStamp = now();
+ let ageRes;
+ let gearRes;
+ let genderRes;
+ let emotionRes;
+ let mobilefacenetRes;
+ let insightfaceRes;
+ let antispoofRes;
+ let livenessRes;
+ let descRes;
+ const faceRes = [];
+ instance.state = "run:face";
+ const faces = await predict4(input, instance.config);
+ instance.performance.face = env.perfadd ? (instance.performance.face || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ if (!input.shape || input.shape.length !== 4)
+ return [];
+ if (!faces)
+ return [];
+ for (let i = 0; i < faces.length; i++) {
+ instance.analyze("Get Face");
+ if (!faces[i].tensor || faces[i].tensor.isDisposedInternal) {
+ log("Face object is disposed:", faces[i].tensor);
+ continue;
+ }
+ if ((_a = instance.config.face.detector) == null ? void 0 : _a.mask) {
+ const masked = await mask(faces[i]);
+ tfjs_esm_exports.dispose(faces[i].tensor);
+ if (masked)
+ faces[i].tensor = masked;
+ }
+ const rotation = faces[i].mesh && faces[i].mesh.length > 200 ? calculateFaceAngle(faces[i], [input.shape[2], input.shape[1]]) : null;
+ instance.analyze("Start Emotion:");
+ if (instance.config.async) {
+ emotionRes = ((_b = instance.config.face.emotion) == null ? void 0 : _b.enabled) ? predict5(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : [];
+ } else {
+ instance.state = "run:emotion";
+ timeStamp = now();
+ emotionRes = ((_c = instance.config.face.emotion) == null ? void 0 : _c.enabled) ? await predict5(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : [];
+ instance.performance.emotion = env.perfadd ? (instance.performance.emotion || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ }
+ instance.analyze("End Emotion:");
+ instance.analyze("Start AntiSpoof:");
+ if (instance.config.async) {
+ antispoofRes = ((_d = instance.config.face.antispoof) == null ? void 0 : _d.enabled) ? predict7(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : 0;
+ } else {
+ instance.state = "run:antispoof";
+ timeStamp = now();
+ antispoofRes = ((_e = instance.config.face.antispoof) == null ? void 0 : _e.enabled) ? await predict7(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : 0;
+ instance.performance.antispoof = env.perfadd ? (instance.performance.antispoof || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ }
+ instance.analyze("End AntiSpoof:");
+ instance.analyze("Start Liveness:");
+ if (instance.config.async) {
+ livenessRes = ((_f = instance.config.face.liveness) == null ? void 0 : _f.enabled) ? predict8(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : 0;
+ } else {
+ instance.state = "run:liveness";
+ timeStamp = now();
+ livenessRes = ((_g = instance.config.face.liveness) == null ? void 0 : _g.enabled) ? await predict8(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : 0;
+ instance.performance.liveness = env.perfadd ? (instance.performance.antispoof || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ }
+ instance.analyze("End Liveness:");
+ instance.analyze("Start GEAR:");
+ if (instance.config.async) {
+ gearRes = ((_h = instance.config.face.gear) == null ? void 0 : _h.enabled) ? predict9(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ } else {
+ instance.state = "run:gear";
+ timeStamp = now();
+ gearRes = ((_i = instance.config.face.gear) == null ? void 0 : _i.enabled) ? await predict9(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ instance.performance.gear = Math.trunc(now() - timeStamp);
+ }
+ instance.analyze("End GEAR:");
+ instance.analyze("Start SSRNet:");
+ if (instance.config.async) {
+ ageRes = ((_j = instance.config.face["ssrnet"]) == null ? void 0 : _j.enabled) ? predict10(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ genderRes = ((_k = instance.config.face["ssrnet"]) == null ? void 0 : _k.enabled) ? predict11(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ } else {
+ instance.state = "run:ssrnet";
+ timeStamp = now();
+ ageRes = ((_l = instance.config.face["ssrnet"]) == null ? void 0 : _l.enabled) ? await predict10(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ genderRes = ((_m = instance.config.face["ssrnet"]) == null ? void 0 : _m.enabled) ? await predict11(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ instance.performance.ssrnet = Math.trunc(now() - timeStamp);
+ }
+ instance.analyze("End SSRNet:");
+ instance.analyze("Start MobileFaceNet:");
+ if (instance.config.async) {
+ mobilefacenetRes = ((_n = instance.config.face["mobilefacenet"]) == null ? void 0 : _n.enabled) ? predict12(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ } else {
+ instance.state = "run:mobilefacenet";
+ timeStamp = now();
+ mobilefacenetRes = ((_o = instance.config.face["mobilefacenet"]) == null ? void 0 : _o.enabled) ? await predict12(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ instance.performance.mobilefacenet = Math.trunc(now() - timeStamp);
+ }
+ instance.analyze("End MobileFaceNet:");
+ instance.analyze("Start InsightFace:");
+ if (instance.config.async) {
+ insightfaceRes = ((_p = instance.config.face["insightface"]) == null ? void 0 : _p.enabled) ? predict13(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ } else {
+ instance.state = "run:mobilefacenet";
+ timeStamp = now();
+ insightfaceRes = ((_q = instance.config.face["insightface"]) == null ? void 0 : _q.enabled) ? await predict13(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length) : null;
+ instance.performance.mobilefacenet = Math.trunc(now() - timeStamp);
+ }
+ instance.analyze("End InsightFace:");
+ instance.analyze("Start Description:");
+ if (instance.config.async) {
+ descRes = predict6(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length);
+ } else {
+ instance.state = "run:description";
+ timeStamp = now();
+ descRes = await predict6(faces[i].tensor || tfjs_esm_exports.tensor([]), instance.config, i, faces.length);
+ instance.performance.description = env.perfadd ? (instance.performance.description || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ }
+ instance.analyze("End Description:");
+ if (instance.config.async) {
+ [ageRes, genderRes, emotionRes, mobilefacenetRes, insightfaceRes, descRes, gearRes, antispoofRes, livenessRes] = await Promise.all([ageRes, genderRes, emotionRes, mobilefacenetRes, insightfaceRes, descRes, gearRes, antispoofRes, livenessRes]);
+ }
+ instance.analyze("Finish Face:");
+ if (((_r = instance.config.face["ssrnet"]) == null ? void 0 : _r.enabled) && ageRes && genderRes) {
+ descRes = {
+ ...descRes,
+ age: ageRes.age,
+ gender: genderRes.gender,
+ genderScore: genderRes.genderScore
+ };
+ }
+ if (((_s = instance.config.face.gear) == null ? void 0 : _s.enabled) && gearRes) {
+ descRes = {
+ ...descRes,
+ age: gearRes.age,
+ gender: gearRes.gender,
+ genderScore: gearRes.genderScore,
+ race: gearRes.race
+ };
+ }
+ if (((_t = instance.config.face["mobilefacenet"]) == null ? void 0 : _t.enabled) && mobilefacenetRes) {
+ descRes.descriptor = mobilefacenetRes;
+ }
+ if (((_u = instance.config.face["insightface"]) == null ? void 0 : _u.enabled) && insightfaceRes) {
+ descRes.descriptor = insightfaceRes;
+ }
+ const irisSize = ((_v = instance.config.face.iris) == null ? void 0 : _v.enabled) ? calculateCameraDistance(faces[i], input.shape[2]) : 0;
+ const tensor6 = ((_w = instance.config.face.detector) == null ? void 0 : _w.return) ? tfjs_esm_exports.squeeze(faces[i].tensor) : null;
+ tfjs_esm_exports.dispose(faces[i].tensor);
+ if (faces[i].tensor)
+ delete faces[i].tensor;
+ const res = {
+ ...faces[i],
+ id: i
+ };
+ if (descRes.age)
+ res.age = descRes.age;
+ if (descRes.gender)
+ res.gender = descRes.gender;
+ if (descRes.genderScore)
+ res.genderScore = descRes.genderScore;
+ if (descRes.descriptor)
+ res.embedding = descRes.descriptor;
+ if (descRes.race)
+ res.race = descRes.race;
+ if (emotionRes)
+ res.emotion = emotionRes;
+ if (antispoofRes)
+ res.real = antispoofRes;
+ if (livenessRes)
+ res.live = livenessRes;
+ if (irisSize > 0)
+ res.distance = irisSize;
+ if (rotation)
+ res.rotation = rotation;
+ if (tensor6)
+ res.tensor = tensor6;
+ faceRes.push(res);
+ instance.analyze("End Face");
+ }
+ instance.analyze("End FaceMesh:");
+ if (instance.config.async) {
+ if (instance.performance.face)
+ delete instance.performance.face;
+ if (instance.performance.age)
+ delete instance.performance.age;
+ if (instance.performance.gender)
+ delete instance.performance.gender;
+ if (instance.performance.emotion)
+ delete instance.performance.emotion;
+ }
+ return faceRes;
+};
+
+// src/hand/fingerdef.ts
+var Finger = {
+ thumb: 0,
+ index: 1,
+ middle: 2,
+ ring: 3,
+ pinky: 4,
+ all: [0, 1, 2, 3, 4],
+ nameMapping: { 0: "thumb", 1: "index", 2: "middle", 3: "ring", 4: "pinky" },
+ pointsMapping: {
+ 0: [[0, 1], [1, 2], [2, 3], [3, 4]],
+ 1: [[0, 5], [5, 6], [6, 7], [7, 8]],
+ 2: [[0, 9], [9, 10], [10, 11], [11, 12]],
+ 3: [[0, 13], [13, 14], [14, 15], [15, 16]],
+ 4: [[0, 17], [17, 18], [18, 19], [19, 20]]
+ },
+ getName: (value) => Finger.nameMapping[value],
+ getPoints: (value) => Finger.pointsMapping[value]
+};
+var FingerCurl = {
+ none: 0,
+ half: 1,
+ full: 2,
+ nameMapping: { 0: "none", 1: "half", 2: "full" },
+ getName: (value) => FingerCurl.nameMapping[value]
+};
+var FingerDirection = {
+ verticalUp: 0,
+ verticalDown: 1,
+ horizontalLeft: 2,
+ horizontalRight: 3,
+ diagonalUpRight: 4,
+ diagonalUpLeft: 5,
+ diagonalDownRight: 6,
+ diagonalDownLeft: 7,
+ nameMapping: { 0: "verticalUp", 1: "verticalDown", 2: "horizontalLeft", 3: "horizontalRight", 4: "diagonalUpRight", 5: "diagonalUpLeft", 6: "diagonalDownRight", 7: "diagonalDownLeft" },
+ getName: (value) => FingerDirection.nameMapping[value]
+};
+var FingerGesture = class {
+ constructor(name) {
+ __publicField(this, "name");
+ __publicField(this, "curls");
+ __publicField(this, "directions");
+ __publicField(this, "weights");
+ __publicField(this, "weightsRelative");
+ this.name = name;
+ this.curls = {};
+ this.directions = {};
+ this.weights = [1, 1, 1, 1, 1];
+ this.weightsRelative = [1, 1, 1, 1, 1];
+ }
+ curl(finger, curl, confidence) {
+ if (typeof this.curls[finger] === "undefined")
+ this.curls[finger] = [];
+ this.curls[finger].push([curl, confidence]);
+ }
+ direction(finger, position, confidence) {
+ if (!this.directions[finger])
+ this.directions[finger] = [];
+ this.directions[finger].push([position, confidence]);
+ }
+ weight(finger, weight) {
+ this.weights[finger] = weight;
+ const total = this.weights.reduce((a, b) => a + b, 0);
+ this.weightsRelative = this.weights.map((el) => el * 5 / total);
+ }
+ matchAgainst(detectedCurls, detectedDirections) {
+ let confidence = 0;
+ for (const fingerIdx in detectedCurls) {
+ const detectedCurl = detectedCurls[fingerIdx];
+ const expectedCurls = this.curls[fingerIdx];
+ if (typeof expectedCurls === "undefined") {
+ confidence += this.weightsRelative[fingerIdx];
+ continue;
+ }
+ for (const [expectedCurl, score] of expectedCurls) {
+ if (detectedCurl === expectedCurl) {
+ confidence += score * this.weightsRelative[fingerIdx];
+ break;
+ }
+ }
+ }
+ for (const fingerIdx in detectedDirections) {
+ const detectedDirection = detectedDirections[fingerIdx];
+ const expectedDirections = this.directions[fingerIdx];
+ if (typeof expectedDirections === "undefined") {
+ confidence += this.weightsRelative[fingerIdx];
+ continue;
+ }
+ for (const [expectedDirection, score] of expectedDirections) {
+ if (detectedDirection === expectedDirection) {
+ confidence += score * this.weightsRelative[fingerIdx];
+ break;
+ }
+ }
+ }
+ return confidence / 10;
+ }
+};
+
+// src/hand/fingergesture.ts
+var { thumb, index, middle, ring, pinky } = Finger;
+var { none, half, full } = FingerCurl;
+var { verticalUp, verticalDown, horizontalLeft, horizontalRight, diagonalUpRight, diagonalUpLeft, diagonalDownRight, diagonalDownLeft } = FingerDirection;
+var ThumbsUp = new FingerGesture("thumbs up");
+ThumbsUp.curl(thumb, none, 1);
+ThumbsUp.direction(thumb, verticalUp, 1);
+ThumbsUp.direction(thumb, diagonalUpLeft, 0.25);
+ThumbsUp.direction(thumb, diagonalUpRight, 0.25);
+for (const finger of [Finger.index, Finger.middle, Finger.ring, Finger.pinky]) {
+ ThumbsUp.curl(finger, full, 1);
+ ThumbsUp.direction(finger, horizontalLeft, 1);
+ ThumbsUp.direction(finger, horizontalRight, 1);
+}
+var Victory = new FingerGesture("victory");
+Victory.curl(thumb, half, 0.5);
+Victory.curl(thumb, none, 0.5);
+Victory.direction(thumb, verticalUp, 1);
+Victory.direction(thumb, diagonalUpLeft, 1);
+Victory.curl(index, none, 1);
+Victory.direction(index, verticalUp, 0.75);
+Victory.direction(index, diagonalUpLeft, 1);
+Victory.curl(middle, none, 1);
+Victory.direction(middle, verticalUp, 1);
+Victory.direction(middle, diagonalUpLeft, 0.75);
+Victory.curl(ring, full, 1);
+Victory.direction(ring, verticalUp, 0.2);
+Victory.direction(ring, diagonalUpLeft, 1);
+Victory.direction(ring, horizontalLeft, 0.2);
+Victory.curl(pinky, full, 1);
+Victory.direction(pinky, verticalUp, 0.2);
+Victory.direction(pinky, diagonalUpLeft, 1);
+Victory.direction(pinky, horizontalLeft, 0.2);
+Victory.weight(index, 2);
+Victory.weight(middle, 2);
+var Point = new FingerGesture("point");
+Point.curl(thumb, full, 1);
+Point.curl(index, none, 0.5);
+Point.curl(middle, full, 0.5);
+Point.curl(ring, full, 0.5);
+Point.curl(pinky, full, 0.5);
+Point.weight(index, 2);
+Point.weight(middle, 2);
+var MiddleFinger = new FingerGesture("middle finger");
+MiddleFinger.curl(thumb, none, 1);
+MiddleFinger.curl(index, full, 0.5);
+MiddleFinger.curl(middle, full, 0.5);
+MiddleFinger.curl(ring, full, 0.5);
+MiddleFinger.curl(pinky, full, 0.5);
+MiddleFinger.weight(index, 2);
+MiddleFinger.weight(middle, 2);
+var OpenPalm = new FingerGesture("open palm");
+OpenPalm.curl(thumb, none, 0.75);
+OpenPalm.curl(index, none, 0.75);
+OpenPalm.curl(middle, none, 0.75);
+OpenPalm.curl(ring, none, 0.75);
+OpenPalm.curl(pinky, none, 0.75);
+var fingergesture_default = [ThumbsUp, Victory, Point, MiddleFinger, OpenPalm];
+
+// src/hand/fingerpose.ts
+var minConfidence = 0.7;
+var options3 = {
+ HALF_CURL_START_LIMIT: 60,
+ NO_CURL_START_LIMIT: 130,
+ DISTANCE_VOTE_POWER: 1.1,
+ SINGLE_ANGLE_VOTE_POWER: 0.9,
+ TOTAL_ANGLE_VOTE_POWER: 1.6
+};
+function calculateSlope(point1x, point1y, point2x, point2y) {
+ const value = (point1y - point2y) / (point1x - point2x);
+ let slope = Math.atan(value) * 180 / Math.PI;
+ if (slope <= 0)
+ slope = -slope;
+ else if (slope > 0)
+ slope = 180 - slope;
+ return slope;
+}
+function getSlopes(point1, point2) {
+ if (!point1 || !point2)
+ return [0, 0];
+ const slopeXY = calculateSlope(point1[0], point1[1], point2[0], point2[1]);
+ if (point1.length === 2)
+ return slopeXY;
+ const slopeYZ = calculateSlope(point1[1], point1[2], point2[1], point2[2]);
+ return [slopeXY, slopeYZ];
+}
+function angleOrientationAt(angle, weightageAt = 1) {
+ let isVertical = 0;
+ let isDiagonal = 0;
+ let isHorizontal = 0;
+ if (angle >= 75 && angle <= 105)
+ isVertical = 1 * weightageAt;
+ else if (angle >= 25 && angle <= 155)
+ isDiagonal = 1 * weightageAt;
+ else
+ isHorizontal = 1 * weightageAt;
+ return [isVertical, isDiagonal, isHorizontal];
+}
+function estimateFingerCurl(startPoint, midPoint, endPoint) {
+ const start_mid_x_dist = startPoint[0] - midPoint[0];
+ const start_end_x_dist = startPoint[0] - endPoint[0];
+ const mid_end_x_dist = midPoint[0] - endPoint[0];
+ const start_mid_y_dist = startPoint[1] - midPoint[1];
+ const start_end_y_dist = startPoint[1] - endPoint[1];
+ const mid_end_y_dist = midPoint[1] - endPoint[1];
+ const start_mid_z_dist = startPoint[2] - midPoint[2];
+ const start_end_z_dist = startPoint[2] - endPoint[2];
+ const mid_end_z_dist = midPoint[2] - endPoint[2];
+ const start_mid_dist = Math.sqrt(start_mid_x_dist * start_mid_x_dist + start_mid_y_dist * start_mid_y_dist + start_mid_z_dist * start_mid_z_dist);
+ const start_end_dist = Math.sqrt(start_end_x_dist * start_end_x_dist + start_end_y_dist * start_end_y_dist + start_end_z_dist * start_end_z_dist);
+ const mid_end_dist = Math.sqrt(mid_end_x_dist * mid_end_x_dist + mid_end_y_dist * mid_end_y_dist + mid_end_z_dist * mid_end_z_dist);
+ let cos_in = (mid_end_dist * mid_end_dist + start_mid_dist * start_mid_dist - start_end_dist * start_end_dist) / (2 * mid_end_dist * start_mid_dist);
+ if (cos_in > 1)
+ cos_in = 1;
+ else if (cos_in < -1)
+ cos_in = -1;
+ let angleOfCurve = Math.acos(cos_in);
+ angleOfCurve = 57.2958 * angleOfCurve % 180;
+ let fingerCurl;
+ if (angleOfCurve > options3.NO_CURL_START_LIMIT)
+ fingerCurl = FingerCurl.none;
+ else if (angleOfCurve > options3.HALF_CURL_START_LIMIT)
+ fingerCurl = FingerCurl.half;
+ else
+ fingerCurl = FingerCurl.full;
+ return fingerCurl;
+}
+function estimateHorizontalDirection(start_end_x_dist, start_mid_x_dist, mid_end_x_dist, max_dist_x) {
+ let estimatedDirection;
+ if (max_dist_x === Math.abs(start_end_x_dist)) {
+ if (start_end_x_dist > 0)
+ estimatedDirection = FingerDirection.horizontalLeft;
+ else
+ estimatedDirection = FingerDirection.horizontalRight;
+ } else if (max_dist_x === Math.abs(start_mid_x_dist)) {
+ if (start_mid_x_dist > 0)
+ estimatedDirection = FingerDirection.horizontalLeft;
+ else
+ estimatedDirection = FingerDirection.horizontalRight;
+ } else {
+ if (mid_end_x_dist > 0)
+ estimatedDirection = FingerDirection.horizontalLeft;
+ else
+ estimatedDirection = FingerDirection.horizontalRight;
+ }
+ return estimatedDirection;
+}
+function estimateVerticalDirection(start_end_y_dist, start_mid_y_dist, mid_end_y_dist, max_dist_y) {
+ let estimatedDirection;
+ if (max_dist_y === Math.abs(start_end_y_dist)) {
+ if (start_end_y_dist < 0)
+ estimatedDirection = FingerDirection.verticalDown;
+ else
+ estimatedDirection = FingerDirection.verticalUp;
+ } else if (max_dist_y === Math.abs(start_mid_y_dist)) {
+ if (start_mid_y_dist < 0)
+ estimatedDirection = FingerDirection.verticalDown;
+ else
+ estimatedDirection = FingerDirection.verticalUp;
+ } else {
+ if (mid_end_y_dist < 0)
+ estimatedDirection = FingerDirection.verticalDown;
+ else
+ estimatedDirection = FingerDirection.verticalUp;
+ }
+ return estimatedDirection;
+}
+function estimateDiagonalDirection(start_end_y_dist, start_mid_y_dist, mid_end_y_dist, max_dist_y, start_end_x_dist, start_mid_x_dist, mid_end_x_dist, max_dist_x) {
+ let estimatedDirection;
+ const reqd_vertical_direction = estimateVerticalDirection(start_end_y_dist, start_mid_y_dist, mid_end_y_dist, max_dist_y);
+ const reqd_horizontal_direction = estimateHorizontalDirection(start_end_x_dist, start_mid_x_dist, mid_end_x_dist, max_dist_x);
+ if (reqd_vertical_direction === FingerDirection.verticalUp) {
+ if (reqd_horizontal_direction === FingerDirection.horizontalLeft)
+ estimatedDirection = FingerDirection.diagonalUpLeft;
+ else
+ estimatedDirection = FingerDirection.diagonalUpRight;
+ } else {
+ if (reqd_horizontal_direction === FingerDirection.horizontalLeft)
+ estimatedDirection = FingerDirection.diagonalDownLeft;
+ else
+ estimatedDirection = FingerDirection.diagonalDownRight;
+ }
+ return estimatedDirection;
+}
+function calculateFingerDirection(startPoint, midPoint, endPoint, fingerSlopes) {
+ const start_mid_x_dist = startPoint[0] - midPoint[0];
+ const start_end_x_dist = startPoint[0] - endPoint[0];
+ const mid_end_x_dist = midPoint[0] - endPoint[0];
+ const start_mid_y_dist = startPoint[1] - midPoint[1];
+ const start_end_y_dist = startPoint[1] - endPoint[1];
+ const mid_end_y_dist = midPoint[1] - endPoint[1];
+ const max_dist_x = Math.max(Math.abs(start_mid_x_dist), Math.abs(start_end_x_dist), Math.abs(mid_end_x_dist));
+ const max_dist_y = Math.max(Math.abs(start_mid_y_dist), Math.abs(start_end_y_dist), Math.abs(mid_end_y_dist));
+ let voteVertical = 0;
+ let voteDiagonal = 0;
+ let voteHorizontal = 0;
+ const start_end_x_y_dist_ratio = max_dist_y / (max_dist_x + 1e-5);
+ if (start_end_x_y_dist_ratio > 1.5)
+ voteVertical += options3.DISTANCE_VOTE_POWER;
+ else if (start_end_x_y_dist_ratio > 0.66)
+ voteDiagonal += options3.DISTANCE_VOTE_POWER;
+ else
+ voteHorizontal += options3.DISTANCE_VOTE_POWER;
+ const start_mid_dist = Math.sqrt(start_mid_x_dist * start_mid_x_dist + start_mid_y_dist * start_mid_y_dist);
+ const start_end_dist = Math.sqrt(start_end_x_dist * start_end_x_dist + start_end_y_dist * start_end_y_dist);
+ const mid_end_dist = Math.sqrt(mid_end_x_dist * mid_end_x_dist + mid_end_y_dist * mid_end_y_dist);
+ const max_dist = Math.max(start_mid_dist, start_end_dist, mid_end_dist);
+ let calc_start_point_x = startPoint[0];
+ let calc_start_point_y = startPoint[1];
+ let calc_end_point_x = endPoint[0];
+ let calc_end_point_y = endPoint[1];
+ if (max_dist === start_mid_dist) {
+ calc_end_point_x = endPoint[0];
+ calc_end_point_y = endPoint[1];
+ } else if (max_dist === mid_end_dist) {
+ calc_start_point_x = midPoint[0];
+ calc_start_point_y = midPoint[1];
+ }
+ const calcStartPoint = [calc_start_point_x, calc_start_point_y];
+ const calcEndPoint = [calc_end_point_x, calc_end_point_y];
+ const totalAngle = getSlopes(calcStartPoint, calcEndPoint);
+ const votes = angleOrientationAt(totalAngle, options3.TOTAL_ANGLE_VOTE_POWER);
+ voteVertical += votes[0];
+ voteDiagonal += votes[1];
+ voteHorizontal += votes[2];
+ for (const fingerSlope of fingerSlopes) {
+ const fingerVotes = angleOrientationAt(fingerSlope, options3.SINGLE_ANGLE_VOTE_POWER);
+ voteVertical += fingerVotes[0];
+ voteDiagonal += fingerVotes[1];
+ voteHorizontal += fingerVotes[2];
+ }
+ let estimatedDirection;
+ if (voteVertical === Math.max(voteVertical, voteDiagonal, voteHorizontal)) {
+ estimatedDirection = estimateVerticalDirection(start_end_y_dist, start_mid_y_dist, mid_end_y_dist, max_dist_y);
+ } else if (voteHorizontal === Math.max(voteDiagonal, voteHorizontal)) {
+ estimatedDirection = estimateHorizontalDirection(start_end_x_dist, start_mid_x_dist, mid_end_x_dist, max_dist_x);
+ } else {
+ estimatedDirection = estimateDiagonalDirection(start_end_y_dist, start_mid_y_dist, mid_end_y_dist, max_dist_y, start_end_x_dist, start_mid_x_dist, mid_end_x_dist, max_dist_x);
+ }
+ return estimatedDirection;
+}
+function estimate(landmarks) {
+ const slopesXY = [];
+ const slopesYZ = [];
+ const fingerCurls = [];
+ const fingerDirections = [];
+ if (!landmarks)
+ return { curls: fingerCurls, directions: fingerDirections };
+ for (const finger of Finger.all) {
+ const points = Finger.getPoints(finger);
+ const slopeAtXY = [];
+ const slopeAtYZ = [];
+ for (const point2 of points) {
+ const point1 = landmarks[point2[0]];
+ const point22 = landmarks[point2[1]];
+ const slopes = getSlopes(point1, point22);
+ const slopeXY = slopes[0];
+ const slopeYZ = slopes[1];
+ slopeAtXY.push(slopeXY);
+ slopeAtYZ.push(slopeYZ);
+ }
+ slopesXY.push(slopeAtXY);
+ slopesYZ.push(slopeAtYZ);
+ }
+ for (const finger of Finger.all) {
+ const pointIndexAt = finger === Finger.thumb ? 1 : 0;
+ const fingerPointsAt = Finger.getPoints(finger);
+ const startPoint = landmarks[fingerPointsAt[pointIndexAt][0]];
+ const midPoint = landmarks[fingerPointsAt[pointIndexAt + 1][1]];
+ const endPoint = landmarks[fingerPointsAt[3][1]];
+ const fingerCurled = estimateFingerCurl(startPoint, midPoint, endPoint);
+ const fingerPosition = calculateFingerDirection(startPoint, midPoint, endPoint, slopesXY[finger].slice(pointIndexAt));
+ fingerCurls[finger] = fingerCurled;
+ fingerDirections[finger] = fingerPosition;
+ }
+ return { curls: fingerCurls, directions: fingerDirections };
+}
+function analyze(keypoints) {
+ if (!keypoints || keypoints.length === 0)
+ return null;
+ const estimatorRes = estimate(keypoints);
+ const landmarks = {};
+ for (const fingerIdx of Finger.all) {
+ landmarks[Finger.getName(fingerIdx)] = {
+ curl: FingerCurl.getName(estimatorRes.curls[fingerIdx]),
+ direction: FingerDirection.getName(estimatorRes.directions[fingerIdx])
+ };
+ }
+ return landmarks;
+}
+function match(keypoints) {
+ const poses = [];
+ if (!keypoints || keypoints.length === 0)
+ return poses;
+ const estimatorRes = estimate(keypoints);
+ for (const gesture2 of fingergesture_default) {
+ const confidence = gesture2.matchAgainst(estimatorRes.curls, estimatorRes.directions);
+ if (confidence >= minConfidence)
+ poses.push({ name: gesture2.name, confidence });
+ }
+ return poses;
+}
+
+// src/gesture/gesture.ts
+var body2 = (res) => {
+ if (!res)
+ return [];
+ const gestures = [];
+ for (let i = 0; i < res.length; i++) {
+ const leftWrist = res[i].keypoints.find((a) => a.part === "leftWrist");
+ const rightWrist = res[i].keypoints.find((a) => a.part === "rightWrist");
+ const nose = res[i].keypoints.find((a) => a.part === "nose");
+ if (nose && leftWrist && rightWrist && leftWrist.position[1] < nose.position[1] && rightWrist.position[1] < nose.position[1])
+ gestures.push({ body: i, gesture: "i give up" });
+ else if (nose && leftWrist && leftWrist.position[1] < nose.position[1])
+ gestures.push({ body: i, gesture: "raise left hand" });
+ else if (nose && rightWrist && rightWrist.position[1] < nose.position[1])
+ gestures.push({ body: i, gesture: "raise right hand" });
+ const leftShoulder = res[i].keypoints.find((a) => a.part === "leftShoulder");
+ const rightShoulder = res[i].keypoints.find((a) => a.part === "rightShoulder");
+ if (leftShoulder && rightShoulder && Math.abs(leftShoulder.positionRaw[1] - rightShoulder.positionRaw[1]) > 0.1) {
+ gestures.push({ body: i, gesture: `leaning ${leftShoulder.position[1] > rightShoulder.position[1] ? "left" : "right"}` });
+ }
+ }
+ return gestures;
+};
+var face2 = (res) => {
+ if (!res)
+ return [];
+ const gestures = [];
+ for (let i = 0; i < res.length; i++) {
+ if (res[i].mesh && res[i].mesh.length > 450) {
+ const zDiff = (res[i].mesh[33][2] || 0) - (res[i].mesh[263][2] || 0);
+ const xDiff = res[i].mesh[33][0] - res[i].mesh[263][0];
+ if (Math.abs(zDiff / xDiff) <= 0.15)
+ gestures.push({ face: i, gesture: "facing center" });
+ else
+ gestures.push({ face: i, gesture: `facing ${zDiff < 0 ? "left" : "right"}` });
+ const openLeft = Math.abs(res[i].mesh[374][1] - res[i].mesh[386][1]) / Math.abs(res[i].mesh[443][1] - res[i].mesh[450][1]);
+ if (openLeft < 0.2)
+ gestures.push({ face: i, gesture: "blink left eye" });
+ const openRight = Math.abs(res[i].mesh[145][1] - res[i].mesh[159][1]) / Math.abs(res[i].mesh[223][1] - res[i].mesh[230][1]);
+ if (openRight < 0.2)
+ gestures.push({ face: i, gesture: "blink right eye" });
+ const mouthOpen = Math.min(100, 500 * Math.abs(res[i].mesh[13][1] - res[i].mesh[14][1]) / Math.abs(res[i].mesh[10][1] - res[i].mesh[152][1]));
+ if (mouthOpen > 10)
+ gestures.push({ face: i, gesture: `mouth ${Math.trunc(mouthOpen)}% open` });
+ const chinDepth = res[i].mesh[152][2] || 0;
+ if (Math.abs(chinDepth) > 10)
+ gestures.push({ face: i, gesture: `head ${chinDepth < 0 ? "up" : "down"}` });
+ }
+ }
+ return gestures;
+};
+var iris2 = (res) => {
+ var _a, _b, _c, _d;
+ if (!res)
+ return [];
+ const gestures = [];
+ for (let i = 0; i < res.length; i++) {
+ if (!((_b = (_a = res[i].annotations) == null ? void 0 : _a.leftEyeIris) == null ? void 0 : _b[0]) || !((_d = (_c = res[i].annotations) == null ? void 0 : _c.rightEyeIris) == null ? void 0 : _d[0]))
+ continue;
+ const sizeXLeft = res[i].annotations.leftEyeIris[3][0] - res[i].annotations.leftEyeIris[1][0];
+ const sizeYLeft = res[i].annotations.leftEyeIris[4][1] - res[i].annotations.leftEyeIris[2][1];
+ const areaLeft = Math.abs(sizeXLeft * sizeYLeft);
+ const sizeXRight = res[i].annotations.rightEyeIris[3][0] - res[i].annotations.rightEyeIris[1][0];
+ const sizeYRight = res[i].annotations.rightEyeIris[4][1] - res[i].annotations.rightEyeIris[2][1];
+ const areaRight = Math.abs(sizeXRight * sizeYRight);
+ let center = false;
+ const difference = Math.abs(areaLeft - areaRight) / Math.max(areaLeft, areaRight);
+ if (difference < 0.25) {
+ center = true;
+ gestures.push({ iris: i, gesture: "facing center" });
+ }
+ const leftIrisCenterX = Math.abs(res[i].mesh[263][0] - res[i].annotations.leftEyeIris[0][0]) / res[i].box[2];
+ const rightIrisCenterX = Math.abs(res[i].mesh[33][0] - res[i].annotations.rightEyeIris[0][0]) / res[i].box[2];
+ if (leftIrisCenterX > 0.06 || rightIrisCenterX > 0.06)
+ center = false;
+ if (leftIrisCenterX > rightIrisCenterX) {
+ if (leftIrisCenterX > 0.05)
+ gestures.push({ iris: i, gesture: "looking right" });
+ } else {
+ if (rightIrisCenterX > 0.05)
+ gestures.push({ iris: i, gesture: "looking left" });
+ }
+ const rightIrisCenterY = Math.abs(res[i].mesh[145][1] - res[i].annotations.rightEyeIris[0][1]) / res[i].box[3];
+ const leftIrisCenterY = Math.abs(res[i].mesh[374][1] - res[i].annotations.leftEyeIris[0][1]) / res[i].box[3];
+ if (leftIrisCenterY < 0.01 || rightIrisCenterY < 0.01 || leftIrisCenterY > 0.022 || rightIrisCenterY > 0.022)
+ center = false;
+ if (leftIrisCenterY < 0.01 || rightIrisCenterY < 0.01)
+ gestures.push({ iris: i, gesture: "looking down" });
+ if (leftIrisCenterY > 0.022 || rightIrisCenterY > 0.022)
+ gestures.push({ iris: i, gesture: "looking up" });
+ if (center)
+ gestures.push({ iris: i, gesture: "looking center" });
+ }
+ return gestures;
+};
+var hand2 = (res) => {
+ if (!res)
+ return [];
+ const gestures = [];
+ for (let i = 0; i < res.length; i++) {
+ const fingers = [];
+ if (res[i].annotations) {
+ for (const [finger, pos] of Object.entries(res[i].annotations)) {
+ if (finger !== "palmBase" && Array.isArray(pos) && pos[0])
+ fingers.push({ name: finger.toLowerCase(), position: pos[0] });
+ }
+ }
+ if (fingers && fingers.length > 0) {
+ const closest = fingers.reduce((best, a) => (best.position[2] || 0) < (a.position[2] || 0) ? best : a);
+ gestures.push({ hand: i, gesture: `${closest.name} forward` });
+ const highest = fingers.reduce((best, a) => best.position[1] < a.position[1] ? best : a);
+ gestures.push({ hand: i, gesture: `${highest.name} up` });
+ }
+ if (res[i].keypoints) {
+ const poses = match(res[i].keypoints);
+ for (const pose of poses)
+ gestures.push({ hand: i, gesture: pose.name });
+ }
+ }
+ return gestures;
+};
+
+// src/hand/handposeutil.ts
+function getBoxSize2(box) {
+ return [
+ Math.abs(box.endPoint[0] - box.startPoint[0]),
+ Math.abs(box.endPoint[1] - box.startPoint[1])
+ ];
+}
+function getBoxCenter2(box) {
+ return [
+ box.startPoint[0] + (box.endPoint[0] - box.startPoint[0]) / 2,
+ box.startPoint[1] + (box.endPoint[1] - box.startPoint[1]) / 2
+ ];
+}
+function cutBoxFromImageAndResize(box, image28, cropSize) {
+ const h = image28.shape[1];
+ const w = image28.shape[2];
+ const boxes = [[
+ box.startPoint[1] / h,
+ box.startPoint[0] / w,
+ box.endPoint[1] / h,
+ box.endPoint[0] / w
+ ]];
+ return tfjs_esm_exports.image.cropAndResize(image28, boxes, [0], cropSize);
+}
+function scaleBoxCoordinates2(box, factor) {
+ const startPoint = [box.startPoint[0] * factor[0], box.startPoint[1] * factor[1]];
+ const endPoint = [box.endPoint[0] * factor[0], box.endPoint[1] * factor[1]];
+ const palmLandmarks = box.palmLandmarks.map((coord) => {
+ const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
+ return scaledCoord;
+ });
+ return { startPoint, endPoint, palmLandmarks, confidence: box.confidence };
+}
+function enlargeBox2(box, factor = 1.5) {
+ const center = getBoxCenter2(box);
+ const size2 = getBoxSize2(box);
+ const newHalfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
+ const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
+ const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
+ return { startPoint, endPoint, palmLandmarks: box.palmLandmarks };
+}
+function squarifyBox2(box) {
+ const centers = getBoxCenter2(box);
+ const size2 = getBoxSize2(box);
+ const maxEdge = Math.max(...size2);
+ const halfSize = maxEdge / 2;
+ const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
+ const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
+ return { startPoint, endPoint, palmLandmarks: box.palmLandmarks };
+}
+function normalizeRadians2(angle) {
+ return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
+}
+function computeRotation2(point1, point2) {
+ const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
+ return normalizeRadians2(radians);
+}
+var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
+function dot2(v1, v2) {
+ let product = 0;
+ for (let i = 0; i < v1.length; i++) {
+ product += v1[i] * v2[i];
+ }
+ return product;
+}
+function getColumnFrom2DArr2(arr, columnIndex) {
+ const column = [];
+ for (let i = 0; i < arr.length; i++) {
+ column.push(arr[i][columnIndex]);
+ }
+ return column;
+}
+function multiplyTransformMatrices2(mat1, mat2) {
+ const product = [];
+ const size2 = mat1.length;
+ for (let row = 0; row < size2; row++) {
+ product.push([]);
+ for (let col = 0; col < size2; col++) {
+ product[row].push(dot2(mat1[row], getColumnFrom2DArr2(mat2, col)));
+ }
+ }
+ return product;
+}
+function buildRotationMatrix2(rotation, center) {
+ const cosA = Math.cos(rotation);
+ const sinA = Math.sin(rotation);
+ const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
+ const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
+ const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
+ const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
+ return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
+}
+function invertTransformMatrix2(matrix) {
+ const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
+ const translationComponent = [matrix[0][2], matrix[1][2]];
+ const invertedTranslation = [
+ -dot2(rotationComponent[0], translationComponent),
+ -dot2(rotationComponent[1], translationComponent)
+ ];
+ return [
+ rotationComponent[0].concat(invertedTranslation[0]),
+ rotationComponent[1].concat(invertedTranslation[1]),
+ [0, 0, 1]
+ ];
+}
+function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
+ return [
+ dot2(homogeneousCoordinate, rotationMatrix[0]),
+ dot2(homogeneousCoordinate, rotationMatrix[1])
+ ];
+}
+
+// src/hand/handposeanchors.ts
+var anchors2 = [
+ { x: 0.015625, y: 0.015625 },
+ { x: 0.015625, y: 0.015625 },
+ { x: 0.046875, y: 0.015625 },
+ { x: 0.046875, y: 0.015625 },
+ { x: 0.078125, y: 0.015625 },
+ { x: 0.078125, y: 0.015625 },
+ { x: 0.109375, y: 0.015625 },
+ { x: 0.109375, y: 0.015625 },
+ { x: 0.140625, y: 0.015625 },
+ { x: 0.140625, y: 0.015625 },
+ { x: 0.171875, y: 0.015625 },
+ { x: 0.171875, y: 0.015625 },
+ { x: 0.203125, y: 0.015625 },
+ { x: 0.203125, y: 0.015625 },
+ { x: 0.234375, y: 0.015625 },
+ { x: 0.234375, y: 0.015625 },
+ { x: 0.265625, y: 0.015625 },
+ { x: 0.265625, y: 0.015625 },
+ { x: 0.296875, y: 0.015625 },
+ { x: 0.296875, y: 0.015625 },
+ { x: 0.328125, y: 0.015625 },
+ { x: 0.328125, y: 0.015625 },
+ { x: 0.359375, y: 0.015625 },
+ { x: 0.359375, y: 0.015625 },
+ { x: 0.390625, y: 0.015625 },
+ { x: 0.390625, y: 0.015625 },
+ { x: 0.421875, y: 0.015625 },
+ { x: 0.421875, y: 0.015625 },
+ { x: 0.453125, y: 0.015625 },
+ { x: 0.453125, y: 0.015625 },
+ { x: 0.484375, y: 0.015625 },
+ { x: 0.484375, y: 0.015625 },
+ { x: 0.515625, y: 0.015625 },
+ { x: 0.515625, y: 0.015625 },
+ { x: 0.546875, y: 0.015625 },
+ { x: 0.546875, y: 0.015625 },
+ { x: 0.578125, y: 0.015625 },
+ { x: 0.578125, y: 0.015625 },
+ { x: 0.609375, y: 0.015625 },
+ { x: 0.609375, y: 0.015625 },
+ { x: 0.640625, y: 0.015625 },
+ { x: 0.640625, y: 0.015625 },
+ { x: 0.671875, y: 0.015625 },
+ { x: 0.671875, y: 0.015625 },
+ { x: 0.703125, y: 0.015625 },
+ { x: 0.703125, y: 0.015625 },
+ { x: 0.734375, y: 0.015625 },
+ { x: 0.734375, y: 0.015625 },
+ { x: 0.765625, y: 0.015625 },
+ { x: 0.765625, y: 0.015625 },
+ { x: 0.796875, y: 0.015625 },
+ { x: 0.796875, y: 0.015625 },
+ { x: 0.828125, y: 0.015625 },
+ { x: 0.828125, y: 0.015625 },
+ { x: 0.859375, y: 0.015625 },
+ { x: 0.859375, y: 0.015625 },
+ { x: 0.890625, y: 0.015625 },
+ { x: 0.890625, y: 0.015625 },
+ { x: 0.921875, y: 0.015625 },
+ { x: 0.921875, y: 0.015625 },
+ { x: 0.953125, y: 0.015625 },
+ { x: 0.953125, y: 0.015625 },
+ { x: 0.984375, y: 0.015625 },
+ { x: 0.984375, y: 0.015625 },
+ { x: 0.015625, y: 0.046875 },
+ { x: 0.015625, y: 0.046875 },
+ { x: 0.046875, y: 0.046875 },
+ { x: 0.046875, y: 0.046875 },
+ { x: 0.078125, y: 0.046875 },
+ { x: 0.078125, y: 0.046875 },
+ { x: 0.109375, y: 0.046875 },
+ { x: 0.109375, y: 0.046875 },
+ { x: 0.140625, y: 0.046875 },
+ { x: 0.140625, y: 0.046875 },
+ { x: 0.171875, y: 0.046875 },
+ { x: 0.171875, y: 0.046875 },
+ { x: 0.203125, y: 0.046875 },
+ { x: 0.203125, y: 0.046875 },
+ { x: 0.234375, y: 0.046875 },
+ { x: 0.234375, y: 0.046875 },
+ { x: 0.265625, y: 0.046875 },
+ { x: 0.265625, y: 0.046875 },
+ { x: 0.296875, y: 0.046875 },
+ { x: 0.296875, y: 0.046875 },
+ { x: 0.328125, y: 0.046875 },
+ { x: 0.328125, y: 0.046875 },
+ { x: 0.359375, y: 0.046875 },
+ { x: 0.359375, y: 0.046875 },
+ { x: 0.390625, y: 0.046875 },
+ { x: 0.390625, y: 0.046875 },
+ { x: 0.421875, y: 0.046875 },
+ { x: 0.421875, y: 0.046875 },
+ { x: 0.453125, y: 0.046875 },
+ { x: 0.453125, y: 0.046875 },
+ { x: 0.484375, y: 0.046875 },
+ { x: 0.484375, y: 0.046875 },
+ { x: 0.515625, y: 0.046875 },
+ { x: 0.515625, y: 0.046875 },
+ { x: 0.546875, y: 0.046875 },
+ { x: 0.546875, y: 0.046875 },
+ { x: 0.578125, y: 0.046875 },
+ { x: 0.578125, y: 0.046875 },
+ { x: 0.609375, y: 0.046875 },
+ { x: 0.609375, y: 0.046875 },
+ { x: 0.640625, y: 0.046875 },
+ { x: 0.640625, y: 0.046875 },
+ { x: 0.671875, y: 0.046875 },
+ { x: 0.671875, y: 0.046875 },
+ { x: 0.703125, y: 0.046875 },
+ { x: 0.703125, y: 0.046875 },
+ { x: 0.734375, y: 0.046875 },
+ { x: 0.734375, y: 0.046875 },
+ { x: 0.765625, y: 0.046875 },
+ { x: 0.765625, y: 0.046875 },
+ { x: 0.796875, y: 0.046875 },
+ { x: 0.796875, y: 0.046875 },
+ { x: 0.828125, y: 0.046875 },
+ { x: 0.828125, y: 0.046875 },
+ { x: 0.859375, y: 0.046875 },
+ { x: 0.859375, y: 0.046875 },
+ { x: 0.890625, y: 0.046875 },
+ { x: 0.890625, y: 0.046875 },
+ { x: 0.921875, y: 0.046875 },
+ { x: 0.921875, y: 0.046875 },
+ { x: 0.953125, y: 0.046875 },
+ { x: 0.953125, y: 0.046875 },
+ { x: 0.984375, y: 0.046875 },
+ { x: 0.984375, y: 0.046875 },
+ { x: 0.015625, y: 0.078125 },
+ { x: 0.015625, y: 0.078125 },
+ { x: 0.046875, y: 0.078125 },
+ { x: 0.046875, y: 0.078125 },
+ { x: 0.078125, y: 0.078125 },
+ { x: 0.078125, y: 0.078125 },
+ { x: 0.109375, y: 0.078125 },
+ { x: 0.109375, y: 0.078125 },
+ { x: 0.140625, y: 0.078125 },
+ { x: 0.140625, y: 0.078125 },
+ { x: 0.171875, y: 0.078125 },
+ { x: 0.171875, y: 0.078125 },
+ { x: 0.203125, y: 0.078125 },
+ { x: 0.203125, y: 0.078125 },
+ { x: 0.234375, y: 0.078125 },
+ { x: 0.234375, y: 0.078125 },
+ { x: 0.265625, y: 0.078125 },
+ { x: 0.265625, y: 0.078125 },
+ { x: 0.296875, y: 0.078125 },
+ { x: 0.296875, y: 0.078125 },
+ { x: 0.328125, y: 0.078125 },
+ { x: 0.328125, y: 0.078125 },
+ { x: 0.359375, y: 0.078125 },
+ { x: 0.359375, y: 0.078125 },
+ { x: 0.390625, y: 0.078125 },
+ { x: 0.390625, y: 0.078125 },
+ { x: 0.421875, y: 0.078125 },
+ { x: 0.421875, y: 0.078125 },
+ { x: 0.453125, y: 0.078125 },
+ { x: 0.453125, y: 0.078125 },
+ { x: 0.484375, y: 0.078125 },
+ { x: 0.484375, y: 0.078125 },
+ { x: 0.515625, y: 0.078125 },
+ { x: 0.515625, y: 0.078125 },
+ { x: 0.546875, y: 0.078125 },
+ { x: 0.546875, y: 0.078125 },
+ { x: 0.578125, y: 0.078125 },
+ { x: 0.578125, y: 0.078125 },
+ { x: 0.609375, y: 0.078125 },
+ { x: 0.609375, y: 0.078125 },
+ { x: 0.640625, y: 0.078125 },
+ { x: 0.640625, y: 0.078125 },
+ { x: 0.671875, y: 0.078125 },
+ { x: 0.671875, y: 0.078125 },
+ { x: 0.703125, y: 0.078125 },
+ { x: 0.703125, y: 0.078125 },
+ { x: 0.734375, y: 0.078125 },
+ { x: 0.734375, y: 0.078125 },
+ { x: 0.765625, y: 0.078125 },
+ { x: 0.765625, y: 0.078125 },
+ { x: 0.796875, y: 0.078125 },
+ { x: 0.796875, y: 0.078125 },
+ { x: 0.828125, y: 0.078125 },
+ { x: 0.828125, y: 0.078125 },
+ { x: 0.859375, y: 0.078125 },
+ { x: 0.859375, y: 0.078125 },
+ { x: 0.890625, y: 0.078125 },
+ { x: 0.890625, y: 0.078125 },
+ { x: 0.921875, y: 0.078125 },
+ { x: 0.921875, y: 0.078125 },
+ { x: 0.953125, y: 0.078125 },
+ { x: 0.953125, y: 0.078125 },
+ { x: 0.984375, y: 0.078125 },
+ { x: 0.984375, y: 0.078125 },
+ { x: 0.015625, y: 0.109375 },
+ { x: 0.015625, y: 0.109375 },
+ { x: 0.046875, y: 0.109375 },
+ { x: 0.046875, y: 0.109375 },
+ { x: 0.078125, y: 0.109375 },
+ { x: 0.078125, y: 0.109375 },
+ { x: 0.109375, y: 0.109375 },
+ { x: 0.109375, y: 0.109375 },
+ { x: 0.140625, y: 0.109375 },
+ { x: 0.140625, y: 0.109375 },
+ { x: 0.171875, y: 0.109375 },
+ { x: 0.171875, y: 0.109375 },
+ { x: 0.203125, y: 0.109375 },
+ { x: 0.203125, y: 0.109375 },
+ { x: 0.234375, y: 0.109375 },
+ { x: 0.234375, y: 0.109375 },
+ { x: 0.265625, y: 0.109375 },
+ { x: 0.265625, y: 0.109375 },
+ { x: 0.296875, y: 0.109375 },
+ { x: 0.296875, y: 0.109375 },
+ { x: 0.328125, y: 0.109375 },
+ { x: 0.328125, y: 0.109375 },
+ { x: 0.359375, y: 0.109375 },
+ { x: 0.359375, y: 0.109375 },
+ { x: 0.390625, y: 0.109375 },
+ { x: 0.390625, y: 0.109375 },
+ { x: 0.421875, y: 0.109375 },
+ { x: 0.421875, y: 0.109375 },
+ { x: 0.453125, y: 0.109375 },
+ { x: 0.453125, y: 0.109375 },
+ { x: 0.484375, y: 0.109375 },
+ { x: 0.484375, y: 0.109375 },
+ { x: 0.515625, y: 0.109375 },
+ { x: 0.515625, y: 0.109375 },
+ { x: 0.546875, y: 0.109375 },
+ { x: 0.546875, y: 0.109375 },
+ { x: 0.578125, y: 0.109375 },
+ { x: 0.578125, y: 0.109375 },
+ { x: 0.609375, y: 0.109375 },
+ { x: 0.609375, y: 0.109375 },
+ { x: 0.640625, y: 0.109375 },
+ { x: 0.640625, y: 0.109375 },
+ { x: 0.671875, y: 0.109375 },
+ { x: 0.671875, y: 0.109375 },
+ { x: 0.703125, y: 0.109375 },
+ { x: 0.703125, y: 0.109375 },
+ { x: 0.734375, y: 0.109375 },
+ { x: 0.734375, y: 0.109375 },
+ { x: 0.765625, y: 0.109375 },
+ { x: 0.765625, y: 0.109375 },
+ { x: 0.796875, y: 0.109375 },
+ { x: 0.796875, y: 0.109375 },
+ { x: 0.828125, y: 0.109375 },
+ { x: 0.828125, y: 0.109375 },
+ { x: 0.859375, y: 0.109375 },
+ { x: 0.859375, y: 0.109375 },
+ { x: 0.890625, y: 0.109375 },
+ { x: 0.890625, y: 0.109375 },
+ { x: 0.921875, y: 0.109375 },
+ { x: 0.921875, y: 0.109375 },
+ { x: 0.953125, y: 0.109375 },
+ { x: 0.953125, y: 0.109375 },
+ { x: 0.984375, y: 0.109375 },
+ { x: 0.984375, y: 0.109375 },
+ { x: 0.015625, y: 0.140625 },
+ { x: 0.015625, y: 0.140625 },
+ { x: 0.046875, y: 0.140625 },
+ { x: 0.046875, y: 0.140625 },
+ { x: 0.078125, y: 0.140625 },
+ { x: 0.078125, y: 0.140625 },
+ { x: 0.109375, y: 0.140625 },
+ { x: 0.109375, y: 0.140625 },
+ { x: 0.140625, y: 0.140625 },
+ { x: 0.140625, y: 0.140625 },
+ { x: 0.171875, y: 0.140625 },
+ { x: 0.171875, y: 0.140625 },
+ { x: 0.203125, y: 0.140625 },
+ { x: 0.203125, y: 0.140625 },
+ { x: 0.234375, y: 0.140625 },
+ { x: 0.234375, y: 0.140625 },
+ { x: 0.265625, y: 0.140625 },
+ { x: 0.265625, y: 0.140625 },
+ { x: 0.296875, y: 0.140625 },
+ { x: 0.296875, y: 0.140625 },
+ { x: 0.328125, y: 0.140625 },
+ { x: 0.328125, y: 0.140625 },
+ { x: 0.359375, y: 0.140625 },
+ { x: 0.359375, y: 0.140625 },
+ { x: 0.390625, y: 0.140625 },
+ { x: 0.390625, y: 0.140625 },
+ { x: 0.421875, y: 0.140625 },
+ { x: 0.421875, y: 0.140625 },
+ { x: 0.453125, y: 0.140625 },
+ { x: 0.453125, y: 0.140625 },
+ { x: 0.484375, y: 0.140625 },
+ { x: 0.484375, y: 0.140625 },
+ { x: 0.515625, y: 0.140625 },
+ { x: 0.515625, y: 0.140625 },
+ { x: 0.546875, y: 0.140625 },
+ { x: 0.546875, y: 0.140625 },
+ { x: 0.578125, y: 0.140625 },
+ { x: 0.578125, y: 0.140625 },
+ { x: 0.609375, y: 0.140625 },
+ { x: 0.609375, y: 0.140625 },
+ { x: 0.640625, y: 0.140625 },
+ { x: 0.640625, y: 0.140625 },
+ { x: 0.671875, y: 0.140625 },
+ { x: 0.671875, y: 0.140625 },
+ { x: 0.703125, y: 0.140625 },
+ { x: 0.703125, y: 0.140625 },
+ { x: 0.734375, y: 0.140625 },
+ { x: 0.734375, y: 0.140625 },
+ { x: 0.765625, y: 0.140625 },
+ { x: 0.765625, y: 0.140625 },
+ { x: 0.796875, y: 0.140625 },
+ { x: 0.796875, y: 0.140625 },
+ { x: 0.828125, y: 0.140625 },
+ { x: 0.828125, y: 0.140625 },
+ { x: 0.859375, y: 0.140625 },
+ { x: 0.859375, y: 0.140625 },
+ { x: 0.890625, y: 0.140625 },
+ { x: 0.890625, y: 0.140625 },
+ { x: 0.921875, y: 0.140625 },
+ { x: 0.921875, y: 0.140625 },
+ { x: 0.953125, y: 0.140625 },
+ { x: 0.953125, y: 0.140625 },
+ { x: 0.984375, y: 0.140625 },
+ { x: 0.984375, y: 0.140625 },
+ { x: 0.015625, y: 0.171875 },
+ { x: 0.015625, y: 0.171875 },
+ { x: 0.046875, y: 0.171875 },
+ { x: 0.046875, y: 0.171875 },
+ { x: 0.078125, y: 0.171875 },
+ { x: 0.078125, y: 0.171875 },
+ { x: 0.109375, y: 0.171875 },
+ { x: 0.109375, y: 0.171875 },
+ { x: 0.140625, y: 0.171875 },
+ { x: 0.140625, y: 0.171875 },
+ { x: 0.171875, y: 0.171875 },
+ { x: 0.171875, y: 0.171875 },
+ { x: 0.203125, y: 0.171875 },
+ { x: 0.203125, y: 0.171875 },
+ { x: 0.234375, y: 0.171875 },
+ { x: 0.234375, y: 0.171875 },
+ { x: 0.265625, y: 0.171875 },
+ { x: 0.265625, y: 0.171875 },
+ { x: 0.296875, y: 0.171875 },
+ { x: 0.296875, y: 0.171875 },
+ { x: 0.328125, y: 0.171875 },
+ { x: 0.328125, y: 0.171875 },
+ { x: 0.359375, y: 0.171875 },
+ { x: 0.359375, y: 0.171875 },
+ { x: 0.390625, y: 0.171875 },
+ { x: 0.390625, y: 0.171875 },
+ { x: 0.421875, y: 0.171875 },
+ { x: 0.421875, y: 0.171875 },
+ { x: 0.453125, y: 0.171875 },
+ { x: 0.453125, y: 0.171875 },
+ { x: 0.484375, y: 0.171875 },
+ { x: 0.484375, y: 0.171875 },
+ { x: 0.515625, y: 0.171875 },
+ { x: 0.515625, y: 0.171875 },
+ { x: 0.546875, y: 0.171875 },
+ { x: 0.546875, y: 0.171875 },
+ { x: 0.578125, y: 0.171875 },
+ { x: 0.578125, y: 0.171875 },
+ { x: 0.609375, y: 0.171875 },
+ { x: 0.609375, y: 0.171875 },
+ { x: 0.640625, y: 0.171875 },
+ { x: 0.640625, y: 0.171875 },
+ { x: 0.671875, y: 0.171875 },
+ { x: 0.671875, y: 0.171875 },
+ { x: 0.703125, y: 0.171875 },
+ { x: 0.703125, y: 0.171875 },
+ { x: 0.734375, y: 0.171875 },
+ { x: 0.734375, y: 0.171875 },
+ { x: 0.765625, y: 0.171875 },
+ { x: 0.765625, y: 0.171875 },
+ { x: 0.796875, y: 0.171875 },
+ { x: 0.796875, y: 0.171875 },
+ { x: 0.828125, y: 0.171875 },
+ { x: 0.828125, y: 0.171875 },
+ { x: 0.859375, y: 0.171875 },
+ { x: 0.859375, y: 0.171875 },
+ { x: 0.890625, y: 0.171875 },
+ { x: 0.890625, y: 0.171875 },
+ { x: 0.921875, y: 0.171875 },
+ { x: 0.921875, y: 0.171875 },
+ { x: 0.953125, y: 0.171875 },
+ { x: 0.953125, y: 0.171875 },
+ { x: 0.984375, y: 0.171875 },
+ { x: 0.984375, y: 0.171875 },
+ { x: 0.015625, y: 0.203125 },
+ { x: 0.015625, y: 0.203125 },
+ { x: 0.046875, y: 0.203125 },
+ { x: 0.046875, y: 0.203125 },
+ { x: 0.078125, y: 0.203125 },
+ { x: 0.078125, y: 0.203125 },
+ { x: 0.109375, y: 0.203125 },
+ { x: 0.109375, y: 0.203125 },
+ { x: 0.140625, y: 0.203125 },
+ { x: 0.140625, y: 0.203125 },
+ { x: 0.171875, y: 0.203125 },
+ { x: 0.171875, y: 0.203125 },
+ { x: 0.203125, y: 0.203125 },
+ { x: 0.203125, y: 0.203125 },
+ { x: 0.234375, y: 0.203125 },
+ { x: 0.234375, y: 0.203125 },
+ { x: 0.265625, y: 0.203125 },
+ { x: 0.265625, y: 0.203125 },
+ { x: 0.296875, y: 0.203125 },
+ { x: 0.296875, y: 0.203125 },
+ { x: 0.328125, y: 0.203125 },
+ { x: 0.328125, y: 0.203125 },
+ { x: 0.359375, y: 0.203125 },
+ { x: 0.359375, y: 0.203125 },
+ { x: 0.390625, y: 0.203125 },
+ { x: 0.390625, y: 0.203125 },
+ { x: 0.421875, y: 0.203125 },
+ { x: 0.421875, y: 0.203125 },
+ { x: 0.453125, y: 0.203125 },
+ { x: 0.453125, y: 0.203125 },
+ { x: 0.484375, y: 0.203125 },
+ { x: 0.484375, y: 0.203125 },
+ { x: 0.515625, y: 0.203125 },
+ { x: 0.515625, y: 0.203125 },
+ { x: 0.546875, y: 0.203125 },
+ { x: 0.546875, y: 0.203125 },
+ { x: 0.578125, y: 0.203125 },
+ { x: 0.578125, y: 0.203125 },
+ { x: 0.609375, y: 0.203125 },
+ { x: 0.609375, y: 0.203125 },
+ { x: 0.640625, y: 0.203125 },
+ { x: 0.640625, y: 0.203125 },
+ { x: 0.671875, y: 0.203125 },
+ { x: 0.671875, y: 0.203125 },
+ { x: 0.703125, y: 0.203125 },
+ { x: 0.703125, y: 0.203125 },
+ { x: 0.734375, y: 0.203125 },
+ { x: 0.734375, y: 0.203125 },
+ { x: 0.765625, y: 0.203125 },
+ { x: 0.765625, y: 0.203125 },
+ { x: 0.796875, y: 0.203125 },
+ { x: 0.796875, y: 0.203125 },
+ { x: 0.828125, y: 0.203125 },
+ { x: 0.828125, y: 0.203125 },
+ { x: 0.859375, y: 0.203125 },
+ { x: 0.859375, y: 0.203125 },
+ { x: 0.890625, y: 0.203125 },
+ { x: 0.890625, y: 0.203125 },
+ { x: 0.921875, y: 0.203125 },
+ { x: 0.921875, y: 0.203125 },
+ { x: 0.953125, y: 0.203125 },
+ { x: 0.953125, y: 0.203125 },
+ { x: 0.984375, y: 0.203125 },
+ { x: 0.984375, y: 0.203125 },
+ { x: 0.015625, y: 0.234375 },
+ { x: 0.015625, y: 0.234375 },
+ { x: 0.046875, y: 0.234375 },
+ { x: 0.046875, y: 0.234375 },
+ { x: 0.078125, y: 0.234375 },
+ { x: 0.078125, y: 0.234375 },
+ { x: 0.109375, y: 0.234375 },
+ { x: 0.109375, y: 0.234375 },
+ { x: 0.140625, y: 0.234375 },
+ { x: 0.140625, y: 0.234375 },
+ { x: 0.171875, y: 0.234375 },
+ { x: 0.171875, y: 0.234375 },
+ { x: 0.203125, y: 0.234375 },
+ { x: 0.203125, y: 0.234375 },
+ { x: 0.234375, y: 0.234375 },
+ { x: 0.234375, y: 0.234375 },
+ { x: 0.265625, y: 0.234375 },
+ { x: 0.265625, y: 0.234375 },
+ { x: 0.296875, y: 0.234375 },
+ { x: 0.296875, y: 0.234375 },
+ { x: 0.328125, y: 0.234375 },
+ { x: 0.328125, y: 0.234375 },
+ { x: 0.359375, y: 0.234375 },
+ { x: 0.359375, y: 0.234375 },
+ { x: 0.390625, y: 0.234375 },
+ { x: 0.390625, y: 0.234375 },
+ { x: 0.421875, y: 0.234375 },
+ { x: 0.421875, y: 0.234375 },
+ { x: 0.453125, y: 0.234375 },
+ { x: 0.453125, y: 0.234375 },
+ { x: 0.484375, y: 0.234375 },
+ { x: 0.484375, y: 0.234375 },
+ { x: 0.515625, y: 0.234375 },
+ { x: 0.515625, y: 0.234375 },
+ { x: 0.546875, y: 0.234375 },
+ { x: 0.546875, y: 0.234375 },
+ { x: 0.578125, y: 0.234375 },
+ { x: 0.578125, y: 0.234375 },
+ { x: 0.609375, y: 0.234375 },
+ { x: 0.609375, y: 0.234375 },
+ { x: 0.640625, y: 0.234375 },
+ { x: 0.640625, y: 0.234375 },
+ { x: 0.671875, y: 0.234375 },
+ { x: 0.671875, y: 0.234375 },
+ { x: 0.703125, y: 0.234375 },
+ { x: 0.703125, y: 0.234375 },
+ { x: 0.734375, y: 0.234375 },
+ { x: 0.734375, y: 0.234375 },
+ { x: 0.765625, y: 0.234375 },
+ { x: 0.765625, y: 0.234375 },
+ { x: 0.796875, y: 0.234375 },
+ { x: 0.796875, y: 0.234375 },
+ { x: 0.828125, y: 0.234375 },
+ { x: 0.828125, y: 0.234375 },
+ { x: 0.859375, y: 0.234375 },
+ { x: 0.859375, y: 0.234375 },
+ { x: 0.890625, y: 0.234375 },
+ { x: 0.890625, y: 0.234375 },
+ { x: 0.921875, y: 0.234375 },
+ { x: 0.921875, y: 0.234375 },
+ { x: 0.953125, y: 0.234375 },
+ { x: 0.953125, y: 0.234375 },
+ { x: 0.984375, y: 0.234375 },
+ { x: 0.984375, y: 0.234375 },
+ { x: 0.015625, y: 0.265625 },
+ { x: 0.015625, y: 0.265625 },
+ { x: 0.046875, y: 0.265625 },
+ { x: 0.046875, y: 0.265625 },
+ { x: 0.078125, y: 0.265625 },
+ { x: 0.078125, y: 0.265625 },
+ { x: 0.109375, y: 0.265625 },
+ { x: 0.109375, y: 0.265625 },
+ { x: 0.140625, y: 0.265625 },
+ { x: 0.140625, y: 0.265625 },
+ { x: 0.171875, y: 0.265625 },
+ { x: 0.171875, y: 0.265625 },
+ { x: 0.203125, y: 0.265625 },
+ { x: 0.203125, y: 0.265625 },
+ { x: 0.234375, y: 0.265625 },
+ { x: 0.234375, y: 0.265625 },
+ { x: 0.265625, y: 0.265625 },
+ { x: 0.265625, y: 0.265625 },
+ { x: 0.296875, y: 0.265625 },
+ { x: 0.296875, y: 0.265625 },
+ { x: 0.328125, y: 0.265625 },
+ { x: 0.328125, y: 0.265625 },
+ { x: 0.359375, y: 0.265625 },
+ { x: 0.359375, y: 0.265625 },
+ { x: 0.390625, y: 0.265625 },
+ { x: 0.390625, y: 0.265625 },
+ { x: 0.421875, y: 0.265625 },
+ { x: 0.421875, y: 0.265625 },
+ { x: 0.453125, y: 0.265625 },
+ { x: 0.453125, y: 0.265625 },
+ { x: 0.484375, y: 0.265625 },
+ { x: 0.484375, y: 0.265625 },
+ { x: 0.515625, y: 0.265625 },
+ { x: 0.515625, y: 0.265625 },
+ { x: 0.546875, y: 0.265625 },
+ { x: 0.546875, y: 0.265625 },
+ { x: 0.578125, y: 0.265625 },
+ { x: 0.578125, y: 0.265625 },
+ { x: 0.609375, y: 0.265625 },
+ { x: 0.609375, y: 0.265625 },
+ { x: 0.640625, y: 0.265625 },
+ { x: 0.640625, y: 0.265625 },
+ { x: 0.671875, y: 0.265625 },
+ { x: 0.671875, y: 0.265625 },
+ { x: 0.703125, y: 0.265625 },
+ { x: 0.703125, y: 0.265625 },
+ { x: 0.734375, y: 0.265625 },
+ { x: 0.734375, y: 0.265625 },
+ { x: 0.765625, y: 0.265625 },
+ { x: 0.765625, y: 0.265625 },
+ { x: 0.796875, y: 0.265625 },
+ { x: 0.796875, y: 0.265625 },
+ { x: 0.828125, y: 0.265625 },
+ { x: 0.828125, y: 0.265625 },
+ { x: 0.859375, y: 0.265625 },
+ { x: 0.859375, y: 0.265625 },
+ { x: 0.890625, y: 0.265625 },
+ { x: 0.890625, y: 0.265625 },
+ { x: 0.921875, y: 0.265625 },
+ { x: 0.921875, y: 0.265625 },
+ { x: 0.953125, y: 0.265625 },
+ { x: 0.953125, y: 0.265625 },
+ { x: 0.984375, y: 0.265625 },
+ { x: 0.984375, y: 0.265625 },
+ { x: 0.015625, y: 0.296875 },
+ { x: 0.015625, y: 0.296875 },
+ { x: 0.046875, y: 0.296875 },
+ { x: 0.046875, y: 0.296875 },
+ { x: 0.078125, y: 0.296875 },
+ { x: 0.078125, y: 0.296875 },
+ { x: 0.109375, y: 0.296875 },
+ { x: 0.109375, y: 0.296875 },
+ { x: 0.140625, y: 0.296875 },
+ { x: 0.140625, y: 0.296875 },
+ { x: 0.171875, y: 0.296875 },
+ { x: 0.171875, y: 0.296875 },
+ { x: 0.203125, y: 0.296875 },
+ { x: 0.203125, y: 0.296875 },
+ { x: 0.234375, y: 0.296875 },
+ { x: 0.234375, y: 0.296875 },
+ { x: 0.265625, y: 0.296875 },
+ { x: 0.265625, y: 0.296875 },
+ { x: 0.296875, y: 0.296875 },
+ { x: 0.296875, y: 0.296875 },
+ { x: 0.328125, y: 0.296875 },
+ { x: 0.328125, y: 0.296875 },
+ { x: 0.359375, y: 0.296875 },
+ { x: 0.359375, y: 0.296875 },
+ { x: 0.390625, y: 0.296875 },
+ { x: 0.390625, y: 0.296875 },
+ { x: 0.421875, y: 0.296875 },
+ { x: 0.421875, y: 0.296875 },
+ { x: 0.453125, y: 0.296875 },
+ { x: 0.453125, y: 0.296875 },
+ { x: 0.484375, y: 0.296875 },
+ { x: 0.484375, y: 0.296875 },
+ { x: 0.515625, y: 0.296875 },
+ { x: 0.515625, y: 0.296875 },
+ { x: 0.546875, y: 0.296875 },
+ { x: 0.546875, y: 0.296875 },
+ { x: 0.578125, y: 0.296875 },
+ { x: 0.578125, y: 0.296875 },
+ { x: 0.609375, y: 0.296875 },
+ { x: 0.609375, y: 0.296875 },
+ { x: 0.640625, y: 0.296875 },
+ { x: 0.640625, y: 0.296875 },
+ { x: 0.671875, y: 0.296875 },
+ { x: 0.671875, y: 0.296875 },
+ { x: 0.703125, y: 0.296875 },
+ { x: 0.703125, y: 0.296875 },
+ { x: 0.734375, y: 0.296875 },
+ { x: 0.734375, y: 0.296875 },
+ { x: 0.765625, y: 0.296875 },
+ { x: 0.765625, y: 0.296875 },
+ { x: 0.796875, y: 0.296875 },
+ { x: 0.796875, y: 0.296875 },
+ { x: 0.828125, y: 0.296875 },
+ { x: 0.828125, y: 0.296875 },
+ { x: 0.859375, y: 0.296875 },
+ { x: 0.859375, y: 0.296875 },
+ { x: 0.890625, y: 0.296875 },
+ { x: 0.890625, y: 0.296875 },
+ { x: 0.921875, y: 0.296875 },
+ { x: 0.921875, y: 0.296875 },
+ { x: 0.953125, y: 0.296875 },
+ { x: 0.953125, y: 0.296875 },
+ { x: 0.984375, y: 0.296875 },
+ { x: 0.984375, y: 0.296875 },
+ { x: 0.015625, y: 0.328125 },
+ { x: 0.015625, y: 0.328125 },
+ { x: 0.046875, y: 0.328125 },
+ { x: 0.046875, y: 0.328125 },
+ { x: 0.078125, y: 0.328125 },
+ { x: 0.078125, y: 0.328125 },
+ { x: 0.109375, y: 0.328125 },
+ { x: 0.109375, y: 0.328125 },
+ { x: 0.140625, y: 0.328125 },
+ { x: 0.140625, y: 0.328125 },
+ { x: 0.171875, y: 0.328125 },
+ { x: 0.171875, y: 0.328125 },
+ { x: 0.203125, y: 0.328125 },
+ { x: 0.203125, y: 0.328125 },
+ { x: 0.234375, y: 0.328125 },
+ { x: 0.234375, y: 0.328125 },
+ { x: 0.265625, y: 0.328125 },
+ { x: 0.265625, y: 0.328125 },
+ { x: 0.296875, y: 0.328125 },
+ { x: 0.296875, y: 0.328125 },
+ { x: 0.328125, y: 0.328125 },
+ { x: 0.328125, y: 0.328125 },
+ { x: 0.359375, y: 0.328125 },
+ { x: 0.359375, y: 0.328125 },
+ { x: 0.390625, y: 0.328125 },
+ { x: 0.390625, y: 0.328125 },
+ { x: 0.421875, y: 0.328125 },
+ { x: 0.421875, y: 0.328125 },
+ { x: 0.453125, y: 0.328125 },
+ { x: 0.453125, y: 0.328125 },
+ { x: 0.484375, y: 0.328125 },
+ { x: 0.484375, y: 0.328125 },
+ { x: 0.515625, y: 0.328125 },
+ { x: 0.515625, y: 0.328125 },
+ { x: 0.546875, y: 0.328125 },
+ { x: 0.546875, y: 0.328125 },
+ { x: 0.578125, y: 0.328125 },
+ { x: 0.578125, y: 0.328125 },
+ { x: 0.609375, y: 0.328125 },
+ { x: 0.609375, y: 0.328125 },
+ { x: 0.640625, y: 0.328125 },
+ { x: 0.640625, y: 0.328125 },
+ { x: 0.671875, y: 0.328125 },
+ { x: 0.671875, y: 0.328125 },
+ { x: 0.703125, y: 0.328125 },
+ { x: 0.703125, y: 0.328125 },
+ { x: 0.734375, y: 0.328125 },
+ { x: 0.734375, y: 0.328125 },
+ { x: 0.765625, y: 0.328125 },
+ { x: 0.765625, y: 0.328125 },
+ { x: 0.796875, y: 0.328125 },
+ { x: 0.796875, y: 0.328125 },
+ { x: 0.828125, y: 0.328125 },
+ { x: 0.828125, y: 0.328125 },
+ { x: 0.859375, y: 0.328125 },
+ { x: 0.859375, y: 0.328125 },
+ { x: 0.890625, y: 0.328125 },
+ { x: 0.890625, y: 0.328125 },
+ { x: 0.921875, y: 0.328125 },
+ { x: 0.921875, y: 0.328125 },
+ { x: 0.953125, y: 0.328125 },
+ { x: 0.953125, y: 0.328125 },
+ { x: 0.984375, y: 0.328125 },
+ { x: 0.984375, y: 0.328125 },
+ { x: 0.015625, y: 0.359375 },
+ { x: 0.015625, y: 0.359375 },
+ { x: 0.046875, y: 0.359375 },
+ { x: 0.046875, y: 0.359375 },
+ { x: 0.078125, y: 0.359375 },
+ { x: 0.078125, y: 0.359375 },
+ { x: 0.109375, y: 0.359375 },
+ { x: 0.109375, y: 0.359375 },
+ { x: 0.140625, y: 0.359375 },
+ { x: 0.140625, y: 0.359375 },
+ { x: 0.171875, y: 0.359375 },
+ { x: 0.171875, y: 0.359375 },
+ { x: 0.203125, y: 0.359375 },
+ { x: 0.203125, y: 0.359375 },
+ { x: 0.234375, y: 0.359375 },
+ { x: 0.234375, y: 0.359375 },
+ { x: 0.265625, y: 0.359375 },
+ { x: 0.265625, y: 0.359375 },
+ { x: 0.296875, y: 0.359375 },
+ { x: 0.296875, y: 0.359375 },
+ { x: 0.328125, y: 0.359375 },
+ { x: 0.328125, y: 0.359375 },
+ { x: 0.359375, y: 0.359375 },
+ { x: 0.359375, y: 0.359375 },
+ { x: 0.390625, y: 0.359375 },
+ { x: 0.390625, y: 0.359375 },
+ { x: 0.421875, y: 0.359375 },
+ { x: 0.421875, y: 0.359375 },
+ { x: 0.453125, y: 0.359375 },
+ { x: 0.453125, y: 0.359375 },
+ { x: 0.484375, y: 0.359375 },
+ { x: 0.484375, y: 0.359375 },
+ { x: 0.515625, y: 0.359375 },
+ { x: 0.515625, y: 0.359375 },
+ { x: 0.546875, y: 0.359375 },
+ { x: 0.546875, y: 0.359375 },
+ { x: 0.578125, y: 0.359375 },
+ { x: 0.578125, y: 0.359375 },
+ { x: 0.609375, y: 0.359375 },
+ { x: 0.609375, y: 0.359375 },
+ { x: 0.640625, y: 0.359375 },
+ { x: 0.640625, y: 0.359375 },
+ { x: 0.671875, y: 0.359375 },
+ { x: 0.671875, y: 0.359375 },
+ { x: 0.703125, y: 0.359375 },
+ { x: 0.703125, y: 0.359375 },
+ { x: 0.734375, y: 0.359375 },
+ { x: 0.734375, y: 0.359375 },
+ { x: 0.765625, y: 0.359375 },
+ { x: 0.765625, y: 0.359375 },
+ { x: 0.796875, y: 0.359375 },
+ { x: 0.796875, y: 0.359375 },
+ { x: 0.828125, y: 0.359375 },
+ { x: 0.828125, y: 0.359375 },
+ { x: 0.859375, y: 0.359375 },
+ { x: 0.859375, y: 0.359375 },
+ { x: 0.890625, y: 0.359375 },
+ { x: 0.890625, y: 0.359375 },
+ { x: 0.921875, y: 0.359375 },
+ { x: 0.921875, y: 0.359375 },
+ { x: 0.953125, y: 0.359375 },
+ { x: 0.953125, y: 0.359375 },
+ { x: 0.984375, y: 0.359375 },
+ { x: 0.984375, y: 0.359375 },
+ { x: 0.015625, y: 0.390625 },
+ { x: 0.015625, y: 0.390625 },
+ { x: 0.046875, y: 0.390625 },
+ { x: 0.046875, y: 0.390625 },
+ { x: 0.078125, y: 0.390625 },
+ { x: 0.078125, y: 0.390625 },
+ { x: 0.109375, y: 0.390625 },
+ { x: 0.109375, y: 0.390625 },
+ { x: 0.140625, y: 0.390625 },
+ { x: 0.140625, y: 0.390625 },
+ { x: 0.171875, y: 0.390625 },
+ { x: 0.171875, y: 0.390625 },
+ { x: 0.203125, y: 0.390625 },
+ { x: 0.203125, y: 0.390625 },
+ { x: 0.234375, y: 0.390625 },
+ { x: 0.234375, y: 0.390625 },
+ { x: 0.265625, y: 0.390625 },
+ { x: 0.265625, y: 0.390625 },
+ { x: 0.296875, y: 0.390625 },
+ { x: 0.296875, y: 0.390625 },
+ { x: 0.328125, y: 0.390625 },
+ { x: 0.328125, y: 0.390625 },
+ { x: 0.359375, y: 0.390625 },
+ { x: 0.359375, y: 0.390625 },
+ { x: 0.390625, y: 0.390625 },
+ { x: 0.390625, y: 0.390625 },
+ { x: 0.421875, y: 0.390625 },
+ { x: 0.421875, y: 0.390625 },
+ { x: 0.453125, y: 0.390625 },
+ { x: 0.453125, y: 0.390625 },
+ { x: 0.484375, y: 0.390625 },
+ { x: 0.484375, y: 0.390625 },
+ { x: 0.515625, y: 0.390625 },
+ { x: 0.515625, y: 0.390625 },
+ { x: 0.546875, y: 0.390625 },
+ { x: 0.546875, y: 0.390625 },
+ { x: 0.578125, y: 0.390625 },
+ { x: 0.578125, y: 0.390625 },
+ { x: 0.609375, y: 0.390625 },
+ { x: 0.609375, y: 0.390625 },
+ { x: 0.640625, y: 0.390625 },
+ { x: 0.640625, y: 0.390625 },
+ { x: 0.671875, y: 0.390625 },
+ { x: 0.671875, y: 0.390625 },
+ { x: 0.703125, y: 0.390625 },
+ { x: 0.703125, y: 0.390625 },
+ { x: 0.734375, y: 0.390625 },
+ { x: 0.734375, y: 0.390625 },
+ { x: 0.765625, y: 0.390625 },
+ { x: 0.765625, y: 0.390625 },
+ { x: 0.796875, y: 0.390625 },
+ { x: 0.796875, y: 0.390625 },
+ { x: 0.828125, y: 0.390625 },
+ { x: 0.828125, y: 0.390625 },
+ { x: 0.859375, y: 0.390625 },
+ { x: 0.859375, y: 0.390625 },
+ { x: 0.890625, y: 0.390625 },
+ { x: 0.890625, y: 0.390625 },
+ { x: 0.921875, y: 0.390625 },
+ { x: 0.921875, y: 0.390625 },
+ { x: 0.953125, y: 0.390625 },
+ { x: 0.953125, y: 0.390625 },
+ { x: 0.984375, y: 0.390625 },
+ { x: 0.984375, y: 0.390625 },
+ { x: 0.015625, y: 0.421875 },
+ { x: 0.015625, y: 0.421875 },
+ { x: 0.046875, y: 0.421875 },
+ { x: 0.046875, y: 0.421875 },
+ { x: 0.078125, y: 0.421875 },
+ { x: 0.078125, y: 0.421875 },
+ { x: 0.109375, y: 0.421875 },
+ { x: 0.109375, y: 0.421875 },
+ { x: 0.140625, y: 0.421875 },
+ { x: 0.140625, y: 0.421875 },
+ { x: 0.171875, y: 0.421875 },
+ { x: 0.171875, y: 0.421875 },
+ { x: 0.203125, y: 0.421875 },
+ { x: 0.203125, y: 0.421875 },
+ { x: 0.234375, y: 0.421875 },
+ { x: 0.234375, y: 0.421875 },
+ { x: 0.265625, y: 0.421875 },
+ { x: 0.265625, y: 0.421875 },
+ { x: 0.296875, y: 0.421875 },
+ { x: 0.296875, y: 0.421875 },
+ { x: 0.328125, y: 0.421875 },
+ { x: 0.328125, y: 0.421875 },
+ { x: 0.359375, y: 0.421875 },
+ { x: 0.359375, y: 0.421875 },
+ { x: 0.390625, y: 0.421875 },
+ { x: 0.390625, y: 0.421875 },
+ { x: 0.421875, y: 0.421875 },
+ { x: 0.421875, y: 0.421875 },
+ { x: 0.453125, y: 0.421875 },
+ { x: 0.453125, y: 0.421875 },
+ { x: 0.484375, y: 0.421875 },
+ { x: 0.484375, y: 0.421875 },
+ { x: 0.515625, y: 0.421875 },
+ { x: 0.515625, y: 0.421875 },
+ { x: 0.546875, y: 0.421875 },
+ { x: 0.546875, y: 0.421875 },
+ { x: 0.578125, y: 0.421875 },
+ { x: 0.578125, y: 0.421875 },
+ { x: 0.609375, y: 0.421875 },
+ { x: 0.609375, y: 0.421875 },
+ { x: 0.640625, y: 0.421875 },
+ { x: 0.640625, y: 0.421875 },
+ { x: 0.671875, y: 0.421875 },
+ { x: 0.671875, y: 0.421875 },
+ { x: 0.703125, y: 0.421875 },
+ { x: 0.703125, y: 0.421875 },
+ { x: 0.734375, y: 0.421875 },
+ { x: 0.734375, y: 0.421875 },
+ { x: 0.765625, y: 0.421875 },
+ { x: 0.765625, y: 0.421875 },
+ { x: 0.796875, y: 0.421875 },
+ { x: 0.796875, y: 0.421875 },
+ { x: 0.828125, y: 0.421875 },
+ { x: 0.828125, y: 0.421875 },
+ { x: 0.859375, y: 0.421875 },
+ { x: 0.859375, y: 0.421875 },
+ { x: 0.890625, y: 0.421875 },
+ { x: 0.890625, y: 0.421875 },
+ { x: 0.921875, y: 0.421875 },
+ { x: 0.921875, y: 0.421875 },
+ { x: 0.953125, y: 0.421875 },
+ { x: 0.953125, y: 0.421875 },
+ { x: 0.984375, y: 0.421875 },
+ { x: 0.984375, y: 0.421875 },
+ { x: 0.015625, y: 0.453125 },
+ { x: 0.015625, y: 0.453125 },
+ { x: 0.046875, y: 0.453125 },
+ { x: 0.046875, y: 0.453125 },
+ { x: 0.078125, y: 0.453125 },
+ { x: 0.078125, y: 0.453125 },
+ { x: 0.109375, y: 0.453125 },
+ { x: 0.109375, y: 0.453125 },
+ { x: 0.140625, y: 0.453125 },
+ { x: 0.140625, y: 0.453125 },
+ { x: 0.171875, y: 0.453125 },
+ { x: 0.171875, y: 0.453125 },
+ { x: 0.203125, y: 0.453125 },
+ { x: 0.203125, y: 0.453125 },
+ { x: 0.234375, y: 0.453125 },
+ { x: 0.234375, y: 0.453125 },
+ { x: 0.265625, y: 0.453125 },
+ { x: 0.265625, y: 0.453125 },
+ { x: 0.296875, y: 0.453125 },
+ { x: 0.296875, y: 0.453125 },
+ { x: 0.328125, y: 0.453125 },
+ { x: 0.328125, y: 0.453125 },
+ { x: 0.359375, y: 0.453125 },
+ { x: 0.359375, y: 0.453125 },
+ { x: 0.390625, y: 0.453125 },
+ { x: 0.390625, y: 0.453125 },
+ { x: 0.421875, y: 0.453125 },
+ { x: 0.421875, y: 0.453125 },
+ { x: 0.453125, y: 0.453125 },
+ { x: 0.453125, y: 0.453125 },
+ { x: 0.484375, y: 0.453125 },
+ { x: 0.484375, y: 0.453125 },
+ { x: 0.515625, y: 0.453125 },
+ { x: 0.515625, y: 0.453125 },
+ { x: 0.546875, y: 0.453125 },
+ { x: 0.546875, y: 0.453125 },
+ { x: 0.578125, y: 0.453125 },
+ { x: 0.578125, y: 0.453125 },
+ { x: 0.609375, y: 0.453125 },
+ { x: 0.609375, y: 0.453125 },
+ { x: 0.640625, y: 0.453125 },
+ { x: 0.640625, y: 0.453125 },
+ { x: 0.671875, y: 0.453125 },
+ { x: 0.671875, y: 0.453125 },
+ { x: 0.703125, y: 0.453125 },
+ { x: 0.703125, y: 0.453125 },
+ { x: 0.734375, y: 0.453125 },
+ { x: 0.734375, y: 0.453125 },
+ { x: 0.765625, y: 0.453125 },
+ { x: 0.765625, y: 0.453125 },
+ { x: 0.796875, y: 0.453125 },
+ { x: 0.796875, y: 0.453125 },
+ { x: 0.828125, y: 0.453125 },
+ { x: 0.828125, y: 0.453125 },
+ { x: 0.859375, y: 0.453125 },
+ { x: 0.859375, y: 0.453125 },
+ { x: 0.890625, y: 0.453125 },
+ { x: 0.890625, y: 0.453125 },
+ { x: 0.921875, y: 0.453125 },
+ { x: 0.921875, y: 0.453125 },
+ { x: 0.953125, y: 0.453125 },
+ { x: 0.953125, y: 0.453125 },
+ { x: 0.984375, y: 0.453125 },
+ { x: 0.984375, y: 0.453125 },
+ { x: 0.015625, y: 0.484375 },
+ { x: 0.015625, y: 0.484375 },
+ { x: 0.046875, y: 0.484375 },
+ { x: 0.046875, y: 0.484375 },
+ { x: 0.078125, y: 0.484375 },
+ { x: 0.078125, y: 0.484375 },
+ { x: 0.109375, y: 0.484375 },
+ { x: 0.109375, y: 0.484375 },
+ { x: 0.140625, y: 0.484375 },
+ { x: 0.140625, y: 0.484375 },
+ { x: 0.171875, y: 0.484375 },
+ { x: 0.171875, y: 0.484375 },
+ { x: 0.203125, y: 0.484375 },
+ { x: 0.203125, y: 0.484375 },
+ { x: 0.234375, y: 0.484375 },
+ { x: 0.234375, y: 0.484375 },
+ { x: 0.265625, y: 0.484375 },
+ { x: 0.265625, y: 0.484375 },
+ { x: 0.296875, y: 0.484375 },
+ { x: 0.296875, y: 0.484375 },
+ { x: 0.328125, y: 0.484375 },
+ { x: 0.328125, y: 0.484375 },
+ { x: 0.359375, y: 0.484375 },
+ { x: 0.359375, y: 0.484375 },
+ { x: 0.390625, y: 0.484375 },
+ { x: 0.390625, y: 0.484375 },
+ { x: 0.421875, y: 0.484375 },
+ { x: 0.421875, y: 0.484375 },
+ { x: 0.453125, y: 0.484375 },
+ { x: 0.453125, y: 0.484375 },
+ { x: 0.484375, y: 0.484375 },
+ { x: 0.484375, y: 0.484375 },
+ { x: 0.515625, y: 0.484375 },
+ { x: 0.515625, y: 0.484375 },
+ { x: 0.546875, y: 0.484375 },
+ { x: 0.546875, y: 0.484375 },
+ { x: 0.578125, y: 0.484375 },
+ { x: 0.578125, y: 0.484375 },
+ { x: 0.609375, y: 0.484375 },
+ { x: 0.609375, y: 0.484375 },
+ { x: 0.640625, y: 0.484375 },
+ { x: 0.640625, y: 0.484375 },
+ { x: 0.671875, y: 0.484375 },
+ { x: 0.671875, y: 0.484375 },
+ { x: 0.703125, y: 0.484375 },
+ { x: 0.703125, y: 0.484375 },
+ { x: 0.734375, y: 0.484375 },
+ { x: 0.734375, y: 0.484375 },
+ { x: 0.765625, y: 0.484375 },
+ { x: 0.765625, y: 0.484375 },
+ { x: 0.796875, y: 0.484375 },
+ { x: 0.796875, y: 0.484375 },
+ { x: 0.828125, y: 0.484375 },
+ { x: 0.828125, y: 0.484375 },
+ { x: 0.859375, y: 0.484375 },
+ { x: 0.859375, y: 0.484375 },
+ { x: 0.890625, y: 0.484375 },
+ { x: 0.890625, y: 0.484375 },
+ { x: 0.921875, y: 0.484375 },
+ { x: 0.921875, y: 0.484375 },
+ { x: 0.953125, y: 0.484375 },
+ { x: 0.953125, y: 0.484375 },
+ { x: 0.984375, y: 0.484375 },
+ { x: 0.984375, y: 0.484375 },
+ { x: 0.015625, y: 0.515625 },
+ { x: 0.015625, y: 0.515625 },
+ { x: 0.046875, y: 0.515625 },
+ { x: 0.046875, y: 0.515625 },
+ { x: 0.078125, y: 0.515625 },
+ { x: 0.078125, y: 0.515625 },
+ { x: 0.109375, y: 0.515625 },
+ { x: 0.109375, y: 0.515625 },
+ { x: 0.140625, y: 0.515625 },
+ { x: 0.140625, y: 0.515625 },
+ { x: 0.171875, y: 0.515625 },
+ { x: 0.171875, y: 0.515625 },
+ { x: 0.203125, y: 0.515625 },
+ { x: 0.203125, y: 0.515625 },
+ { x: 0.234375, y: 0.515625 },
+ { x: 0.234375, y: 0.515625 },
+ { x: 0.265625, y: 0.515625 },
+ { x: 0.265625, y: 0.515625 },
+ { x: 0.296875, y: 0.515625 },
+ { x: 0.296875, y: 0.515625 },
+ { x: 0.328125, y: 0.515625 },
+ { x: 0.328125, y: 0.515625 },
+ { x: 0.359375, y: 0.515625 },
+ { x: 0.359375, y: 0.515625 },
+ { x: 0.390625, y: 0.515625 },
+ { x: 0.390625, y: 0.515625 },
+ { x: 0.421875, y: 0.515625 },
+ { x: 0.421875, y: 0.515625 },
+ { x: 0.453125, y: 0.515625 },
+ { x: 0.453125, y: 0.515625 },
+ { x: 0.484375, y: 0.515625 },
+ { x: 0.484375, y: 0.515625 },
+ { x: 0.515625, y: 0.515625 },
+ { x: 0.515625, y: 0.515625 },
+ { x: 0.546875, y: 0.515625 },
+ { x: 0.546875, y: 0.515625 },
+ { x: 0.578125, y: 0.515625 },
+ { x: 0.578125, y: 0.515625 },
+ { x: 0.609375, y: 0.515625 },
+ { x: 0.609375, y: 0.515625 },
+ { x: 0.640625, y: 0.515625 },
+ { x: 0.640625, y: 0.515625 },
+ { x: 0.671875, y: 0.515625 },
+ { x: 0.671875, y: 0.515625 },
+ { x: 0.703125, y: 0.515625 },
+ { x: 0.703125, y: 0.515625 },
+ { x: 0.734375, y: 0.515625 },
+ { x: 0.734375, y: 0.515625 },
+ { x: 0.765625, y: 0.515625 },
+ { x: 0.765625, y: 0.515625 },
+ { x: 0.796875, y: 0.515625 },
+ { x: 0.796875, y: 0.515625 },
+ { x: 0.828125, y: 0.515625 },
+ { x: 0.828125, y: 0.515625 },
+ { x: 0.859375, y: 0.515625 },
+ { x: 0.859375, y: 0.515625 },
+ { x: 0.890625, y: 0.515625 },
+ { x: 0.890625, y: 0.515625 },
+ { x: 0.921875, y: 0.515625 },
+ { x: 0.921875, y: 0.515625 },
+ { x: 0.953125, y: 0.515625 },
+ { x: 0.953125, y: 0.515625 },
+ { x: 0.984375, y: 0.515625 },
+ { x: 0.984375, y: 0.515625 },
+ { x: 0.015625, y: 0.546875 },
+ { x: 0.015625, y: 0.546875 },
+ { x: 0.046875, y: 0.546875 },
+ { x: 0.046875, y: 0.546875 },
+ { x: 0.078125, y: 0.546875 },
+ { x: 0.078125, y: 0.546875 },
+ { x: 0.109375, y: 0.546875 },
+ { x: 0.109375, y: 0.546875 },
+ { x: 0.140625, y: 0.546875 },
+ { x: 0.140625, y: 0.546875 },
+ { x: 0.171875, y: 0.546875 },
+ { x: 0.171875, y: 0.546875 },
+ { x: 0.203125, y: 0.546875 },
+ { x: 0.203125, y: 0.546875 },
+ { x: 0.234375, y: 0.546875 },
+ { x: 0.234375, y: 0.546875 },
+ { x: 0.265625, y: 0.546875 },
+ { x: 0.265625, y: 0.546875 },
+ { x: 0.296875, y: 0.546875 },
+ { x: 0.296875, y: 0.546875 },
+ { x: 0.328125, y: 0.546875 },
+ { x: 0.328125, y: 0.546875 },
+ { x: 0.359375, y: 0.546875 },
+ { x: 0.359375, y: 0.546875 },
+ { x: 0.390625, y: 0.546875 },
+ { x: 0.390625, y: 0.546875 },
+ { x: 0.421875, y: 0.546875 },
+ { x: 0.421875, y: 0.546875 },
+ { x: 0.453125, y: 0.546875 },
+ { x: 0.453125, y: 0.546875 },
+ { x: 0.484375, y: 0.546875 },
+ { x: 0.484375, y: 0.546875 },
+ { x: 0.515625, y: 0.546875 },
+ { x: 0.515625, y: 0.546875 },
+ { x: 0.546875, y: 0.546875 },
+ { x: 0.546875, y: 0.546875 },
+ { x: 0.578125, y: 0.546875 },
+ { x: 0.578125, y: 0.546875 },
+ { x: 0.609375, y: 0.546875 },
+ { x: 0.609375, y: 0.546875 },
+ { x: 0.640625, y: 0.546875 },
+ { x: 0.640625, y: 0.546875 },
+ { x: 0.671875, y: 0.546875 },
+ { x: 0.671875, y: 0.546875 },
+ { x: 0.703125, y: 0.546875 },
+ { x: 0.703125, y: 0.546875 },
+ { x: 0.734375, y: 0.546875 },
+ { x: 0.734375, y: 0.546875 },
+ { x: 0.765625, y: 0.546875 },
+ { x: 0.765625, y: 0.546875 },
+ { x: 0.796875, y: 0.546875 },
+ { x: 0.796875, y: 0.546875 },
+ { x: 0.828125, y: 0.546875 },
+ { x: 0.828125, y: 0.546875 },
+ { x: 0.859375, y: 0.546875 },
+ { x: 0.859375, y: 0.546875 },
+ { x: 0.890625, y: 0.546875 },
+ { x: 0.890625, y: 0.546875 },
+ { x: 0.921875, y: 0.546875 },
+ { x: 0.921875, y: 0.546875 },
+ { x: 0.953125, y: 0.546875 },
+ { x: 0.953125, y: 0.546875 },
+ { x: 0.984375, y: 0.546875 },
+ { x: 0.984375, y: 0.546875 },
+ { x: 0.015625, y: 0.578125 },
+ { x: 0.015625, y: 0.578125 },
+ { x: 0.046875, y: 0.578125 },
+ { x: 0.046875, y: 0.578125 },
+ { x: 0.078125, y: 0.578125 },
+ { x: 0.078125, y: 0.578125 },
+ { x: 0.109375, y: 0.578125 },
+ { x: 0.109375, y: 0.578125 },
+ { x: 0.140625, y: 0.578125 },
+ { x: 0.140625, y: 0.578125 },
+ { x: 0.171875, y: 0.578125 },
+ { x: 0.171875, y: 0.578125 },
+ { x: 0.203125, y: 0.578125 },
+ { x: 0.203125, y: 0.578125 },
+ { x: 0.234375, y: 0.578125 },
+ { x: 0.234375, y: 0.578125 },
+ { x: 0.265625, y: 0.578125 },
+ { x: 0.265625, y: 0.578125 },
+ { x: 0.296875, y: 0.578125 },
+ { x: 0.296875, y: 0.578125 },
+ { x: 0.328125, y: 0.578125 },
+ { x: 0.328125, y: 0.578125 },
+ { x: 0.359375, y: 0.578125 },
+ { x: 0.359375, y: 0.578125 },
+ { x: 0.390625, y: 0.578125 },
+ { x: 0.390625, y: 0.578125 },
+ { x: 0.421875, y: 0.578125 },
+ { x: 0.421875, y: 0.578125 },
+ { x: 0.453125, y: 0.578125 },
+ { x: 0.453125, y: 0.578125 },
+ { x: 0.484375, y: 0.578125 },
+ { x: 0.484375, y: 0.578125 },
+ { x: 0.515625, y: 0.578125 },
+ { x: 0.515625, y: 0.578125 },
+ { x: 0.546875, y: 0.578125 },
+ { x: 0.546875, y: 0.578125 },
+ { x: 0.578125, y: 0.578125 },
+ { x: 0.578125, y: 0.578125 },
+ { x: 0.609375, y: 0.578125 },
+ { x: 0.609375, y: 0.578125 },
+ { x: 0.640625, y: 0.578125 },
+ { x: 0.640625, y: 0.578125 },
+ { x: 0.671875, y: 0.578125 },
+ { x: 0.671875, y: 0.578125 },
+ { x: 0.703125, y: 0.578125 },
+ { x: 0.703125, y: 0.578125 },
+ { x: 0.734375, y: 0.578125 },
+ { x: 0.734375, y: 0.578125 },
+ { x: 0.765625, y: 0.578125 },
+ { x: 0.765625, y: 0.578125 },
+ { x: 0.796875, y: 0.578125 },
+ { x: 0.796875, y: 0.578125 },
+ { x: 0.828125, y: 0.578125 },
+ { x: 0.828125, y: 0.578125 },
+ { x: 0.859375, y: 0.578125 },
+ { x: 0.859375, y: 0.578125 },
+ { x: 0.890625, y: 0.578125 },
+ { x: 0.890625, y: 0.578125 },
+ { x: 0.921875, y: 0.578125 },
+ { x: 0.921875, y: 0.578125 },
+ { x: 0.953125, y: 0.578125 },
+ { x: 0.953125, y: 0.578125 },
+ { x: 0.984375, y: 0.578125 },
+ { x: 0.984375, y: 0.578125 },
+ { x: 0.015625, y: 0.609375 },
+ { x: 0.015625, y: 0.609375 },
+ { x: 0.046875, y: 0.609375 },
+ { x: 0.046875, y: 0.609375 },
+ { x: 0.078125, y: 0.609375 },
+ { x: 0.078125, y: 0.609375 },
+ { x: 0.109375, y: 0.609375 },
+ { x: 0.109375, y: 0.609375 },
+ { x: 0.140625, y: 0.609375 },
+ { x: 0.140625, y: 0.609375 },
+ { x: 0.171875, y: 0.609375 },
+ { x: 0.171875, y: 0.609375 },
+ { x: 0.203125, y: 0.609375 },
+ { x: 0.203125, y: 0.609375 },
+ { x: 0.234375, y: 0.609375 },
+ { x: 0.234375, y: 0.609375 },
+ { x: 0.265625, y: 0.609375 },
+ { x: 0.265625, y: 0.609375 },
+ { x: 0.296875, y: 0.609375 },
+ { x: 0.296875, y: 0.609375 },
+ { x: 0.328125, y: 0.609375 },
+ { x: 0.328125, y: 0.609375 },
+ { x: 0.359375, y: 0.609375 },
+ { x: 0.359375, y: 0.609375 },
+ { x: 0.390625, y: 0.609375 },
+ { x: 0.390625, y: 0.609375 },
+ { x: 0.421875, y: 0.609375 },
+ { x: 0.421875, y: 0.609375 },
+ { x: 0.453125, y: 0.609375 },
+ { x: 0.453125, y: 0.609375 },
+ { x: 0.484375, y: 0.609375 },
+ { x: 0.484375, y: 0.609375 },
+ { x: 0.515625, y: 0.609375 },
+ { x: 0.515625, y: 0.609375 },
+ { x: 0.546875, y: 0.609375 },
+ { x: 0.546875, y: 0.609375 },
+ { x: 0.578125, y: 0.609375 },
+ { x: 0.578125, y: 0.609375 },
+ { x: 0.609375, y: 0.609375 },
+ { x: 0.609375, y: 0.609375 },
+ { x: 0.640625, y: 0.609375 },
+ { x: 0.640625, y: 0.609375 },
+ { x: 0.671875, y: 0.609375 },
+ { x: 0.671875, y: 0.609375 },
+ { x: 0.703125, y: 0.609375 },
+ { x: 0.703125, y: 0.609375 },
+ { x: 0.734375, y: 0.609375 },
+ { x: 0.734375, y: 0.609375 },
+ { x: 0.765625, y: 0.609375 },
+ { x: 0.765625, y: 0.609375 },
+ { x: 0.796875, y: 0.609375 },
+ { x: 0.796875, y: 0.609375 },
+ { x: 0.828125, y: 0.609375 },
+ { x: 0.828125, y: 0.609375 },
+ { x: 0.859375, y: 0.609375 },
+ { x: 0.859375, y: 0.609375 },
+ { x: 0.890625, y: 0.609375 },
+ { x: 0.890625, y: 0.609375 },
+ { x: 0.921875, y: 0.609375 },
+ { x: 0.921875, y: 0.609375 },
+ { x: 0.953125, y: 0.609375 },
+ { x: 0.953125, y: 0.609375 },
+ { x: 0.984375, y: 0.609375 },
+ { x: 0.984375, y: 0.609375 },
+ { x: 0.015625, y: 0.640625 },
+ { x: 0.015625, y: 0.640625 },
+ { x: 0.046875, y: 0.640625 },
+ { x: 0.046875, y: 0.640625 },
+ { x: 0.078125, y: 0.640625 },
+ { x: 0.078125, y: 0.640625 },
+ { x: 0.109375, y: 0.640625 },
+ { x: 0.109375, y: 0.640625 },
+ { x: 0.140625, y: 0.640625 },
+ { x: 0.140625, y: 0.640625 },
+ { x: 0.171875, y: 0.640625 },
+ { x: 0.171875, y: 0.640625 },
+ { x: 0.203125, y: 0.640625 },
+ { x: 0.203125, y: 0.640625 },
+ { x: 0.234375, y: 0.640625 },
+ { x: 0.234375, y: 0.640625 },
+ { x: 0.265625, y: 0.640625 },
+ { x: 0.265625, y: 0.640625 },
+ { x: 0.296875, y: 0.640625 },
+ { x: 0.296875, y: 0.640625 },
+ { x: 0.328125, y: 0.640625 },
+ { x: 0.328125, y: 0.640625 },
+ { x: 0.359375, y: 0.640625 },
+ { x: 0.359375, y: 0.640625 },
+ { x: 0.390625, y: 0.640625 },
+ { x: 0.390625, y: 0.640625 },
+ { x: 0.421875, y: 0.640625 },
+ { x: 0.421875, y: 0.640625 },
+ { x: 0.453125, y: 0.640625 },
+ { x: 0.453125, y: 0.640625 },
+ { x: 0.484375, y: 0.640625 },
+ { x: 0.484375, y: 0.640625 },
+ { x: 0.515625, y: 0.640625 },
+ { x: 0.515625, y: 0.640625 },
+ { x: 0.546875, y: 0.640625 },
+ { x: 0.546875, y: 0.640625 },
+ { x: 0.578125, y: 0.640625 },
+ { x: 0.578125, y: 0.640625 },
+ { x: 0.609375, y: 0.640625 },
+ { x: 0.609375, y: 0.640625 },
+ { x: 0.640625, y: 0.640625 },
+ { x: 0.640625, y: 0.640625 },
+ { x: 0.671875, y: 0.640625 },
+ { x: 0.671875, y: 0.640625 },
+ { x: 0.703125, y: 0.640625 },
+ { x: 0.703125, y: 0.640625 },
+ { x: 0.734375, y: 0.640625 },
+ { x: 0.734375, y: 0.640625 },
+ { x: 0.765625, y: 0.640625 },
+ { x: 0.765625, y: 0.640625 },
+ { x: 0.796875, y: 0.640625 },
+ { x: 0.796875, y: 0.640625 },
+ { x: 0.828125, y: 0.640625 },
+ { x: 0.828125, y: 0.640625 },
+ { x: 0.859375, y: 0.640625 },
+ { x: 0.859375, y: 0.640625 },
+ { x: 0.890625, y: 0.640625 },
+ { x: 0.890625, y: 0.640625 },
+ { x: 0.921875, y: 0.640625 },
+ { x: 0.921875, y: 0.640625 },
+ { x: 0.953125, y: 0.640625 },
+ { x: 0.953125, y: 0.640625 },
+ { x: 0.984375, y: 0.640625 },
+ { x: 0.984375, y: 0.640625 },
+ { x: 0.015625, y: 0.671875 },
+ { x: 0.015625, y: 0.671875 },
+ { x: 0.046875, y: 0.671875 },
+ { x: 0.046875, y: 0.671875 },
+ { x: 0.078125, y: 0.671875 },
+ { x: 0.078125, y: 0.671875 },
+ { x: 0.109375, y: 0.671875 },
+ { x: 0.109375, y: 0.671875 },
+ { x: 0.140625, y: 0.671875 },
+ { x: 0.140625, y: 0.671875 },
+ { x: 0.171875, y: 0.671875 },
+ { x: 0.171875, y: 0.671875 },
+ { x: 0.203125, y: 0.671875 },
+ { x: 0.203125, y: 0.671875 },
+ { x: 0.234375, y: 0.671875 },
+ { x: 0.234375, y: 0.671875 },
+ { x: 0.265625, y: 0.671875 },
+ { x: 0.265625, y: 0.671875 },
+ { x: 0.296875, y: 0.671875 },
+ { x: 0.296875, y: 0.671875 },
+ { x: 0.328125, y: 0.671875 },
+ { x: 0.328125, y: 0.671875 },
+ { x: 0.359375, y: 0.671875 },
+ { x: 0.359375, y: 0.671875 },
+ { x: 0.390625, y: 0.671875 },
+ { x: 0.390625, y: 0.671875 },
+ { x: 0.421875, y: 0.671875 },
+ { x: 0.421875, y: 0.671875 },
+ { x: 0.453125, y: 0.671875 },
+ { x: 0.453125, y: 0.671875 },
+ { x: 0.484375, y: 0.671875 },
+ { x: 0.484375, y: 0.671875 },
+ { x: 0.515625, y: 0.671875 },
+ { x: 0.515625, y: 0.671875 },
+ { x: 0.546875, y: 0.671875 },
+ { x: 0.546875, y: 0.671875 },
+ { x: 0.578125, y: 0.671875 },
+ { x: 0.578125, y: 0.671875 },
+ { x: 0.609375, y: 0.671875 },
+ { x: 0.609375, y: 0.671875 },
+ { x: 0.640625, y: 0.671875 },
+ { x: 0.640625, y: 0.671875 },
+ { x: 0.671875, y: 0.671875 },
+ { x: 0.671875, y: 0.671875 },
+ { x: 0.703125, y: 0.671875 },
+ { x: 0.703125, y: 0.671875 },
+ { x: 0.734375, y: 0.671875 },
+ { x: 0.734375, y: 0.671875 },
+ { x: 0.765625, y: 0.671875 },
+ { x: 0.765625, y: 0.671875 },
+ { x: 0.796875, y: 0.671875 },
+ { x: 0.796875, y: 0.671875 },
+ { x: 0.828125, y: 0.671875 },
+ { x: 0.828125, y: 0.671875 },
+ { x: 0.859375, y: 0.671875 },
+ { x: 0.859375, y: 0.671875 },
+ { x: 0.890625, y: 0.671875 },
+ { x: 0.890625, y: 0.671875 },
+ { x: 0.921875, y: 0.671875 },
+ { x: 0.921875, y: 0.671875 },
+ { x: 0.953125, y: 0.671875 },
+ { x: 0.953125, y: 0.671875 },
+ { x: 0.984375, y: 0.671875 },
+ { x: 0.984375, y: 0.671875 },
+ { x: 0.015625, y: 0.703125 },
+ { x: 0.015625, y: 0.703125 },
+ { x: 0.046875, y: 0.703125 },
+ { x: 0.046875, y: 0.703125 },
+ { x: 0.078125, y: 0.703125 },
+ { x: 0.078125, y: 0.703125 },
+ { x: 0.109375, y: 0.703125 },
+ { x: 0.109375, y: 0.703125 },
+ { x: 0.140625, y: 0.703125 },
+ { x: 0.140625, y: 0.703125 },
+ { x: 0.171875, y: 0.703125 },
+ { x: 0.171875, y: 0.703125 },
+ { x: 0.203125, y: 0.703125 },
+ { x: 0.203125, y: 0.703125 },
+ { x: 0.234375, y: 0.703125 },
+ { x: 0.234375, y: 0.703125 },
+ { x: 0.265625, y: 0.703125 },
+ { x: 0.265625, y: 0.703125 },
+ { x: 0.296875, y: 0.703125 },
+ { x: 0.296875, y: 0.703125 },
+ { x: 0.328125, y: 0.703125 },
+ { x: 0.328125, y: 0.703125 },
+ { x: 0.359375, y: 0.703125 },
+ { x: 0.359375, y: 0.703125 },
+ { x: 0.390625, y: 0.703125 },
+ { x: 0.390625, y: 0.703125 },
+ { x: 0.421875, y: 0.703125 },
+ { x: 0.421875, y: 0.703125 },
+ { x: 0.453125, y: 0.703125 },
+ { x: 0.453125, y: 0.703125 },
+ { x: 0.484375, y: 0.703125 },
+ { x: 0.484375, y: 0.703125 },
+ { x: 0.515625, y: 0.703125 },
+ { x: 0.515625, y: 0.703125 },
+ { x: 0.546875, y: 0.703125 },
+ { x: 0.546875, y: 0.703125 },
+ { x: 0.578125, y: 0.703125 },
+ { x: 0.578125, y: 0.703125 },
+ { x: 0.609375, y: 0.703125 },
+ { x: 0.609375, y: 0.703125 },
+ { x: 0.640625, y: 0.703125 },
+ { x: 0.640625, y: 0.703125 },
+ { x: 0.671875, y: 0.703125 },
+ { x: 0.671875, y: 0.703125 },
+ { x: 0.703125, y: 0.703125 },
+ { x: 0.703125, y: 0.703125 },
+ { x: 0.734375, y: 0.703125 },
+ { x: 0.734375, y: 0.703125 },
+ { x: 0.765625, y: 0.703125 },
+ { x: 0.765625, y: 0.703125 },
+ { x: 0.796875, y: 0.703125 },
+ { x: 0.796875, y: 0.703125 },
+ { x: 0.828125, y: 0.703125 },
+ { x: 0.828125, y: 0.703125 },
+ { x: 0.859375, y: 0.703125 },
+ { x: 0.859375, y: 0.703125 },
+ { x: 0.890625, y: 0.703125 },
+ { x: 0.890625, y: 0.703125 },
+ { x: 0.921875, y: 0.703125 },
+ { x: 0.921875, y: 0.703125 },
+ { x: 0.953125, y: 0.703125 },
+ { x: 0.953125, y: 0.703125 },
+ { x: 0.984375, y: 0.703125 },
+ { x: 0.984375, y: 0.703125 },
+ { x: 0.015625, y: 0.734375 },
+ { x: 0.015625, y: 0.734375 },
+ { x: 0.046875, y: 0.734375 },
+ { x: 0.046875, y: 0.734375 },
+ { x: 0.078125, y: 0.734375 },
+ { x: 0.078125, y: 0.734375 },
+ { x: 0.109375, y: 0.734375 },
+ { x: 0.109375, y: 0.734375 },
+ { x: 0.140625, y: 0.734375 },
+ { x: 0.140625, y: 0.734375 },
+ { x: 0.171875, y: 0.734375 },
+ { x: 0.171875, y: 0.734375 },
+ { x: 0.203125, y: 0.734375 },
+ { x: 0.203125, y: 0.734375 },
+ { x: 0.234375, y: 0.734375 },
+ { x: 0.234375, y: 0.734375 },
+ { x: 0.265625, y: 0.734375 },
+ { x: 0.265625, y: 0.734375 },
+ { x: 0.296875, y: 0.734375 },
+ { x: 0.296875, y: 0.734375 },
+ { x: 0.328125, y: 0.734375 },
+ { x: 0.328125, y: 0.734375 },
+ { x: 0.359375, y: 0.734375 },
+ { x: 0.359375, y: 0.734375 },
+ { x: 0.390625, y: 0.734375 },
+ { x: 0.390625, y: 0.734375 },
+ { x: 0.421875, y: 0.734375 },
+ { x: 0.421875, y: 0.734375 },
+ { x: 0.453125, y: 0.734375 },
+ { x: 0.453125, y: 0.734375 },
+ { x: 0.484375, y: 0.734375 },
+ { x: 0.484375, y: 0.734375 },
+ { x: 0.515625, y: 0.734375 },
+ { x: 0.515625, y: 0.734375 },
+ { x: 0.546875, y: 0.734375 },
+ { x: 0.546875, y: 0.734375 },
+ { x: 0.578125, y: 0.734375 },
+ { x: 0.578125, y: 0.734375 },
+ { x: 0.609375, y: 0.734375 },
+ { x: 0.609375, y: 0.734375 },
+ { x: 0.640625, y: 0.734375 },
+ { x: 0.640625, y: 0.734375 },
+ { x: 0.671875, y: 0.734375 },
+ { x: 0.671875, y: 0.734375 },
+ { x: 0.703125, y: 0.734375 },
+ { x: 0.703125, y: 0.734375 },
+ { x: 0.734375, y: 0.734375 },
+ { x: 0.734375, y: 0.734375 },
+ { x: 0.765625, y: 0.734375 },
+ { x: 0.765625, y: 0.734375 },
+ { x: 0.796875, y: 0.734375 },
+ { x: 0.796875, y: 0.734375 },
+ { x: 0.828125, y: 0.734375 },
+ { x: 0.828125, y: 0.734375 },
+ { x: 0.859375, y: 0.734375 },
+ { x: 0.859375, y: 0.734375 },
+ { x: 0.890625, y: 0.734375 },
+ { x: 0.890625, y: 0.734375 },
+ { x: 0.921875, y: 0.734375 },
+ { x: 0.921875, y: 0.734375 },
+ { x: 0.953125, y: 0.734375 },
+ { x: 0.953125, y: 0.734375 },
+ { x: 0.984375, y: 0.734375 },
+ { x: 0.984375, y: 0.734375 },
+ { x: 0.015625, y: 0.765625 },
+ { x: 0.015625, y: 0.765625 },
+ { x: 0.046875, y: 0.765625 },
+ { x: 0.046875, y: 0.765625 },
+ { x: 0.078125, y: 0.765625 },
+ { x: 0.078125, y: 0.765625 },
+ { x: 0.109375, y: 0.765625 },
+ { x: 0.109375, y: 0.765625 },
+ { x: 0.140625, y: 0.765625 },
+ { x: 0.140625, y: 0.765625 },
+ { x: 0.171875, y: 0.765625 },
+ { x: 0.171875, y: 0.765625 },
+ { x: 0.203125, y: 0.765625 },
+ { x: 0.203125, y: 0.765625 },
+ { x: 0.234375, y: 0.765625 },
+ { x: 0.234375, y: 0.765625 },
+ { x: 0.265625, y: 0.765625 },
+ { x: 0.265625, y: 0.765625 },
+ { x: 0.296875, y: 0.765625 },
+ { x: 0.296875, y: 0.765625 },
+ { x: 0.328125, y: 0.765625 },
+ { x: 0.328125, y: 0.765625 },
+ { x: 0.359375, y: 0.765625 },
+ { x: 0.359375, y: 0.765625 },
+ { x: 0.390625, y: 0.765625 },
+ { x: 0.390625, y: 0.765625 },
+ { x: 0.421875, y: 0.765625 },
+ { x: 0.421875, y: 0.765625 },
+ { x: 0.453125, y: 0.765625 },
+ { x: 0.453125, y: 0.765625 },
+ { x: 0.484375, y: 0.765625 },
+ { x: 0.484375, y: 0.765625 },
+ { x: 0.515625, y: 0.765625 },
+ { x: 0.515625, y: 0.765625 },
+ { x: 0.546875, y: 0.765625 },
+ { x: 0.546875, y: 0.765625 },
+ { x: 0.578125, y: 0.765625 },
+ { x: 0.578125, y: 0.765625 },
+ { x: 0.609375, y: 0.765625 },
+ { x: 0.609375, y: 0.765625 },
+ { x: 0.640625, y: 0.765625 },
+ { x: 0.640625, y: 0.765625 },
+ { x: 0.671875, y: 0.765625 },
+ { x: 0.671875, y: 0.765625 },
+ { x: 0.703125, y: 0.765625 },
+ { x: 0.703125, y: 0.765625 },
+ { x: 0.734375, y: 0.765625 },
+ { x: 0.734375, y: 0.765625 },
+ { x: 0.765625, y: 0.765625 },
+ { x: 0.765625, y: 0.765625 },
+ { x: 0.796875, y: 0.765625 },
+ { x: 0.796875, y: 0.765625 },
+ { x: 0.828125, y: 0.765625 },
+ { x: 0.828125, y: 0.765625 },
+ { x: 0.859375, y: 0.765625 },
+ { x: 0.859375, y: 0.765625 },
+ { x: 0.890625, y: 0.765625 },
+ { x: 0.890625, y: 0.765625 },
+ { x: 0.921875, y: 0.765625 },
+ { x: 0.921875, y: 0.765625 },
+ { x: 0.953125, y: 0.765625 },
+ { x: 0.953125, y: 0.765625 },
+ { x: 0.984375, y: 0.765625 },
+ { x: 0.984375, y: 0.765625 },
+ { x: 0.015625, y: 0.796875 },
+ { x: 0.015625, y: 0.796875 },
+ { x: 0.046875, y: 0.796875 },
+ { x: 0.046875, y: 0.796875 },
+ { x: 0.078125, y: 0.796875 },
+ { x: 0.078125, y: 0.796875 },
+ { x: 0.109375, y: 0.796875 },
+ { x: 0.109375, y: 0.796875 },
+ { x: 0.140625, y: 0.796875 },
+ { x: 0.140625, y: 0.796875 },
+ { x: 0.171875, y: 0.796875 },
+ { x: 0.171875, y: 0.796875 },
+ { x: 0.203125, y: 0.796875 },
+ { x: 0.203125, y: 0.796875 },
+ { x: 0.234375, y: 0.796875 },
+ { x: 0.234375, y: 0.796875 },
+ { x: 0.265625, y: 0.796875 },
+ { x: 0.265625, y: 0.796875 },
+ { x: 0.296875, y: 0.796875 },
+ { x: 0.296875, y: 0.796875 },
+ { x: 0.328125, y: 0.796875 },
+ { x: 0.328125, y: 0.796875 },
+ { x: 0.359375, y: 0.796875 },
+ { x: 0.359375, y: 0.796875 },
+ { x: 0.390625, y: 0.796875 },
+ { x: 0.390625, y: 0.796875 },
+ { x: 0.421875, y: 0.796875 },
+ { x: 0.421875, y: 0.796875 },
+ { x: 0.453125, y: 0.796875 },
+ { x: 0.453125, y: 0.796875 },
+ { x: 0.484375, y: 0.796875 },
+ { x: 0.484375, y: 0.796875 },
+ { x: 0.515625, y: 0.796875 },
+ { x: 0.515625, y: 0.796875 },
+ { x: 0.546875, y: 0.796875 },
+ { x: 0.546875, y: 0.796875 },
+ { x: 0.578125, y: 0.796875 },
+ { x: 0.578125, y: 0.796875 },
+ { x: 0.609375, y: 0.796875 },
+ { x: 0.609375, y: 0.796875 },
+ { x: 0.640625, y: 0.796875 },
+ { x: 0.640625, y: 0.796875 },
+ { x: 0.671875, y: 0.796875 },
+ { x: 0.671875, y: 0.796875 },
+ { x: 0.703125, y: 0.796875 },
+ { x: 0.703125, y: 0.796875 },
+ { x: 0.734375, y: 0.796875 },
+ { x: 0.734375, y: 0.796875 },
+ { x: 0.765625, y: 0.796875 },
+ { x: 0.765625, y: 0.796875 },
+ { x: 0.796875, y: 0.796875 },
+ { x: 0.796875, y: 0.796875 },
+ { x: 0.828125, y: 0.796875 },
+ { x: 0.828125, y: 0.796875 },
+ { x: 0.859375, y: 0.796875 },
+ { x: 0.859375, y: 0.796875 },
+ { x: 0.890625, y: 0.796875 },
+ { x: 0.890625, y: 0.796875 },
+ { x: 0.921875, y: 0.796875 },
+ { x: 0.921875, y: 0.796875 },
+ { x: 0.953125, y: 0.796875 },
+ { x: 0.953125, y: 0.796875 },
+ { x: 0.984375, y: 0.796875 },
+ { x: 0.984375, y: 0.796875 },
+ { x: 0.015625, y: 0.828125 },
+ { x: 0.015625, y: 0.828125 },
+ { x: 0.046875, y: 0.828125 },
+ { x: 0.046875, y: 0.828125 },
+ { x: 0.078125, y: 0.828125 },
+ { x: 0.078125, y: 0.828125 },
+ { x: 0.109375, y: 0.828125 },
+ { x: 0.109375, y: 0.828125 },
+ { x: 0.140625, y: 0.828125 },
+ { x: 0.140625, y: 0.828125 },
+ { x: 0.171875, y: 0.828125 },
+ { x: 0.171875, y: 0.828125 },
+ { x: 0.203125, y: 0.828125 },
+ { x: 0.203125, y: 0.828125 },
+ { x: 0.234375, y: 0.828125 },
+ { x: 0.234375, y: 0.828125 },
+ { x: 0.265625, y: 0.828125 },
+ { x: 0.265625, y: 0.828125 },
+ { x: 0.296875, y: 0.828125 },
+ { x: 0.296875, y: 0.828125 },
+ { x: 0.328125, y: 0.828125 },
+ { x: 0.328125, y: 0.828125 },
+ { x: 0.359375, y: 0.828125 },
+ { x: 0.359375, y: 0.828125 },
+ { x: 0.390625, y: 0.828125 },
+ { x: 0.390625, y: 0.828125 },
+ { x: 0.421875, y: 0.828125 },
+ { x: 0.421875, y: 0.828125 },
+ { x: 0.453125, y: 0.828125 },
+ { x: 0.453125, y: 0.828125 },
+ { x: 0.484375, y: 0.828125 },
+ { x: 0.484375, y: 0.828125 },
+ { x: 0.515625, y: 0.828125 },
+ { x: 0.515625, y: 0.828125 },
+ { x: 0.546875, y: 0.828125 },
+ { x: 0.546875, y: 0.828125 },
+ { x: 0.578125, y: 0.828125 },
+ { x: 0.578125, y: 0.828125 },
+ { x: 0.609375, y: 0.828125 },
+ { x: 0.609375, y: 0.828125 },
+ { x: 0.640625, y: 0.828125 },
+ { x: 0.640625, y: 0.828125 },
+ { x: 0.671875, y: 0.828125 },
+ { x: 0.671875, y: 0.828125 },
+ { x: 0.703125, y: 0.828125 },
+ { x: 0.703125, y: 0.828125 },
+ { x: 0.734375, y: 0.828125 },
+ { x: 0.734375, y: 0.828125 },
+ { x: 0.765625, y: 0.828125 },
+ { x: 0.765625, y: 0.828125 },
+ { x: 0.796875, y: 0.828125 },
+ { x: 0.796875, y: 0.828125 },
+ { x: 0.828125, y: 0.828125 },
+ { x: 0.828125, y: 0.828125 },
+ { x: 0.859375, y: 0.828125 },
+ { x: 0.859375, y: 0.828125 },
+ { x: 0.890625, y: 0.828125 },
+ { x: 0.890625, y: 0.828125 },
+ { x: 0.921875, y: 0.828125 },
+ { x: 0.921875, y: 0.828125 },
+ { x: 0.953125, y: 0.828125 },
+ { x: 0.953125, y: 0.828125 },
+ { x: 0.984375, y: 0.828125 },
+ { x: 0.984375, y: 0.828125 },
+ { x: 0.015625, y: 0.859375 },
+ { x: 0.015625, y: 0.859375 },
+ { x: 0.046875, y: 0.859375 },
+ { x: 0.046875, y: 0.859375 },
+ { x: 0.078125, y: 0.859375 },
+ { x: 0.078125, y: 0.859375 },
+ { x: 0.109375, y: 0.859375 },
+ { x: 0.109375, y: 0.859375 },
+ { x: 0.140625, y: 0.859375 },
+ { x: 0.140625, y: 0.859375 },
+ { x: 0.171875, y: 0.859375 },
+ { x: 0.171875, y: 0.859375 },
+ { x: 0.203125, y: 0.859375 },
+ { x: 0.203125, y: 0.859375 },
+ { x: 0.234375, y: 0.859375 },
+ { x: 0.234375, y: 0.859375 },
+ { x: 0.265625, y: 0.859375 },
+ { x: 0.265625, y: 0.859375 },
+ { x: 0.296875, y: 0.859375 },
+ { x: 0.296875, y: 0.859375 },
+ { x: 0.328125, y: 0.859375 },
+ { x: 0.328125, y: 0.859375 },
+ { x: 0.359375, y: 0.859375 },
+ { x: 0.359375, y: 0.859375 },
+ { x: 0.390625, y: 0.859375 },
+ { x: 0.390625, y: 0.859375 },
+ { x: 0.421875, y: 0.859375 },
+ { x: 0.421875, y: 0.859375 },
+ { x: 0.453125, y: 0.859375 },
+ { x: 0.453125, y: 0.859375 },
+ { x: 0.484375, y: 0.859375 },
+ { x: 0.484375, y: 0.859375 },
+ { x: 0.515625, y: 0.859375 },
+ { x: 0.515625, y: 0.859375 },
+ { x: 0.546875, y: 0.859375 },
+ { x: 0.546875, y: 0.859375 },
+ { x: 0.578125, y: 0.859375 },
+ { x: 0.578125, y: 0.859375 },
+ { x: 0.609375, y: 0.859375 },
+ { x: 0.609375, y: 0.859375 },
+ { x: 0.640625, y: 0.859375 },
+ { x: 0.640625, y: 0.859375 },
+ { x: 0.671875, y: 0.859375 },
+ { x: 0.671875, y: 0.859375 },
+ { x: 0.703125, y: 0.859375 },
+ { x: 0.703125, y: 0.859375 },
+ { x: 0.734375, y: 0.859375 },
+ { x: 0.734375, y: 0.859375 },
+ { x: 0.765625, y: 0.859375 },
+ { x: 0.765625, y: 0.859375 },
+ { x: 0.796875, y: 0.859375 },
+ { x: 0.796875, y: 0.859375 },
+ { x: 0.828125, y: 0.859375 },
+ { x: 0.828125, y: 0.859375 },
+ { x: 0.859375, y: 0.859375 },
+ { x: 0.859375, y: 0.859375 },
+ { x: 0.890625, y: 0.859375 },
+ { x: 0.890625, y: 0.859375 },
+ { x: 0.921875, y: 0.859375 },
+ { x: 0.921875, y: 0.859375 },
+ { x: 0.953125, y: 0.859375 },
+ { x: 0.953125, y: 0.859375 },
+ { x: 0.984375, y: 0.859375 },
+ { x: 0.984375, y: 0.859375 },
+ { x: 0.015625, y: 0.890625 },
+ { x: 0.015625, y: 0.890625 },
+ { x: 0.046875, y: 0.890625 },
+ { x: 0.046875, y: 0.890625 },
+ { x: 0.078125, y: 0.890625 },
+ { x: 0.078125, y: 0.890625 },
+ { x: 0.109375, y: 0.890625 },
+ { x: 0.109375, y: 0.890625 },
+ { x: 0.140625, y: 0.890625 },
+ { x: 0.140625, y: 0.890625 },
+ { x: 0.171875, y: 0.890625 },
+ { x: 0.171875, y: 0.890625 },
+ { x: 0.203125, y: 0.890625 },
+ { x: 0.203125, y: 0.890625 },
+ { x: 0.234375, y: 0.890625 },
+ { x: 0.234375, y: 0.890625 },
+ { x: 0.265625, y: 0.890625 },
+ { x: 0.265625, y: 0.890625 },
+ { x: 0.296875, y: 0.890625 },
+ { x: 0.296875, y: 0.890625 },
+ { x: 0.328125, y: 0.890625 },
+ { x: 0.328125, y: 0.890625 },
+ { x: 0.359375, y: 0.890625 },
+ { x: 0.359375, y: 0.890625 },
+ { x: 0.390625, y: 0.890625 },
+ { x: 0.390625, y: 0.890625 },
+ { x: 0.421875, y: 0.890625 },
+ { x: 0.421875, y: 0.890625 },
+ { x: 0.453125, y: 0.890625 },
+ { x: 0.453125, y: 0.890625 },
+ { x: 0.484375, y: 0.890625 },
+ { x: 0.484375, y: 0.890625 },
+ { x: 0.515625, y: 0.890625 },
+ { x: 0.515625, y: 0.890625 },
+ { x: 0.546875, y: 0.890625 },
+ { x: 0.546875, y: 0.890625 },
+ { x: 0.578125, y: 0.890625 },
+ { x: 0.578125, y: 0.890625 },
+ { x: 0.609375, y: 0.890625 },
+ { x: 0.609375, y: 0.890625 },
+ { x: 0.640625, y: 0.890625 },
+ { x: 0.640625, y: 0.890625 },
+ { x: 0.671875, y: 0.890625 },
+ { x: 0.671875, y: 0.890625 },
+ { x: 0.703125, y: 0.890625 },
+ { x: 0.703125, y: 0.890625 },
+ { x: 0.734375, y: 0.890625 },
+ { x: 0.734375, y: 0.890625 },
+ { x: 0.765625, y: 0.890625 },
+ { x: 0.765625, y: 0.890625 },
+ { x: 0.796875, y: 0.890625 },
+ { x: 0.796875, y: 0.890625 },
+ { x: 0.828125, y: 0.890625 },
+ { x: 0.828125, y: 0.890625 },
+ { x: 0.859375, y: 0.890625 },
+ { x: 0.859375, y: 0.890625 },
+ { x: 0.890625, y: 0.890625 },
+ { x: 0.890625, y: 0.890625 },
+ { x: 0.921875, y: 0.890625 },
+ { x: 0.921875, y: 0.890625 },
+ { x: 0.953125, y: 0.890625 },
+ { x: 0.953125, y: 0.890625 },
+ { x: 0.984375, y: 0.890625 },
+ { x: 0.984375, y: 0.890625 },
+ { x: 0.015625, y: 0.921875 },
+ { x: 0.015625, y: 0.921875 },
+ { x: 0.046875, y: 0.921875 },
+ { x: 0.046875, y: 0.921875 },
+ { x: 0.078125, y: 0.921875 },
+ { x: 0.078125, y: 0.921875 },
+ { x: 0.109375, y: 0.921875 },
+ { x: 0.109375, y: 0.921875 },
+ { x: 0.140625, y: 0.921875 },
+ { x: 0.140625, y: 0.921875 },
+ { x: 0.171875, y: 0.921875 },
+ { x: 0.171875, y: 0.921875 },
+ { x: 0.203125, y: 0.921875 },
+ { x: 0.203125, y: 0.921875 },
+ { x: 0.234375, y: 0.921875 },
+ { x: 0.234375, y: 0.921875 },
+ { x: 0.265625, y: 0.921875 },
+ { x: 0.265625, y: 0.921875 },
+ { x: 0.296875, y: 0.921875 },
+ { x: 0.296875, y: 0.921875 },
+ { x: 0.328125, y: 0.921875 },
+ { x: 0.328125, y: 0.921875 },
+ { x: 0.359375, y: 0.921875 },
+ { x: 0.359375, y: 0.921875 },
+ { x: 0.390625, y: 0.921875 },
+ { x: 0.390625, y: 0.921875 },
+ { x: 0.421875, y: 0.921875 },
+ { x: 0.421875, y: 0.921875 },
+ { x: 0.453125, y: 0.921875 },
+ { x: 0.453125, y: 0.921875 },
+ { x: 0.484375, y: 0.921875 },
+ { x: 0.484375, y: 0.921875 },
+ { x: 0.515625, y: 0.921875 },
+ { x: 0.515625, y: 0.921875 },
+ { x: 0.546875, y: 0.921875 },
+ { x: 0.546875, y: 0.921875 },
+ { x: 0.578125, y: 0.921875 },
+ { x: 0.578125, y: 0.921875 },
+ { x: 0.609375, y: 0.921875 },
+ { x: 0.609375, y: 0.921875 },
+ { x: 0.640625, y: 0.921875 },
+ { x: 0.640625, y: 0.921875 },
+ { x: 0.671875, y: 0.921875 },
+ { x: 0.671875, y: 0.921875 },
+ { x: 0.703125, y: 0.921875 },
+ { x: 0.703125, y: 0.921875 },
+ { x: 0.734375, y: 0.921875 },
+ { x: 0.734375, y: 0.921875 },
+ { x: 0.765625, y: 0.921875 },
+ { x: 0.765625, y: 0.921875 },
+ { x: 0.796875, y: 0.921875 },
+ { x: 0.796875, y: 0.921875 },
+ { x: 0.828125, y: 0.921875 },
+ { x: 0.828125, y: 0.921875 },
+ { x: 0.859375, y: 0.921875 },
+ { x: 0.859375, y: 0.921875 },
+ { x: 0.890625, y: 0.921875 },
+ { x: 0.890625, y: 0.921875 },
+ { x: 0.921875, y: 0.921875 },
+ { x: 0.921875, y: 0.921875 },
+ { x: 0.953125, y: 0.921875 },
+ { x: 0.953125, y: 0.921875 },
+ { x: 0.984375, y: 0.921875 },
+ { x: 0.984375, y: 0.921875 },
+ { x: 0.015625, y: 0.953125 },
+ { x: 0.015625, y: 0.953125 },
+ { x: 0.046875, y: 0.953125 },
+ { x: 0.046875, y: 0.953125 },
+ { x: 0.078125, y: 0.953125 },
+ { x: 0.078125, y: 0.953125 },
+ { x: 0.109375, y: 0.953125 },
+ { x: 0.109375, y: 0.953125 },
+ { x: 0.140625, y: 0.953125 },
+ { x: 0.140625, y: 0.953125 },
+ { x: 0.171875, y: 0.953125 },
+ { x: 0.171875, y: 0.953125 },
+ { x: 0.203125, y: 0.953125 },
+ { x: 0.203125, y: 0.953125 },
+ { x: 0.234375, y: 0.953125 },
+ { x: 0.234375, y: 0.953125 },
+ { x: 0.265625, y: 0.953125 },
+ { x: 0.265625, y: 0.953125 },
+ { x: 0.296875, y: 0.953125 },
+ { x: 0.296875, y: 0.953125 },
+ { x: 0.328125, y: 0.953125 },
+ { x: 0.328125, y: 0.953125 },
+ { x: 0.359375, y: 0.953125 },
+ { x: 0.359375, y: 0.953125 },
+ { x: 0.390625, y: 0.953125 },
+ { x: 0.390625, y: 0.953125 },
+ { x: 0.421875, y: 0.953125 },
+ { x: 0.421875, y: 0.953125 },
+ { x: 0.453125, y: 0.953125 },
+ { x: 0.453125, y: 0.953125 },
+ { x: 0.484375, y: 0.953125 },
+ { x: 0.484375, y: 0.953125 },
+ { x: 0.515625, y: 0.953125 },
+ { x: 0.515625, y: 0.953125 },
+ { x: 0.546875, y: 0.953125 },
+ { x: 0.546875, y: 0.953125 },
+ { x: 0.578125, y: 0.953125 },
+ { x: 0.578125, y: 0.953125 },
+ { x: 0.609375, y: 0.953125 },
+ { x: 0.609375, y: 0.953125 },
+ { x: 0.640625, y: 0.953125 },
+ { x: 0.640625, y: 0.953125 },
+ { x: 0.671875, y: 0.953125 },
+ { x: 0.671875, y: 0.953125 },
+ { x: 0.703125, y: 0.953125 },
+ { x: 0.703125, y: 0.953125 },
+ { x: 0.734375, y: 0.953125 },
+ { x: 0.734375, y: 0.953125 },
+ { x: 0.765625, y: 0.953125 },
+ { x: 0.765625, y: 0.953125 },
+ { x: 0.796875, y: 0.953125 },
+ { x: 0.796875, y: 0.953125 },
+ { x: 0.828125, y: 0.953125 },
+ { x: 0.828125, y: 0.953125 },
+ { x: 0.859375, y: 0.953125 },
+ { x: 0.859375, y: 0.953125 },
+ { x: 0.890625, y: 0.953125 },
+ { x: 0.890625, y: 0.953125 },
+ { x: 0.921875, y: 0.953125 },
+ { x: 0.921875, y: 0.953125 },
+ { x: 0.953125, y: 0.953125 },
+ { x: 0.953125, y: 0.953125 },
+ { x: 0.984375, y: 0.953125 },
+ { x: 0.984375, y: 0.953125 },
+ { x: 0.015625, y: 0.984375 },
+ { x: 0.015625, y: 0.984375 },
+ { x: 0.046875, y: 0.984375 },
+ { x: 0.046875, y: 0.984375 },
+ { x: 0.078125, y: 0.984375 },
+ { x: 0.078125, y: 0.984375 },
+ { x: 0.109375, y: 0.984375 },
+ { x: 0.109375, y: 0.984375 },
+ { x: 0.140625, y: 0.984375 },
+ { x: 0.140625, y: 0.984375 },
+ { x: 0.171875, y: 0.984375 },
+ { x: 0.171875, y: 0.984375 },
+ { x: 0.203125, y: 0.984375 },
+ { x: 0.203125, y: 0.984375 },
+ { x: 0.234375, y: 0.984375 },
+ { x: 0.234375, y: 0.984375 },
+ { x: 0.265625, y: 0.984375 },
+ { x: 0.265625, y: 0.984375 },
+ { x: 0.296875, y: 0.984375 },
+ { x: 0.296875, y: 0.984375 },
+ { x: 0.328125, y: 0.984375 },
+ { x: 0.328125, y: 0.984375 },
+ { x: 0.359375, y: 0.984375 },
+ { x: 0.359375, y: 0.984375 },
+ { x: 0.390625, y: 0.984375 },
+ { x: 0.390625, y: 0.984375 },
+ { x: 0.421875, y: 0.984375 },
+ { x: 0.421875, y: 0.984375 },
+ { x: 0.453125, y: 0.984375 },
+ { x: 0.453125, y: 0.984375 },
+ { x: 0.484375, y: 0.984375 },
+ { x: 0.484375, y: 0.984375 },
+ { x: 0.515625, y: 0.984375 },
+ { x: 0.515625, y: 0.984375 },
+ { x: 0.546875, y: 0.984375 },
+ { x: 0.546875, y: 0.984375 },
+ { x: 0.578125, y: 0.984375 },
+ { x: 0.578125, y: 0.984375 },
+ { x: 0.609375, y: 0.984375 },
+ { x: 0.609375, y: 0.984375 },
+ { x: 0.640625, y: 0.984375 },
+ { x: 0.640625, y: 0.984375 },
+ { x: 0.671875, y: 0.984375 },
+ { x: 0.671875, y: 0.984375 },
+ { x: 0.703125, y: 0.984375 },
+ { x: 0.703125, y: 0.984375 },
+ { x: 0.734375, y: 0.984375 },
+ { x: 0.734375, y: 0.984375 },
+ { x: 0.765625, y: 0.984375 },
+ { x: 0.765625, y: 0.984375 },
+ { x: 0.796875, y: 0.984375 },
+ { x: 0.796875, y: 0.984375 },
+ { x: 0.828125, y: 0.984375 },
+ { x: 0.828125, y: 0.984375 },
+ { x: 0.859375, y: 0.984375 },
+ { x: 0.859375, y: 0.984375 },
+ { x: 0.890625, y: 0.984375 },
+ { x: 0.890625, y: 0.984375 },
+ { x: 0.921875, y: 0.984375 },
+ { x: 0.921875, y: 0.984375 },
+ { x: 0.953125, y: 0.984375 },
+ { x: 0.953125, y: 0.984375 },
+ { x: 0.984375, y: 0.984375 },
+ { x: 0.984375, y: 0.984375 },
+ { x: 0.03125, y: 0.03125 },
+ { x: 0.03125, y: 0.03125 },
+ { x: 0.09375, y: 0.03125 },
+ { x: 0.09375, y: 0.03125 },
+ { x: 0.15625, y: 0.03125 },
+ { x: 0.15625, y: 0.03125 },
+ { x: 0.21875, y: 0.03125 },
+ { x: 0.21875, y: 0.03125 },
+ { x: 0.28125, y: 0.03125 },
+ { x: 0.28125, y: 0.03125 },
+ { x: 0.34375, y: 0.03125 },
+ { x: 0.34375, y: 0.03125 },
+ { x: 0.40625, y: 0.03125 },
+ { x: 0.40625, y: 0.03125 },
+ { x: 0.46875, y: 0.03125 },
+ { x: 0.46875, y: 0.03125 },
+ { x: 0.53125, y: 0.03125 },
+ { x: 0.53125, y: 0.03125 },
+ { x: 0.59375, y: 0.03125 },
+ { x: 0.59375, y: 0.03125 },
+ { x: 0.65625, y: 0.03125 },
+ { x: 0.65625, y: 0.03125 },
+ { x: 0.71875, y: 0.03125 },
+ { x: 0.71875, y: 0.03125 },
+ { x: 0.78125, y: 0.03125 },
+ { x: 0.78125, y: 0.03125 },
+ { x: 0.84375, y: 0.03125 },
+ { x: 0.84375, y: 0.03125 },
+ { x: 0.90625, y: 0.03125 },
+ { x: 0.90625, y: 0.03125 },
+ { x: 0.96875, y: 0.03125 },
+ { x: 0.96875, y: 0.03125 },
+ { x: 0.03125, y: 0.09375 },
+ { x: 0.03125, y: 0.09375 },
+ { x: 0.09375, y: 0.09375 },
+ { x: 0.09375, y: 0.09375 },
+ { x: 0.15625, y: 0.09375 },
+ { x: 0.15625, y: 0.09375 },
+ { x: 0.21875, y: 0.09375 },
+ { x: 0.21875, y: 0.09375 },
+ { x: 0.28125, y: 0.09375 },
+ { x: 0.28125, y: 0.09375 },
+ { x: 0.34375, y: 0.09375 },
+ { x: 0.34375, y: 0.09375 },
+ { x: 0.40625, y: 0.09375 },
+ { x: 0.40625, y: 0.09375 },
+ { x: 0.46875, y: 0.09375 },
+ { x: 0.46875, y: 0.09375 },
+ { x: 0.53125, y: 0.09375 },
+ { x: 0.53125, y: 0.09375 },
+ { x: 0.59375, y: 0.09375 },
+ { x: 0.59375, y: 0.09375 },
+ { x: 0.65625, y: 0.09375 },
+ { x: 0.65625, y: 0.09375 },
+ { x: 0.71875, y: 0.09375 },
+ { x: 0.71875, y: 0.09375 },
+ { x: 0.78125, y: 0.09375 },
+ { x: 0.78125, y: 0.09375 },
+ { x: 0.84375, y: 0.09375 },
+ { x: 0.84375, y: 0.09375 },
+ { x: 0.90625, y: 0.09375 },
+ { x: 0.90625, y: 0.09375 },
+ { x: 0.96875, y: 0.09375 },
+ { x: 0.96875, y: 0.09375 },
+ { x: 0.03125, y: 0.15625 },
+ { x: 0.03125, y: 0.15625 },
+ { x: 0.09375, y: 0.15625 },
+ { x: 0.09375, y: 0.15625 },
+ { x: 0.15625, y: 0.15625 },
+ { x: 0.15625, y: 0.15625 },
+ { x: 0.21875, y: 0.15625 },
+ { x: 0.21875, y: 0.15625 },
+ { x: 0.28125, y: 0.15625 },
+ { x: 0.28125, y: 0.15625 },
+ { x: 0.34375, y: 0.15625 },
+ { x: 0.34375, y: 0.15625 },
+ { x: 0.40625, y: 0.15625 },
+ { x: 0.40625, y: 0.15625 },
+ { x: 0.46875, y: 0.15625 },
+ { x: 0.46875, y: 0.15625 },
+ { x: 0.53125, y: 0.15625 },
+ { x: 0.53125, y: 0.15625 },
+ { x: 0.59375, y: 0.15625 },
+ { x: 0.59375, y: 0.15625 },
+ { x: 0.65625, y: 0.15625 },
+ { x: 0.65625, y: 0.15625 },
+ { x: 0.71875, y: 0.15625 },
+ { x: 0.71875, y: 0.15625 },
+ { x: 0.78125, y: 0.15625 },
+ { x: 0.78125, y: 0.15625 },
+ { x: 0.84375, y: 0.15625 },
+ { x: 0.84375, y: 0.15625 },
+ { x: 0.90625, y: 0.15625 },
+ { x: 0.90625, y: 0.15625 },
+ { x: 0.96875, y: 0.15625 },
+ { x: 0.96875, y: 0.15625 },
+ { x: 0.03125, y: 0.21875 },
+ { x: 0.03125, y: 0.21875 },
+ { x: 0.09375, y: 0.21875 },
+ { x: 0.09375, y: 0.21875 },
+ { x: 0.15625, y: 0.21875 },
+ { x: 0.15625, y: 0.21875 },
+ { x: 0.21875, y: 0.21875 },
+ { x: 0.21875, y: 0.21875 },
+ { x: 0.28125, y: 0.21875 },
+ { x: 0.28125, y: 0.21875 },
+ { x: 0.34375, y: 0.21875 },
+ { x: 0.34375, y: 0.21875 },
+ { x: 0.40625, y: 0.21875 },
+ { x: 0.40625, y: 0.21875 },
+ { x: 0.46875, y: 0.21875 },
+ { x: 0.46875, y: 0.21875 },
+ { x: 0.53125, y: 0.21875 },
+ { x: 0.53125, y: 0.21875 },
+ { x: 0.59375, y: 0.21875 },
+ { x: 0.59375, y: 0.21875 },
+ { x: 0.65625, y: 0.21875 },
+ { x: 0.65625, y: 0.21875 },
+ { x: 0.71875, y: 0.21875 },
+ { x: 0.71875, y: 0.21875 },
+ { x: 0.78125, y: 0.21875 },
+ { x: 0.78125, y: 0.21875 },
+ { x: 0.84375, y: 0.21875 },
+ { x: 0.84375, y: 0.21875 },
+ { x: 0.90625, y: 0.21875 },
+ { x: 0.90625, y: 0.21875 },
+ { x: 0.96875, y: 0.21875 },
+ { x: 0.96875, y: 0.21875 },
+ { x: 0.03125, y: 0.28125 },
+ { x: 0.03125, y: 0.28125 },
+ { x: 0.09375, y: 0.28125 },
+ { x: 0.09375, y: 0.28125 },
+ { x: 0.15625, y: 0.28125 },
+ { x: 0.15625, y: 0.28125 },
+ { x: 0.21875, y: 0.28125 },
+ { x: 0.21875, y: 0.28125 },
+ { x: 0.28125, y: 0.28125 },
+ { x: 0.28125, y: 0.28125 },
+ { x: 0.34375, y: 0.28125 },
+ { x: 0.34375, y: 0.28125 },
+ { x: 0.40625, y: 0.28125 },
+ { x: 0.40625, y: 0.28125 },
+ { x: 0.46875, y: 0.28125 },
+ { x: 0.46875, y: 0.28125 },
+ { x: 0.53125, y: 0.28125 },
+ { x: 0.53125, y: 0.28125 },
+ { x: 0.59375, y: 0.28125 },
+ { x: 0.59375, y: 0.28125 },
+ { x: 0.65625, y: 0.28125 },
+ { x: 0.65625, y: 0.28125 },
+ { x: 0.71875, y: 0.28125 },
+ { x: 0.71875, y: 0.28125 },
+ { x: 0.78125, y: 0.28125 },
+ { x: 0.78125, y: 0.28125 },
+ { x: 0.84375, y: 0.28125 },
+ { x: 0.84375, y: 0.28125 },
+ { x: 0.90625, y: 0.28125 },
+ { x: 0.90625, y: 0.28125 },
+ { x: 0.96875, y: 0.28125 },
+ { x: 0.96875, y: 0.28125 },
+ { x: 0.03125, y: 0.34375 },
+ { x: 0.03125, y: 0.34375 },
+ { x: 0.09375, y: 0.34375 },
+ { x: 0.09375, y: 0.34375 },
+ { x: 0.15625, y: 0.34375 },
+ { x: 0.15625, y: 0.34375 },
+ { x: 0.21875, y: 0.34375 },
+ { x: 0.21875, y: 0.34375 },
+ { x: 0.28125, y: 0.34375 },
+ { x: 0.28125, y: 0.34375 },
+ { x: 0.34375, y: 0.34375 },
+ { x: 0.34375, y: 0.34375 },
+ { x: 0.40625, y: 0.34375 },
+ { x: 0.40625, y: 0.34375 },
+ { x: 0.46875, y: 0.34375 },
+ { x: 0.46875, y: 0.34375 },
+ { x: 0.53125, y: 0.34375 },
+ { x: 0.53125, y: 0.34375 },
+ { x: 0.59375, y: 0.34375 },
+ { x: 0.59375, y: 0.34375 },
+ { x: 0.65625, y: 0.34375 },
+ { x: 0.65625, y: 0.34375 },
+ { x: 0.71875, y: 0.34375 },
+ { x: 0.71875, y: 0.34375 },
+ { x: 0.78125, y: 0.34375 },
+ { x: 0.78125, y: 0.34375 },
+ { x: 0.84375, y: 0.34375 },
+ { x: 0.84375, y: 0.34375 },
+ { x: 0.90625, y: 0.34375 },
+ { x: 0.90625, y: 0.34375 },
+ { x: 0.96875, y: 0.34375 },
+ { x: 0.96875, y: 0.34375 },
+ { x: 0.03125, y: 0.40625 },
+ { x: 0.03125, y: 0.40625 },
+ { x: 0.09375, y: 0.40625 },
+ { x: 0.09375, y: 0.40625 },
+ { x: 0.15625, y: 0.40625 },
+ { x: 0.15625, y: 0.40625 },
+ { x: 0.21875, y: 0.40625 },
+ { x: 0.21875, y: 0.40625 },
+ { x: 0.28125, y: 0.40625 },
+ { x: 0.28125, y: 0.40625 },
+ { x: 0.34375, y: 0.40625 },
+ { x: 0.34375, y: 0.40625 },
+ { x: 0.40625, y: 0.40625 },
+ { x: 0.40625, y: 0.40625 },
+ { x: 0.46875, y: 0.40625 },
+ { x: 0.46875, y: 0.40625 },
+ { x: 0.53125, y: 0.40625 },
+ { x: 0.53125, y: 0.40625 },
+ { x: 0.59375, y: 0.40625 },
+ { x: 0.59375, y: 0.40625 },
+ { x: 0.65625, y: 0.40625 },
+ { x: 0.65625, y: 0.40625 },
+ { x: 0.71875, y: 0.40625 },
+ { x: 0.71875, y: 0.40625 },
+ { x: 0.78125, y: 0.40625 },
+ { x: 0.78125, y: 0.40625 },
+ { x: 0.84375, y: 0.40625 },
+ { x: 0.84375, y: 0.40625 },
+ { x: 0.90625, y: 0.40625 },
+ { x: 0.90625, y: 0.40625 },
+ { x: 0.96875, y: 0.40625 },
+ { x: 0.96875, y: 0.40625 },
+ { x: 0.03125, y: 0.46875 },
+ { x: 0.03125, y: 0.46875 },
+ { x: 0.09375, y: 0.46875 },
+ { x: 0.09375, y: 0.46875 },
+ { x: 0.15625, y: 0.46875 },
+ { x: 0.15625, y: 0.46875 },
+ { x: 0.21875, y: 0.46875 },
+ { x: 0.21875, y: 0.46875 },
+ { x: 0.28125, y: 0.46875 },
+ { x: 0.28125, y: 0.46875 },
+ { x: 0.34375, y: 0.46875 },
+ { x: 0.34375, y: 0.46875 },
+ { x: 0.40625, y: 0.46875 },
+ { x: 0.40625, y: 0.46875 },
+ { x: 0.46875, y: 0.46875 },
+ { x: 0.46875, y: 0.46875 },
+ { x: 0.53125, y: 0.46875 },
+ { x: 0.53125, y: 0.46875 },
+ { x: 0.59375, y: 0.46875 },
+ { x: 0.59375, y: 0.46875 },
+ { x: 0.65625, y: 0.46875 },
+ { x: 0.65625, y: 0.46875 },
+ { x: 0.71875, y: 0.46875 },
+ { x: 0.71875, y: 0.46875 },
+ { x: 0.78125, y: 0.46875 },
+ { x: 0.78125, y: 0.46875 },
+ { x: 0.84375, y: 0.46875 },
+ { x: 0.84375, y: 0.46875 },
+ { x: 0.90625, y: 0.46875 },
+ { x: 0.90625, y: 0.46875 },
+ { x: 0.96875, y: 0.46875 },
+ { x: 0.96875, y: 0.46875 },
+ { x: 0.03125, y: 0.53125 },
+ { x: 0.03125, y: 0.53125 },
+ { x: 0.09375, y: 0.53125 },
+ { x: 0.09375, y: 0.53125 },
+ { x: 0.15625, y: 0.53125 },
+ { x: 0.15625, y: 0.53125 },
+ { x: 0.21875, y: 0.53125 },
+ { x: 0.21875, y: 0.53125 },
+ { x: 0.28125, y: 0.53125 },
+ { x: 0.28125, y: 0.53125 },
+ { x: 0.34375, y: 0.53125 },
+ { x: 0.34375, y: 0.53125 },
+ { x: 0.40625, y: 0.53125 },
+ { x: 0.40625, y: 0.53125 },
+ { x: 0.46875, y: 0.53125 },
+ { x: 0.46875, y: 0.53125 },
+ { x: 0.53125, y: 0.53125 },
+ { x: 0.53125, y: 0.53125 },
+ { x: 0.59375, y: 0.53125 },
+ { x: 0.59375, y: 0.53125 },
+ { x: 0.65625, y: 0.53125 },
+ { x: 0.65625, y: 0.53125 },
+ { x: 0.71875, y: 0.53125 },
+ { x: 0.71875, y: 0.53125 },
+ { x: 0.78125, y: 0.53125 },
+ { x: 0.78125, y: 0.53125 },
+ { x: 0.84375, y: 0.53125 },
+ { x: 0.84375, y: 0.53125 },
+ { x: 0.90625, y: 0.53125 },
+ { x: 0.90625, y: 0.53125 },
+ { x: 0.96875, y: 0.53125 },
+ { x: 0.96875, y: 0.53125 },
+ { x: 0.03125, y: 0.59375 },
+ { x: 0.03125, y: 0.59375 },
+ { x: 0.09375, y: 0.59375 },
+ { x: 0.09375, y: 0.59375 },
+ { x: 0.15625, y: 0.59375 },
+ { x: 0.15625, y: 0.59375 },
+ { x: 0.21875, y: 0.59375 },
+ { x: 0.21875, y: 0.59375 },
+ { x: 0.28125, y: 0.59375 },
+ { x: 0.28125, y: 0.59375 },
+ { x: 0.34375, y: 0.59375 },
+ { x: 0.34375, y: 0.59375 },
+ { x: 0.40625, y: 0.59375 },
+ { x: 0.40625, y: 0.59375 },
+ { x: 0.46875, y: 0.59375 },
+ { x: 0.46875, y: 0.59375 },
+ { x: 0.53125, y: 0.59375 },
+ { x: 0.53125, y: 0.59375 },
+ { x: 0.59375, y: 0.59375 },
+ { x: 0.59375, y: 0.59375 },
+ { x: 0.65625, y: 0.59375 },
+ { x: 0.65625, y: 0.59375 },
+ { x: 0.71875, y: 0.59375 },
+ { x: 0.71875, y: 0.59375 },
+ { x: 0.78125, y: 0.59375 },
+ { x: 0.78125, y: 0.59375 },
+ { x: 0.84375, y: 0.59375 },
+ { x: 0.84375, y: 0.59375 },
+ { x: 0.90625, y: 0.59375 },
+ { x: 0.90625, y: 0.59375 },
+ { x: 0.96875, y: 0.59375 },
+ { x: 0.96875, y: 0.59375 },
+ { x: 0.03125, y: 0.65625 },
+ { x: 0.03125, y: 0.65625 },
+ { x: 0.09375, y: 0.65625 },
+ { x: 0.09375, y: 0.65625 },
+ { x: 0.15625, y: 0.65625 },
+ { x: 0.15625, y: 0.65625 },
+ { x: 0.21875, y: 0.65625 },
+ { x: 0.21875, y: 0.65625 },
+ { x: 0.28125, y: 0.65625 },
+ { x: 0.28125, y: 0.65625 },
+ { x: 0.34375, y: 0.65625 },
+ { x: 0.34375, y: 0.65625 },
+ { x: 0.40625, y: 0.65625 },
+ { x: 0.40625, y: 0.65625 },
+ { x: 0.46875, y: 0.65625 },
+ { x: 0.46875, y: 0.65625 },
+ { x: 0.53125, y: 0.65625 },
+ { x: 0.53125, y: 0.65625 },
+ { x: 0.59375, y: 0.65625 },
+ { x: 0.59375, y: 0.65625 },
+ { x: 0.65625, y: 0.65625 },
+ { x: 0.65625, y: 0.65625 },
+ { x: 0.71875, y: 0.65625 },
+ { x: 0.71875, y: 0.65625 },
+ { x: 0.78125, y: 0.65625 },
+ { x: 0.78125, y: 0.65625 },
+ { x: 0.84375, y: 0.65625 },
+ { x: 0.84375, y: 0.65625 },
+ { x: 0.90625, y: 0.65625 },
+ { x: 0.90625, y: 0.65625 },
+ { x: 0.96875, y: 0.65625 },
+ { x: 0.96875, y: 0.65625 },
+ { x: 0.03125, y: 0.71875 },
+ { x: 0.03125, y: 0.71875 },
+ { x: 0.09375, y: 0.71875 },
+ { x: 0.09375, y: 0.71875 },
+ { x: 0.15625, y: 0.71875 },
+ { x: 0.15625, y: 0.71875 },
+ { x: 0.21875, y: 0.71875 },
+ { x: 0.21875, y: 0.71875 },
+ { x: 0.28125, y: 0.71875 },
+ { x: 0.28125, y: 0.71875 },
+ { x: 0.34375, y: 0.71875 },
+ { x: 0.34375, y: 0.71875 },
+ { x: 0.40625, y: 0.71875 },
+ { x: 0.40625, y: 0.71875 },
+ { x: 0.46875, y: 0.71875 },
+ { x: 0.46875, y: 0.71875 },
+ { x: 0.53125, y: 0.71875 },
+ { x: 0.53125, y: 0.71875 },
+ { x: 0.59375, y: 0.71875 },
+ { x: 0.59375, y: 0.71875 },
+ { x: 0.65625, y: 0.71875 },
+ { x: 0.65625, y: 0.71875 },
+ { x: 0.71875, y: 0.71875 },
+ { x: 0.71875, y: 0.71875 },
+ { x: 0.78125, y: 0.71875 },
+ { x: 0.78125, y: 0.71875 },
+ { x: 0.84375, y: 0.71875 },
+ { x: 0.84375, y: 0.71875 },
+ { x: 0.90625, y: 0.71875 },
+ { x: 0.90625, y: 0.71875 },
+ { x: 0.96875, y: 0.71875 },
+ { x: 0.96875, y: 0.71875 },
+ { x: 0.03125, y: 0.78125 },
+ { x: 0.03125, y: 0.78125 },
+ { x: 0.09375, y: 0.78125 },
+ { x: 0.09375, y: 0.78125 },
+ { x: 0.15625, y: 0.78125 },
+ { x: 0.15625, y: 0.78125 },
+ { x: 0.21875, y: 0.78125 },
+ { x: 0.21875, y: 0.78125 },
+ { x: 0.28125, y: 0.78125 },
+ { x: 0.28125, y: 0.78125 },
+ { x: 0.34375, y: 0.78125 },
+ { x: 0.34375, y: 0.78125 },
+ { x: 0.40625, y: 0.78125 },
+ { x: 0.40625, y: 0.78125 },
+ { x: 0.46875, y: 0.78125 },
+ { x: 0.46875, y: 0.78125 },
+ { x: 0.53125, y: 0.78125 },
+ { x: 0.53125, y: 0.78125 },
+ { x: 0.59375, y: 0.78125 },
+ { x: 0.59375, y: 0.78125 },
+ { x: 0.65625, y: 0.78125 },
+ { x: 0.65625, y: 0.78125 },
+ { x: 0.71875, y: 0.78125 },
+ { x: 0.71875, y: 0.78125 },
+ { x: 0.78125, y: 0.78125 },
+ { x: 0.78125, y: 0.78125 },
+ { x: 0.84375, y: 0.78125 },
+ { x: 0.84375, y: 0.78125 },
+ { x: 0.90625, y: 0.78125 },
+ { x: 0.90625, y: 0.78125 },
+ { x: 0.96875, y: 0.78125 },
+ { x: 0.96875, y: 0.78125 },
+ { x: 0.03125, y: 0.84375 },
+ { x: 0.03125, y: 0.84375 },
+ { x: 0.09375, y: 0.84375 },
+ { x: 0.09375, y: 0.84375 },
+ { x: 0.15625, y: 0.84375 },
+ { x: 0.15625, y: 0.84375 },
+ { x: 0.21875, y: 0.84375 },
+ { x: 0.21875, y: 0.84375 },
+ { x: 0.28125, y: 0.84375 },
+ { x: 0.28125, y: 0.84375 },
+ { x: 0.34375, y: 0.84375 },
+ { x: 0.34375, y: 0.84375 },
+ { x: 0.40625, y: 0.84375 },
+ { x: 0.40625, y: 0.84375 },
+ { x: 0.46875, y: 0.84375 },
+ { x: 0.46875, y: 0.84375 },
+ { x: 0.53125, y: 0.84375 },
+ { x: 0.53125, y: 0.84375 },
+ { x: 0.59375, y: 0.84375 },
+ { x: 0.59375, y: 0.84375 },
+ { x: 0.65625, y: 0.84375 },
+ { x: 0.65625, y: 0.84375 },
+ { x: 0.71875, y: 0.84375 },
+ { x: 0.71875, y: 0.84375 },
+ { x: 0.78125, y: 0.84375 },
+ { x: 0.78125, y: 0.84375 },
+ { x: 0.84375, y: 0.84375 },
+ { x: 0.84375, y: 0.84375 },
+ { x: 0.90625, y: 0.84375 },
+ { x: 0.90625, y: 0.84375 },
+ { x: 0.96875, y: 0.84375 },
+ { x: 0.96875, y: 0.84375 },
+ { x: 0.03125, y: 0.90625 },
+ { x: 0.03125, y: 0.90625 },
+ { x: 0.09375, y: 0.90625 },
+ { x: 0.09375, y: 0.90625 },
+ { x: 0.15625, y: 0.90625 },
+ { x: 0.15625, y: 0.90625 },
+ { x: 0.21875, y: 0.90625 },
+ { x: 0.21875, y: 0.90625 },
+ { x: 0.28125, y: 0.90625 },
+ { x: 0.28125, y: 0.90625 },
+ { x: 0.34375, y: 0.90625 },
+ { x: 0.34375, y: 0.90625 },
+ { x: 0.40625, y: 0.90625 },
+ { x: 0.40625, y: 0.90625 },
+ { x: 0.46875, y: 0.90625 },
+ { x: 0.46875, y: 0.90625 },
+ { x: 0.53125, y: 0.90625 },
+ { x: 0.53125, y: 0.90625 },
+ { x: 0.59375, y: 0.90625 },
+ { x: 0.59375, y: 0.90625 },
+ { x: 0.65625, y: 0.90625 },
+ { x: 0.65625, y: 0.90625 },
+ { x: 0.71875, y: 0.90625 },
+ { x: 0.71875, y: 0.90625 },
+ { x: 0.78125, y: 0.90625 },
+ { x: 0.78125, y: 0.90625 },
+ { x: 0.84375, y: 0.90625 },
+ { x: 0.84375, y: 0.90625 },
+ { x: 0.90625, y: 0.90625 },
+ { x: 0.90625, y: 0.90625 },
+ { x: 0.96875, y: 0.90625 },
+ { x: 0.96875, y: 0.90625 },
+ { x: 0.03125, y: 0.96875 },
+ { x: 0.03125, y: 0.96875 },
+ { x: 0.09375, y: 0.96875 },
+ { x: 0.09375, y: 0.96875 },
+ { x: 0.15625, y: 0.96875 },
+ { x: 0.15625, y: 0.96875 },
+ { x: 0.21875, y: 0.96875 },
+ { x: 0.21875, y: 0.96875 },
+ { x: 0.28125, y: 0.96875 },
+ { x: 0.28125, y: 0.96875 },
+ { x: 0.34375, y: 0.96875 },
+ { x: 0.34375, y: 0.96875 },
+ { x: 0.40625, y: 0.96875 },
+ { x: 0.40625, y: 0.96875 },
+ { x: 0.46875, y: 0.96875 },
+ { x: 0.46875, y: 0.96875 },
+ { x: 0.53125, y: 0.96875 },
+ { x: 0.53125, y: 0.96875 },
+ { x: 0.59375, y: 0.96875 },
+ { x: 0.59375, y: 0.96875 },
+ { x: 0.65625, y: 0.96875 },
+ { x: 0.65625, y: 0.96875 },
+ { x: 0.71875, y: 0.96875 },
+ { x: 0.71875, y: 0.96875 },
+ { x: 0.78125, y: 0.96875 },
+ { x: 0.78125, y: 0.96875 },
+ { x: 0.84375, y: 0.96875 },
+ { x: 0.84375, y: 0.96875 },
+ { x: 0.90625, y: 0.96875 },
+ { x: 0.90625, y: 0.96875 },
+ { x: 0.96875, y: 0.96875 },
+ { x: 0.96875, y: 0.96875 },
+ { x: 0.0625, y: 0.0625 },
+ { x: 0.0625, y: 0.0625 },
+ { x: 0.0625, y: 0.0625 },
+ { x: 0.0625, y: 0.0625 },
+ { x: 0.0625, y: 0.0625 },
+ { x: 0.0625, y: 0.0625 },
+ { x: 0.1875, y: 0.0625 },
+ { x: 0.1875, y: 0.0625 },
+ { x: 0.1875, y: 0.0625 },
+ { x: 0.1875, y: 0.0625 },
+ { x: 0.1875, y: 0.0625 },
+ { x: 0.1875, y: 0.0625 },
+ { x: 0.3125, y: 0.0625 },
+ { x: 0.3125, y: 0.0625 },
+ { x: 0.3125, y: 0.0625 },
+ { x: 0.3125, y: 0.0625 },
+ { x: 0.3125, y: 0.0625 },
+ { x: 0.3125, y: 0.0625 },
+ { x: 0.4375, y: 0.0625 },
+ { x: 0.4375, y: 0.0625 },
+ { x: 0.4375, y: 0.0625 },
+ { x: 0.4375, y: 0.0625 },
+ { x: 0.4375, y: 0.0625 },
+ { x: 0.4375, y: 0.0625 },
+ { x: 0.5625, y: 0.0625 },
+ { x: 0.5625, y: 0.0625 },
+ { x: 0.5625, y: 0.0625 },
+ { x: 0.5625, y: 0.0625 },
+ { x: 0.5625, y: 0.0625 },
+ { x: 0.5625, y: 0.0625 },
+ { x: 0.6875, y: 0.0625 },
+ { x: 0.6875, y: 0.0625 },
+ { x: 0.6875, y: 0.0625 },
+ { x: 0.6875, y: 0.0625 },
+ { x: 0.6875, y: 0.0625 },
+ { x: 0.6875, y: 0.0625 },
+ { x: 0.8125, y: 0.0625 },
+ { x: 0.8125, y: 0.0625 },
+ { x: 0.8125, y: 0.0625 },
+ { x: 0.8125, y: 0.0625 },
+ { x: 0.8125, y: 0.0625 },
+ { x: 0.8125, y: 0.0625 },
+ { x: 0.9375, y: 0.0625 },
+ { x: 0.9375, y: 0.0625 },
+ { x: 0.9375, y: 0.0625 },
+ { x: 0.9375, y: 0.0625 },
+ { x: 0.9375, y: 0.0625 },
+ { x: 0.9375, y: 0.0625 },
+ { x: 0.0625, y: 0.1875 },
+ { x: 0.0625, y: 0.1875 },
+ { x: 0.0625, y: 0.1875 },
+ { x: 0.0625, y: 0.1875 },
+ { x: 0.0625, y: 0.1875 },
+ { x: 0.0625, y: 0.1875 },
+ { x: 0.1875, y: 0.1875 },
+ { x: 0.1875, y: 0.1875 },
+ { x: 0.1875, y: 0.1875 },
+ { x: 0.1875, y: 0.1875 },
+ { x: 0.1875, y: 0.1875 },
+ { x: 0.1875, y: 0.1875 },
+ { x: 0.3125, y: 0.1875 },
+ { x: 0.3125, y: 0.1875 },
+ { x: 0.3125, y: 0.1875 },
+ { x: 0.3125, y: 0.1875 },
+ { x: 0.3125, y: 0.1875 },
+ { x: 0.3125, y: 0.1875 },
+ { x: 0.4375, y: 0.1875 },
+ { x: 0.4375, y: 0.1875 },
+ { x: 0.4375, y: 0.1875 },
+ { x: 0.4375, y: 0.1875 },
+ { x: 0.4375, y: 0.1875 },
+ { x: 0.4375, y: 0.1875 },
+ { x: 0.5625, y: 0.1875 },
+ { x: 0.5625, y: 0.1875 },
+ { x: 0.5625, y: 0.1875 },
+ { x: 0.5625, y: 0.1875 },
+ { x: 0.5625, y: 0.1875 },
+ { x: 0.5625, y: 0.1875 },
+ { x: 0.6875, y: 0.1875 },
+ { x: 0.6875, y: 0.1875 },
+ { x: 0.6875, y: 0.1875 },
+ { x: 0.6875, y: 0.1875 },
+ { x: 0.6875, y: 0.1875 },
+ { x: 0.6875, y: 0.1875 },
+ { x: 0.8125, y: 0.1875 },
+ { x: 0.8125, y: 0.1875 },
+ { x: 0.8125, y: 0.1875 },
+ { x: 0.8125, y: 0.1875 },
+ { x: 0.8125, y: 0.1875 },
+ { x: 0.8125, y: 0.1875 },
+ { x: 0.9375, y: 0.1875 },
+ { x: 0.9375, y: 0.1875 },
+ { x: 0.9375, y: 0.1875 },
+ { x: 0.9375, y: 0.1875 },
+ { x: 0.9375, y: 0.1875 },
+ { x: 0.9375, y: 0.1875 },
+ { x: 0.0625, y: 0.3125 },
+ { x: 0.0625, y: 0.3125 },
+ { x: 0.0625, y: 0.3125 },
+ { x: 0.0625, y: 0.3125 },
+ { x: 0.0625, y: 0.3125 },
+ { x: 0.0625, y: 0.3125 },
+ { x: 0.1875, y: 0.3125 },
+ { x: 0.1875, y: 0.3125 },
+ { x: 0.1875, y: 0.3125 },
+ { x: 0.1875, y: 0.3125 },
+ { x: 0.1875, y: 0.3125 },
+ { x: 0.1875, y: 0.3125 },
+ { x: 0.3125, y: 0.3125 },
+ { x: 0.3125, y: 0.3125 },
+ { x: 0.3125, y: 0.3125 },
+ { x: 0.3125, y: 0.3125 },
+ { x: 0.3125, y: 0.3125 },
+ { x: 0.3125, y: 0.3125 },
+ { x: 0.4375, y: 0.3125 },
+ { x: 0.4375, y: 0.3125 },
+ { x: 0.4375, y: 0.3125 },
+ { x: 0.4375, y: 0.3125 },
+ { x: 0.4375, y: 0.3125 },
+ { x: 0.4375, y: 0.3125 },
+ { x: 0.5625, y: 0.3125 },
+ { x: 0.5625, y: 0.3125 },
+ { x: 0.5625, y: 0.3125 },
+ { x: 0.5625, y: 0.3125 },
+ { x: 0.5625, y: 0.3125 },
+ { x: 0.5625, y: 0.3125 },
+ { x: 0.6875, y: 0.3125 },
+ { x: 0.6875, y: 0.3125 },
+ { x: 0.6875, y: 0.3125 },
+ { x: 0.6875, y: 0.3125 },
+ { x: 0.6875, y: 0.3125 },
+ { x: 0.6875, y: 0.3125 },
+ { x: 0.8125, y: 0.3125 },
+ { x: 0.8125, y: 0.3125 },
+ { x: 0.8125, y: 0.3125 },
+ { x: 0.8125, y: 0.3125 },
+ { x: 0.8125, y: 0.3125 },
+ { x: 0.8125, y: 0.3125 },
+ { x: 0.9375, y: 0.3125 },
+ { x: 0.9375, y: 0.3125 },
+ { x: 0.9375, y: 0.3125 },
+ { x: 0.9375, y: 0.3125 },
+ { x: 0.9375, y: 0.3125 },
+ { x: 0.9375, y: 0.3125 },
+ { x: 0.0625, y: 0.4375 },
+ { x: 0.0625, y: 0.4375 },
+ { x: 0.0625, y: 0.4375 },
+ { x: 0.0625, y: 0.4375 },
+ { x: 0.0625, y: 0.4375 },
+ { x: 0.0625, y: 0.4375 },
+ { x: 0.1875, y: 0.4375 },
+ { x: 0.1875, y: 0.4375 },
+ { x: 0.1875, y: 0.4375 },
+ { x: 0.1875, y: 0.4375 },
+ { x: 0.1875, y: 0.4375 },
+ { x: 0.1875, y: 0.4375 },
+ { x: 0.3125, y: 0.4375 },
+ { x: 0.3125, y: 0.4375 },
+ { x: 0.3125, y: 0.4375 },
+ { x: 0.3125, y: 0.4375 },
+ { x: 0.3125, y: 0.4375 },
+ { x: 0.3125, y: 0.4375 },
+ { x: 0.4375, y: 0.4375 },
+ { x: 0.4375, y: 0.4375 },
+ { x: 0.4375, y: 0.4375 },
+ { x: 0.4375, y: 0.4375 },
+ { x: 0.4375, y: 0.4375 },
+ { x: 0.4375, y: 0.4375 },
+ { x: 0.5625, y: 0.4375 },
+ { x: 0.5625, y: 0.4375 },
+ { x: 0.5625, y: 0.4375 },
+ { x: 0.5625, y: 0.4375 },
+ { x: 0.5625, y: 0.4375 },
+ { x: 0.5625, y: 0.4375 },
+ { x: 0.6875, y: 0.4375 },
+ { x: 0.6875, y: 0.4375 },
+ { x: 0.6875, y: 0.4375 },
+ { x: 0.6875, y: 0.4375 },
+ { x: 0.6875, y: 0.4375 },
+ { x: 0.6875, y: 0.4375 },
+ { x: 0.8125, y: 0.4375 },
+ { x: 0.8125, y: 0.4375 },
+ { x: 0.8125, y: 0.4375 },
+ { x: 0.8125, y: 0.4375 },
+ { x: 0.8125, y: 0.4375 },
+ { x: 0.8125, y: 0.4375 },
+ { x: 0.9375, y: 0.4375 },
+ { x: 0.9375, y: 0.4375 },
+ { x: 0.9375, y: 0.4375 },
+ { x: 0.9375, y: 0.4375 },
+ { x: 0.9375, y: 0.4375 },
+ { x: 0.9375, y: 0.4375 },
+ { x: 0.0625, y: 0.5625 },
+ { x: 0.0625, y: 0.5625 },
+ { x: 0.0625, y: 0.5625 },
+ { x: 0.0625, y: 0.5625 },
+ { x: 0.0625, y: 0.5625 },
+ { x: 0.0625, y: 0.5625 },
+ { x: 0.1875, y: 0.5625 },
+ { x: 0.1875, y: 0.5625 },
+ { x: 0.1875, y: 0.5625 },
+ { x: 0.1875, y: 0.5625 },
+ { x: 0.1875, y: 0.5625 },
+ { x: 0.1875, y: 0.5625 },
+ { x: 0.3125, y: 0.5625 },
+ { x: 0.3125, y: 0.5625 },
+ { x: 0.3125, y: 0.5625 },
+ { x: 0.3125, y: 0.5625 },
+ { x: 0.3125, y: 0.5625 },
+ { x: 0.3125, y: 0.5625 },
+ { x: 0.4375, y: 0.5625 },
+ { x: 0.4375, y: 0.5625 },
+ { x: 0.4375, y: 0.5625 },
+ { x: 0.4375, y: 0.5625 },
+ { x: 0.4375, y: 0.5625 },
+ { x: 0.4375, y: 0.5625 },
+ { x: 0.5625, y: 0.5625 },
+ { x: 0.5625, y: 0.5625 },
+ { x: 0.5625, y: 0.5625 },
+ { x: 0.5625, y: 0.5625 },
+ { x: 0.5625, y: 0.5625 },
+ { x: 0.5625, y: 0.5625 },
+ { x: 0.6875, y: 0.5625 },
+ { x: 0.6875, y: 0.5625 },
+ { x: 0.6875, y: 0.5625 },
+ { x: 0.6875, y: 0.5625 },
+ { x: 0.6875, y: 0.5625 },
+ { x: 0.6875, y: 0.5625 },
+ { x: 0.8125, y: 0.5625 },
+ { x: 0.8125, y: 0.5625 },
+ { x: 0.8125, y: 0.5625 },
+ { x: 0.8125, y: 0.5625 },
+ { x: 0.8125, y: 0.5625 },
+ { x: 0.8125, y: 0.5625 },
+ { x: 0.9375, y: 0.5625 },
+ { x: 0.9375, y: 0.5625 },
+ { x: 0.9375, y: 0.5625 },
+ { x: 0.9375, y: 0.5625 },
+ { x: 0.9375, y: 0.5625 },
+ { x: 0.9375, y: 0.5625 },
+ { x: 0.0625, y: 0.6875 },
+ { x: 0.0625, y: 0.6875 },
+ { x: 0.0625, y: 0.6875 },
+ { x: 0.0625, y: 0.6875 },
+ { x: 0.0625, y: 0.6875 },
+ { x: 0.0625, y: 0.6875 },
+ { x: 0.1875, y: 0.6875 },
+ { x: 0.1875, y: 0.6875 },
+ { x: 0.1875, y: 0.6875 },
+ { x: 0.1875, y: 0.6875 },
+ { x: 0.1875, y: 0.6875 },
+ { x: 0.1875, y: 0.6875 },
+ { x: 0.3125, y: 0.6875 },
+ { x: 0.3125, y: 0.6875 },
+ { x: 0.3125, y: 0.6875 },
+ { x: 0.3125, y: 0.6875 },
+ { x: 0.3125, y: 0.6875 },
+ { x: 0.3125, y: 0.6875 },
+ { x: 0.4375, y: 0.6875 },
+ { x: 0.4375, y: 0.6875 },
+ { x: 0.4375, y: 0.6875 },
+ { x: 0.4375, y: 0.6875 },
+ { x: 0.4375, y: 0.6875 },
+ { x: 0.4375, y: 0.6875 },
+ { x: 0.5625, y: 0.6875 },
+ { x: 0.5625, y: 0.6875 },
+ { x: 0.5625, y: 0.6875 },
+ { x: 0.5625, y: 0.6875 },
+ { x: 0.5625, y: 0.6875 },
+ { x: 0.5625, y: 0.6875 },
+ { x: 0.6875, y: 0.6875 },
+ { x: 0.6875, y: 0.6875 },
+ { x: 0.6875, y: 0.6875 },
+ { x: 0.6875, y: 0.6875 },
+ { x: 0.6875, y: 0.6875 },
+ { x: 0.6875, y: 0.6875 },
+ { x: 0.8125, y: 0.6875 },
+ { x: 0.8125, y: 0.6875 },
+ { x: 0.8125, y: 0.6875 },
+ { x: 0.8125, y: 0.6875 },
+ { x: 0.8125, y: 0.6875 },
+ { x: 0.8125, y: 0.6875 },
+ { x: 0.9375, y: 0.6875 },
+ { x: 0.9375, y: 0.6875 },
+ { x: 0.9375, y: 0.6875 },
+ { x: 0.9375, y: 0.6875 },
+ { x: 0.9375, y: 0.6875 },
+ { x: 0.9375, y: 0.6875 },
+ { x: 0.0625, y: 0.8125 },
+ { x: 0.0625, y: 0.8125 },
+ { x: 0.0625, y: 0.8125 },
+ { x: 0.0625, y: 0.8125 },
+ { x: 0.0625, y: 0.8125 },
+ { x: 0.0625, y: 0.8125 },
+ { x: 0.1875, y: 0.8125 },
+ { x: 0.1875, y: 0.8125 },
+ { x: 0.1875, y: 0.8125 },
+ { x: 0.1875, y: 0.8125 },
+ { x: 0.1875, y: 0.8125 },
+ { x: 0.1875, y: 0.8125 },
+ { x: 0.3125, y: 0.8125 },
+ { x: 0.3125, y: 0.8125 },
+ { x: 0.3125, y: 0.8125 },
+ { x: 0.3125, y: 0.8125 },
+ { x: 0.3125, y: 0.8125 },
+ { x: 0.3125, y: 0.8125 },
+ { x: 0.4375, y: 0.8125 },
+ { x: 0.4375, y: 0.8125 },
+ { x: 0.4375, y: 0.8125 },
+ { x: 0.4375, y: 0.8125 },
+ { x: 0.4375, y: 0.8125 },
+ { x: 0.4375, y: 0.8125 },
+ { x: 0.5625, y: 0.8125 },
+ { x: 0.5625, y: 0.8125 },
+ { x: 0.5625, y: 0.8125 },
+ { x: 0.5625, y: 0.8125 },
+ { x: 0.5625, y: 0.8125 },
+ { x: 0.5625, y: 0.8125 },
+ { x: 0.6875, y: 0.8125 },
+ { x: 0.6875, y: 0.8125 },
+ { x: 0.6875, y: 0.8125 },
+ { x: 0.6875, y: 0.8125 },
+ { x: 0.6875, y: 0.8125 },
+ { x: 0.6875, y: 0.8125 },
+ { x: 0.8125, y: 0.8125 },
+ { x: 0.8125, y: 0.8125 },
+ { x: 0.8125, y: 0.8125 },
+ { x: 0.8125, y: 0.8125 },
+ { x: 0.8125, y: 0.8125 },
+ { x: 0.8125, y: 0.8125 },
+ { x: 0.9375, y: 0.8125 },
+ { x: 0.9375, y: 0.8125 },
+ { x: 0.9375, y: 0.8125 },
+ { x: 0.9375, y: 0.8125 },
+ { x: 0.9375, y: 0.8125 },
+ { x: 0.9375, y: 0.8125 },
+ { x: 0.0625, y: 0.9375 },
+ { x: 0.0625, y: 0.9375 },
+ { x: 0.0625, y: 0.9375 },
+ { x: 0.0625, y: 0.9375 },
+ { x: 0.0625, y: 0.9375 },
+ { x: 0.0625, y: 0.9375 },
+ { x: 0.1875, y: 0.9375 },
+ { x: 0.1875, y: 0.9375 },
+ { x: 0.1875, y: 0.9375 },
+ { x: 0.1875, y: 0.9375 },
+ { x: 0.1875, y: 0.9375 },
+ { x: 0.1875, y: 0.9375 },
+ { x: 0.3125, y: 0.9375 },
+ { x: 0.3125, y: 0.9375 },
+ { x: 0.3125, y: 0.9375 },
+ { x: 0.3125, y: 0.9375 },
+ { x: 0.3125, y: 0.9375 },
+ { x: 0.3125, y: 0.9375 },
+ { x: 0.4375, y: 0.9375 },
+ { x: 0.4375, y: 0.9375 },
+ { x: 0.4375, y: 0.9375 },
+ { x: 0.4375, y: 0.9375 },
+ { x: 0.4375, y: 0.9375 },
+ { x: 0.4375, y: 0.9375 },
+ { x: 0.5625, y: 0.9375 },
+ { x: 0.5625, y: 0.9375 },
+ { x: 0.5625, y: 0.9375 },
+ { x: 0.5625, y: 0.9375 },
+ { x: 0.5625, y: 0.9375 },
+ { x: 0.5625, y: 0.9375 },
+ { x: 0.6875, y: 0.9375 },
+ { x: 0.6875, y: 0.9375 },
+ { x: 0.6875, y: 0.9375 },
+ { x: 0.6875, y: 0.9375 },
+ { x: 0.6875, y: 0.9375 },
+ { x: 0.6875, y: 0.9375 },
+ { x: 0.8125, y: 0.9375 },
+ { x: 0.8125, y: 0.9375 },
+ { x: 0.8125, y: 0.9375 },
+ { x: 0.8125, y: 0.9375 },
+ { x: 0.8125, y: 0.9375 },
+ { x: 0.8125, y: 0.9375 },
+ { x: 0.9375, y: 0.9375 },
+ { x: 0.9375, y: 0.9375 },
+ { x: 0.9375, y: 0.9375 },
+ { x: 0.9375, y: 0.9375 },
+ { x: 0.9375, y: 0.9375 },
+ { x: 0.9375, y: 0.9375 }
+];
+
+// src/hand/handposedetector.ts
+var HandDetector = class {
+ constructor(model23) {
+ __publicField(this, "model");
+ __publicField(this, "anchors");
+ __publicField(this, "anchorsTensor");
+ __publicField(this, "inputSize");
+ __publicField(this, "inputSizeTensor");
+ __publicField(this, "doubleInputSizeTensor");
+ var _a, _b, _c, _d;
+ this.model = model23;
+ this.anchors = anchors2.map((anchor) => [anchor.x, anchor.y]);
+ this.anchorsTensor = tfjs_esm_exports.tensor2d(this.anchors);
+ this.inputSize = ((_d = (_c = (_b = (_a = this == null ? void 0 : this.model) == null ? void 0 : _a.inputs) == null ? void 0 : _b[0]) == null ? void 0 : _c.shape) == null ? void 0 : _d[2]) || 0;
+ this.inputSizeTensor = tfjs_esm_exports.tensor1d([this.inputSize, this.inputSize]);
+ this.doubleInputSizeTensor = tfjs_esm_exports.tensor1d([this.inputSize * 2, this.inputSize * 2]);
+ }
+ normalizeBoxes(boxes) {
+ const t2 = {};
+ t2.boxOffsets = tfjs_esm_exports.slice(boxes, [0, 0], [-1, 2]);
+ t2.boxSizes = tfjs_esm_exports.slice(boxes, [0, 2], [-1, 2]);
+ t2.div = tfjs_esm_exports.div(t2.boxOffsets, this.inputSizeTensor);
+ t2.boxCenterPoints = tfjs_esm_exports.add(t2.div, this.anchorsTensor);
+ t2.halfBoxSizes = tfjs_esm_exports.div(t2.boxSizes, this.doubleInputSizeTensor);
+ t2.sub = tfjs_esm_exports.sub(t2.boxCenterPoints, t2.halfBoxSizes);
+ t2.startPoints = tfjs_esm_exports.mul(t2.sub, this.inputSizeTensor);
+ t2.add = tfjs_esm_exports.add(t2.boxCenterPoints, t2.halfBoxSizes);
+ t2.endPoints = tfjs_esm_exports.mul(t2.add, this.inputSizeTensor);
+ const res = tfjs_esm_exports.concat2d([t2.startPoints, t2.endPoints], 1);
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return res;
+ }
+ normalizeLandmarks(rawPalmLandmarks, index2) {
+ const t2 = {};
+ t2.reshape = tfjs_esm_exports.reshape(rawPalmLandmarks, [-1, 7, 2]);
+ t2.div = tfjs_esm_exports.div(t2.reshape, this.inputSizeTensor);
+ t2.landmarks = tfjs_esm_exports.add(t2.div, this.anchors[index2] ? this.anchors[index2] : 0);
+ const res = tfjs_esm_exports.mul(t2.landmarks, this.inputSizeTensor);
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return res;
+ }
+ async predict(input, config3) {
+ var _a;
+ const t2 = {};
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(input, [this.inputSize, this.inputSize]);
+ t2.div = tfjs_esm_exports.div(t2.resize, constants.tf127);
+ t2.image = tfjs_esm_exports.sub(t2.div, constants.tf1);
+ t2.batched = this.model.execute(t2.image);
+ t2.predictions = tfjs_esm_exports.squeeze(t2.batched);
+ t2.slice = tfjs_esm_exports.slice(t2.predictions, [0, 0], [-1, 1]);
+ t2.sigmoid = tfjs_esm_exports.sigmoid(t2.slice);
+ t2.scores = tfjs_esm_exports.squeeze(t2.sigmoid);
+ const scores = await t2.scores.data();
+ t2.boxes = tfjs_esm_exports.slice(t2.predictions, [0, 1], [-1, 4]);
+ t2.norm = this.normalizeBoxes(t2.boxes);
+ t2.nms = await tfjs_esm_exports.image.nonMaxSuppressionAsync(t2.norm, t2.scores, 3 * (((_a = config3.hand) == null ? void 0 : _a.maxDetected) || 1), config3.hand.iouThreshold, config3.hand.minConfidence);
+ const nms = await t2.nms.array();
+ const hands = [];
+ for (const index2 of nms) {
+ const p = {};
+ p.box = tfjs_esm_exports.slice(t2.norm, [index2, 0], [1, -1]);
+ p.slice = tfjs_esm_exports.slice(t2.predictions, [index2, 5], [1, 14]);
+ p.norm = this.normalizeLandmarks(p.slice, index2);
+ p.palmLandmarks = tfjs_esm_exports.reshape(p.norm, [-1, 2]);
+ const box = await p.box.data();
+ const startPoint = box.slice(0, 2);
+ const endPoint = box.slice(2, 4);
+ const palmLandmarks = await p.palmLandmarks.array();
+ const hand3 = { startPoint, endPoint, palmLandmarks, confidence: scores[index2] };
+ const scaled = scaleBoxCoordinates2(hand3, [(input.shape[2] || 1) / this.inputSize, (input.shape[1] || 0) / this.inputSize]);
+ hands.push(scaled);
+ Object.keys(p).forEach((tensor6) => tfjs_esm_exports.dispose(p[tensor6]));
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return hands;
+ }
+};
+
+// src/hand/handposepipeline.ts
+var palmBoxEnlargeFactor = 5;
+var handBoxEnlargeFactor = 1.65;
+var palmLandmarkIds = [0, 5, 9, 13, 17, 1, 2];
+var palmLandmarksPalmBase = 0;
+var palmLandmarksMiddleFingerBase = 2;
+var lastTime13 = 0;
+var HandPipeline = class {
+ constructor(handDetector, handPoseModel2) {
+ __publicField(this, "handDetector");
+ __publicField(this, "handPoseModel");
+ __publicField(this, "inputSize");
+ __publicField(this, "storedBoxes");
+ __publicField(this, "skipped");
+ __publicField(this, "detectedHands");
+ var _a, _b, _c;
+ this.handDetector = handDetector;
+ this.handPoseModel = handPoseModel2;
+ this.inputSize = ((_c = (_b = (_a = this.handPoseModel) == null ? void 0 : _a.inputs) == null ? void 0 : _b[0].shape) == null ? void 0 : _c[2]) || 0;
+ this.storedBoxes = [];
+ this.skipped = Number.MAX_SAFE_INTEGER;
+ this.detectedHands = 0;
+ }
+ calculateLandmarksBoundingBox(landmarks) {
+ const xs = landmarks.map((d) => d[0]);
+ const ys = landmarks.map((d) => d[1]);
+ const startPoint = [Math.min(...xs), Math.min(...ys)];
+ const endPoint = [Math.max(...xs), Math.max(...ys)];
+ return { startPoint, endPoint };
+ }
+ getBoxForPalmLandmarks(palmLandmarks, rotationMatrix) {
+ const rotatedPalmLandmarks = palmLandmarks.map((coord) => rotatePoint2([...coord, 1], rotationMatrix));
+ const boxAroundPalm = this.calculateLandmarksBoundingBox(rotatedPalmLandmarks);
+ return enlargeBox2(squarifyBox2(boxAroundPalm), palmBoxEnlargeFactor);
+ }
+ getBoxForHandLandmarks(landmarks) {
+ const boundingBox = this.calculateLandmarksBoundingBox(landmarks);
+ const boxAroundHand = enlargeBox2(squarifyBox2(boundingBox), handBoxEnlargeFactor);
+ boxAroundHand.palmLandmarks = [];
+ for (let i = 0; i < palmLandmarkIds.length; i++) {
+ boxAroundHand.palmLandmarks.push(landmarks[palmLandmarkIds[i]].slice(0, 2));
+ }
+ return boxAroundHand;
+ }
+ transformRawCoords(rawCoords, box2, angle, rotationMatrix) {
+ const boxSize = getBoxSize2(box2);
+ const scaleFactor = [boxSize[0] / this.inputSize, boxSize[1] / this.inputSize, (boxSize[0] + boxSize[1]) / this.inputSize / 2];
+ const coordsScaled = rawCoords.map((coord) => [
+ scaleFactor[0] * (coord[0] - this.inputSize / 2),
+ scaleFactor[1] * (coord[1] - this.inputSize / 2),
+ scaleFactor[2] * coord[2]
+ ]);
+ const coordsRotationMatrix = buildRotationMatrix2(angle, [0, 0]);
+ const coordsRotated = coordsScaled.map((coord) => {
+ const rotated = rotatePoint2(coord, coordsRotationMatrix);
+ return [...rotated, coord[2]];
+ });
+ const inverseRotationMatrix = invertTransformMatrix2(rotationMatrix);
+ const boxCenter = [...getBoxCenter2(box2), 1];
+ const originalBoxCenter = [
+ dot2(boxCenter, inverseRotationMatrix[0]),
+ dot2(boxCenter, inverseRotationMatrix[1])
+ ];
+ return coordsRotated.map((coord) => [
+ Math.trunc(coord[0] + originalBoxCenter[0]),
+ Math.trunc(coord[1] + originalBoxCenter[1]),
+ Math.trunc(coord[2])
+ ]);
+ }
+ async estimateHands(image28, config3) {
+ let useFreshBox = false;
+ let boxes;
+ const skipTime = (config3.hand.skipTime || 0) > now() - lastTime13;
+ const skipFrame = this.skipped < (config3.hand.skipFrames || 0);
+ if (config3.skipAllowed && skipTime && skipFrame) {
+ boxes = await this.handDetector.predict(image28, config3);
+ this.skipped = 0;
+ }
+ if (config3.skipAllowed)
+ this.skipped++;
+ if (boxes && boxes.length > 0 && (boxes.length !== this.detectedHands && this.detectedHands !== config3.hand.maxDetected || !config3.hand.landmarks)) {
+ this.detectedHands = 0;
+ this.storedBoxes = [...boxes];
+ if (this.storedBoxes.length > 0)
+ useFreshBox = true;
+ }
+ const hands = [];
+ for (let i = 0; i < this.storedBoxes.length; i++) {
+ const currentBox = this.storedBoxes[i];
+ if (!currentBox)
+ continue;
+ if (config3.hand.landmarks) {
+ const angle = config3.hand.rotation ? computeRotation2(currentBox.palmLandmarks[palmLandmarksPalmBase], currentBox.palmLandmarks[palmLandmarksMiddleFingerBase]) : 0;
+ const palmCenter = getBoxCenter2(currentBox);
+ const palmCenterNormalized = [palmCenter[0] / image28.shape[2], palmCenter[1] / image28.shape[1]];
+ const rotatedImage = config3.hand.rotation && env.kernels.includes("rotatewithoffset") ? tfjs_esm_exports.image.rotateWithOffset(image28, angle, 0, palmCenterNormalized) : image28.clone();
+ const rotationMatrix = buildRotationMatrix2(-angle, palmCenter);
+ const newBox = useFreshBox ? this.getBoxForPalmLandmarks(currentBox.palmLandmarks, rotationMatrix) : currentBox;
+ const croppedInput = cutBoxFromImageAndResize(newBox, rotatedImage, [this.inputSize, this.inputSize]);
+ const handImage = tfjs_esm_exports.div(croppedInput, constants.tf255);
+ tfjs_esm_exports.dispose(croppedInput);
+ tfjs_esm_exports.dispose(rotatedImage);
+ const [confidenceT, keypoints] = this.handPoseModel.execute(handImage);
+ lastTime13 = now();
+ tfjs_esm_exports.dispose(handImage);
+ const confidence = (await confidenceT.data())[0];
+ tfjs_esm_exports.dispose(confidenceT);
+ if (confidence >= config3.hand.minConfidence / 4) {
+ const keypointsReshaped = tfjs_esm_exports.reshape(keypoints, [-1, 3]);
+ const rawCoords = await keypointsReshaped.array();
+ tfjs_esm_exports.dispose(keypoints);
+ tfjs_esm_exports.dispose(keypointsReshaped);
+ const coords = this.transformRawCoords(rawCoords, newBox, angle, rotationMatrix);
+ const nextBoundingBox = this.getBoxForHandLandmarks(coords);
+ this.storedBoxes[i] = { ...nextBoundingBox, confidence };
+ const result = {
+ landmarks: coords,
+ confidence,
+ boxConfidence: currentBox.confidence,
+ fingerConfidence: confidence,
+ box: { topLeft: nextBoundingBox.startPoint, bottomRight: nextBoundingBox.endPoint }
+ };
+ hands.push(result);
+ } else {
+ this.storedBoxes[i] = null;
+ }
+ tfjs_esm_exports.dispose(keypoints);
+ } else {
+ const enlarged = enlargeBox2(squarifyBox2(currentBox), handBoxEnlargeFactor);
+ const result = {
+ confidence: currentBox.confidence,
+ boxConfidence: currentBox.confidence,
+ fingerConfidence: 0,
+ box: { topLeft: enlarged.startPoint, bottomRight: enlarged.endPoint },
+ landmarks: []
+ };
+ hands.push(result);
+ }
+ }
+ this.storedBoxes = this.storedBoxes.filter((a) => a !== null);
+ this.detectedHands = hands.length;
+ if (hands.length > config3.hand.maxDetected)
+ hands.length = config3.hand.maxDetected;
+ return hands;
+ }
+};
+
+// src/hand/handpose.ts
+var meshAnnotations2 = {
+ thumb: [1, 2, 3, 4],
+ index: [5, 6, 7, 8],
+ middle: [9, 10, 11, 12],
+ ring: [13, 14, 15, 16],
+ pinky: [17, 18, 19, 20],
+ palm: [0]
+};
+var handDetectorModel;
+var handPoseModel;
+var handPipeline;
+async function predict14(input, config3) {
+ const predictions = await handPipeline.estimateHands(input, config3);
+ if (!predictions)
+ return [];
+ const hands = [];
+ for (let i = 0; i < predictions.length; i++) {
+ const annotations2 = {};
+ if (predictions[i].landmarks) {
+ for (const key of Object.keys(meshAnnotations2)) {
+ annotations2[key] = meshAnnotations2[key].map((index2) => predictions[i].landmarks[index2]);
+ }
+ }
+ const keypoints = predictions[i].landmarks;
+ let box = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
+ let boxRaw = [0, 0, 0, 0];
+ if (keypoints && keypoints.length > 0) {
+ for (const pt of keypoints) {
+ if (pt[0] < box[0])
+ box[0] = pt[0];
+ if (pt[1] < box[1])
+ box[1] = pt[1];
+ if (pt[0] > box[2])
+ box[2] = pt[0];
+ if (pt[1] > box[3])
+ box[3] = pt[1];
+ }
+ box[2] -= box[0];
+ box[3] -= box[1];
+ boxRaw = [box[0] / (input.shape[2] || 0), box[1] / (input.shape[1] || 0), box[2] / (input.shape[2] || 0), box[3] / (input.shape[1] || 0)];
+ } else {
+ box = predictions[i].box ? [
+ Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
+ Math.trunc(Math.max(0, predictions[i].box.topLeft[1])),
+ Math.trunc(Math.min(input.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])),
+ Math.trunc(Math.min(input.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1]))
+ ] : [0, 0, 0, 0];
+ boxRaw = [
+ predictions[i].box.topLeft[0] / (input.shape[2] || 0),
+ predictions[i].box.topLeft[1] / (input.shape[1] || 0),
+ (predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input.shape[2] || 0),
+ (predictions[i].box.bottomRight[1] - predictions[i].box.topLeft[1]) / (input.shape[1] || 0)
+ ];
+ }
+ const landmarks = analyze(keypoints);
+ hands.push({
+ id: i,
+ score: Math.round(100 * predictions[i].confidence) / 100,
+ boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
+ fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
+ label: "hand",
+ box,
+ boxRaw,
+ keypoints,
+ annotations: annotations2,
+ landmarks
+ });
+ }
+ return hands;
+}
+async function load15(config3) {
+ var _a, _b;
+ if (env.initial) {
+ handDetectorModel = null;
+ handPoseModel = null;
+ }
+ if (!handDetectorModel || !handPoseModel) {
+ [handDetectorModel, handPoseModel] = await Promise.all([
+ config3.hand.enabled ? loadModel((_a = config3.hand.detector) == null ? void 0 : _a.modelPath) : null,
+ config3.hand.landmarks ? loadModel((_b = config3.hand.skeleton) == null ? void 0 : _b.modelPath) : null
+ ]);
+ } else {
+ if (config3.debug)
+ log("cached model:", handDetectorModel["modelUrl"]);
+ if (config3.debug)
+ log("cached model:", handPoseModel["modelUrl"]);
+ }
+ const handDetector = handDetectorModel ? new HandDetector(handDetectorModel) : void 0;
+ if (handDetector && handPoseModel)
+ handPipeline = new HandPipeline(handDetector, handPoseModel);
+ return [handDetectorModel, handPoseModel];
+}
+
+// src/hand/handtrack.ts
+var models2 = [null, null];
+var modelOutputNodes = ["StatefulPartitionedCall/Postprocessor/Slice", "StatefulPartitionedCall/Postprocessor/ExpandDims_1"];
+var inputSize7 = [[0, 0], [0, 0]];
+var classes = ["hand", "fist", "pinch", "point", "face", "tip", "pinchtip"];
+var faceIndex = 4;
+var boxExpandFact = 1.6;
+var maxDetectorResolution = 512;
+var detectorExpandFact = 1.4;
+var skipped13 = Number.MAX_SAFE_INTEGER;
+var lastTime14 = 0;
+var outputSize = [0, 0];
+var cache4 = {
+ boxes: [],
+ hands: []
+};
+var fingerMap = {
+ thumb: [1, 2, 3, 4],
+ index: [5, 6, 7, 8],
+ middle: [9, 10, 11, 12],
+ ring: [13, 14, 15, 16],
+ pinky: [17, 18, 19, 20],
+ base: [0],
+ palm: [0, 17, 13, 9, 5, 1, 0]
+};
+async function loadDetect2(config3) {
+ var _a;
+ if (env.initial)
+ models2[0] = null;
+ if (!models2[0]) {
+ fakeOps(["tensorlistreserve", "enter", "tensorlistfromtensor", "merge", "loopcond", "switch", "exit", "tensorliststack", "nextiteration", "tensorlistsetitem", "tensorlistgetitem", "reciprocal", "shape", "split", "where"], config3);
+ models2[0] = await loadModel((_a = config3.hand.detector) == null ? void 0 : _a.modelPath);
+ const inputs = models2[0]["executor"] ? Object.values(models2[0].modelSignature["inputs"]) : void 0;
+ inputSize7[0][0] = Array.isArray(inputs) ? parseInt(inputs[0].tensorShape.dim[1].size) : 0;
+ inputSize7[0][1] = Array.isArray(inputs) ? parseInt(inputs[0].tensorShape.dim[2].size) : 0;
+ } else if (config3.debug)
+ log("cached model:", models2[0]["modelUrl"]);
+ return models2[0];
+}
+async function loadSkeleton(config3) {
+ var _a;
+ if (env.initial)
+ models2[1] = null;
+ if (!models2[1]) {
+ models2[1] = await loadModel((_a = config3.hand.skeleton) == null ? void 0 : _a.modelPath);
+ const inputs = models2[1]["executor"] ? Object.values(models2[1].modelSignature["inputs"]) : void 0;
+ inputSize7[1][0] = Array.isArray(inputs) ? parseInt(inputs[0].tensorShape.dim[1].size) : 0;
+ inputSize7[1][1] = Array.isArray(inputs) ? parseInt(inputs[0].tensorShape.dim[2].size) : 0;
+ } else if (config3.debug)
+ log("cached model:", models2[1]["modelUrl"]);
+ return models2[1];
+}
+async function detectHands(input, config3) {
+ const hands = [];
+ if (!input || !models2[0])
+ return hands;
+ const t2 = {};
+ const ratio2 = (input.shape[2] || 1) / (input.shape[1] || 1);
+ const height = Math.min(Math.round((input.shape[1] || 0) / 8) * 8, maxDetectorResolution);
+ const width = Math.round(height * ratio2 / 8) * 8;
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(input, [height, width]);
+ t2.cast = tfjs_esm_exports.cast(t2.resize, "int32");
+ [t2.rawScores, t2.rawBoxes] = await models2[0].executeAsync(t2.cast, modelOutputNodes);
+ t2.boxes = tfjs_esm_exports.squeeze(t2.rawBoxes, [0, 2]);
+ t2.scores = tfjs_esm_exports.squeeze(t2.rawScores, [0]);
+ const classScores = tfjs_esm_exports.unstack(t2.scores, 1);
+ tfjs_esm_exports.dispose(classScores[faceIndex]);
+ classScores.splice(faceIndex, 1);
+ t2.filtered = tfjs_esm_exports.stack(classScores, 1);
+ tfjs_esm_exports.dispose(classScores);
+ t2.max = tfjs_esm_exports.max(t2.filtered, 1);
+ t2.argmax = tfjs_esm_exports.argMax(t2.filtered, 1);
+ let id = 0;
+ t2.nms = await tfjs_esm_exports.image.nonMaxSuppressionAsync(t2.boxes, t2.max, (config3.hand.maxDetected || 0) + 1, config3.hand.iouThreshold || 0, config3.hand.minConfidence || 1);
+ const nms = await t2.nms.data();
+ const scores = await t2.max.data();
+ const classNum = await t2.argmax.data();
+ for (const nmsIndex of Array.from(nms)) {
+ const boxSlice = tfjs_esm_exports.slice(t2.boxes, nmsIndex, 1);
+ const boxYX = await boxSlice.data();
+ tfjs_esm_exports.dispose(boxSlice);
+ const boxData = [boxYX[1], boxYX[0], boxYX[3] - boxYX[1], boxYX[2] - boxYX[0]];
+ const boxRaw = scale(boxData, detectorExpandFact);
+ const boxFull = [Math.trunc(boxData[0] * outputSize[0]), Math.trunc(boxData[1] * outputSize[1]), Math.trunc(boxData[2] * outputSize[0]), Math.trunc(boxData[3] * outputSize[1])];
+ const score = scores[nmsIndex];
+ const label = classes[classNum[nmsIndex]];
+ const hand3 = { id: id++, score, box: boxFull, boxRaw, label };
+ hands.push(hand3);
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ hands.sort((a, b) => b.score - a.score);
+ if (hands.length > (config3.hand.maxDetected || 1))
+ hands.length = config3.hand.maxDetected || 1;
+ return hands;
+}
+async function detectFingers(input, h, config3) {
+ const hand3 = {
+ id: h.id,
+ score: Math.round(100 * h.score) / 100,
+ boxScore: Math.round(100 * h.score) / 100,
+ fingerScore: 0,
+ box: h.box,
+ boxRaw: h.boxRaw,
+ label: h.label,
+ keypoints: [],
+ landmarks: {},
+ annotations: {}
+ };
+ if (input && models2[1] && config3.hand.landmarks && h.score > (config3.hand.minConfidence || 0)) {
+ const t2 = {};
+ const boxCrop = [h.boxRaw[1], h.boxRaw[0], h.boxRaw[3] + h.boxRaw[1], h.boxRaw[2] + h.boxRaw[0]];
+ t2.crop = tfjs_esm_exports.image.cropAndResize(input, [boxCrop], [0], [inputSize7[1][0], inputSize7[1][1]], "bilinear");
+ t2.div = tfjs_esm_exports.div(t2.crop, constants.tf255);
+ [t2.score, t2.keypoints] = models2[1].execute(t2.div, ["Identity_1", "Identity"]);
+ const rawScore = (await t2.score.data())[0];
+ const score = (100 - Math.trunc(100 / (1 + Math.exp(rawScore)))) / 100;
+ if (score >= (config3.hand.minConfidence || 0)) {
+ hand3.fingerScore = score;
+ t2.reshaped = tfjs_esm_exports.reshape(t2.keypoints, [-1, 3]);
+ const coordsData = await t2.reshaped.array();
+ const coordsRaw = coordsData.map((kpt4) => [kpt4[0] / inputSize7[1][1], kpt4[1] / inputSize7[1][0], kpt4[2] || 0]);
+ const coordsNorm = coordsRaw.map((kpt4) => [kpt4[0] * h.boxRaw[2], kpt4[1] * h.boxRaw[3], kpt4[2] || 0]);
+ hand3.keypoints = coordsNorm.map((kpt4) => [outputSize[0] * (kpt4[0] + h.boxRaw[0]), outputSize[1] * (kpt4[1] + h.boxRaw[1]), kpt4[2] || 0]);
+ hand3.landmarks = analyze(hand3.keypoints);
+ for (const key of Object.keys(fingerMap)) {
+ hand3.annotations[key] = fingerMap[key].map((index2) => hand3.landmarks && hand3.keypoints[index2] ? hand3.keypoints[index2] : null);
+ }
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ }
+ return hand3;
+}
+async function predict15(input, config3) {
+ var _a, _b;
+ if (!((_a = models2[0]) == null ? void 0 : _a["executor"]) || !((_b = models2[1]) == null ? void 0 : _b["executor"]) || !models2[0].inputs[0].shape || !models2[1].inputs[0].shape)
+ return [];
+ outputSize = [input.shape[2] || 0, input.shape[1] || 0];
+ skipped13++;
+ const skipTime = (config3.hand.skipTime || 0) > now() - lastTime14;
+ const skipFrame = skipped13 < (config3.hand.skipFrames || 0);
+ if (config3.skipAllowed && skipTime && skipFrame) {
+ return cache4.hands;
+ }
+ return new Promise(async (resolve) => {
+ const skipTimeExtended = 3 * (config3.hand.skipTime || 0) > now() - lastTime14;
+ const skipFrameExtended = skipped13 < 3 * (config3.hand.skipFrames || 0);
+ if (config3.skipAllowed && cache4.hands.length === config3.hand.maxDetected) {
+ cache4.hands = await Promise.all(cache4.boxes.map((handBox) => detectFingers(input, handBox, config3)));
+ } else if (config3.skipAllowed && skipTimeExtended && skipFrameExtended && cache4.hands.length > 0) {
+ cache4.hands = await Promise.all(cache4.boxes.map((handBox) => detectFingers(input, handBox, config3)));
+ } else {
+ cache4.boxes = await detectHands(input, config3);
+ lastTime14 = now();
+ cache4.hands = await Promise.all(cache4.boxes.map((handBox) => detectFingers(input, handBox, config3)));
+ skipped13 = 0;
+ }
+ const oldCache = [...cache4.boxes];
+ cache4.boxes.length = 0;
+ if (config3.cacheSensitivity > 0) {
+ for (let i = 0; i < cache4.hands.length; i++) {
+ const boxKpt = square(cache4.hands[i].keypoints, outputSize);
+ if (boxKpt.box[2] / (input.shape[2] || 1) > 0.05 && boxKpt.box[3] / (input.shape[1] || 1) > 0.05 && cache4.hands[i].fingerScore && cache4.hands[i].fingerScore > (config3.hand.minConfidence || 0)) {
+ const boxScale = scale(boxKpt.box, boxExpandFact);
+ const boxScaleRaw = scale(boxKpt.boxRaw, boxExpandFact);
+ cache4.boxes.push({ ...oldCache[i], box: boxScale, boxRaw: boxScaleRaw });
+ }
+ }
+ }
+ for (let i = 0; i < cache4.hands.length; i++) {
+ const bbox = calc(cache4.hands[i].keypoints, outputSize);
+ cache4.hands[i].box = bbox.box;
+ cache4.hands[i].boxRaw = bbox.boxRaw;
+ }
+ resolve(cache4.hands);
+ });
+}
+
+// src/result.ts
+var empty = (error = null) => ({ face: [], body: [], hand: [], gesture: [], object: [], persons: [], performance: {}, timestamp: 0, width: 0, height: 0, error });
+
+// src/body/movenetcoords.ts
+var movenetcoords_exports = {};
+__export(movenetcoords_exports, {
+ connected: () => connected3,
+ horizontal: () => horizontal,
+ kpt: () => kpt3,
+ relative: () => relative,
+ vertical: () => vertical
+});
+var kpt3 = [
+ "nose",
+ "leftEye",
+ "rightEye",
+ "leftEar",
+ "rightEar",
+ "leftShoulder",
+ "rightShoulder",
+ "leftElbow",
+ "rightElbow",
+ "leftWrist",
+ "rightWrist",
+ "leftHip",
+ "rightHip",
+ "leftKnee",
+ "rightKnee",
+ "leftAnkle",
+ "rightAnkle"
+];
+var horizontal = [
+ ["leftEye", "rightEye"],
+ ["leftEar", "rightEar"],
+ ["leftShoulder", "rightShoulder"],
+ ["leftElbow", "rightElbow"],
+ ["leftWrist", "rightWrist"],
+ ["leftHip", "rightHip"],
+ ["leftKnee", "rightKnee"],
+ ["leftAnkle", "rightAnkle"]
+];
+var vertical = [
+ ["leftKnee", "leftShoulder"],
+ ["rightKnee", "rightShoulder"],
+ ["leftAnkle", "leftKnee"],
+ ["rightAnkle", "rightKnee"]
+];
+var relative = [
+ [["leftHip", "rightHip"], ["leftShoulder", "rightShoulder"]],
+ [["leftElbow", "rightElbow"], ["leftShoulder", "rightShoulder"]]
+];
+var connected3 = {
+ leftLeg: ["leftHip", "leftKnee", "leftAnkle"],
+ rightLeg: ["rightHip", "rightKnee", "rightAnkle"],
+ torso: ["leftShoulder", "rightShoulder", "rightHip", "leftHip", "leftShoulder"],
+ leftArm: ["leftShoulder", "leftElbow", "leftWrist"],
+ rightArm: ["rightShoulder", "rightElbow", "rightWrist"],
+ head: []
+};
+
+// src/util/interpolate.ts
+var bufferedResult = empty();
+var interpolateTime = 0;
+function calc2(newResult, config3) {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
+ const t0 = now();
+ if (!newResult)
+ return empty();
+ const elapsed = Date.now() - newResult.timestamp;
+ const bufferedFactor = elapsed < 1e3 ? 8 - Math.log(elapsed + 1) : 1;
+ if (newResult.canvas)
+ bufferedResult.canvas = newResult.canvas;
+ if (newResult.error)
+ bufferedResult.error = newResult.error;
+ if (!bufferedResult.body || newResult.body.length !== bufferedResult.body.length) {
+ bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
+ } else {
+ for (let i = 0; i < newResult.body.length; i++) {
+ const box = newResult.body[i].box.map((newBoxCoord, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + newBoxCoord) / bufferedFactor);
+ const boxRaw = newResult.body[i].boxRaw.map((newBoxCoord, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + newBoxCoord) / bufferedFactor);
+ const keypoints = newResult.body[i].keypoints.map((newKpt, j) => {
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
+ return {
+ score: newKpt.score,
+ part: newKpt.part,
+ position: [
+ bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * (bufferedResult.body[i].keypoints[j].position[0] || 0) + (newKpt.position[0] || 0)) / bufferedFactor : newKpt.position[0],
+ bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * (bufferedResult.body[i].keypoints[j].position[1] || 0) + (newKpt.position[1] || 0)) / bufferedFactor : newKpt.position[1],
+ bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * (bufferedResult.body[i].keypoints[j].position[2] || 0) + (newKpt.position[2] || 0)) / bufferedFactor : newKpt.position[2]
+ ],
+ positionRaw: [
+ bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * (bufferedResult.body[i].keypoints[j].positionRaw[0] || 0) + (newKpt.positionRaw[0] || 0)) / bufferedFactor : newKpt.positionRaw[0],
+ bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * (bufferedResult.body[i].keypoints[j].positionRaw[1] || 0) + (newKpt.positionRaw[1] || 0)) / bufferedFactor : newKpt.positionRaw[1],
+ bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * (bufferedResult.body[i].keypoints[j].positionRaw[2] || 0) + (newKpt.positionRaw[2] || 0)) / bufferedFactor : newKpt.positionRaw[2]
+ ],
+ distance: [
+ bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * (((_a2 = bufferedResult.body[i].keypoints[j].distance) == null ? void 0 : _a2[0]) || 0) + (((_b2 = newKpt.distance) == null ? void 0 : _b2[0]) || 0)) / bufferedFactor : (_c2 = newKpt.distance) == null ? void 0 : _c2[0],
+ bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * (((_d2 = bufferedResult.body[i].keypoints[j].distance) == null ? void 0 : _d2[1]) || 0) + (((_e2 = newKpt.distance) == null ? void 0 : _e2[1]) || 0)) / bufferedFactor : (_f2 = newKpt.distance) == null ? void 0 : _f2[1],
+ bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * (((_g2 = bufferedResult.body[i].keypoints[j].distance) == null ? void 0 : _g2[2]) || 0) + (((_h2 = newKpt.distance) == null ? void 0 : _h2[2]) || 0)) / bufferedFactor : (_i2 = newKpt.distance) == null ? void 0 : _i2[2]
+ ]
+ };
+ });
+ const annotations2 = {};
+ let coords = { connected: {} };
+ if ((_a = config3.body.modelPath) == null ? void 0 : _a.includes("efficientpose"))
+ coords = efficientposecoords_exports;
+ else if ((_b = config3.body.modelPath) == null ? void 0 : _b.includes("blazepose"))
+ coords = blazeposecoords_exports;
+ else if ((_c = config3.body.modelPath) == null ? void 0 : _c.includes("movenet"))
+ coords = movenetcoords_exports;
+ for (const [name, indexes] of Object.entries(coords.connected)) {
+ const pt = [];
+ for (let j = 0; j < indexes.length - 1; j++) {
+ const pt0 = keypoints.find((kp) => kp.part === indexes[j]);
+ const pt1 = keypoints.find((kp) => kp.part === indexes[j + 1]);
+ if (pt0 && pt1)
+ pt.push([pt0.position, pt1.position]);
+ }
+ annotations2[name] = pt;
+ }
+ bufferedResult.body[i] = { ...newResult.body[i], box, boxRaw, keypoints, annotations: annotations2 };
+ }
+ }
+ if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
+ bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
+ } else {
+ for (let i = 0; i < newResult.hand.length; i++) {
+ const box = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
+ const boxRaw = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor);
+ if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length)
+ bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
+ const keypoints = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * (bufferedResult.hand[i].keypoints[j][k] || 1) + (coord || 0)) / bufferedFactor)) : [];
+ let annotations2 = {};
+ if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length) {
+ bufferedResult.hand[i].annotations = newResult.hand[i].annotations;
+ annotations2 = bufferedResult.hand[i].annotations;
+ } else if (newResult.hand[i].annotations) {
+ for (const key of Object.keys(newResult.hand[i].annotations)) {
+ annotations2[key] = ((_f = (_e = (_d = newResult.hand[i]) == null ? void 0 : _d.annotations) == null ? void 0 : _e[key]) == null ? void 0 : _f[0]) ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null;
+ }
+ }
+ bufferedResult.hand[i] = { ...newResult.hand[i], box, boxRaw, keypoints, annotations: annotations2 };
+ }
+ }
+ if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
+ bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
+ } else {
+ for (let i = 0; i < newResult.face.length; i++) {
+ const box = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
+ const boxRaw = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor);
+ if (newResult.face[i].rotation) {
+ const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } };
+ rotation.matrix = (_g = newResult.face[i].rotation) == null ? void 0 : _g.matrix;
+ rotation.angle = {
+ roll: ((bufferedFactor - 1) * (((_i = (_h = bufferedResult.face[i].rotation) == null ? void 0 : _h.angle) == null ? void 0 : _i.roll) || 0) + (((_k = (_j = newResult.face[i].rotation) == null ? void 0 : _j.angle) == null ? void 0 : _k.roll) || 0)) / bufferedFactor,
+ yaw: ((bufferedFactor - 1) * (((_m = (_l = bufferedResult.face[i].rotation) == null ? void 0 : _l.angle) == null ? void 0 : _m.yaw) || 0) + (((_o = (_n = newResult.face[i].rotation) == null ? void 0 : _n.angle) == null ? void 0 : _o.yaw) || 0)) / bufferedFactor,
+ pitch: ((bufferedFactor - 1) * (((_q = (_p = bufferedResult.face[i].rotation) == null ? void 0 : _p.angle) == null ? void 0 : _q.pitch) || 0) + (((_s = (_r = newResult.face[i].rotation) == null ? void 0 : _r.angle) == null ? void 0 : _s.pitch) || 0)) / bufferedFactor
+ };
+ rotation.gaze = {
+ bearing: ((bufferedFactor - 1) * (((_t = bufferedResult.face[i].rotation) == null ? void 0 : _t.gaze.bearing) || 0) + (((_u = newResult.face[i].rotation) == null ? void 0 : _u.gaze.bearing) || 0)) / bufferedFactor,
+ strength: ((bufferedFactor - 1) * (((_v = bufferedResult.face[i].rotation) == null ? void 0 : _v.gaze.strength) || 0) + (((_w = newResult.face[i].rotation) == null ? void 0 : _w.gaze.strength) || 0)) / bufferedFactor
+ };
+ bufferedResult.face[i] = { ...newResult.face[i], rotation, box, boxRaw };
+ } else {
+ bufferedResult.face[i] = { ...newResult.face[i], box, boxRaw };
+ }
+ }
+ }
+ if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
+ bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
+ } else {
+ for (let i = 0; i < newResult.object.length; i++) {
+ const box = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
+ const boxRaw = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor);
+ bufferedResult.object[i] = { ...newResult.object[i], box, boxRaw };
+ }
+ }
+ if (newResult.persons) {
+ const newPersons = newResult.persons;
+ if (!bufferedResult.persons || newPersons.length !== bufferedResult.persons.length) {
+ bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
+ } else {
+ for (let i = 0; i < newPersons.length; i++) {
+ bufferedResult.persons[i].box = newPersons[i].box.map((box, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box) / bufferedFactor);
+ }
+ }
+ }
+ if (newResult.gesture)
+ bufferedResult.gesture = newResult.gesture;
+ bufferedResult.width = newResult.width;
+ bufferedResult.height = newResult.height;
+ const t1 = now();
+ interpolateTime = env.perfadd ? interpolateTime + Math.round(t1 - t0) : Math.round(t1 - t0);
+ if (newResult.performance)
+ bufferedResult.performance = { ...newResult.performance, interpolate: interpolateTime };
+ return bufferedResult;
+}
+
+// src/segmentation/meet.ts
+var model17;
+async function load16(config3) {
+ if (!model17 || env.initial)
+ model17 = await loadModel(config3.segmentation.modelPath);
+ else if (config3.debug)
+ log("cached model:", model17["modelUrl"]);
+ return model17;
+}
+async function predict16(input, config3) {
+ var _a;
+ if (!model17)
+ model17 = await load16(config3);
+ if (!(model17 == null ? void 0 : model17["executor"]) || !((_a = model17 == null ? void 0 : model17.inputs) == null ? void 0 : _a[0].shape))
+ return null;
+ const t2 = {};
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(input, [model17.inputs[0].shape ? model17.inputs[0].shape[1] : 0, model17.inputs[0].shape ? model17.inputs[0].shape[2] : 0], false);
+ t2.norm = tfjs_esm_exports.div(t2.resize, constants.tf255);
+ t2.res = model17.execute(t2.norm);
+ t2.squeeze = tfjs_esm_exports.squeeze(t2.res, [0]);
+ [t2.bgRaw, t2.fgRaw] = tfjs_esm_exports.unstack(t2.squeeze, 2);
+ t2.fg = tfjs_esm_exports.softmax(t2.fgRaw);
+ t2.mul = tfjs_esm_exports.mul(t2.fg, constants.tf255);
+ t2.expand = tfjs_esm_exports.expandDims(t2.mul, 2);
+ t2.output = tfjs_esm_exports.image.resizeBilinear(t2.expand, [input.shape[1] || 0, input.shape[2] || 0]);
+ let rgba;
+ switch (config3.segmentation.mode || "default") {
+ case "default":
+ t2.input = tfjs_esm_exports.squeeze(input);
+ t2.concat = tfjs_esm_exports.concat([t2.input, t2.output], -1);
+ rgba = tfjs_esm_exports.cast(t2.concat, "int32");
+ break;
+ case "alpha":
+ rgba = tfjs_esm_exports.cast(t2.output, "int32");
+ break;
+ default:
+ rgba = tfjs_esm_exports.tensor(0);
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return rgba;
+}
+
+// src/face/match.ts
+var match_exports = {};
+__export(match_exports, {
+ distance: () => distance,
+ find: () => find,
+ similarity: () => similarity
+});
+function distance(descriptor1, descriptor2, options4 = { order: 2, multiplier: 25 }) {
+ if (!descriptor1 || !descriptor1)
+ return Number.MAX_SAFE_INTEGER;
+ let sum3 = 0;
+ for (let i = 0; i < descriptor1.length; i++) {
+ const diff = !options4.order || options4.order === 2 ? descriptor1[i] - descriptor2[i] : Math.abs(descriptor1[i] - descriptor2[i]);
+ sum3 += !options4.order || options4.order === 2 ? diff * diff : diff ** options4.order;
+ }
+ return (options4.multiplier || 20) * sum3;
+}
+var normalizeDistance = (dist, order, min2, max5) => {
+ if (dist === 0)
+ return 1;
+ const root = order === 2 ? Math.sqrt(dist) : dist ** (1 / order);
+ const norm = (1 - root / 100 - min2) / (max5 - min2);
+ const clamp2 = Math.max(Math.min(norm, 1), 0);
+ return clamp2;
+};
+function similarity(descriptor1, descriptor2, options4 = { order: 2, multiplier: 25, min: 0.2, max: 0.8 }) {
+ const dist = distance(descriptor1, descriptor2, options4);
+ return normalizeDistance(dist, options4.order || 2, options4.min || 0, options4.max || 1);
+}
+function find(descriptor, descriptors, options4 = { order: 2, multiplier: 25, threshold: 0, min: 0.2, max: 0.8 }) {
+ if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0) {
+ return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 };
+ }
+ let lowestDistance = Number.MAX_SAFE_INTEGER;
+ let index2 = -1;
+ for (let i = 0; i < descriptors.length; i++) {
+ const res = descriptors[i].length === descriptor.length ? distance(descriptor, descriptors[i], options4) : Number.MAX_SAFE_INTEGER;
+ if (res < lowestDistance) {
+ lowestDistance = res;
+ index2 = i;
+ }
+ if (lowestDistance < (options4.threshold || 0))
+ break;
+ }
+ const normalizedSimilarity = normalizeDistance(lowestDistance, options4.order || 2, options4.min || 0, options4.max || 1);
+ return { index: index2, distance: lowestDistance, similarity: normalizedSimilarity };
+}
+
+// src/models.ts
+var models_exports2 = {};
+__export(models_exports2, {
+ Models: () => Models,
+ validateModel: () => validateModel
+});
+
+// src/body/movenetfix.ts
+var maxJitter = 5e-3;
+var cache5 = {
+ keypoints: [],
+ padding: [[0, 0], [0, 0], [0, 0], [0, 0]]
+};
+function bodyParts(body4) {
+ for (const pair of horizontal) {
+ const left = body4.keypoints.findIndex((kp) => kp.part === pair[0]);
+ const right = body4.keypoints.findIndex((kp) => kp.part === pair[1]);
+ if (body4.keypoints[left] && body4.keypoints[right]) {
+ if (body4.keypoints[left].position[0] < body4.keypoints[right].position[0]) {
+ const tmp = body4.keypoints[left];
+ body4.keypoints[left] = body4.keypoints[right];
+ body4.keypoints[right] = tmp;
+ }
+ }
+ }
+ for (const pair of vertical) {
+ const lower = body4.keypoints.findIndex((kp) => kp && kp.part === pair[0]);
+ const higher = body4.keypoints.findIndex((kp) => kp && kp.part === pair[1]);
+ if (body4.keypoints[lower] && body4.keypoints[higher]) {
+ if (body4.keypoints[lower].position[1] < body4.keypoints[higher].position[1]) {
+ body4.keypoints.splice(lower, 1);
+ }
+ }
+ }
+ for (const [pair, compare2] of relative) {
+ const left = body4.keypoints.findIndex((kp) => kp && kp.part === pair[0]);
+ const right = body4.keypoints.findIndex((kp) => kp && kp.part === pair[1]);
+ const leftTo = body4.keypoints.findIndex((kp) => kp && kp.part === compare2[0]);
+ const rightTo = body4.keypoints.findIndex((kp) => kp && kp.part === compare2[1]);
+ if (!body4.keypoints[leftTo] || !body4.keypoints[rightTo])
+ continue;
+ const distanceLeft = body4.keypoints[left] ? [
+ Math.abs(body4.keypoints[leftTo].position[0] - body4.keypoints[left].position[0]),
+ Math.abs(body4.keypoints[rightTo].position[0] - body4.keypoints[left].position[0])
+ ] : [0, 0];
+ const distanceRight = body4.keypoints[right] ? [
+ Math.abs(body4.keypoints[rightTo].position[0] - body4.keypoints[right].position[0]),
+ Math.abs(body4.keypoints[leftTo].position[0] - body4.keypoints[right].position[0])
+ ] : [0, 0];
+ if (distanceLeft[0] > distanceLeft[1] || distanceRight[0] > distanceRight[1]) {
+ const tmp = body4.keypoints[left];
+ body4.keypoints[left] = body4.keypoints[right];
+ body4.keypoints[right] = tmp;
+ }
+ }
+}
+function jitter(keypoints) {
+ for (let i = 0; i < keypoints.length; i++) {
+ if (keypoints[i] && cache5.keypoints[i]) {
+ const diff = [Math.abs(keypoints[i].positionRaw[0] - cache5.keypoints[i].positionRaw[0]), Math.abs(keypoints[i].positionRaw[1] - cache5.keypoints[i].positionRaw[1])];
+ if (diff[0] < maxJitter && diff[1] < maxJitter) {
+ keypoints[i] = cache5.keypoints[i];
+ } else {
+ cache5.keypoints[i] = keypoints[i];
+ }
+ } else {
+ cache5.keypoints[i] = keypoints[i];
+ }
+ }
+ return keypoints;
+}
+function padInput(input, inputSize10) {
+ var _a, _b;
+ const t2 = {};
+ if (!((_a = input == null ? void 0 : input.shape) == null ? void 0 : _a[1]) || !((_b = input == null ? void 0 : input.shape) == null ? void 0 : _b[2]))
+ return input;
+ cache5.padding = [
+ [0, 0],
+ [input.shape[2] > input.shape[1] ? Math.trunc((input.shape[2] - input.shape[1]) / 2) : 0, input.shape[2] > input.shape[1] ? Math.trunc((input.shape[2] - input.shape[1]) / 2) : 0],
+ [input.shape[1] > input.shape[2] ? Math.trunc((input.shape[1] - input.shape[2]) / 2) : 0, input.shape[1] > input.shape[2] ? Math.trunc((input.shape[1] - input.shape[2]) / 2) : 0],
+ [0, 0]
+ ];
+ t2.pad = tfjs_esm_exports.pad(input, cache5.padding);
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(t2.pad, [inputSize10, inputSize10]);
+ const final = tfjs_esm_exports.cast(t2.resize, "int32");
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return final;
+}
+function rescaleBody(body4, outputSize2) {
+ body4.keypoints = body4.keypoints.filter((kpt4) => kpt4 == null ? void 0 : kpt4.position);
+ for (const kpt4 of body4.keypoints) {
+ kpt4.position = [
+ kpt4.position[0] * (outputSize2[0] + cache5.padding[2][0] + cache5.padding[2][1]) / outputSize2[0] - cache5.padding[2][0],
+ kpt4.position[1] * (outputSize2[1] + cache5.padding[1][0] + cache5.padding[1][1]) / outputSize2[1] - cache5.padding[1][0]
+ ];
+ kpt4.positionRaw = [
+ kpt4.position[0] / outputSize2[0],
+ kpt4.position[1] / outputSize2[1]
+ ];
+ }
+ const rescaledBoxes = calc(body4.keypoints.map((pt) => pt.position), outputSize2);
+ body4.box = rescaledBoxes.box;
+ body4.boxRaw = rescaledBoxes.boxRaw;
+ return body4;
+}
+
+// src/body/movenet.ts
+var model18;
+var inputSize8 = 0;
+var skipped14 = Number.MAX_SAFE_INTEGER;
+var cache6 = {
+ boxes: [],
+ bodies: [],
+ last: 0
+};
+async function load17(config3) {
+ var _a;
+ if (env.initial)
+ model18 = null;
+ if (!model18) {
+ fakeOps(["size"], config3);
+ model18 = await loadModel(config3.body.modelPath);
+ } else if (config3.debug)
+ log("cached model:", model18["modelUrl"]);
+ inputSize8 = (model18 == null ? void 0 : model18["executor"]) && ((_a = model18 == null ? void 0 : model18.inputs) == null ? void 0 : _a[0].shape) ? model18.inputs[0].shape[2] : 0;
+ if (inputSize8 < 64)
+ inputSize8 = 256;
+ return model18;
+}
+function parseSinglePose(res, config3, image28) {
+ const kpt4 = res[0][0];
+ const keypoints = [];
+ let score = 0;
+ for (let id = 0; id < kpt4.length; id++) {
+ score = kpt4[id][2];
+ if (score > config3.body.minConfidence) {
+ const positionRaw = [kpt4[id][1], kpt4[id][0]];
+ keypoints.push({
+ score: Math.round(100 * score) / 100,
+ part: kpt3[id],
+ positionRaw,
+ position: [
+ Math.round((image28.shape[2] || 0) * positionRaw[0]),
+ Math.round((image28.shape[1] || 0) * positionRaw[1])
+ ]
+ });
+ }
+ }
+ score = keypoints.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
+ const bodies = [];
+ const newBox = calc(keypoints.map((pt) => pt.position), [image28.shape[2], image28.shape[1]]);
+ const annotations2 = {};
+ for (const [name, indexes] of Object.entries(connected3)) {
+ const pt = [];
+ for (let i = 0; i < indexes.length - 1; i++) {
+ const pt0 = keypoints.find((kp) => kp.part === indexes[i]);
+ const pt1 = keypoints.find((kp) => kp.part === indexes[i + 1]);
+ if (pt0 && pt1 && pt0.score > (config3.body.minConfidence || 0) && pt1.score > (config3.body.minConfidence || 0))
+ pt.push([pt0.position, pt1.position]);
+ }
+ annotations2[name] = pt;
+ }
+ const body4 = { id: 0, score, box: newBox.box, boxRaw: newBox.boxRaw, keypoints, annotations: annotations2 };
+ bodyParts(body4);
+ bodies.push(body4);
+ return bodies;
+}
+function parseMultiPose(res, config3, image28) {
+ const bodies = [];
+ for (let id = 0; id < res[0].length; id++) {
+ const kpt4 = res[0][id];
+ const totalScore = Math.round(100 * kpt4[51 + 4]) / 100;
+ if (totalScore > config3.body.minConfidence) {
+ const keypoints = [];
+ for (let i = 0; i < 17; i++) {
+ const score = kpt4[3 * i + 2];
+ if (score > config3.body.minConfidence) {
+ const positionRaw = [kpt4[3 * i + 1], kpt4[3 * i + 0]];
+ keypoints.push({
+ part: kpt3[i],
+ score: Math.round(100 * score) / 100,
+ positionRaw,
+ position: [Math.round((image28.shape[2] || 0) * positionRaw[0]), Math.round((image28.shape[1] || 0) * positionRaw[1])]
+ });
+ }
+ }
+ const newBox = calc(keypoints.map((pt) => pt.position), [image28.shape[2], image28.shape[1]]);
+ const annotations2 = {};
+ for (const [name, indexes] of Object.entries(connected3)) {
+ const pt = [];
+ for (let i = 0; i < indexes.length - 1; i++) {
+ const pt0 = keypoints.find((kp) => kp.part === indexes[i]);
+ const pt1 = keypoints.find((kp) => kp.part === indexes[i + 1]);
+ if (pt0 && pt1 && pt0.score > (config3.body.minConfidence || 0) && pt1.score > (config3.body.minConfidence || 0))
+ pt.push([pt0.position, pt1.position]);
+ }
+ annotations2[name] = pt;
+ }
+ const body4 = { id, score: totalScore, box: newBox.box, boxRaw: newBox.boxRaw, keypoints: [...keypoints], annotations: annotations2 };
+ bodyParts(body4);
+ bodies.push(body4);
+ }
+ }
+ bodies.sort((a, b) => b.score - a.score);
+ if (bodies.length > config3.body.maxDetected)
+ bodies.length = config3.body.maxDetected;
+ return bodies;
+}
+async function predict17(input, config3) {
+ var _a;
+ if (!(model18 == null ? void 0 : model18["executor"]) || !((_a = model18 == null ? void 0 : model18.inputs) == null ? void 0 : _a[0].shape))
+ return [];
+ if (!config3.skipAllowed)
+ cache6.boxes.length = 0;
+ skipped14++;
+ const skipTime = (config3.body.skipTime || 0) > now() - cache6.last;
+ const skipFrame = skipped14 < (config3.body.skipFrames || 0);
+ if (config3.skipAllowed && skipTime && skipFrame) {
+ return cache6.bodies;
+ }
+ return new Promise(async (resolve) => {
+ const t2 = {};
+ skipped14 = 0;
+ t2.input = padInput(input, inputSize8);
+ t2.res = model18 == null ? void 0 : model18.execute(t2.input);
+ cache6.last = now();
+ const res = await t2.res.array();
+ cache6.bodies = t2.res.shape[2] === 17 ? parseSinglePose(res, config3, input) : parseMultiPose(res, config3, input);
+ for (const body4 of cache6.bodies) {
+ rescaleBody(body4, [input.shape[2] || 1, input.shape[1] || 1]);
+ jitter(body4.keypoints);
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ resolve(cache6.bodies);
+ });
+}
+
+// src/object/nanodet.ts
+var model19;
+var last10 = [];
+var lastTime15 = 0;
+var skipped15 = Number.MAX_SAFE_INTEGER;
+var inputSize9 = 0;
+var scaleBox = 2.5;
+async function load18(config3) {
+ if (!model19 || env.initial) {
+ model19 = await loadModel(config3.object.modelPath);
+ const inputs = (model19 == null ? void 0 : model19["executor"]) ? Object.values(model19.modelSignature["inputs"]) : void 0;
+ inputSize9 = Array.isArray(inputs) ? parseInt(inputs[0].tensorShape.dim[2].size) : 416;
+ } else if (config3.debug)
+ log("cached model:", model19["modelUrl"]);
+ return model19;
+}
+async function process4(res, outputShape, config3) {
+ var _a, _b;
+ let id = 0;
+ let results = [];
+ const size2 = inputSize9;
+ for (const strideSize of [1, 2, 4]) {
+ const baseSize = strideSize * 13;
+ const scoresT = tfjs_esm_exports.squeeze(res.find((a) => a.shape[1] === baseSize ** 2 && (a.shape[2] || 0) === labels2.length));
+ const scores = await scoresT.array();
+ const featuresT = tfjs_esm_exports.squeeze(res.find((a) => a.shape[1] === baseSize ** 2 && (a.shape[2] || 0) < labels2.length));
+ const boxesMaxT = tfjs_esm_exports.reshape(featuresT, [-1, 4, (((_a = featuresT.shape) == null ? void 0 : _a[1]) || 0) / 4]);
+ const boxIdxT = tfjs_esm_exports.argMax(boxesMaxT, 2);
+ const boxIdx = await boxIdxT.array();
+ for (let i = 0; i < scoresT.shape[0]; i++) {
+ for (let j = 0; j < (((_b = scoresT.shape) == null ? void 0 : _b[1]) || 0); j++) {
+ const score = scores[i][j];
+ if (score > (config3.object.minConfidence || 0) && j !== 61) {
+ const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize;
+ const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize;
+ const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / size2));
+ const [x, y] = [
+ cx - scaleBox / strideSize * boxOffset[0],
+ cy - scaleBox / strideSize * boxOffset[1]
+ ];
+ const [w, h] = [
+ cx + scaleBox / strideSize * boxOffset[2] - x,
+ cy + scaleBox / strideSize * boxOffset[3] - y
+ ];
+ let boxRaw = [x, y, w, h];
+ boxRaw = boxRaw.map((a) => Math.max(0, Math.min(a, 1)));
+ const box = [
+ boxRaw[0] * outputShape[0],
+ boxRaw[1] * outputShape[1],
+ boxRaw[2] * outputShape[0],
+ boxRaw[3] * outputShape[1]
+ ];
+ const result = {
+ id: id++,
+ score: Math.round(100 * score) / 100,
+ class: j + 1,
+ label: labels2[j].label,
+ box: box.map((a) => Math.trunc(a)),
+ boxRaw
+ };
+ results.push(result);
+ }
+ }
+ }
+ tfjs_esm_exports.dispose([scoresT, featuresT, boxesMaxT, boxIdxT]);
+ }
+ const nmsBoxes = results.map((a) => [a.boxRaw[1], a.boxRaw[0], a.boxRaw[3], a.boxRaw[2]]);
+ const nmsScores = results.map((a) => a.score);
+ let nmsIdx = [];
+ if (nmsBoxes && nmsBoxes.length > 0) {
+ const nms = await tfjs_esm_exports.image.nonMaxSuppressionAsync(nmsBoxes, nmsScores, config3.object.maxDetected || 0, config3.object.iouThreshold, config3.object.minConfidence);
+ nmsIdx = Array.from(await nms.data());
+ tfjs_esm_exports.dispose(nms);
+ }
+ results = results.filter((_val, idx) => nmsIdx.includes(idx)).sort((a, b) => b.score - a.score);
+ return results;
+}
+async function predict18(image28, config3) {
+ if (!(model19 == null ? void 0 : model19["executor"]))
+ return [];
+ const skipTime = (config3.object.skipTime || 0) > now() - lastTime15;
+ const skipFrame = skipped15 < (config3.object.skipFrames || 0);
+ if (config3.skipAllowed && skipTime && skipFrame && last10.length > 0) {
+ skipped15++;
+ return last10;
+ }
+ skipped15 = 0;
+ if (!env.kernels.includes("mod") || !env.kernels.includes("sparsetodense"))
+ return last10;
+ return new Promise(async (resolve) => {
+ const outputSize2 = [image28.shape[2] || 0, image28.shape[1] || 0];
+ const resizeT = tfjs_esm_exports.image.resizeBilinear(image28, [inputSize9, inputSize9], false);
+ const normT = tfjs_esm_exports.div(resizeT, constants.tf255);
+ const transposeT = tfjs_esm_exports.transpose(normT, [0, 3, 1, 2]);
+ let objectT;
+ if (config3.object.enabled)
+ objectT = model19.execute(transposeT);
+ lastTime15 = now();
+ const obj = await process4(objectT, outputSize2, config3);
+ last10 = obj;
+ tfjs_esm_exports.dispose([resizeT, normT, transposeT, ...objectT]);
+ resolve(obj);
+ });
+}
+
+// src/body/posenetutils.ts
+var partNames = [
+ "nose",
+ "leftEye",
+ "rightEye",
+ "leftEar",
+ "rightEar",
+ "leftShoulder",
+ "rightShoulder",
+ "leftElbow",
+ "rightElbow",
+ "leftWrist",
+ "rightWrist",
+ "leftHip",
+ "rightHip",
+ "leftKnee",
+ "rightKnee",
+ "leftAnkle",
+ "rightAnkle"
+];
+var count = partNames.length;
+var partIds = partNames.reduce((result, jointName, i) => {
+ result[jointName] = i;
+ return result;
+}, {});
+var connectedPartNames = [
+ ["leftHip", "leftShoulder"],
+ ["leftElbow", "leftShoulder"],
+ ["leftElbow", "leftWrist"],
+ ["leftHip", "leftKnee"],
+ ["leftKnee", "leftAnkle"],
+ ["rightHip", "rightShoulder"],
+ ["rightElbow", "rightShoulder"],
+ ["rightElbow", "rightWrist"],
+ ["rightHip", "rightKnee"],
+ ["rightKnee", "rightAnkle"],
+ ["leftShoulder", "rightShoulder"],
+ ["leftHip", "rightHip"]
+];
+var connectedPartIndices = connectedPartNames.map(([jointNameA, jointNameB]) => [partIds[jointNameA], partIds[jointNameB]]);
+var poseChain = [
+ ["nose", "leftEye"],
+ ["leftEye", "leftEar"],
+ ["nose", "rightEye"],
+ ["rightEye", "rightEar"],
+ ["nose", "leftShoulder"],
+ ["leftShoulder", "leftElbow"],
+ ["leftElbow", "leftWrist"],
+ ["leftShoulder", "leftHip"],
+ ["leftHip", "leftKnee"],
+ ["leftKnee", "leftAnkle"],
+ ["nose", "rightShoulder"],
+ ["rightShoulder", "rightElbow"],
+ ["rightElbow", "rightWrist"],
+ ["rightShoulder", "rightHip"],
+ ["rightHip", "rightKnee"],
+ ["rightKnee", "rightAnkle"]
+];
+function getBoundingBox(keypoints) {
+ const coord = keypoints.reduce(({ maxX, maxY, minX, minY }, { position: { x, y } }) => ({
+ maxX: Math.max(maxX, x),
+ maxY: Math.max(maxY, y),
+ minX: Math.min(minX, x),
+ minY: Math.min(minY, y)
+ }), {
+ maxX: Number.NEGATIVE_INFINITY,
+ maxY: Number.NEGATIVE_INFINITY,
+ minX: Number.POSITIVE_INFINITY,
+ minY: Number.POSITIVE_INFINITY
+ });
+ return [coord.minX, coord.minY, coord.maxX - coord.minX, coord.maxY - coord.minY];
+}
+function scalePoses(poses, [height, width], [inputResolutionHeight, inputResolutionWidth]) {
+ const scaleY = height / inputResolutionHeight;
+ const scaleX = width / inputResolutionWidth;
+ const scalePose = (pose, i) => ({
+ id: i,
+ score: pose.score,
+ boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight],
+ box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)],
+ keypoints: pose.keypoints.map(({ score, part, position }) => ({
+ score,
+ part,
+ position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)],
+ positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight]
+ })),
+ annotations: {}
+ });
+ const scaledPoses = poses.map((pose, i) => scalePose(pose, i));
+ return scaledPoses;
+}
+var MaxHeap = class {
+ constructor(maxSize2, getElementValue) {
+ __publicField(this, "priorityQueue");
+ __publicField(this, "numberOfElements");
+ __publicField(this, "getElementValue");
+ this.priorityQueue = new Array(maxSize2);
+ this.numberOfElements = -1;
+ this.getElementValue = getElementValue;
+ }
+ enqueue(x) {
+ this.priorityQueue[++this.numberOfElements] = x;
+ this.swim(this.numberOfElements);
+ }
+ dequeue() {
+ const max5 = this.priorityQueue[0];
+ this.exchange(0, this.numberOfElements--);
+ this.sink(0);
+ this.priorityQueue[this.numberOfElements + 1] = null;
+ return max5;
+ }
+ empty() {
+ return this.numberOfElements === -1;
+ }
+ size() {
+ return this.numberOfElements + 1;
+ }
+ all() {
+ return this.priorityQueue.slice(0, this.numberOfElements + 1);
+ }
+ max() {
+ return this.priorityQueue[0];
+ }
+ swim(k) {
+ while (k > 0 && this.less(Math.floor(k / 2), k)) {
+ this.exchange(k, Math.floor(k / 2));
+ k = Math.floor(k / 2);
+ }
+ }
+ sink(k) {
+ while (2 * k <= this.numberOfElements) {
+ let j = 2 * k;
+ if (j < this.numberOfElements && this.less(j, j + 1))
+ j++;
+ if (!this.less(k, j))
+ break;
+ this.exchange(k, j);
+ k = j;
+ }
+ }
+ getValueAt(i) {
+ return this.getElementValue(this.priorityQueue[i]);
+ }
+ less(i, j) {
+ return this.getValueAt(i) < this.getValueAt(j);
+ }
+ exchange(i, j) {
+ const t2 = this.priorityQueue[i];
+ this.priorityQueue[i] = this.priorityQueue[j];
+ this.priorityQueue[j] = t2;
+ }
+};
+function getOffsetPoint(y, x, keypoint, offsets) {
+ return {
+ y: offsets.get(y, x, keypoint),
+ x: offsets.get(y, x, keypoint + count)
+ };
+}
+function getImageCoords(part, outputStride2, offsets) {
+ const { heatmapY, heatmapX, id: keypoint } = part;
+ const { y, x } = getOffsetPoint(heatmapY, heatmapX, keypoint, offsets);
+ return {
+ x: part.heatmapX * outputStride2 + x,
+ y: part.heatmapY * outputStride2 + y
+ };
+}
+function clamp(a, min2, max5) {
+ if (a < min2)
+ return min2;
+ if (a > max5)
+ return max5;
+ return a;
+}
+function squaredDistance(y1, x1, y2, x2) {
+ const dy = y2 - y1;
+ const dx = x2 - x1;
+ return dy * dy + dx * dx;
+}
+function addVectors(a, b) {
+ return { x: a.x + b.x, y: a.y + b.y };
+}
+
+// src/body/posenet.ts
+var model20;
+var poseNetOutputs = ["MobilenetV1/offset_2/BiasAdd", "MobilenetV1/heatmap_2/BiasAdd", "MobilenetV1/displacement_fwd_2/BiasAdd", "MobilenetV1/displacement_bwd_2/BiasAdd"];
+var localMaximumRadius = 1;
+var outputStride = 16;
+var squaredNmsRadius = 50 ** 2;
+function traverse(edgeId, sourceKeypoint, targetId, scores, offsets, displacements, offsetRefineStep = 2) {
+ const getDisplacement = (point2) => ({
+ y: displacements.get(point2.y, point2.x, edgeId),
+ x: displacements.get(point2.y, point2.x, displacements.shape[2] / 2 + edgeId)
+ });
+ const getStridedIndexNearPoint = (point2, height2, width2) => ({
+ y: clamp(Math.round(point2.y / outputStride), 0, height2 - 1),
+ x: clamp(Math.round(point2.x / outputStride), 0, width2 - 1)
+ });
+ const [height, width] = scores.shape;
+ const sourceKeypointIndices = getStridedIndexNearPoint(sourceKeypoint.position, height, width);
+ const displacement = getDisplacement(sourceKeypointIndices);
+ const displacedPoint = addVectors(sourceKeypoint.position, displacement);
+ let targetKeypoint = displacedPoint;
+ for (let i = 0; i < offsetRefineStep; i++) {
+ const targetKeypointIndices = getStridedIndexNearPoint(targetKeypoint, height, width);
+ const offsetPoint = getOffsetPoint(targetKeypointIndices.y, targetKeypointIndices.x, targetId, offsets);
+ targetKeypoint = addVectors(
+ { x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride },
+ { x: offsetPoint.x, y: offsetPoint.y }
+ );
+ }
+ const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width);
+ const score = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId);
+ return { position: targetKeypoint, part: partNames[targetId], score };
+}
+function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
+ const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]);
+ const edgesFwd = tuples.map(([, childJointId]) => childJointId);
+ const edgesBwd = tuples.map(([parentJointId]) => parentJointId);
+ const numParts = scores.shape[2];
+ const numEdges = edgesFwd.length;
+ const keypoints = new Array(numParts);
+ const rootPoint = getImageCoords(root.part, outputStride, offsets);
+ keypoints[root.part.id] = {
+ score: root.score,
+ part: partNames[root.part.id],
+ position: rootPoint
+ };
+ for (let edge = numEdges - 1; edge >= 0; --edge) {
+ const sourceId = edgesFwd[edge];
+ const targetId = edgesBwd[edge];
+ if (keypoints[sourceId] && !keypoints[targetId]) {
+ keypoints[targetId] = traverse(edge, keypoints[sourceId], targetId, scores, offsets, displacementsBwd);
+ }
+ }
+ for (let edge = 0; edge < numEdges; ++edge) {
+ const sourceId = edgesBwd[edge];
+ const targetId = edgesFwd[edge];
+ if (keypoints[sourceId] && !keypoints[targetId]) {
+ keypoints[targetId] = traverse(edge, keypoints[sourceId], targetId, scores, offsets, displacementsFwd);
+ }
+ }
+ return keypoints;
+}
+function scoreIsMaximumInLocalWindow(keypointId, score, heatmapY, heatmapX, scores) {
+ const [height, width] = scores.shape;
+ let localMaximum = true;
+ const yStart = Math.max(heatmapY - localMaximumRadius, 0);
+ const yEnd = Math.min(heatmapY + localMaximumRadius + 1, height);
+ for (let yCurrent = yStart; yCurrent < yEnd; ++yCurrent) {
+ const xStart = Math.max(heatmapX - localMaximumRadius, 0);
+ const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width);
+ for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) {
+ if (scores.get(yCurrent, xCurrent, keypointId) > score) {
+ localMaximum = false;
+ break;
+ }
+ }
+ if (!localMaximum)
+ break;
+ }
+ return localMaximum;
+}
+function buildPartWithScoreQueue(minConfidence2, scores) {
+ const [height, width, numKeypoints] = scores.shape;
+ const queue = new MaxHeap(height * width * numKeypoints, ({ score }) => score);
+ for (let heatmapY = 0; heatmapY < height; ++heatmapY) {
+ for (let heatmapX = 0; heatmapX < width; ++heatmapX) {
+ for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) {
+ const score = scores.get(heatmapY, heatmapX, keypointId);
+ if (score < minConfidence2)
+ continue;
+ if (scoreIsMaximumInLocalWindow(keypointId, score, heatmapY, heatmapX, scores))
+ queue.enqueue({ score, part: { heatmapY, heatmapX, id: keypointId } });
+ }
+ }
+ }
+ return queue;
+}
+function withinRadius(poses, { x, y }, keypointId) {
+ return poses.some(({ keypoints }) => {
+ var _a;
+ const correspondingKeypoint = (_a = keypoints[keypointId]) == null ? void 0 : _a.position;
+ if (!correspondingKeypoint)
+ return false;
+ return squaredDistance(y, x, correspondingKeypoint.y, correspondingKeypoint.x) <= squaredNmsRadius;
+ });
+}
+function getInstanceScore(existingPoses, keypoints) {
+ const notOverlappedKeypointScores = keypoints.reduce((result, { position, score }, keypointId) => {
+ if (!withinRadius(existingPoses, position, keypointId))
+ result += score;
+ return result;
+ }, 0);
+ return notOverlappedKeypointScores / keypoints.length;
+}
+function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected, minConfidence2) {
+ const poses = [];
+ const queue = buildPartWithScoreQueue(minConfidence2, scores);
+ while (poses.length < maxDetected && !queue.empty()) {
+ const root = queue.dequeue();
+ const rootImageCoords = getImageCoords(root.part, outputStride, offsets);
+ if (withinRadius(poses, rootImageCoords, root.part.id))
+ continue;
+ let keypoints = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
+ keypoints = keypoints.filter((a) => a.score > minConfidence2);
+ const score = getInstanceScore(poses, keypoints);
+ const box = getBoundingBox(keypoints);
+ if (score > minConfidence2)
+ poses.push({ keypoints, box, score: Math.round(100 * score) / 100 });
+ }
+ return poses;
+}
+async function predict19(input, config3) {
+ if (!(model20 == null ? void 0 : model20["executor"]))
+ return [];
+ const res = tfjs_esm_exports.tidy(() => {
+ if (!model20.inputs[0].shape)
+ return [];
+ const resized = tfjs_esm_exports.image.resizeBilinear(input, [model20.inputs[0].shape[2], model20.inputs[0].shape[1]]);
+ const normalized = tfjs_esm_exports.sub(tfjs_esm_exports.div(tfjs_esm_exports.cast(resized, "float32"), 127.5), 1);
+ const results = model20.execute(normalized, poseNetOutputs);
+ const results3d = results.map((y) => tfjs_esm_exports.squeeze(y, [0]));
+ results3d[1] = tfjs_esm_exports.sigmoid(results3d[1]);
+ return results3d;
+ });
+ const buffers = await Promise.all(res.map((tensor6) => tensor6.buffer()));
+ for (const t2 of res)
+ tfjs_esm_exports.dispose(t2);
+ const decoded = decode(buffers[0], buffers[1], buffers[2], buffers[3], config3.body.maxDetected, config3.body.minConfidence);
+ if (!model20.inputs[0].shape)
+ return [];
+ const scaled = scalePoses(decoded, [input.shape[1], input.shape[2]], [model20.inputs[0].shape[2], model20.inputs[0].shape[1]]);
+ return scaled;
+}
+async function load19(config3) {
+ if (!model20 || env.initial)
+ model20 = await loadModel(config3.body.modelPath);
+ else if (config3.debug)
+ log("cached model:", model20["modelUrl"]);
+ return model20;
+}
+
+// src/segmentation/rvm.ts
+var model21;
+var outputNodes2 = ["fgr", "pha", "r1o", "r2o", "r3o", "r4o"];
+var t = {};
+var ratio = 0;
+function init3(config3) {
+ tfjs_esm_exports.dispose([t.r1i, t.r2i, t.r3i, t.r4i, t.downsample_ratio]);
+ t.r1i = tfjs_esm_exports.tensor(0);
+ t.r2i = tfjs_esm_exports.tensor(0);
+ t.r3i = tfjs_esm_exports.tensor(0);
+ t.r4i = tfjs_esm_exports.tensor(0);
+ ratio = config3.segmentation.ratio || 0.5;
+ t.downsample_ratio = tfjs_esm_exports.tensor(ratio);
+}
+async function load20(config3) {
+ if (!model21 || env.initial)
+ model21 = await loadModel(config3.segmentation.modelPath);
+ else if (config3.debug)
+ log("cached model:", model21["modelUrl"]);
+ init3(config3);
+ return model21;
+}
+var normalize = (r) => tfjs_esm_exports.tidy(() => {
+ const squeeze14 = tfjs_esm_exports.squeeze(r, [0]);
+ const mul15 = tfjs_esm_exports.mul(squeeze14, constants.tf255);
+ const cast8 = tfjs_esm_exports.cast(mul15, "int32");
+ return cast8;
+});
+function getRGBA(fgr, pha) {
+ const rgb2 = fgr ? normalize(fgr) : tfjs_esm_exports.fill([pha.shape[1] || 0, pha.shape[2] || 0, 3], 255, "int32");
+ const a = pha ? normalize(pha) : tfjs_esm_exports.fill([fgr.shape[1] || 0, fgr.shape[2] || 0, 1], 255, "int32");
+ const rgba = tfjs_esm_exports.concat([rgb2, a], -1);
+ tfjs_esm_exports.dispose([rgb2, a]);
+ return rgba;
+}
+function getState(state) {
+ return tfjs_esm_exports.tidy(() => {
+ const r = {};
+ r.unstack = tfjs_esm_exports.unstack(state, -1);
+ r.concat = tfjs_esm_exports.concat(r.unstack, 1);
+ r.split = tfjs_esm_exports.split(r.concat, 4, 1);
+ r.stack = tfjs_esm_exports.concat(r.split, 2);
+ r.squeeze = tfjs_esm_exports.squeeze(r.stack, [0]);
+ r.expand = tfjs_esm_exports.expandDims(r.squeeze, -1);
+ r.add = tfjs_esm_exports.add(r.expand, 1);
+ r.mul = tfjs_esm_exports.mul(r.add, 127.5);
+ r.cast = tfjs_esm_exports.cast(r.mul, "int32");
+ r.tile = tfjs_esm_exports.tile(r.cast, [1, 1, 3]);
+ r.alpha = tfjs_esm_exports.fill([r.tile.shape[0] || 0, r.tile.shape[1] || 0, 1], 255, "int32");
+ return tfjs_esm_exports.concat([r.tile, r.alpha], -1);
+ });
+}
+async function predict20(input, config3) {
+ if (!model21)
+ model21 = await load20(config3);
+ if (!(model21 == null ? void 0 : model21["executor"]))
+ return null;
+ t.src = tfjs_esm_exports.div(input, 255);
+ if (ratio !== config3.segmentation.ratio)
+ init3(config3);
+ const [fgr, pha, r1o, r2o, r3o, r4o] = await model21.executeAsync(t, outputNodes2);
+ let rgba;
+ switch (config3.segmentation.mode || "default") {
+ case "default":
+ rgba = getRGBA(fgr, pha);
+ break;
+ case "alpha":
+ rgba = getRGBA(null, pha);
+ break;
+ case "foreground":
+ rgba = getRGBA(fgr, null);
+ break;
+ case "state":
+ rgba = getState(r1o);
+ break;
+ default:
+ rgba = tfjs_esm_exports.tensor(0);
+ }
+ tfjs_esm_exports.dispose([t.src, fgr, pha, t.r1i, t.r2i, t.r3i, t.r4i]);
+ [t.r1i, t.r2i, t.r3i, t.r4i] = [r1o, r2o, r3o, r4o];
+ return rgba;
+}
+
+// src/segmentation/selfie.ts
+var model22;
+async function load21(config3) {
+ if (!model22 || env.initial)
+ model22 = await loadModel(config3.segmentation.modelPath);
+ else if (config3.debug)
+ log("cached model:", model22["modelUrl"]);
+ return model22;
+}
+async function predict21(input, config3) {
+ var _a;
+ if (!model22)
+ model22 = await load21(config3);
+ if (!(model22 == null ? void 0 : model22["executor"]) || !((_a = model22 == null ? void 0 : model22.inputs) == null ? void 0 : _a[0].shape))
+ return null;
+ const t2 = {};
+ t2.resize = tfjs_esm_exports.image.resizeBilinear(input, [model22.inputs[0].shape ? model22.inputs[0].shape[1] : 0, model22.inputs[0].shape ? model22.inputs[0].shape[2] : 0], false);
+ t2.norm = tfjs_esm_exports.div(t2.resize, constants.tf255);
+ t2.res = model22.execute(t2.norm);
+ t2.squeeze = tfjs_esm_exports.squeeze(t2.res, [0]);
+ t2.alpha = tfjs_esm_exports.image.resizeBilinear(t2.squeeze, [input.shape[1] || 0, input.shape[2] || 0]);
+ t2.mul = tfjs_esm_exports.mul(t2.alpha, constants.tf255);
+ let rgba;
+ switch (config3.segmentation.mode || "default") {
+ case "default":
+ t2.input = tfjs_esm_exports.squeeze(input);
+ t2.concat = tfjs_esm_exports.concat([t2.input, t2.mul], -1);
+ rgba = tfjs_esm_exports.cast(t2.concat, "int32");
+ break;
+ case "alpha":
+ rgba = tfjs_esm_exports.cast(t2.mul, "int32");
+ break;
+ default:
+ rgba = tfjs_esm_exports.tensor(0);
+ }
+ Object.keys(t2).forEach((tensor6) => tfjs_esm_exports.dispose(t2[tensor6]));
+ return rgba;
+}
+
+// src/models.ts
+function validateModel(instance, model23, name) {
+ var _a, _b;
+ if (!model23)
+ return null;
+ if (!((_a = instance == null ? void 0 : instance.config) == null ? void 0 : _a.validateModels))
+ return null;
+ const simpleOps = ["const", "placeholder", "noop", "pad", "squeeze", "add", "sub", "mul", "div"];
+ const ignoreOps = ["biasadd", "fusedbatchnormv3", "matmul", "switch", "shape", "merge", "split", "broadcastto"];
+ const ops = [];
+ const missing = [];
+ const url = model23["modelUrl"];
+ const executor = model23["executor"];
+ if ((_b = executor == null ? void 0 : executor.graph) == null ? void 0 : _b.nodes) {
+ for (const kernel of Object.values(executor.graph.nodes)) {
+ const op = kernel.op.toLowerCase();
+ if (!ops.includes(op))
+ ops.push(op);
+ }
+ } else {
+ if (!executor && instance.config.debug) {
+ log("model not loaded", name);
+ }
+ }
+ for (const op of ops) {
+ if (!simpleOps.includes(op) && !ignoreOps.includes(op) && !instance.env.kernels.includes(op) && !instance.env.kernels.includes(op.replace("_", "")) && !instance.env.kernels.includes(op.replace("native", "")) && !instance.env.kernels.includes(op.replace("v2", ""))) {
+ missing.push(op);
+ }
+ }
+ if (instance.config.debug && missing.length > 0)
+ log("model validation failed:", name, missing);
+ return missing.length > 0 ? { name, missing, ops, url } : null;
+}
+var Models = class {
+ constructor(currentInstance) {
+ __publicField(this, "instance");
+ __publicField(this, "models", {});
+ this.models = {};
+ this.instance = currentInstance;
+ }
+ stats() {
+ let totalSizeFromManifest = 0;
+ let totalSizeWeights = 0;
+ let totalSizeLoading = 0;
+ for (const m of Object.values(modelStats)) {
+ totalSizeFromManifest += m.sizeFromManifest;
+ totalSizeWeights += m.sizeLoadedWeights;
+ totalSizeLoading += m.sizeDesired;
+ }
+ const percentageLoaded = totalSizeLoading > 0 ? totalSizeWeights / totalSizeLoading : 0;
+ return {
+ numLoadedModels: Object.values(modelStats).length,
+ numDefinedModels: Object.keys(this.models).length,
+ percentageLoaded,
+ totalSizeFromManifest,
+ totalSizeWeights,
+ totalSizeLoading,
+ modelStats: Object.values(modelStats)
+ };
+ }
+ reset() {
+ for (const model23 of Object.keys(this.models))
+ this.models[model23] = null;
+ }
+ async load(instance) {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
+ if (env.initial)
+ this.reset();
+ if (instance)
+ this.instance = instance;
+ const m = {};
+ m.blazeface = this.instance.config.face.enabled && !this.models.blazeface ? load3(this.instance.config) : null;
+ m.antispoof = this.instance.config.face.enabled && ((_a = this.instance.config.face.antispoof) == null ? void 0 : _a.enabled) && !this.models.antispoof ? load8(this.instance.config) : null;
+ m.liveness = this.instance.config.face.enabled && ((_b = this.instance.config.face.liveness) == null ? void 0 : _b.enabled) && !this.models.liveness ? load9(this.instance.config) : null;
+ m.faceres = this.instance.config.face.enabled && ((_c = this.instance.config.face.description) == null ? void 0 : _c.enabled) && !this.models.faceres ? load7(this.instance.config) : null;
+ m.emotion = this.instance.config.face.enabled && ((_d = this.instance.config.face.emotion) == null ? void 0 : _d.enabled) && !this.models.emotion ? load6(this.instance.config) : null;
+ m.iris = this.instance.config.face.enabled && ((_e = this.instance.config.face.iris) == null ? void 0 : _e.enabled) && !((_f = this.instance.config.face.attention) == null ? void 0 : _f.enabled) && !this.models.iris ? load4(this.instance.config) : null;
+ m.facemesh = this.instance.config.face.enabled && ((_g = this.instance.config.face.mesh) == null ? void 0 : _g.enabled) && !this.models.facemesh ? load5(this.instance.config) : null;
+ m.gear = this.instance.config.face.enabled && ((_h = this.instance.config.face["gear"]) == null ? void 0 : _h.enabled) && !this.models.gear ? load10(this.instance.config) : null;
+ m.ssrnetage = this.instance.config.face.enabled && ((_i = this.instance.config.face["ssrnet"]) == null ? void 0 : _i.enabled) && !this.models.ssrnetage ? load11(this.instance.config) : null;
+ m.ssrnetgender = this.instance.config.face.enabled && ((_j = this.instance.config.face["ssrnet"]) == null ? void 0 : _j.enabled) && !this.models.ssrnetgender ? load12(this.instance.config) : null;
+ m.mobilefacenet = this.instance.config.face.enabled && ((_k = this.instance.config.face["mobilefacenet"]) == null ? void 0 : _k.enabled) && !this.models.mobilefacenet ? load13(this.instance.config) : null;
+ m.insightface = this.instance.config.face.enabled && ((_l = this.instance.config.face["insightface"]) == null ? void 0 : _l.enabled) && !this.models.insightface ? load14(this.instance.config) : null;
+ m.blazepose = this.instance.config.body.enabled && !this.models.blazepose && ((_m = this.instance.config.body.modelPath) == null ? void 0 : _m.includes("blazepose")) ? loadPose(this.instance.config) : null;
+ m.blazeposedetect = this.instance.config.body.enabled && !this.models.blazeposedetect && this.instance.config.body["detector"] && this.instance.config.body["detector"].modelPath ? loadDetect(this.instance.config) : null;
+ m.efficientpose = this.instance.config.body.enabled && !this.models.efficientpose && ((_n = this.instance.config.body.modelPath) == null ? void 0 : _n.includes("efficientpose")) ? load2(this.instance.config) : null;
+ m.movenet = this.instance.config.body.enabled && !this.models.movenet && ((_o = this.instance.config.body.modelPath) == null ? void 0 : _o.includes("movenet")) ? load17(this.instance.config) : null;
+ m.posenet = this.instance.config.body.enabled && !this.models.posenet && ((_p = this.instance.config.body.modelPath) == null ? void 0 : _p.includes("posenet")) ? load19(this.instance.config) : null;
+ m.handtrack = this.instance.config.hand.enabled && !this.models.handtrack && ((_r = (_q = this.instance.config.hand.detector) == null ? void 0 : _q.modelPath) == null ? void 0 : _r.includes("handtrack")) ? loadDetect2(this.instance.config) : null;
+ m.handskeleton = this.instance.config.hand.enabled && this.instance.config.hand.landmarks && !this.models.handskeleton && ((_t = (_s = this.instance.config.hand.detector) == null ? void 0 : _s.modelPath) == null ? void 0 : _t.includes("handtrack")) ? loadSkeleton(this.instance.config) : null;
+ if ((_v = (_u = this.instance.config.hand.detector) == null ? void 0 : _u.modelPath) == null ? void 0 : _v.includes("handdetect"))
+ [m.handpose, m.handskeleton] = !this.models.handpose ? await load15(this.instance.config) : [null, null];
+ m.centernet = this.instance.config.object.enabled && !this.models.centernet && ((_w = this.instance.config.object.modelPath) == null ? void 0 : _w.includes("centernet")) ? load(this.instance.config) : null;
+ m.nanodet = this.instance.config.object.enabled && !this.models.nanodet && ((_x = this.instance.config.object.modelPath) == null ? void 0 : _x.includes("nanodet")) ? load18(this.instance.config) : null;
+ m.selfie = this.instance.config.segmentation.enabled && !this.models.selfie && ((_y = this.instance.config.segmentation.modelPath) == null ? void 0 : _y.includes("selfie")) ? load21(this.instance.config) : null;
+ m.meet = this.instance.config.segmentation.enabled && !this.models.meet && ((_z = this.instance.config.segmentation.modelPath) == null ? void 0 : _z.includes("meet")) ? load16(this.instance.config) : null;
+ m.rvm = this.instance.config.segmentation.enabled && !this.models.rvm && ((_A = this.instance.config.segmentation.modelPath) == null ? void 0 : _A.includes("rvm")) ? load20(this.instance.config) : null;
+ await Promise.all([...Object.values(m)]);
+ for (const model23 of Object.keys(m))
+ this.models[model23] = m[model23] || this.models[model23] || null;
+ }
+ list() {
+ const models3 = Object.keys(this.models).map((model23) => {
+ var _a;
+ return { name: model23, loaded: this.models[model23] !== null, size: 0, url: this.models[model23] ? (_a = this.models[model23]) == null ? void 0 : _a["modelUrl"] : null };
+ });
+ for (const m of models3) {
+ const stats = Object.keys(modelStats).find((s) => s.startsWith(m.name));
+ if (!stats)
+ continue;
+ m.size = modelStats[stats].sizeLoadedWeights;
+ m.url = modelStats[stats].url;
+ }
+ return models3;
+ }
+ loaded() {
+ const list = this.list();
+ const loaded = list.filter((model23) => model23.loaded).map((model23) => model23.name);
+ return loaded;
+ }
+ validate() {
+ const missing = [];
+ for (const defined of Object.keys(this.models)) {
+ const model23 = this.models[defined];
+ if (!model23)
+ continue;
+ const res = validateModel(this.instance, model23, defined);
+ if (res)
+ missing.push(res);
+ }
+ return missing;
+ }
+};
+
+// src/util/persons.ts
+function join2(faces, bodies, hands, gestures, shape) {
+ var _a, _b, _c, _d, _e, _f;
+ let id = 0;
+ const persons = [];
+ for (const face4 of faces) {
+ const person2 = { id: id++, face: face4, body: null, hands: { left: null, right: null }, gestures: [], box: [0, 0, 0, 0] };
+ for (const body4 of bodies) {
+ if (face4.box[0] > body4.box[0] && face4.box[0] < body4.box[0] + body4.box[2] && face4.box[1] + face4.box[3] > body4.box[1] && face4.box[1] + face4.box[3] < body4.box[1] + body4.box[3]) {
+ person2.body = body4;
+ }
+ }
+ if (person2.body) {
+ for (const hand3 of hands) {
+ if (hand3.box[0] + hand3.box[2] > person2.body.box[0] && hand3.box[0] + hand3.box[2] < person2.body.box[0] + person2.body.box[2] && hand3.box[1] + hand3.box[3] > person2.body.box[1] && hand3.box[1] + hand3.box[3] < person2.body.box[1] + person2.body.box[3]) {
+ if (person2.hands)
+ person2.hands.left = hand3;
+ }
+ if (hand3.box[0] < person2.body.box[0] + person2.body.box[2] && hand3.box[0] > person2.body.box[0] && hand3.box[1] + hand3.box[3] > person2.body.box[1] && hand3.box[1] + hand3.box[3] < person2.body.box[1] + person2.body.box[3]) {
+ if (person2.hands)
+ person2.hands.right = hand3;
+ }
+ }
+ }
+ for (const gesture2 of gestures) {
+ if (gesture2["face"] !== void 0 && gesture2["face"] === face4.id)
+ person2.gestures.push(gesture2);
+ else if (gesture2["iris"] !== void 0 && gesture2["iris"] === face4.id)
+ person2.gestures.push(gesture2);
+ else if (gesture2["body"] !== void 0 && gesture2["body"] === ((_a = person2.body) == null ? void 0 : _a.id))
+ person2.gestures.push(gesture2);
+ else if (gesture2["hand"] !== void 0 && gesture2["hand"] === ((_b = person2.hands.left) == null ? void 0 : _b.id))
+ person2.gestures.push(gesture2);
+ else if (gesture2["hand"] !== void 0 && gesture2["hand"] === ((_c = person2.hands.right) == null ? void 0 : _c.id))
+ person2.gestures.push(gesture2);
+ }
+ const x = [];
+ const y = [];
+ const extractXY = (box) => {
+ if (box && box.length === 4) {
+ x.push(box[0], box[0] + box[2]);
+ y.push(box[1], box[1] + box[3]);
+ }
+ };
+ extractXY(person2.face.box);
+ extractXY((_d = person2.body) == null ? void 0 : _d.box);
+ extractXY((_e = person2.hands.left) == null ? void 0 : _e.box);
+ extractXY((_f = person2.hands.right) == null ? void 0 : _f.box);
+ const minX = Math.min(...x);
+ const minY = Math.min(...y);
+ person2.box = [minX, minY, Math.max(...x) - minX, Math.max(...y) - minY];
+ if ((shape == null ? void 0 : shape[1]) && (shape == null ? void 0 : shape[2]))
+ person2.boxRaw = [person2.box[0] / shape[2], person2.box[1] / shape[1], person2.box[2] / shape[2], person2.box[3] / shape[1]];
+ persons.push(person2);
+ }
+ return persons;
+}
+
+// src/sample.ts
+var face3 = `
/9j/4AAQSkZJRgABAQEAYABgAAD/4QBoRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUA
AAABAAAARgEoAAMAAAABAAIAAAExAAIAAAARAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQu
bmV0IDQuMi4xMwAA/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBgXFBYWGh0lHxob
@@ -269,7 +14008,8 @@ PQ4GJ+ashuK0MhWaoWcA0AaOmASMK7jRNPWYBmHyiuepO2x10qfcv6vYxCzYqoGK4HVYVTJrmb5l
c6oaM5TUJ8EgGsG4kLNUHT0M64OaqMMikSRsuKbnFMRLG3zVehOaGNE445NNlnVFpDMu6uie9Vo1
8z5mOAOST2pDK91cNN+5tsrH3PrW54a06KxT7fdrlh/q1Pc+tJ6IUdZGvHPLezMcnBOWbsPap5r3
ylFtbdT1xUWNWzU0/Zbwlgfmx8zGsHWtRHmMqE59aAMyNifvHPc1f0gtPdqkY5JosJHeNci2tktY
-euPnNY+oXWZEVJNrZ9aun8SIq/CzodHuriIokhDIR1ronbKZr0o6o8ipoz//2Q==`,et=`
+euPnNY+oXWZEVJNrZ9aun8SIq/CzodHuriIokhDIR1ronbKZr0o6o8ipoz//2Q==`;
+var body3 = `
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAsICAoIBwsKCQoNDAsNERwSEQ8PESIZGhQcKSQrKigk
JyctMkA3LTA9MCcnOEw5PUNFSElIKzZPVU5GVEBHSEX/2wBDAQwNDREPESESEiFFLicuRUVFRUVF
RUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUX/wAARCASwBLADASIA
@@ -837,4 +14577,559 @@ AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA
BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2
SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
-2Q==`;async function aA(e){let t=(s,A="application/octet-stream")=>fetch(`data:${A};base64,${s}`).then(a=>a.blob()),n,o;switch(e.config.warmup){case"face":n=await t($2);break;case"body":case"full":n=await t(et);break;default:n=null}if(n){let s=await createImageBitmap(n);o=await e.detect(s,e.config),s.close()}return o}async function iA(e){return new Promise(t=>{let n;switch(e.config.warmup){case"face":n="data:image/jpeg;base64,"+$2;break;case"full":case"body":n="data:image/jpeg;base64,"+et;break;default:n=""}let o;if(typeof Image!="undefined")o=new Image;else if(M.Image)o=new M.Image;else return;o.onload=async()=>{let s=I0(o.naturalWidth,o.naturalHeight);if(!s)h("Warmup: Canvas not found"),t(void 0);else{let A=s.getContext("2d");A&&A.drawImage(o,0,0);let a=await e.image(s,!0),i=a.tensor?await e.detect(a.tensor,e.config):void 0;t(i)}},n?o.src=n:t(void 0)})}async function lA(e){let t=s=>Buffer.from(s,"base64"),n;e.config.warmup==="face"?n=t($2):n=t(et);let o;if("node"in r&&r.getBackend()==="tensorflow"){let s=r.node.decodeJpeg(n),A=r.expandDims(s,0);e.tf.dispose(s),o=await e.detect(A,e.config),e.tf.dispose(A)}else e.config.debug&&h("Warmup tfjs-node not loaded");return o}async function cA(e){let t;return typeof createImageBitmap=="function"?t=await aA(e):typeof Image!="undefined"||M.Canvas!==void 0?t=await iA(e):t=await lA(e),t}async function xA(e){var i,c,x,y;if(!r.env().flagRegistry.ENGINE_COMPILE_ONLY)return;let t=r.getBackend(),n=r.backend();if(t!=="webgl"&&t!=="humangl"||!(n!=null&&n.checkCompileCompletion))return;r.env().set("ENGINE_COMPILE_ONLY",!0);let o=r.engine().state.numTensors,s=[];for(let[l,f]of Object.entries(e.models).filter(([d,u])=>d!==null&&u!==null)){let d=(f==null?void 0:f.modelSignature)&&((c=(i=f==null?void 0:f.inputs)==null?void 0:i[0])==null?void 0:c.shape)?[...f.inputs[0].shape]:[1,64,64,3],u=(f==null?void 0:f.modelSignature)&&((y=(x=f==null?void 0:f.inputs)==null?void 0:x[0])==null?void 0:y.dtype)?f.inputs[0].dtype:"float32";for(let g=0;gr.dispose(P)):r.dispose(g)}catch(g){e.config.debug&&h("compile fail model:",l)}r.dispose(m)}let A=await n.checkCompileCompletionAsync();n.getUniformLocations(),e.config.debug&&h("compile pass:",{models:s,kernels:A.length}),r.env().set("ENGINE_COMPILE_ONLY",!1);let a=r.engine().state.numTensors;a-o>0&&h("tensor leak:",a-o)}async function Fn(e,t){await Je(e,!1);let n=T();return e.state="warmup",t&&(e.config=J(e.config,t)),!e.config.warmup||e.config.warmup.length===0||e.config.warmup==="none"?_0():new Promise(async o=>{await e.models.load(),await xA(e);let s=await cA(e),A=T();e.config.debug&&h("warmup",e.config.warmup,Math.round(A-n),"ms"),e.emit("warmup"),o(s)})}var qe,s2,A2,tt,pe,Bn=class{constructor(t){E(this,"version");E(this,"config");E(this,"result");E(this,"state");E(this,"process");E(this,"tf");E(this,"env",M);E(this,"draw",pt);E(this,"match",h5);E(this,"models");E(this,"events");E(this,"faceTriangulation");E(this,"faceUVMap");E(this,"performance");Ne(this,qe,void 0);Ne(this,s2,void 0);Ne(this,A2,void 0);E(this,"analyze",(...t)=>{if(!V0(this,s2))return;let n=this.tf.engine().state.numTensors,o=V0(this,qe);Ye(this,qe,n);let s=n-o;s!==0&&h(...t,s)});Ne(this,tt,t=>{if(!V0(this,A2))return null;if(!t)return"input is not defined";if(this.env.node&&!(t instanceof r.Tensor))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});E(this,"webcam",new y2);E(this,"emit",t=>{var n;(n=this.events)!=null&&n.dispatchEvent&&this.events.dispatchEvent(new Event(t))});Ne(this,pe,{});let n=(Ke.tfjs||r.version_core).replace(/-(.*)/,"");Ie.wasmPath=`https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${n}/dist/`,Ie.modelBasePath=M.browser?"../models/":"file://models/",this.version=it,Object.defineProperty(this,"version",{value:it}),this.config=JSON.parse(JSON.stringify(Ie)),Object.seal(this.config),this.config.cacheModels=typeof indexedDB!="undefined",t&&(this.config=J(this.config,t)),K5(this.config),this.tf=r,this.state="idle",Ye(this,qe,0),Ye(this,s2,!1),Ye(this,A2,!1),this.performance={},this.events=typeof EventTarget!="undefined"?new EventTarget:void 0,this.models=new r2(this),mt(),this.result=_0(),this.process={tensor:null,canvas:null},this.faceTriangulation=H1,this.faceUVMap=G1,_2(this,null,""),this.emit("create"),(this.config.debug||this.env.browser)&&h(`version: ${this.version}`),this.config.debug&&h(`tfjs version: ${this.tf.version["tfjs-core"]}`);let o=JSON.parse(JSON.stringify(this.env));delete o.kernels,delete o.initial,delete o.perfadd,this.config.debug&&h("environment:",o)}reset(){let t=this.config.backend;this.config=JSON.parse(JSON.stringify(Ie)),this.config.backend=t,At(),M.initial=!0}validate(t){let n=ot(Ie,t||this.config);return n.length===0&&(this.config=J(this.config,t)),n}now(){return T()}image(t,n=!1){return c2(t,this.config,n)}async segmentation(t,n){var A,a,i;if(n&&(this.config=J(this.config,n)),!this.config.segmentation.enabled)return null;let o=await c2(t,this.config);if(!o.tensor)return null;let s=null;return(A=this.config.segmentation.modelPath)!=null&&A.includes("rvm")&&(s=await In(o.tensor,this.config)),(a=this.config.segmentation.modelPath)!=null&&a.includes("meet")&&(s=await xn(o.tensor,this.config)),(i=this.config.segmentation.modelPath)!=null&&i.includes("selfie")&&(s=await On(o.tensor,this.config)),r.dispose(o.tensor),s}compare(t,n){return Y5(this.config,t,n)}async init(){await Je(this,!0),await this.tf.ready(),At()}async load(t){this.state="load";let n=T(),o=Object.values(this.models).filter(a=>a).length;t&&(this.config=J(this.config,t)),this.env.initial&&(await Je(this,!1)||h("error: backend check failed"),await r.ready(),this.env.browser&&(this.config.debug&&h("configuration:",this.config),this.config.debug&&h("tf flags:",this.tf.ENV.flags))),await this.models.load(),this.env.initial&&this.config.debug&&h("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),this.env.initial=!1,Object.values(this.models).filter(a=>a).length!==o&&(this.models.validate(),this.emit("load"));let A=Math.trunc(T()-n);A>(this.performance.loadModels||0)&&(this.performance.loadModels=this.env.perfadd?(this.performance.loadModels||0)+A:A)}next(t=this.result){return cn(t,this.config)}async warmup(t){let n=T(),o=await Fn(this,t),s=T();return this.performance.warmup=Math.trunc(s-n),o}async profile(t,n){let o=await this.tf.profile(()=>this.detect(t,n)),s={},A=0;for(let i of o.kernels){let c=Number(i.kernelTimeMs)||0;s[i.name]?s[i.name]+=c:s[i.name]=c,A+=c}let a=[];Object.entries(s).forEach(i=>a.push({kernel:i[0],time:i[1],perc:0}));for(let i of a)i.perc=Math.round(1e3*i.time/A)/1e3,i.time=Math.round(1e3*i.time)/1e3;return a.sort((i,c)=>c.time-i.time),a.length=20,a}async detect(t,n){return this.state="detect",new Promise(async o=>{var g,P,v,p,b,j,k,I,B,q,W,Z,K,R,D,A0,H,a0,n0,C,F;this.state="config";let s;this.config=J(this.config,n),this.state="check";let A=V0(this,tt).call(this,t);A&&(h(A,t),this.emit("error"),o(_0(A)));let a=T();await this.load(),s=T(),this.state="image";let i=await c2(t,this.config);if(this.process=i,this.performance.inputProcess=this.env.perfadd?(this.performance.inputProcess||0)+Math.trunc(T()-s):Math.trunc(T()-s),this.analyze("Get Image:"),!i.tensor){this.config.debug&&h("could not convert input to tensor"),this.emit("error"),o(_0("could not convert input to tensor"));return}this.emit("image"),s=T(),this.config.skipAllowed=await U5(this.config,i.tensor),this.config.filter.autoBrightness=(this.config.filter.autoBrightness||!1)&&this.config.skipAllowed,this.performance.totalFrames||(this.performance.totalFrames=0),this.performance.cachedFrames||(this.performance.cachedFrames=0),this.performance.totalFrames++,this.config.skipAllowed&&this.performance.cachedFrames++,this.performance.cacheCheck=this.env.perfadd?(this.performance.cacheCheck||0)+Math.trunc(T()-s):Math.trunc(T()-s),this.analyze("Check Changed:");let c=[],x=[],y=[],l=[];this.state="detect:face",this.config.async?(c=this.config.face.enabled?o5(this,i.tensor):[],this.performance.face&&delete this.performance.face):(s=T(),c=this.config.face.enabled?await o5(this,i.tensor):[],this.performance.face=this.env.perfadd?(this.performance.face||0)+Math.trunc(T()-s):Math.trunc(T()-s)),this.config.async&&(this.config.body.maxDetected===-1||this.config.hand.maxDetected===-1)&&(c=await c),this.analyze("Start Body:"),this.state="detect:body";let f=this.config.body.maxDetected===-1?J(this.config,{body:{maxDetected:this.config.face.enabled?1*c.length:1}}):this.config;this.config.async?((g=this.config.body.modelPath)!=null&&g.includes("posenet")?x=this.config.body.enabled?E5(i.tensor,f):[]:(P=this.config.body.modelPath)!=null&&P.includes("blazepose")?x=this.config.body.enabled?Tt(i.tensor,f):[]:(v=this.config.body.modelPath)!=null&&v.includes("efficientpose")?x=this.config.body.enabled?Et(i.tensor,f):[]:(p=this.config.body.modelPath)!=null&&p.includes("movenet")&&(x=this.config.body.enabled?T5(i.tensor,f):[]),this.performance.body&&delete this.performance.body):(s=T(),(b=this.config.body.modelPath)!=null&&b.includes("posenet")?x=this.config.body.enabled?await E5(i.tensor,f):[]:(j=this.config.body.modelPath)!=null&&j.includes("blazepose")?x=this.config.body.enabled?await Tt(i.tensor,f):[]:(k=this.config.body.modelPath)!=null&&k.includes("efficientpose")?x=this.config.body.enabled?await Et(i.tensor,f):[]:(I=this.config.body.modelPath)!=null&&I.includes("movenet")&&(x=this.config.body.enabled?await T5(i.tensor,f):[]),this.performance.body=this.env.perfadd?(this.performance.body||0)+Math.trunc(T()-s):Math.trunc(T()-s)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.state="detect:hand";let d=this.config.hand.maxDetected===-1?J(this.config,{hand:{maxDetected:this.config.face.enabled?2*c.length:1}}):this.config;this.config.async?((q=(B=this.config.hand.detector)==null?void 0:B.modelPath)!=null&&q.includes("handdetect")?y=this.config.hand.enabled?i5(i.tensor,d):[]:(Z=(W=this.config.hand.detector)==null?void 0:W.modelPath)!=null&&Z.includes("handtrack")&&(y=this.config.hand.enabled?x5(i.tensor,d):[]),this.performance.hand&&delete this.performance.hand):(s=T(),(R=(K=this.config.hand.detector)==null?void 0:K.modelPath)!=null&&R.includes("handdetect")?y=this.config.hand.enabled?await i5(i.tensor,d):[]:(A0=(D=this.config.hand.detector)==null?void 0:D.modelPath)!=null&&A0.includes("handtrack")&&(y=this.config.hand.enabled?await x5(i.tensor,d):[]),this.performance.hand=this.env.perfadd?(this.performance.hand||0)+Math.trunc(T()-s):Math.trunc(T()-s)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.state="detect:object",this.config.async?((H=this.config.object.modelPath)!=null&&H.includes("nanodet")?l=this.config.object.enabled?R5(i.tensor,this.config):[]:(a0=this.config.object.modelPath)!=null&&a0.includes("centernet")&&(l=this.config.object.enabled?Mt(i.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(s=T(),(n0=this.config.object.modelPath)!=null&&n0.includes("nanodet")?l=this.config.object.enabled?await R5(i.tensor,this.config):[]:(C=this.config.object.modelPath)!=null&&C.includes("centernet")&&(l=this.config.object.enabled?await Mt(i.tensor,this.config):[]),this.performance.object=this.env.perfadd?(this.performance.object||0)+Math.trunc(T()-s):Math.trunc(T()-s)),this.analyze("End Object:"),this.state="detect:await",this.config.async&&([c,x,y,l]=await Promise.all([c,x,y,l])),this.state="detect:gesture";let u=[];this.config.gesture.enabled&&(s=T(),u=[...F3(c),...D3(x),...H3(y),...B3(c)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=this.env.perfadd?(this.performance.gesture||0)+Math.trunc(T()-s):Math.trunc(T()-s)),this.performance.total=this.env.perfadd?(this.performance.total||0)+Math.trunc(T()-a):Math.trunc(T()-a);let m=((F=this.process.tensor)==null?void 0:F.shape)||[0,0,0,0];this.result={face:c,body:x,hand:y,gesture:u,object:l,performance:this.performance,canvas:this.process.canvas,timestamp:Date.now(),error:null,width:m[2],height:m[1],get persons(){return Dn(c,x,y,u,m)}},r.dispose(i.tensor),this.emit("detect"),this.state="idle",o(this.result)})}async sleep(t){return new Promise(n=>{setTimeout(n,t)})}async video(t,n=!0,o=0){n?(V0(this,pe)[t.id]||(this.config.debug&&h("video start",t.id),V0(this,pe)[t.id]=!0),!t.paused&&V0(this,pe)[t.id]&&t.readyState>=2&&await this.detect(t),o>0&&await this.sleep(o),V0(this,pe)[t.id]&&requestAnimationFrame(()=>this.video(t,n,o))):(this.config.debug&&h("video stop",t.id),V0(this,pe)[t.id]=!1)}};qe=new WeakMap,s2=new WeakMap,A2=new WeakMap,tt=new WeakMap,pe=new WeakMap;export{d2 as Env,Bn as Human,Bn as default,Ie as defaults,pt as draw,_0 as empty,M as env,h5 as match,Wn as models};
+2Q==`;
+
+// src/warmup.ts
+async function warmupBitmap(instance) {
+ const b64toBlob = (base64, type = "application/octet-stream") => fetch(`data:${type};base64,${base64}`).then((res2) => res2.blob());
+ let blob;
+ let res;
+ switch (instance.config.warmup) {
+ case "face":
+ blob = await b64toBlob(face3);
+ break;
+ case "body":
+ case "full":
+ blob = await b64toBlob(body3);
+ break;
+ default:
+ blob = null;
+ }
+ if (blob) {
+ const bitmap = await createImageBitmap(blob);
+ res = await instance.detect(bitmap, instance.config);
+ bitmap.close();
+ }
+ return res;
+}
+async function warmupCanvas(instance) {
+ return new Promise((resolve) => {
+ let src;
+ switch (instance.config.warmup) {
+ case "face":
+ src = "data:image/jpeg;base64," + face3;
+ break;
+ case "full":
+ case "body":
+ src = "data:image/jpeg;base64," + body3;
+ break;
+ default:
+ src = "";
+ }
+ let img;
+ if (typeof Image !== "undefined")
+ img = new Image();
+ else if (env.Image)
+ img = new env.Image();
+ else
+ return;
+ img.onload = async () => {
+ const canvas3 = canvas(img.naturalWidth, img.naturalHeight);
+ if (!canvas3) {
+ log("Warmup: Canvas not found");
+ resolve(void 0);
+ } else {
+ const ctx = canvas3.getContext("2d");
+ if (ctx)
+ ctx.drawImage(img, 0, 0);
+ const tensor6 = await instance.image(canvas3, true);
+ const res = tensor6.tensor ? await instance.detect(tensor6.tensor, instance.config) : void 0;
+ resolve(res);
+ }
+ };
+ if (src)
+ img.src = src;
+ else
+ resolve(void 0);
+ });
+}
+async function warmupNode(instance) {
+ const atob = (str) => Buffer.from(str, "base64");
+ let img;
+ if (instance.config.warmup === "face")
+ img = atob(face3);
+ else
+ img = atob(body3);
+ let res;
+ if ("node" in tfjs_esm_exports && tfjs_esm_exports.getBackend() === "tensorflow") {
+ const data = tfjs_esm_exports["node"].decodeJpeg(img);
+ const expanded = tfjs_esm_exports.expandDims(data, 0);
+ instance.tf.dispose(data);
+ res = await instance.detect(expanded, instance.config);
+ instance.tf.dispose(expanded);
+ } else {
+ if (instance.config.debug)
+ log("Warmup tfjs-node not loaded");
+ }
+ return res;
+}
+async function runInference(instance) {
+ let res;
+ if (typeof createImageBitmap === "function")
+ res = await warmupBitmap(instance);
+ else if (typeof Image !== "undefined" || env.Canvas !== void 0)
+ res = await warmupCanvas(instance);
+ else
+ res = await warmupNode(instance);
+ return res;
+}
+async function runCompile(instance) {
+ var _a, _b, _c, _d;
+ if (!tfjs_esm_exports.env().flagRegistry.ENGINE_COMPILE_ONLY)
+ return;
+ const backendType = tfjs_esm_exports.getBackend();
+ const webGLBackend = tfjs_esm_exports.backend();
+ if (backendType !== "webgl" && backendType !== "humangl" || !(webGLBackend == null ? void 0 : webGLBackend["checkCompileCompletion"])) {
+ return;
+ }
+ tfjs_esm_exports.env().set("ENGINE_COMPILE_ONLY", true);
+ const numTensorsStart = tfjs_esm_exports.engine().state.numTensors;
+ const compiledModels = [];
+ for (const [modelName, model23] of Object.entries(instance.models).filter(([key, val]) => key !== null && val !== null)) {
+ const shape = (model23 == null ? void 0 : model23.modelSignature) && ((_b = (_a = model23 == null ? void 0 : model23.inputs) == null ? void 0 : _a[0]) == null ? void 0 : _b.shape) ? [...model23.inputs[0].shape] : [1, 64, 64, 3];
+ const dtype = (model23 == null ? void 0 : model23.modelSignature) && ((_d = (_c = model23 == null ? void 0 : model23.inputs) == null ? void 0 : _c[0]) == null ? void 0 : _d.dtype) ? model23.inputs[0].dtype : "float32";
+ for (let dim = 0; dim < shape.length; dim++) {
+ if (shape[dim] === -1)
+ shape[dim] = dim === 0 ? 1 : 64;
+ }
+ const tensor6 = tfjs_esm_exports.zeros(shape, dtype);
+ try {
+ const res = model23.execute(tensor6);
+ compiledModels.push(modelName);
+ if (Array.isArray(res))
+ res.forEach((t2) => tfjs_esm_exports.dispose(t2));
+ else
+ tfjs_esm_exports.dispose(res);
+ } catch (e) {
+ if (instance.config.debug)
+ log("compile fail model:", modelName);
+ }
+ tfjs_esm_exports.dispose(tensor6);
+ }
+ const kernels = await webGLBackend["checkCompileCompletionAsync"]();
+ webGLBackend["getUniformLocations"]();
+ if (instance.config.debug)
+ log("compile pass:", { models: compiledModels, kernels: kernels.length });
+ tfjs_esm_exports.env().set("ENGINE_COMPILE_ONLY", false);
+ const numTensorsEnd = tfjs_esm_exports.engine().state.numTensors;
+ if (numTensorsEnd - numTensorsStart > 0)
+ log("tensor leak:", numTensorsEnd - numTensorsStart);
+}
+async function warmup(instance, userConfig) {
+ await check(instance, false);
+ const t0 = now();
+ instance.state = "warmup";
+ if (userConfig)
+ instance.config = mergeDeep(instance.config, userConfig);
+ if (!instance.config.warmup || instance.config.warmup.length === 0 || instance.config.warmup === "none") {
+ return empty();
+ }
+ return new Promise(async (resolve) => {
+ await instance.models.load();
+ await runCompile(instance);
+ const res = await runInference(instance);
+ const t1 = now();
+ if (instance.config.debug)
+ log("warmup", instance.config.warmup, Math.round(t1 - t0), "ms");
+ instance.emit("warmup");
+ resolve(res);
+ });
+}
+
+// src/human.ts
+var _numTensors, _analyzeMemoryLeaks, _checkSanity, _sanity, _loops;
+var Human = class {
+ constructor(userConfig) {
+ __publicField(this, "version");
+ __publicField(this, "config");
+ __publicField(this, "result");
+ __publicField(this, "state");
+ __publicField(this, "process");
+ __publicField(this, "tf");
+ __publicField(this, "env", env);
+ __publicField(this, "draw", draw_exports);
+ __publicField(this, "match", match_exports);
+ __publicField(this, "models");
+ __publicField(this, "events");
+ __publicField(this, "faceTriangulation");
+ __publicField(this, "faceUVMap");
+ __publicField(this, "performance");
+ __privateAdd(this, _numTensors, void 0);
+ __privateAdd(this, _analyzeMemoryLeaks, void 0);
+ __privateAdd(this, _checkSanity, void 0);
+ __publicField(this, "analyze", (...msg) => {
+ if (!__privateGet(this, _analyzeMemoryLeaks))
+ return;
+ const currentTensors = this.tf.engine().state.numTensors;
+ const previousTensors = __privateGet(this, _numTensors);
+ __privateSet(this, _numTensors, currentTensors);
+ const leaked = currentTensors - previousTensors;
+ if (leaked !== 0)
+ log(...msg, leaked);
+ });
+ __privateAdd(this, _sanity, (input) => {
+ if (!__privateGet(this, _checkSanity))
+ return null;
+ if (!input)
+ return "input is not defined";
+ if (this.env.node && !(input instanceof tfjs_esm_exports.Tensor))
+ return "input must be a tensor";
+ try {
+ this.tf.getBackend();
+ } catch (e) {
+ return "backend not loaded";
+ }
+ return null;
+ });
+ __publicField(this, "webcam", new WebCam());
+ __publicField(this, "emit", (event) => {
+ var _a;
+ if ((_a = this.events) == null ? void 0 : _a.dispatchEvent)
+ this.events.dispatchEvent(new Event(event));
+ });
+ __privateAdd(this, _loops, {});
+ const tfVersion = (version7.tfjs || tfjs_esm_exports.version_core).replace(/-(.*)/, "");
+ config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tfVersion}/dist/`;
+ config.modelBasePath = env.browser ? "../models/" : "file://models/";
+ this.version = version8;
+ Object.defineProperty(this, "version", { value: version8 });
+ this.config = JSON.parse(JSON.stringify(config));
+ Object.seal(this.config);
+ this.config.cacheModels = typeof indexedDB !== "undefined";
+ if (userConfig)
+ this.config = mergeDeep(this.config, userConfig);
+ setModelLoadOptions(this.config);
+ this.tf = tfjs_esm_exports;
+ this.state = "idle";
+ __privateSet(this, _numTensors, 0);
+ __privateSet(this, _analyzeMemoryLeaks, false);
+ __privateSet(this, _checkSanity, false);
+ this.performance = {};
+ this.events = typeof EventTarget !== "undefined" ? new EventTarget() : void 0;
+ this.models = new Models(this);
+ init2();
+ this.result = empty();
+ this.process = { tensor: null, canvas: null };
+ this.faceTriangulation = triangulation;
+ this.faceUVMap = uvmap;
+ validateModel(this, null, "");
+ this.emit("create");
+ if (this.config.debug || this.env.browser)
+ log(`version: ${this.version}`);
+ if (this.config.debug)
+ log(`tfjs version: ${this.tf.version["tfjs-core"]}`);
+ const envTemp = JSON.parse(JSON.stringify(this.env));
+ delete envTemp.kernels;
+ delete envTemp.initial;
+ delete envTemp.perfadd;
+ if (this.config.debug)
+ log("environment:", envTemp);
+ }
+ reset() {
+ const currentBackend = this.config.backend;
+ this.config = JSON.parse(JSON.stringify(config));
+ this.config.backend = currentBackend;
+ reset();
+ env.initial = true;
+ }
+ validate(userConfig) {
+ const msgs = validate(config, userConfig || this.config);
+ if (msgs.length === 0)
+ this.config = mergeDeep(this.config, userConfig);
+ return msgs;
+ }
+ now() {
+ return now();
+ }
+ image(input, getTensor = false) {
+ return process2(input, this.config, getTensor);
+ }
+ async segmentation(input, userConfig) {
+ var _a, _b, _c;
+ if (userConfig)
+ this.config = mergeDeep(this.config, userConfig);
+ if (!this.config.segmentation.enabled)
+ return null;
+ const processed = await process2(input, this.config);
+ if (!processed.tensor)
+ return null;
+ let tensor6 = null;
+ if ((_a = this.config.segmentation.modelPath) == null ? void 0 : _a.includes("rvm"))
+ tensor6 = await predict20(processed.tensor, this.config);
+ if ((_b = this.config.segmentation.modelPath) == null ? void 0 : _b.includes("meet"))
+ tensor6 = await predict16(processed.tensor, this.config);
+ if ((_c = this.config.segmentation.modelPath) == null ? void 0 : _c.includes("selfie"))
+ tensor6 = await predict21(processed.tensor, this.config);
+ tfjs_esm_exports.dispose(processed.tensor);
+ return tensor6;
+ }
+ compare(firstImageTensor, secondImageTensor) {
+ return compare(this.config, firstImageTensor, secondImageTensor);
+ }
+ async init() {
+ await check(this, true);
+ await this.tf.ready();
+ reset();
+ }
+ async load(userConfig) {
+ this.state = "load";
+ const timeStamp = now();
+ const count2 = Object.values(this.models.models).filter((model23) => model23).length;
+ if (userConfig)
+ this.config = mergeDeep(this.config, userConfig);
+ if (this.env.initial) {
+ if (!await check(this, false))
+ log("error: backend check failed");
+ await tfjs_esm_exports.ready();
+ if (this.env.browser) {
+ if (this.config.debug)
+ log("configuration:", this.config);
+ if (this.config.debug)
+ log("tf flags:", this.tf.ENV.flags);
+ }
+ }
+ await this.models.load(this);
+ if (this.env.initial && this.config.debug)
+ log("tf engine state:", this.tf.engine().state.numBytes, "bytes", this.tf.engine().state.numTensors, "tensors");
+ this.env.initial = false;
+ const loaded = Object.values(this.models.models).filter((model23) => model23).length;
+ if (loaded !== count2) {
+ this.models.validate();
+ this.emit("load");
+ }
+ const current = Math.trunc(now() - timeStamp);
+ if (current > (this.performance.loadModels || 0))
+ this.performance.loadModels = this.env.perfadd ? (this.performance.loadModels || 0) + current : current;
+ }
+ next(result = this.result) {
+ return calc2(result, this.config);
+ }
+ async warmup(userConfig) {
+ const t0 = now();
+ const res = await warmup(this, userConfig);
+ const t1 = now();
+ this.performance.warmup = Math.trunc(t1 - t0);
+ return res;
+ }
+ async profile(input, userConfig) {
+ const profile = await this.tf.profile(() => this.detect(input, userConfig));
+ const kernels = {};
+ let total = 0;
+ for (const kernel of profile.kernels) {
+ const ms = Number(kernel.kernelTimeMs) || 0;
+ if (kernels[kernel.name])
+ kernels[kernel.name] += ms;
+ else
+ kernels[kernel.name] = ms;
+ total += ms;
+ }
+ const kernelArr = [];
+ Object.entries(kernels).forEach((key) => kernelArr.push({ kernel: key[0], time: key[1], perc: 0 }));
+ for (const kernel of kernelArr) {
+ kernel.perc = Math.round(1e3 * kernel.time / total) / 1e3;
+ kernel.time = Math.round(1e3 * kernel.time) / 1e3;
+ }
+ kernelArr.sort((a, b) => b.time - a.time);
+ kernelArr.length = 20;
+ return kernelArr;
+ }
+ async detect(input, userConfig) {
+ this.state = "detect";
+ return new Promise(async (resolve) => {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
+ this.state = "config";
+ let timeStamp;
+ this.config = mergeDeep(this.config, userConfig);
+ this.state = "check";
+ const error = __privateGet(this, _sanity).call(this, input);
+ if (error) {
+ log(error, input);
+ this.emit("error");
+ resolve(empty(error));
+ }
+ const timeStart = now();
+ await this.load();
+ timeStamp = now();
+ this.state = "image";
+ const img = await process2(input, this.config);
+ this.process = img;
+ this.performance.inputProcess = this.env.perfadd ? (this.performance.inputProcess || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ this.analyze("Get Image:");
+ if (!img.tensor) {
+ if (this.config.debug)
+ log("could not convert input to tensor");
+ this.emit("error");
+ resolve(empty("could not convert input to tensor"));
+ return;
+ }
+ this.emit("image");
+ timeStamp = now();
+ this.config.skipAllowed = await skip(this.config, img.tensor);
+ this.config.filter.autoBrightness = (this.config.filter.autoBrightness || false) && this.config.skipAllowed;
+ if (!this.performance.totalFrames)
+ this.performance.totalFrames = 0;
+ if (!this.performance.cachedFrames)
+ this.performance.cachedFrames = 0;
+ this.performance.totalFrames++;
+ if (this.config.skipAllowed)
+ this.performance.cachedFrames++;
+ this.performance.cacheCheck = this.env.perfadd ? (this.performance.cacheCheck || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ this.analyze("Check Changed:");
+ let faceRes = [];
+ let bodyRes = [];
+ let handRes = [];
+ let objectRes = [];
+ this.state = "detect:face";
+ if (this.config.async) {
+ faceRes = this.config.face.enabled ? detectFace(this, img.tensor) : [];
+ if (this.performance.face)
+ delete this.performance.face;
+ } else {
+ timeStamp = now();
+ faceRes = this.config.face.enabled ? await detectFace(this, img.tensor) : [];
+ this.performance.face = this.env.perfadd ? (this.performance.face || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ }
+ if (this.config.async && (this.config.body.maxDetected === -1 || this.config.hand.maxDetected === -1))
+ faceRes = await faceRes;
+ this.analyze("Start Body:");
+ this.state = "detect:body";
+ const bodyConfig = this.config.body.maxDetected === -1 ? mergeDeep(this.config, { body: { maxDetected: this.config.face.enabled ? 1 * faceRes.length : 1 } }) : this.config;
+ if (this.config.async) {
+ if ((_a = this.config.body.modelPath) == null ? void 0 : _a.includes("posenet"))
+ bodyRes = this.config.body.enabled ? predict19(img.tensor, bodyConfig) : [];
+ else if ((_b = this.config.body.modelPath) == null ? void 0 : _b.includes("blazepose"))
+ bodyRes = this.config.body.enabled ? predict(img.tensor, bodyConfig) : [];
+ else if ((_c = this.config.body.modelPath) == null ? void 0 : _c.includes("efficientpose"))
+ bodyRes = this.config.body.enabled ? predict3(img.tensor, bodyConfig) : [];
+ else if ((_d = this.config.body.modelPath) == null ? void 0 : _d.includes("movenet"))
+ bodyRes = this.config.body.enabled ? predict17(img.tensor, bodyConfig) : [];
+ if (this.performance.body)
+ delete this.performance.body;
+ } else {
+ timeStamp = now();
+ if ((_e = this.config.body.modelPath) == null ? void 0 : _e.includes("posenet"))
+ bodyRes = this.config.body.enabled ? await predict19(img.tensor, bodyConfig) : [];
+ else if ((_f = this.config.body.modelPath) == null ? void 0 : _f.includes("blazepose"))
+ bodyRes = this.config.body.enabled ? await predict(img.tensor, bodyConfig) : [];
+ else if ((_g = this.config.body.modelPath) == null ? void 0 : _g.includes("efficientpose"))
+ bodyRes = this.config.body.enabled ? await predict3(img.tensor, bodyConfig) : [];
+ else if ((_h = this.config.body.modelPath) == null ? void 0 : _h.includes("movenet"))
+ bodyRes = this.config.body.enabled ? await predict17(img.tensor, bodyConfig) : [];
+ this.performance.body = this.env.perfadd ? (this.performance.body || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ }
+ this.analyze("End Body:");
+ this.analyze("Start Hand:");
+ this.state = "detect:hand";
+ const handConfig = this.config.hand.maxDetected === -1 ? mergeDeep(this.config, { hand: { maxDetected: this.config.face.enabled ? 2 * faceRes.length : 1 } }) : this.config;
+ if (this.config.async) {
+ if ((_j = (_i = this.config.hand.detector) == null ? void 0 : _i.modelPath) == null ? void 0 : _j.includes("handdetect"))
+ handRes = this.config.hand.enabled ? predict14(img.tensor, handConfig) : [];
+ else if ((_l = (_k = this.config.hand.detector) == null ? void 0 : _k.modelPath) == null ? void 0 : _l.includes("handtrack"))
+ handRes = this.config.hand.enabled ? predict15(img.tensor, handConfig) : [];
+ if (this.performance.hand)
+ delete this.performance.hand;
+ } else {
+ timeStamp = now();
+ if ((_n = (_m = this.config.hand.detector) == null ? void 0 : _m.modelPath) == null ? void 0 : _n.includes("handdetect"))
+ handRes = this.config.hand.enabled ? await predict14(img.tensor, handConfig) : [];
+ else if ((_p = (_o = this.config.hand.detector) == null ? void 0 : _o.modelPath) == null ? void 0 : _p.includes("handtrack"))
+ handRes = this.config.hand.enabled ? await predict15(img.tensor, handConfig) : [];
+ this.performance.hand = this.env.perfadd ? (this.performance.hand || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ }
+ this.analyze("End Hand:");
+ this.analyze("Start Object:");
+ this.state = "detect:object";
+ if (this.config.async) {
+ if ((_q = this.config.object.modelPath) == null ? void 0 : _q.includes("nanodet"))
+ objectRes = this.config.object.enabled ? predict18(img.tensor, this.config) : [];
+ else if ((_r = this.config.object.modelPath) == null ? void 0 : _r.includes("centernet"))
+ objectRes = this.config.object.enabled ? predict2(img.tensor, this.config) : [];
+ if (this.performance.object)
+ delete this.performance.object;
+ } else {
+ timeStamp = now();
+ if ((_s = this.config.object.modelPath) == null ? void 0 : _s.includes("nanodet"))
+ objectRes = this.config.object.enabled ? await predict18(img.tensor, this.config) : [];
+ else if ((_t = this.config.object.modelPath) == null ? void 0 : _t.includes("centernet"))
+ objectRes = this.config.object.enabled ? await predict2(img.tensor, this.config) : [];
+ this.performance.object = this.env.perfadd ? (this.performance.object || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ }
+ this.analyze("End Object:");
+ this.state = "detect:await";
+ if (this.config.async)
+ [faceRes, bodyRes, handRes, objectRes] = await Promise.all([faceRes, bodyRes, handRes, objectRes]);
+ this.state = "detect:gesture";
+ let gestureRes = [];
+ if (this.config.gesture.enabled) {
+ timeStamp = now();
+ gestureRes = [...face2(faceRes), ...body2(bodyRes), ...hand2(handRes), ...iris2(faceRes)];
+ if (!this.config.async)
+ this.performance.gesture = this.env.perfadd ? (this.performance.gesture || 0) + Math.trunc(now() - timeStamp) : Math.trunc(now() - timeStamp);
+ else if (this.performance.gesture)
+ delete this.performance.gesture;
+ }
+ this.performance.total = this.env.perfadd ? (this.performance.total || 0) + Math.trunc(now() - timeStart) : Math.trunc(now() - timeStart);
+ const shape = ((_u = this.process.tensor) == null ? void 0 : _u.shape) || [0, 0, 0, 0];
+ this.result = {
+ face: faceRes,
+ body: bodyRes,
+ hand: handRes,
+ gesture: gestureRes,
+ object: objectRes,
+ performance: this.performance,
+ canvas: this.process.canvas,
+ timestamp: Date.now(),
+ error: null,
+ width: shape[2],
+ height: shape[1],
+ get persons() {
+ return join2(faceRes, bodyRes, handRes, gestureRes, shape);
+ }
+ };
+ tfjs_esm_exports.dispose(img.tensor);
+ this.emit("detect");
+ this.state = "idle";
+ resolve(this.result);
+ });
+ }
+ async sleep(ms) {
+ return new Promise((resolve) => {
+ setTimeout(resolve, ms);
+ });
+ }
+ async video(element, run = true, delay = 0) {
+ if (run) {
+ if (!__privateGet(this, _loops)[element.id]) {
+ if (this.config.debug)
+ log("video start", element.id);
+ __privateGet(this, _loops)[element.id] = true;
+ }
+ if (!element.paused && __privateGet(this, _loops)[element.id] && element.readyState >= 2)
+ await this.detect(element);
+ if (delay > 0)
+ await this.sleep(delay);
+ if (__privateGet(this, _loops)[element.id])
+ requestAnimationFrame(() => this.video(element, run, delay));
+ } else {
+ if (this.config.debug)
+ log("video stop", element.id);
+ __privateGet(this, _loops)[element.id] = false;
+ }
+ }
+};
+_numTensors = new WeakMap();
+_analyzeMemoryLeaks = new WeakMap();
+_checkSanity = new WeakMap();
+_sanity = new WeakMap();
+_loops = new WeakMap();
+export {
+ Env,
+ Human,
+ Human as default,
+ config as defaults,
+ draw_exports as draw,
+ empty,
+ env,
+ match_exports as match,
+ models_exports2 as models
+};
diff --git a/dist/human.esm.js b/dist/human.esm.js
index 463c5b5a..de625a38 100644
--- a/dist/human.esm.js
+++ b/dist/human.esm.js
@@ -6,12 +6,12 @@
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
-var __require = /* @__PURE__ */ ((x6) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x6, {
+var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
-}) : x6)(function(x6) {
+}) : x)(function(x) {
if (typeof require !== "undefined")
return require.apply(this, arguments);
- throw new Error('Dynamic require of "' + x6 + '" is not supported');
+ throw new Error('Dynamic require of "' + x + '" is not supported');
});
var __export = (target, all2) => {
for (var name in all2)
@@ -43,623 +43,623 @@ var __privateSet = (obj, member, value, setter) => {
// dist/tfjs.esm.js
var tfjs_esm_exports = {};
__export(tfjs_esm_exports, {
- Abs: () => sn,
- Acos: () => Li,
- Acosh: () => Bi,
- AdadeltaOptimizer: () => xi,
- AdagradOptimizer: () => yi,
- AdamOptimizer: () => bi,
- AdamaxOptimizer: () => Ci,
- Add: () => _r,
- AddN: () => an,
- All: () => oa,
- Any: () => na,
- ArgMax: () => un,
- ArgMin: () => ja,
- Asin: () => Vi,
- Asinh: () => zi,
- Atan: () => Wi,
- Atan2: () => sa,
- Atanh: () => Ui,
- AvgPool: () => pn,
+ Abs: () => gs,
+ Acos: () => sa,
+ Acosh: () => aa,
+ AdadeltaOptimizer: () => Ei,
+ AdagradOptimizer: () => $i,
+ AdamOptimizer: () => Ai,
+ AdamaxOptimizer: () => Ri,
+ Add: () => eo,
+ AddN: () => Mo,
+ All: () => Lo,
+ Any: () => Bo,
+ ArgMax: () => Vo,
+ ArgMin: () => Za,
+ Asin: () => ia,
+ Asinh: () => ua,
+ Atan: () => pa,
+ Atan2: () => la,
+ Atanh: () => ca,
+ AvgPool: () => zo,
AvgPool3D: () => ip,
- AvgPool3DGrad: () => Fm,
- AvgPoolGrad: () => Am,
- BackendWasm: () => Gl,
- BatchMatMul: () => cn,
- BatchToSpaceND: () => hs,
- Bincount: () => up,
- BroadcastArgs: () => pp,
- BroadcastTo: () => Tne,
- Cast: () => to,
- Ceil: () => ro,
- ClipByValue: () => Ro,
- Complex: () => aa,
- ComplexAbs: () => cp,
- Concat: () => gs,
- Conv2D: () => ln,
- Conv2DBackpropFilter: () => lp,
- Conv2DBackpropInput: () => mn,
- Conv3D: () => mp,
- Conv3DBackpropFilterV2: () => Dm,
- Conv3DBackpropInputV2: () => fp,
- Cos: () => fn,
- Cosh: () => dn,
- CropAndResize: () => xn,
- Cumprod: () => hn,
- Cumsum: () => gn,
- DataStorage: () => rn,
- DenseBincount: () => dp,
- DepthToSpace: () => yn,
- DepthwiseConv2dNative: () => bn,
- DepthwiseConv2dNativeBackpropFilter: () => hp,
- DepthwiseConv2dNativeBackpropInput: () => gp,
- Diag: () => xp,
- Dilation2D: () => yp,
- Dilation2DBackpropFilter: () => vb,
- Dilation2DBackpropInput: () => Sb,
- ENV: () => Cb,
- Einsum: () => Xa,
- Elu: () => In,
- EluGrad: () => Pm,
- Environment: () => Qc,
- Equal: () => oo,
- Erf: () => Gi,
- Exp: () => no,
- ExpandDims: () => xs,
- Expm1: () => wn,
- FFT: () => bp,
- Fill: () => ys,
- FlipLeftRight: () => Sn,
- Floor: () => so,
- FloorDiv: () => vn,
+ AvgPool3DGrad: () => Im,
+ AvgPoolGrad: () => wm,
+ BackendWasm: () => Pl,
+ BatchMatMul: () => Wo,
+ BatchToSpaceND: () => xs,
+ Bincount: () => Ja,
+ BroadcastArgs: () => up,
+ BroadcastTo: () => wne,
+ Cast: () => co,
+ Ceil: () => Uo,
+ ClipByValue: () => lo,
+ Complex: () => ei,
+ ComplexAbs: () => pp,
+ Concat: () => ys,
+ Conv2D: () => Go,
+ Conv2DBackpropFilter: () => cp,
+ Conv2DBackpropInput: () => Ho,
+ Conv3D: () => lp,
+ Conv3DBackpropFilterV2: () => vm,
+ Conv3DBackpropInputV2: () => mp,
+ Cos: () => qo,
+ Cosh: () => Ko,
+ CropAndResize: () => Yo,
+ Cumprod: () => jo,
+ Cumsum: () => Xo,
+ DataStorage: () => Do,
+ DenseBincount: () => ti,
+ DepthToSpace: () => Qo,
+ DepthwiseConv2dNative: () => Zo,
+ DepthwiseConv2dNativeBackpropFilter: () => dp,
+ DepthwiseConv2dNativeBackpropInput: () => fp,
+ Diag: () => hp,
+ Dilation2D: () => gp,
+ Dilation2DBackpropFilter: () => bb,
+ Dilation2DBackpropInput: () => yb,
+ ENV: () => hb,
+ Einsum: () => ri,
+ Elu: () => en,
+ EluGrad: () => km,
+ Environment: () => Uc,
+ Equal: () => tn,
+ Erf: () => ma,
+ Exp: () => rn,
+ ExpandDims: () => bs,
+ Expm1: () => da,
+ FFT: () => oi,
+ Fill: () => Cs,
+ FlipLeftRight: () => on,
+ Floor: () => nn,
+ FloorDiv: () => sn,
FromPixels: () => Zi,
- FusedBatchNorm: () => kn,
- FusedConv2D: () => Do,
- FusedDepthwiseConv2D: () => Po,
+ FusedBatchNorm: () => an,
+ FusedConv2D: () => ho,
+ FusedDepthwiseConv2D: () => go,
GPGPUContext: () => Fu,
- GatherNd: () => Tn,
- GatherV2: () => bs,
- GraphModel: () => bl,
- Greater: () => ao,
- GreaterEqual: () => io,
- IFFT: () => Cp,
- Identity: () => uo,
- Imag: () => Ya,
- IsFinite: () => Hi,
- IsInf: () => qi,
- IsNan: () => ia,
- KernelBackend: () => Jr,
- LRN: () => wp,
- LRNGrad: () => Om,
- LeakyRelu: () => Nn,
- Less: () => po,
- LessEqual: () => co,
- LinSpace: () => Ip,
- Log: () => lo,
- Log1p: () => Ki,
- LogSoftmax: () => Nne,
- LogicalAnd: () => _n,
- LogicalNot: () => En,
- LogicalOr: () => ua,
- LogicalXor: () => g0,
- LowerBound: () => _ne,
- MathBackendCPU: () => Si,
- MathBackendWebGL: () => Ni,
- Max: () => $n,
- MaxPool: () => Rn,
- MaxPool3D: () => Sp,
- MaxPool3DGrad: () => Lm,
- MaxPoolGrad: () => Mm,
- MaxPoolWithArgmax: () => vp,
- Maximum: () => mo,
- Mean: () => An,
- Min: () => Fn,
- Minimum: () => fo,
- MirrorPad: () => Dn,
- Mod: () => ji,
- MomentumOptimizer: () => Ii,
- Multinomial: () => kp,
- Multiply: () => ho,
- Neg: () => Pn,
- NonMaxSuppressionV3: () => On,
- NonMaxSuppressionV4: () => pa,
- NonMaxSuppressionV5: () => Mn,
- NotEqual: () => go,
- OP_SCOPE_SUFFIX: () => Ub,
- OneHot: () => ca,
- OnesLike: () => Cs,
+ GatherNd: () => un,
+ GatherV2: () => Ss,
+ GraphModel: () => ll,
+ Greater: () => pn,
+ GreaterEqual: () => cn,
+ IFFT: () => ni,
+ Identity: () => mo,
+ Imag: () => si,
+ IsFinite: () => fa,
+ IsInf: () => ha,
+ IsNan: () => ln,
+ KernelBackend: () => Zr,
+ LRN: () => yp,
+ LRNGrad: () => Nm,
+ LeakyRelu: () => mn,
+ Less: () => dn,
+ LessEqual: () => fn,
+ LinSpace: () => xp,
+ Log: () => hn,
+ Log1p: () => ga,
+ LogSoftmax: () => Ine,
+ LogicalAnd: () => gn,
+ LogicalNot: () => xn,
+ LogicalOr: () => xa,
+ LogicalXor: () => GI,
+ LowerBound: () => vne,
+ MathBackendCPU: () => Oi,
+ MathBackendWebGL: () => Bi,
+ Max: () => yn,
+ MaxPool: () => Cn,
+ MaxPool3D: () => bp,
+ MaxPool3DGrad: () => _m,
+ MaxPoolGrad: () => Tm,
+ MaxPoolWithArgmax: () => Cp,
+ Maximum: () => bn,
+ Mean: () => Sn,
+ Min: () => wn,
+ Minimum: () => In,
+ MirrorPad: () => vn,
+ Mod: () => ya,
+ MomentumOptimizer: () => Fi,
+ Multinomial: () => Sp,
+ Multiply: () => kn,
+ Neg: () => ws,
+ NonMaxSuppressionV3: () => Tn,
+ NonMaxSuppressionV4: () => ba,
+ NonMaxSuppressionV5: () => _n,
+ NotEqual: () => Nn,
+ OP_SCOPE_SUFFIX: () => Lb,
+ OneHot: () => En,
+ OnesLike: () => Is,
Optimizer: () => wr,
OptimizerConstructors: () => ns,
- Pack: () => Is,
- PadV2: () => Ln,
- Pool: () => Ene,
- Pow: () => Bn,
- Prelu: () => Vn,
- Prod: () => Ao,
- RMSPropOptimizer: () => wi,
- RaggedGather: () => Tp,
- RaggedRange: () => Np,
- RaggedTensorToTensor: () => _p,
- Range: () => ws,
- Rank: () => Fb,
- Real: () => la,
- RealDiv: () => Cn,
- Reciprocal: () => ma,
+ Pack: () => vs,
+ PadV2: () => $n,
+ Pool: () => kne,
+ Pow: () => An,
+ Prelu: () => Rn,
+ Prod: () => Fn,
+ RMSPropOptimizer: () => Di,
+ RaggedGather: () => wp,
+ RaggedRange: () => Ip,
+ RaggedTensorToTensor: () => vp,
+ Range: () => ks,
+ Rank: () => _b,
+ Real: () => ai,
+ RealDiv: () => Jo,
+ Reciprocal: () => Dn,
Reduction: () => Et,
- Relu: () => zn,
- Relu6: () => Gn,
- Reshape: () => Ss,
- ResizeBilinear: () => Un,
- ResizeBilinearGrad: () => Vm,
- ResizeNearestNeighbor: () => Wn,
- ResizeNearestNeighborGrad: () => Bm,
- Reverse: () => fa,
+ Relu: () => On,
+ Relu6: () => Ln,
+ Reshape: () => Ns,
+ ResizeBilinear: () => Mn,
+ ResizeBilinearGrad: () => $m,
+ ResizeNearestNeighbor: () => Pn,
+ ResizeNearestNeighborGrad: () => Em,
+ Reverse: () => Bn,
RotateWithOffset: () => es,
- Round: () => da,
- Rsqrt: () => xo,
- SGDOptimizer: () => Us,
- ScatterNd: () => Hn,
- SearchSorted: () => Ep,
- Select: () => vs,
+ Round: () => Ca,
+ Rsqrt: () => Vn,
+ SGDOptimizer: () => qs,
+ ScatterNd: () => zn,
+ SearchSorted: () => ii,
+ Select: () => Ts,
Selu: () => Xi,
- Sigmoid: () => yo,
+ Sigmoid: () => Un,
Sign: () => Yi,
- Sin: () => Kn,
- Sinh: () => ha,
- Slice: () => qn,
- Softmax: () => Xn,
+ Sin: () => Wn,
+ Sinh: () => Sa,
+ Slice: () => _s,
+ Softmax: () => qn,
Softplus: () => Qi,
- SpaceToBatchND: () => ks,
- SparseFillEmptyRows: () => Qa,
- SparseReshape: () => ga,
- SparseSegmentMean: () => Za,
- SparseSegmentSum: () => Ja,
- SparseToDense: () => ei,
- SplitV: () => Ts,
- Sqrt: () => bo,
- Square: () => ti,
- SquaredDifference: () => Co,
- Step: () => $s,
- StridedSlice: () => Yn,
- StringNGrams: () => Ns,
- StringSplit: () => ri,
- StringToHashBucketFast: () => oi,
- Sub: () => Io,
- Sum: () => jn,
- Tan: () => xa,
+ SpaceToBatchND: () => Es,
+ SparseFillEmptyRows: () => ui,
+ SparseReshape: () => wa,
+ SparseSegmentMean: () => pi,
+ SparseSegmentSum: () => ci,
+ SparseToDense: () => li,
+ SplitV: () => $s,
+ Sqrt: () => Gn,
+ Square: () => mi,
+ SquaredDifference: () => Kn,
+ Step: () => Ds,
+ StridedSlice: () => jn,
+ StringNGrams: () => As,
+ StringSplit: () => di,
+ StringToHashBucketFast: () => fi,
+ Sub: () => Xn,
+ Sum: () => Hn,
+ Tan: () => Yn,
Tanh: () => Qn,
- Tensor: () => ut,
- TensorBuffer: () => je,
- Tile: () => wo,
+ Tensor: () => it,
+ TensorBuffer: () => st,
+ Tile: () => to,
TopK: () => Zn,
Transform: () => Jn,
- Transpose: () => Mr,
- Unique: () => $p,
- Unpack: () => _s,
- UnsortedSegmentSum: () => Rp,
- UpperBound: () => $ne,
- Variable: () => ba,
- WebGPUBackend: () => Ai,
- ZerosLike: () => Es,
- _FusedMatMul: () => Fo,
- abs: () => Qt,
- acos: () => Vv,
- acosh: () => zv,
- add: () => ge,
- addN: () => Wv,
- all: () => Uv,
- any: () => Gv,
- argMax: () => Hv,
- argMin: () => qv,
- asin: () => Kv,
- asinh: () => jv,
- atan: () => Xv,
- atan2: () => Yv,
- atanh: () => Qv,
- avgPool: () => mf,
- avgPool3d: () => ek,
- backend: () => Bie,
- backend_util: () => I,
- basicLSTMCell: () => tk,
- batchNorm: () => li,
- batchNorm2d: () => ok,
- batchNorm3d: () => nk,
- batchNorm4d: () => sk,
- batchToSpaceND: () => ff,
- bincount: () => df,
- booleanMaskAsync: () => _H,
- broadcastArgs: () => ak,
- broadcastTo: () => Ls,
+ Transpose: () => ro,
+ Unique: () => kp,
+ Unpack: () => Rs,
+ UnsortedSegmentSum: () => Np,
+ UpperBound: () => Nne,
+ Variable: () => va,
+ WebGPUBackend: () => Ui,
+ ZerosLike: () => Fs,
+ _FusedMatMul: () => fo,
+ abs: () => Yt,
+ acos: () => f0,
+ acosh: () => h0,
+ add: () => xe,
+ addN: () => g0,
+ all: () => x0,
+ any: () => y0,
+ argMax: () => b0,
+ argMin: () => C0,
+ asin: () => S0,
+ asinh: () => w0,
+ atan: () => I0,
+ atan2: () => v0,
+ atanh: () => k0,
+ avgPool: () => td,
+ avgPool3d: () => _0,
+ backend: () => Oie,
+ backend_util: () => S,
+ basicLSTMCell: () => E0,
+ batchNorm: () => wi,
+ batchNorm2d: () => A0,
+ batchNorm3d: () => R0,
+ batchNorm4d: () => F0,
+ batchToSpaceND: () => rd,
+ bincount: () => od,
+ booleanMaskAsync: () => XG,
+ broadcastArgs: () => D0,
+ broadcastTo: () => Ii,
broadcast_util: () => br,
- browser: () => Sv,
- buffer: () => ne,
- cast: () => qe,
- ceil: () => ik,
- clipByValue: () => uk,
- clone: () => zr,
- complex: () => Er,
+ browser: () => Qv,
+ buffer: () => le,
+ cast: () => Ke,
+ ceil: () => O0,
+ clipByValue: () => P0,
+ clone: () => Br,
+ complex: () => Tr,
concat: () => gt,
- concat1d: () => pk,
- concat2d: () => ck,
- concat3d: () => lk,
- concat4d: () => mk,
- conv1d: () => fk,
- conv2d: () => mi,
- conv2dTranspose: () => dk,
- conv3d: () => hk,
- conv3dTranspose: () => xk,
- copyRegisteredKernels: () => Lne,
- cos: () => yk,
- cosh: () => bk,
- cosineWindow: () => hl,
- cumprod: () => Ck,
- cumsum: () => Ik,
+ concat1d: () => M0,
+ concat2d: () => L0,
+ concat3d: () => B0,
+ concat4d: () => V0,
+ conv1d: () => z0,
+ conv2d: () => vi,
+ conv2dTranspose: () => W0,
+ conv3d: () => U0,
+ conv3dTranspose: () => H0,
+ copyRegisteredKernels: () => Dne,
+ cos: () => q0,
+ cosh: () => K0,
+ cosineWindow: () => il,
+ cumprod: () => j0,
+ cumsum: () => X0,
customGrad: () => Cr,
- denseBincount: () => wk,
- deprecationWarn: () => sC,
- depthToSpace: () => Sk,
- depthwiseConv2d: () => Gp,
- deregisterOp: () => YK,
- device_util: () => ii,
- diag: () => vk,
- dilation2d: () => kk,
- disableDeprecationWarnings: () => _ie,
- dispose: () => Ft,
- disposeVariables: () => Eie,
- div: () => We,
- divNoNan: () => Tk,
- dot: () => Nk,
- dropout: () => BH,
- einsum: () => _k,
- elu: () => xf,
- enableDebugMode: () => Nie,
- enableProdMode: () => Tie,
- enclosingPowerOfTwo: () => wC,
+ denseBincount: () => Y0,
+ deprecationWarn: () => eC,
+ depthToSpace: () => Q0,
+ depthwiseConv2d: () => Bp,
+ deregisterOp: () => xK,
+ device_util: () => yi,
+ diag: () => Z0,
+ dilation2d: () => J0,
+ disableDeprecationWarnings: () => vie,
+ dispose: () => Dt,
+ disposeVariables: () => kie,
+ div: () => Ge,
+ divNoNan: () => ek,
+ dot: () => tk,
+ dropout: () => aH,
+ einsum: () => rk,
+ elu: () => ad,
+ enableDebugMode: () => Iie,
+ enableProdMode: () => wie,
+ enclosingPowerOfTwo: () => xC,
engine: () => cr,
- env: () => P,
- equal: () => gf,
- erf: () => Ek,
- euclideanNorm: () => Ak,
- exp: () => Bo,
- expandDims: () => _a,
- expm1: () => Fk,
- eye: () => yf,
- fft: () => qp,
- fill: () => Bs,
- findBackend: () => Mie,
- findBackendFactory: () => Lie,
- floor: () => bf,
- floorDiv: () => cf,
- forceHalfFloat: () => pR,
- fused: () => SC,
- gather: () => Cf,
- gatherND: () => MH,
- gather_util: () => af,
- getBackend: () => Pie,
- getGradient: () => kb,
- getKernel: () => el,
- getKernelsForBackend: () => zm,
- getThreadsCount: () => nte,
- gpgpu_util: () => Sw,
- grad: () => GG,
- grads: () => HG,
+ env: () => O,
+ equal: () => sd,
+ erf: () => ok,
+ euclideanNorm: () => ak,
+ exp: () => Co,
+ expandDims: () => Fa,
+ expm1: () => ik,
+ eye: () => id,
+ fft: () => zp,
+ fill: () => Ws,
+ findBackend: () => Fie,
+ findBackendFactory: () => Die,
+ floor: () => ud,
+ floorDiv: () => Jm,
+ forceHalfFloat: () => L$,
+ fused: () => yC,
+ gather: () => pd,
+ gatherND: () => nH,
+ gather_util: () => Ym,
+ getBackend: () => Aie,
+ getGradient: () => Cb,
+ getKernel: () => qc,
+ getKernelsForBackend: () => Am,
+ getThreadsCount: () => Nee,
+ gpgpu_util: () => yw,
+ grad: () => l4,
+ grads: () => m4,
greater: () => cu,
- greaterEqual: () => If,
+ greaterEqual: () => cd,
ifft: () => hu,
- imag: () => ci,
- image: () => zq,
- inTopKAsync: () => zH,
- io: () => va,
- irfft: () => Gf,
- isFinite: () => Dk,
- isInf: () => Pk,
- isNaN: () => Ok,
- keep: () => So,
- kernel_impls: () => Bt,
- leakyRelu: () => wf,
- less: () => Mk,
- lessEqual: () => Hp,
- linalg: () => Wq,
- linspace: () => Lk,
- loadGraphModel: () => U6,
- loadGraphModelSync: () => G6,
- localResponseNormalization: () => Bk,
- log: () => Ea,
- log1p: () => Sf,
- logSigmoid: () => Vk,
- logSoftmax: () => zk,
- logSumExp: () => Tf,
+ imag: () => Si,
+ image: () => uq,
+ inTopKAsync: () => uH,
+ io: () => Ea,
+ irfft: () => Fd,
+ isFinite: () => uk,
+ isInf: () => pk,
+ isNaN: () => ck,
+ keep: () => _r,
+ kernel_impls: () => Lt,
+ leakyRelu: () => ld,
+ less: () => lk,
+ lessEqual: () => Vp,
+ linalg: () => pq,
+ linspace: () => mk,
+ loadGraphModel: () => l6,
+ loadGraphModelSync: () => m6,
+ localResponseNormalization: () => dk,
+ log: () => Da,
+ log1p: () => md,
+ logSigmoid: () => fk,
+ logSoftmax: () => hk,
+ logSumExp: () => hd,
logicalAnd: () => lu,
- logicalNot: () => Nf,
- logicalOr: () => _f,
- logicalXor: () => Wk,
- losses: () => Uq,
- lowerBound: () => Uk,
+ logicalNot: () => gd,
+ logicalOr: () => xd,
+ logicalXor: () => gk,
+ losses: () => cq,
+ lowerBound: () => xk,
matMul: () => Xe,
- math: () => Cv,
- max: () => Vs,
- maxPool: () => $f,
- maxPool3d: () => Gk,
- maxPoolWithArgmax: () => Hk,
- maximum: () => Rf,
+ math: () => jv,
+ max: () => Us,
+ maxPool: () => bd,
+ maxPool3d: () => yk,
+ maxPoolWithArgmax: () => bk,
+ maximum: () => Cd,
mean: () => mu,
- memory: () => $ie,
- meshgrid: () => qk,
- min: () => fl,
- minimum: () => Af,
- mirrorPad: () => Kk,
- mod: () => jk,
- moments: () => Xk,
- movingAverage: () => $H,
- mul: () => oe,
- multiRNNCell: () => Yk,
- multinomial: () => Qk,
+ memory: () => Nie,
+ meshgrid: () => Ck,
+ min: () => sl,
+ minimum: () => Sd,
+ mirrorPad: () => Sk,
+ mod: () => wk,
+ moments: () => Ik,
+ movingAverage: () => QG,
+ mul: () => ae,
+ multiRNNCell: () => vk,
+ multinomial: () => kk,
neg: () => yr,
- nextFrame: () => kC,
+ nextFrame: () => CC,
norm: () => pu,
- notEqual: () => Ff,
- oneHot: () => pl,
- ones: () => zs,
- onesLike: () => Zk,
- op: () => T,
- outerProduct: () => Jk,
- pad: () => Ws,
- pad1d: () => e1,
- pad2d: () => t1,
- pad3d: () => r1,
- pad4d: () => o1,
- pool: () => n1,
- pow: () => Na,
- prelu: () => Pf,
- print: () => ef,
- prod: () => s1,
- profile: () => Rie,
- raggedGather: () => a1,
- raggedRange: () => i1,
- raggedTensorToTensor: () => u1,
- rand: () => p1,
- randomGamma: () => T1,
- randomNormal: () => Vf,
- randomStandardNormal: () => N1,
- randomUniform: () => zf,
- range: () => di,
- ready: () => Die,
- real: () => ka,
- reciprocal: () => _1,
- registerBackend: () => pi,
- registerGradient: () => Pne,
- registerKernel: () => ya,
- registerOp: () => XK,
- relu: () => hi,
- relu6: () => Wf,
- removeBackend: () => Oie,
+ notEqual: () => wd,
+ oneHot: () => tl,
+ ones: () => Gs,
+ onesLike: () => Nk,
+ op: () => N,
+ outerProduct: () => Tk,
+ pad: () => Hs,
+ pad1d: () => _k,
+ pad2d: () => Ek,
+ pad3d: () => $k,
+ pad4d: () => Ak,
+ pool: () => Rk,
+ pow: () => Ra,
+ prelu: () => vd,
+ print: () => Gm,
+ prod: () => Fk,
+ profile: () => Tie,
+ raggedGather: () => Dk,
+ raggedRange: () => Ok,
+ raggedTensorToTensor: () => Pk,
+ rand: () => Mk,
+ randomGamma: () => e1,
+ randomNormal: () => Ed,
+ randomStandardNormal: () => t1,
+ randomUniform: () => $d,
+ range: () => Ni,
+ ready: () => $ie,
+ real: () => $a,
+ reciprocal: () => r1,
+ registerBackend: () => Ci,
+ registerGradient: () => Ane,
+ registerKernel: () => Ia,
+ registerOp: () => gK,
+ relu: () => Ti,
+ relu6: () => Ad,
+ removeBackend: () => Rie,
reshape: () => z,
- reverse: () => vo,
- reverse1d: () => E1,
- reverse2d: () => $1,
- reverse3d: () => R1,
- reverse4d: () => A1,
- rfft: () => Kp,
- round: () => Uf,
- rsqrt: () => F1,
+ reverse: () => no,
+ reverse1d: () => o1,
+ reverse2d: () => n1,
+ reverse3d: () => s1,
+ reverse4d: () => a1,
+ rfft: () => Wp,
+ round: () => Rd,
+ rsqrt: () => i1,
scalar: () => be,
- scatterND: () => AH,
- scatter_util: () => cl,
- searchSorted: () => dl,
- selu: () => D1,
- separableConv2d: () => P1,
- serialization: () => Pv,
- setBackend: () => Fie,
- setPlatform: () => Vie,
- setThreadsCount: () => ote,
- setWasmPath: () => tte,
- setWasmPaths: () => rte,
- setWebGLContext: () => MI,
- setdiff1dAsync: () => O1,
- shared: () => Ad,
- sigmoid: () => Ms,
- sign: () => M1,
- signal: () => Vq,
- sin: () => L1,
- sinh: () => B1,
- slice: () => Ue,
- slice1d: () => V1,
- slice2d: () => z1,
- slice3d: () => W1,
- slice4d: () => U1,
- slice_util: () => et,
- softmax: () => G1,
- softplus: () => kf,
- spaceToBatchND: () => Df,
- sparse: () => Gq,
- sparseToDense: () => PH,
- spectral: () => Bq,
- split: () => $a,
- sqrt: () => Rr,
- square: () => Zt,
- squaredDifference: () => Hf,
- squeeze: () => jp,
- stack: () => Ir,
- step: () => qf,
- stridedSlice: () => H1,
- string: () => Hq,
- sub: () => ke,
- sum: () => tt,
- sumOutType: () => Ca,
- tan: () => q1,
- tanh: () => ml,
+ scatterND: () => JG,
+ scatter_util: () => rl,
+ searchSorted: () => al,
+ selu: () => u1,
+ separableConv2d: () => p1,
+ serialization: () => p0,
+ setBackend: () => Eie,
+ setPlatform: () => Pie,
+ setThreadsCount: () => kee,
+ setWasmPath: () => Iee,
+ setWasmPaths: () => vee,
+ setWebGLContext: () => RS,
+ setdiff1dAsync: () => c1,
+ shared: () => Qp,
+ sigmoid: () => zs,
+ sign: () => l1,
+ signal: () => iq,
+ sin: () => m1,
+ sinh: () => d1,
+ slice: () => He,
+ slice1d: () => f1,
+ slice2d: () => h1,
+ slice3d: () => g1,
+ slice4d: () => x1,
+ slice_util: () => ut,
+ softmax: () => y1,
+ softplus: () => fd,
+ spaceToBatchND: () => Id,
+ sparse: () => lq,
+ sparseToDense: () => rH,
+ spectral: () => aq,
+ split: () => Oa,
+ sqrt: () => $r,
+ square: () => Qt,
+ squaredDifference: () => Dd,
+ squeeze: () => Up,
+ stack: () => Sr,
+ step: () => Od,
+ stridedSlice: () => b1,
+ string: () => mq,
+ sub: () => Ne,
+ sum: () => et,
+ sumOutType: () => ka,
+ tan: () => C1,
+ tanh: () => nl,
tensor: () => nr,
tensor1d: () => mr,
- tensor2d: () => gi,
- tensor3d: () => sf,
- tensor4d: () => K1,
- tensor5d: () => j1,
- tensor6d: () => X1,
- tensor_util: () => z0,
- test_util: () => Bv,
- tidy: () => Ne,
- tile: () => fi,
- time: () => Aie,
- topk: () => Y1,
- train: () => pMe,
- transpose: () => Wp,
- truncatedNormal: () => Q1,
- unique: () => Z1,
- unregisterGradient: () => Mne,
- unregisterKernel: () => One,
- unsortedSegmentSum: () => J1,
- unstack: () => ko,
- upcastType: () => ct,
- upperBound: () => eT,
- util: () => x,
- valueAndGrad: () => qG,
- valueAndGrads: () => KG,
- variable: () => tT,
- variableGrads: () => dC,
- version: () => Cne,
- version_converter: () => q6,
- version_core: () => YW,
- version_cpu: () => Ij,
- version_wasm: () => ste,
- version_webgl: () => gY,
- webgl: () => R9e,
- webgl_util: () => ic,
- webgpu_util: () => pS,
+ tensor2d: () => _i,
+ tensor3d: () => Xm,
+ tensor4d: () => S1,
+ tensor5d: () => w1,
+ tensor6d: () => I1,
+ tensor_util: () => hv,
+ test_util: () => d0,
+ tidy: () => Ee,
+ tile: () => ki,
+ time: () => _ie,
+ topk: () => v1,
+ train: () => hMe,
+ transpose: () => Mp,
+ truncatedNormal: () => k1,
+ unique: () => N1,
+ unregisterGradient: () => Fne,
+ unregisterKernel: () => Rne,
+ unsortedSegmentSum: () => T1,
+ unstack: () => so,
+ upcastType: () => dt,
+ upperBound: () => _1,
+ util: () => y,
+ valueAndGrad: () => d4,
+ valueAndGrads: () => f4,
+ variable: () => E1,
+ variableGrads: () => pC,
+ version: () => gne,
+ version_converter: () => f6,
+ version_core: () => xW,
+ version_cpu: () => U6,
+ version_wasm: () => Tee,
+ version_webgl: () => L8,
+ webgl: () => L9e,
+ webgl_util: () => oc,
+ webgpu_util: () => nI,
where: () => os,
- whereAsync: () => jf,
- zeros: () => Wr,
- zerosLike: () => Gt
+ whereAsync: () => Md,
+ zeros: () => Vr,
+ zerosLike: () => Ut
});
-var QV = Object.create;
-var fb = Object.defineProperty;
-var ZV = Object.getOwnPropertyDescriptor;
-var JV = Object.getOwnPropertyNames;
-var ez = Object.getPrototypeOf;
-var tz = Object.prototype.hasOwnProperty;
-var Em = ((r) => typeof __require != "undefined" ? __require : typeof Proxy != "undefined" ? new Proxy(r, { get: (e, t10) => (typeof __require != "undefined" ? __require : e)[t10] }) : r)(function(r) {
+var yV = Object.create;
+var ub = Object.defineProperty;
+var bV = Object.getOwnPropertyDescriptor;
+var CV = Object.getOwnPropertyNames;
+var SV = Object.getPrototypeOf;
+var wV = Object.prototype.hasOwnProperty;
+var bm = ((r) => typeof __require != "undefined" ? __require : typeof Proxy != "undefined" ? new Proxy(r, { get: (e, t6) => (typeof __require != "undefined" ? __require : e)[t6] }) : r)(function(r) {
if (typeof __require != "undefined")
return __require.apply(this, arguments);
throw new Error('Dynamic require of "' + r + '" is not supported');
});
-var Kt = (r, e) => () => (e || r((e = { exports: {} }).exports, e), e.exports);
-var Be = (r, e) => {
- for (var t10 in e)
- fb(r, t10, { get: e[t10], enumerable: true });
+var qt = (r, e) => () => (e || r((e = { exports: {} }).exports, e), e.exports);
+var Ue = (r, e) => {
+ for (var t6 in e)
+ ub(r, t6, { get: e[t6], enumerable: true });
};
-var rz = (r, e, t10, o) => {
+var IV = (r, e, t6, o) => {
if (e && typeof e == "object" || typeof e == "function")
- for (let n of JV(e))
- !tz.call(r, n) && n !== t10 && fb(r, n, { get: () => e[n], enumerable: !(o = ZV(e, n)) || o.enumerable });
+ for (let n of CV(e))
+ !wV.call(r, n) && n !== t6 && ub(r, n, { get: () => e[n], enumerable: !(o = bV(e, n)) || o.enumerable });
return r;
};
-var rp = (r, e, t10) => (t10 = r != null ? QV(ez(r)) : {}, rz(e || !r || !r.__esModule ? fb(t10, "default", { value: r, enumerable: true }) : t10, r));
-var _0 = Kt((Vne, N0) => {
- N0.exports = wt;
- var Oo = null;
+var rp = (r, e, t6) => (t6 = r != null ? yV(SV(r)) : {}, IV(e || !r || !r.__esModule ? ub(t6, "default", { value: r, enumerable: true }) : t6, r));
+var rv = qt((Pne, tv) => {
+ tv.exports = It;
+ var xo = null;
try {
- Oo = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports;
+ xo = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports;
} catch (r) {
}
- function wt(r, e, t10) {
- this.low = r | 0, this.high = e | 0, this.unsigned = !!t10;
+ function It(r, e, t6) {
+ this.low = r | 0, this.high = e | 0, this.unsigned = !!t6;
}
- wt.prototype.__isLong__;
- Object.defineProperty(wt.prototype, "__isLong__", { value: true });
- function Br(r) {
+ It.prototype.__isLong__;
+ Object.defineProperty(It.prototype, "__isLong__", { value: true });
+ function Lr(r) {
return (r && r.__isLong__) === true;
}
- wt.isLong = Br;
- var y0 = {}, b0 = {};
+ It.isLong = Lr;
+ var qI = {}, KI = {};
function eu(r, e) {
- var t10, o, n;
- return e ? (r >>>= 0, (n = 0 <= r && r < 256) && (o = b0[r], o) ? o : (t10 = St(r, (r | 0) < 0 ? -1 : 0, true), n && (b0[r] = t10), t10)) : (r |= 0, (n = -128 <= r && r < 128) && (o = y0[r], o) ? o : (t10 = St(r, r < 0 ? -1 : 0, false), n && (y0[r] = t10), t10));
+ var t6, o, n;
+ return e ? (r >>>= 0, (n = 0 <= r && r < 256) && (o = KI[r], o) ? o : (t6 = vt(r, (r | 0) < 0 ? -1 : 0, true), n && (KI[r] = t6), t6)) : (r |= 0, (n = -128 <= r && r < 128) && (o = qI[r], o) ? o : (t6 = vt(r, r < 0 ? -1 : 0, false), n && (qI[r] = t6), t6));
}
- wt.fromInt = eu;
- function Mo(r, e) {
+ It.fromInt = eu;
+ function yo(r, e) {
if (isNaN(r))
- return e ? Ji : Lo;
+ return e ? Ji : bo;
if (e) {
if (r < 0)
return Ji;
- if (r >= S0)
- return T0;
+ if (r >= QI)
+ return ev;
} else {
- if (r <= -I0)
- return Lr;
- if (r + 1 >= I0)
- return k0;
+ if (r <= -XI)
+ return Mr;
+ if (r + 1 >= XI)
+ return JI;
}
- return r < 0 ? Mo(-r, e).neg() : St(r % Dp | 0, r / Dp | 0, e);
+ return r < 0 ? yo(-r, e).neg() : vt(r % Ep | 0, r / Ep | 0, e);
}
- wt.fromNumber = Mo;
- function St(r, e, t10) {
- return new wt(r, e, t10);
+ It.fromNumber = yo;
+ function vt(r, e, t6) {
+ return new It(r, e, t6);
}
- wt.fromBits = St;
- var Wm = Math.pow;
- function _b(r, e, t10) {
+ It.fromBits = vt;
+ var Rm = Math.pow;
+ function Ib(r, e, t6) {
if (r.length === 0)
throw Error("empty string");
if (r === "NaN" || r === "Infinity" || r === "+Infinity" || r === "-Infinity")
- return Lo;
- if (typeof e == "number" ? (t10 = e, e = false) : e = !!e, t10 = t10 || 10, t10 < 2 || 36 < t10)
+ return bo;
+ if (typeof e == "number" ? (t6 = e, e = false) : e = !!e, t6 = t6 || 10, t6 < 2 || 36 < t6)
throw RangeError("radix");
var o;
if ((o = r.indexOf("-")) > 0)
throw Error("interior hyphen");
if (o === 0)
- return _b(r.substring(1), e, t10).neg();
- for (var n = Mo(Wm(t10, 8)), s = Lo, a = 0; a < r.length; a += 8) {
- var i = Math.min(8, r.length - a), p = parseInt(r.substring(a, a + i), t10);
+ return Ib(r.substring(1), e, t6).neg();
+ for (var n = yo(Rm(t6, 8)), s = bo, a = 0; a < r.length; a += 8) {
+ var i = Math.min(8, r.length - a), p = parseInt(r.substring(a, a + i), t6);
if (i < 8) {
- var u = Mo(Wm(t10, i));
- s = s.mul(u).add(Mo(p));
+ var u = yo(Rm(t6, i));
+ s = s.mul(u).add(yo(p));
} else
- s = s.mul(n), s = s.add(Mo(p));
+ s = s.mul(n), s = s.add(yo(p));
}
return s.unsigned = e, s;
}
- wt.fromString = _b;
+ It.fromString = Ib;
function ts(r, e) {
- return typeof r == "number" ? Mo(r, e) : typeof r == "string" ? _b(r, e) : St(r.low, r.high, typeof e == "boolean" ? e : r.unsigned);
+ return typeof r == "number" ? yo(r, e) : typeof r == "string" ? Ib(r, e) : vt(r.low, r.high, typeof e == "boolean" ? e : r.unsigned);
}
- wt.fromValue = ts;
- var C0 = 1 << 16, vz = 1 << 24, Dp = C0 * C0, S0 = Dp * Dp, I0 = S0 / 2, w0 = eu(vz), Lo = eu(0);
- wt.ZERO = Lo;
+ It.fromValue = ts;
+ var jI = 1 << 16, HV = 1 << 24, Ep = jI * jI, QI = Ep * Ep, XI = QI / 2, YI = eu(HV), bo = eu(0);
+ It.ZERO = bo;
var Ji = eu(0, true);
- wt.UZERO = Ji;
- var Fp = eu(1);
- wt.ONE = Fp;
- var v0 = eu(1, true);
- wt.UONE = v0;
- var Nb = eu(-1);
- wt.NEG_ONE = Nb;
- var k0 = St(-1, 2147483647, false);
- wt.MAX_VALUE = k0;
- var T0 = St(-1, -1, true);
- wt.MAX_UNSIGNED_VALUE = T0;
- var Lr = St(0, -2147483648, false);
- wt.MIN_VALUE = Lr;
- var ce = wt.prototype;
- ce.toInt = function() {
+ It.UZERO = Ji;
+ var _p = eu(1);
+ It.ONE = _p;
+ var ZI = eu(1, true);
+ It.UONE = ZI;
+ var wb = eu(-1);
+ It.NEG_ONE = wb;
+ var JI = vt(-1, 2147483647, false);
+ It.MAX_VALUE = JI;
+ var ev = vt(-1, -1, true);
+ It.MAX_UNSIGNED_VALUE = ev;
+ var Mr = vt(0, -2147483648, false);
+ It.MIN_VALUE = Mr;
+ var me = It.prototype;
+ me.toInt = function() {
return this.unsigned ? this.low >>> 0 : this.low;
};
- ce.toNumber = function() {
- return this.unsigned ? (this.high >>> 0) * Dp + (this.low >>> 0) : this.high * Dp + (this.low >>> 0);
+ me.toNumber = function() {
+ return this.unsigned ? (this.high >>> 0) * Ep + (this.low >>> 0) : this.high * Ep + (this.low >>> 0);
};
- ce.toString = function(e) {
+ me.toString = function(e) {
if (e = e || 10, e < 2 || 36 < e)
throw RangeError("radix");
if (this.isZero())
return "0";
if (this.isNegative())
- if (this.eq(Lr)) {
- var t10 = Mo(e), o = this.div(t10), n = o.mul(t10).sub(this);
+ if (this.eq(Mr)) {
+ var t6 = yo(e), o = this.div(t6), n = o.mul(t6).sub(this);
return o.toString(e) + n.toInt().toString(e);
} else
return "-" + this.neg().toString(e);
- for (var s = Mo(Wm(e, 6), this.unsigned), a = this, i = ""; ; ) {
+ for (var s = yo(Rm(e, 6), this.unsigned), a = this, i = ""; ; ) {
var p = a.div(s), u = a.sub(p.mul(s)).toInt() >>> 0, c = u.toString(e);
if (a = p, a.isZero())
return c + i;
@@ -668,228 +668,228 @@ var _0 = Kt((Vne, N0) => {
i = "" + c + i;
}
};
- ce.getHighBits = function() {
+ me.getHighBits = function() {
return this.high;
};
- ce.getHighBitsUnsigned = function() {
+ me.getHighBitsUnsigned = function() {
return this.high >>> 0;
};
- ce.getLowBits = function() {
+ me.getLowBits = function() {
return this.low;
};
- ce.getLowBitsUnsigned = function() {
+ me.getLowBitsUnsigned = function() {
return this.low >>> 0;
};
- ce.getNumBitsAbs = function() {
+ me.getNumBitsAbs = function() {
if (this.isNegative())
- return this.eq(Lr) ? 64 : this.neg().getNumBitsAbs();
- for (var e = this.high != 0 ? this.high : this.low, t10 = 31; t10 > 0 && (e & 1 << t10) == 0; t10--)
+ return this.eq(Mr) ? 64 : this.neg().getNumBitsAbs();
+ for (var e = this.high != 0 ? this.high : this.low, t6 = 31; t6 > 0 && (e & 1 << t6) == 0; t6--)
;
- return this.high != 0 ? t10 + 33 : t10 + 1;
+ return this.high != 0 ? t6 + 33 : t6 + 1;
};
- ce.isZero = function() {
+ me.isZero = function() {
return this.high === 0 && this.low === 0;
};
- ce.eqz = ce.isZero;
- ce.isNegative = function() {
+ me.eqz = me.isZero;
+ me.isNegative = function() {
return !this.unsigned && this.high < 0;
};
- ce.isPositive = function() {
+ me.isPositive = function() {
return this.unsigned || this.high >= 0;
};
- ce.isOdd = function() {
+ me.isOdd = function() {
return (this.low & 1) === 1;
};
- ce.isEven = function() {
+ me.isEven = function() {
return (this.low & 1) === 0;
};
- ce.equals = function(e) {
- return Br(e) || (e = ts(e)), this.unsigned !== e.unsigned && this.high >>> 31 === 1 && e.high >>> 31 === 1 ? false : this.high === e.high && this.low === e.low;
+ me.equals = function(e) {
+ return Lr(e) || (e = ts(e)), this.unsigned !== e.unsigned && this.high >>> 31 === 1 && e.high >>> 31 === 1 ? false : this.high === e.high && this.low === e.low;
};
- ce.eq = ce.equals;
- ce.notEquals = function(e) {
+ me.eq = me.equals;
+ me.notEquals = function(e) {
return !this.eq(e);
};
- ce.neq = ce.notEquals;
- ce.ne = ce.notEquals;
- ce.lessThan = function(e) {
+ me.neq = me.notEquals;
+ me.ne = me.notEquals;
+ me.lessThan = function(e) {
return this.comp(e) < 0;
};
- ce.lt = ce.lessThan;
- ce.lessThanOrEqual = function(e) {
+ me.lt = me.lessThan;
+ me.lessThanOrEqual = function(e) {
return this.comp(e) <= 0;
};
- ce.lte = ce.lessThanOrEqual;
- ce.le = ce.lessThanOrEqual;
- ce.greaterThan = function(e) {
+ me.lte = me.lessThanOrEqual;
+ me.le = me.lessThanOrEqual;
+ me.greaterThan = function(e) {
return this.comp(e) > 0;
};
- ce.gt = ce.greaterThan;
- ce.greaterThanOrEqual = function(e) {
+ me.gt = me.greaterThan;
+ me.greaterThanOrEqual = function(e) {
return this.comp(e) >= 0;
};
- ce.gte = ce.greaterThanOrEqual;
- ce.ge = ce.greaterThanOrEqual;
- ce.compare = function(e) {
- if (Br(e) || (e = ts(e)), this.eq(e))
+ me.gte = me.greaterThanOrEqual;
+ me.ge = me.greaterThanOrEqual;
+ me.compare = function(e) {
+ if (Lr(e) || (e = ts(e)), this.eq(e))
return 0;
- var t10 = this.isNegative(), o = e.isNegative();
- return t10 && !o ? -1 : !t10 && o ? 1 : this.unsigned ? e.high >>> 0 > this.high >>> 0 || e.high === this.high && e.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(e).isNegative() ? -1 : 1;
+ var t6 = this.isNegative(), o = e.isNegative();
+ return t6 && !o ? -1 : !t6 && o ? 1 : this.unsigned ? e.high >>> 0 > this.high >>> 0 || e.high === this.high && e.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(e).isNegative() ? -1 : 1;
};
- ce.comp = ce.compare;
- ce.negate = function() {
- return !this.unsigned && this.eq(Lr) ? Lr : this.not().add(Fp);
+ me.comp = me.compare;
+ me.negate = function() {
+ return !this.unsigned && this.eq(Mr) ? Mr : this.not().add(_p);
};
- ce.neg = ce.negate;
- ce.add = function(e) {
- Br(e) || (e = ts(e));
- var t10 = this.high >>> 16, o = this.high & 65535, n = this.low >>> 16, s = this.low & 65535, a = e.high >>> 16, i = e.high & 65535, p = e.low >>> 16, u = e.low & 65535, c = 0, l = 0, m = 0, f = 0;
- return f += s + u, m += f >>> 16, f &= 65535, m += n + p, l += m >>> 16, m &= 65535, l += o + i, c += l >>> 16, l &= 65535, c += t10 + a, c &= 65535, St(m << 16 | f, c << 16 | l, this.unsigned);
+ me.neg = me.negate;
+ me.add = function(e) {
+ Lr(e) || (e = ts(e));
+ var t6 = this.high >>> 16, o = this.high & 65535, n = this.low >>> 16, s = this.low & 65535, a = e.high >>> 16, i = e.high & 65535, p = e.low >>> 16, u = e.low & 65535, c = 0, l = 0, m = 0, d = 0;
+ return d += s + u, m += d >>> 16, d &= 65535, m += n + p, l += m >>> 16, m &= 65535, l += o + i, c += l >>> 16, l &= 65535, c += t6 + a, c &= 65535, vt(m << 16 | d, c << 16 | l, this.unsigned);
};
- ce.subtract = function(e) {
- return Br(e) || (e = ts(e)), this.add(e.neg());
+ me.subtract = function(e) {
+ return Lr(e) || (e = ts(e)), this.add(e.neg());
};
- ce.sub = ce.subtract;
- ce.multiply = function(e) {
+ me.sub = me.subtract;
+ me.multiply = function(e) {
if (this.isZero())
- return Lo;
- if (Br(e) || (e = ts(e)), Oo) {
- var t10 = Oo.mul(this.low, this.high, e.low, e.high);
- return St(t10, Oo.get_high(), this.unsigned);
+ return bo;
+ if (Lr(e) || (e = ts(e)), xo) {
+ var t6 = xo.mul(this.low, this.high, e.low, e.high);
+ return vt(t6, xo.get_high(), this.unsigned);
}
if (e.isZero())
- return Lo;
- if (this.eq(Lr))
- return e.isOdd() ? Lr : Lo;
- if (e.eq(Lr))
- return this.isOdd() ? Lr : Lo;
+ return bo;
+ if (this.eq(Mr))
+ return e.isOdd() ? Mr : bo;
+ if (e.eq(Mr))
+ return this.isOdd() ? Mr : bo;
if (this.isNegative())
return e.isNegative() ? this.neg().mul(e.neg()) : this.neg().mul(e).neg();
if (e.isNegative())
return this.mul(e.neg()).neg();
- if (this.lt(w0) && e.lt(w0))
- return Mo(this.toNumber() * e.toNumber(), this.unsigned);
- var o = this.high >>> 16, n = this.high & 65535, s = this.low >>> 16, a = this.low & 65535, i = e.high >>> 16, p = e.high & 65535, u = e.low >>> 16, c = e.low & 65535, l = 0, m = 0, f = 0, d = 0;
- return d += a * c, f += d >>> 16, d &= 65535, f += s * c, m += f >>> 16, f &= 65535, f += a * u, m += f >>> 16, f &= 65535, m += n * c, l += m >>> 16, m &= 65535, m += s * u, l += m >>> 16, m &= 65535, m += a * p, l += m >>> 16, m &= 65535, l += o * c + n * u + s * p + a * i, l &= 65535, St(f << 16 | d, l << 16 | m, this.unsigned);
+ if (this.lt(YI) && e.lt(YI))
+ return yo(this.toNumber() * e.toNumber(), this.unsigned);
+ var o = this.high >>> 16, n = this.high & 65535, s = this.low >>> 16, a = this.low & 65535, i = e.high >>> 16, p = e.high & 65535, u = e.low >>> 16, c = e.low & 65535, l = 0, m = 0, d = 0, f = 0;
+ return f += a * c, d += f >>> 16, f &= 65535, d += s * c, m += d >>> 16, d &= 65535, d += a * u, m += d >>> 16, d &= 65535, m += n * c, l += m >>> 16, m &= 65535, m += s * u, l += m >>> 16, m &= 65535, m += a * p, l += m >>> 16, m &= 65535, l += o * c + n * u + s * p + a * i, l &= 65535, vt(d << 16 | f, l << 16 | m, this.unsigned);
};
- ce.mul = ce.multiply;
- ce.divide = function(e) {
- if (Br(e) || (e = ts(e)), e.isZero())
+ me.mul = me.multiply;
+ me.divide = function(e) {
+ if (Lr(e) || (e = ts(e)), e.isZero())
throw Error("division by zero");
- if (Oo) {
+ if (xo) {
if (!this.unsigned && this.high === -2147483648 && e.low === -1 && e.high === -1)
return this;
- var t10 = (this.unsigned ? Oo.div_u : Oo.div_s)(this.low, this.high, e.low, e.high);
- return St(t10, Oo.get_high(), this.unsigned);
+ var t6 = (this.unsigned ? xo.div_u : xo.div_s)(this.low, this.high, e.low, e.high);
+ return vt(t6, xo.get_high(), this.unsigned);
}
if (this.isZero())
- return this.unsigned ? Ji : Lo;
+ return this.unsigned ? Ji : bo;
var o, n, s;
if (this.unsigned) {
if (e.unsigned || (e = e.toUnsigned()), e.gt(this))
return Ji;
if (e.gt(this.shru(1)))
- return v0;
+ return ZI;
s = Ji;
} else {
- if (this.eq(Lr)) {
- if (e.eq(Fp) || e.eq(Nb))
- return Lr;
- if (e.eq(Lr))
- return Fp;
+ if (this.eq(Mr)) {
+ if (e.eq(_p) || e.eq(wb))
+ return Mr;
+ if (e.eq(Mr))
+ return _p;
var a = this.shr(1);
- return o = a.div(e).shl(1), o.eq(Lo) ? e.isNegative() ? Fp : Nb : (n = this.sub(e.mul(o)), s = o.add(n.div(e)), s);
- } else if (e.eq(Lr))
- return this.unsigned ? Ji : Lo;
+ return o = a.div(e).shl(1), o.eq(bo) ? e.isNegative() ? _p : wb : (n = this.sub(e.mul(o)), s = o.add(n.div(e)), s);
+ } else if (e.eq(Mr))
+ return this.unsigned ? Ji : bo;
if (this.isNegative())
return e.isNegative() ? this.neg().div(e.neg()) : this.neg().div(e).neg();
if (e.isNegative())
return this.div(e.neg()).neg();
- s = Lo;
+ s = bo;
}
for (n = this; n.gte(e); ) {
o = Math.max(1, Math.floor(n.toNumber() / e.toNumber()));
- for (var i = Math.ceil(Math.log(o) / Math.LN2), p = i <= 48 ? 1 : Wm(2, i - 48), u = Mo(o), c = u.mul(e); c.isNegative() || c.gt(n); )
- o -= p, u = Mo(o, this.unsigned), c = u.mul(e);
- u.isZero() && (u = Fp), s = s.add(u), n = n.sub(c);
+ for (var i = Math.ceil(Math.log(o) / Math.LN2), p = i <= 48 ? 1 : Rm(2, i - 48), u = yo(o), c = u.mul(e); c.isNegative() || c.gt(n); )
+ o -= p, u = yo(o, this.unsigned), c = u.mul(e);
+ u.isZero() && (u = _p), s = s.add(u), n = n.sub(c);
}
return s;
};
- ce.div = ce.divide;
- ce.modulo = function(e) {
- if (Br(e) || (e = ts(e)), Oo) {
- var t10 = (this.unsigned ? Oo.rem_u : Oo.rem_s)(this.low, this.high, e.low, e.high);
- return St(t10, Oo.get_high(), this.unsigned);
+ me.div = me.divide;
+ me.modulo = function(e) {
+ if (Lr(e) || (e = ts(e)), xo) {
+ var t6 = (this.unsigned ? xo.rem_u : xo.rem_s)(this.low, this.high, e.low, e.high);
+ return vt(t6, xo.get_high(), this.unsigned);
}
return this.sub(this.div(e).mul(e));
};
- ce.mod = ce.modulo;
- ce.rem = ce.modulo;
- ce.not = function() {
- return St(~this.low, ~this.high, this.unsigned);
+ me.mod = me.modulo;
+ me.rem = me.modulo;
+ me.not = function() {
+ return vt(~this.low, ~this.high, this.unsigned);
};
- ce.and = function(e) {
- return Br(e) || (e = ts(e)), St(this.low & e.low, this.high & e.high, this.unsigned);
+ me.and = function(e) {
+ return Lr(e) || (e = ts(e)), vt(this.low & e.low, this.high & e.high, this.unsigned);
};
- ce.or = function(e) {
- return Br(e) || (e = ts(e)), St(this.low | e.low, this.high | e.high, this.unsigned);
+ me.or = function(e) {
+ return Lr(e) || (e = ts(e)), vt(this.low | e.low, this.high | e.high, this.unsigned);
};
- ce.xor = function(e) {
- return Br(e) || (e = ts(e)), St(this.low ^ e.low, this.high ^ e.high, this.unsigned);
+ me.xor = function(e) {
+ return Lr(e) || (e = ts(e)), vt(this.low ^ e.low, this.high ^ e.high, this.unsigned);
};
- ce.shiftLeft = function(e) {
- return Br(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? St(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : St(0, this.low << e - 32, this.unsigned);
+ me.shiftLeft = function(e) {
+ return Lr(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? vt(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : vt(0, this.low << e - 32, this.unsigned);
};
- ce.shl = ce.shiftLeft;
- ce.shiftRight = function(e) {
- return Br(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? St(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : St(this.high >> e - 32, this.high >= 0 ? 0 : -1, this.unsigned);
+ me.shl = me.shiftLeft;
+ me.shiftRight = function(e) {
+ return Lr(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? vt(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : vt(this.high >> e - 32, this.high >= 0 ? 0 : -1, this.unsigned);
};
- ce.shr = ce.shiftRight;
- ce.shiftRightUnsigned = function(e) {
- if (Br(e) && (e = e.toInt()), e &= 63, e === 0)
+ me.shr = me.shiftRight;
+ me.shiftRightUnsigned = function(e) {
+ if (Lr(e) && (e = e.toInt()), e &= 63, e === 0)
return this;
- var t10 = this.high;
+ var t6 = this.high;
if (e < 32) {
var o = this.low;
- return St(o >>> e | t10 << 32 - e, t10 >>> e, this.unsigned);
+ return vt(o >>> e | t6 << 32 - e, t6 >>> e, this.unsigned);
} else
- return e === 32 ? St(t10, 0, this.unsigned) : St(t10 >>> e - 32, 0, this.unsigned);
+ return e === 32 ? vt(t6, 0, this.unsigned) : vt(t6 >>> e - 32, 0, this.unsigned);
};
- ce.shru = ce.shiftRightUnsigned;
- ce.shr_u = ce.shiftRightUnsigned;
- ce.toSigned = function() {
- return this.unsigned ? St(this.low, this.high, false) : this;
+ me.shru = me.shiftRightUnsigned;
+ me.shr_u = me.shiftRightUnsigned;
+ me.toSigned = function() {
+ return this.unsigned ? vt(this.low, this.high, false) : this;
};
- ce.toUnsigned = function() {
- return this.unsigned ? this : St(this.low, this.high, true);
+ me.toUnsigned = function() {
+ return this.unsigned ? this : vt(this.low, this.high, true);
};
- ce.toBytes = function(e) {
+ me.toBytes = function(e) {
return e ? this.toBytesLE() : this.toBytesBE();
};
- ce.toBytesLE = function() {
- var e = this.high, t10 = this.low;
- return [t10 & 255, t10 >>> 8 & 255, t10 >>> 16 & 255, t10 >>> 24, e & 255, e >>> 8 & 255, e >>> 16 & 255, e >>> 24];
+ me.toBytesLE = function() {
+ var e = this.high, t6 = this.low;
+ return [t6 & 255, t6 >>> 8 & 255, t6 >>> 16 & 255, t6 >>> 24, e & 255, e >>> 8 & 255, e >>> 16 & 255, e >>> 24];
};
- ce.toBytesBE = function() {
- var e = this.high, t10 = this.low;
- return [e >>> 24, e >>> 16 & 255, e >>> 8 & 255, e & 255, t10 >>> 24, t10 >>> 16 & 255, t10 >>> 8 & 255, t10 & 255];
+ me.toBytesBE = function() {
+ var e = this.high, t6 = this.low;
+ return [e >>> 24, e >>> 16 & 255, e >>> 8 & 255, e & 255, t6 >>> 24, t6 >>> 16 & 255, t6 >>> 8 & 255, t6 & 255];
};
- wt.fromBytes = function(e, t10, o) {
- return o ? wt.fromBytesLE(e, t10) : wt.fromBytesBE(e, t10);
+ It.fromBytes = function(e, t6, o) {
+ return o ? It.fromBytesLE(e, t6) : It.fromBytesBE(e, t6);
};
- wt.fromBytesLE = function(e, t10) {
- return new wt(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t10);
+ It.fromBytesLE = function(e, t6) {
+ return new It(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t6);
};
- wt.fromBytesBE = function(e, t10) {
- return new wt(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t10);
+ It.fromBytesBE = function(e, t6) {
+ return new It(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t6);
};
});
-var pv = Kt(() => {
+var Mv = qt(() => {
});
-var cv = Kt(() => {
+var Lv = qt(() => {
});
-var l1 = Kt((c1, hC) => {
- (function(r, e, t10) {
+var Bk = qt((Lk, cC) => {
+ (function(r, e, t6) {
function o(i) {
var p = this, u = a();
p.next = function() {
@@ -922,13 +922,13 @@ var l1 = Kt((c1, hC) => {
};
return p;
}
- e && e.exports ? e.exports = s : t10 && t10.amd ? t10(function() {
+ e && e.exports ? e.exports = s : t6 && t6.amd ? t6(function() {
return s;
}) : this.alea = s;
- })(c1, typeof hC == "object" && hC, typeof define == "function" && define);
+ })(Lk, typeof cC == "object" && cC, typeof define == "function" && define);
});
-var f1 = Kt((m1, gC) => {
- (function(r, e, t10) {
+var zk = qt((Vk, lC) => {
+ (function(r, e, t6) {
function o(a) {
var i = this, p = "";
i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.next = function() {
@@ -947,20 +947,20 @@ var f1 = Kt((m1, gC) => {
};
return c.double = function() {
do
- var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, f = (l + m) / (1 << 21);
- while (f === 0);
- return f;
+ var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, d = (l + m) / (1 << 21);
+ while (d === 0);
+ return d;
}, c.int32 = p.next, c.quick = c, u && (typeof u == "object" && n(u, p), c.state = function() {
return n(p, {});
}), c;
}
- e && e.exports ? e.exports = s : t10 && t10.amd ? t10(function() {
+ e && e.exports ? e.exports = s : t6 && t6.amd ? t6(function() {
return s;
}) : this.xor128 = s;
- })(m1, typeof gC == "object" && gC, typeof define == "function" && define);
+ })(Vk, typeof lC == "object" && lC, typeof define == "function" && define);
});
-var h1 = Kt((d1, xC) => {
- (function(r, e, t10) {
+var Uk = qt((Wk, mC) => {
+ (function(r, e, t6) {
function o(a) {
var i = this, p = "";
i.next = function() {
@@ -979,38 +979,38 @@ var h1 = Kt((d1, xC) => {
};
return c.double = function() {
do
- var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, f = (l + m) / (1 << 21);
- while (f === 0);
- return f;
+ var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, d = (l + m) / (1 << 21);
+ while (d === 0);
+ return d;
}, c.int32 = p.next, c.quick = c, u && (typeof u == "object" && n(u, p), c.state = function() {
return n(p, {});
}), c;
}
- e && e.exports ? e.exports = s : t10 && t10.amd ? t10(function() {
+ e && e.exports ? e.exports = s : t6 && t6.amd ? t6(function() {
return s;
}) : this.xorwow = s;
- })(d1, typeof xC == "object" && xC, typeof define == "function" && define);
+ })(Wk, typeof mC == "object" && mC, typeof define == "function" && define);
});
-var x1 = Kt((g1, yC) => {
- (function(r, e, t10) {
+var Hk = qt((Gk, dC) => {
+ (function(r, e, t6) {
function o(a) {
var i = this;
i.next = function() {
- var u = i.x, c = i.i, l, m, f;
+ var u = i.x, c = i.i, l, m, d;
return l = u[c], l ^= l >>> 7, m = l ^ l << 24, l = u[c + 1 & 7], m ^= l ^ l >>> 10, l = u[c + 3 & 7], m ^= l ^ l >>> 3, l = u[c + 4 & 7], m ^= l ^ l << 7, l = u[c + 7 & 7], l = l ^ l << 13, m ^= l ^ l << 9, u[c] = m, i.i = c + 1 & 7, m;
};
function p(u, c) {
- var l, m, f = [];
+ var l, m, d = [];
if (c === (c | 0))
- m = f[0] = c;
+ m = d[0] = c;
else
for (c = "" + c, l = 0; l < c.length; ++l)
- f[l & 7] = f[l & 7] << 15 ^ c.charCodeAt(l) + f[l + 1 & 7] << 13;
- for (; f.length < 8; )
- f.push(0);
- for (l = 0; l < 8 && f[l] === 0; ++l)
+ d[l & 7] = d[l & 7] << 15 ^ c.charCodeAt(l) + d[l + 1 & 7] << 13;
+ for (; d.length < 8; )
+ d.push(0);
+ for (l = 0; l < 8 && d[l] === 0; ++l)
;
- for (l == 8 ? m = f[7] = -1 : m = f[l], u.x = f, u.i = 0, l = 256; l > 0; --l)
+ for (l == 8 ? m = d[7] = -1 : m = d[l], u.x = d, u.i = 0, l = 256; l > 0; --l)
u.next();
}
p(i, a);
@@ -1025,33 +1025,33 @@ var x1 = Kt((g1, yC) => {
};
return c.double = function() {
do
- var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, f = (l + m) / (1 << 21);
- while (f === 0);
- return f;
+ var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, d = (l + m) / (1 << 21);
+ while (d === 0);
+ return d;
}, c.int32 = p.next, c.quick = c, u && (u.x && n(u, p), c.state = function() {
return n(p, {});
}), c;
}
- e && e.exports ? e.exports = s : t10 && t10.amd ? t10(function() {
+ e && e.exports ? e.exports = s : t6 && t6.amd ? t6(function() {
return s;
}) : this.xorshift7 = s;
- })(g1, typeof yC == "object" && yC, typeof define == "function" && define);
+ })(Gk, typeof dC == "object" && dC, typeof define == "function" && define);
});
-var b1 = Kt((y1, bC) => {
- (function(r, e, t10) {
+var Kk = qt((qk, fC) => {
+ (function(r, e, t6) {
function o(a) {
var i = this;
i.next = function() {
- var u = i.w, c = i.X, l = i.i, m, f;
- return i.w = u = u + 1640531527 | 0, f = c[l + 34 & 127], m = c[l = l + 1 & 127], f ^= f << 13, m ^= m << 17, f ^= f >>> 15, m ^= m >>> 12, f = c[l] = f ^ m, i.i = l, f + (u ^ u >>> 16) | 0;
+ var u = i.w, c = i.X, l = i.i, m, d;
+ return i.w = u = u + 1640531527 | 0, d = c[l + 34 & 127], m = c[l = l + 1 & 127], d ^= d << 13, m ^= m << 17, d ^= d >>> 15, m ^= m >>> 12, d = c[l] = d ^ m, i.i = l, d + (u ^ u >>> 16) | 0;
};
function p(u, c) {
- var l, m, f, d, h, g = [], y = 128;
- for (c === (c | 0) ? (m = c, c = null) : (c = c + "\0", m = 0, y = Math.max(y, c.length)), f = 0, d = -32; d < y; ++d)
- c && (m ^= c.charCodeAt((d + 32) % c.length)), d === 0 && (h = m), m ^= m << 10, m ^= m >>> 15, m ^= m << 4, m ^= m >>> 13, d >= 0 && (h = h + 1640531527 | 0, l = g[d & 127] ^= m + h, f = l == 0 ? f + 1 : 0);
- for (f >= 128 && (g[(c && c.length || 0) & 127] = -1), f = 127, d = 4 * 128; d > 0; --d)
- m = g[f + 34 & 127], l = g[f = f + 1 & 127], m ^= m << 13, l ^= l << 17, m ^= m >>> 15, l ^= l >>> 12, g[f] = m ^ l;
- u.w = h, u.X = g, u.i = f;
+ var l, m, d, f, h, g = [], x = 128;
+ for (c === (c | 0) ? (m = c, c = null) : (c = c + "\0", m = 0, x = Math.max(x, c.length)), d = 0, f = -32; f < x; ++f)
+ c && (m ^= c.charCodeAt((f + 32) % c.length)), f === 0 && (h = m), m ^= m << 10, m ^= m >>> 15, m ^= m << 4, m ^= m >>> 13, f >= 0 && (h = h + 1640531527 | 0, l = g[f & 127] ^= m + h, d = l == 0 ? d + 1 : 0);
+ for (d >= 128 && (g[(c && c.length || 0) & 127] = -1), d = 127, f = 4 * 128; f > 0; --f)
+ m = g[d + 34 & 127], l = g[d = d + 1 & 127], m ^= m << 13, l ^= l << 17, m ^= m >>> 15, l ^= l >>> 12, g[d] = m ^ l;
+ u.w = h, u.X = g, u.i = d;
}
p(i, a);
}
@@ -1065,25 +1065,25 @@ var b1 = Kt((y1, bC) => {
};
return c.double = function() {
do
- var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, f = (l + m) / (1 << 21);
- while (f === 0);
- return f;
+ var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, d = (l + m) / (1 << 21);
+ while (d === 0);
+ return d;
}, c.int32 = p.next, c.quick = c, u && (u.X && n(u, p), c.state = function() {
return n(p, {});
}), c;
}
- e && e.exports ? e.exports = s : t10 && t10.amd ? t10(function() {
+ e && e.exports ? e.exports = s : t6 && t6.amd ? t6(function() {
return s;
}) : this.xor4096 = s;
- })(y1, typeof bC == "object" && bC, typeof define == "function" && define);
+ })(qk, typeof fC == "object" && fC, typeof define == "function" && define);
});
-var I1 = Kt((C1, CC) => {
- (function(r, e, t10) {
+var Xk = qt((jk, hC) => {
+ (function(r, e, t6) {
function o(a) {
var i = this, p = "";
i.next = function() {
- var c = i.b, l = i.c, m = i.d, f = i.a;
- return c = c << 25 ^ c >>> 7 ^ l, l = l - m | 0, m = m << 24 ^ m >>> 8 ^ f, f = f - c | 0, i.b = c = c << 20 ^ c >>> 12 ^ l, i.c = l = l - m | 0, i.d = m << 16 ^ l >>> 16 ^ f, i.a = f - c | 0;
+ var c = i.b, l = i.c, m = i.d, d = i.a;
+ return c = c << 25 ^ c >>> 7 ^ l, l = l - m | 0, m = m << 24 ^ m >>> 8 ^ d, d = d - c | 0, i.b = c = c << 20 ^ c >>> 12 ^ l, i.c = l = l - m | 0, i.d = m << 16 ^ l >>> 16 ^ d, i.a = d - c | 0;
}, i.a = 0, i.b = 0, i.c = -1640531527, i.d = 1367130551, a === Math.floor(a) ? (i.a = a / 4294967296 | 0, i.b = a | 0) : p += a;
for (var u = 0; u < p.length + 20; u++)
i.b ^= p.charCodeAt(u) | 0, i.next();
@@ -1097,74 +1097,74 @@ var I1 = Kt((C1, CC) => {
};
return c.double = function() {
do
- var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, f = (l + m) / (1 << 21);
- while (f === 0);
- return f;
+ var l = p.next() >>> 11, m = (p.next() >>> 0) / 4294967296, d = (l + m) / (1 << 21);
+ while (d === 0);
+ return d;
}, c.int32 = p.next, c.quick = c, u && (typeof u == "object" && n(u, p), c.state = function() {
return n(p, {});
}), c;
}
- e && e.exports ? e.exports = s : t10 && t10.amd ? t10(function() {
+ e && e.exports ? e.exports = s : t6 && t6.amd ? t6(function() {
return s;
}) : this.tychei = s;
- })(C1, typeof CC == "object" && CC, typeof define == "function" && define);
+ })(jk, typeof hC == "object" && hC, typeof define == "function" && define);
});
-var w1 = Kt(() => {
+var Yk = qt(() => {
});
-var v1 = Kt((S1, Of) => {
- (function(r, e, t10) {
- var o = 256, n = 6, s = 52, a = "random", i = t10.pow(o, n), p = t10.pow(2, s), u = p * 2, c = o - 1, l;
+var Zk = qt((Qk, kd) => {
+ (function(r, e, t6) {
+ var o = 256, n = 6, s = 52, a = "random", i = t6.pow(o, n), p = t6.pow(2, s), u = p * 2, c = o - 1, l;
function m(C, w, k) {
var _ = [];
w = w == true ? { entropy: true } : w || {};
- var E = g(h(w.entropy ? [C, b(e)] : C == null ? y() : C, 3), _), R = new f(_), A = function() {
- for (var D = R.g(n), O = i, M = 0; D < p; )
- D = (D + M) * o, O *= o, M = R.g(1);
+ var $ = g(h(w.entropy ? [C, b(e)] : C == null ? x() : C, 3), _), A = new d(_), R = function() {
+ for (var D = A.g(n), P = i, M = 0; D < p; )
+ D = (D + M) * o, P *= o, M = A.g(1);
for (; D >= u; )
- D /= 2, O /= 2, M >>>= 1;
- return (D + M) / O;
+ D /= 2, P /= 2, M >>>= 1;
+ return (D + M) / P;
};
- return A.int32 = function() {
- return R.g(4) | 0;
- }, A.quick = function() {
- return R.g(4) / 4294967296;
- }, A.double = A, g(b(R.S), e), (w.pass || k || function(D, O, M, L) {
- return L && (L.S && d(L, R), D.state = function() {
- return d(R, {});
- }), M ? (t10[a] = D, O) : D;
- })(A, E, "global" in w ? w.global : this == t10, w.state);
+ return R.int32 = function() {
+ return A.g(4) | 0;
+ }, R.quick = function() {
+ return A.g(4) / 4294967296;
+ }, R.double = R, g(b(A.S), e), (w.pass || k || function(D, P, M, L) {
+ return L && (L.S && f(L, A), D.state = function() {
+ return f(A, {});
+ }), M ? (t6[a] = D, P) : D;
+ })(R, $, "global" in w ? w.global : this == t6, w.state);
}
- function f(C) {
- var w, k = C.length, _ = this, E = 0, R = _.i = _.j = 0, A = _.S = [];
- for (k || (C = [k++]); E < o; )
- A[E] = E++;
- for (E = 0; E < o; E++)
- A[E] = A[R = c & R + C[E % k] + (w = A[E])], A[R] = w;
+ function d(C) {
+ var w, k = C.length, _ = this, $ = 0, A = _.i = _.j = 0, R = _.S = [];
+ for (k || (C = [k++]); $ < o; )
+ R[$] = $++;
+ for ($ = 0; $ < o; $++)
+ R[$] = R[A = c & A + C[$ % k] + (w = R[$])], R[A] = w;
(_.g = function(D) {
- for (var O, M = 0, L = _.i, W = _.j, V = _.S; D--; )
- O = V[L = c & L + 1], M = M * o + V[c & (V[L] = V[W = c & W + O]) + (V[W] = O)];
+ for (var P, M = 0, L = _.i, W = _.j, V = _.S; D--; )
+ P = V[L = c & L + 1], M = M * o + V[c & (V[L] = V[W = c & W + P]) + (V[W] = P)];
return _.i = L, _.j = W, M;
})(o);
}
- function d(C, w) {
+ function f(C, w) {
return w.i = C.i, w.j = C.j, w.S = C.S.slice(), w;
}
function h(C, w) {
- var k = [], _ = typeof C, E;
+ var k = [], _ = typeof C, $;
if (w && _ == "object")
- for (E in C)
+ for ($ in C)
try {
- k.push(h(C[E], w - 1));
- } catch (R) {
+ k.push(h(C[$], w - 1));
+ } catch (A) {
}
return k.length ? k : _ == "string" ? C : C + "\0";
}
function g(C, w) {
- for (var k = C + "", _, E = 0; E < k.length; )
- w[c & E] = c & (_ ^= w[c & E] * 19) + k.charCodeAt(E++);
+ for (var k = C + "", _, $ = 0; $ < k.length; )
+ w[c & $] = c & (_ ^= w[c & $] * 19) + k.charCodeAt($++);
return b(w);
}
- function y() {
+ function x() {
try {
var C;
return l && (C = l.randomBytes) ? C = C(o) : (C = new Uint8Array(o), (r.crypto || r.msCrypto).getRandomValues(C)), b(C);
@@ -1176,63 +1176,63 @@ var v1 = Kt((S1, Of) => {
function b(C) {
return String.fromCharCode.apply(0, C);
}
- if (g(t10.random(), e), typeof Of == "object" && Of.exports) {
- Of.exports = m;
+ if (g(t6.random(), e), typeof kd == "object" && kd.exports) {
+ kd.exports = m;
try {
- l = w1();
+ l = Yk();
} catch (C) {
}
} else
typeof define == "function" && define.amd ? define(function() {
return m;
- }) : t10["seed" + a] = m;
- })(typeof self != "undefined" ? self : S1, [], Math);
+ }) : t6["seed" + a] = m;
+ })(typeof self != "undefined" ? self : Qk, [], Math);
});
-var IC = Kt((_we, k1) => {
- var F4 = l1(), D4 = f1(), P4 = h1(), O4 = x1(), M4 = b1(), L4 = I1(), fu = v1();
- fu.alea = F4;
- fu.xor128 = D4;
- fu.xorwow = P4;
- fu.xorshift7 = O4;
- fu.xor4096 = M4;
- fu.tychei = L4;
- k1.exports = fu;
+var gC = qt((_we, Jk) => {
+ var eG = Bk(), tG = zk(), rG = Uk(), oG = Hk(), nG = Kk(), sG = Xk(), du = Zk();
+ du.alea = eG;
+ du.xor128 = tG;
+ du.xorwow = rG;
+ du.xorshift7 = oG;
+ du.xor4096 = nG;
+ du.tychei = sG;
+ Jk.exports = du;
});
-var Vl = Kt(() => {
+var Rl = qt(() => {
});
-var Qw = Kt(() => {
+var qw = qt(() => {
});
-var D3 = Kt(() => {
+var l3 = qt(() => {
});
-var P3 = Kt(() => {
+var m3 = qt(() => {
});
-var O3 = Kt(() => {
+var d3 = qt(() => {
});
-var M3 = Kt((Fg, Jw) => {
- var Zw = (() => {
+var f3 = qt((wg, jw) => {
+ var Kw = (() => {
var r = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0;
return typeof __filename != "undefined" && (r = r || __filename), function(e) {
e = e || {};
- function t10() {
- return Q.buffer != De && Tt(Q.buffer), ft;
+ function t6() {
+ return J.buffer != Oe && Nt(J.buffer), mt;
}
function o() {
- return Q.buffer != De && Tt(Q.buffer), at;
+ return J.buffer != Oe && Nt(J.buffer), at;
}
function n() {
- return Q.buffer != De && Tt(Q.buffer), dt;
+ return J.buffer != Oe && Nt(J.buffer), ft;
}
function s() {
- return Q.buffer != De && Tt(Q.buffer), Fr;
+ return J.buffer != Oe && Nt(J.buffer), Fr;
}
function a() {
- return Q.buffer != De && Tt(Q.buffer), Pt;
+ return J.buffer != Oe && Nt(J.buffer), Ot;
}
function i() {
- return Q.buffer != De && Tt(Q.buffer), jr;
+ return J.buffer != Oe && Nt(J.buffer), Kr;
}
function p() {
- return Q.buffer != De && Tt(Q.buffer), er;
+ return J.buffer != Oe && Nt(J.buffer), er;
}
var u = typeof e != "undefined" ? e : {}, c, l;
u.ready = new Promise(function(F, B) {
@@ -1240,422 +1240,422 @@ var M3 = Kt((Fg, Jw) => {
});
var m;
typeof process != "undefined" && process.listeners && (m = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") });
- var f = Object.assign({}, u), d = [], h = "./this.program", g = (F, B) => {
+ var d = Object.assign({}, u), f = [], h = "./this.program", g = (F, B) => {
throw B;
- }, y = typeof window == "object", b = typeof importScripts == "function", C = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", w = u.ENVIRONMENT_IS_PTHREAD || false, k = "";
+ }, x = typeof window == "object", b = typeof importScripts == "function", C = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", w = u.ENVIRONMENT_IS_PTHREAD || false, k = "";
function _(F) {
return u.locateFile ? u.locateFile(F, k) : k + F;
}
- var E, R, A, D;
- function O(F) {
- if (F instanceof Di)
+ var $, A, R, D;
+ function P(F) {
+ if (F instanceof Hi)
return;
q("exiting due to exception: " + F);
}
if (C) {
- b ? k = Vl().dirname(k) + "/" : k = __dirname + "/";
+ b ? k = Rl().dirname(k) + "/" : k = __dirname + "/";
var M, L;
- typeof Em == "function" && (M = Qw(), L = Vl()), E = (B, re) => (B = L.normalize(B), M.readFileSync(B, re ? void 0 : "utf8")), A = (B) => {
- var re = E(B, true);
- return re.buffer || (re = new Uint8Array(re)), re;
- }, R = (B, re, le) => {
+ typeof bm == "function" && (M = qw(), L = Rl()), $ = (B, ne) => (B = L.normalize(B), M.readFileSync(B, ne ? void 0 : "utf8")), R = (B) => {
+ var ne = $(B, true);
+ return ne.buffer || (ne = new Uint8Array(ne)), ne;
+ }, A = (B, ne, fe) => {
B = L.normalize(B), M.readFile(B, function(Te, Ze) {
- Te ? le(Te) : re(Ze.buffer);
+ Te ? fe(Te) : ne(Ze.buffer);
});
- }, process.argv.length > 1 && (h = process.argv[1].replace(/\\/g, "/")), d = process.argv.slice(2), process.on("uncaughtException", function(B) {
- if (!(B instanceof Di))
+ }, process.argv.length > 1 && (h = process.argv[1].replace(/\\/g, "/")), f = process.argv.slice(2), process.on("uncaughtException", function(B) {
+ if (!(B instanceof Hi))
throw B;
}), process.on("unhandledRejection", function(B) {
throw B;
- }), g = (B, re) => {
- if (tn())
- throw process.exitCode = B, re;
- O(re), process.exit(B);
+ }), g = (B, ne) => {
+ if (Fo())
+ throw process.exitCode = B, ne;
+ P(ne), process.exit(B);
}, u.inspect = function() {
return "[Emscripten Module object]";
};
let F;
try {
- F = D3();
+ F = l3();
} catch (B) {
throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'), B;
}
global.Worker = F.Worker;
} else
- (y || b) && (b ? k = self.location.href : typeof document != "undefined" && document.currentScript && (k = document.currentScript.src), typeof r != "undefined" && r && (k = r), k.indexOf("blob:") !== 0 ? k = k.substr(0, k.replace(/[?#].*/, "").lastIndexOf("/") + 1) : k = "", C || (E = (F) => {
+ (x || b) && (b ? k = self.location.href : typeof document != "undefined" && document.currentScript && (k = document.currentScript.src), typeof r != "undefined" && r && (k = r), k.indexOf("blob:") !== 0 ? k = k.substr(0, k.replace(/[?#].*/, "").lastIndexOf("/") + 1) : k = "", C || ($ = (F) => {
var B = new XMLHttpRequest();
return B.open("GET", F, false), B.send(null), B.responseText;
- }, b && (A = (F) => {
+ }, b && (R = (F) => {
var B = new XMLHttpRequest();
return B.open("GET", F, false), B.responseType = "arraybuffer", B.send(null), new Uint8Array(B.response);
- }), R = (F, B, re) => {
- var le = new XMLHttpRequest();
- le.open("GET", F, true), le.responseType = "arraybuffer", le.onload = () => {
- if (le.status == 200 || le.status == 0 && le.response) {
- B(le.response);
+ }), A = (F, B, ne) => {
+ var fe = new XMLHttpRequest();
+ fe.open("GET", F, true), fe.responseType = "arraybuffer", fe.onload = () => {
+ if (fe.status == 200 || fe.status == 0 && fe.response) {
+ B(fe.response);
return;
}
- re();
- }, le.onerror = re, le.send(null);
+ ne();
+ }, fe.onerror = ne, fe.send(null);
}), D = (F) => document.title = F);
- C && typeof performance == "undefined" && (global.performance = P3().performance);
+ C && typeof performance == "undefined" && (global.performance = m3().performance);
var W = console.log.bind(console), V = console.warn.bind(console);
C && (W = (F) => M.writeSync(1, F + `
`), V = (F) => M.writeSync(2, F + `
`));
- var G = u.print || W, q = u.printErr || V;
- Object.assign(u, f), f = null, u.arguments && (d = u.arguments), u.thisProgram && (h = u.thisProgram), u.quit && (g = u.quit);
- var H = 4, j = Atomics.load, Y = Atomics.store, Z = Atomics.compareExchange, ee;
+ var U = u.print || W, q = u.printErr || V;
+ Object.assign(u, d), d = null, u.arguments && (f = u.arguments), u.thisProgram && (h = u.thisProgram), u.quit && (g = u.quit);
+ var H = 4, j = Atomics.load, X = Atomics.store, Z = Atomics.compareExchange, ee;
u.wasmBinary && (ee = u.wasmBinary);
- var X = u.noExitRuntime || true;
+ var Y = u.noExitRuntime || true;
typeof WebAssembly != "object" && Xu("no native wasm support detected");
- var Q, se, ie = false, de;
- function Ie(F, B) {
+ var J, ie, pe = false, he;
+ function we(F, B) {
F || Xu(B);
}
- var Se = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0;
- function Ee(F, B, re) {
- for (var le = B + re, Te = B; F[Te] && !(Te >= le); )
+ var ve = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0;
+ function $e(F, B, ne) {
+ for (var fe = B + ne, Te = B; F[Te] && !(Te >= fe); )
++Te;
- if (Te - B > 16 && F.buffer && Se)
- return Se.decode(F.buffer instanceof SharedArrayBuffer ? F.slice(B, Te) : F.subarray(B, Te));
+ if (Te - B > 16 && F.buffer && ve)
+ return ve.decode(F.buffer instanceof SharedArrayBuffer ? F.slice(B, Te) : F.subarray(B, Te));
for (var Ze = ""; B < Te; ) {
- var $e = F[B++];
- if (!($e & 128)) {
- Ze += String.fromCharCode($e);
+ var Ae = F[B++];
+ if (!(Ae & 128)) {
+ Ze += String.fromCharCode(Ae);
continue;
}
var Pe = F[B++] & 63;
- if (($e & 224) == 192) {
- Ze += String.fromCharCode(($e & 31) << 6 | Pe);
+ if ((Ae & 224) == 192) {
+ Ze += String.fromCharCode((Ae & 31) << 6 | Pe);
continue;
}
- var Wt = F[B++] & 63;
- if (($e & 240) == 224 ? $e = ($e & 15) << 12 | Pe << 6 | Wt : $e = ($e & 7) << 18 | Pe << 12 | Wt << 6 | F[B++] & 63, $e < 65536)
- Ze += String.fromCharCode($e);
+ var zt = F[B++] & 63;
+ if ((Ae & 240) == 224 ? Ae = (Ae & 15) << 12 | Pe << 6 | zt : Ae = (Ae & 7) << 18 | Pe << 12 | zt << 6 | F[B++] & 63, Ae < 65536)
+ Ze += String.fromCharCode(Ae);
else {
- var Zr = $e - 65536;
- Ze += String.fromCharCode(55296 | Zr >> 10, 56320 | Zr & 1023);
+ var Qr = Ae - 65536;
+ Ze += String.fromCharCode(55296 | Qr >> 10, 56320 | Qr & 1023);
}
}
return Ze;
}
- function Me(F, B) {
- return F ? Ee(o(), F, B) : "";
+ function Le(F, B) {
+ return F ? $e(o(), F, B) : "";
}
- function st(F, B, re, le) {
- if (!(le > 0))
+ function nt(F, B, ne, fe) {
+ if (!(fe > 0))
return 0;
- for (var Te = re, Ze = re + le - 1, $e = 0; $e < F.length; ++$e) {
- var Pe = F.charCodeAt($e);
+ for (var Te = ne, Ze = ne + fe - 1, Ae = 0; Ae < F.length; ++Ae) {
+ var Pe = F.charCodeAt(Ae);
if (Pe >= 55296 && Pe <= 57343) {
- var Wt = F.charCodeAt(++$e);
- Pe = 65536 + ((Pe & 1023) << 10) | Wt & 1023;
+ var zt = F.charCodeAt(++Ae);
+ Pe = 65536 + ((Pe & 1023) << 10) | zt & 1023;
}
if (Pe <= 127) {
- if (re >= Ze)
+ if (ne >= Ze)
break;
- B[re++] = Pe;
+ B[ne++] = Pe;
} else if (Pe <= 2047) {
- if (re + 1 >= Ze)
+ if (ne + 1 >= Ze)
break;
- B[re++] = 192 | Pe >> 6, B[re++] = 128 | Pe & 63;
+ B[ne++] = 192 | Pe >> 6, B[ne++] = 128 | Pe & 63;
} else if (Pe <= 65535) {
- if (re + 2 >= Ze)
+ if (ne + 2 >= Ze)
break;
- B[re++] = 224 | Pe >> 12, B[re++] = 128 | Pe >> 6 & 63, B[re++] = 128 | Pe & 63;
+ B[ne++] = 224 | Pe >> 12, B[ne++] = 128 | Pe >> 6 & 63, B[ne++] = 128 | Pe & 63;
} else {
- if (re + 3 >= Ze)
+ if (ne + 3 >= Ze)
break;
- B[re++] = 240 | Pe >> 18, B[re++] = 128 | Pe >> 12 & 63, B[re++] = 128 | Pe >> 6 & 63, B[re++] = 128 | Pe & 63;
+ B[ne++] = 240 | Pe >> 18, B[ne++] = 128 | Pe >> 12 & 63, B[ne++] = 128 | Pe >> 6 & 63, B[ne++] = 128 | Pe & 63;
}
}
- return B[re] = 0, re - Te;
+ return B[ne] = 0, ne - Te;
}
- function pt(F, B, re) {
- return st(F, o(), B, re);
+ function pt(F, B, ne) {
+ return nt(F, o(), B, ne);
}
- var De, ft, at, dt, It, Fr, Pt, jr, er;
- w && (De = u.buffer);
- function Tt(F) {
- De = F, u.HEAP8 = ft = new Int8Array(F), u.HEAP16 = dt = new Int16Array(F), u.HEAP32 = Fr = new Int32Array(F), u.HEAPU8 = at = new Uint8Array(F), u.HEAPU16 = It = new Uint16Array(F), u.HEAPU32 = Pt = new Uint32Array(F), u.HEAPF32 = jr = new Float32Array(F), u.HEAPF64 = er = new Float64Array(F);
+ var Oe, mt, at, ft, wt, Fr, Ot, Kr, er;
+ w && (Oe = u.buffer);
+ function Nt(F) {
+ Oe = F, u.HEAP8 = mt = new Int8Array(F), u.HEAP16 = ft = new Int16Array(F), u.HEAP32 = Fr = new Int32Array(F), u.HEAPU8 = at = new Uint8Array(F), u.HEAPU16 = wt = new Uint16Array(F), u.HEAPU32 = Ot = new Uint32Array(F), u.HEAPF32 = Kr = new Float32Array(F), u.HEAPF64 = er = new Float64Array(F);
}
var tr = u.INITIAL_MEMORY || 16777216;
if (w)
- Q = u.wasmMemory, De = u.buffer;
+ J = u.wasmMemory, Oe = u.buffer;
else if (u.wasmMemory)
- Q = u.wasmMemory;
- else if (Q = new WebAssembly.Memory({ initial: tr / 65536, maximum: 32768, shared: true }), !(Q.buffer instanceof SharedArrayBuffer))
+ J = u.wasmMemory;
+ else if (J = new WebAssembly.Memory({ initial: tr / 65536, maximum: 32768, shared: true }), !(J.buffer instanceof SharedArrayBuffer))
throw q("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"), C && console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"), Error("bad memory");
- Q && (De = Q.buffer), tr = De.byteLength, Tt(De);
- var rr, Xr = [], Yr = [], pr = [], Qs = false;
- function tn() {
- return X;
+ J && (Oe = J.buffer), tr = Oe.byteLength, Nt(Oe);
+ var rr, jr = [], Xr = [], pr = [], Js = false;
+ function Fo() {
+ return Y;
}
- function Ua() {
+ function Ka() {
if (u.preRun)
for (typeof u.preRun == "function" && (u.preRun = [u.preRun]); u.preRun.length; )
- Lc(u.preRun.shift());
- Uc(Xr);
+ Ac(u.preRun.shift());
+ Pc(jr);
}
- function jt() {
- Qs = true, !w && Uc(Yr);
+ function Kt() {
+ Js = true, !w && Pc(Xr);
}
- function Zs() {
+ function ea() {
if (!w) {
if (u.postRun)
for (typeof u.postRun == "function" && (u.postRun = [u.postRun]); u.postRun.length; )
- KS(u.postRun.shift());
- Uc(pr);
+ SI(u.postRun.shift());
+ Pc(pr);
}
}
- function Lc(F) {
+ function Ac(F) {
+ jr.unshift(F);
+ }
+ function Rc(F) {
Xr.unshift(F);
}
- function Bc(F) {
- Yr.unshift(F);
- }
- function KS(F) {
+ function SI(F) {
pr.unshift(F);
}
- var Ga = 0, ju = null, Js = null;
- function jS(F) {
- Ga++, u.monitorRunDependencies && u.monitorRunDependencies(Ga);
+ var ja = 0, ju = null, ta = null;
+ function wI(F) {
+ ja++, u.monitorRunDependencies && u.monitorRunDependencies(ja);
}
- function XS(F) {
- if (Ga--, u.monitorRunDependencies && u.monitorRunDependencies(Ga), Ga == 0 && (ju !== null && (clearInterval(ju), ju = null), Js)) {
- var B = Js;
- Js = null, B();
+ function II(F) {
+ if (ja--, u.monitorRunDependencies && u.monitorRunDependencies(ja), ja == 0 && (ju !== null && (clearInterval(ju), ju = null), ta)) {
+ var B = ta;
+ ta = null, B();
}
}
function Xu(F) {
- w ? postMessage({ cmd: "onAbort", arg: F }) : u.onAbort && u.onAbort(F), F = "Aborted(" + F + ")", q(F), ie = true, de = 1, F += ". Build with -sASSERTIONS for more info.";
+ w ? postMessage({ cmd: "onAbort", arg: F }) : u.onAbort && u.onAbort(F), F = "Aborted(" + F + ")", q(F), pe = true, he = 1, F += ". Build with -sASSERTIONS for more info.";
var B = new WebAssembly.RuntimeError(F);
throw l(B), B;
}
- var $x = "data:application/octet-stream;base64,";
- function nm(F) {
- return F.startsWith($x);
+ var Ix = "data:application/octet-stream;base64,";
+ function jl(F) {
+ return F.startsWith(Ix);
}
- function Vc(F) {
+ function Fc(F) {
return F.startsWith("file://");
}
- var dr;
- dr = "tfjs-backend-wasm-threaded-simd.wasm", nm(dr) || (dr = _(dr));
- function sm(F) {
+ var fr;
+ fr = "tfjs-backend-wasm-threaded-simd.wasm", jl(fr) || (fr = _(fr));
+ function Xl(F) {
try {
- if (F == dr && ee)
+ if (F == fr && ee)
return new Uint8Array(ee);
- if (A)
- return A(F);
+ if (R)
+ return R(F);
throw "both async and sync fetching of the wasm failed";
} catch (B) {
Xu(B);
}
}
- function Rx() {
- if (!ee && (y || b)) {
- if (typeof fetch == "function" && !Vc(dr))
- return fetch(dr, { credentials: "same-origin" }).then(function(F) {
+ function vx() {
+ if (!ee && (x || b)) {
+ if (typeof fetch == "function" && !Fc(fr))
+ return fetch(fr, { credentials: "same-origin" }).then(function(F) {
if (!F.ok)
- throw "failed to load wasm binary file at '" + dr + "'";
+ throw "failed to load wasm binary file at '" + fr + "'";
return F.arrayBuffer();
}).catch(function() {
- return sm(dr);
+ return Xl(fr);
});
- if (R)
+ if (A)
return new Promise(function(F, B) {
- R(dr, function(re) {
- F(new Uint8Array(re));
+ A(fr, function(ne) {
+ F(new Uint8Array(ne));
}, B);
});
}
return Promise.resolve().then(function() {
- return sm(dr);
+ return Xl(fr);
});
}
- function Ax() {
- var F = { env: xm, wasi_snapshot_preview1: xm };
- function B($e, Pe) {
- var Wt = $e.exports;
- if (u.asm = Wt, Wx(u.asm._emscripten_tls_init), rr = u.asm.__indirect_function_table, Bc(u.asm.__wasm_call_ctors), se = Pe, !w) {
- var Zr = Fe.unusedWorkers.length;
- Fe.unusedWorkers.forEach(function(ta) {
- Fe.loadWasmModuleToWorker(ta, function() {
- --Zr || XS("wasm-instantiate");
+ function kx() {
+ var F = { env: im, wasi_snapshot_preview1: im };
+ function B(Ae, Pe) {
+ var zt = Ae.exports;
+ if (u.asm = zt, Ox(u.asm._emscripten_tls_init), rr = u.asm.__indirect_function_table, Rc(u.asm.__wasm_call_ctors), ie = Pe, !w) {
+ var Qr = De.unusedWorkers.length;
+ De.unusedWorkers.forEach(function(oa) {
+ De.loadWasmModuleToWorker(oa, function() {
+ --Qr || II("wasm-instantiate");
});
});
}
}
- w || jS("wasm-instantiate");
- function re($e) {
- B($e.instance, $e.module);
+ w || wI("wasm-instantiate");
+ function ne(Ae) {
+ B(Ae.instance, Ae.module);
}
- function le($e) {
- return Rx().then(function(Pe) {
+ function fe(Ae) {
+ return vx().then(function(Pe) {
return WebAssembly.instantiate(Pe, F);
}).then(function(Pe) {
return Pe;
- }).then($e, function(Pe) {
+ }).then(Ae, function(Pe) {
q("failed to asynchronously prepare wasm: " + Pe), Xu(Pe);
});
}
function Te() {
- return !ee && typeof WebAssembly.instantiateStreaming == "function" && !nm(dr) && !Vc(dr) && !C && typeof fetch == "function" ? fetch(dr, { credentials: "same-origin" }).then(function($e) {
- var Pe = WebAssembly.instantiateStreaming($e, F);
- return Pe.then(re, function(Wt) {
- return q("wasm streaming compile failed: " + Wt), q("falling back to ArrayBuffer instantiation"), le(re);
+ return !ee && typeof WebAssembly.instantiateStreaming == "function" && !jl(fr) && !Fc(fr) && !C && typeof fetch == "function" ? fetch(fr, { credentials: "same-origin" }).then(function(Ae) {
+ var Pe = WebAssembly.instantiateStreaming(Ae, F);
+ return Pe.then(ne, function(zt) {
+ return q("wasm streaming compile failed: " + zt), q("falling back to ArrayBuffer instantiation"), fe(ne);
});
- }) : le(re);
+ }) : fe(ne);
}
if (u.instantiateWasm)
try {
var Ze = u.instantiateWasm(F, B);
return Ze;
- } catch ($e) {
- q("Module.instantiateWasm callback failed with error: " + $e), l($e);
+ } catch (Ae) {
+ q("Module.instantiateWasm callback failed with error: " + Ae), l(Ae);
}
return Te().catch(l), {};
}
- var Fx, YS, Dx = {};
- function Di(F) {
+ var Nx, vI, Tx = {};
+ function Hi(F) {
this.name = "ExitStatus", this.message = "Program terminated with exit(" + F + ")", this.status = F;
}
- function Px(F) {
- var B = Fe.pthreads[F];
- delete Fe.pthreads[F], B.terminate(), cb(F), Fe.runningWorkers.splice(Fe.runningWorkers.indexOf(B), 1), B.pthread_ptr = 0;
+ function _x(F) {
+ var B = De.pthreads[F];
+ delete De.pthreads[F], B.terminate(), sb(F), De.runningWorkers.splice(De.runningWorkers.indexOf(B), 1), B.pthread_ptr = 0;
}
- function Ox(F) {
- var B = Fe.pthreads[F];
+ function Ex(F) {
+ var B = De.pthreads[F];
B.postMessage({ cmd: "cancel" });
}
- function zc(F) {
- var B = Fe.pthreads[F];
- Ie(B), Fe.returnWorkerToPool(B);
+ function Dc(F) {
+ var B = De.pthreads[F];
+ we(B), De.returnWorkerToPool(B);
}
- function am(F) {
- var B = Fe.getNewWorker();
+ function Yl(F) {
+ var B = De.getNewWorker();
if (!B)
return 6;
- Fe.runningWorkers.push(B), Fe.pthreads[F.pthread_ptr] = B, B.pthread_ptr = F.pthread_ptr;
- var re = { cmd: "run", start_routine: F.startRoutine, arg: F.arg, pthread_ptr: F.pthread_ptr };
+ De.runningWorkers.push(B), De.pthreads[F.pthread_ptr] = B, B.pthread_ptr = F.pthread_ptr;
+ var ne = { cmd: "run", start_routine: F.startRoutine, arg: F.arg, pthread_ptr: F.pthread_ptr };
return B.runPthread = () => {
- re.time = performance.now(), B.postMessage(re, F.transferList);
+ ne.time = performance.now(), B.postMessage(ne, F.transferList);
}, B.loaded && (B.runPthread(), delete B.runPthread), 0;
}
- var im = { varargs: void 0, get: function() {
- im.varargs += 4;
- var F = s()[im.varargs - 4 >> 2];
+ var Ql = { varargs: void 0, get: function() {
+ Ql.varargs += 4;
+ var F = s()[Ql.varargs - 4 >> 2];
return F;
}, getStr: function(F) {
- var B = Me(F);
+ var B = Le(F);
return B;
} };
- function Wc(F) {
+ function Oc(F) {
if (w)
- return Ha(1, 1, F);
- de = F, tn() || (Fe.terminateAllThreads(), u.onExit && u.onExit(F), ie = true), g(F, new Di(F));
+ return Xa(1, 1, F);
+ he = F, Fo() || (De.terminateAllThreads(), u.onExit && u.onExit(F), pe = true), g(F, new Hi(F));
}
- function QS(F, B) {
- if (de = F, !B && w)
- throw pm(F), "unwind";
- Wc(F);
+ function kI(F, B) {
+ if (he = F, !B && w)
+ throw Jl(F), "unwind";
+ Oc(F);
}
- var um = QS;
- function Mx(F) {
- if (F instanceof Di || F == "unwind")
- return de;
+ var Zl = kI;
+ function $x(F) {
+ if (F instanceof Hi || F == "unwind")
+ return he;
g(1, F);
}
- var Fe = { unusedWorkers: [], runningWorkers: [], tlsInitFunctions: [], pthreads: {}, init: function() {
- w ? Fe.initWorker() : Fe.initMainThread();
+ var De = { unusedWorkers: [], runningWorkers: [], tlsInitFunctions: [], pthreads: {}, init: function() {
+ w ? De.initWorker() : De.initMainThread();
}, initMainThread: function() {
for (var F = 8; F--; )
- Fe.allocateUnusedWorker();
+ De.allocateUnusedWorker();
}, initWorker: function() {
- X = false;
+ Y = false;
}, setExitStatus: function(F) {
- de = F;
+ he = F;
}, terminateAllThreads: function() {
- for (var F of Object.values(Fe.pthreads))
- Fe.returnWorkerToPool(F);
- for (var F of Fe.unusedWorkers)
+ for (var F of Object.values(De.pthreads))
+ De.returnWorkerToPool(F);
+ for (var F of De.unusedWorkers)
F.terminate();
- Fe.unusedWorkers = [];
+ De.unusedWorkers = [];
}, returnWorkerToPool: function(F) {
var B = F.pthread_ptr;
- delete Fe.pthreads[B], Fe.unusedWorkers.push(F), Fe.runningWorkers.splice(Fe.runningWorkers.indexOf(F), 1), F.pthread_ptr = 0, cb(B);
+ delete De.pthreads[B], De.unusedWorkers.push(F), De.runningWorkers.splice(De.runningWorkers.indexOf(F), 1), F.pthread_ptr = 0, sb(B);
}, receiveObjectTransfer: function(F) {
}, threadInitTLS: function() {
- Fe.tlsInitFunctions.forEach((F) => F());
+ De.tlsInitFunctions.forEach((F) => F());
}, loadWasmModuleToWorker: function(F, B) {
- F.onmessage = (re) => {
- var le = re.data, Te = le.cmd;
- if (F.pthread_ptr && (Fe.currentProxiedOperationCallerThread = F.pthread_ptr), le.targetThread && le.targetThread != Sm()) {
- var Ze = Fe.pthreads[le.targetThread];
- Ze ? Ze.postMessage(le, le.transferList) : q('Internal error! Worker sent a message "' + Te + '" to target pthread ' + le.targetThread + ", but that thread no longer exists!"), Fe.currentProxiedOperationCallerThread = void 0;
+ F.onmessage = (ne) => {
+ var fe = ne.data, Te = fe.cmd;
+ if (F.pthread_ptr && (De.currentProxiedOperationCallerThread = F.pthread_ptr), fe.targetThread && fe.targetThread != dm()) {
+ var Ze = De.pthreads[fe.targetThread];
+ Ze ? Ze.postMessage(fe, fe.transferList) : q('Internal error! Worker sent a message "' + Te + '" to target pthread ' + fe.targetThread + ", but that thread no longer exists!"), De.currentProxiedOperationCallerThread = void 0;
return;
}
- Te === "processProxyingQueue" ? Gc(le.queue) : Te === "spawnThread" ? am(le) : Te === "cleanupThread" ? zc(le.thread) : Te === "killThread" ? Px(le.thread) : Te === "cancelThread" ? Ox(le.thread) : Te === "loaded" ? (F.loaded = true, B && B(F), F.runPthread && (F.runPthread(), delete F.runPthread)) : Te === "print" ? G("Thread " + le.threadId + ": " + le.text) : Te === "printErr" ? q("Thread " + le.threadId + ": " + le.text) : Te === "alert" ? alert("Thread " + le.threadId + ": " + le.text) : le.target === "setimmediate" ? F.postMessage(le) : Te === "onAbort" ? u.onAbort && u.onAbort(le.arg) : Te && q("worker sent an unknown command " + Te), Fe.currentProxiedOperationCallerThread = void 0;
- }, F.onerror = (re) => {
- var le = "worker sent an error!";
- throw q(le + " " + re.filename + ":" + re.lineno + ": " + re.message), re;
- }, C && (F.on("message", function(re) {
- F.onmessage({ data: re });
- }), F.on("error", function(re) {
- F.onerror(re);
+ Te === "processProxyingQueue" ? Mc(fe.queue) : Te === "spawnThread" ? Yl(fe) : Te === "cleanupThread" ? Dc(fe.thread) : Te === "killThread" ? _x(fe.thread) : Te === "cancelThread" ? Ex(fe.thread) : Te === "loaded" ? (F.loaded = true, B && B(F), F.runPthread && (F.runPthread(), delete F.runPthread)) : Te === "print" ? U("Thread " + fe.threadId + ": " + fe.text) : Te === "printErr" ? q("Thread " + fe.threadId + ": " + fe.text) : Te === "alert" ? alert("Thread " + fe.threadId + ": " + fe.text) : fe.target === "setimmediate" ? F.postMessage(fe) : Te === "onAbort" ? u.onAbort && u.onAbort(fe.arg) : Te && q("worker sent an unknown command " + Te), De.currentProxiedOperationCallerThread = void 0;
+ }, F.onerror = (ne) => {
+ var fe = "worker sent an error!";
+ throw q(fe + " " + ne.filename + ":" + ne.lineno + ": " + ne.message), ne;
+ }, C && (F.on("message", function(ne) {
+ F.onmessage({ data: ne });
+ }), F.on("error", function(ne) {
+ F.onerror(ne);
}), F.on("detachedExit", function() {
- })), F.postMessage({ cmd: "load", urlOrBlob: u.mainScriptUrlOrBlob || r, wasmMemory: Q, wasmModule: se });
+ })), F.postMessage({ cmd: "load", urlOrBlob: u.mainScriptUrlOrBlob || r, wasmMemory: J, wasmModule: ie });
}, allocateUnusedWorker: function() {
var F = _("tfjs-backend-wasm-threaded-simd.worker.js");
- Fe.unusedWorkers.push(new Worker(F));
+ De.unusedWorkers.push(new Worker(F));
}, getNewWorker: function() {
- return Fe.unusedWorkers.length == 0 && (Fe.allocateUnusedWorker(), Fe.loadWasmModuleToWorker(Fe.unusedWorkers[0])), Fe.unusedWorkers.pop();
+ return De.unusedWorkers.length == 0 && (De.allocateUnusedWorker(), De.loadWasmModuleToWorker(De.unusedWorkers[0])), De.unusedWorkers.pop();
} };
- u.PThread = Fe;
- function Uc(F) {
+ u.PThread = De;
+ function Pc(F) {
for (; F.length > 0; )
F.shift()(u);
}
- function Lx(F) {
- var B = lb(), re = F();
- return vm(B), re;
+ function Ax(F) {
+ var B = ab(), ne = F();
+ return fm(B), ne;
}
- function ZS(F) {
+ function NI(F) {
return F;
}
- function JS(F) {
+ function TI(F) {
var B = /\b_Z[\w\d_]+/g;
- return F.replace(B, function(re) {
- var le = re;
- return re === le ? re : le + " [" + re + "]";
+ return F.replace(B, function(ne) {
+ var fe = ne;
+ return ne === fe ? ne : fe + " [" + ne + "]";
});
}
- function Bx() {
- var F = Sm(), B = s()[F + 44 >> 2], re = s()[F + 48 >> 2], le = B - re;
- a0(B, le), vm(B);
+ function Rx() {
+ var F = dm(), B = s()[F + 44 >> 2], ne = s()[F + 48 >> 2], fe = B - ne;
+ DI(B, fe), fm(B);
}
- u.establishStackSpace = Bx;
- function pm(F) {
+ u.establishStackSpace = Rx;
+ function Jl(F) {
if (w)
- return Ha(2, 0, F);
+ return Xa(2, 0, F);
try {
- um(F);
+ Zl(F);
} catch (B) {
- Mx(B);
+ $x(B);
}
}
var Yu = [];
- function Vx(F) {
+ function Fx(F) {
var B = Yu[F];
return B || (F >= Yu.length && (Yu.length = F + 1), Yu[F] = B = rr.get(F)), B;
}
- function zx(F, B) {
- var re = Vx(F)(B);
- tn() ? Fe.setExitStatus(re) : s0(re);
+ function Dx(F, B) {
+ var ne = Fx(F)(B);
+ Fo() ? De.setExitStatus(ne) : FI(ne);
}
- u.invokeEntryPoint = zx;
- function e0() {
+ u.invokeEntryPoint = Dx;
+ function _I() {
var F = new Error();
if (!F.stack) {
try {
@@ -1668,443 +1668,447 @@ var M3 = Kt((Fg, Jw) => {
}
return F.stack.toString();
}
- function Wx(F) {
- Fe.tlsInitFunctions.push(F);
+ function Ox(F) {
+ De.tlsInitFunctions.push(F);
}
- function Ux(F, B) {
- t10().set(F, B);
+ function Px(F, B) {
+ t6().set(F, B);
}
- function Gx(F) {
- r0(F, !b, 1, !y), Fe.threadInitTLS();
+ function Mx(F) {
+ $I(F, !b, 1, !x), De.threadInitTLS();
}
- function Hx(F) {
- w ? postMessage({ cmd: "cleanupThread", thread: F }) : zc(F);
+ function Lx(F) {
+ w ? postMessage({ cmd: "cleanupThread", thread: F }) : Dc(F);
}
- function cm(F, B, re, le) {
- return w ? Ha(3, 1, F, B, re, le) : lm(F, B, re, le);
+ function em(F, B, ne, fe) {
+ return w ? Xa(3, 1, F, B, ne, fe) : tm(F, B, ne, fe);
}
- function lm(F, B, re, le) {
+ function tm(F, B, ne, fe) {
if (typeof SharedArrayBuffer == "undefined")
return q("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6;
var Te = [], Ze = 0;
if (w && (Te.length === 0 || Ze))
- return cm(F, B, re, le);
+ return em(F, B, ne, fe);
if (Ze)
return Ze;
- var $e = { startRoutine: re, pthread_ptr: F, arg: le, transferList: Te };
- return w ? ($e.cmd = "spawnThread", postMessage($e, Te), 0) : am($e);
+ var Ae = { startRoutine: ne, pthread_ptr: F, arg: fe, transferList: Te };
+ return w ? (Ae.cmd = "spawnThread", postMessage(Ae, Te), 0) : Yl(Ae);
}
- function qx() {
+ function Bx() {
return 2097152;
}
- var Kx = true;
- function jx() {
- return Kx;
+ var Vx = true;
+ function zx() {
+ return Vx;
}
- function Gc(F) {
- Atomics.store(s(), F >> 2, 1), Sm() && n0(F), Atomics.compareExchange(s(), F >> 2, 1, 0);
+ function Mc(F) {
+ Atomics.store(s(), F >> 2, 1), dm() && RI(F), Atomics.compareExchange(s(), F >> 2, 1, 0);
}
- u.executeNotifiedProxyingQueue = Gc;
- function Xx(F, B, re, le) {
+ u.executeNotifiedProxyingQueue = Mc;
+ function Wx(F, B, ne, fe) {
if (F == B)
- setTimeout(() => Gc(le));
+ setTimeout(() => Mc(fe));
else if (w)
- postMessage({ targetThread: F, cmd: "processProxyingQueue", queue: le });
+ postMessage({ targetThread: F, cmd: "processProxyingQueue", queue: fe });
else {
- var Te = Fe.pthreads[F];
+ var Te = De.pthreads[F];
if (!Te)
return;
- Te.postMessage({ cmd: "processProxyingQueue", queue: le });
+ Te.postMessage({ cmd: "processProxyingQueue", queue: fe });
}
return 1;
}
- function Yx(F, B, re) {
+ function Ux(F, B, ne) {
return -1;
}
- function Qx() {
+ function Gx() {
Xu("");
}
- function Pi(F) {
- Pi.shown || (Pi.shown = {}), Pi.shown[F] || (Pi.shown[F] = 1, C && (F = "warning: " + F), q(F));
+ function qi(F) {
+ qi.shown || (qi.shown = {}), qi.shown[F] || (qi.shown[F] = 1, C && (F = "warning: " + F), q(F));
}
- function Zx() {
- C || b || Pi("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread");
+ function Hx() {
+ C || b || qi("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread");
}
- function Jx() {
+ function qx() {
return Date.now();
}
- function mm() {
+ function rm() {
return 2147483648;
}
- function ey() {
- return mm();
+ function Kx() {
+ return rm();
}
var Qu;
C ? Qu = () => {
var F = process.hrtime();
return F[0] * 1e3 + F[1] / 1e6;
} : w ? Qu = () => performance.now() - u.__performance_now_clock_drift : Qu = () => performance.now();
- function ty(F, B, re) {
- o().copyWithin(F, B, B + re);
+ function jx(F, B, ne) {
+ o().copyWithin(F, B, B + ne);
}
- function ry() {
- return C ? O3().cpus().length : navigator.hardwareConcurrency;
+ function Xx() {
+ return C ? d3().cpus().length : navigator.hardwareConcurrency;
}
- function Ha(F, B) {
- var re = arguments.length - 2, le = arguments;
- return Lx(() => {
- for (var Te = re, Ze = km(Te * 8), $e = Ze >> 3, Pe = 0; Pe < re; Pe++) {
- var Wt = le[2 + Pe];
- p()[$e + Pe] = Wt;
+ function Xa(F, B) {
+ var ne = arguments.length - 2, fe = arguments;
+ return Ax(() => {
+ for (var Te = ne, Ze = hm(Te * 8), Ae = Ze >> 3, Pe = 0; Pe < ne; Pe++) {
+ var zt = fe[2 + Pe];
+ p()[Ae + Pe] = zt;
}
- return o0(F, Te, Ze, B);
+ return AI(F, Te, Ze, B);
});
}
- var Hc = [];
- function oy(F, B, re) {
- Hc.length = B;
- for (var le = re >> 3, Te = 0; Te < B; Te++)
- Hc[Te] = p()[le + Te];
- var Ze = F < 0, $e = Ze ? Dx[-F - 1] : ly[F];
- return $e.apply(null, Hc);
+ var Lc = [];
+ function Yx(F, B, ne) {
+ Lc.length = B;
+ for (var fe = ne >> 3, Te = 0; Te < B; Te++)
+ Lc[Te] = p()[fe + Te];
+ var Ze = F < 0, Ae = Ze ? Tx[-F - 1] : ny[F];
+ return Ae.apply(null, Lc);
}
- function ny(F) {
+ function Qx(F) {
try {
- return Q.grow(F - De.byteLength + 65535 >>> 16), Tt(Q.buffer), 1;
+ return J.grow(F - Oe.byteLength + 65535 >>> 16), Nt(J.buffer), 1;
} catch (B) {
}
}
- function sy(F) {
+ function Zx(F) {
var B = o().length;
if (F = F >>> 0, F <= B)
return false;
- var re = mm();
- if (F > re)
+ var ne = rm();
+ if (F > ne)
return false;
- let le = (Wt, Zr) => Wt + (Zr - Wt % Zr) % Zr;
+ let fe = (zt, Qr) => zt + (Qr - zt % Qr) % Qr;
for (var Te = 1; Te <= 4; Te *= 2) {
var Ze = B * (1 + 0.2 / Te);
Ze = Math.min(Ze, F + 100663296);
- var $e = Math.min(re, le(Math.max(F, Ze), 65536)), Pe = ny($e);
+ var Ae = Math.min(ne, fe(Math.max(F, Ze), 65536)), Pe = Qx(Ae);
if (Pe)
return true;
}
return false;
}
- function ay() {
+ function Jx() {
throw "unwind";
}
- function fm(F) {
- return w ? Ha(4, 1, F) : 52;
+ function om(F) {
+ return w ? Xa(4, 1, F) : 52;
}
- function dm(F, B, re, le, Te) {
- return w ? Ha(5, 1, F, B, re, le, Te) : 70;
+ function nm(F, B, ne, fe, Te) {
+ return w ? Xa(5, 1, F, B, ne, fe, Te) : 70;
}
- var iy = [null, [], []];
- function uy(F, B) {
- var re = iy[F];
- B === 0 || B === 10 ? ((F === 1 ? G : q)(Ee(re, 0)), re.length = 0) : re.push(B);
+ var ey = [null, [], []];
+ function ty(F, B) {
+ var ne = ey[F];
+ B === 0 || B === 10 ? ((F === 1 ? U : q)($e(ne, 0)), ne.length = 0) : ne.push(B);
}
- function hm(F, B, re, le) {
+ function sm(F, B, ne, fe) {
if (w)
- return Ha(6, 1, F, B, re, le);
- for (var Te = 0, Ze = 0; Ze < re; Ze++) {
- var $e = a()[B >> 2], Pe = a()[B + 4 >> 2];
+ return Xa(6, 1, F, B, ne, fe);
+ for (var Te = 0, Ze = 0; Ze < ne; Ze++) {
+ var Ae = a()[B >> 2], Pe = a()[B + 4 >> 2];
B += 8;
- for (var Wt = 0; Wt < Pe; Wt++)
- uy(F, o()[$e + Wt]);
+ for (var zt = 0; zt < Pe; zt++)
+ ty(F, o()[Ae + zt]);
Te += Pe;
}
- return a()[le >> 2] = Te, 0;
+ return a()[fe >> 2] = Te, 0;
}
- function gm(F) {
+ function am(F) {
var B = u["_" + F];
return B;
}
- function py(F, B, re, le, Te) {
+ function ry(F, B, ne, fe, Te) {
var Ze = { string: (Dr) => {
var tp = 0;
if (Dr != null && Dr !== 0) {
- var p0 = (Dr.length << 2) + 1;
- tp = km(p0), pt(Dr, tp, p0);
+ var MI = (Dr.length << 2) + 1;
+ tp = hm(MI), pt(Dr, tp, MI);
}
return tp;
}, array: (Dr) => {
- var tp = km(Dr.length);
- return Ux(Dr, tp), tp;
+ var tp = hm(Dr.length);
+ return Px(Dr, tp), tp;
} };
- function $e(Dr) {
- return B === "string" ? Me(Dr) : B === "boolean" ? Boolean(Dr) : Dr;
+ function Ae(Dr) {
+ return B === "string" ? Le(Dr) : B === "boolean" ? Boolean(Dr) : Dr;
}
- var Pe = gm(F), Wt = [], Zr = 0;
- if (le)
- for (var ta = 0; ta < le.length; ta++) {
- var u0 = Ze[re[ta]];
- u0 ? (Zr === 0 && (Zr = lb()), Wt[ta] = u0(le[ta])) : Wt[ta] = le[ta];
+ var Pe = am(F), zt = [], Qr = 0;
+ if (fe)
+ for (var oa = 0; oa < fe.length; oa++) {
+ var PI = Ze[ne[oa]];
+ PI ? (Qr === 0 && (Qr = ab()), zt[oa] = PI(fe[oa])) : zt[oa] = fe[oa];
}
- var mb = Pe.apply(null, Wt);
- function YV(Dr) {
- return Zr !== 0 && vm(Zr), $e(Dr);
+ var ib = Pe.apply(null, zt);
+ function xV(Dr) {
+ return Qr !== 0 && fm(Qr), Ae(Dr);
}
- return mb = YV(mb), mb;
+ return ib = xV(ib), ib;
}
- function cy(F, B, re, le) {
- re = re || [];
- var Te = re.every(($e) => $e === "number" || $e === "boolean"), Ze = B !== "string";
- return Ze && Te && !le ? gm(F) : function() {
- return py(F, B, re, arguments, le);
+ function oy(F, B, ne, fe) {
+ ne = ne || [];
+ var Te = ne.every((Ae) => Ae === "number" || Ae === "boolean"), Ze = B !== "string";
+ return Ze && Te && !fe ? am(F) : function() {
+ return ry(F, B, ne, arguments, fe);
};
}
- Fe.init();
- var ly = [null, Wc, pm, cm, fm, dm, hm], xm = { __emscripten_init_main_thread_js: Gx, __emscripten_thread_cleanup: Hx, __pthread_create_js: lm, _emscripten_default_pthread_stack_size: qx, _emscripten_get_now_is_monotonic: jx, _emscripten_notify_task_queue: Xx, _emscripten_set_offscreencanvas_size: Yx, abort: Qx, emscripten_check_blocking_allowed: Zx, emscripten_date_now: Jx, emscripten_get_heap_max: ey, emscripten_get_now: Qu, emscripten_memcpy_big: ty, emscripten_num_logical_cores: ry, emscripten_receive_on_main_thread_js: oy, emscripten_resize_heap: sy, emscripten_unwind_to_js_event_loop: ay, exit: um, fd_close: fm, fd_seek: dm, fd_write: hm, memory: Q || u.wasmMemory }, t0 = Ax(), my = u.___wasm_call_ctors = function() {
- return (my = u.___wasm_call_ctors = u.asm.__wasm_call_ctors).apply(null, arguments);
- }, fy = u._init = function() {
- return (fy = u._init = u.asm.init).apply(null, arguments);
- }, dy = u._init_with_threads_count = function() {
- return (dy = u._init_with_threads_count = u.asm.init_with_threads_count).apply(null, arguments);
- }, hy = u._get_threads_count = function() {
- return (hy = u._get_threads_count = u.asm.get_threads_count).apply(null, arguments);
- }, gy = u._register_tensor = function() {
- return (gy = u._register_tensor = u.asm.register_tensor).apply(null, arguments);
- }, xy = u._dispose_data = function() {
- return (xy = u._dispose_data = u.asm.dispose_data).apply(null, arguments);
- }, yy = u._dispose = function() {
- return (yy = u._dispose = u.asm.dispose).apply(null, arguments);
- }, by = u._Abs = function() {
- return (by = u._Abs = u.asm.Abs).apply(null, arguments);
- }, Cy = u._Add = function() {
- return (Cy = u._Add = u.asm.Add).apply(null, arguments);
- }, Iy = u._AddN = function() {
- return (Iy = u._AddN = u.asm.AddN).apply(null, arguments);
- }, wy = u._All = function() {
- return (wy = u._All = u.asm.All).apply(null, arguments);
- }, Sy = u._Any = function() {
- return (Sy = u._Any = u.asm.Any).apply(null, arguments);
- }, vy = u._ArgMax = function() {
- return (vy = u._ArgMax = u.asm.ArgMax).apply(null, arguments);
- }, ky = u._AvgPool = function() {
- return (ky = u._AvgPool = u.asm.AvgPool).apply(null, arguments);
- }, Ty = u._BatchMatMul = function() {
- return (Ty = u._BatchMatMul = u.asm.BatchMatMul).apply(null, arguments);
- }, Ny = u._Ceil = function() {
- return (Ny = u._Ceil = u.asm.Ceil).apply(null, arguments);
- }, _y = u._ClipByValue = function() {
- return (_y = u._ClipByValue = u.asm.ClipByValue).apply(null, arguments);
- }, Ey = u._Conv2D = function() {
- return (Ey = u._Conv2D = u.asm.Conv2D).apply(null, arguments);
- }, $y = u._Conv2DBackpropInput = function() {
- return ($y = u._Conv2DBackpropInput = u.asm.Conv2DBackpropInput).apply(null, arguments);
- }, Ry = u._Cos = function() {
- return (Ry = u._Cos = u.asm.Cos).apply(null, arguments);
- }, Ay = u._Cosh = function() {
- return (Ay = u._Cosh = u.asm.Cosh).apply(null, arguments);
- }, Fy = u._CropAndResize = function() {
- return (Fy = u._CropAndResize = u.asm.CropAndResize).apply(null, arguments);
- }, Dy = u._Cumprod = function() {
- return (Dy = u._Cumprod = u.asm.Cumprod).apply(null, arguments);
- }, Py = u._Cumsum = function() {
- return (Py = u._Cumsum = u.asm.Cumsum).apply(null, arguments);
- }, Oy = u._DepthToSpace = function() {
- return (Oy = u._DepthToSpace = u.asm.DepthToSpace).apply(null, arguments);
- }, My = u._DepthwiseConv2dNative = function() {
- return (My = u._DepthwiseConv2dNative = u.asm.DepthwiseConv2dNative).apply(null, arguments);
- }, Ly = u._Elu = function() {
- return (Ly = u._Elu = u.asm.Elu).apply(null, arguments);
- }, By = u._Equal = function() {
- return (By = u._Equal = u.asm.Equal).apply(null, arguments);
- }, Vy = u._Exp = function() {
- return (Vy = u._Exp = u.asm.Exp).apply(null, arguments);
- }, zy = u._FlipLeftRight = function() {
- return (zy = u._FlipLeftRight = u.asm.FlipLeftRight).apply(null, arguments);
- }, Wy = u._Floor = function() {
- return (Wy = u._Floor = u.asm.Floor).apply(null, arguments);
- }, Uy = u._FloorDiv = function() {
- return (Uy = u._FloorDiv = u.asm.FloorDiv).apply(null, arguments);
- }, Gy = u._FusedBatchNorm = function() {
- return (Gy = u._FusedBatchNorm = u.asm.FusedBatchNorm).apply(null, arguments);
- }, Hy = u._FusedConv2D = function() {
- return (Hy = u._FusedConv2D = u.asm.FusedConv2D).apply(null, arguments);
- }, qy = u._FusedDepthwiseConv2D = function() {
- return (qy = u._FusedDepthwiseConv2D = u.asm.FusedDepthwiseConv2D).apply(null, arguments);
- }, Ky = u._Gather = function() {
- return (Ky = u._Gather = u.asm.Gather).apply(null, arguments);
- }, jy = u._GatherNd = function() {
- return (jy = u._GatherNd = u.asm.GatherNd).apply(null, arguments);
- }, Xy = u._Greater = function() {
- return (Xy = u._Greater = u.asm.Greater).apply(null, arguments);
- }, Yy = u._GreaterEqual = function() {
- return (Yy = u._GreaterEqual = u.asm.GreaterEqual).apply(null, arguments);
- }, Qy = u._LeakyRelu = function() {
- return (Qy = u._LeakyRelu = u.asm.LeakyRelu).apply(null, arguments);
- }, Zy = u._Less = function() {
- return (Zy = u._Less = u.asm.Less).apply(null, arguments);
- }, Jy = u._LessEqual = function() {
- return (Jy = u._LessEqual = u.asm.LessEqual).apply(null, arguments);
- }, eb = u._Log = function() {
- return (eb = u._Log = u.asm.Log).apply(null, arguments);
- }, tb = u._LogicalAnd = function() {
- return (tb = u._LogicalAnd = u.asm.LogicalAnd).apply(null, arguments);
- }, rb = u._LogicalNot = function() {
- return (rb = u._LogicalNot = u.asm.LogicalNot).apply(null, arguments);
- }, ob = u._LogicalOr = function() {
- return (ob = u._LogicalOr = u.asm.LogicalOr).apply(null, arguments);
- }, nb = u._LogicalXor = function() {
- return (nb = u._LogicalXor = u.asm.LogicalXor).apply(null, arguments);
- }, sb = u._Max = function() {
- return (sb = u._Max = u.asm.Max).apply(null, arguments);
- }, ym = u._MaxPool = function() {
- return (ym = u._MaxPool = u.asm.MaxPool).apply(null, arguments);
- }, bm = u._Maximum = function() {
- return (bm = u._Maximum = u.asm.Maximum).apply(null, arguments);
- }, qc = u._Mean = function() {
- return (qc = u._Mean = u.asm.Mean).apply(null, arguments);
- }, ab = u._Min = function() {
- return (ab = u._Min = u.asm.Min).apply(null, arguments);
- }, ib = u._Minimum = function() {
- return (ib = u._Minimum = u.asm.Minimum).apply(null, arguments);
- }, Zu = u._MirrorPad = function() {
- return (Zu = u._MirrorPad = u.asm.MirrorPad).apply(null, arguments);
- }, Cm = u._Multiply = function() {
- return (Cm = u._Multiply = u.asm.Multiply).apply(null, arguments);
- }, Ju = u._Neg = function() {
- return (Ju = u._Neg = u.asm.Neg).apply(null, arguments);
- }, ep = u._NonMaxSuppressionV3 = function() {
- return (ep = u._NonMaxSuppressionV3 = u.asm.NonMaxSuppressionV3).apply(null, arguments);
- }, ub = u._NonMaxSuppressionV4 = function() {
- return (ub = u._NonMaxSuppressionV4 = u.asm.NonMaxSuppressionV4).apply(null, arguments);
- }, U = u._NonMaxSuppressionV5 = function() {
- return (U = u._NonMaxSuppressionV5 = u.asm.NonMaxSuppressionV5).apply(null, arguments);
- }, te = u._NotEqual = function() {
- return (te = u._NotEqual = u.asm.NotEqual).apply(null, arguments);
- }, ve = u._OneHot = function() {
- return (ve = u._OneHot = u.asm.OneHot).apply(null, arguments);
- }, Ke = u._PadV2 = function() {
- return (Ke = u._PadV2 = u.asm.PadV2).apply(null, arguments);
- }, Nt = u._Pow = function() {
- return (Nt = u._Pow = u.asm.Pow).apply(null, arguments);
- }, _t = u._Prelu = function() {
- return (_t = u._Prelu = u.asm.Prelu).apply(null, arguments);
- }, He = u._Prod = function() {
- return (He = u._Prod = u.asm.Prod).apply(null, arguments);
- }, ze = u._RealDiv = function() {
- return (ze = u._RealDiv = u.asm.RealDiv).apply(null, arguments);
- }, zt = u._Relu = function() {
- return (zt = u._Relu = u.asm.Relu).apply(null, arguments);
- }, Qr = u._Relu6 = function() {
- return (Qr = u._Relu6 = u.asm.Relu6).apply(null, arguments);
- }, ea = u._ResizeBilinear = function() {
- return (ea = u._ResizeBilinear = u.asm.ResizeBilinear).apply(null, arguments);
- }, Im = u._ResizeNearestNeighbor = function() {
- return (Im = u._ResizeNearestNeighbor = u.asm.ResizeNearestNeighbor).apply(null, arguments);
- }, Kc = u._Reverse = function() {
- return (Kc = u._Reverse = u.asm.Reverse).apply(null, arguments);
- }, pb = u._RotateWithOffset = function() {
- return (pb = u._RotateWithOffset = u.asm.RotateWithOffset).apply(null, arguments);
+ De.init();
+ var ny = [null, Oc, Jl, em, om, nm, sm], im = { __emscripten_init_main_thread_js: Mx, __emscripten_thread_cleanup: Lx, __pthread_create_js: tm, _emscripten_default_pthread_stack_size: Bx, _emscripten_get_now_is_monotonic: zx, _emscripten_notify_task_queue: Wx, _emscripten_set_offscreencanvas_size: Ux, abort: Gx, emscripten_check_blocking_allowed: Hx, emscripten_date_now: qx, emscripten_get_heap_max: Kx, emscripten_get_now: Qu, emscripten_memcpy_big: jx, emscripten_num_logical_cores: Xx, emscripten_receive_on_main_thread_js: Yx, emscripten_resize_heap: Zx, emscripten_unwind_to_js_event_loop: Jx, exit: Zl, fd_close: om, fd_seek: nm, fd_write: sm, memory: J || u.wasmMemory }, EI = kx(), sy = u.___wasm_call_ctors = function() {
+ return (sy = u.___wasm_call_ctors = u.asm.__wasm_call_ctors).apply(null, arguments);
+ }, ay = u._init = function() {
+ return (ay = u._init = u.asm.init).apply(null, arguments);
+ }, iy = u._init_with_threads_count = function() {
+ return (iy = u._init_with_threads_count = u.asm.init_with_threads_count).apply(null, arguments);
+ }, uy = u._get_threads_count = function() {
+ return (uy = u._get_threads_count = u.asm.get_threads_count).apply(null, arguments);
+ }, py = u._register_tensor = function() {
+ return (py = u._register_tensor = u.asm.register_tensor).apply(null, arguments);
+ }, cy = u._dispose_data = function() {
+ return (cy = u._dispose_data = u.asm.dispose_data).apply(null, arguments);
+ }, ly = u._dispose = function() {
+ return (ly = u._dispose = u.asm.dispose).apply(null, arguments);
+ }, my = u._Abs = function() {
+ return (my = u._Abs = u.asm.Abs).apply(null, arguments);
+ }, dy = u._Add = function() {
+ return (dy = u._Add = u.asm.Add).apply(null, arguments);
+ }, fy = u._AddN = function() {
+ return (fy = u._AddN = u.asm.AddN).apply(null, arguments);
+ }, hy = u._All = function() {
+ return (hy = u._All = u.asm.All).apply(null, arguments);
+ }, gy = u._Any = function() {
+ return (gy = u._Any = u.asm.Any).apply(null, arguments);
+ }, xy = u._ArgMax = function() {
+ return (xy = u._ArgMax = u.asm.ArgMax).apply(null, arguments);
+ }, yy = u._AvgPool = function() {
+ return (yy = u._AvgPool = u.asm.AvgPool).apply(null, arguments);
+ }, by = u._BatchMatMul = function() {
+ return (by = u._BatchMatMul = u.asm.BatchMatMul).apply(null, arguments);
+ }, Cy = u._Ceil = function() {
+ return (Cy = u._Ceil = u.asm.Ceil).apply(null, arguments);
+ }, Sy = u._ClipByValue = function() {
+ return (Sy = u._ClipByValue = u.asm.ClipByValue).apply(null, arguments);
+ }, wy = u._Conv2D = function() {
+ return (wy = u._Conv2D = u.asm.Conv2D).apply(null, arguments);
+ }, Iy = u._Conv2DBackpropInput = function() {
+ return (Iy = u._Conv2DBackpropInput = u.asm.Conv2DBackpropInput).apply(null, arguments);
+ }, vy = u._Cos = function() {
+ return (vy = u._Cos = u.asm.Cos).apply(null, arguments);
+ }, ky = u._Cosh = function() {
+ return (ky = u._Cosh = u.asm.Cosh).apply(null, arguments);
+ }, Ny = u._CropAndResize = function() {
+ return (Ny = u._CropAndResize = u.asm.CropAndResize).apply(null, arguments);
+ }, Ty = u._Cumprod = function() {
+ return (Ty = u._Cumprod = u.asm.Cumprod).apply(null, arguments);
+ }, _y = u._Cumsum = function() {
+ return (_y = u._Cumsum = u.asm.Cumsum).apply(null, arguments);
+ }, Ey = u._DepthToSpace = function() {
+ return (Ey = u._DepthToSpace = u.asm.DepthToSpace).apply(null, arguments);
+ }, $y = u._DepthwiseConv2dNative = function() {
+ return ($y = u._DepthwiseConv2dNative = u.asm.DepthwiseConv2dNative).apply(null, arguments);
+ }, Ay = u._Elu = function() {
+ return (Ay = u._Elu = u.asm.Elu).apply(null, arguments);
+ }, Ry = u._Equal = function() {
+ return (Ry = u._Equal = u.asm.Equal).apply(null, arguments);
+ }, Fy = u._Exp = function() {
+ return (Fy = u._Exp = u.asm.Exp).apply(null, arguments);
+ }, Dy = u._FlipLeftRight = function() {
+ return (Dy = u._FlipLeftRight = u.asm.FlipLeftRight).apply(null, arguments);
+ }, Oy = u._Floor = function() {
+ return (Oy = u._Floor = u.asm.Floor).apply(null, arguments);
+ }, Py = u._FloorDiv = function() {
+ return (Py = u._FloorDiv = u.asm.FloorDiv).apply(null, arguments);
+ }, My = u._FusedBatchNorm = function() {
+ return (My = u._FusedBatchNorm = u.asm.FusedBatchNorm).apply(null, arguments);
+ }, Ly = u._FusedConv2D = function() {
+ return (Ly = u._FusedConv2D = u.asm.FusedConv2D).apply(null, arguments);
+ }, By = u._FusedDepthwiseConv2D = function() {
+ return (By = u._FusedDepthwiseConv2D = u.asm.FusedDepthwiseConv2D).apply(null, arguments);
+ }, Vy = u._Gather = function() {
+ return (Vy = u._Gather = u.asm.Gather).apply(null, arguments);
+ }, zy = u._GatherNd = function() {
+ return (zy = u._GatherNd = u.asm.GatherNd).apply(null, arguments);
+ }, Wy = u._Greater = function() {
+ return (Wy = u._Greater = u.asm.Greater).apply(null, arguments);
+ }, Uy = u._GreaterEqual = function() {
+ return (Uy = u._GreaterEqual = u.asm.GreaterEqual).apply(null, arguments);
+ }, Gy = u._IsNan = function() {
+ return (Gy = u._IsNan = u.asm.IsNan).apply(null, arguments);
+ }, Hy = u._LeakyRelu = function() {
+ return (Hy = u._LeakyRelu = u.asm.LeakyRelu).apply(null, arguments);
+ }, qy = u._Less = function() {
+ return (qy = u._Less = u.asm.Less).apply(null, arguments);
+ }, Ky = u._LessEqual = function() {
+ return (Ky = u._LessEqual = u.asm.LessEqual).apply(null, arguments);
+ }, jy = u._Log = function() {
+ return (jy = u._Log = u.asm.Log).apply(null, arguments);
+ }, Xy = u._LogicalAnd = function() {
+ return (Xy = u._LogicalAnd = u.asm.LogicalAnd).apply(null, arguments);
+ }, Yy = u._LogicalNot = function() {
+ return (Yy = u._LogicalNot = u.asm.LogicalNot).apply(null, arguments);
+ }, Qy = u._LogicalOr = function() {
+ return (Qy = u._LogicalOr = u.asm.LogicalOr).apply(null, arguments);
+ }, Zy = u._LogicalXor = function() {
+ return (Zy = u._LogicalXor = u.asm.LogicalXor).apply(null, arguments);
+ }, Jy = u._Max = function() {
+ return (Jy = u._Max = u.asm.Max).apply(null, arguments);
+ }, eb = u._MaxPool = function() {
+ return (eb = u._MaxPool = u.asm.MaxPool).apply(null, arguments);
+ }, um = u._Maximum = function() {
+ return (um = u._Maximum = u.asm.Maximum).apply(null, arguments);
+ }, pm = u._Mean = function() {
+ return (pm = u._Mean = u.asm.Mean).apply(null, arguments);
+ }, Bc = u._Min = function() {
+ return (Bc = u._Min = u.asm.Min).apply(null, arguments);
+ }, tb = u._Minimum = function() {
+ return (tb = u._Minimum = u.asm.Minimum).apply(null, arguments);
+ }, rb = u._MirrorPad = function() {
+ return (rb = u._MirrorPad = u.asm.MirrorPad).apply(null, arguments);
+ }, Zu = u._Multiply = function() {
+ return (Zu = u._Multiply = u.asm.Multiply).apply(null, arguments);
+ }, cm = u._Neg = function() {
+ return (cm = u._Neg = u.asm.Neg).apply(null, arguments);
+ }, Ju = u._NonMaxSuppressionV3 = function() {
+ return (Ju = u._NonMaxSuppressionV3 = u.asm.NonMaxSuppressionV3).apply(null, arguments);
+ }, ep = u._NonMaxSuppressionV4 = function() {
+ return (ep = u._NonMaxSuppressionV4 = u.asm.NonMaxSuppressionV4).apply(null, arguments);
+ }, ob = u._NonMaxSuppressionV5 = function() {
+ return (ob = u._NonMaxSuppressionV5 = u.asm.NonMaxSuppressionV5).apply(null, arguments);
+ }, G = u._NotEqual = function() {
+ return (G = u._NotEqual = u.asm.NotEqual).apply(null, arguments);
+ }, oe = u._OneHot = function() {
+ return (oe = u._OneHot = u.asm.OneHot).apply(null, arguments);
+ }, ke = u._PadV2 = function() {
+ return (ke = u._PadV2 = u.asm.PadV2).apply(null, arguments);
+ }, je = u._Pow = function() {
+ return (je = u._Pow = u.asm.Pow).apply(null, arguments);
+ }, Tt = u._Prelu = function() {
+ return (Tt = u._Prelu = u.asm.Prelu).apply(null, arguments);
+ }, _t = u._Prod = function() {
+ return (_t = u._Prod = u.asm.Prod).apply(null, arguments);
+ }, qe = u._RealDiv = function() {
+ return (qe = u._RealDiv = u.asm.RealDiv).apply(null, arguments);
+ }, We = u._Reciprocal = function() {
+ return (We = u._Reciprocal = u.asm.Reciprocal).apply(null, arguments);
+ }, Vt = u._Relu = function() {
+ return (Vt = u._Relu = u.asm.Relu).apply(null, arguments);
+ }, Yr = u._Relu6 = function() {
+ return (Yr = u._Relu6 = u.asm.Relu6).apply(null, arguments);
+ }, ra = u._ResizeBilinear = function() {
+ return (ra = u._ResizeBilinear = u.asm.ResizeBilinear).apply(null, arguments);
+ }, lm = u._ResizeNearestNeighbor = function() {
+ return (lm = u._ResizeNearestNeighbor = u.asm.ResizeNearestNeighbor).apply(null, arguments);
+ }, Vc = u._Reverse = function() {
+ return (Vc = u._Reverse = u.asm.Reverse).apply(null, arguments);
+ }, nb = u._RotateWithOffset = function() {
+ return (nb = u._RotateWithOffset = u.asm.RotateWithOffset).apply(null, arguments);
}, hr = u._Round = function() {
return (hr = u._Round = u.asm.Round).apply(null, arguments);
- }, qa = u._Rsqrt = function() {
- return (qa = u._Rsqrt = u.asm.Rsqrt).apply(null, arguments);
- }, wm = u._ScatterNd = function() {
- return (wm = u._ScatterNd = u.asm.ScatterNd).apply(null, arguments);
- }, yV = u._SelectV2 = function() {
- return (yV = u._SelectV2 = u.asm.SelectV2).apply(null, arguments);
- }, bV = u._Sigmoid = function() {
- return (bV = u._Sigmoid = u.asm.Sigmoid).apply(null, arguments);
- }, CV = u._Sin = function() {
- return (CV = u._Sin = u.asm.Sin).apply(null, arguments);
- }, IV = u._Softmax = function() {
- return (IV = u._Softmax = u.asm.Softmax).apply(null, arguments);
- }, wV = u._SparseFillEmptyRows = function() {
- return (wV = u._SparseFillEmptyRows = u.asm.SparseFillEmptyRows).apply(null, arguments);
- }, SV = u._SparseReshape = function() {
- return (SV = u._SparseReshape = u.asm.SparseReshape).apply(null, arguments);
- }, vV = u._SparseSegmentReduction = function() {
- return (vV = u._SparseSegmentReduction = u.asm.SparseSegmentReduction).apply(null, arguments);
- }, kV = u._Sqrt = function() {
- return (kV = u._Sqrt = u.asm.Sqrt).apply(null, arguments);
- }, TV = u._Square = function() {
- return (TV = u._Square = u.asm.Square).apply(null, arguments);
- }, NV = u._SquaredDifference = function() {
- return (NV = u._SquaredDifference = u.asm.SquaredDifference).apply(null, arguments);
- }, _V = u._Step = function() {
- return (_V = u._Step = u.asm.Step).apply(null, arguments);
- }, EV = u._StridedSlice = function() {
- return (EV = u._StridedSlice = u.asm.StridedSlice).apply(null, arguments);
- }, $V = u._Sub = function() {
- return ($V = u._Sub = u.asm.Sub).apply(null, arguments);
- }, RV = u._Sum = function() {
- return (RV = u._Sum = u.asm.Sum).apply(null, arguments);
- }, AV = u._Tan = function() {
- return (AV = u._Tan = u.asm.Tan).apply(null, arguments);
- }, FV = u._Tanh = function() {
- return (FV = u._Tanh = u.asm.Tanh).apply(null, arguments);
- }, DV = u._Tile = function() {
- return (DV = u._Tile = u.asm.Tile).apply(null, arguments);
- }, PV = u._TopK = function() {
- return (PV = u._TopK = u.asm.TopK).apply(null, arguments);
- }, OV = u._Transform = function() {
- return (OV = u._Transform = u.asm.Transform).apply(null, arguments);
- }, MV = u._Transpose = function() {
- return (MV = u._Transpose = u.asm.Transpose).apply(null, arguments);
- }, LV = u.__FusedMatMul = function() {
- return (LV = u.__FusedMatMul = u.asm._FusedMatMul).apply(null, arguments);
- }, BV = u._malloc = function() {
- return (BV = u._malloc = u.asm.malloc).apply(null, arguments);
- }, VV = u._free = function() {
- return (VV = u._free = u.asm.free).apply(null, arguments);
- }, zV = u.__emscripten_tls_init = function() {
- return (zV = u.__emscripten_tls_init = u.asm._emscripten_tls_init).apply(null, arguments);
- }, Sm = u._pthread_self = function() {
- return (Sm = u._pthread_self = u.asm.pthread_self).apply(null, arguments);
- }, WV = u.___errno_location = function() {
- return (WV = u.___errno_location = u.asm.__errno_location).apply(null, arguments);
- }, r0 = u.__emscripten_thread_init = function() {
- return (r0 = u.__emscripten_thread_init = u.asm._emscripten_thread_init).apply(null, arguments);
- }, UV = u.__emscripten_thread_crashed = function() {
- return (UV = u.__emscripten_thread_crashed = u.asm._emscripten_thread_crashed).apply(null, arguments);
- }, GV = u._emscripten_main_thread_process_queued_calls = function() {
- return (GV = u._emscripten_main_thread_process_queued_calls = u.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments);
- }, HV = u._emscripten_main_browser_thread_id = function() {
- return (HV = u._emscripten_main_browser_thread_id = u.asm.emscripten_main_browser_thread_id).apply(null, arguments);
- }, o0 = u._emscripten_run_in_main_runtime_thread_js = function() {
- return (o0 = u._emscripten_run_in_main_runtime_thread_js = u.asm.emscripten_run_in_main_runtime_thread_js).apply(null, arguments);
- }, qV = u._emscripten_dispatch_to_thread_ = function() {
- return (qV = u._emscripten_dispatch_to_thread_ = u.asm.emscripten_dispatch_to_thread_).apply(null, arguments);
- }, n0 = u.__emscripten_proxy_execute_task_queue = function() {
- return (n0 = u.__emscripten_proxy_execute_task_queue = u.asm._emscripten_proxy_execute_task_queue).apply(null, arguments);
- }, cb = u.__emscripten_thread_free_data = function() {
- return (cb = u.__emscripten_thread_free_data = u.asm._emscripten_thread_free_data).apply(null, arguments);
- }, s0 = u.__emscripten_thread_exit = function() {
- return (s0 = u.__emscripten_thread_exit = u.asm._emscripten_thread_exit).apply(null, arguments);
- }, a0 = u._emscripten_stack_set_limits = function() {
- return (a0 = u._emscripten_stack_set_limits = u.asm.emscripten_stack_set_limits).apply(null, arguments);
- }, lb = u.stackSave = function() {
- return (lb = u.stackSave = u.asm.stackSave).apply(null, arguments);
- }, vm = u.stackRestore = function() {
- return (vm = u.stackRestore = u.asm.stackRestore).apply(null, arguments);
- }, km = u.stackAlloc = function() {
- return (km = u.stackAlloc = u.asm.stackAlloc).apply(null, arguments);
- }, KV = u.dynCall_iijjiiii = function() {
- return (KV = u.dynCall_iijjiiii = u.asm.dynCall_iijjiiii).apply(null, arguments);
- }, jV = u.dynCall_jiji = function() {
- return (jV = u.dynCall_jiji = u.asm.dynCall_jiji).apply(null, arguments);
+ }, Ya = u._Rsqrt = function() {
+ return (Ya = u._Rsqrt = u.asm.Rsqrt).apply(null, arguments);
+ }, mm = u._ScatterNd = function() {
+ return (mm = u._ScatterNd = u.asm.ScatterNd).apply(null, arguments);
+ }, BB = u._SelectV2 = function() {
+ return (BB = u._SelectV2 = u.asm.SelectV2).apply(null, arguments);
+ }, VB = u._Sigmoid = function() {
+ return (VB = u._Sigmoid = u.asm.Sigmoid).apply(null, arguments);
+ }, zB = u._Sin = function() {
+ return (zB = u._Sin = u.asm.Sin).apply(null, arguments);
+ }, WB = u._Softmax = function() {
+ return (WB = u._Softmax = u.asm.Softmax).apply(null, arguments);
+ }, UB = u._SparseFillEmptyRows = function() {
+ return (UB = u._SparseFillEmptyRows = u.asm.SparseFillEmptyRows).apply(null, arguments);
+ }, GB = u._SparseReshape = function() {
+ return (GB = u._SparseReshape = u.asm.SparseReshape).apply(null, arguments);
+ }, HB = u._SparseSegmentReduction = function() {
+ return (HB = u._SparseSegmentReduction = u.asm.SparseSegmentReduction).apply(null, arguments);
+ }, qB = u._Sqrt = function() {
+ return (qB = u._Sqrt = u.asm.Sqrt).apply(null, arguments);
+ }, KB = u._Square = function() {
+ return (KB = u._Square = u.asm.Square).apply(null, arguments);
+ }, jB = u._SquaredDifference = function() {
+ return (jB = u._SquaredDifference = u.asm.SquaredDifference).apply(null, arguments);
+ }, XB = u._Step = function() {
+ return (XB = u._Step = u.asm.Step).apply(null, arguments);
+ }, YB = u._StridedSlice = function() {
+ return (YB = u._StridedSlice = u.asm.StridedSlice).apply(null, arguments);
+ }, QB = u._Sub = function() {
+ return (QB = u._Sub = u.asm.Sub).apply(null, arguments);
+ }, ZB = u._Sum = function() {
+ return (ZB = u._Sum = u.asm.Sum).apply(null, arguments);
+ }, JB = u._Tan = function() {
+ return (JB = u._Tan = u.asm.Tan).apply(null, arguments);
+ }, eV = u._Tanh = function() {
+ return (eV = u._Tanh = u.asm.Tanh).apply(null, arguments);
+ }, tV = u._Tile = function() {
+ return (tV = u._Tile = u.asm.Tile).apply(null, arguments);
+ }, rV = u._TopK = function() {
+ return (rV = u._TopK = u.asm.TopK).apply(null, arguments);
+ }, oV = u._Transform = function() {
+ return (oV = u._Transform = u.asm.Transform).apply(null, arguments);
+ }, nV = u._Transpose = function() {
+ return (nV = u._Transpose = u.asm.Transpose).apply(null, arguments);
+ }, sV = u.__FusedMatMul = function() {
+ return (sV = u.__FusedMatMul = u.asm._FusedMatMul).apply(null, arguments);
+ }, aV = u._malloc = function() {
+ return (aV = u._malloc = u.asm.malloc).apply(null, arguments);
+ }, iV = u._free = function() {
+ return (iV = u._free = u.asm.free).apply(null, arguments);
+ }, uV = u.__emscripten_tls_init = function() {
+ return (uV = u.__emscripten_tls_init = u.asm._emscripten_tls_init).apply(null, arguments);
+ }, dm = u._pthread_self = function() {
+ return (dm = u._pthread_self = u.asm.pthread_self).apply(null, arguments);
+ }, pV = u.___errno_location = function() {
+ return (pV = u.___errno_location = u.asm.__errno_location).apply(null, arguments);
+ }, $I = u.__emscripten_thread_init = function() {
+ return ($I = u.__emscripten_thread_init = u.asm._emscripten_thread_init).apply(null, arguments);
+ }, cV = u.__emscripten_thread_crashed = function() {
+ return (cV = u.__emscripten_thread_crashed = u.asm._emscripten_thread_crashed).apply(null, arguments);
+ }, lV = u._emscripten_main_thread_process_queued_calls = function() {
+ return (lV = u._emscripten_main_thread_process_queued_calls = u.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments);
+ }, mV = u._emscripten_main_browser_thread_id = function() {
+ return (mV = u._emscripten_main_browser_thread_id = u.asm.emscripten_main_browser_thread_id).apply(null, arguments);
+ }, AI = u._emscripten_run_in_main_runtime_thread_js = function() {
+ return (AI = u._emscripten_run_in_main_runtime_thread_js = u.asm.emscripten_run_in_main_runtime_thread_js).apply(null, arguments);
+ }, dV = u._emscripten_dispatch_to_thread_ = function() {
+ return (dV = u._emscripten_dispatch_to_thread_ = u.asm.emscripten_dispatch_to_thread_).apply(null, arguments);
+ }, RI = u.__emscripten_proxy_execute_task_queue = function() {
+ return (RI = u.__emscripten_proxy_execute_task_queue = u.asm._emscripten_proxy_execute_task_queue).apply(null, arguments);
+ }, sb = u.__emscripten_thread_free_data = function() {
+ return (sb = u.__emscripten_thread_free_data = u.asm._emscripten_thread_free_data).apply(null, arguments);
+ }, FI = u.__emscripten_thread_exit = function() {
+ return (FI = u.__emscripten_thread_exit = u.asm._emscripten_thread_exit).apply(null, arguments);
+ }, DI = u._emscripten_stack_set_limits = function() {
+ return (DI = u._emscripten_stack_set_limits = u.asm.emscripten_stack_set_limits).apply(null, arguments);
+ }, ab = u.stackSave = function() {
+ return (ab = u.stackSave = u.asm.stackSave).apply(null, arguments);
+ }, fm = u.stackRestore = function() {
+ return (fm = u.stackRestore = u.asm.stackRestore).apply(null, arguments);
+ }, hm = u.stackAlloc = function() {
+ return (hm = u.stackAlloc = u.asm.stackAlloc).apply(null, arguments);
+ }, fV = u.dynCall_iijjiiii = function() {
+ return (fV = u.dynCall_iijjiiii = u.asm.dynCall_iijjiiii).apply(null, arguments);
+ }, hV = u.dynCall_jiji = function() {
+ return (hV = u.dynCall_jiji = u.asm.dynCall_jiji).apply(null, arguments);
};
- u.keepRuntimeAlive = tn, u.wasmMemory = Q, u.cwrap = cy, u.ExitStatus = Di, u.PThread = Fe;
- var Tm;
- Js = function F() {
- Tm || i0(), Tm || (Js = F);
+ u.keepRuntimeAlive = Fo, u.wasmMemory = J, u.cwrap = oy, u.ExitStatus = Hi, u.PThread = De;
+ var gm;
+ ta = function F() {
+ gm || OI(), gm || (ta = F);
};
- function i0(F) {
- if (F = F || d, Ga > 0)
+ function OI(F) {
+ if (F = F || f, ja > 0)
return;
if (w) {
- c(u), jt(), postMessage({ cmd: "loaded" });
+ c(u), Kt(), postMessage({ cmd: "loaded" });
return;
}
- if (Ua(), Ga > 0)
+ if (Ka(), ja > 0)
return;
function B() {
- Tm || (Tm = true, u.calledRun = true, !ie && (jt(), c(u), u.onRuntimeInitialized && u.onRuntimeInitialized(), Zs()));
+ gm || (gm = true, u.calledRun = true, !pe && (Kt(), c(u), u.onRuntimeInitialized && u.onRuntimeInitialized(), ea()));
}
u.setStatus ? (u.setStatus("Running..."), setTimeout(function() {
setTimeout(function() {
@@ -2115,26 +2119,26 @@ var M3 = Kt((Fg, Jw) => {
if (u.preInit)
for (typeof u.preInit == "function" && (u.preInit = [u.preInit]); u.preInit.length > 0; )
u.preInit.pop()();
- i0();
- var Nm;
- m && (Nm = { uncaughtException: process.listeners("uncaughtException").filter(function(F) {
+ OI();
+ var xm;
+ m && (xm = { uncaughtException: process.listeners("uncaughtException").filter(function(F) {
return !m.uncaughtException.indexOf(F) > -1;
}), unhandledRejection: process.listeners("unhandledRejection").filter(function(F) {
return !m.unhandledRejection.indexOf(F) > -1;
}) });
- var _m;
+ var ym;
if (typeof WasmBackendModule != "undefined")
- _m = WasmBackendModule;
+ ym = WasmBackendModule;
else if (typeof e != "undefined")
- _m = e;
+ ym = e;
else
throw new Error("Could not find wasm module in post.js");
- if (Nm) {
- var XV = _m._dispose;
- _m._dispose = function() {
- XV(), Nm.uncaughtException.forEach(function(F) {
+ if (xm) {
+ var gV = ym._dispose;
+ ym._dispose = function() {
+ gV(), xm.uncaughtException.forEach(function(F) {
process.removeListener("uncaughtException", F);
- }), Nm.unhandledRejection.forEach(function(F) {
+ }), xm.unhandledRejection.forEach(function(F) {
process.removeListener("unhandledRejection", F);
});
};
@@ -2142,642 +2146,646 @@ var M3 = Kt((Fg, Jw) => {
return e.ready;
};
})();
- typeof Fg == "object" && typeof Jw == "object" ? Jw.exports = Zw : typeof define == "function" && define.amd ? define([], function() {
- return Zw;
- }) : typeof Fg == "object" && (Fg.WasmBackendModuleThreadedSimd = Zw);
+ typeof wg == "object" && typeof jw == "object" ? jw.exports = Kw : typeof define == "function" && define.amd ? define([], function() {
+ return Kw;
+ }) : typeof wg == "object" && (wg.WasmBackendModuleThreadedSimd = Kw);
});
-var B3 = Kt((ukt, L3) => {
- L3.exports.wasmWorkerContents = `"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",data=>onmessage({data:data}));var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8"))},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}var initializedJS=false;var pendingNotifiedProxyingQueues=[];function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+"
+var g3 = qt((kkt, h3) => {
+ h3.exports.wasmWorkerContents = `"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",data=>onmessage({data:data}));var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8"))},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}var initializedJS=false;var pendingNotifiedProxyingQueues=[];function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+"
");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=(info,receiveInstance)=>{var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onunhandledrejection=e=>{throw e.reason??e};self.onmessage=e=>{try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob=="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module).then(function(instance){Module=instance})}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.pthread_ptr,0,0,1);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInitTLS();if(!initializedJS){pendingNotifiedProxyingQueues.forEach(queue=>{Module["executeNotifiedProxyingQueue"](queue)});pendingNotifiedProxyingQueues=[];initializedJS=true}try{Module["invokeEntryPoint"](e.data.start_routine,e.data.arg)}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processProxyingQueue"){if(initializedJS){Module["executeNotifiedProxyingQueue"](e.data.queue)}else{pendingNotifiedProxyingQueues.push(e.data.queue)}}else if(e.data.cmd){err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}};`;
});
-var V3 = Kt((Dg, tS) => {
- var eS = (() => {
+var x3 = qt((Ig, Yw) => {
+ var Xw = (() => {
var r = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0;
return typeof __filename != "undefined" && (r = r || __filename), function(e) {
e = e || {};
- var t10 = typeof e != "undefined" ? e : {}, o, n;
- t10.ready = new Promise(function(U, te) {
- o = U, n = te;
+ var t6 = typeof e != "undefined" ? e : {}, o, n;
+ t6.ready = new Promise(function(G, oe) {
+ o = G, n = oe;
});
var s;
typeof process != "undefined" && process.listeners && (s = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") });
- var a = Object.assign({}, t10), i = [], p = "./this.program", u = (U, te) => {
- throw te;
- }, c = typeof window == "object", l = typeof importScripts == "function", m = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", f = "";
- function d(U) {
- return t10.locateFile ? t10.locateFile(U, f) : f + U;
+ var a = Object.assign({}, t6), i = [], p = "./this.program", u = (G, oe) => {
+ throw oe;
+ }, c = typeof window == "object", l = typeof importScripts == "function", m = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", d = "";
+ function f(G) {
+ return t6.locateFile ? t6.locateFile(G, d) : d + G;
}
- var h, g, y, b;
- function C(U) {
- if (U instanceof ju)
+ var h, g, x, b;
+ function C(G) {
+ if (G instanceof ju)
return;
- E("exiting due to exception: " + U);
+ $("exiting due to exception: " + G);
}
if (m) {
- l ? f = Vl().dirname(f) + "/" : f = __dirname + "/";
+ l ? d = Rl().dirname(d) + "/" : d = __dirname + "/";
var w, k;
- typeof Em == "function" && (w = Qw(), k = Vl()), h = (U, te) => (U = k.normalize(U), w.readFileSync(U, te ? void 0 : "utf8")), y = (U) => {
- var te = h(U, true);
- return te.buffer || (te = new Uint8Array(te)), te;
- }, g = (U, te, ve) => {
- U = k.normalize(U), w.readFile(U, function(Ke, Nt) {
- Ke ? ve(Ke) : te(Nt.buffer);
+ typeof bm == "function" && (w = qw(), k = Rl()), h = (G, oe) => (G = k.normalize(G), w.readFileSync(G, oe ? void 0 : "utf8")), x = (G) => {
+ var oe = h(G, true);
+ return oe.buffer || (oe = new Uint8Array(oe)), oe;
+ }, g = (G, oe, ke) => {
+ G = k.normalize(G), w.readFile(G, function(je, Tt) {
+ je ? ke(je) : oe(Tt.buffer);
});
- }, process.argv.length > 1 && (p = process.argv[1].replace(/\\/g, "/")), i = process.argv.slice(2), process.on("uncaughtException", function(U) {
- if (!(U instanceof ju))
- throw U;
- }), process.on("unhandledRejection", function(U) {
- throw U;
- }), u = (U, te) => {
+ }, process.argv.length > 1 && (p = process.argv[1].replace(/\\/g, "/")), i = process.argv.slice(2), process.on("uncaughtException", function(G) {
+ if (!(G instanceof ju))
+ throw G;
+ }), process.on("unhandledRejection", function(G) {
+ throw G;
+ }), u = (G, oe) => {
if (at())
- throw process.exitCode = U, te;
- C(te), process.exit(U);
- }, t10.inspect = function() {
+ throw process.exitCode = G, oe;
+ C(oe), process.exit(G);
+ }, t6.inspect = function() {
return "[Emscripten Module object]";
};
} else
- (c || l) && (l ? f = self.location.href : typeof document != "undefined" && document.currentScript && (f = document.currentScript.src), r && (f = r), f.indexOf("blob:") !== 0 ? f = f.substr(0, f.replace(/[?#].*/, "").lastIndexOf("/") + 1) : f = "", h = (U) => {
- var te = new XMLHttpRequest();
- return te.open("GET", U, false), te.send(null), te.responseText;
- }, l && (y = (U) => {
- var te = new XMLHttpRequest();
- return te.open("GET", U, false), te.responseType = "arraybuffer", te.send(null), new Uint8Array(te.response);
- }), g = (U, te, ve) => {
- var Ke = new XMLHttpRequest();
- Ke.open("GET", U, true), Ke.responseType = "arraybuffer", Ke.onload = () => {
- if (Ke.status == 200 || Ke.status == 0 && Ke.response) {
- te(Ke.response);
+ (c || l) && (l ? d = self.location.href : typeof document != "undefined" && document.currentScript && (d = document.currentScript.src), r && (d = r), d.indexOf("blob:") !== 0 ? d = d.substr(0, d.replace(/[?#].*/, "").lastIndexOf("/") + 1) : d = "", h = (G) => {
+ var oe = new XMLHttpRequest();
+ return oe.open("GET", G, false), oe.send(null), oe.responseText;
+ }, l && (x = (G) => {
+ var oe = new XMLHttpRequest();
+ return oe.open("GET", G, false), oe.responseType = "arraybuffer", oe.send(null), new Uint8Array(oe.response);
+ }), g = (G, oe, ke) => {
+ var je = new XMLHttpRequest();
+ je.open("GET", G, true), je.responseType = "arraybuffer", je.onload = () => {
+ if (je.status == 200 || je.status == 0 && je.response) {
+ oe(je.response);
return;
}
- ve();
- }, Ke.onerror = ve, Ke.send(null);
- }, b = (U) => document.title = U);
- var _ = t10.print || console.log.bind(console), E = t10.printErr || console.warn.bind(console);
- Object.assign(t10, a), a = null, t10.arguments && (i = t10.arguments), t10.thisProgram && (p = t10.thisProgram), t10.quit && (u = t10.quit);
- var R = 4, A;
- t10.wasmBinary && (A = t10.wasmBinary);
- var D = t10.noExitRuntime || true;
+ ke();
+ }, je.onerror = ke, je.send(null);
+ }, b = (G) => document.title = G);
+ var _ = t6.print || console.log.bind(console), $ = t6.printErr || console.warn.bind(console);
+ Object.assign(t6, a), a = null, t6.arguments && (i = t6.arguments), t6.thisProgram && (p = t6.thisProgram), t6.quit && (u = t6.quit);
+ var A = 4, R;
+ t6.wasmBinary && (R = t6.wasmBinary);
+ var D = t6.noExitRuntime || true;
typeof WebAssembly != "object" && pr("no native wasm support detected");
- var O, M = false, L;
- function W(U, te) {
- U || pr(te);
+ var P, M = false, L;
+ function W(G, oe) {
+ G || pr(oe);
}
var V = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0;
- function G(U, te, ve) {
- for (var Ke = te + ve, Nt = te; U[Nt] && !(Nt >= Ke); )
- ++Nt;
- if (Nt - te > 16 && U.buffer && V)
- return V.decode(U.subarray(te, Nt));
- for (var _t = ""; te < Nt; ) {
- var He = U[te++];
- if (!(He & 128)) {
- _t += String.fromCharCode(He);
+ function U(G, oe, ke) {
+ for (var je = oe + ke, Tt = oe; G[Tt] && !(Tt >= je); )
+ ++Tt;
+ if (Tt - oe > 16 && G.buffer && V)
+ return V.decode(G.subarray(oe, Tt));
+ for (var _t = ""; oe < Tt; ) {
+ var qe = G[oe++];
+ if (!(qe & 128)) {
+ _t += String.fromCharCode(qe);
continue;
}
- var ze = U[te++] & 63;
- if ((He & 224) == 192) {
- _t += String.fromCharCode((He & 31) << 6 | ze);
+ var We = G[oe++] & 63;
+ if ((qe & 224) == 192) {
+ _t += String.fromCharCode((qe & 31) << 6 | We);
continue;
}
- var zt = U[te++] & 63;
- if ((He & 240) == 224 ? He = (He & 15) << 12 | ze << 6 | zt : He = (He & 7) << 18 | ze << 12 | zt << 6 | U[te++] & 63, He < 65536)
- _t += String.fromCharCode(He);
+ var Vt = G[oe++] & 63;
+ if ((qe & 240) == 224 ? qe = (qe & 15) << 12 | We << 6 | Vt : qe = (qe & 7) << 18 | We << 12 | Vt << 6 | G[oe++] & 63, qe < 65536)
+ _t += String.fromCharCode(qe);
else {
- var Qr = He - 65536;
- _t += String.fromCharCode(55296 | Qr >> 10, 56320 | Qr & 1023);
+ var Yr = qe - 65536;
+ _t += String.fromCharCode(55296 | Yr >> 10, 56320 | Yr & 1023);
}
}
return _t;
}
- function q(U, te) {
- return U ? G(ee, U, te) : "";
+ function q(G, oe) {
+ return G ? U(ee, G, oe) : "";
}
- function H(U, te, ve, Ke) {
- if (!(Ke > 0))
+ function H(G, oe, ke, je) {
+ if (!(je > 0))
return 0;
- for (var Nt = ve, _t = ve + Ke - 1, He = 0; He < U.length; ++He) {
- var ze = U.charCodeAt(He);
- if (ze >= 55296 && ze <= 57343) {
- var zt = U.charCodeAt(++He);
- ze = 65536 + ((ze & 1023) << 10) | zt & 1023;
+ for (var Tt = ke, _t = ke + je - 1, qe = 0; qe < G.length; ++qe) {
+ var We = G.charCodeAt(qe);
+ if (We >= 55296 && We <= 57343) {
+ var Vt = G.charCodeAt(++qe);
+ We = 65536 + ((We & 1023) << 10) | Vt & 1023;
}
- if (ze <= 127) {
- if (ve >= _t)
+ if (We <= 127) {
+ if (ke >= _t)
break;
- te[ve++] = ze;
- } else if (ze <= 2047) {
- if (ve + 1 >= _t)
+ oe[ke++] = We;
+ } else if (We <= 2047) {
+ if (ke + 1 >= _t)
break;
- te[ve++] = 192 | ze >> 6, te[ve++] = 128 | ze & 63;
- } else if (ze <= 65535) {
- if (ve + 2 >= _t)
+ oe[ke++] = 192 | We >> 6, oe[ke++] = 128 | We & 63;
+ } else if (We <= 65535) {
+ if (ke + 2 >= _t)
break;
- te[ve++] = 224 | ze >> 12, te[ve++] = 128 | ze >> 6 & 63, te[ve++] = 128 | ze & 63;
+ oe[ke++] = 224 | We >> 12, oe[ke++] = 128 | We >> 6 & 63, oe[ke++] = 128 | We & 63;
} else {
- if (ve + 3 >= _t)
+ if (ke + 3 >= _t)
break;
- te[ve++] = 240 | ze >> 18, te[ve++] = 128 | ze >> 12 & 63, te[ve++] = 128 | ze >> 6 & 63, te[ve++] = 128 | ze & 63;
+ oe[ke++] = 240 | We >> 18, oe[ke++] = 128 | We >> 12 & 63, oe[ke++] = 128 | We >> 6 & 63, oe[ke++] = 128 | We & 63;
}
}
- return te[ve] = 0, ve - Nt;
+ return oe[ke] = 0, ke - Tt;
}
- function j(U, te, ve) {
- return H(U, ee, te, ve);
+ function j(G, oe, ke) {
+ return H(G, ee, oe, ke);
}
- var Y, Z, ee, X, Q, se, ie, de, Ie;
- function Se(U) {
- Y = U, t10.HEAP8 = Z = new Int8Array(U), t10.HEAP16 = X = new Int16Array(U), t10.HEAP32 = se = new Int32Array(U), t10.HEAPU8 = ee = new Uint8Array(U), t10.HEAPU16 = Q = new Uint16Array(U), t10.HEAPU32 = ie = new Uint32Array(U), t10.HEAPF32 = de = new Float32Array(U), t10.HEAPF64 = Ie = new Float64Array(U);
+ var X, Z, ee, Y, J, ie, pe, he, we;
+ function ve(G) {
+ X = G, t6.HEAP8 = Z = new Int8Array(G), t6.HEAP16 = Y = new Int16Array(G), t6.HEAP32 = ie = new Int32Array(G), t6.HEAPU8 = ee = new Uint8Array(G), t6.HEAPU16 = J = new Uint16Array(G), t6.HEAPU32 = pe = new Uint32Array(G), t6.HEAPF32 = he = new Float32Array(G), t6.HEAPF64 = we = new Float64Array(G);
}
- var Ee = t10.INITIAL_MEMORY || 16777216, Me, st = [], pt = [], De = [], ft = false;
+ var $e = t6.INITIAL_MEMORY || 16777216, Le, nt = [], pt = [], Oe = [], mt = false;
function at() {
return D;
}
- function dt() {
- if (t10.preRun)
- for (typeof t10.preRun == "function" && (t10.preRun = [t10.preRun]); t10.preRun.length; )
- Pt(t10.preRun.shift());
- Js(st);
+ function ft() {
+ if (t6.preRun)
+ for (typeof t6.preRun == "function" && (t6.preRun = [t6.preRun]); t6.preRun.length; )
+ Ot(t6.preRun.shift());
+ ta(nt);
}
- function It() {
- ft = true, Js(pt);
+ function wt() {
+ mt = true, ta(pt);
}
function Fr() {
- if (t10.postRun)
- for (typeof t10.postRun == "function" && (t10.postRun = [t10.postRun]); t10.postRun.length; )
- er(t10.postRun.shift());
- Js(De);
+ if (t6.postRun)
+ for (typeof t6.postRun == "function" && (t6.postRun = [t6.postRun]); t6.postRun.length; )
+ er(t6.postRun.shift());
+ ta(Oe);
}
- function Pt(U) {
- st.unshift(U);
+ function Ot(G) {
+ nt.unshift(G);
}
- function jr(U) {
- pt.unshift(U);
+ function Kr(G) {
+ pt.unshift(G);
}
- function er(U) {
- De.unshift(U);
+ function er(G) {
+ Oe.unshift(G);
}
- var Tt = 0, tr = null, rr = null;
- function Xr(U) {
- Tt++, t10.monitorRunDependencies && t10.monitorRunDependencies(Tt);
+ var Nt = 0, tr = null, rr = null;
+ function jr(G) {
+ Nt++, t6.monitorRunDependencies && t6.monitorRunDependencies(Nt);
}
- function Yr(U) {
- if (Tt--, t10.monitorRunDependencies && t10.monitorRunDependencies(Tt), Tt == 0 && (tr !== null && (clearInterval(tr), tr = null), rr)) {
- var te = rr;
- rr = null, te();
+ function Xr(G) {
+ if (Nt--, t6.monitorRunDependencies && t6.monitorRunDependencies(Nt), Nt == 0 && (tr !== null && (clearInterval(tr), tr = null), rr)) {
+ var oe = rr;
+ rr = null, oe();
}
}
- function pr(U) {
- t10.onAbort && t10.onAbort(U), U = "Aborted(" + U + ")", E(U), M = true, L = 1, U += ". Build with -sASSERTIONS for more info.";
- var te = new WebAssembly.RuntimeError(U);
- throw n(te), te;
+ function pr(G) {
+ t6.onAbort && t6.onAbort(G), G = "Aborted(" + G + ")", $(G), M = true, L = 1, G += ". Build with -sASSERTIONS for more info.";
+ var oe = new WebAssembly.RuntimeError(G);
+ throw n(oe), oe;
}
- var Qs = "data:application/octet-stream;base64,";
- function tn(U) {
- return U.startsWith(Qs);
+ var Js = "data:application/octet-stream;base64,";
+ function Fo(G) {
+ return G.startsWith(Js);
}
- function Ua(U) {
- return U.startsWith("file://");
+ function Ka(G) {
+ return G.startsWith("file://");
}
- var jt;
- jt = "tfjs-backend-wasm.wasm", tn(jt) || (jt = d(jt));
- function Zs(U) {
+ var Kt;
+ Kt = "tfjs-backend-wasm.wasm", Fo(Kt) || (Kt = f(Kt));
+ function ea(G) {
try {
- if (U == jt && A)
- return new Uint8Array(A);
- if (y)
- return y(U);
+ if (G == Kt && R)
+ return new Uint8Array(R);
+ if (x)
+ return x(G);
throw "both async and sync fetching of the wasm failed";
- } catch (te) {
- pr(te);
+ } catch (oe) {
+ pr(oe);
}
}
- function Lc() {
- if (!A && (c || l)) {
- if (typeof fetch == "function" && !Ua(jt))
- return fetch(jt, { credentials: "same-origin" }).then(function(U) {
- if (!U.ok)
- throw "failed to load wasm binary file at '" + jt + "'";
- return U.arrayBuffer();
+ function Ac() {
+ if (!R && (c || l)) {
+ if (typeof fetch == "function" && !Ka(Kt))
+ return fetch(Kt, { credentials: "same-origin" }).then(function(G) {
+ if (!G.ok)
+ throw "failed to load wasm binary file at '" + Kt + "'";
+ return G.arrayBuffer();
}).catch(function() {
- return Zs(jt);
+ return ea(Kt);
});
if (g)
- return new Promise(function(U, te) {
- g(jt, function(ve) {
- U(new Uint8Array(ve));
- }, te);
+ return new Promise(function(G, oe) {
+ g(Kt, function(ke) {
+ G(new Uint8Array(ke));
+ }, oe);
});
}
return Promise.resolve().then(function() {
- return Zs(jt);
+ return ea(Kt);
});
}
- function Bc() {
- var U = { env: Wc, wasi_snapshot_preview1: Wc };
- function te(He, ze) {
- var zt = He.exports;
- t10.asm = zt, O = t10.asm.memory, Se(O.buffer), Me = t10.asm.__indirect_function_table, jr(t10.asm.__wasm_call_ctors), Yr("wasm-instantiate");
+ function Rc() {
+ var G = { env: Oc, wasi_snapshot_preview1: Oc };
+ function oe(qe, We) {
+ var Vt = qe.exports;
+ t6.asm = Vt, P = t6.asm.memory, ve(P.buffer), Le = t6.asm.__indirect_function_table, Kr(t6.asm.__wasm_call_ctors), Xr("wasm-instantiate");
}
- Xr("wasm-instantiate");
- function ve(He) {
- te(He.instance);
+ jr("wasm-instantiate");
+ function ke(qe) {
+ oe(qe.instance);
}
- function Ke(He) {
- return Lc().then(function(ze) {
- return WebAssembly.instantiate(ze, U);
- }).then(function(ze) {
- return ze;
- }).then(He, function(ze) {
- E("failed to asynchronously prepare wasm: " + ze), pr(ze);
+ function je(qe) {
+ return Ac().then(function(We) {
+ return WebAssembly.instantiate(We, G);
+ }).then(function(We) {
+ return We;
+ }).then(qe, function(We) {
+ $("failed to asynchronously prepare wasm: " + We), pr(We);
});
}
- function Nt() {
- return !A && typeof WebAssembly.instantiateStreaming == "function" && !tn(jt) && !Ua(jt) && !m && typeof fetch == "function" ? fetch(jt, { credentials: "same-origin" }).then(function(He) {
- var ze = WebAssembly.instantiateStreaming(He, U);
- return ze.then(ve, function(zt) {
- return E("wasm streaming compile failed: " + zt), E("falling back to ArrayBuffer instantiation"), Ke(ve);
+ function Tt() {
+ return !R && typeof WebAssembly.instantiateStreaming == "function" && !Fo(Kt) && !Ka(Kt) && !m && typeof fetch == "function" ? fetch(Kt, { credentials: "same-origin" }).then(function(qe) {
+ var We = WebAssembly.instantiateStreaming(qe, G);
+ return We.then(ke, function(Vt) {
+ return $("wasm streaming compile failed: " + Vt), $("falling back to ArrayBuffer instantiation"), je(ke);
});
- }) : Ke(ve);
+ }) : je(ke);
}
- if (t10.instantiateWasm)
+ if (t6.instantiateWasm)
try {
- var _t = t10.instantiateWasm(U, te);
+ var _t = t6.instantiateWasm(G, oe);
return _t;
- } catch (He) {
- E("Module.instantiateWasm callback failed with error: " + He), n(He);
+ } catch (qe) {
+ $("Module.instantiateWasm callback failed with error: " + qe), n(qe);
}
- return Nt().catch(n), {};
+ return Tt().catch(n), {};
}
- var KS, Ga;
- function ju(U) {
- this.name = "ExitStatus", this.message = "Program terminated with exit(" + U + ")", this.status = U;
+ var SI, ja;
+ function ju(G) {
+ this.name = "ExitStatus", this.message = "Program terminated with exit(" + G + ")", this.status = G;
}
- function Js(U) {
- for (; U.length > 0; )
- U.shift()(t10);
+ function ta(G) {
+ for (; G.length > 0; )
+ G.shift()(t6);
}
- function jS(U) {
- return U;
+ function wI(G) {
+ return G;
}
- function XS(U) {
- var te = /\b_Z[\w\d_]+/g;
- return U.replace(te, function(ve) {
- var Ke = ve;
- return ve === Ke ? ve : Ke + " [" + ve + "]";
+ function II(G) {
+ var oe = /\b_Z[\w\d_]+/g;
+ return G.replace(oe, function(ke) {
+ var je = ke;
+ return ke === je ? ke : je + " [" + ke + "]";
});
}
function Xu() {
- var U = new Error();
- if (!U.stack) {
+ var G = new Error();
+ if (!G.stack) {
try {
throw new Error();
- } catch (te) {
- U = te;
+ } catch (oe) {
+ G = oe;
}
- if (!U.stack)
+ if (!G.stack)
return "(no stack trace available)";
}
- return U.stack.toString();
+ return G.stack.toString();
}
- function $x(U, te) {
- Z.set(U, te);
+ function Ix(G, oe) {
+ Z.set(G, oe);
}
- function nm() {
+ function jl() {
pr("");
}
- function Vc() {
+ function Fc() {
return 2147483648;
}
- function dr() {
- return Vc();
+ function fr() {
+ return Fc();
}
- function sm(U, te, ve) {
- ee.copyWithin(U, te, te + ve);
+ function Xl(G, oe, ke) {
+ ee.copyWithin(G, oe, oe + ke);
}
- function Rx(U) {
+ function vx(G) {
try {
- return O.grow(U - Y.byteLength + 65535 >>> 16), Se(O.buffer), 1;
- } catch (te) {
+ return P.grow(G - X.byteLength + 65535 >>> 16), ve(P.buffer), 1;
+ } catch (oe) {
}
}
- function Ax(U) {
- var te = ee.length;
- U = U >>> 0;
- var ve = Vc();
- if (U > ve)
+ function kx(G) {
+ var oe = ee.length;
+ G = G >>> 0;
+ var ke = Fc();
+ if (G > ke)
return false;
- let Ke = (zt, Qr) => zt + (Qr - zt % Qr) % Qr;
- for (var Nt = 1; Nt <= 4; Nt *= 2) {
- var _t = te * (1 + 0.2 / Nt);
- _t = Math.min(_t, U + 100663296);
- var He = Math.min(ve, Ke(Math.max(U, _t), 65536)), ze = Rx(He);
- if (ze)
+ let je = (Vt, Yr) => Vt + (Yr - Vt % Yr) % Yr;
+ for (var Tt = 1; Tt <= 4; Tt *= 2) {
+ var _t = oe * (1 + 0.2 / Tt);
+ _t = Math.min(_t, G + 100663296);
+ var qe = Math.min(ke, je(Math.max(G, _t), 65536)), We = vx(qe);
+ if (We)
return true;
}
return false;
}
- var Fx = { varargs: void 0, get: function() {
- Fx.varargs += 4;
- var U = se[Fx.varargs - 4 >> 2];
- return U;
- }, getStr: function(U) {
- var te = q(U);
- return te;
+ var Nx = { varargs: void 0, get: function() {
+ Nx.varargs += 4;
+ var G = ie[Nx.varargs - 4 >> 2];
+ return G;
+ }, getStr: function(G) {
+ var oe = q(G);
+ return oe;
} };
- function YS(U) {
+ function vI(G) {
return 52;
}
- function Dx(U, te, ve, Ke, Nt) {
+ function Tx(G, oe, ke, je, Tt) {
return 70;
}
- var Di = [null, [], []];
- function Px(U, te) {
- var ve = Di[U];
- te === 0 || te === 10 ? ((U === 1 ? _ : E)(G(ve, 0)), ve.length = 0) : ve.push(te);
+ var Hi = [null, [], []];
+ function _x(G, oe) {
+ var ke = Hi[G];
+ oe === 0 || oe === 10 ? ((G === 1 ? _ : $)(U(ke, 0)), ke.length = 0) : ke.push(oe);
}
- function Ox(U, te, ve, Ke) {
- for (var Nt = 0, _t = 0; _t < ve; _t++) {
- var He = ie[te >> 2], ze = ie[te + 4 >> 2];
- te += 8;
- for (var zt = 0; zt < ze; zt++)
- Px(U, ee[He + zt]);
- Nt += ze;
+ function Ex(G, oe, ke, je) {
+ for (var Tt = 0, _t = 0; _t < ke; _t++) {
+ var qe = pe[oe >> 2], We = pe[oe + 4 >> 2];
+ oe += 8;
+ for (var Vt = 0; Vt < We; Vt++)
+ _x(G, ee[qe + Vt]);
+ Tt += We;
}
- return ie[Ke >> 2] = Nt, 0;
+ return pe[je >> 2] = Tt, 0;
}
- function zc(U) {
- var te = t10["_" + U];
- return te;
+ function Dc(G) {
+ var oe = t6["_" + G];
+ return oe;
}
- function am(U, te, ve, Ke, Nt) {
+ function Yl(G, oe, ke, je, Tt) {
var _t = { string: (hr) => {
- var qa = 0;
+ var Ya = 0;
if (hr != null && hr !== 0) {
- var wm = (hr.length << 2) + 1;
- qa = qc(wm), j(hr, qa, wm);
+ var mm = (hr.length << 2) + 1;
+ Ya = Bc(mm), j(hr, Ya, mm);
}
- return qa;
+ return Ya;
}, array: (hr) => {
- var qa = qc(hr.length);
- return $x(hr, qa), qa;
+ var Ya = Bc(hr.length);
+ return Ix(hr, Ya), Ya;
} };
- function He(hr) {
- return te === "string" ? q(hr) : te === "boolean" ? Boolean(hr) : hr;
+ function qe(hr) {
+ return oe === "string" ? q(hr) : oe === "boolean" ? Boolean(hr) : hr;
}
- var ze = zc(U), zt = [], Qr = 0;
- if (Ke)
- for (var ea = 0; ea < Ke.length; ea++) {
- var Im = _t[ve[ea]];
- Im ? (Qr === 0 && (Qr = ym()), zt[ea] = Im(Ke[ea])) : zt[ea] = Ke[ea];
+ var We = Dc(G), Vt = [], Yr = 0;
+ if (je)
+ for (var ra = 0; ra < je.length; ra++) {
+ var lm = _t[ke[ra]];
+ lm ? (Yr === 0 && (Yr = um()), Vt[ra] = lm(je[ra])) : Vt[ra] = je[ra];
}
- var Kc = ze.apply(null, zt);
- function pb(hr) {
- return Qr !== 0 && bm(Qr), He(hr);
+ var Vc = We.apply(null, Vt);
+ function nb(hr) {
+ return Yr !== 0 && pm(Yr), qe(hr);
}
- return Kc = pb(Kc), Kc;
+ return Vc = nb(Vc), Vc;
}
- function im(U, te, ve, Ke) {
- ve = ve || [];
- var Nt = ve.every((He) => He === "number" || He === "boolean"), _t = te !== "string";
- return _t && Nt && !Ke ? zc(U) : function() {
- return am(U, te, ve, arguments, Ke);
+ function Ql(G, oe, ke, je) {
+ ke = ke || [];
+ var Tt = ke.every((qe) => qe === "number" || qe === "boolean"), _t = oe !== "string";
+ return _t && Tt && !je ? Dc(G) : function() {
+ return Yl(G, oe, ke, arguments, je);
};
}
- var Wc = { abort: nm, emscripten_get_heap_max: dr, emscripten_memcpy_big: sm, emscripten_resize_heap: Ax, fd_close: YS, fd_seek: Dx, fd_write: Ox }, QS = Bc(), um = t10.___wasm_call_ctors = function() {
- return (um = t10.___wasm_call_ctors = t10.asm.__wasm_call_ctors).apply(null, arguments);
- }, Mx = t10._init = function() {
- return (Mx = t10._init = t10.asm.init).apply(null, arguments);
- }, Fe = t10._init_with_threads_count = function() {
- return (Fe = t10._init_with_threads_count = t10.asm.init_with_threads_count).apply(null, arguments);
- }, Uc = t10._get_threads_count = function() {
- return (Uc = t10._get_threads_count = t10.asm.get_threads_count).apply(null, arguments);
- }, Lx = t10._register_tensor = function() {
- return (Lx = t10._register_tensor = t10.asm.register_tensor).apply(null, arguments);
- }, ZS = t10._dispose_data = function() {
- return (ZS = t10._dispose_data = t10.asm.dispose_data).apply(null, arguments);
- }, JS = t10._dispose = function() {
- return (JS = t10._dispose = t10.asm.dispose).apply(null, arguments);
- }, Bx = t10._Abs = function() {
- return (Bx = t10._Abs = t10.asm.Abs).apply(null, arguments);
- }, pm = t10._Add = function() {
- return (pm = t10._Add = t10.asm.Add).apply(null, arguments);
- }, Yu = t10._AddN = function() {
- return (Yu = t10._AddN = t10.asm.AddN).apply(null, arguments);
- }, Vx = t10._All = function() {
- return (Vx = t10._All = t10.asm.All).apply(null, arguments);
- }, zx = t10._Any = function() {
- return (zx = t10._Any = t10.asm.Any).apply(null, arguments);
- }, e0 = t10._ArgMax = function() {
- return (e0 = t10._ArgMax = t10.asm.ArgMax).apply(null, arguments);
- }, Wx = t10._AvgPool = function() {
- return (Wx = t10._AvgPool = t10.asm.AvgPool).apply(null, arguments);
- }, Ux = t10._BatchMatMul = function() {
- return (Ux = t10._BatchMatMul = t10.asm.BatchMatMul).apply(null, arguments);
- }, Gx = t10._Ceil = function() {
- return (Gx = t10._Ceil = t10.asm.Ceil).apply(null, arguments);
- }, Hx = t10._ClipByValue = function() {
- return (Hx = t10._ClipByValue = t10.asm.ClipByValue).apply(null, arguments);
- }, cm = t10._Conv2D = function() {
- return (cm = t10._Conv2D = t10.asm.Conv2D).apply(null, arguments);
- }, lm = t10._Conv2DBackpropInput = function() {
- return (lm = t10._Conv2DBackpropInput = t10.asm.Conv2DBackpropInput).apply(null, arguments);
- }, qx = t10._Cos = function() {
- return (qx = t10._Cos = t10.asm.Cos).apply(null, arguments);
- }, Kx = t10._Cosh = function() {
- return (Kx = t10._Cosh = t10.asm.Cosh).apply(null, arguments);
- }, jx = t10._CropAndResize = function() {
- return (jx = t10._CropAndResize = t10.asm.CropAndResize).apply(null, arguments);
- }, Gc = t10._Cumprod = function() {
- return (Gc = t10._Cumprod = t10.asm.Cumprod).apply(null, arguments);
- }, Xx = t10._Cumsum = function() {
- return (Xx = t10._Cumsum = t10.asm.Cumsum).apply(null, arguments);
- }, Yx = t10._DepthToSpace = function() {
- return (Yx = t10._DepthToSpace = t10.asm.DepthToSpace).apply(null, arguments);
- }, Qx = t10._DepthwiseConv2dNative = function() {
- return (Qx = t10._DepthwiseConv2dNative = t10.asm.DepthwiseConv2dNative).apply(null, arguments);
- }, Pi = t10._Elu = function() {
- return (Pi = t10._Elu = t10.asm.Elu).apply(null, arguments);
- }, Zx = t10._Equal = function() {
- return (Zx = t10._Equal = t10.asm.Equal).apply(null, arguments);
- }, Jx = t10._Exp = function() {
- return (Jx = t10._Exp = t10.asm.Exp).apply(null, arguments);
- }, mm = t10._FlipLeftRight = function() {
- return (mm = t10._FlipLeftRight = t10.asm.FlipLeftRight).apply(null, arguments);
- }, ey = t10._Floor = function() {
- return (ey = t10._Floor = t10.asm.Floor).apply(null, arguments);
- }, Qu = t10._FloorDiv = function() {
- return (Qu = t10._FloorDiv = t10.asm.FloorDiv).apply(null, arguments);
- }, ty = t10._FusedBatchNorm = function() {
- return (ty = t10._FusedBatchNorm = t10.asm.FusedBatchNorm).apply(null, arguments);
- }, ry = t10._FusedConv2D = function() {
- return (ry = t10._FusedConv2D = t10.asm.FusedConv2D).apply(null, arguments);
- }, Ha = t10._FusedDepthwiseConv2D = function() {
- return (Ha = t10._FusedDepthwiseConv2D = t10.asm.FusedDepthwiseConv2D).apply(null, arguments);
- }, Hc = t10._Gather = function() {
- return (Hc = t10._Gather = t10.asm.Gather).apply(null, arguments);
- }, oy = t10._GatherNd = function() {
- return (oy = t10._GatherNd = t10.asm.GatherNd).apply(null, arguments);
- }, ny = t10._Greater = function() {
- return (ny = t10._Greater = t10.asm.Greater).apply(null, arguments);
- }, sy = t10._GreaterEqual = function() {
- return (sy = t10._GreaterEqual = t10.asm.GreaterEqual).apply(null, arguments);
- }, ay = t10._LeakyRelu = function() {
- return (ay = t10._LeakyRelu = t10.asm.LeakyRelu).apply(null, arguments);
- }, fm = t10._Less = function() {
- return (fm = t10._Less = t10.asm.Less).apply(null, arguments);
- }, dm = t10._LessEqual = function() {
- return (dm = t10._LessEqual = t10.asm.LessEqual).apply(null, arguments);
- }, iy = t10._Log = function() {
- return (iy = t10._Log = t10.asm.Log).apply(null, arguments);
- }, uy = t10._LogicalAnd = function() {
- return (uy = t10._LogicalAnd = t10.asm.LogicalAnd).apply(null, arguments);
- }, hm = t10._LogicalNot = function() {
- return (hm = t10._LogicalNot = t10.asm.LogicalNot).apply(null, arguments);
- }, gm = t10._LogicalOr = function() {
- return (gm = t10._LogicalOr = t10.asm.LogicalOr).apply(null, arguments);
- }, py = t10._LogicalXor = function() {
- return (py = t10._LogicalXor = t10.asm.LogicalXor).apply(null, arguments);
- }, cy = t10._Max = function() {
- return (cy = t10._Max = t10.asm.Max).apply(null, arguments);
- }, ly = t10._MaxPool = function() {
- return (ly = t10._MaxPool = t10.asm.MaxPool).apply(null, arguments);
- }, xm = t10._Maximum = function() {
- return (xm = t10._Maximum = t10.asm.Maximum).apply(null, arguments);
- }, t0 = t10._Mean = function() {
- return (t0 = t10._Mean = t10.asm.Mean).apply(null, arguments);
- }, my = t10._Min = function() {
- return (my = t10._Min = t10.asm.Min).apply(null, arguments);
- }, fy = t10._Minimum = function() {
- return (fy = t10._Minimum = t10.asm.Minimum).apply(null, arguments);
- }, dy = t10._MirrorPad = function() {
- return (dy = t10._MirrorPad = t10.asm.MirrorPad).apply(null, arguments);
- }, hy = t10._Multiply = function() {
- return (hy = t10._Multiply = t10.asm.Multiply).apply(null, arguments);
- }, gy = t10._Neg = function() {
- return (gy = t10._Neg = t10.asm.Neg).apply(null, arguments);
- }, xy = t10._NonMaxSuppressionV3 = function() {
- return (xy = t10._NonMaxSuppressionV3 = t10.asm.NonMaxSuppressionV3).apply(null, arguments);
- }, yy = t10._NonMaxSuppressionV4 = function() {
- return (yy = t10._NonMaxSuppressionV4 = t10.asm.NonMaxSuppressionV4).apply(null, arguments);
- }, by = t10._NonMaxSuppressionV5 = function() {
- return (by = t10._NonMaxSuppressionV5 = t10.asm.NonMaxSuppressionV5).apply(null, arguments);
- }, Cy = t10._NotEqual = function() {
- return (Cy = t10._NotEqual = t10.asm.NotEqual).apply(null, arguments);
- }, Iy = t10._OneHot = function() {
- return (Iy = t10._OneHot = t10.asm.OneHot).apply(null, arguments);
- }, wy = t10._PadV2 = function() {
- return (wy = t10._PadV2 = t10.asm.PadV2).apply(null, arguments);
- }, Sy = t10._Pow = function() {
- return (Sy = t10._Pow = t10.asm.Pow).apply(null, arguments);
- }, vy = t10._Prelu = function() {
- return (vy = t10._Prelu = t10.asm.Prelu).apply(null, arguments);
- }, ky = t10._Prod = function() {
- return (ky = t10._Prod = t10.asm.Prod).apply(null, arguments);
- }, Ty = t10._RealDiv = function() {
- return (Ty = t10._RealDiv = t10.asm.RealDiv).apply(null, arguments);
- }, Ny = t10._Relu = function() {
- return (Ny = t10._Relu = t10.asm.Relu).apply(null, arguments);
- }, _y = t10._Relu6 = function() {
- return (_y = t10._Relu6 = t10.asm.Relu6).apply(null, arguments);
- }, Ey = t10._ResizeBilinear = function() {
- return (Ey = t10._ResizeBilinear = t10.asm.ResizeBilinear).apply(null, arguments);
- }, $y = t10._ResizeNearestNeighbor = function() {
- return ($y = t10._ResizeNearestNeighbor = t10.asm.ResizeNearestNeighbor).apply(null, arguments);
- }, Ry = t10._Reverse = function() {
- return (Ry = t10._Reverse = t10.asm.Reverse).apply(null, arguments);
- }, Ay = t10._RotateWithOffset = function() {
- return (Ay = t10._RotateWithOffset = t10.asm.RotateWithOffset).apply(null, arguments);
- }, Fy = t10._Round = function() {
- return (Fy = t10._Round = t10.asm.Round).apply(null, arguments);
- }, Dy = t10._Rsqrt = function() {
- return (Dy = t10._Rsqrt = t10.asm.Rsqrt).apply(null, arguments);
- }, Py = t10._ScatterNd = function() {
- return (Py = t10._ScatterNd = t10.asm.ScatterNd).apply(null, arguments);
- }, Oy = t10._SelectV2 = function() {
- return (Oy = t10._SelectV2 = t10.asm.SelectV2).apply(null, arguments);
- }, My = t10._Sigmoid = function() {
- return (My = t10._Sigmoid = t10.asm.Sigmoid).apply(null, arguments);
- }, Ly = t10._Sin = function() {
- return (Ly = t10._Sin = t10.asm.Sin).apply(null, arguments);
- }, By = t10._Softmax = function() {
- return (By = t10._Softmax = t10.asm.Softmax).apply(null, arguments);
- }, Vy = t10._SparseFillEmptyRows = function() {
- return (Vy = t10._SparseFillEmptyRows = t10.asm.SparseFillEmptyRows).apply(null, arguments);
- }, zy = t10._SparseReshape = function() {
- return (zy = t10._SparseReshape = t10.asm.SparseReshape).apply(null, arguments);
- }, Wy = t10._SparseSegmentReduction = function() {
- return (Wy = t10._SparseSegmentReduction = t10.asm.SparseSegmentReduction).apply(null, arguments);
- }, Uy = t10._Sqrt = function() {
- return (Uy = t10._Sqrt = t10.asm.Sqrt).apply(null, arguments);
- }, Gy = t10._Square = function() {
- return (Gy = t10._Square = t10.asm.Square).apply(null, arguments);
- }, Hy = t10._SquaredDifference = function() {
- return (Hy = t10._SquaredDifference = t10.asm.SquaredDifference).apply(null, arguments);
- }, qy = t10._Step = function() {
- return (qy = t10._Step = t10.asm.Step).apply(null, arguments);
- }, Ky = t10._StridedSlice = function() {
- return (Ky = t10._StridedSlice = t10.asm.StridedSlice).apply(null, arguments);
- }, jy = t10._Sub = function() {
- return (jy = t10._Sub = t10.asm.Sub).apply(null, arguments);
- }, Xy = t10._Sum = function() {
- return (Xy = t10._Sum = t10.asm.Sum).apply(null, arguments);
- }, Yy = t10._Tan = function() {
- return (Yy = t10._Tan = t10.asm.Tan).apply(null, arguments);
- }, Qy = t10._Tanh = function() {
- return (Qy = t10._Tanh = t10.asm.Tanh).apply(null, arguments);
- }, Zy = t10._Tile = function() {
- return (Zy = t10._Tile = t10.asm.Tile).apply(null, arguments);
- }, Jy = t10._TopK = function() {
- return (Jy = t10._TopK = t10.asm.TopK).apply(null, arguments);
- }, eb = t10._Transform = function() {
- return (eb = t10._Transform = t10.asm.Transform).apply(null, arguments);
- }, tb = t10._Transpose = function() {
- return (tb = t10._Transpose = t10.asm.Transpose).apply(null, arguments);
- }, rb = t10.__FusedMatMul = function() {
- return (rb = t10.__FusedMatMul = t10.asm._FusedMatMul).apply(null, arguments);
- }, ob = t10._malloc = function() {
- return (ob = t10._malloc = t10.asm.malloc).apply(null, arguments);
- }, nb = t10._free = function() {
- return (nb = t10._free = t10.asm.free).apply(null, arguments);
- }, sb = t10.___errno_location = function() {
- return (sb = t10.___errno_location = t10.asm.__errno_location).apply(null, arguments);
- }, ym = t10.stackSave = function() {
- return (ym = t10.stackSave = t10.asm.stackSave).apply(null, arguments);
- }, bm = t10.stackRestore = function() {
- return (bm = t10.stackRestore = t10.asm.stackRestore).apply(null, arguments);
- }, qc = t10.stackAlloc = function() {
- return (qc = t10.stackAlloc = t10.asm.stackAlloc).apply(null, arguments);
- }, ab = t10.dynCall_iijjiiii = function() {
- return (ab = t10.dynCall_iijjiiii = t10.asm.dynCall_iijjiiii).apply(null, arguments);
- }, ib = t10.dynCall_jiji = function() {
- return (ib = t10.dynCall_jiji = t10.asm.dynCall_jiji).apply(null, arguments);
+ var Oc = { abort: jl, emscripten_get_heap_max: fr, emscripten_memcpy_big: Xl, emscripten_resize_heap: kx, fd_close: vI, fd_seek: Tx, fd_write: Ex }, kI = Rc(), Zl = t6.___wasm_call_ctors = function() {
+ return (Zl = t6.___wasm_call_ctors = t6.asm.__wasm_call_ctors).apply(null, arguments);
+ }, $x = t6._init = function() {
+ return ($x = t6._init = t6.asm.init).apply(null, arguments);
+ }, De = t6._init_with_threads_count = function() {
+ return (De = t6._init_with_threads_count = t6.asm.init_with_threads_count).apply(null, arguments);
+ }, Pc = t6._get_threads_count = function() {
+ return (Pc = t6._get_threads_count = t6.asm.get_threads_count).apply(null, arguments);
+ }, Ax = t6._register_tensor = function() {
+ return (Ax = t6._register_tensor = t6.asm.register_tensor).apply(null, arguments);
+ }, NI = t6._dispose_data = function() {
+ return (NI = t6._dispose_data = t6.asm.dispose_data).apply(null, arguments);
+ }, TI = t6._dispose = function() {
+ return (TI = t6._dispose = t6.asm.dispose).apply(null, arguments);
+ }, Rx = t6._Abs = function() {
+ return (Rx = t6._Abs = t6.asm.Abs).apply(null, arguments);
+ }, Jl = t6._Add = function() {
+ return (Jl = t6._Add = t6.asm.Add).apply(null, arguments);
+ }, Yu = t6._AddN = function() {
+ return (Yu = t6._AddN = t6.asm.AddN).apply(null, arguments);
+ }, Fx = t6._All = function() {
+ return (Fx = t6._All = t6.asm.All).apply(null, arguments);
+ }, Dx = t6._Any = function() {
+ return (Dx = t6._Any = t6.asm.Any).apply(null, arguments);
+ }, _I = t6._ArgMax = function() {
+ return (_I = t6._ArgMax = t6.asm.ArgMax).apply(null, arguments);
+ }, Ox = t6._AvgPool = function() {
+ return (Ox = t6._AvgPool = t6.asm.AvgPool).apply(null, arguments);
+ }, Px = t6._BatchMatMul = function() {
+ return (Px = t6._BatchMatMul = t6.asm.BatchMatMul).apply(null, arguments);
+ }, Mx = t6._Ceil = function() {
+ return (Mx = t6._Ceil = t6.asm.Ceil).apply(null, arguments);
+ }, Lx = t6._ClipByValue = function() {
+ return (Lx = t6._ClipByValue = t6.asm.ClipByValue).apply(null, arguments);
+ }, em = t6._Conv2D = function() {
+ return (em = t6._Conv2D = t6.asm.Conv2D).apply(null, arguments);
+ }, tm = t6._Conv2DBackpropInput = function() {
+ return (tm = t6._Conv2DBackpropInput = t6.asm.Conv2DBackpropInput).apply(null, arguments);
+ }, Bx = t6._Cos = function() {
+ return (Bx = t6._Cos = t6.asm.Cos).apply(null, arguments);
+ }, Vx = t6._Cosh = function() {
+ return (Vx = t6._Cosh = t6.asm.Cosh).apply(null, arguments);
+ }, zx = t6._CropAndResize = function() {
+ return (zx = t6._CropAndResize = t6.asm.CropAndResize).apply(null, arguments);
+ }, Mc = t6._Cumprod = function() {
+ return (Mc = t6._Cumprod = t6.asm.Cumprod).apply(null, arguments);
+ }, Wx = t6._Cumsum = function() {
+ return (Wx = t6._Cumsum = t6.asm.Cumsum).apply(null, arguments);
+ }, Ux = t6._DepthToSpace = function() {
+ return (Ux = t6._DepthToSpace = t6.asm.DepthToSpace).apply(null, arguments);
+ }, Gx = t6._DepthwiseConv2dNative = function() {
+ return (Gx = t6._DepthwiseConv2dNative = t6.asm.DepthwiseConv2dNative).apply(null, arguments);
+ }, qi = t6._Elu = function() {
+ return (qi = t6._Elu = t6.asm.Elu).apply(null, arguments);
+ }, Hx = t6._Equal = function() {
+ return (Hx = t6._Equal = t6.asm.Equal).apply(null, arguments);
+ }, qx = t6._Exp = function() {
+ return (qx = t6._Exp = t6.asm.Exp).apply(null, arguments);
+ }, rm = t6._FlipLeftRight = function() {
+ return (rm = t6._FlipLeftRight = t6.asm.FlipLeftRight).apply(null, arguments);
+ }, Kx = t6._Floor = function() {
+ return (Kx = t6._Floor = t6.asm.Floor).apply(null, arguments);
+ }, Qu = t6._FloorDiv = function() {
+ return (Qu = t6._FloorDiv = t6.asm.FloorDiv).apply(null, arguments);
+ }, jx = t6._FusedBatchNorm = function() {
+ return (jx = t6._FusedBatchNorm = t6.asm.FusedBatchNorm).apply(null, arguments);
+ }, Xx = t6._FusedConv2D = function() {
+ return (Xx = t6._FusedConv2D = t6.asm.FusedConv2D).apply(null, arguments);
+ }, Xa = t6._FusedDepthwiseConv2D = function() {
+ return (Xa = t6._FusedDepthwiseConv2D = t6.asm.FusedDepthwiseConv2D).apply(null, arguments);
+ }, Lc = t6._Gather = function() {
+ return (Lc = t6._Gather = t6.asm.Gather).apply(null, arguments);
+ }, Yx = t6._GatherNd = function() {
+ return (Yx = t6._GatherNd = t6.asm.GatherNd).apply(null, arguments);
+ }, Qx = t6._Greater = function() {
+ return (Qx = t6._Greater = t6.asm.Greater).apply(null, arguments);
+ }, Zx = t6._GreaterEqual = function() {
+ return (Zx = t6._GreaterEqual = t6.asm.GreaterEqual).apply(null, arguments);
+ }, Jx = t6._IsNan = function() {
+ return (Jx = t6._IsNan = t6.asm.IsNan).apply(null, arguments);
+ }, om = t6._LeakyRelu = function() {
+ return (om = t6._LeakyRelu = t6.asm.LeakyRelu).apply(null, arguments);
+ }, nm = t6._Less = function() {
+ return (nm = t6._Less = t6.asm.Less).apply(null, arguments);
+ }, ey = t6._LessEqual = function() {
+ return (ey = t6._LessEqual = t6.asm.LessEqual).apply(null, arguments);
+ }, ty = t6._Log = function() {
+ return (ty = t6._Log = t6.asm.Log).apply(null, arguments);
+ }, sm = t6._LogicalAnd = function() {
+ return (sm = t6._LogicalAnd = t6.asm.LogicalAnd).apply(null, arguments);
+ }, am = t6._LogicalNot = function() {
+ return (am = t6._LogicalNot = t6.asm.LogicalNot).apply(null, arguments);
+ }, ry = t6._LogicalOr = function() {
+ return (ry = t6._LogicalOr = t6.asm.LogicalOr).apply(null, arguments);
+ }, oy = t6._LogicalXor = function() {
+ return (oy = t6._LogicalXor = t6.asm.LogicalXor).apply(null, arguments);
+ }, ny = t6._Max = function() {
+ return (ny = t6._Max = t6.asm.Max).apply(null, arguments);
+ }, im = t6._MaxPool = function() {
+ return (im = t6._MaxPool = t6.asm.MaxPool).apply(null, arguments);
+ }, EI = t6._Maximum = function() {
+ return (EI = t6._Maximum = t6.asm.Maximum).apply(null, arguments);
+ }, sy = t6._Mean = function() {
+ return (sy = t6._Mean = t6.asm.Mean).apply(null, arguments);
+ }, ay = t6._Min = function() {
+ return (ay = t6._Min = t6.asm.Min).apply(null, arguments);
+ }, iy = t6._Minimum = function() {
+ return (iy = t6._Minimum = t6.asm.Minimum).apply(null, arguments);
+ }, uy = t6._MirrorPad = function() {
+ return (uy = t6._MirrorPad = t6.asm.MirrorPad).apply(null, arguments);
+ }, py = t6._Multiply = function() {
+ return (py = t6._Multiply = t6.asm.Multiply).apply(null, arguments);
+ }, cy = t6._Neg = function() {
+ return (cy = t6._Neg = t6.asm.Neg).apply(null, arguments);
+ }, ly = t6._NonMaxSuppressionV3 = function() {
+ return (ly = t6._NonMaxSuppressionV3 = t6.asm.NonMaxSuppressionV3).apply(null, arguments);
+ }, my = t6._NonMaxSuppressionV4 = function() {
+ return (my = t6._NonMaxSuppressionV4 = t6.asm.NonMaxSuppressionV4).apply(null, arguments);
+ }, dy = t6._NonMaxSuppressionV5 = function() {
+ return (dy = t6._NonMaxSuppressionV5 = t6.asm.NonMaxSuppressionV5).apply(null, arguments);
+ }, fy = t6._NotEqual = function() {
+ return (fy = t6._NotEqual = t6.asm.NotEqual).apply(null, arguments);
+ }, hy = t6._OneHot = function() {
+ return (hy = t6._OneHot = t6.asm.OneHot).apply(null, arguments);
+ }, gy = t6._PadV2 = function() {
+ return (gy = t6._PadV2 = t6.asm.PadV2).apply(null, arguments);
+ }, xy = t6._Pow = function() {
+ return (xy = t6._Pow = t6.asm.Pow).apply(null, arguments);
+ }, yy = t6._Prelu = function() {
+ return (yy = t6._Prelu = t6.asm.Prelu).apply(null, arguments);
+ }, by = t6._Prod = function() {
+ return (by = t6._Prod = t6.asm.Prod).apply(null, arguments);
+ }, Cy = t6._RealDiv = function() {
+ return (Cy = t6._RealDiv = t6.asm.RealDiv).apply(null, arguments);
+ }, Sy = t6._Reciprocal = function() {
+ return (Sy = t6._Reciprocal = t6.asm.Reciprocal).apply(null, arguments);
+ }, wy = t6._Relu = function() {
+ return (wy = t6._Relu = t6.asm.Relu).apply(null, arguments);
+ }, Iy = t6._Relu6 = function() {
+ return (Iy = t6._Relu6 = t6.asm.Relu6).apply(null, arguments);
+ }, vy = t6._ResizeBilinear = function() {
+ return (vy = t6._ResizeBilinear = t6.asm.ResizeBilinear).apply(null, arguments);
+ }, ky = t6._ResizeNearestNeighbor = function() {
+ return (ky = t6._ResizeNearestNeighbor = t6.asm.ResizeNearestNeighbor).apply(null, arguments);
+ }, Ny = t6._Reverse = function() {
+ return (Ny = t6._Reverse = t6.asm.Reverse).apply(null, arguments);
+ }, Ty = t6._RotateWithOffset = function() {
+ return (Ty = t6._RotateWithOffset = t6.asm.RotateWithOffset).apply(null, arguments);
+ }, _y = t6._Round = function() {
+ return (_y = t6._Round = t6.asm.Round).apply(null, arguments);
+ }, Ey = t6._Rsqrt = function() {
+ return (Ey = t6._Rsqrt = t6.asm.Rsqrt).apply(null, arguments);
+ }, $y = t6._ScatterNd = function() {
+ return ($y = t6._ScatterNd = t6.asm.ScatterNd).apply(null, arguments);
+ }, Ay = t6._SelectV2 = function() {
+ return (Ay = t6._SelectV2 = t6.asm.SelectV2).apply(null, arguments);
+ }, Ry = t6._Sigmoid = function() {
+ return (Ry = t6._Sigmoid = t6.asm.Sigmoid).apply(null, arguments);
+ }, Fy = t6._Sin = function() {
+ return (Fy = t6._Sin = t6.asm.Sin).apply(null, arguments);
+ }, Dy = t6._Softmax = function() {
+ return (Dy = t6._Softmax = t6.asm.Softmax).apply(null, arguments);
+ }, Oy = t6._SparseFillEmptyRows = function() {
+ return (Oy = t6._SparseFillEmptyRows = t6.asm.SparseFillEmptyRows).apply(null, arguments);
+ }, Py = t6._SparseReshape = function() {
+ return (Py = t6._SparseReshape = t6.asm.SparseReshape).apply(null, arguments);
+ }, My = t6._SparseSegmentReduction = function() {
+ return (My = t6._SparseSegmentReduction = t6.asm.SparseSegmentReduction).apply(null, arguments);
+ }, Ly = t6._Sqrt = function() {
+ return (Ly = t6._Sqrt = t6.asm.Sqrt).apply(null, arguments);
+ }, By = t6._Square = function() {
+ return (By = t6._Square = t6.asm.Square).apply(null, arguments);
+ }, Vy = t6._SquaredDifference = function() {
+ return (Vy = t6._SquaredDifference = t6.asm.SquaredDifference).apply(null, arguments);
+ }, zy = t6._Step = function() {
+ return (zy = t6._Step = t6.asm.Step).apply(null, arguments);
+ }, Wy = t6._StridedSlice = function() {
+ return (Wy = t6._StridedSlice = t6.asm.StridedSlice).apply(null, arguments);
+ }, Uy = t6._Sub = function() {
+ return (Uy = t6._Sub = t6.asm.Sub).apply(null, arguments);
+ }, Gy = t6._Sum = function() {
+ return (Gy = t6._Sum = t6.asm.Sum).apply(null, arguments);
+ }, Hy = t6._Tan = function() {
+ return (Hy = t6._Tan = t6.asm.Tan).apply(null, arguments);
+ }, qy = t6._Tanh = function() {
+ return (qy = t6._Tanh = t6.asm.Tanh).apply(null, arguments);
+ }, Ky = t6._Tile = function() {
+ return (Ky = t6._Tile = t6.asm.Tile).apply(null, arguments);
+ }, jy = t6._TopK = function() {
+ return (jy = t6._TopK = t6.asm.TopK).apply(null, arguments);
+ }, Xy = t6._Transform = function() {
+ return (Xy = t6._Transform = t6.asm.Transform).apply(null, arguments);
+ }, Yy = t6._Transpose = function() {
+ return (Yy = t6._Transpose = t6.asm.Transpose).apply(null, arguments);
+ }, Qy = t6.__FusedMatMul = function() {
+ return (Qy = t6.__FusedMatMul = t6.asm._FusedMatMul).apply(null, arguments);
+ }, Zy = t6._malloc = function() {
+ return (Zy = t6._malloc = t6.asm.malloc).apply(null, arguments);
+ }, Jy = t6._free = function() {
+ return (Jy = t6._free = t6.asm.free).apply(null, arguments);
+ }, eb = t6.___errno_location = function() {
+ return (eb = t6.___errno_location = t6.asm.__errno_location).apply(null, arguments);
+ }, um = t6.stackSave = function() {
+ return (um = t6.stackSave = t6.asm.stackSave).apply(null, arguments);
+ }, pm = t6.stackRestore = function() {
+ return (pm = t6.stackRestore = t6.asm.stackRestore).apply(null, arguments);
+ }, Bc = t6.stackAlloc = function() {
+ return (Bc = t6.stackAlloc = t6.asm.stackAlloc).apply(null, arguments);
+ }, tb = t6.dynCall_iijjiiii = function() {
+ return (tb = t6.dynCall_iijjiiii = t6.asm.dynCall_iijjiiii).apply(null, arguments);
+ }, rb = t6.dynCall_jiji = function() {
+ return (rb = t6.dynCall_jiji = t6.asm.dynCall_jiji).apply(null, arguments);
};
- t10.cwrap = im;
+ t6.cwrap = Ql;
var Zu;
- rr = function U() {
- Zu || Cm(), Zu || (rr = U);
+ rr = function G() {
+ Zu || cm(), Zu || (rr = G);
};
- function Cm(U) {
- if (U = U || i, Tt > 0 || (dt(), Tt > 0))
+ function cm(G) {
+ if (G = G || i, Nt > 0 || (ft(), Nt > 0))
return;
- function te() {
- Zu || (Zu = true, t10.calledRun = true, !M && (It(), o(t10), t10.onRuntimeInitialized && t10.onRuntimeInitialized(), Fr()));
+ function oe() {
+ Zu || (Zu = true, t6.calledRun = true, !M && (wt(), o(t6), t6.onRuntimeInitialized && t6.onRuntimeInitialized(), Fr()));
}
- t10.setStatus ? (t10.setStatus("Running..."), setTimeout(function() {
+ t6.setStatus ? (t6.setStatus("Running..."), setTimeout(function() {
setTimeout(function() {
- t10.setStatus("");
- }, 1), te();
- }, 1)) : te();
+ t6.setStatus("");
+ }, 1), oe();
+ }, 1)) : oe();
}
- if (t10.preInit)
- for (typeof t10.preInit == "function" && (t10.preInit = [t10.preInit]); t10.preInit.length > 0; )
- t10.preInit.pop()();
- Cm();
+ if (t6.preInit)
+ for (typeof t6.preInit == "function" && (t6.preInit = [t6.preInit]); t6.preInit.length > 0; )
+ t6.preInit.pop()();
+ cm();
var Ju;
- s && (Ju = { uncaughtException: process.listeners("uncaughtException").filter(function(U) {
- return !s.uncaughtException.indexOf(U) > -1;
- }), unhandledRejection: process.listeners("unhandledRejection").filter(function(U) {
- return !s.unhandledRejection.indexOf(U) > -1;
+ s && (Ju = { uncaughtException: process.listeners("uncaughtException").filter(function(G) {
+ return !s.uncaughtException.indexOf(G) > -1;
+ }), unhandledRejection: process.listeners("unhandledRejection").filter(function(G) {
+ return !s.unhandledRejection.indexOf(G) > -1;
}) });
var ep;
if (typeof e != "undefined")
@@ -2787,31 +2795,31 @@ var V3 = Kt((Dg, tS) => {
else
throw new Error("Could not find wasm module in post.js");
if (Ju) {
- var ub = ep._dispose;
+ var ob = ep._dispose;
ep._dispose = function() {
- ub(), Ju.uncaughtException.forEach(function(U) {
- process.removeListener("uncaughtException", U);
- }), Ju.unhandledRejection.forEach(function(U) {
- process.removeListener("unhandledRejection", U);
+ ob(), Ju.uncaughtException.forEach(function(G) {
+ process.removeListener("uncaughtException", G);
+ }), Ju.unhandledRejection.forEach(function(G) {
+ process.removeListener("unhandledRejection", G);
});
};
}
return e.ready;
};
})();
- typeof Dg == "object" && typeof tS == "object" ? tS.exports = eS : typeof define == "function" && define.amd ? define([], function() {
- return eS;
- }) : typeof Dg == "object" && (Dg.WasmBackendModule = eS);
+ typeof Ig == "object" && typeof Yw == "object" ? Yw.exports = Xw : typeof define == "function" && define.amd ? define([], function() {
+ return Xw;
+ }) : typeof Ig == "object" && (Ig.WasmBackendModule = Xw);
});
-var rn = class {
- constructor(e, t10) {
- this.backend = e, this.dataMover = t10, this.data = /* @__PURE__ */ new WeakMap(), this.dataIdsCount = 0;
+var Do = class {
+ constructor(e, t6) {
+ this.backend = e, this.dataMover = t6, this.data = /* @__PURE__ */ new WeakMap(), this.dataIdsCount = 0;
}
get(e) {
return this.data.has(e) || this.dataMover.moveData(this.backend, e), this.data.get(e);
}
- set(e, t10) {
- this.dataIdsCount++, this.data.set(e, t10);
+ set(e, t6) {
+ this.dataIdsCount++, this.data.set(e, t6);
}
has(e) {
return this.data.has(e);
@@ -2823,142 +2831,142 @@ var rn = class {
return this.dataIdsCount;
}
};
-var Jr = class {
+var Zr = class {
refCount(e) {
- return Pr("refCount");
+ return Or("refCount");
}
incRef(e) {
- return Pr("incRef");
+ return Or("incRef");
}
timerAvailable() {
return true;
}
time(e) {
- return Pr("time");
+ return Or("time");
}
read(e) {
- return Pr("read");
+ return Or("read");
}
readSync(e) {
- return Pr("readSync");
+ return Or("readSync");
}
- readToGPU(e, t10) {
- return Pr("readToGPU");
+ readToGPU(e, t6) {
+ return Or("readToGPU");
}
numDataIds() {
- return Pr("numDataIds");
+ return Or("numDataIds");
}
- disposeData(e, t10) {
- return Pr("disposeData");
+ disposeData(e, t6) {
+ return Or("disposeData");
}
- write(e, t10, o) {
- return Pr("write");
+ write(e, t6, o) {
+ return Or("write");
}
- move(e, t10, o, n, s) {
- return Pr("move");
+ move(e, t6, o, n, s) {
+ return Or("move");
}
- createTensorFromTexture(e, t10, o) {
- return Pr("createTensorFromTexture");
+ createTensorFromTexture(e, t6, o) {
+ return Or("createTensorFromTexture");
}
memory() {
- return Pr("memory");
+ return Or("memory");
}
floatPrecision() {
- return Pr("floatPrecision");
+ return Or("floatPrecision");
}
epsilon() {
return this.floatPrecision() === 32 ? 1e-7 : 1e-4;
}
dispose() {
- return Pr("dispose");
+ return Or("dispose");
}
};
-function Pr(r) {
+function Or(r) {
throw new Error(`'${r}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`);
}
-function c0(r) {
- let e = r.length, t10 = 0;
+function LI(r) {
+ let e = r.length, t6 = 0;
for (; e > 0; )
- t10 = Math.random() * e | 0, e--, $m(r, e, t10);
+ t6 = Math.random() * e | 0, e--, Cm(r, e, t6);
}
-function oz(r, e) {
+function vV(r, e) {
if (r.length !== e.length)
throw new Error(`Array sizes must match to be shuffled together First array length was ${r.length}Second array length was ${e.length}`);
- let t10 = r.length, o = 0;
- for (; t10 > 0; )
- o = Math.random() * t10 | 0, t10--, $m(r, t10, o), $m(e, t10, o);
+ let t6 = r.length, o = 0;
+ for (; t6 > 0; )
+ o = Math.random() * t6 | 0, t6--, Cm(r, t6, o), Cm(e, t6, o);
}
-function op(r, e, t10) {
- return Math.max(r, Math.min(e, t10));
+function op(r, e, t6) {
+ return Math.max(r, Math.min(e, t6));
}
-function nz(r) {
+function kV(r) {
return r % 2 === 0 ? r : r + 1;
}
-function $m(r, e, t10) {
+function Cm(r, e, t6) {
let o = r[e];
- r[e] = r[t10], r[t10] = o;
+ r[e] = r[t6], r[t6] = o;
}
-function sz(r) {
+function NV(r) {
let e = 0;
- for (let t10 = 0; t10 < r.length; t10++)
- e += r[t10];
+ for (let t6 = 0; t6 < r.length; t6++)
+ e += r[t6];
return e;
}
-function az(r, e) {
- let t10 = Math.random();
- return e * t10 + (1 - t10) * r;
+function TV(r, e) {
+ let t6 = Math.random();
+ return e * t6 + (1 - t6) * r;
}
-function iz(r, e) {
- let t10 = 0;
+function _V(r, e) {
+ let t6 = 0;
for (let o = 0; o < r.length; o++) {
let n = Number(r[o]) - Number(e[o]);
- t10 += n * n;
+ t6 += n * n;
}
- return t10;
+ return t6;
}
-function $(r, e) {
+function E(r, e) {
if (!r)
throw new Error(typeof e == "string" ? e : e());
}
-function ht(r, e, t10 = "") {
- $(Or(r, e), () => t10 + ` Shapes ${r} and ${e} must match`);
+function ht(r, e, t6 = "") {
+ E(Pr(r, e), () => t6 + ` Shapes ${r} and ${e} must match`);
}
-function eo(r) {
- $(r != null, () => "The input to the tensor constructor must be a non-null value.");
+function Jr(r) {
+ E(r != null, () => "The input to the tensor constructor must be a non-null value.");
}
-function on(r, e = [], t10 = false) {
- if (e == null && (e = []), Array.isArray(r) || Ut(r) && !t10)
+function Oo(r, e = [], t6 = false) {
+ if (e == null && (e = []), Array.isArray(r) || Wt(r) && !t6)
for (let o = 0; o < r.length; ++o)
- on(r[o], e, t10);
+ Oo(r[o], e, t6);
else
e.push(r);
return e;
}
-function Ve(r) {
+function ze(r) {
if (r.length === 0)
return 1;
let e = r[0];
- for (let t10 = 1; t10 < r.length; t10++)
- e *= r[t10];
+ for (let t6 = 1; t6 < r.length; t6++)
+ e *= r[t6];
return e;
}
-function uz(r) {
+function EV(r) {
return r.length === 0;
}
-function Or(r, e) {
+function Pr(r, e) {
if (r === e)
return true;
if (r == null || e == null || r.length !== e.length)
return false;
- for (let t10 = 0; t10 < r.length; t10++)
- if (r[t10] !== e[t10])
+ for (let t6 = 0; t6 < r.length; t6++)
+ if (r[t6] !== e[t6])
return false;
return true;
}
-function ra(r) {
+function na(r) {
return r % 1 === 0;
}
-function pz(r) {
+function $V(r) {
if (Math.tanh != null)
return Math.tanh(r);
if (r === 1 / 0)
@@ -2970,20 +2978,20 @@ function pz(r) {
return (e - 1) / (e + 1);
}
}
-function cz(r) {
+function AV(r) {
let e = Math.ceil(Math.sqrt(r));
return [e, Math.ceil(r / e)];
}
-function lz(r) {
+function RV(r) {
let e = new Uint32Array(r);
- for (let t10 = 0; t10 < r; ++t10)
- e[t10] = t10;
- return c0(e), e;
+ for (let t6 = 0; t6 < r; ++t6)
+ e[t6] = t6;
+ return LI(e), e;
}
-function Mi(r, e) {
+function ji(r, e) {
return e <= r.length ? r : r + " ".repeat(e - r.length);
}
-function mz(r, e = (n) => 0, t10, o) {
+function FV(r, e = (n) => 0, t6, o) {
return new Promise((n, s) => {
let a = 0, i = () => {
if (r()) {
@@ -2992,7 +3000,7 @@ function mz(r, e = (n) => 0, t10, o) {
}
a++;
let p = e(a);
- if (t10 != null && a >= t10) {
+ if (t6 != null && a >= t6) {
s();
return;
}
@@ -3001,11 +3009,11 @@ function mz(r, e = (n) => 0, t10, o) {
i();
});
}
-function fz(r, e) {
- let t10 = 1, o = -1;
+function DV(r, e) {
+ let t6 = 1, o = -1;
for (let s = 0; s < r.length; ++s)
if (r[s] >= 0)
- t10 *= r[s];
+ t6 *= r[s];
else if (r[s] === -1) {
if (o !== -1)
throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${o} and dim ${s}`);
@@ -3013,76 +3021,76 @@ function fz(r, e) {
} else if (r[s] < 0)
throw Error(`Shapes can not be < 0. Found ${r[s]} at dim ${s}`);
if (o === -1) {
- if (e > 0 && e !== t10)
+ if (e > 0 && e !== t6)
throw Error(`Size(${e}) must match the product of shape ${r}`);
return r;
}
- if (t10 === 0)
+ if (t6 === 0)
throw Error(`Cannot infer the missing size in [${r}] when there are 0 elements`);
- if (e % t10 !== 0)
- throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${t10}`);
+ if (e % t6 !== 0)
+ throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${t6}`);
let n = r.slice();
- return n[o] = e / t10, n;
+ return n[o] = e / t6, n;
}
-function Ka(r, e) {
- let t10 = e.length;
- return r = r == null ? e.map((o, n) => n) : [].concat(r), $(r.every((o) => o >= -t10 && o < t10), () => `All values in axis param must be in range [-${t10}, ${t10}) but got axis ${r}`), $(r.every((o) => ra(o)), () => `All values in axis param must be integers but got axis ${r}`), r.map((o) => o < 0 ? t10 + o : o);
+function Qa(r, e) {
+ let t6 = e.length;
+ return r = r == null ? e.map((o, n) => n) : [].concat(r), E(r.every((o) => o >= -t6 && o < t6), () => `All values in axis param must be in range [-${t6}, ${t6}) but got axis ${r}`), E(r.every((o) => na(o)), () => `All values in axis param must be integers but got axis ${r}`), r.map((o) => o < 0 ? t6 + o : o);
}
-function db(r, e) {
- let t10 = [], o = [], n = e != null && Array.isArray(e) && e.length === 0, s = e == null || n ? null : Ka(e, r).sort(), a = 0;
+function pb(r, e) {
+ let t6 = [], o = [], n = e != null && Array.isArray(e) && e.length === 0, s = e == null || n ? null : Qa(e, r).sort(), a = 0;
for (let i = 0; i < r.length; ++i) {
if (s != null) {
if (s[a] === i && r[i] !== 1)
throw new Error(`Can't squeeze axis ${i} since its dim '${r[i]}' is not 1`);
- (s[a] == null || s[a] > i) && r[i] === 1 && (t10.push(r[i]), o.push(i)), s[a] <= i && a++;
+ (s[a] == null || s[a] > i) && r[i] === 1 && (t6.push(r[i]), o.push(i)), s[a] <= i && a++;
}
- r[i] !== 1 && (t10.push(r[i]), o.push(i));
+ r[i] !== 1 && (t6.push(r[i]), o.push(i));
}
- return { newShape: t10, keptDims: o };
+ return { newShape: t6, keptDims: o };
}
-function hb(r, e) {
- let t10 = null;
+function cb(r, e) {
+ let t6 = null;
if (r == null || r === "float32")
- t10 = new Float32Array(e);
+ t6 = new Float32Array(e);
else if (r === "int32")
- t10 = new Int32Array(e);
+ t6 = new Int32Array(e);
else if (r === "bool")
- t10 = new Uint8Array(e);
+ t6 = new Uint8Array(e);
else
throw new Error(`Unknown data type ${r}`);
- return t10;
+ return t6;
}
-function gb(r, e) {
- let t10 = null;
+function lb(r, e) {
+ let t6 = null;
if (r == null || r === "float32")
- t10 = new Float32Array(e);
+ t6 = new Float32Array(e);
else if (r === "int32")
- t10 = new Int32Array(e);
+ t6 = new Int32Array(e);
else if (r === "bool")
- t10 = new Uint8Array(e);
+ t6 = new Uint8Array(e);
else if (r === "string")
- t10 = new Array(e);
+ t6 = new Array(e);
else
throw new Error(`Unknown data type ${r}`);
- return t10;
+ return t6;
}
-function xb(r, e) {
- for (let t10 = 0; t10 < r.length; t10++) {
- let o = r[t10];
+function mb(r, e) {
+ for (let t6 = 0; t6 < r.length; t6++) {
+ let o = r[t6];
if (isNaN(o) || !isFinite(o))
throw Error(`A tensor of type ${e} being uploaded contains ${o}.`);
}
}
-function yb(r) {
+function db(r) {
return r === "bool" || r === "complex64" || r === "float32" || r === "int32" || r === "string";
}
-function dz(r, e) {
+function OV(r, e) {
return !(e === "complex64" || e === "float32" && r !== "complex64" || e === "int32" && r !== "float32" && r !== "complex64" || e === "bool" && r === "bool");
}
-function Ut(r) {
+function Wt(r) {
return r instanceof Float32Array || r instanceof Int32Array || r instanceof Uint8Array || r instanceof Uint8ClampedArray;
}
-function Rm(r) {
+function Sm(r) {
if (r === "float32" || r === "int32")
return 4;
if (r === "complex64")
@@ -3091,71 +3099,71 @@ function Rm(r) {
return 1;
throw new Error(`Unknown dtype ${r}`);
}
-function bb(r) {
+function fb(r) {
if (r == null)
return 0;
let e = 0;
- return r.forEach((t10) => e += t10.length), e;
+ return r.forEach((t6) => e += t6.length), e;
}
-function nn(r) {
+function Po(r) {
return typeof r == "string" || r instanceof String;
}
-function l0(r) {
+function BI(r) {
return typeof r == "boolean";
}
-function m0(r) {
+function VI(r) {
return typeof r == "number";
}
function np(r) {
- return Array.isArray(r) ? np(r[0]) : r instanceof Float32Array ? "float32" : r instanceof Int32Array || r instanceof Uint8Array || r instanceof Uint8ClampedArray ? "int32" : m0(r) ? "float32" : nn(r) ? "string" : l0(r) ? "bool" : "float32";
+ return Array.isArray(r) ? np(r[0]) : r instanceof Float32Array ? "float32" : r instanceof Int32Array || r instanceof Uint8Array || r instanceof Uint8ClampedArray ? "int32" : VI(r) ? "float32" : Po(r) ? "string" : BI(r) ? "bool" : "float32";
}
function fs(r) {
return !!(r && r.constructor && r.call && r.apply);
}
function sp(r, e) {
- for (let t10 = e; t10 < r; ++t10)
- if (r % t10 === 0)
- return t10;
+ for (let t6 = e; t6 < r; ++t6)
+ if (r % t6 === 0)
+ return t6;
return r;
}
-function ds(r) {
+function hs(r) {
let e = r.length;
if (e < 2)
return [];
- let t10 = new Array(e - 1);
- t10[e - 2] = r[e - 1];
+ let t6 = new Array(e - 1);
+ t6[e - 2] = r[e - 1];
for (let o = e - 3; o >= 0; --o)
- t10[o] = t10[o + 1] * r[o + 1];
- return t10;
+ t6[o] = t6[o + 1] * r[o + 1];
+ return t6;
}
-function f0(r, e, t10, o = false) {
+function zI(r, e, t6, o = false) {
let n = new Array();
if (e.length === 1) {
let s = e[0] * (o ? 2 : 1);
for (let a = 0; a < s; a++)
- n[a] = t10[r + a];
+ n[a] = t6[r + a];
} else {
let s = e[0], a = e.slice(1), i = a.reduce((p, u) => p * u) * (o ? 2 : 1);
for (let p = 0; p < s; p++)
- n[p] = f0(r + p * i, a, t10, o);
+ n[p] = zI(r + p * i, a, t6, o);
}
return n;
}
-function Oi(r, e, t10 = false) {
+function Ki(r, e, t6 = false) {
if (r.length === 0)
return e[0];
- let o = r.reduce((n, s) => n * s) * (t10 ? 2 : 1);
+ let o = r.reduce((n, s) => n * s) * (t6 ? 2 : 1);
if (o === 0)
return [];
if (o !== e.length)
- throw new Error(`[${r}] does not match the input size ${e.length}${t10 ? " for a complex tensor" : ""}.`);
- return f0(0, r, e, t10);
+ throw new Error(`[${r}] does not match the input size ${e.length}${t6 ? " for a complex tensor" : ""}.`);
+ return zI(0, r, e, t6);
}
-function jc(r, e) {
- let t10 = ap(r, e);
- for (let o = 0; o < t10.length; o++)
- t10[o] = 1;
- return t10;
+function zc(r, e) {
+ let t6 = ap(r, e);
+ for (let o = 0; o < t6.length; o++)
+ t6[o] = 1;
+ return t6;
}
function ap(r, e) {
if (e == null || e === "float32" || e === "complex64")
@@ -3166,56 +3174,56 @@ function ap(r, e) {
return new Uint8Array(r);
throw new Error(`Unknown data type ${e}`);
}
-function hz(r, e) {
- let t10 = r.reduce((o, n) => o * n, 1);
+function PV(r, e) {
+ let t6 = r.reduce((o, n) => o * n, 1);
if (e == null || e === "float32")
- return Oi(r, new Float32Array(t10));
+ return Ki(r, new Float32Array(t6));
if (e === "int32")
- return Oi(r, new Int32Array(t10));
+ return Ki(r, new Int32Array(t6));
if (e === "bool")
- return Oi(r, new Uint8Array(t10));
+ return Ki(r, new Uint8Array(t6));
throw new Error(`Unknown data type ${e}`);
}
-function Xc(r) {
+function yt(r) {
r.forEach((e) => {
- $(Number.isInteger(e) && e >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${r}].`);
+ E(Number.isInteger(e) && e >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${r}].`);
});
}
-function gz(r, e, t10) {
+function MV(r, e, t6) {
if (e === 0)
return 0;
if (e === 1)
return r[0];
let o = r[r.length - 1];
for (let n = 0; n < r.length - 1; ++n)
- o += t10[n] * r[n];
+ o += t6[n] * r[n];
return o;
}
-function xz(r, e, t10) {
+function LV(r, e, t6) {
if (e === 0)
return [];
if (e === 1)
return [r];
let o = new Array(e);
for (let n = 0; n < o.length - 1; ++n)
- o[n] = Math.floor(r / t10[n]), r -= o[n] * t10[n];
+ o[n] = Math.floor(r / t6[n]), r -= o[n] * t6[n];
return o[o.length - 1] = r, o;
}
-function Yc(r) {
+function Wc(r) {
return r && r.then && typeof r.then == "function";
}
-var d0 = "tfjsflags";
-var Qc = class {
+var WI = "tfjsflags";
+var Uc = class {
constructor(e) {
- this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = bz, this.populateURLFlags();
+ this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = VV, this.populateURLFlags();
}
- setPlatform(e, t10) {
- this.platform != null && (P().getBool("IS_TEST") || P().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)), this.platformName = e, this.platform = t10;
+ setPlatform(e, t6) {
+ this.platform != null && (O().getBool("IS_TEST") || O().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)), this.platformName = e, this.platform = t6;
}
- registerFlag(e, t10, o) {
- if (this.flagRegistry[e] = { evaluationFn: t10, setHook: o }, this.urlFlags[e] != null) {
+ registerFlag(e, t6, o) {
+ if (this.flagRegistry[e] = { evaluationFn: t6, setHook: o }, this.urlFlags[e] != null) {
let n = this.urlFlags[e];
- P().getBool("IS_TEST") || P().getBool("PROD") || console.warn(`Setting feature override from URL ${e}: ${n}.`), this.set(e, n);
+ O().getBool("IS_TEST") || O().getBool("PROD") || console.warn(`Setting feature override from URL ${e}: ${n}.`), this.set(e, n);
}
}
async getAsync(e) {
@@ -3224,10 +3232,10 @@ var Qc = class {
get(e) {
if (e in this.flags)
return this.flags[e];
- let t10 = this.evaluateFlag(e);
- if (Yc(t10))
+ let t6 = this.evaluateFlag(e);
+ if (Wc(t6))
throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);
- return this.flags[e] = t10, this.flags[e];
+ return this.flags[e] = t6, this.flags[e];
}
getNumber(e) {
return this.get(e);
@@ -3241,10 +3249,10 @@ var Qc = class {
get features() {
return this.flags;
}
- set(e, t10) {
+ set(e, t6) {
if (this.flagRegistry[e] == null)
throw new Error(`Cannot set flag ${e} as it has not been registered.`);
- this.flags[e] = t10, this.flagRegistry[e].setHook != null && this.flagRegistry[e].setHook(t10);
+ this.flags[e] = t6, this.flagRegistry[e].setHook != null && this.flagRegistry[e].setHook(t6);
}
evaluateFlag(e) {
if (this.flagRegistry[e] == null)
@@ -3261,36 +3269,36 @@ var Qc = class {
if (typeof this.global == "undefined" || typeof this.global.location == "undefined" || typeof this.global.location.search == "undefined")
return;
let e = this.getQueryParams(this.global.location.search);
- d0 in e && e[d0].split(",").forEach((o) => {
+ WI in e && e[WI].split(",").forEach((o) => {
let [n, s] = o.split(":");
- this.urlFlags[n] = Iz(n, s);
+ this.urlFlags[n] = WV(n, s);
});
}
};
-function bz(r) {
+function VV(r) {
let e = {};
- return r.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (t10, ...o) => (Cz(e, o[0], o[1]), o.join("="))), e;
+ return r.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (t6, ...o) => (zV(e, o[0], o[1]), o.join("="))), e;
}
-function Cz(r, e, t10) {
- r[decodeURIComponent(e)] = decodeURIComponent(t10 || "");
+function zV(r, e, t6) {
+ r[decodeURIComponent(e)] = decodeURIComponent(t6 || "");
}
-function Iz(r, e) {
+function WV(r, e) {
if (e = e.toLowerCase(), e === "true" || e === "false")
return e === "true";
if (`${+e}` === e)
return +e;
throw new Error(`Could not parse value flag value ${e} for flag ${r}.`);
}
-function P() {
- return Cb;
+function O() {
+ return hb;
}
-var Cb = null;
-function h0(r) {
- Cb = r;
+var hb = null;
+function UI(r) {
+ hb = r;
}
-var Ib;
-function wb() {
- if (Ib == null) {
+var gb;
+function xb() {
+ if (gb == null) {
let r;
if (typeof window != "undefined")
r = window;
@@ -3302,370 +3310,370 @@ function wb() {
r = self;
else
throw new Error("Could not find a global object");
- Ib = r;
+ gb = r;
}
- return Ib;
+ return gb;
}
-function wz() {
- let r = wb();
+function UV() {
+ let r = xb();
return r._tfGlobals == null && (r._tfGlobals = /* @__PURE__ */ new Map()), r._tfGlobals;
}
-function Zc(r, e) {
- let t10 = wz();
- if (t10.has(r))
- return t10.get(r);
+function Gc(r, e) {
+ let t6 = UV();
+ if (t6.has(r))
+ return t6.get(r);
{
let o = e();
- return t10.set(r, o), t10.get(r);
+ return t6.set(r, o), t6.get(r);
}
}
-var sn = "Abs";
-var Li = "Acos";
-var Bi = "Acosh";
-var _r = "Add";
-var an = "AddN";
-var oa = "All";
-var na = "Any";
-var un = "ArgMax";
-var ja = "ArgMin";
-var Vi = "Asin";
-var zi = "Asinh";
-var Wi = "Atan";
-var Ui = "Atanh";
-var sa = "Atan2";
-var pn = "AvgPool";
-var Am = "AvgPoolGrad";
+var gs = "Abs";
+var sa = "Acos";
+var aa = "Acosh";
+var eo = "Add";
+var Mo = "AddN";
+var Lo = "All";
+var Bo = "Any";
+var Vo = "ArgMax";
+var Za = "ArgMin";
+var ia = "Asin";
+var ua = "Asinh";
+var pa = "Atan";
+var ca = "Atanh";
+var la = "Atan2";
+var zo = "AvgPool";
+var wm = "AvgPoolGrad";
var ip = "AvgPool3D";
-var Fm = "AvgPool3DGrad";
-var cn = "BatchMatMul";
-var hs = "BatchToSpaceND";
-var up = "Bincount";
-var Tne = "BroadcastTo";
-var pp = "BroadcastArgs";
-var to = "Cast";
-var ro = "Ceil";
-var Ro = "ClipByValue";
-var aa = "Complex";
-var cp = "ComplexAbs";
-var gs = "Concat";
-var ln = "Conv2D";
-var lp = "Conv2DBackpropFilter";
-var mn = "Conv2DBackpropInput";
-var mp = "Conv3D";
-var Dm = "Conv3DBackpropFilterV2";
-var fp = "Conv3DBackpropInputV2";
-var fn = "Cos";
-var dn = "Cosh";
-var hn = "Cumprod";
-var gn = "Cumsum";
-var xn = "CropAndResize";
-var dp = "DenseBincount";
-var yn = "DepthToSpace";
-var bn = "DepthwiseConv2dNative";
-var hp = "DepthwiseConv2dNativeBackpropFilter";
-var gp = "DepthwiseConv2dNativeBackpropInput";
-var xp = "Diag";
-var yp = "Dilation2D";
-var Sb = "Dilation2DBackpropInput";
-var vb = "Dilation2DBackpropFilter";
-var Cn = "RealDiv";
-var Xa = "Einsum";
-var In = "Elu";
-var Pm = "EluGrad";
-var Gi = "Erf";
-var oo = "Equal";
-var no = "Exp";
-var xs = "ExpandDims";
-var wn = "Expm1";
-var bp = "FFT";
-var ys = "Fill";
-var Sn = "FlipLeftRight";
-var so = "Floor";
-var vn = "FloorDiv";
-var kn = "FusedBatchNorm";
-var bs = "GatherV2";
-var Tn = "GatherNd";
-var ao = "Greater";
-var io = "GreaterEqual";
-var uo = "Identity";
-var Cp = "IFFT";
-var Ya = "Imag";
-var Hi = "IsFinite";
-var qi = "IsInf";
-var ia = "IsNan";
-var Nn = "LeakyRelu";
-var po = "Less";
-var co = "LessEqual";
-var Ip = "LinSpace";
-var lo = "Log";
-var Ki = "Log1p";
-var _n = "LogicalAnd";
-var En = "LogicalNot";
-var ua = "LogicalOr";
-var g0 = "LogicalXor";
-var Nne = "LogSoftmax";
-var _ne = "LowerBound";
-var wp = "LRN";
-var Om = "LRNGrad";
-var $n = "Max";
-var mo = "Maximum";
-var Rn = "MaxPool";
-var Mm = "MaxPoolGrad";
-var Sp = "MaxPool3D";
-var Lm = "MaxPool3DGrad";
-var vp = "MaxPoolWithArgmax";
-var An = "Mean";
-var Fn = "Min";
-var fo = "Minimum";
-var Dn = "MirrorPad";
-var ji = "Mod";
-var kp = "Multinomial";
-var ho = "Multiply";
-var Pn = "Neg";
-var go = "NotEqual";
-var On = "NonMaxSuppressionV3";
-var pa = "NonMaxSuppressionV4";
-var Mn = "NonMaxSuppressionV5";
-var Cs = "OnesLike";
-var ca = "OneHot";
-var Is = "Pack";
-var Ln = "PadV2";
-var Ene = "Pool";
-var Bn = "Pow";
-var Vn = "Prelu";
-var Ao = "Prod";
-var Tp = "RaggedGather";
-var Np = "RaggedRange";
-var _p = "RaggedTensorToTensor";
-var ws = "Range";
-var la = "Real";
-var ma = "Reciprocal";
-var zn = "Relu";
-var Ss = "Reshape";
-var Wn = "ResizeNearestNeighbor";
-var Bm = "ResizeNearestNeighborGrad";
-var Un = "ResizeBilinear";
-var Vm = "ResizeBilinearGrad";
-var Gn = "Relu6";
-var fa = "Reverse";
-var da = "Round";
-var xo = "Rsqrt";
-var Hn = "ScatterNd";
-var Ep = "SearchSorted";
-var vs = "Select";
+var Im = "AvgPool3DGrad";
+var Wo = "BatchMatMul";
+var xs = "BatchToSpaceND";
+var Ja = "Bincount";
+var wne = "BroadcastTo";
+var up = "BroadcastArgs";
+var co = "Cast";
+var Uo = "Ceil";
+var lo = "ClipByValue";
+var ei = "Complex";
+var pp = "ComplexAbs";
+var ys = "Concat";
+var Go = "Conv2D";
+var cp = "Conv2DBackpropFilter";
+var Ho = "Conv2DBackpropInput";
+var lp = "Conv3D";
+var vm = "Conv3DBackpropFilterV2";
+var mp = "Conv3DBackpropInputV2";
+var qo = "Cos";
+var Ko = "Cosh";
+var jo = "Cumprod";
+var Xo = "Cumsum";
+var Yo = "CropAndResize";
+var ti = "DenseBincount";
+var Qo = "DepthToSpace";
+var Zo = "DepthwiseConv2dNative";
+var dp = "DepthwiseConv2dNativeBackpropFilter";
+var fp = "DepthwiseConv2dNativeBackpropInput";
+var hp = "Diag";
+var gp = "Dilation2D";
+var yb = "Dilation2DBackpropInput";
+var bb = "Dilation2DBackpropFilter";
+var Jo = "RealDiv";
+var ri = "Einsum";
+var en = "Elu";
+var km = "EluGrad";
+var ma = "Erf";
+var tn = "Equal";
+var rn = "Exp";
+var bs = "ExpandDims";
+var da = "Expm1";
+var oi = "FFT";
+var Cs = "Fill";
+var on = "FlipLeftRight";
+var nn = "Floor";
+var sn = "FloorDiv";
+var an = "FusedBatchNorm";
+var Ss = "GatherV2";
+var un = "GatherNd";
+var pn = "Greater";
+var cn = "GreaterEqual";
+var mo = "Identity";
+var ni = "IFFT";
+var si = "Imag";
+var fa = "IsFinite";
+var ha = "IsInf";
+var ln = "IsNan";
+var mn = "LeakyRelu";
+var dn = "Less";
+var fn = "LessEqual";
+var xp = "LinSpace";
+var hn = "Log";
+var ga = "Log1p";
+var gn = "LogicalAnd";
+var xn = "LogicalNot";
+var xa = "LogicalOr";
+var GI = "LogicalXor";
+var Ine = "LogSoftmax";
+var vne = "LowerBound";
+var yp = "LRN";
+var Nm = "LRNGrad";
+var yn = "Max";
+var bn = "Maximum";
+var Cn = "MaxPool";
+var Tm = "MaxPoolGrad";
+var bp = "MaxPool3D";
+var _m = "MaxPool3DGrad";
+var Cp = "MaxPoolWithArgmax";
+var Sn = "Mean";
+var wn = "Min";
+var In = "Minimum";
+var vn = "MirrorPad";
+var ya = "Mod";
+var Sp = "Multinomial";
+var kn = "Multiply";
+var ws = "Neg";
+var Nn = "NotEqual";
+var Tn = "NonMaxSuppressionV3";
+var ba = "NonMaxSuppressionV4";
+var _n = "NonMaxSuppressionV5";
+var Is = "OnesLike";
+var En = "OneHot";
+var vs = "Pack";
+var $n = "PadV2";
+var kne = "Pool";
+var An = "Pow";
+var Rn = "Prelu";
+var Fn = "Prod";
+var wp = "RaggedGather";
+var Ip = "RaggedRange";
+var vp = "RaggedTensorToTensor";
+var ks = "Range";
+var ai = "Real";
+var Dn = "Reciprocal";
+var On = "Relu";
+var Ns = "Reshape";
+var Pn = "ResizeNearestNeighbor";
+var Em = "ResizeNearestNeighborGrad";
+var Mn = "ResizeBilinear";
+var $m = "ResizeBilinearGrad";
+var Ln = "Relu6";
+var Bn = "Reverse";
+var Ca = "Round";
+var Vn = "Rsqrt";
+var zn = "ScatterNd";
+var ii = "SearchSorted";
+var Ts = "Select";
var Xi = "Selu";
-var qn = "Slice";
-var Kn = "Sin";
-var ha = "Sinh";
+var _s = "Slice";
+var Wn = "Sin";
+var Sa = "Sinh";
var Yi = "Sign";
-var yo = "Sigmoid";
+var Un = "Sigmoid";
var Qi = "Softplus";
-var bo = "Sqrt";
-var jn = "Sum";
-var ks = "SpaceToBatchND";
-var Ts = "SplitV";
-var Xn = "Softmax";
-var Qa = "SparseFillEmptyRows";
-var ga = "SparseReshape";
-var Za = "SparseSegmentMean";
-var Ja = "SparseSegmentSum";
-var ei = "SparseToDense";
-var Co = "SquaredDifference";
-var ti = "Square";
-var Yn = "StridedSlice";
-var Ns = "StringNGrams";
-var ri = "StringSplit";
-var oi = "StringToHashBucketFast";
-var Io = "Sub";
-var xa = "Tan";
+var Gn = "Sqrt";
+var Hn = "Sum";
+var Es = "SpaceToBatchND";
+var $s = "SplitV";
+var qn = "Softmax";
+var ui = "SparseFillEmptyRows";
+var wa = "SparseReshape";
+var pi = "SparseSegmentMean";
+var ci = "SparseSegmentSum";
+var li = "SparseToDense";
+var Kn = "SquaredDifference";
+var mi = "Square";
+var jn = "StridedSlice";
+var As = "StringNGrams";
+var di = "StringSplit";
+var fi = "StringToHashBucketFast";
+var Xn = "Sub";
+var Yn = "Tan";
var Qn = "Tanh";
-var wo = "Tile";
+var to = "Tile";
var Zn = "TopK";
var Jn = "Transform";
-var Mr = "Transpose";
-var $p = "Unique";
-var _s = "Unpack";
-var Rp = "UnsortedSegmentSum";
-var $ne = "UpperBound";
-var Es = "ZerosLike";
-var $s = "Step";
+var ro = "Transpose";
+var kp = "Unique";
+var Rs = "Unpack";
+var Np = "UnsortedSegmentSum";
+var Nne = "UpperBound";
+var Fs = "ZerosLike";
+var Ds = "Step";
var Zi = "FromPixels";
var es = "RotateWithOffset";
-var Fo = "_FusedMatMul";
-var Do = "FusedConv2D";
-var Po = "FusedDepthwiseConv2D";
-function Rs(...r) {
- P().getBool("IS_TEST") || P().getBool("PROD") || console.warn(...r);
+var fo = "_FusedMatMul";
+var ho = "FusedConv2D";
+var go = "FusedDepthwiseConv2D";
+function Os(...r) {
+ O().getBool("IS_TEST") || O().getBool("PROD") || console.warn(...r);
}
-function Sz(...r) {
- P().getBool("IS_TEST") || P().getBool("PROD") || console.log(...r);
+function GV(...r) {
+ O().getBool("IS_TEST") || O().getBool("PROD") || console.log(...r);
}
-var Ap = Zc("kernelRegistry", () => /* @__PURE__ */ new Map());
-var Jc = Zc("gradRegistry", () => /* @__PURE__ */ new Map());
-function el(r, e) {
- let t10 = Tb(r, e);
- return Ap.get(t10);
+var Tp = Gc("kernelRegistry", () => /* @__PURE__ */ new Map());
+var Hc = Gc("gradRegistry", () => /* @__PURE__ */ new Map());
+function qc(r, e) {
+ let t6 = Sb(r, e);
+ return Tp.get(t6);
}
-function kb(r) {
- return Jc.get(r);
+function Cb(r) {
+ return Hc.get(r);
}
-function zm(r) {
- let e = Ap.entries(), t10 = [];
+function Am(r) {
+ let e = Tp.entries(), t6 = [];
for (; ; ) {
let { done: o, value: n } = e.next();
if (o)
break;
let [s, a] = n, [i] = s.split("_");
- i === r && t10.push(a);
+ i === r && t6.push(a);
}
- return t10;
+ return t6;
}
-function ya(r) {
- let { kernelName: e, backendName: t10 } = r, o = Tb(e, t10);
- Ap.has(o) && Rs(`The kernel '${e}' for backend '${t10}' is already registered`), Ap.set(o, r);
+function Ia(r) {
+ let { kernelName: e, backendName: t6 } = r, o = Sb(e, t6);
+ Tp.has(o) && Os(`The kernel '${e}' for backend '${t6}' is already registered`), Tp.set(o, r);
}
-function Pne(r) {
+function Ane(r) {
let { kernelName: e } = r;
- Jc.has(e) && P().getBool("DEBUG") && Rs(`Overriding the gradient for '${e}'`), Jc.set(e, r);
+ Hc.has(e) && O().getBool("DEBUG") && Os(`Overriding the gradient for '${e}'`), Hc.set(e, r);
}
-function One(r, e) {
- let t10 = Tb(r, e);
- if (!Ap.has(t10))
+function Rne(r, e) {
+ let t6 = Sb(r, e);
+ if (!Tp.has(t6))
throw new Error(`The kernel '${r}' for backend '${e}' is not registered`);
- Ap.delete(t10);
+ Tp.delete(t6);
}
-function Mne(r) {
- if (!Jc.has(r))
+function Fne(r) {
+ if (!Hc.has(r))
throw new Error(`The gradient '${r}' for backend is not registered`);
- Jc.delete(r);
+ Hc.delete(r);
}
-function Lne(r, e) {
- zm(r).forEach((o) => {
+function Dne(r, e) {
+ Am(r).forEach((o) => {
let n = Object.assign({}, o, { backendName: e });
- ya(n);
+ Ia(n);
});
}
-function Tb(r, e) {
+function Sb(r, e) {
return `${e}_${r}`;
}
-var x = {};
-Be(x, { arraysEqual: () => Or, assert: () => $, assertNonNegativeIntegerDimensions: () => Xc, assertNonNull: () => eo, assertShapesMatch: () => ht, bytesFromStringArray: () => bb, bytesPerElement: () => Rm, checkConversionForErrors: () => xb, clamp: () => op, computeStrides: () => ds, createScalarValue: () => $z, createShuffledIndices: () => lz, decodeString: () => Op, distSquared: () => iz, encodeString: () => si, fetch: () => Az, fingerPrint64: () => Ez, flatten: () => on, getArrayFromDType: () => gb, getTypedArrayFromDType: () => hb, hasEncodingLoss: () => dz, hexToLong: () => tl, indexToLoc: () => xz, inferDtype: () => np, inferFromImplicitShape: () => fz, isBoolean: () => l0, isFunction: () => fs, isInt: () => ra, isNumber: () => m0, isPromise: () => Yc, isScalarShape: () => uz, isString: () => nn, isTypedArray: () => Ut, isValidDtype: () => yb, locToIndex: () => gz, makeOnesTypedArray: () => jc, makeZerosNestedTypedArray: () => hz, makeZerosTypedArray: () => ap, nearestDivisor: () => sp, nearestLargerEven: () => nz, now: () => ou, parseAxisParam: () => Ka, randUniform: () => az, repeatedTry: () => mz, rightPad: () => Mi, shuffle: () => c0, shuffleCombo: () => oz, sizeFromShape: () => Ve, sizeToSquarishShape: () => cz, squeezeShape: () => db, sum: () => sz, swap: () => $m, tanh: () => pz, toNestedArray: () => Oi, toTypedArray: () => Pp });
-var $b = rp(_0());
-var ru = $b.default || $b;
-function tl(r) {
+var y = {};
+Ue(y, { arraysEqual: () => Pr, assert: () => E, assertNonNegativeIntegerDimensions: () => yt, assertNonNull: () => Jr, assertShapesMatch: () => ht, bytesFromStringArray: () => fb, bytesPerElement: () => Sm, checkConversionForErrors: () => mb, clamp: () => op, computeStrides: () => hs, createScalarValue: () => QV, createShuffledIndices: () => RV, decodeString: () => Ap, distSquared: () => _V, encodeString: () => gi, fetch: () => JV, fingerPrint64: () => YV, flatten: () => Oo, getArrayFromDType: () => lb, getTypedArrayFromDType: () => cb, hasEncodingLoss: () => OV, hexToLong: () => Kc, indexToLoc: () => LV, inferDtype: () => np, inferFromImplicitShape: () => DV, isBoolean: () => BI, isFunction: () => fs, isInt: () => na, isNumber: () => VI, isPromise: () => Wc, isScalarShape: () => EV, isString: () => Po, isTypedArray: () => Wt, isValidDtype: () => db, locToIndex: () => MV, makeOnesTypedArray: () => zc, makeZerosNestedTypedArray: () => PV, makeZerosTypedArray: () => ap, nearestDivisor: () => sp, nearestLargerEven: () => kV, now: () => ou, parseAxisParam: () => Qa, randUniform: () => TV, repeatedTry: () => FV, rightPad: () => ji, shuffle: () => LI, shuffleCombo: () => vV, sizeFromShape: () => ze, sizeToSquarishShape: () => AV, squeezeShape: () => pb, sum: () => NV, swap: () => Cm, tanh: () => $V, toNestedArray: () => Ki, toTypedArray: () => $p });
+var kb = rp(rv());
+var ru = kb.default || kb;
+function Kc(r) {
return ru.fromString(r, true, 16);
}
-var $0 = tl("c3a5c85c97cb3127");
-var tu = tl("b492b66fbe98f273");
-var gr = tl("9ae16a3b2f90404f");
-function Eb(r) {
+var nv = Kc("c3a5c85c97cb3127");
+var tu = Kc("b492b66fbe98f273");
+var gr = Kc("9ae16a3b2f90404f");
+function vb(r) {
return r.xor(r.shru(47));
}
-function R0(r, e, t10) {
- let o = r.slice(e, e + t10);
+function sv(r, e, t6) {
+ let o = r.slice(e, e + t6);
return ru.fromBytes(Array.from(o), true, true);
}
-function yt(r, e) {
- return R0(r, e, 8);
+function bt(r, e) {
+ return sv(r, e, 8);
}
-function E0(r, e) {
- return R0(r, e, 4);
+function ov(r, e) {
+ return sv(r, e, 4);
}
-function Xt(r, e) {
+function jt(r, e) {
return e === 0 ? r : r.shru(e).or(r.shl(64 - e));
}
-function ni(r, e, t10 = tl("9ddfea08eb382d69")) {
- let o = r.xor(e).mul(t10);
+function hi(r, e, t6 = Kc("9ddfea08eb382d69")) {
+ let o = r.xor(e).mul(t6);
o = o.xor(o.shru(47));
- let n = e.xor(o).mul(t10);
- return n = n.xor(n.shru(47)), n = n.mul(t10), n;
+ let n = e.xor(o).mul(t6);
+ return n = n.xor(n.shru(47)), n = n.mul(t6), n;
}
-function kz(r, e, t10, o, n, s) {
- n = n.add(r), s = Xt(s.add(n).add(o), 21);
+function qV(r, e, t6, o, n, s) {
+ n = n.add(r), s = jt(s.add(n).add(o), 21);
let a = n;
- return n = n.add(e), n = n.add(t10), s = s.add(Xt(n, 44)), [n.add(o), s.add(a)];
+ return n = n.add(e), n = n.add(t6), s = s.add(jt(n, 44)), [n.add(o), s.add(a)];
}
-function Um(r, e, t10, o) {
- return kz(yt(r, e), yt(r, e + 8), yt(r, e + 16), yt(r, e + 24), t10, o);
+function Fm(r, e, t6, o) {
+ return qV(bt(r, e), bt(r, e + 8), bt(r, e + 16), bt(r, e + 24), t6, o);
}
-function Tz(r, e = r.length) {
+function KV(r, e = r.length) {
if (e >= 8) {
- let t10 = gr.add(e * 2), o = yt(r, 0).add(gr), n = yt(r, e - 8), s = Xt(n, 37).mul(t10).add(o), a = Xt(o, 25).add(n).mul(t10);
- return ni(s, a, t10);
+ let t6 = gr.add(e * 2), o = bt(r, 0).add(gr), n = bt(r, e - 8), s = jt(n, 37).mul(t6).add(o), a = jt(o, 25).add(n).mul(t6);
+ return hi(s, a, t6);
}
if (e >= 4) {
- let t10 = gr.add(e * 2), o = E0(r, 0);
- return ni(o.shl(3).add(e), E0(r, e - 4), t10);
+ let t6 = gr.add(e * 2), o = ov(r, 0);
+ return hi(o.shl(3).add(e), ov(r, e - 4), t6);
}
if (e > 0) {
- let t10 = r[0], o = r[e >> 1], n = r[e - 1], s = t10 + (o << 8), a = e + (n << 2);
- return Eb(gr.mul(s).xor($0.mul(a))).mul(gr);
+ let t6 = r[0], o = r[e >> 1], n = r[e - 1], s = t6 + (o << 8), a = e + (n << 2);
+ return vb(gr.mul(s).xor(nv.mul(a))).mul(gr);
}
return gr;
}
-function Nz(r, e = r.length) {
- let t10 = gr.add(e * 2), o = yt(r, 0).mul(tu), n = yt(r, 8), s = yt(r, e - 8).mul(t10), a = yt(r, e - 16).mul(gr);
- return ni(Xt(o.add(n), 43).add(Xt(s, 30)).add(a), o.add(Xt(n.add(gr), 18)).add(s), t10);
+function jV(r, e = r.length) {
+ let t6 = gr.add(e * 2), o = bt(r, 0).mul(tu), n = bt(r, 8), s = bt(r, e - 8).mul(t6), a = bt(r, e - 16).mul(gr);
+ return hi(jt(o.add(n), 43).add(jt(s, 30)).add(a), o.add(jt(n.add(gr), 18)).add(s), t6);
}
-function _z(r, e = r.length) {
- let t10 = gr.add(e * 2), o = yt(r, 0).mul(gr), n = yt(r, 8), s = yt(r, e - 8).mul(t10), a = yt(r, e - 16).mul(gr), i = Xt(o.add(n), 43).add(Xt(s, 30)).add(a), p = ni(i, o.add(Xt(n.add(gr), 18)).add(s), t10), u = yt(r, 16).mul(t10), c = yt(r, 24), l = i.add(yt(r, e - 32)).mul(t10), m = p.add(yt(r, e - 24)).mul(t10);
- return ni(Xt(u.add(c), 43).add(Xt(l, 30)).add(m), u.add(Xt(c.add(o), 18)).add(l), t10);
+function XV(r, e = r.length) {
+ let t6 = gr.add(e * 2), o = bt(r, 0).mul(gr), n = bt(r, 8), s = bt(r, e - 8).mul(t6), a = bt(r, e - 16).mul(gr), i = jt(o.add(n), 43).add(jt(s, 30)).add(a), p = hi(i, o.add(jt(n.add(gr), 18)).add(s), t6), u = bt(r, 16).mul(t6), c = bt(r, 24), l = i.add(bt(r, e - 32)).mul(t6), m = p.add(bt(r, e - 24)).mul(t6);
+ return hi(jt(u.add(c), 43).add(jt(l, 30)).add(m), u.add(jt(c.add(o), 18)).add(l), t6);
}
-function Ez(r, e = r.length) {
- let t10 = ru.fromNumber(81, true);
+function YV(r, e = r.length) {
+ let t6 = ru.fromNumber(81, true);
if (e <= 32)
- return e <= 16 ? Tz(r, e) : Nz(r, e);
+ return e <= 16 ? KV(r, e) : jV(r, e);
if (e <= 64)
- return _z(r, e);
- let o = t10, n = t10.mul(tu).add(113), s = Eb(n.mul(gr).add(113)).mul(gr), a = [ru.UZERO, ru.UZERO], i = [ru.UZERO, ru.UZERO];
- o = o.mul(gr).add(yt(r, 0));
+ return XV(r, e);
+ let o = t6, n = t6.mul(tu).add(113), s = vb(n.mul(gr).add(113)).mul(gr), a = [ru.UZERO, ru.UZERO], i = [ru.UZERO, ru.UZERO];
+ o = o.mul(gr).add(bt(r, 0));
let p = 0, u = (e - 1 >> 6) * 64, c = u + (e - 1 & 63) - 63;
do
- o = Xt(o.add(n).add(a[0]).add(yt(r, p + 8)), 37).mul(tu), n = Xt(n.add(a[1]).add(yt(r, p + 48)), 42).mul(tu), o = o.xor(i[1]), n = n.add(a[0]).add(yt(r, p + 40)), s = Xt(s.add(i[0]), 33).mul(tu), a = Um(r, p, a[1].mul(tu), o.add(i[0])), i = Um(r, p + 32, s.add(i[1]), n.add(yt(r, p + 16))), [s, o] = [o, s], p += 64;
+ o = jt(o.add(n).add(a[0]).add(bt(r, p + 8)), 37).mul(tu), n = jt(n.add(a[1]).add(bt(r, p + 48)), 42).mul(tu), o = o.xor(i[1]), n = n.add(a[0]).add(bt(r, p + 40)), s = jt(s.add(i[0]), 33).mul(tu), a = Fm(r, p, a[1].mul(tu), o.add(i[0])), i = Fm(r, p + 32, s.add(i[1]), n.add(bt(r, p + 16))), [s, o] = [o, s], p += 64;
while (p !== u);
let l = tu.add(s.and(255).shl(1));
- return p = c, i[0] = i[0].add(e - 1 & 63), a[0] = a[0].add(i[0]), i[0] = i[0].add(a[0]), o = Xt(o.add(n).add(a[0]).add(yt(r, p + 8)), 37).mul(l), n = Xt(n.add(a[1]).add(yt(r, p + 48)), 42).mul(l), o = o.xor(i[1].mul(9)), n = n.add(a[0].mul(9).add(yt(r, p + 40))), s = Xt(s.add(i[0]), 33).mul(l), a = Um(r, p, a[1].mul(l), o.add(i[0])), i = Um(r, p + 32, s.add(i[1]), n.add(yt(r, p + 16))), [s, o] = [o, s], ni(ni(a[0], i[0], l).add(Eb(n).mul($0)).add(s), ni(a[1], i[1], l).add(o), l);
+ return p = c, i[0] = i[0].add(e - 1 & 63), a[0] = a[0].add(i[0]), i[0] = i[0].add(a[0]), o = jt(o.add(n).add(a[0]).add(bt(r, p + 8)), 37).mul(l), n = jt(n.add(a[1]).add(bt(r, p + 48)), 42).mul(l), o = o.xor(i[1].mul(9)), n = n.add(a[0].mul(9).add(bt(r, p + 40))), s = jt(s.add(i[0]), 33).mul(l), a = Fm(r, p, a[1].mul(l), o.add(i[0])), i = Fm(r, p + 32, s.add(i[1]), n.add(bt(r, p + 16))), [s, o] = [o, s], hi(hi(a[0], i[0], l).add(vb(n).mul(nv)).add(s), hi(a[1], i[1], l).add(o), l);
}
-function $z(r, e) {
- return e === "string" ? si(r) : Pp([r], e);
+function QV(r, e) {
+ return e === "string" ? gi(r) : $p([r], e);
}
-function Rz(r, e) {
+function ZV(r, e) {
return r instanceof Float32Array && e === "float32" || r instanceof Int32Array && e === "int32" || r instanceof Uint8Array && e === "bool";
}
-function Pp(r, e) {
+function $p(r, e) {
if (e === "string")
throw new Error("Cannot convert a string[] to a TypedArray");
- if (Array.isArray(r) && (r = on(r)), P().getBool("DEBUG") && xb(r, e), Rz(r, e))
+ if (Array.isArray(r) && (r = Oo(r)), O().getBool("DEBUG") && mb(r, e), ZV(r, e))
return r;
if (e == null || e === "float32" || e === "complex64")
return new Float32Array(r);
if (e === "int32")
return new Int32Array(r);
if (e === "bool") {
- let t10 = new Uint8Array(r.length);
- for (let o = 0; o < t10.length; ++o)
- Math.round(r[o]) !== 0 && (t10[o] = 1);
- return t10;
+ let t6 = new Uint8Array(r.length);
+ for (let o = 0; o < t6.length; ++o)
+ Math.round(r[o]) !== 0 && (t6[o] = 1);
+ return t6;
} else
throw new Error(`Unknown data type ${e}`);
}
function ou() {
- return P().platform.now();
+ return O().platform.now();
}
-function Az(r, e) {
- return P().platform.fetch(r, e);
+function JV(r, e) {
+ return O().platform.fetch(r, e);
}
-function si(r, e = "utf-8") {
- return e = e || "utf-8", P().platform.encode(r, e);
+function gi(r, e = "utf-8") {
+ return e = e || "utf-8", O().platform.encode(r, e);
}
-function Op(r, e = "utf-8") {
- return e = e || "utf-8", P().platform.decode(r, e);
+function Ap(r, e = "utf-8") {
+ return e = e || "utf-8", O().platform.decode(r, e);
}
-var Gm = class {
- constructor(e, t10) {
- this.backendTimer = e, this.logger = t10, t10 == null && (this.logger = new Rb());
+var Dm = class {
+ constructor(e, t6) {
+ this.backendTimer = e, this.logger = t6, t6 == null && (this.logger = new Nb());
}
- profileKernel(e, t10, o) {
+ profileKernel(e, t6, o) {
let n, s = () => {
n = o();
}, a, i = ou();
@@ -3677,66 +3685,66 @@ var Gm = class {
u.dataSync();
a = Promise.resolve({ kernelMs: ou() - i });
}
- if (P().getBool("CHECK_COMPUTATION_FOR_ERRORS"))
+ if (O().getBool("CHECK_COMPUTATION_FOR_ERRORS"))
for (let u = 0; u < n.length; u++) {
let c = n[u];
c.data().then((l) => {
- Fz(l, c.dtype, e);
+ ez(l, c.dtype, e);
});
}
- return { kernelName: e, outputs: n, inputs: t10, timeMs: a.then((u) => u.kernelMs), extraInfo: a.then((u) => u.getExtraProfileInfo != null ? u.getExtraProfileInfo() : "") };
+ return { kernelName: e, outputs: n, inputs: t6, timeMs: a.then((u) => u.kernelMs), extraInfo: a.then((u) => u.getExtraProfileInfo != null ? u.getExtraProfileInfo() : "") };
}
logKernelProfile(e) {
- let { kernelName: t10, outputs: o, timeMs: n, inputs: s, extraInfo: a } = e;
+ let { kernelName: t6, outputs: o, timeMs: n, inputs: s, extraInfo: a } = e;
o.forEach((i) => {
Promise.all([i.data(), n, a]).then((p) => {
- this.logger.logKernelProfile(t10, i, p[0], p[1], s, p[2]);
+ this.logger.logKernelProfile(t6, i, p[0], p[1], s, p[2]);
});
});
}
};
-function Fz(r, e, t10) {
+function ez(r, e, t6) {
if (e !== "float32")
return false;
for (let o = 0; o < r.length; o++) {
let n = r[o];
if (isNaN(n) || !isFinite(n))
- return console.warn(`Found ${n} in the result of '${t10}'`), true;
+ return console.warn(`Found ${n} in the result of '${t6}'`), true;
}
return false;
}
-var Rb = class {
- logKernelProfile(e, t10, o, n, s, a) {
- let i = typeof n == "number" ? Mi(`${n}ms`, 9) : n.error, p = Mi(e, 25), u = t10.rank, c = t10.size, l = Mi(t10.shape.toString(), 14), m = "";
- for (let f in s) {
- let d = s[f];
- if (d != null) {
- let h = d.shape || t10.shape, g = h.length;
- m += `${f}: ${g}D ${g > 0 ? h : ""} `;
+var Nb = class {
+ logKernelProfile(e, t6, o, n, s, a) {
+ let i = typeof n == "number" ? ji(`${n}ms`, 9) : n.error, p = ji(e, 25), u = t6.rank, c = t6.size, l = ji(t6.shape.toString(), 14), m = "";
+ for (let d in s) {
+ let f = s[d];
+ if (f != null) {
+ let h = f.shape || t6.shape, g = h.length;
+ m += `${d}: ${g}D ${g > 0 ? h : ""} `;
}
}
console.log(`%c${p} %c${i} %c${u}D ${l} %c${c} %c${m} %c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue");
}
};
-function A0(r, e, t10) {
+function av(r, e, t6) {
let o = {}, n = {};
for (let p = 0; p < e.length; p++)
o[e[p].id] = true;
for (let p = 0; p < r.length; p++) {
let u = r[p], c = u.inputs;
for (let l in c) {
- let m = c[l], f = false;
- for (let d = 0; d < e.length; d++)
+ let m = c[l], d = false;
+ for (let f = 0; f < e.length; f++)
if (o[m.id]) {
- u.outputs.forEach((h) => o[h.id] = true), f = true, n[u.id] = true;
+ u.outputs.forEach((h) => o[h.id] = true), d = true, n[u.id] = true;
break;
}
- if (f)
+ if (d)
break;
}
}
let s = {};
- s[t10.id] = true;
+ s[t6.id] = true;
let a = {};
for (let p = r.length - 1; p >= 0; p--) {
let u = r[p], c = u.inputs;
@@ -3753,8 +3761,8 @@ function A0(r, e, t10) {
if (n[u.id] && a[u.id]) {
let c = {};
for (let m in u.inputs) {
- let f = u.inputs[m];
- o[f.id] && (c[m] = f);
+ let d = u.inputs[m];
+ o[d.id] && (c[m] = d);
}
let l = Object.assign({}, u);
l.inputs = c, l.outputs = u.outputs, i.push(l);
@@ -3762,7 +3770,7 @@ function A0(r, e, t10) {
}
return i;
}
-function F0(r, e, t10, o) {
+function iv(r, e, t6, o) {
for (let n = e.length - 1; n >= 0; n--) {
let s = e[n], a = [];
if (s.outputs.forEach((p) => {
@@ -3774,11 +3782,11 @@ function F0(r, e, t10, o) {
for (let p in s.inputs) {
if (!(p in i))
throw new Error(`Cannot backprop through input ${p}. Available gradients found: ${Object.keys(i)}.`);
- let u = t10(() => i[p]());
+ let u = t6(() => i[p]());
if (u.dtype !== "float32")
throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${p} must have 'float32' dtype, but has '${u.dtype}'`);
let c = s.inputs[p];
- if (!Or(u.shape, c.shape))
+ if (!Pr(u.shape, c.shape))
throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${p}' has shape '${u.shape}', which does not match the shape of the input '${c.shape}'`);
if (r[c.id] == null)
r[c.id] = u;
@@ -3789,105 +3797,105 @@ function F0(r, e, t10, o) {
}
}
}
-var D0 = 20;
-var rl = 3;
-var Ab = 7;
-function P0(r, e, t10, o) {
- let n = ds(e), s = Dz(r, e, t10, n), a = e.length, i = Hm(r, e, t10, n, s), p = ["Tensor"];
- return o && (p.push(` dtype: ${t10}`), p.push(` rank: ${a}`), p.push(` shape: [${e}]`), p.push(" values:")), p.push(i.map((u) => " " + u).join(`
+var uv = 20;
+var jc = 3;
+var Tb = 7;
+function pv(r, e, t6, o) {
+ let n = hs(e), s = tz(r, e, t6, n), a = e.length, i = Om(r, e, t6, n, s), p = ["Tensor"];
+ return o && (p.push(` dtype: ${t6}`), p.push(` rank: ${a}`), p.push(` shape: [${e}]`), p.push(" values:")), p.push(i.map((u) => " " + u).join(`
`)), p.join(`
`);
}
-function Dz(r, e, t10, o) {
- let n = Ve(e), s = o[o.length - 1], a = new Array(s).fill(0), i = e.length, p = t10 === "complex64" ? nl(r) : r;
+function tz(r, e, t6, o) {
+ let n = ze(e), s = o[o.length - 1], a = new Array(s).fill(0), i = e.length, p = t6 === "complex64" ? Yc(r) : r;
if (i > 1)
for (let u = 0; u < n / s; u++) {
let c = u * s;
for (let l = 0; l < s; l++)
- a[l] = Math.max(a[l], ol(p[c + l], 0, t10).length);
+ a[l] = Math.max(a[l], Xc(p[c + l], 0, t6).length);
}
return a;
}
-function ol(r, e, t10) {
+function Xc(r, e, t6) {
let o;
- return Array.isArray(r) ? o = `${parseFloat(r[0].toFixed(Ab))} + ${parseFloat(r[1].toFixed(Ab))}j` : nn(r) ? o = `'${r}'` : t10 === "bool" ? o = O0(r) : o = parseFloat(r.toFixed(Ab)).toString(), Mi(o, e);
+ return Array.isArray(r) ? o = `${parseFloat(r[0].toFixed(Tb))} + ${parseFloat(r[1].toFixed(Tb))}j` : Po(r) ? o = `'${r}'` : t6 === "bool" ? o = cv(r) : o = parseFloat(r.toFixed(Tb)).toString(), ji(o, e);
}
-function O0(r) {
+function cv(r) {
return r === 0 ? "false" : "true";
}
-function Hm(r, e, t10, o, n, s = true) {
- let a = t10 === "complex64" ? 2 : 1, i = e[0], p = e.length;
+function Om(r, e, t6, o, n, s = true) {
+ let a = t6 === "complex64" ? 2 : 1, i = e[0], p = e.length;
if (p === 0) {
- if (t10 === "complex64") {
- let h = nl(r);
- return [ol(h[0], 0, t10)];
+ if (t6 === "complex64") {
+ let h = Yc(r);
+ return [Xc(h[0], 0, t6)];
}
- return t10 === "bool" ? [O0(r[0])] : [r[0].toString()];
+ return t6 === "bool" ? [cv(r[0])] : [r[0].toString()];
}
if (p === 1) {
- if (i > D0) {
- let g = rl * a, y = Array.from(r.slice(0, g)), b = Array.from(r.slice((i - rl) * a, i * a));
- return t10 === "complex64" && (y = nl(y), b = nl(b)), ["[" + y.map((C, w) => ol(C, n[w], t10)).join(", ") + ", ..., " + b.map((C, w) => ol(C, n[i - rl + w], t10)).join(", ") + "]"];
+ if (i > uv) {
+ let g = jc * a, x = Array.from(r.slice(0, g)), b = Array.from(r.slice((i - jc) * a, i * a));
+ return t6 === "complex64" && (x = Yc(x), b = Yc(b)), ["[" + x.map((C, w) => Xc(C, n[w], t6)).join(", ") + ", ..., " + b.map((C, w) => Xc(C, n[i - jc + w], t6)).join(", ") + "]"];
}
- return ["[" + (t10 === "complex64" ? nl(r) : Array.from(r)).map((g, y) => ol(g, n[y], t10)).join(", ") + "]"];
+ return ["[" + (t6 === "complex64" ? Yc(r) : Array.from(r)).map((g, x) => Xc(g, n[x], t6)).join(", ") + "]"];
}
let u = e.slice(1), c = o.slice(1), l = o[0] * a, m = [];
- if (i > D0) {
- for (let h = 0; h < rl; h++) {
- let g = h * l, y = g + l;
- m.push(...Hm(r.slice(g, y), u, t10, c, n, false));
+ if (i > uv) {
+ for (let h = 0; h < jc; h++) {
+ let g = h * l, x = g + l;
+ m.push(...Om(r.slice(g, x), u, t6, c, n, false));
}
m.push("...");
- for (let h = i - rl; h < i; h++) {
- let g = h * l, y = g + l;
- m.push(...Hm(r.slice(g, y), u, t10, c, n, h === i - 1));
+ for (let h = i - jc; h < i; h++) {
+ let g = h * l, x = g + l;
+ m.push(...Om(r.slice(g, x), u, t6, c, n, h === i - 1));
}
} else
for (let h = 0; h < i; h++) {
- let g = h * l, y = g + l;
- m.push(...Hm(r.slice(g, y), u, t10, c, n, h === i - 1));
+ let g = h * l, x = g + l;
+ m.push(...Om(r.slice(g, x), u, t6, c, n, h === i - 1));
}
- let f = p === 2 ? "," : "";
- m[0] = "[" + m[0] + f;
+ let d = p === 2 ? "," : "";
+ m[0] = "[" + m[0] + d;
for (let h = 1; h < m.length - 1; h++)
- m[h] = " " + m[h] + f;
- let d = `,
+ m[h] = " " + m[h] + d;
+ let f = `,
`;
for (let h = 2; h < p; h++)
- d += `
+ f += `
`;
- return m[m.length - 1] = " " + m[m.length - 1] + "]" + (s ? "" : d), m;
+ return m[m.length - 1] = " " + m[m.length - 1] + "]" + (s ? "" : f), m;
}
-function nl(r) {
+function Yc(r) {
let e = [];
- for (let t10 = 0; t10 < r.length; t10 += 2)
- e.push([r[t10], r[t10 + 1]]);
+ for (let t6 = 0; t6 < r.length; t6 += 2)
+ e.push([r[t6], r[t6 + 1]]);
return e;
}
-var je = class {
- constructor(e, t10, o) {
- if (this.dtype = t10, this.shape = e.slice(), this.size = Ve(e), o != null) {
+var st = class {
+ constructor(e, t6, o) {
+ if (this.dtype = t6, this.shape = e.slice(), this.size = ze(e), o != null) {
let n = o.length;
- $(n === this.size, () => `Length of values '${n}' does not match the size inferred by the shape '${this.size}'.`);
+ E(n === this.size, () => `Length of values '${n}' does not match the size inferred by the shape '${this.size}'.`);
}
- if (t10 === "complex64")
+ if (t6 === "complex64")
throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");
- this.values = o || gb(t10, this.size), this.strides = ds(e);
+ this.values = o || lb(t6, this.size), this.strides = hs(e);
}
- set(e, ...t10) {
- t10.length === 0 && (t10 = [0]), $(t10.length === this.rank, () => `The number of provided coordinates (${t10.length}) must match the rank (${this.rank})`);
- let o = this.locToIndex(t10);
+ set(e, ...t6) {
+ t6.length === 0 && (t6 = [0]), E(t6.length === this.rank, () => `The number of provided coordinates (${t6.length}) must match the rank (${this.rank})`);
+ let o = this.locToIndex(t6);
this.values[o] = e;
}
get(...e) {
e.length === 0 && (e = [0]);
- let t10 = 0;
+ let t6 = 0;
for (let n of e) {
- if (n < 0 || n >= this.shape[t10]) {
+ if (n < 0 || n >= this.shape[t6]) {
let s = `Requested out of range element at ${e}. Buffer shape=${this.shape}`;
throw new Error(s);
}
- t10++;
+ t6++;
}
let o = e[e.length - 1];
for (let n = 0; n < e.length - 1; ++n)
@@ -3899,20 +3907,20 @@ var je = class {
return 0;
if (this.rank === 1)
return e[0];
- let t10 = e[e.length - 1];
+ let t6 = e[e.length - 1];
for (let o = 0; o < e.length - 1; ++o)
- t10 += this.strides[o] * e[o];
- return t10;
+ t6 += this.strides[o] * e[o];
+ return t6;
}
indexToLoc(e) {
if (this.rank === 0)
return [];
if (this.rank === 1)
return [e];
- let t10 = new Array(this.shape.length);
- for (let o = 0; o < t10.length - 1; ++o)
- t10[o] = Math.floor(e / this.strides[o]), e -= t10[o] * this.strides[o];
- return t10[t10.length - 1] = e, t10;
+ let t6 = new Array(this.shape.length);
+ for (let o = 0; o < t6.length - 1; ++o)
+ t6[o] = Math.floor(e / this.strides[o]), e -= t6[o] * this.strides[o];
+ return t6[t6.length - 1] = e, t6;
}
get rank() {
return this.shape.length;
@@ -3922,45 +3930,45 @@ var je = class {
}
};
var rs = null;
-var Mp = null;
-var Pz = null;
-function M0(r) {
+var Rp = null;
+var rz = null;
+function lv(r) {
rs = r;
}
-function L0(r) {
- Mp = r;
+function mv(r) {
+ Rp = r;
}
-function B0(r) {
- Pz = r;
+function dv(r) {
+ rz = r;
}
-var ut = class {
- constructor(e, t10, o, n) {
- this.kept = false, this.isDisposedInternal = false, this.shape = e.slice(), this.dtype = t10 || "float32", this.size = Ve(e), this.strides = ds(e), this.dataId = o, this.id = n, this.rankType = this.rank < 5 ? this.rank.toString() : "higher";
+var it = class {
+ constructor(e, t6, o, n) {
+ this.kept = false, this.isDisposedInternal = false, this.shape = e.slice(), this.dtype = t6 || "float32", this.size = ze(e), this.strides = hs(e), this.dataId = o, this.id = n, this.rankType = this.rank < 5 ? this.rank.toString() : "higher";
}
get rank() {
return this.shape.length;
}
async buffer() {
let e = await this.data();
- return Mp.buffer(this.shape, this.dtype, e);
+ return Rp.buffer(this.shape, this.dtype, e);
}
bufferSync() {
- return Mp.buffer(this.shape, this.dtype, this.dataSync());
+ return Rp.buffer(this.shape, this.dtype, this.dataSync());
}
async array() {
let e = await this.data();
- return Oi(this.shape, e, this.dtype === "complex64");
+ return Ki(this.shape, e, this.dtype === "complex64");
}
arraySync() {
- return Oi(this.shape, this.dataSync(), this.dtype === "complex64");
+ return Ki(this.shape, this.dataSync(), this.dtype === "complex64");
}
async data() {
this.throwIfDisposed();
let e = rs().read(this.dataId);
if (this.dtype === "string") {
- let t10 = await e;
+ let t6 = await e;
try {
- return t10.map((o) => Op(o));
+ return t6.map((o) => Ap(o));
} catch (o) {
throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");
}
@@ -3975,8 +3983,8 @@ var ut = class {
let e = rs().readSync(this.dataId);
if (this.dtype === "string")
try {
- return e.map((t10) => Op(t10));
- } catch (t10) {
+ return e.map((t6) => Ap(t6));
+ } catch (t6) {
throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");
}
return e;
@@ -3997,35 +4005,35 @@ var ut = class {
throw new Error("Tensor is disposed.");
}
print(e = false) {
- return Mp.print(this, e);
+ return Rp.print(this, e);
}
clone() {
- return this.throwIfDisposed(), Mp.clone(this);
+ return this.throwIfDisposed(), Rp.clone(this);
}
toString(e = false) {
- let t10 = this.dataSync();
- return P0(t10, this.shape, this.dtype, e);
+ let t6 = this.dataSync();
+ return pv(t6, this.shape, this.dtype, e);
}
cast(e) {
- return this.throwIfDisposed(), Mp.cast(this, e);
+ return this.throwIfDisposed(), Rp.cast(this, e);
}
- variable(e = true, t10, o) {
- return this.throwIfDisposed(), rs().makeVariable(this, e, t10, o);
+ variable(e = true, t6, o) {
+ return this.throwIfDisposed(), rs().makeVariable(this, e, t6, o);
}
};
-Object.defineProperty(ut, Symbol.hasInstance, { value: (r) => !!r && r.data != null && r.dataSync != null && r.throwIfDisposed != null });
-function Oz() {
- return Zc("Tensor", () => ut);
+Object.defineProperty(it, Symbol.hasInstance, { value: (r) => !!r && r.data != null && r.dataSync != null && r.throwIfDisposed != null });
+function oz() {
+ return Gc("Tensor", () => it);
}
-Oz();
-var ba = class extends ut {
- constructor(e, t10, o, n) {
- super(e.shape, e.dtype, e.dataId, n), this.trainable = t10, this.name = o;
+oz();
+var va = class extends it {
+ constructor(e, t6, o, n) {
+ super(e.shape, e.dtype, e.dataId, n), this.trainable = t6, this.name = o;
}
assign(e) {
if (e.dtype !== this.dtype)
throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);
- if (!Or(e.shape, this.shape))
+ if (!Pr(e.shape, this.shape))
throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);
rs().disposeTensor(this), this.dataId = e.dataId, rs().incRef(this, null);
}
@@ -4033,79 +4041,79 @@ var ba = class extends ut {
rs().disposeVariable(this), this.isDisposedInternal = true;
}
};
-Object.defineProperty(ba, Symbol.hasInstance, { value: (r) => r instanceof ut && r.assign != null && r.assign instanceof Function });
-var z0 = {};
-Be(z0, { assertTypesMatch: () => Lb, getTensorsInContainer: () => sl, isTensorInList: () => Lz, makeTypesMatch: () => Re });
-var Fb;
+Object.defineProperty(va, Symbol.hasInstance, { value: (r) => r instanceof it && r.assign != null && r.assign instanceof Function });
+var hv = {};
+Ue(hv, { assertTypesMatch: () => Fb, getTensorsInContainer: () => Qc, isTensorInList: () => sz, makeTypesMatch: () => Re });
+var _b;
(function(r) {
r.R0 = "R0", r.R1 = "R1", r.R2 = "R2", r.R3 = "R3", r.R4 = "R4", r.R5 = "R5", r.R6 = "R6";
-})(Fb || (Fb = {}));
-var Db;
+})(_b || (_b = {}));
+var Eb;
(function(r) {
r.float32 = "float32", r.int32 = "int32", r.bool = "int32", r.complex64 = "complex64";
-})(Db || (Db = {}));
-var Pb;
+})(Eb || (Eb = {}));
+var $b;
(function(r) {
r.float32 = "float32", r.int32 = "int32", r.bool = "bool", r.complex64 = "complex64";
-})(Pb || (Pb = {}));
-var Ob;
+})($b || ($b = {}));
+var Ab;
(function(r) {
r.float32 = "float32", r.int32 = "float32", r.bool = "float32", r.complex64 = "complex64";
-})(Ob || (Ob = {}));
-var Mb;
+})(Ab || (Ab = {}));
+var Rb;
(function(r) {
r.float32 = "complex64", r.int32 = "complex64", r.bool = "complex64", r.complex64 = "complex64";
-})(Mb || (Mb = {}));
-var Mz = { float32: Ob, int32: Db, bool: Pb, complex64: Mb };
-function ct(r, e) {
+})(Rb || (Rb = {}));
+var nz = { float32: Ab, int32: Eb, bool: $b, complex64: Rb };
+function dt(r, e) {
if (r === "string" || e === "string") {
if (r === "string" && e === "string")
return "string";
throw new Error(`Can not upcast ${r} with ${e}`);
}
- return Mz[r][e];
+ return nz[r][e];
}
-function Ca(r) {
- return ct(r, "int32");
+function ka(r) {
+ return dt(r, "int32");
}
function Re(r, e) {
if (r.dtype === e.dtype)
return [r, e];
- let t10 = ct(r.dtype, e.dtype);
- return [r.cast(t10), e.cast(t10)];
+ let t6 = dt(r.dtype, e.dtype);
+ return [r.cast(t6), e.cast(t6)];
}
-function Lb(r, e) {
- $(r.dtype === e.dtype, () => `The dtypes of the first(${r.dtype}) and second(${e.dtype}) input must match`);
+function Fb(r, e) {
+ E(r.dtype === e.dtype, () => `The dtypes of the first(${r.dtype}) and second(${e.dtype}) input must match`);
}
-function Lz(r, e) {
- return e.some((t10) => t10.id === r.id);
+function sz(r, e) {
+ return e.some((t6) => t6.id === r.id);
}
-function sl(r) {
+function Qc(r) {
let e = [];
- return V0(r, e, /* @__PURE__ */ new Set()), e;
+ return fv(r, e, /* @__PURE__ */ new Set()), e;
}
-function V0(r, e, t10) {
+function fv(r, e, t6) {
if (r == null)
return;
- if (r instanceof ut) {
+ if (r instanceof it) {
e.push(r);
return;
}
- if (!Bz(r))
+ if (!az(r))
return;
let o = r;
for (let n in o) {
let s = o[n];
- t10.has(s) || (t10.add(s), V0(s, e, t10));
+ t6.has(s) || (t6.add(s), fv(s, e, t6));
}
}
-function Bz(r) {
+function az(r) {
return Array.isArray(r) || typeof r == "object";
}
-function Bb(r) {
+function Db(r) {
return r.kernelName != null;
}
-var qm = class {
+var Pm = class {
constructor() {
this.registeredVariables = {}, this.nextTapeNodeId = 0, this.numBytes = 0, this.numTensors = 0, this.numStringTensors = 0, this.numDataBuffers = 0, this.gradientDepth = 0, this.kernelDepth = 0, this.scopeStack = [], this.numDataMovesStack = [], this.nextScopeId = 0, this.tensorInfo = /* @__PURE__ */ new WeakMap(), this.profiling = false, this.activeProfile = { newBytes: 0, newTensors: 0, peakBytes: 0, kernels: [], result: null, get kernelNames() {
return Array.from(new Set(this.kernels.map((e) => e.name)));
@@ -4116,9 +4124,9 @@ var qm = class {
this.registeredVariables[e].dispose();
}
};
-var ai = class {
+var xi = class {
constructor(e) {
- this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new qm();
+ this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new Pm();
}
async ready() {
if (this.pendingBackendInit != null)
@@ -4127,8 +4135,8 @@ var ai = class {
if (this.backendInstance != null)
return;
let e = this.getSortedBackends();
- for (let t10 = 0; t10 < e.length; t10++) {
- let o = e[t10];
+ for (let t6 = 0; t6 < e.length; t6++) {
+ let o = e[t6];
if (await this.initializeBackend(o).success) {
await this.setBackend(o);
return;
@@ -4140,8 +4148,8 @@ var ai = class {
if (this.pendingBackendInit != null)
throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);
if (this.backendInstance == null) {
- let { name: e, asyncInit: t10 } = this.initializeBackendsAndReturnBest();
- if (t10)
+ let { name: e, asyncInit: t6 } = this.initializeBackendsAndReturnBest();
+ if (t6)
throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);
this.setBackend(e);
}
@@ -4153,8 +4161,8 @@ var ai = class {
findBackend(e) {
if (!(e in this.registry))
if (e in this.registryFactory) {
- let { asyncInit: t10 } = this.initializeBackend(e);
- if (t10)
+ let { asyncInit: t6 } = this.initializeBackend(e);
+ if (t6)
return null;
} else
return null;
@@ -4163,43 +4171,43 @@ var ai = class {
findBackendFactory(e) {
return e in this.registryFactory ? this.registryFactory[e].factory : null;
}
- registerBackend(e, t10, o = 1) {
- return e in this.registryFactory ? (Rs(`${e} backend was already registered. Reusing existing backend factory.`), false) : (this.registryFactory[e] = { factory: t10, priority: o }, true);
+ registerBackend(e, t6, o = 1) {
+ return e in this.registryFactory ? (Os(`${e} backend was already registered. Reusing existing backend factory.`), false) : (this.registryFactory[e] = { factory: t6, priority: o }, true);
}
async setBackend(e) {
if (this.registryFactory[e] == null)
throw new Error(`Backend name '${e}' not found in registry`);
if (this.backendName = e, this.registry[e] == null) {
this.backendInstance = null;
- let { success: t10, asyncInit: o } = this.initializeBackend(e);
- if (!(o ? await t10 : t10))
+ let { success: t6, asyncInit: o } = this.initializeBackend(e);
+ if (!(o ? await t6 : t6))
return false;
}
- return this.backendInstance = this.registry[e], this.setupRegisteredKernels(), this.profiler = new Gm(this.backendInstance), true;
+ return this.backendInstance = this.registry[e], this.setupRegisteredKernels(), this.profiler = new Dm(this.backendInstance), true;
}
setupRegisteredKernels() {
- zm(this.backendName).forEach((t10) => {
- t10.setupFunc != null && t10.setupFunc(this.backendInstance);
+ Am(this.backendName).forEach((t6) => {
+ t6.setupFunc != null && t6.setupFunc(this.backendInstance);
});
}
disposeRegisteredKernels(e) {
- zm(e).forEach((o) => {
+ Am(e).forEach((o) => {
o.disposeFunc != null && o.disposeFunc(this.registry[e]);
});
}
initializeBackend(e) {
- let t10 = this.registryFactory[e];
- if (t10 == null)
+ let t6 = this.registryFactory[e];
+ if (t6 == null)
throw new Error(`Cannot initialize backend ${e}, no registration found.`);
try {
- let o = t10.factory();
- if (o && !(o instanceof Jr) && typeof o.then == "function") {
- let n = ++this.pendingBackendInitId, s = o.then((a) => n < this.pendingBackendInitId ? false : (this.registry[e] = a, this.pendingBackendInit = null, true)).catch((a) => (n < this.pendingBackendInitId || (this.pendingBackendInit = null, Rs(`Initialization of backend ${e} failed`), Rs(a.stack || a.message)), false));
+ let o = t6.factory();
+ if (o && !(o instanceof Zr) && typeof o.then == "function") {
+ let n = ++this.pendingBackendInitId, s = o.then((a) => n < this.pendingBackendInitId ? false : (this.registry[e] = a, this.pendingBackendInit = null, true)).catch((a) => (n < this.pendingBackendInitId || (this.pendingBackendInit = null, Os(`Initialization of backend ${e} failed`), Os(a.stack || a.message)), false));
return this.pendingBackendInit = s, { success: s, asyncInit: true };
} else
return this.registry[e] = o, { success: true, asyncInit: false };
} catch (o) {
- return Rs(`Initialization of backend ${e} failed`), Rs(o.stack || o.message), { success: false, asyncInit: false };
+ return Os(`Initialization of backend ${e} failed`), Os(o.stack || o.message), { success: false, asyncInit: false };
}
}
removeBackend(e) {
@@ -4210,181 +4218,181 @@ var ai = class {
getSortedBackends() {
if (Object.keys(this.registryFactory).length === 0)
throw new Error("No backend found in registry.");
- return Object.keys(this.registryFactory).sort((e, t10) => this.registryFactory[t10].priority - this.registryFactory[e].priority);
+ return Object.keys(this.registryFactory).sort((e, t6) => this.registryFactory[t6].priority - this.registryFactory[e].priority);
}
initializeBackendsAndReturnBest() {
let e = this.getSortedBackends();
- for (let t10 = 0; t10 < e.length; t10++) {
- let o = e[t10], { success: n, asyncInit: s } = this.initializeBackend(o);
+ for (let t6 = 0; t6 < e.length; t6++) {
+ let o = e[t6], { success: n, asyncInit: s } = this.initializeBackend(o);
if (s || n)
return { name: o, asyncInit: s };
}
throw new Error("Could not initialize any backends, all backend initializations failed.");
}
- moveData(e, t10) {
- let o = this.state.tensorInfo.get(t10), n = o.backend, s = this.readSync(t10), a = n.refCount(t10);
- n.disposeData(t10, true), o.backend = e, e.move(t10, s, o.shape, o.dtype, a), this.shouldCheckForMemLeaks() && this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++;
+ moveData(e, t6) {
+ let o = this.state.tensorInfo.get(t6), n = o.backend, s = this.readSync(t6), a = n.refCount(t6);
+ n.disposeData(t6, true), o.backend = e, e.move(t6, s, o.shape, o.dtype, a), this.shouldCheckForMemLeaks() && this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++;
}
- tidy(e, t10) {
+ tidy(e, t6) {
let o = null;
- if (t10 == null) {
+ if (t6 == null) {
if (typeof e != "function")
throw new Error("Please provide a function to tidy()");
- t10 = e;
+ t6 = e;
} else {
if (typeof e != "string" && !(e instanceof String))
throw new Error("When calling with two arguments, the first argument to tidy() must be a string");
- if (typeof t10 != "function")
+ if (typeof t6 != "function")
throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");
o = e;
}
let n;
- return this.scopedRun(() => this.startScope(o), () => this.endScope(n), () => (n = t10(), n instanceof Promise && console.error("Cannot return a Promise inside of tidy."), n));
+ return this.scopedRun(() => this.startScope(o), () => this.endScope(n), () => (n = t6(), n instanceof Promise && console.error("Cannot return a Promise inside of tidy."), n));
}
- scopedRun(e, t10, o) {
+ scopedRun(e, t6, o) {
e();
try {
let n = o();
- return t10(), n;
+ return t6(), n;
} catch (n) {
- throw t10(), n;
+ throw t6(), n;
}
}
nextTensorId() {
- return ai.nextTensorId++;
+ return xi.nextTensorId++;
}
nextVariableId() {
- return ai.nextVariableId++;
+ return xi.nextVariableId++;
}
clone(e) {
- let t10 = N.runKernel(uo, { x: e }), o = { x: e }, n = (a) => ({ x: () => {
+ let t6 = T.runKernel(mo, { x: e }), o = { x: e }, n = (a) => ({ x: () => {
let i = "float32", p = { x: a }, u = { dtype: i };
- return N.runKernel(to, p, u);
+ return T.runKernel(co, p, u);
} }), s = [];
- return this.addTapeNode(this.state.activeScope.name, o, [t10], n, s, {}), t10;
+ return this.addTapeNode(this.state.activeScope.name, o, [t6], n, s, {}), t6;
}
- runKernel(e, t10, o) {
- if (this.backendName == null && this.backend, !(el(e, this.backendName) != null))
+ runKernel(e, t6, o) {
+ if (this.backendName == null && this.backend, !(qc(e, this.backendName) != null))
throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);
- return this.runKernelFunc({ kernelName: e, inputs: t10, attrs: o });
+ return this.runKernelFunc({ kernelName: e, inputs: t6, attrs: o });
}
shouldCheckForMemLeaks() {
return this.ENV.getBool("IS_TEST");
}
- checkKernelForMemLeak(e, t10, o) {
+ checkKernelForMemLeak(e, t6, o) {
let n = this.backend.numDataIds(), s = 0;
o.forEach((p) => {
s += p.dtype === "complex64" ? 3 : 1;
});
- let a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], i = n - t10 - s - a;
+ let a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], i = n - t6 - s - a;
if (i > 0)
throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`);
}
runKernelFunc(e) {
- let t10, o = [], n = this.isTapeOn(), s = this.state.numBytes, a = this.state.numTensors;
+ let t6, o = [], n = this.isTapeOn(), s = this.state.numBytes, a = this.state.numTensors;
this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0);
let i;
this.backendName == null && this.backend;
- let p, u = Bb(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : "";
- if (Bb(e)) {
- let { kernelName: d, inputs: h, attrs: g } = e;
+ let p, u = Db(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : "";
+ if (Db(e)) {
+ let { kernelName: f, inputs: h, attrs: g } = e;
this.backendName == null && this.backend;
- let y = el(d, this.backendName);
- $(y != null, () => `Cannot find registered kernel '${d}' for backend '${this.backendName}'`), i = () => {
+ let x = qc(f, this.backendName);
+ E(x != null, () => `Cannot find registered kernel '${f}' for backend '${this.backendName}'`), i = () => {
let b = this.backend.numDataIds();
- p = y.kernelFunc({ inputs: h, attrs: g, backend: this.backend });
+ p = x.kernelFunc({ inputs: h, attrs: g, backend: this.backend });
let C = Array.isArray(p) ? p : [p];
- this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(d, b, C);
+ this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(f, b, C);
let w = C.map((k) => k.rank != null ? k : this.makeTensorFromTensorInfo(k));
if (n) {
- let k = this.getTensorsForGradient(d, h, w);
+ let k = this.getTensorsForGradient(f, h, w);
o = this.saveTensorsForBackwardMode(k);
}
return w;
};
} else {
- let { forwardFunc: d } = e, h = (g) => {
- !n || (o = g.map((y) => this.keep(this.clone(y))));
+ let { forwardFunc: f } = e, h = (g) => {
+ !n || (o = g.map((x) => this.keep(this.clone(x))));
};
i = () => {
let g = this.backend.numDataIds();
- p = this.tidy(() => d(this.backend, h));
- let y = Array.isArray(p) ? p : [p];
- return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(u, g, y), y;
+ p = this.tidy(() => f(this.backend, h));
+ let x = Array.isArray(p) ? p : [p];
+ return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(u, g, x), x;
};
}
- let { inputs: c, attrs: l } = e, m = Bb(e) ? null : e.backwardsFunc, f;
+ let { inputs: c, attrs: l } = e, m = Db(e) ? null : e.backwardsFunc, d;
return this.scopedRun(() => this.state.kernelDepth++, () => this.state.kernelDepth--, () => {
- !this.ENV.getBool("DEBUG") && !this.state.profiling ? t10 = i() : (f = this.profiler.profileKernel(u, c, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(f), t10 = f.outputs);
- }), n && this.addTapeNode(u, c, t10, m, o, l), this.state.profiling && this.state.activeProfile.kernels.push({ name: u, bytesAdded: this.state.numBytes - s, totalBytesSnapshot: this.state.numBytes, tensorsAdded: this.state.numTensors - a, totalTensorsSnapshot: this.state.numTensors, inputShapes: Object.keys(c).map((d) => c[d] != null ? c[d].shape : null), outputShapes: t10.map((d) => d.shape), kernelTimeMs: f.timeMs, extraInfo: f.extraInfo }), Array.isArray(p) ? t10 : t10[0];
+ !this.ENV.getBool("DEBUG") && !this.state.profiling ? t6 = i() : (d = this.profiler.profileKernel(u, c, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(d), t6 = d.outputs);
+ }), n && this.addTapeNode(u, c, t6, m, o, l), this.state.profiling && this.state.activeProfile.kernels.push({ name: u, bytesAdded: this.state.numBytes - s, totalBytesSnapshot: this.state.numBytes, tensorsAdded: this.state.numTensors - a, totalTensorsSnapshot: this.state.numTensors, inputShapes: Object.keys(c).map((f) => c[f] != null ? c[f].shape : null), outputShapes: t6.map((f) => f.shape), kernelTimeMs: d.timeMs, extraInfo: d.extraInfo }), Array.isArray(p) ? t6 : t6[0];
}
saveTensorsForBackwardMode(e) {
return e.map((o) => this.keep(this.clone(o)));
}
- getTensorsForGradient(e, t10, o) {
- let n = kb(e);
+ getTensorsForGradient(e, t6, o) {
+ let n = Cb(e);
if (n != null) {
let s = n.inputsToSave || [], a = n.outputsToSave || [], i;
- n.saveAllInputs ? ($(Array.isArray(t10), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(t10).map((u) => t10[u])) : i = s.map((u) => t10[u]);
+ n.saveAllInputs ? (E(Array.isArray(t6), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(t6).map((u) => t6[u])) : i = s.map((u) => t6[u]);
let p = o.filter((u, c) => a[c]);
return i.concat(p);
}
return [];
}
- makeTensor(e, t10, o, n) {
+ makeTensor(e, t6, o, n) {
if (e == null)
throw new Error("Values passed to engine.makeTensor() are null");
o = o || "float32", n = n || this.backend;
let s = e;
- o === "string" && nn(e[0]) && (s = e.map((p) => si(p)));
- let a = n.write(s, t10, o), i = new ut(t10, o, a, this.nextTensorId());
+ o === "string" && Po(e[0]) && (s = e.map((p) => gi(p)));
+ let a = n.write(s, t6, o), i = new it(t6, o, a, this.nextTensorId());
if (this.trackTensor(i, n), o === "string") {
- let p = this.state.tensorInfo.get(a), u = bb(s);
+ let p = this.state.tensorInfo.get(a), u = fb(s);
this.state.numBytes += u - p.bytes, p.bytes = u;
}
return i;
}
- makeTensorFromDataId(e, t10, o, n) {
+ makeTensorFromDataId(e, t6, o, n) {
o = o || "float32";
- let s = { dataId: e, shape: t10, dtype: o };
+ let s = { dataId: e, shape: t6, dtype: o };
return this.makeTensorFromTensorInfo(s, n);
}
- makeTensorFromTensorInfo(e, t10) {
- let { dataId: o, shape: n, dtype: s } = e, a = new ut(n, s, o, this.nextTensorId());
- return this.trackTensor(a, t10), a;
+ makeTensorFromTensorInfo(e, t6) {
+ let { dataId: o, shape: n, dtype: s } = e, a = new it(n, s, o, this.nextTensorId());
+ return this.trackTensor(a, t6), a;
}
- makeVariable(e, t10 = true, o, n) {
+ makeVariable(e, t6 = true, o, n) {
o = o || this.nextVariableId().toString(), n != null && n !== e.dtype && (e = e.cast(n));
- let s = new ba(e, t10, o, this.nextTensorId());
+ let s = new va(e, t6, o, this.nextTensorId());
if (this.state.registeredVariables[s.name] != null)
throw new Error(`Variable with name ${s.name} was already registered`);
return this.state.registeredVariables[s.name] = s, this.incRef(s, this.backend), s;
}
- trackTensor(e, t10) {
+ trackTensor(e, t6) {
this.state.numTensors++, e.dtype === "string" && this.state.numStringTensors++;
let o = 0;
- e.dtype !== "complex64" && e.dtype !== "string" && (o = e.size * Rm(e.dtype)), this.state.numBytes += o, this.state.tensorInfo.has(e.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(e.dataId, { backend: t10 || this.backend, dtype: e.dtype, shape: e.shape, bytes: o })), e instanceof ba || this.track(e);
+ e.dtype !== "complex64" && e.dtype !== "string" && (o = e.size * Sm(e.dtype)), this.state.numBytes += o, this.state.tensorInfo.has(e.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(e.dataId, { backend: t6 || this.backend, dtype: e.dtype, shape: e.shape, bytes: o })), e instanceof va || this.track(e);
}
- incRef(e, t10) {
- this.trackTensor(e, t10), this.backend.incRef(e.dataId);
+ incRef(e, t6) {
+ this.trackTensor(e, t6), this.backend.incRef(e.dataId);
}
- removeDataId(e, t10) {
- this.state.tensorInfo.has(e) && this.state.tensorInfo.get(e).backend === t10 && (this.state.tensorInfo.delete(e), this.state.numDataBuffers--);
+ removeDataId(e, t6) {
+ this.state.tensorInfo.has(e) && this.state.tensorInfo.get(e).backend === t6 && (this.state.tensorInfo.delete(e), this.state.numDataBuffers--);
}
disposeTensor(e) {
if (!this.state.tensorInfo.has(e.dataId))
return;
- let t10 = this.state.tensorInfo.get(e.dataId);
- if (this.state.numTensors--, e.dtype === "string" && (this.state.numStringTensors--, this.state.numBytes -= t10.bytes), e.dtype !== "complex64" && e.dtype !== "string") {
- let o = e.size * Rm(e.dtype);
+ let t6 = this.state.tensorInfo.get(e.dataId);
+ if (this.state.numTensors--, e.dtype === "string" && (this.state.numStringTensors--, this.state.numBytes -= t6.bytes), e.dtype !== "complex64" && e.dtype !== "string") {
+ let o = e.size * Sm(e.dtype);
this.state.numBytes -= o;
}
- t10.backend.disposeData(e.dataId) && this.removeDataId(e.dataId, t10.backend);
+ t6.backend.disposeData(e.dataId) && this.removeDataId(e.dataId, t6.backend);
}
disposeVariables() {
for (let e in this.state.registeredVariables) {
- let t10 = this.state.registeredVariables[e];
- this.disposeVariable(t10);
+ let t6 = this.state.registeredVariables[e];
+ this.disposeVariable(t6);
}
}
disposeVariable(e) {
@@ -4396,8 +4404,8 @@ var ai = class {
}
async profile(e) {
this.state.profiling = true;
- let t10 = this.state.numBytes, o = this.state.numTensors;
- this.state.activeProfile.kernels = [], this.state.activeProfile.result = await e(), this.state.profiling = false, this.state.activeProfile.peakBytes = Math.max(...this.state.activeProfile.kernels.map((n) => n.totalBytesSnapshot)), this.state.activeProfile.newBytes = this.state.numBytes - t10, this.state.activeProfile.newTensors = this.state.numTensors - o;
+ let t6 = this.state.numBytes, o = this.state.numTensors;
+ this.state.activeProfile.kernels = [], this.state.activeProfile.result = await e(), this.state.profiling = false, this.state.activeProfile.peakBytes = Math.max(...this.state.activeProfile.kernels.map((n) => n.totalBytesSnapshot)), this.state.activeProfile.newBytes = this.state.numBytes - t6, this.state.activeProfile.newTensors = this.state.numTensors - o;
for (let n of this.state.activeProfile.kernels)
n.kernelTimeMs = await n.kernelTimeMs, n.extraInfo = await n.extraInfo;
return this.state.activeProfile;
@@ -4405,12 +4413,12 @@ var ai = class {
isTapeOn() {
return this.state.gradientDepth > 0 && this.state.kernelDepth === 0;
}
- addTapeNode(e, t10, o, n, s, a) {
- let i = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t10, outputs: o, saved: s }, p = kb(e);
+ addTapeNode(e, t6, o, n, s, a) {
+ let i = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t6, outputs: o, saved: s }, p = Cb(e);
p != null && (n = p.gradFunc), n != null && (i.gradient = (u) => (u = u.map((c, l) => {
if (c == null) {
- let m = o[l], f = ap(m.size, m.dtype);
- return this.makeTensor(f, m.shape, m.dtype);
+ let m = o[l], d = ap(m.size, m.dtype);
+ return this.makeTensor(d, m.shape, m.dtype);
}
return c;
}), n(u.length > 1 ? u : u[0], s, a))), this.state.activeTape.push(i);
@@ -4425,32 +4433,32 @@ var ai = class {
this.state.gradientDepth--;
}
startScope(e) {
- let t10 = { track: [], name: "unnamed scope", id: this.state.nextScopeId++ };
- e && (t10.name = e), this.state.scopeStack.push(t10), this.state.activeScope = t10;
+ let t6 = { track: [], name: "unnamed scope", id: this.state.nextScopeId++ };
+ e && (t6.name = e), this.state.scopeStack.push(t6), this.state.activeScope = t6;
}
endScope(e) {
- let t10 = sl(e), o = new Set(t10.map((s) => s.id));
+ let t6 = Qc(e), o = new Set(t6.map((s) => s.id));
for (let s = 0; s < this.state.activeScope.track.length; s++) {
let a = this.state.activeScope.track[s];
!a.kept && !o.has(a.id) && a.dispose();
}
let n = this.state.scopeStack.pop();
- this.state.activeScope = this.state.scopeStack.length === 0 ? null : this.state.scopeStack[this.state.scopeStack.length - 1], t10.forEach((s) => {
+ this.state.activeScope = this.state.scopeStack.length === 0 ? null : this.state.scopeStack[this.state.scopeStack.length - 1], t6.forEach((s) => {
!s.kept && s.scopeId === n.id && this.track(s);
});
}
- gradients(e, t10, o, n = false) {
- if ($(t10.length > 0, () => "gradients() received an empty list of xs."), o != null && o.dtype !== "float32")
+ gradients(e, t6, o, n = false) {
+ if (E(t6.length > 0, () => "gradients() received an empty list of xs."), o != null && o.dtype !== "float32")
throw new Error(`dy must have 'float32' dtype, but has '${o.dtype}'`);
let s = this.scopedRun(() => this.startTape(), () => this.endTape(), () => this.tidy("forward", e));
- $(s instanceof ut, () => "The result y returned by f() must be a tensor.");
- let a = A0(this.state.activeTape, t10, s);
- if (!n && a.length === 0 && t10.length > 0)
+ E(s instanceof it, () => "The result y returned by f() must be a tensor.");
+ let a = av(this.state.activeTape, t6, s);
+ if (!n && a.length === 0 && t6.length > 0)
throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");
return this.tidy("backward", () => {
let i = {};
- i[s.id] = o == null ? Vz(s.shape) : o, F0(i, a, (u) => this.tidy(u), zz);
- let p = t10.map((u) => i[u.id]);
+ i[s.id] = o == null ? iz(s.shape) : o, iv(i, a, (u) => this.tidy(u), uz);
+ let p = t6.map((u) => i[u.id]);
return this.state.gradientDepth === 0 && (this.state.activeTape.forEach((u) => {
for (let c of u.saved)
c.dispose();
@@ -4458,18 +4466,18 @@ var ai = class {
});
}
customGrad(e) {
- return $(fs(e), () => "The f passed in customGrad(f) must be a function."), (...t10) => {
- $(t10.every((i) => i instanceof ut), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors");
+ return E(fs(e), () => "The f passed in customGrad(f) must be a function."), (...t6) => {
+ E(t6.every((i) => i instanceof it), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors");
let o, n = {};
- t10.forEach((i, p) => {
+ t6.forEach((i, p) => {
n[p] = i;
});
- let s = (i, p) => (o = e(...t10, p), $(o.value instanceof ut, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), $(fs(o.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), o.value), a = (i, p) => {
+ let s = (i, p) => (o = e(...t6, p), E(o.value instanceof it, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), E(fs(o.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), o.value), a = (i, p) => {
let u = o.gradFunc(i, p), c = Array.isArray(u) ? u : [u];
- $(c.length === t10.length, () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."), $(c.every((m) => m instanceof ut), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");
+ E(c.length === t6.length, () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."), E(c.every((m) => m instanceof it), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");
let l = {};
- return c.forEach((m, f) => {
- l[f] = () => m;
+ return c.forEach((m, d) => {
+ l[d] = () => m;
}), l;
};
return this.runKernelFunc({ forwardFunc: s, backwardsFunc: a, inputs: n });
@@ -4481,12 +4489,12 @@ var ai = class {
read(e) {
return this.state.tensorInfo.get(e).backend.read(e);
}
- readToGPU(e, t10) {
- return this.state.tensorInfo.get(e).backend.readToGPU(e, t10);
+ readToGPU(e, t6) {
+ return this.state.tensorInfo.get(e).backend.readToGPU(e, t6);
}
async time(e) {
- let t10 = ou(), o = await this.backend.time(e);
- return o.wallMs = ou() - t10, o;
+ let t6 = ou(), o = await this.backend.time(e);
+ return o.wallMs = ou() - t6, o;
}
track(e) {
return this.state.activeScope != null && (e.scopeId = this.state.activeScope.id, this.state.activeScope.track.push(e)), e;
@@ -4495,77 +4503,76 @@ var ai = class {
return this.state.registeredVariables;
}
reset() {
- this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new qm();
+ this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new Pm();
for (let e in this.registry)
this.disposeRegisteredKernels(e), this.registry[e].dispose(), delete this.registry[e];
this.backendName = null, this.backendInstance = null, this.pendingBackendInit = null;
}
};
-ai.nextTensorId = 0;
-ai.nextVariableId = 0;
-function Vz(r) {
- let e = jc(Ve(r), "float32");
- return N.makeTensor(e, r, "float32");
+xi.nextTensorId = 0;
+xi.nextVariableId = 0;
+function iz(r) {
+ let e = zc(ze(r), "float32");
+ return T.makeTensor(e, r, "float32");
}
-function Vb() {
- let r = wb();
+function Ob() {
+ let r = xb();
if (r._tfengine == null) {
- let e = new Qc(r);
- r._tfengine = new ai(e);
+ let e = new Uc(r);
+ r._tfengine = new xi(e);
}
- return h0(r._tfengine.ENV), M0(() => r._tfengine), r._tfengine;
+ return UI(r._tfengine.ENV), lv(() => r._tfengine), r._tfengine;
}
-var N = Vb();
-function zz(r, e) {
- let t10 = { a: r, b: e };
- return N.runKernel(_r, t10);
+var T = Ob();
+function uz(r, e) {
+ let t6 = { a: r, b: e };
+ return T.runKernel(eo, t6);
}
-var ii = {};
-Be(ii, { isBrowser: () => Wb, isMobile: () => Gz, mockIsMobile: () => Uz });
-function Wz() {
+var yi = {};
+Ue(yi, { isBrowser: () => Mb, isMobile: () => lz, mockIsMobile: () => cz });
+function pz() {
return typeof navigator != "undefined" && navigator != null;
}
-var zb;
-function Uz(r) {
- zb = r;
+var Pb;
+function cz(r) {
+ Pb = r;
}
-function Gz(r) {
- if (zb !== void 0)
- return zb;
- if (r || Wz()) {
+function lz(r) {
+ if (Pb !== void 0)
+ return Pb;
+ if (r || pz()) {
if (r || (r = navigator), r.product === "ReactNative")
return true;
let e = r.userAgent || r.vendor || (typeof window != "undefined" ? window.opera : "");
if (!e) {
- let t10 = r;
- return t10.userAgentData && t10.userAgentData.mobile;
+ let t6 = r;
+ return t6.userAgentData && t6.userAgentData.mobile;
}
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0, 4));
}
return false;
}
-function Wb() {
+function Mb() {
return typeof window != "undefined" && window.document != null || typeof WorkerGlobalScope != "undefined";
}
-var Vr = P();
-Vr.registerFlag("DEBUG", () => false, (r) => {
+var oo = O();
+oo.registerFlag("DEBUG", () => false, (r) => {
r && console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.");
});
-Vr.registerFlag("IS_BROWSER", () => Wb());
-Vr.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined");
-Vr.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor));
-Vr.registerFlag("PROD", () => false);
-Vr.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => Vr.getBool("DEBUG"));
-Vr.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => true);
-Vr.registerFlag("IS_TEST", () => false);
-Vr.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => true);
-Vr.registerFlag("WRAP_TO_IMAGEBITMAP", () => false);
-Vr.registerFlag("ENGINE_COMPILE_ONLY", () => false);
-Vr.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU", () => false);
-Vr.registerFlag("USE_SETTIMEOUTCUSTOM", () => false);
+oo.registerFlag("IS_BROWSER", () => Mb());
+oo.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined");
+oo.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor));
+oo.registerFlag("PROD", () => false);
+oo.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => oo.getBool("DEBUG"));
+oo.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => true);
+oo.registerFlag("IS_TEST", () => false);
+oo.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => true);
+oo.registerFlag("WRAP_TO_IMAGEBITMAP", () => false);
+oo.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU", () => false);
+oo.registerFlag("USE_SETTIMEOUTCUSTOM", () => false);
function or(r, e) {
- let t10 = r;
- if (Ut(r))
+ let t6 = r;
+ if (Wt(r))
return e === "string" ? [] : [r.length];
if (typeof r == "object" && "texture" in r) {
let n = r.channels || "RGBA";
@@ -4574,100 +4581,100 @@ function or(r, e) {
if (!Array.isArray(r))
return [];
let o = [];
- for (; Array.isArray(t10) || Ut(t10) && e !== "string"; )
- o.push(t10.length), t10 = t10[0];
- return Array.isArray(r) && P().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && U0(r, o, []), o;
+ for (; Array.isArray(t6) || Wt(t6) && e !== "string"; )
+ o.push(t6.length), t6 = t6[0];
+ return Array.isArray(r) && O().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && xv(r, o, []), o;
}
-function U0(r, e, t10) {
- if (t10 = t10 || [], !Array.isArray(r) && !Ut(r)) {
- $(e.length === 0, () => `Element arr[${t10.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`);
+function xv(r, e, t6) {
+ if (t6 = t6 || [], !Array.isArray(r) && !Wt(r)) {
+ E(e.length === 0, () => `Element arr[${t6.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`);
return;
}
- $(e.length > 0, () => `Element arr[${t10.join("][")}] should be a primitive, but is an array of ${r.length} elements`), $(r.length === e[0], () => `Element arr[${t10.join("][")}] should have ${e[0]} elements, but has ${r.length} elements`);
+ E(e.length > 0, () => `Element arr[${t6.join("][")}] should be a primitive, but is an array of ${r.length} elements`), E(r.length === e[0], () => `Element arr[${t6.join("][")}] should have ${e[0]} elements, but has ${r.length} elements`);
let o = e.slice(1);
for (let n = 0; n < r.length; ++n)
- U0(r[n], o, t10.concat(n));
+ xv(r[n], o, t6.concat(n));
}
-function W0(r, e, t10, o) {
+function gv(r, e, t6, o) {
if (r !== "string_or_numeric") {
if (r == null)
throw new Error("Expected dtype cannot be null.");
if (r !== "numeric" && r !== e || r === "numeric" && e === "string")
- throw new Error(`Argument '${t10}' passed to '${o}' must be ${r} tensor, but got ${e} tensor`);
+ throw new Error(`Argument '${t6}' passed to '${o}' must be ${r} tensor, but got ${e} tensor`);
}
}
-function v(r, e, t10, o = "numeric") {
- if (r instanceof ut)
- return W0(o, r.dtype, e, t10), r;
+function v(r, e, t6, o = "numeric") {
+ if (r instanceof it)
+ return gv(o, r.dtype, e, t6), r;
let n = np(r);
- if (n !== "string" && ["bool", "int32", "float32"].indexOf(o) >= 0 && (n = o), W0(o, n, e, t10), r == null || !Ut(r) && !Array.isArray(r) && typeof r != "number" && typeof r != "boolean" && typeof r != "string") {
+ if (n !== "string" && ["bool", "int32", "float32"].indexOf(o) >= 0 && (n = o), gv(o, n, e, t6), r == null || !Wt(r) && !Array.isArray(r) && typeof r != "number" && typeof r != "boolean" && typeof r != "string") {
let p = r == null ? "null" : r.constructor.name;
- throw new Error(`Argument '${e}' passed to '${t10}' must be a Tensor or TensorLike, but got '${p}'`);
+ throw new Error(`Argument '${e}' passed to '${t6}' must be a Tensor or TensorLike, but got '${p}'`);
}
let s = or(r, n);
- !Ut(r) && !Array.isArray(r) && (r = [r]);
- let i = n !== "string" ? Pp(r, n) : on(r, [], true);
- return N.makeTensor(i, s, n);
+ !Wt(r) && !Array.isArray(r) && (r = [r]);
+ let i = n !== "string" ? $p(r, n) : Oo(r, [], true);
+ return T.makeTensor(i, s, n);
}
-function Ia(r, e, t10, o = "numeric") {
+function Na(r, e, t6, o = "numeric") {
if (!Array.isArray(r))
- throw new Error(`Argument ${e} passed to ${t10} must be a \`Tensor[]\` or \`TensorLike[]\``);
- return r.map((s, a) => v(s, `${e}[${a}]`, t10, o));
+ throw new Error(`Argument ${e} passed to ${t6} must be a \`Tensor[]\` or \`TensorLike[]\``);
+ return r.map((s, a) => v(s, `${e}[${a}]`, t6, o));
}
-var Ub = "__op";
-function T(r) {
+var Lb = "__op";
+function N(r) {
let e = Object.keys(r);
if (e.length !== 1)
throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`);
- let t10 = e[0], o = r[t10];
- t10.endsWith("_") && (t10 = t10.substring(0, t10.length - 1)), t10 = t10 + Ub;
+ let t6 = e[0], o = r[t6];
+ t6.endsWith("_") && (t6 = t6.substring(0, t6.length - 1)), t6 = t6 + Lb;
let n = (...s) => {
- N.startScope(t10);
+ T.startScope(t6);
try {
let a = o(...s);
- return Yc(a) && console.error("Cannot return a Promise inside of tidy."), N.endScope(a), a;
+ return Wc(a) && console.error("Cannot return a Promise inside of tidy."), T.endScope(a), a;
} catch (a) {
- throw N.endScope(null), a;
+ throw T.endScope(null), a;
}
};
- return Object.defineProperty(n, "name", { value: t10, configurable: true }), n;
+ return Object.defineProperty(n, "name", { value: t6, configurable: true }), n;
}
-function Hz(r, e) {
- let t10 = v(r, "real", "complex"), o = v(e, "imag", "complex");
- ht(t10.shape, o.shape, `real and imag shapes, ${t10.shape} and ${o.shape}, must match in call to tf.complex().`);
- let n = { real: t10, imag: o };
- return N.runKernel(aa, n);
+function mz(r, e) {
+ let t6 = v(r, "real", "complex"), o = v(e, "imag", "complex");
+ ht(t6.shape, o.shape, `real and imag shapes, ${t6.shape} and ${o.shape}, must match in call to tf.complex().`);
+ let n = { real: t6, imag: o };
+ return T.runKernel(ei, n);
}
-var Er = T({ complex_: Hz });
-function xr(r, e, t10, o) {
+var Tr = N({ complex_: mz });
+function xr(r, e, t6, o) {
if (o == null && (o = np(r)), o === "complex64")
throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");
if (typeof r == "object" && "texture" in r) {
if (o !== "float32" && o !== "int32")
throw new Error(`Creating tensor from texture only supports 'float32'|'int32' dtype, while the dtype is ${o}.`);
- return r.channels = r.channels || "RGBA", N.backend.createTensorFromTexture(r, e || t10, o);
+ return r.channels = r.channels || "RGBA", T.backend.createTensorFromTexture(r, e || t6, o);
}
- if (!Ut(r) && !Array.isArray(r) && typeof r != "number" && typeof r != "boolean" && typeof r != "string")
+ if (!Wt(r) && !Array.isArray(r) && typeof r != "number" && typeof r != "boolean" && typeof r != "string")
throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");
if (e != null) {
- Xc(e);
- let n = Ve(e), s = Ve(t10);
- $(n === s, () => `Based on the provided shape, [${e}], the tensor should have ${n} values but has ${s}`);
- for (let a = 0; a < t10.length; ++a) {
- let i = t10[a], p = a === t10.length - 1 ? i !== Ve(e.slice(a)) : true;
- $(t10[a] === e[a] || !p, () => `Error creating a new Tensor. Inferred shape (${t10}) does not match the provided shape (${e}). `);
+ yt(e);
+ let n = ze(e), s = ze(t6);
+ E(n === s, () => `Based on the provided shape, [${e}], the tensor should have ${n} values but has ${s}`);
+ for (let a = 0; a < t6.length; ++a) {
+ let i = t6[a], p = a === t6.length - 1 ? i !== ze(e.slice(a)) : true;
+ E(t6[a] === e[a] || !p, () => `Error creating a new Tensor. Inferred shape (${t6}) does not match the provided shape (${e}). `);
}
}
- return !Ut(r) && !Array.isArray(r) && (r = [r]), e = e || t10, r = o !== "string" ? Pp(r, o) : on(r, [], true), N.makeTensor(r, e, o);
+ return !Wt(r) && !Array.isArray(r) && (r = [r]), e = e || t6, r = o !== "string" ? $p(r, o) : Oo(r, [], true), T.makeTensor(r, e, o);
}
-function nr(r, e, t10) {
- let o = or(r, t10);
- return xr(r, e, o, t10);
+function nr(r, e, t6) {
+ let o = or(r, t6);
+ return xr(r, e, o, t6);
}
-var al = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 };
-var Km = 4;
-async function H0(r, e) {
- let t10 = [], o = [], n = Array.isArray(r) ? r.map((a) => a.name) : Object.keys(r);
+var Zc = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 };
+var Mm = 4;
+async function bv(r, e) {
+ let t6 = [], o = [], n = Array.isArray(r) ? r.map((a) => a.name) : Object.keys(r);
for (let a = 0; a < n.length; ++a) {
let i = n[a], p = Array.isArray(r) ? r[a].tensor : r[i];
if (p.dtype !== "float32" && p.dtype !== "int32" && p.dtype !== "bool" && p.dtype !== "string" && p.dtype !== "complex64")
@@ -4675,25 +4682,25 @@ async function H0(r, e) {
let u = { name: i, shape: p.shape, dtype: p.dtype };
if (p.dtype === "string") {
let c = new Promise(async (l) => {
- let m = await p.bytes(), f = m.reduce((g, y) => g + y.length, 0) + Km * m.length, d = new Uint8Array(f), h = 0;
+ let m = await p.bytes(), d = m.reduce((g, x) => g + x.length, 0) + Mm * m.length, f = new Uint8Array(d), h = 0;
for (let g = 0; g < m.length; g++) {
- let y = m[g], b = new Uint8Array(new Uint32Array([y.length]).buffer);
- d.set(b, h), h += Km, d.set(y, h), h += y.length;
+ let x = m[g], b = new Uint8Array(new Uint32Array([x.length]).buffer);
+ f.set(b, h), h += Mm, f.set(x, h), h += x.length;
}
- l(d);
+ l(f);
});
o.push(c);
} else
o.push(p.data());
- e != null && (u.group = e), t10.push(u);
+ e != null && (u.group = e), t6.push(u);
}
let s = await Promise.all(o);
- return { data: qz(s), specs: t10 };
+ return { data: dz(s), specs: t6 };
}
-function jm(r, e) {
- let t10 = {}, o, n = 0;
+function Lm(r, e) {
+ let t6 = {}, o, n = 0;
for (let s of e) {
- let a = s.name, i = s.dtype, p = s.shape, u = Ve(p), c;
+ let a = s.name, i = s.dtype, p = s.shape, u = ze(p), c;
if ("quantization" in s) {
let l = s.quantization;
if (l.dtype === "uint8" || l.dtype === "uint16") {
@@ -4704,40 +4711,40 @@ function jm(r, e) {
throw new Error(`Weight ${s.name} is quantized with ${l.dtype} which only supports weights of type float32 not ${i}.`);
} else
throw new Error(`Weight ${s.name} has unknown quantization dtype ${l.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);
- let m = al[l.dtype], f = r.slice(n, n + u * m), d = l.dtype === "uint8" ? new Uint8Array(f) : new Uint16Array(f);
+ let m = Zc[l.dtype], d = r.slice(n, n + u * m), f = l.dtype === "uint8" ? new Uint8Array(d) : new Uint16Array(d);
if (i === "float32")
if (l.dtype === "uint8" || l.dtype === "uint16") {
- c = new Float32Array(d.length);
- for (let h = 0; h < d.length; h++) {
- let g = d[h];
+ c = new Float32Array(f.length);
+ for (let h = 0; h < f.length; h++) {
+ let g = f[h];
c[h] = g * l.scale + l.min;
}
} else if (l.dtype === "float16")
- o === void 0 && (o = Yz()), c = o(d);
+ o === void 0 && (o = xz()), c = o(f);
else
throw new Error(`Unsupported quantization type ${l.dtype} for weight type float32.`);
else if (i === "int32") {
if (l.dtype !== "uint8" && l.dtype !== "uint16")
throw new Error(`Unsupported quantization type ${l.dtype} for weight type int32.`);
- c = new Int32Array(d.length);
- for (let h = 0; h < d.length; h++) {
- let g = d[h];
+ c = new Int32Array(f.length);
+ for (let h = 0; h < f.length; h++) {
+ let g = f[h];
c[h] = Math.round(g * l.scale + l.min);
}
} else
throw new Error(`Unsupported dtype in weight '${a}': ${i}`);
n += u * m;
} else if (i === "string") {
- let l = Ve(s.shape);
+ let l = ze(s.shape);
c = [];
for (let m = 0; m < l; m++) {
- let f = new Uint32Array(r.slice(n, n + Km))[0];
- n += Km;
- let d = new Uint8Array(r.slice(n, n + f));
- c.push(d), n += f;
+ let d = new Uint32Array(r.slice(n, n + Mm))[0];
+ n += Mm;
+ let f = new Uint8Array(r.slice(n, n + d));
+ c.push(f), n += d;
}
} else {
- let l = al[i], m = r.slice(n, n + u * l);
+ let l = Zc[i], m = r.slice(n, n + u * l);
if (i === "float32")
c = new Float32Array(m);
else if (i === "int32")
@@ -4746,118 +4753,118 @@ function jm(r, e) {
c = new Uint8Array(m);
else if (i === "complex64") {
c = new Float32Array(m);
- let f = new Float32Array(c.length / 2), d = new Float32Array(c.length / 2);
- for (let y = 0; y < f.length; y++)
- f[y] = c[y * 2], d[y] = c[y * 2 + 1];
- let h = nr(f, p, "float32"), g = nr(d, p, "float32");
- t10[a] = Er(h, g), h.dispose(), g.dispose();
+ let d = new Float32Array(c.length / 2), f = new Float32Array(c.length / 2);
+ for (let x = 0; x < d.length; x++)
+ d[x] = c[x * 2], f[x] = c[x * 2 + 1];
+ let h = nr(d, p, "float32"), g = nr(f, p, "float32");
+ t6[a] = Tr(h, g), h.dispose(), g.dispose();
} else
throw new Error(`Unsupported dtype in weight '${a}': ${i}`);
n += u * l;
}
- i !== "complex64" && (t10[a] = nr(c, p, i));
+ i !== "complex64" && (t6[a] = nr(c, p, i));
}
- return t10;
+ return t6;
}
-function qz(r) {
+function dz(r) {
if (r === null)
throw new Error(`Invalid input value: ${JSON.stringify(r)}`);
- let e = 0, t10 = [];
+ let e = 0, t6 = [];
r.forEach((s) => {
- if (e += s.byteLength, t10.push(s.byteLength === s.buffer.byteLength ? s : new s.constructor(s)), !(s instanceof Float32Array || s instanceof Int32Array || s instanceof Uint8Array))
+ if (e += s.byteLength, t6.push(s.byteLength === s.buffer.byteLength ? s : new s.constructor(s)), !(s instanceof Float32Array || s instanceof Int32Array || s instanceof Uint8Array))
throw new Error(`Unsupported TypedArray subtype: ${s.constructor.name}`);
});
let o = new Uint8Array(e), n = 0;
- return t10.forEach((s) => {
+ return t6.forEach((s) => {
o.set(new Uint8Array(s.buffer), n), n += s.byteLength;
}), o.buffer;
}
-var Gb = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined");
-function G0(r) {
- return Gb ? Buffer.byteLength(r) : new Blob([r]).size;
+var Bb = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined");
+function yv(r) {
+ return Bb ? Buffer.byteLength(r) : new Blob([r]).size;
}
-function q0(r) {
- if (Gb)
+function Cv(r) {
+ if (Bb)
return Buffer.from(r).toString("base64");
- let e = new Uint8Array(r), t10 = "";
+ let e = new Uint8Array(r), t6 = "";
for (let o = 0, n = e.length; o < n; o++)
- t10 += String.fromCharCode(e[o]);
- return btoa(t10);
+ t6 += String.fromCharCode(e[o]);
+ return btoa(t6);
}
-function K0(r) {
- if (Gb) {
+function Sv(r) {
+ if (Bb) {
let o = Buffer.from(r, "base64");
return o.buffer.slice(o.byteOffset, o.byteOffset + o.byteLength);
}
- let e = atob(r), t10 = new Uint8Array(e.length);
+ let e = atob(r), t6 = new Uint8Array(e.length);
for (let o = 0; o < e.length; ++o)
- t10.set([e.charCodeAt(o)], o);
- return t10.buffer;
+ t6.set([e.charCodeAt(o)], o);
+ return t6.buffer;
}
-function Lp(r) {
+function Fp(r) {
if (r.length === 1)
return r[0];
let e = 0;
r.forEach((n) => {
e += n.byteLength;
});
- let t10 = new Uint8Array(e), o = 0;
+ let t6 = new Uint8Array(e), o = 0;
return r.forEach((n) => {
- t10.set(new Uint8Array(n), o), o += n.byteLength;
- }), t10.buffer;
+ t6.set(new Uint8Array(n), o), o += n.byteLength;
+ }), t6.buffer;
}
-function Hb(r) {
+function Vb(r) {
let e = "/";
for (r = r.trim(); r.endsWith(e); )
r = r.slice(0, r.length - 1);
- let t10 = r.split(e);
- return t10[t10.length - 1];
+ let t6 = r.split(e);
+ return t6[t6.length - 1];
}
-function Xm(r, e) {
- let t10 = { modelTopology: r.modelTopology, format: r.format, generatedBy: r.generatedBy, convertedBy: r.convertedBy, weightsManifest: e };
- return r.signature != null && (t10.signature = r.signature), r.userDefinedMetadata != null && (t10.userDefinedMetadata = r.userDefinedMetadata), r.modelInitializer != null && (t10.modelInitializer = r.modelInitializer), r.initializerSignature != null && (t10.initializerSignature = r.initializerSignature), r.trainingConfig != null && (t10.trainingConfig = r.trainingConfig), t10;
+function Bm(r, e) {
+ let t6 = { modelTopology: r.modelTopology, format: r.format, generatedBy: r.generatedBy, convertedBy: r.convertedBy, weightsManifest: e };
+ return r.signature != null && (t6.signature = r.signature), r.userDefinedMetadata != null && (t6.userDefinedMetadata = r.userDefinedMetadata), r.modelInitializer != null && (t6.modelInitializer = r.modelInitializer), r.initializerSignature != null && (t6.initializerSignature = r.initializerSignature), r.trainingConfig != null && (t6.trainingConfig = r.trainingConfig), t6;
}
-function qb(r, e, t10) {
+function zb(r, e, t6) {
let o = { modelTopology: r.modelTopology, format: r.format, generatedBy: r.generatedBy, convertedBy: r.convertedBy };
if (r.trainingConfig != null && (o.trainingConfig = r.trainingConfig), r.weightsManifest != null) {
if (!e)
throw new Error("modelJSON has weightsManifest but weightSpecs is null");
- if (!t10)
+ if (!t6)
throw new Error("modelJSON has weightsManifest but weightData is null");
- o.weightSpecs = e, o.weightData = t10;
+ o.weightSpecs = e, o.weightData = t6;
}
return r.signature != null && (o.signature = r.signature), r.userDefinedMetadata != null && (o.userDefinedMetadata = r.userDefinedMetadata), r.modelInitializer != null && (o.modelInitializer = r.modelInitializer), r.initializerSignature != null && (o.initializerSignature = r.initializerSignature), o;
}
-async function Bp(r, e) {
- let t10, o;
- return r.weightsManifest != null && ([t10, o] = await e(r.weightsManifest)), qb(r, t10, o);
+async function Dp(r, e) {
+ let t6, o;
+ return r.weightsManifest != null && ([t6, o] = await e(r.weightsManifest)), zb(r, t6, o);
}
-function As(r) {
+function Ps(r) {
if (r.modelTopology instanceof ArrayBuffer)
throw new Error("Expected JSON model topology, received ArrayBuffer.");
- return { dateSaved: new Date(), modelTopologyType: "JSON", modelTopologyBytes: r.modelTopology == null ? 0 : G0(JSON.stringify(r.modelTopology)), weightSpecsBytes: r.weightSpecs == null ? 0 : G0(JSON.stringify(r.weightSpecs)), weightDataBytes: r.weightData == null ? 0 : r.weightData.byteLength };
+ return { dateSaved: new Date(), modelTopologyType: "JSON", modelTopologyBytes: r.modelTopology == null ? 0 : yv(JSON.stringify(r.modelTopology)), weightSpecsBytes: r.weightSpecs == null ? 0 : yv(JSON.stringify(r.weightSpecs)), weightDataBytes: r.weightData == null ? 0 : r.weightData.byteLength };
}
-function Ym(r) {
+function Vm(r) {
let e = [];
- for (let t10 of r)
- e.push(...t10.weights);
+ for (let t6 of r)
+ e.push(...t6.weights);
return e;
}
-function Kz() {
- let r = (t10) => {
- let o = t10 << 13, n = 0;
+function fz() {
+ let r = (t6) => {
+ let o = t6 << 13, n = 0;
for (; (o & 8388608) === 0; )
n -= 8388608, o <<= 1;
return o &= -8388609, n += 947912704, o | n;
}, e = new Uint32Array(2048);
e[0] = 0;
- for (let t10 = 1; t10 < 1024; t10++)
- e[t10] = r(t10);
- for (let t10 = 1024; t10 < 2048; t10++)
- e[t10] = 939524096 + (t10 - 1024 << 13);
+ for (let t6 = 1; t6 < 1024; t6++)
+ e[t6] = r(t6);
+ for (let t6 = 1024; t6 < 2048; t6++)
+ e[t6] = 939524096 + (t6 - 1024 << 13);
return e;
}
-function jz() {
+function hz() {
let r = new Uint32Array(64);
r[0] = 0, r[31] = 1199570944, r[32] = 2147483648, r[63] = 3347054592;
for (let e = 1; e < 31; e++)
@@ -4866,73 +4873,73 @@ function jz() {
r[e] = 2147483648 + (e - 32 << 23);
return r;
}
-function Xz() {
+function gz() {
let r = new Uint32Array(64);
for (let e = 0; e < 64; e++)
r[e] = 1024;
return r[0] = r[32] = 0, r;
}
-function Yz() {
- let r = Kz(), e = jz(), t10 = Xz();
+function xz() {
+ let r = fz(), e = hz(), t6 = gz();
return (o) => {
let n = new ArrayBuffer(4 * o.length), s = new Uint32Array(n);
for (let a = 0; a < o.length; a++) {
- let i = o[a], p = r[t10[i >> 10] + (i & 1023)] + e[i >> 10];
+ let i = o[a], p = r[t6[i >> 10] + (i & 1023)] + e[i >> 10];
s[a] = p;
}
return new Float32Array(n);
};
}
-var mt = class {
+var lt = class {
constructor() {
this.saveRouters = [], this.loadRouters = [];
}
static getInstance() {
- return mt.instance == null && (mt.instance = new mt()), mt.instance;
+ return lt.instance == null && (lt.instance = new lt()), lt.instance;
}
static registerSaveRouter(e) {
- mt.getInstance().saveRouters.push(e);
+ lt.getInstance().saveRouters.push(e);
}
static registerLoadRouter(e) {
- mt.getInstance().loadRouters.push(e);
+ lt.getInstance().loadRouters.push(e);
}
static getSaveHandlers(e) {
- return mt.getHandlers(e, "save");
+ return lt.getHandlers(e, "save");
}
- static getLoadHandlers(e, t10) {
- return mt.getHandlers(e, "load", t10);
+ static getLoadHandlers(e, t6) {
+ return lt.getHandlers(e, "load", t6);
}
- static getHandlers(e, t10, o) {
+ static getHandlers(e, t6, o) {
let n = [];
- return (t10 === "load" ? mt.getInstance().loadRouters : mt.getInstance().saveRouters).forEach((a) => {
+ return (t6 === "load" ? lt.getInstance().loadRouters : lt.getInstance().saveRouters).forEach((a) => {
let i = a(e, o);
i !== null && n.push(i);
}), n;
}
};
-var j0 = (r) => mt.registerSaveRouter(r);
-var X0 = (r) => mt.registerLoadRouter(r);
-var Y0 = (r) => mt.getSaveHandlers(r);
-var Q0 = (r, e) => mt.getLoadHandlers(r, e);
-var Kb = "tensorflowjs";
-var jb = 1;
+var wv = (r) => lt.registerSaveRouter(r);
+var Iv = (r) => lt.registerLoadRouter(r);
+var vv = (r) => lt.getSaveHandlers(r);
+var kv = (r, e) => lt.getLoadHandlers(r, e);
+var Wb = "tensorflowjs";
+var Ub = 1;
var nu = "models_store";
-var ui = "model_info_store";
-function Z0() {
- if (!P().getBool("IS_BROWSER"))
+var bi = "model_info_store";
+function Nv() {
+ if (!O().getBool("IS_BROWSER"))
throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");
let r = typeof window == "undefined" ? self : window, e = r.indexedDB || r.mozIndexedDB || r.webkitIndexedDB || r.msIndexedDB || r.shimIndexedDB;
if (e == null)
throw new Error("The current browser does not appear to support IndexedDB.");
return e;
}
-function Xb(r) {
+function Gb(r) {
let e = r.result;
- e.createObjectStore(nu, { keyPath: "modelPath" }), e.createObjectStore(ui, { keyPath: "modelPath" });
+ e.createObjectStore(nu, { keyPath: "modelPath" }), e.createObjectStore(bi, { keyPath: "modelPath" });
}
-var Fs = class {
+var Ms = class {
constructor(e) {
- if (this.indexedDB = Z0(), e == null || !e)
+ if (this.indexedDB = Nv(), e == null || !e)
throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");
this.modelPath = e;
}
@@ -4944,12 +4951,12 @@ var Fs = class {
async load() {
return this.databaseAction(this.modelPath);
}
- databaseAction(e, t10) {
+ databaseAction(e, t6) {
return new Promise((o, n) => {
- let s = this.indexedDB.open(Kb, jb);
- s.onupgradeneeded = () => Xb(s), s.onsuccess = () => {
+ let s = this.indexedDB.open(Wb, Ub);
+ s.onupgradeneeded = () => Gb(s), s.onsuccess = () => {
let a = s.result;
- if (t10 == null) {
+ if (t6 == null) {
let i = a.transaction(nu, "readonly"), u = i.objectStore(nu).get(this.modelPath);
u.onsuccess = () => {
if (u.result == null)
@@ -4957,14 +4964,14 @@ var Fs = class {
o(u.result.modelArtifacts);
}, u.onerror = (c) => (a.close(), n(u.error)), i.oncomplete = () => a.close();
} else {
- let i = As(t10), p = a.transaction(ui, "readwrite"), u = p.objectStore(ui), c = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), l;
+ let i = Ps(t6), p = a.transaction(bi, "readwrite"), u = p.objectStore(bi), c = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), l;
c.onsuccess = () => {
l = a.transaction(nu, "readwrite");
- let f = l.objectStore(nu).put({ modelPath: this.modelPath, modelArtifacts: t10, modelArtifactsInfo: i });
- f.onsuccess = () => o({ modelArtifactsInfo: i }), f.onerror = (d) => {
- u = p.objectStore(ui);
+ let d = l.objectStore(nu).put({ modelPath: this.modelPath, modelArtifacts: t6, modelArtifactsInfo: i });
+ d.onsuccess = () => o({ modelArtifactsInfo: i }), d.onerror = (f) => {
+ u = p.objectStore(bi);
let h = u.delete(this.modelPath);
- h.onsuccess = () => (a.close(), n(f.error)), h.onerror = (g) => (a.close(), n(f.error));
+ h.onsuccess = () => (a.close(), n(d.error)), h.onerror = (g) => (a.close(), n(d.error));
};
}, c.onerror = (m) => (a.close(), n(c.error)), p.oncomplete = () => {
l == null ? a.close() : l.oncomplete = () => a.close();
@@ -4974,47 +4981,47 @@ var Fs = class {
});
}
};
-Fs.URL_SCHEME = "indexeddb://";
-var J0 = (r) => P().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(Fs.URL_SCHEME) ? Qz(r.slice(Fs.URL_SCHEME.length)) : null;
-mt.registerSaveRouter(J0);
-mt.registerLoadRouter(J0);
-function Qz(r) {
- return new Fs(r);
+Ms.URL_SCHEME = "indexeddb://";
+var Tv = (r) => O().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(Ms.URL_SCHEME) ? yz(r.slice(Ms.URL_SCHEME.length)) : null;
+lt.registerSaveRouter(Tv);
+lt.registerLoadRouter(Tv);
+function yz(r) {
+ return new Ms(r);
}
-function Zz(r) {
- return r.startsWith(Fs.URL_SCHEME) ? r.slice(Fs.URL_SCHEME.length) : r;
+function bz(r) {
+ return r.startsWith(Ms.URL_SCHEME) ? r.slice(Ms.URL_SCHEME.length) : r;
}
-var Qm = class {
+var zm = class {
constructor() {
- this.indexedDB = Z0();
+ this.indexedDB = Nv();
}
async listModels() {
- return new Promise((e, t10) => {
- let o = this.indexedDB.open(Kb, jb);
- o.onupgradeneeded = () => Xb(o), o.onsuccess = () => {
- let n = o.result, s = n.transaction(ui, "readonly"), i = s.objectStore(ui).getAll();
+ return new Promise((e, t6) => {
+ let o = this.indexedDB.open(Wb, Ub);
+ o.onupgradeneeded = () => Gb(o), o.onsuccess = () => {
+ let n = o.result, s = n.transaction(bi, "readonly"), i = s.objectStore(bi).getAll();
i.onsuccess = () => {
let p = {};
for (let u of i.result)
p[u.modelPath] = u.modelArtifactsInfo;
e(p);
- }, i.onerror = (p) => (n.close(), t10(i.error)), s.oncomplete = () => n.close();
- }, o.onerror = (n) => t10(o.error);
+ }, i.onerror = (p) => (n.close(), t6(i.error)), s.oncomplete = () => n.close();
+ }, o.onerror = (n) => t6(o.error);
});
}
async removeModel(e) {
- return e = Zz(e), new Promise((t10, o) => {
- let n = this.indexedDB.open(Kb, jb);
- n.onupgradeneeded = () => Xb(n), n.onsuccess = () => {
- let s = n.result, a = s.transaction(ui, "readwrite"), i = a.objectStore(ui), p = i.get(e), u;
+ return e = bz(e), new Promise((t6, o) => {
+ let n = this.indexedDB.open(Wb, Ub);
+ n.onupgradeneeded = () => Gb(n), n.onsuccess = () => {
+ let s = n.result, a = s.transaction(bi, "readwrite"), i = a.objectStore(bi), p = i.get(e), u;
p.onsuccess = () => {
if (p.result == null)
return s.close(), o(new Error(`Cannot find model with path '${e}' in IndexedDB.`));
{
let c = i.delete(e), l = () => {
u = s.transaction(nu, "readwrite");
- let f = u.objectStore(nu).delete(e);
- f.onsuccess = () => t10(p.result.modelArtifactsInfo), f.onerror = (d) => o(p.error);
+ let d = u.objectStore(nu).delete(e);
+ d.onsuccess = () => t6(p.result.modelArtifactsInfo), d.onerror = (f) => o(p.error);
};
c.onsuccess = l, c.onerror = (m) => (l(), s.close(), o(p.error));
}
@@ -5025,48 +5032,48 @@ var Qm = class {
});
}
};
-var wa = "/";
-var Vp = "tensorflowjs_models";
-var ev = "info";
-var Jz = "model_topology";
-var eW = "weight_specs";
-var tW = "weight_data";
-var rW = "model_metadata";
-function tv(r) {
- return { info: [Vp, r, ev].join(wa), topology: [Vp, r, Jz].join(wa), weightSpecs: [Vp, r, eW].join(wa), weightData: [Vp, r, tW].join(wa), modelMetadata: [Vp, r, rW].join(wa) };
+var Ta = "/";
+var Op = "tensorflowjs_models";
+var _v = "info";
+var Cz = "model_topology";
+var Sz = "weight_specs";
+var wz = "weight_data";
+var Iz = "model_metadata";
+function Ev(r) {
+ return { info: [Op, r, _v].join(Ta), topology: [Op, r, Cz].join(Ta), weightSpecs: [Op, r, Sz].join(Ta), weightData: [Op, r, wz].join(Ta), modelMetadata: [Op, r, Iz].join(Ta) };
}
-function rv(r) {
+function $v(r) {
for (let e of Object.values(r))
window.localStorage.removeItem(e);
}
-function oW(r) {
- let e = r.split(wa);
+function vz(r) {
+ let e = r.split(Ta);
if (e.length < 3)
throw new Error(`Invalid key format: ${r}`);
- return e.slice(1, e.length - 1).join(wa);
+ return e.slice(1, e.length - 1).join(Ta);
}
-function nW(r) {
- return r.startsWith(Ds.URL_SCHEME) ? r.slice(Ds.URL_SCHEME.length) : r;
+function kz(r) {
+ return r.startsWith(Ls.URL_SCHEME) ? r.slice(Ls.URL_SCHEME.length) : r;
}
-var Ds = class {
+var Ls = class {
constructor(e) {
- if (!P().getBool("IS_BROWSER") || typeof window == "undefined" || typeof window.localStorage == "undefined")
+ if (!O().getBool("IS_BROWSER") || typeof window == "undefined" || typeof window.localStorage == "undefined")
throw new Error("The current environment does not support local storage.");
if (this.LS = window.localStorage, e == null || !e)
throw new Error("For local storage, modelPath must not be null, undefined or empty.");
- this.modelPath = e, this.keys = tv(this.modelPath);
+ this.modelPath = e, this.keys = Ev(this.modelPath);
}
async save(e) {
if (e.modelTopology instanceof ArrayBuffer)
throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");
{
- let t10 = JSON.stringify(e.modelTopology), o = JSON.stringify(e.weightSpecs), n = As(e);
+ let t6 = JSON.stringify(e.modelTopology), o = JSON.stringify(e.weightSpecs), n = Ps(e);
try {
- this.LS.setItem(this.keys.info, JSON.stringify(n)), this.LS.setItem(this.keys.topology, t10), this.LS.setItem(this.keys.weightSpecs, o), this.LS.setItem(this.keys.weightData, q0(e.weightData));
+ this.LS.setItem(this.keys.info, JSON.stringify(n)), this.LS.setItem(this.keys.topology, t6), this.LS.setItem(this.keys.weightSpecs, o), this.LS.setItem(this.keys.weightData, Cv(e.weightData));
let s = { format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, signature: e.signature != null ? e.signature : void 0, userDefinedMetadata: e.userDefinedMetadata != null ? e.userDefinedMetadata : void 0, modelInitializer: e.modelInitializer != null ? e.modelInitializer : void 0, initializerSignature: e.initializerSignature != null ? e.initializerSignature : void 0, trainingConfig: e.trainingConfig != null ? e.trainingConfig : void 0 };
return this.LS.setItem(this.keys.modelMetadata, JSON.stringify(s)), { modelArtifactsInfo: n };
} catch (s) {
- throw rv(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${n.modelTopologyBytes}, weightSpecsBytes=${n.weightSpecsBytes}, weightDataBytes=${n.weightDataBytes}.`);
+ throw $v(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${n.modelTopologyBytes}, weightSpecsBytes=${n.weightSpecsBytes}, weightDataBytes=${n.weightDataBytes}.`);
}
}
}
@@ -5076,142 +5083,142 @@ var Ds = class {
throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);
if (e.modelTopologyType !== "JSON")
throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");
- let t10 = {}, o = JSON.parse(this.LS.getItem(this.keys.topology));
+ let t6 = {}, o = JSON.parse(this.LS.getItem(this.keys.topology));
if (o == null)
throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);
- t10.modelTopology = o;
+ t6.modelTopology = o;
let n = JSON.parse(this.LS.getItem(this.keys.weightSpecs));
if (n == null)
throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);
- t10.weightSpecs = n;
+ t6.weightSpecs = n;
let s = this.LS.getItem(this.keys.modelMetadata);
if (s != null) {
let i = JSON.parse(s);
- t10.format = i.format, t10.generatedBy = i.generatedBy, t10.convertedBy = i.convertedBy, i.signature != null && (t10.signature = i.signature), i.userDefinedMetadata != null && (t10.userDefinedMetadata = i.userDefinedMetadata), i.modelInitializer != null && (t10.modelInitializer = i.modelInitializer), i.initializerSignature != null && (t10.initializerSignature = i.initializerSignature), i.trainingConfig != null && (t10.trainingConfig = i.trainingConfig);
+ t6.format = i.format, t6.generatedBy = i.generatedBy, t6.convertedBy = i.convertedBy, i.signature != null && (t6.signature = i.signature), i.userDefinedMetadata != null && (t6.userDefinedMetadata = i.userDefinedMetadata), i.modelInitializer != null && (t6.modelInitializer = i.modelInitializer), i.initializerSignature != null && (t6.initializerSignature = i.initializerSignature), i.trainingConfig != null && (t6.trainingConfig = i.trainingConfig);
}
let a = this.LS.getItem(this.keys.weightData);
if (a == null)
throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);
- return t10.weightData = K0(a), t10;
+ return t6.weightData = Sv(a), t6;
}
};
-Ds.URL_SCHEME = "localstorage://";
-var ov = (r) => P().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(Ds.URL_SCHEME) ? sW(r.slice(Ds.URL_SCHEME.length)) : null;
-mt.registerSaveRouter(ov);
-mt.registerLoadRouter(ov);
-function sW(r) {
- return new Ds(r);
+Ls.URL_SCHEME = "localstorage://";
+var Av = (r) => O().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(Ls.URL_SCHEME) ? Nz(r.slice(Ls.URL_SCHEME.length)) : null;
+lt.registerSaveRouter(Av);
+lt.registerLoadRouter(Av);
+function Nz(r) {
+ return new Ls(r);
}
-var Zm = class {
+var Wm = class {
constructor() {
- $(P().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), $(typeof window == "undefined" || typeof window.localStorage != "undefined", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage;
+ E(O().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), E(typeof window == "undefined" || typeof window.localStorage != "undefined", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage;
}
async listModels() {
- let e = {}, t10 = Vp + wa, o = wa + ev;
+ let e = {}, t6 = Op + Ta, o = Ta + _v;
for (let n = 0; n < this.LS.length; ++n) {
let s = this.LS.key(n);
- if (s.startsWith(t10) && s.endsWith(o)) {
- let a = oW(s);
+ if (s.startsWith(t6) && s.endsWith(o)) {
+ let a = vz(s);
e[a] = JSON.parse(this.LS.getItem(s));
}
}
return e;
}
async removeModel(e) {
- e = nW(e);
- let t10 = tv(e);
- if (this.LS.getItem(t10.info) == null)
+ e = kz(e);
+ let t6 = Ev(e);
+ if (this.LS.getItem(t6.info) == null)
throw new Error(`Cannot find model at path '${e}'`);
- let o = JSON.parse(this.LS.getItem(t10.info));
- return rv(t10), o;
+ let o = JSON.parse(this.LS.getItem(t6.info));
+ return $v(t6), o;
}
};
-var zp = "://";
-var Yt = class {
+var Pp = "://";
+var Xt = class {
constructor() {
this.managers = {};
}
static getInstance() {
- return Yt.instance == null && (Yt.instance = new Yt()), Yt.instance;
+ return Xt.instance == null && (Xt.instance = new Xt()), Xt.instance;
}
- static registerManager(e, t10) {
- $(e != null, () => "scheme must not be undefined or null."), e.endsWith(zp) && (e = e.slice(0, e.indexOf(zp))), $(e.length > 0, () => "scheme must not be an empty string.");
- let o = Yt.getInstance();
- $(o.managers[e] == null, () => `A model store manager is already registered for scheme '${e}'.`), o.managers[e] = t10;
+ static registerManager(e, t6) {
+ E(e != null, () => "scheme must not be undefined or null."), e.endsWith(Pp) && (e = e.slice(0, e.indexOf(Pp))), E(e.length > 0, () => "scheme must not be an empty string.");
+ let o = Xt.getInstance();
+ E(o.managers[e] == null, () => `A model store manager is already registered for scheme '${e}'.`), o.managers[e] = t6;
}
static getManager(e) {
- let t10 = Yt.getInstance().managers[e];
- if (t10 == null)
+ let t6 = Xt.getInstance().managers[e];
+ if (t6 == null)
throw new Error(`Cannot find model manager for scheme '${e}'`);
- return t10;
+ return t6;
}
static getSchemes() {
- return Object.keys(Yt.getInstance().managers);
+ return Object.keys(Xt.getInstance().managers);
}
};
-function Jm(r) {
- if (r.indexOf(zp) === -1)
- throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Yt.getSchemes().join(",")}`);
- return { scheme: r.split(zp)[0], path: r.split(zp)[1] };
+function Um(r) {
+ if (r.indexOf(Pp) === -1)
+ throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Xt.getSchemes().join(",")}`);
+ return { scheme: r.split(Pp)[0], path: r.split(Pp)[1] };
}
-async function nv(r, e, t10 = false) {
- $(r !== e, () => `Old path and new path are the same: '${r}'`);
- let o = mt.getLoadHandlers(r);
- $(o.length > 0, () => `Copying failed because no load handler is found for source URL ${r}.`), $(o.length < 2, () => `Copying failed because more than one (${o.length}) load handlers for source URL ${r}.`);
- let n = o[0], s = mt.getSaveHandlers(e);
- $(s.length > 0, () => `Copying failed because no save handler is found for destination URL ${e}.`), $(s.length < 2, () => `Copying failed because more than one (${o.length}) save handlers for destination URL ${e}.`);
- let a = s[0], i = Jm(r).scheme, p = Jm(r).path, u = i === Jm(r).scheme, c = await n.load();
- t10 && u && await Yt.getManager(i).removeModel(p);
+async function Rv(r, e, t6 = false) {
+ E(r !== e, () => `Old path and new path are the same: '${r}'`);
+ let o = lt.getLoadHandlers(r);
+ E(o.length > 0, () => `Copying failed because no load handler is found for source URL ${r}.`), E(o.length < 2, () => `Copying failed because more than one (${o.length}) load handlers for source URL ${r}.`);
+ let n = o[0], s = lt.getSaveHandlers(e);
+ E(s.length > 0, () => `Copying failed because no save handler is found for destination URL ${e}.`), E(s.length < 2, () => `Copying failed because more than one (${o.length}) save handlers for destination URL ${e}.`);
+ let a = s[0], i = Um(r).scheme, p = Um(r).path, u = i === Um(r).scheme, c = await n.load();
+ t6 && u && await Xt.getManager(i).removeModel(p);
let l = await a.save(c);
- return t10 && !u && await Yt.getManager(i).removeModel(p), l.modelArtifactsInfo;
+ return t6 && !u && await Xt.getManager(i).removeModel(p), l.modelArtifactsInfo;
}
-async function sv() {
- let r = Yt.getSchemes(), e = {};
- for (let t10 of r) {
- let o = await Yt.getManager(t10).listModels();
+async function Fv() {
+ let r = Xt.getSchemes(), e = {};
+ for (let t6 of r) {
+ let o = await Xt.getManager(t6).listModels();
for (let n in o) {
- let s = t10 + zp + n;
+ let s = t6 + Pp + n;
e[s] = o[n];
}
}
return e;
}
-async function av(r) {
- let e = Jm(r);
- return Yt.getManager(e.scheme).removeModel(e.path);
+async function Dv(r) {
+ let e = Um(r);
+ return Xt.getManager(e.scheme).removeModel(e.path);
}
-async function iv(r, e) {
- return nv(r, e, false);
+async function Ov(r, e) {
+ return Rv(r, e, false);
}
-async function uv(r, e) {
- return nv(r, e, true);
+async function Pv(r, e) {
+ return Rv(r, e, true);
}
-var Yb = class {
+var Hb = class {
constructor() {
this.messageName = "setTimeoutCustom", this.functionRefs = [], this.handledMessageCount = 0, this.hasEventListener = false;
}
- fetch(e, t10) {
- return fetch(e, t10);
+ fetch(e, t6) {
+ return fetch(e, t6);
}
now() {
return performance.now();
}
- encode(e, t10) {
- if (t10 !== "utf-8" && t10 !== "utf8")
- throw new Error(`Browser's encoder only supports utf-8, but got ${t10}`);
+ encode(e, t6) {
+ if (t6 !== "utf-8" && t6 !== "utf8")
+ throw new Error(`Browser's encoder only supports utf-8, but got ${t6}`);
return this.textEncoder == null && (this.textEncoder = new TextEncoder()), this.textEncoder.encode(e);
}
- decode(e, t10) {
- return new TextDecoder(t10).decode(e);
+ decode(e, t6) {
+ return new TextDecoder(t6).decode(e);
}
- setTimeoutCustom(e, t10) {
- if (typeof window == "undefined" || !P().getBool("USE_SETTIMEOUTCUSTOM")) {
- setTimeout(e, t10);
+ setTimeoutCustom(e, t6) {
+ if (typeof window == "undefined" || !O().getBool("USE_SETTIMEOUTCUSTOM")) {
+ setTimeout(e, t6);
return;
}
this.functionRefs.push(e), setTimeout(() => {
window.postMessage({ name: this.messageName, index: this.functionRefs.length - 1 }, "*");
- }, t10), this.hasEventListener || (this.hasEventListener = true, window.addEventListener("message", (o) => {
+ }, t6), this.hasEventListener || (this.hasEventListener = true, window.addEventListener("message", (o) => {
if (o.source === window && o.data.name === this.messageName) {
o.stopPropagation();
let n = this.functionRefs[o.data.index];
@@ -5220,301 +5227,301 @@ var Yb = class {
}, true));
}
};
-if (P().get("IS_BROWSER")) {
- P().setPlatform("browser", new Yb());
+if (O().get("IS_BROWSER")) {
+ O().setPlatform("browser", new Hb());
try {
- Yt.registerManager(Ds.URL_SCHEME, new Zm());
+ Xt.registerManager(Ls.URL_SCHEME, new Wm());
} catch (r) {
}
try {
- Yt.registerManager(Fs.URL_SCHEME, new Qm());
+ Xt.registerManager(Ms.URL_SCHEME, new zm());
} catch (r) {
}
}
-var aW = { importFetch: () => pv() };
-var Qb;
-var Zb = class {
+var Tz = { importFetch: () => Mv() };
+var qb;
+var Kb = class {
constructor() {
- this.util = cv(), this.textEncoder = new this.util.TextEncoder();
+ this.util = Lv(), this.textEncoder = new this.util.TextEncoder();
}
- fetch(e, t10) {
- return P().global.fetch != null ? P().global.fetch(e, t10) : (Qb == null && (Qb = aW.importFetch()), Qb(e, t10));
+ fetch(e, t6) {
+ return O().global.fetch != null ? O().global.fetch(e, t6) : (qb == null && (qb = Tz.importFetch()), qb(e, t6));
}
now() {
let e = process.hrtime();
return e[0] * 1e3 + e[1] / 1e6;
}
- encode(e, t10) {
- if (t10 !== "utf-8" && t10 !== "utf8")
- throw new Error(`Node built-in encoder only supports utf-8, but got ${t10}`);
+ encode(e, t6) {
+ if (t6 !== "utf-8" && t6 !== "utf8")
+ throw new Error(`Node built-in encoder only supports utf-8, but got ${t6}`);
return this.textEncoder.encode(e);
}
- decode(e, t10) {
- return e.length === 0 ? "" : new this.util.TextDecoder(t10).decode(e);
+ decode(e, t6) {
+ return e.length === 0 ? "" : new this.util.TextDecoder(t6).decode(e);
}
};
-P().get("IS_NODE") && !P().get("IS_BROWSER") && P().setPlatform("node", new Zb());
-function ne(r, e = "float32", t10) {
- return e = e || "float32", Xc(r), new je(r, e, t10);
+O().get("IS_NODE") && !O().get("IS_BROWSER") && O().setPlatform("node", new Kb());
+function le(r, e = "float32", t6) {
+ return e = e || "float32", yt(r), new st(r, e, t6);
}
-function iW(r, e) {
- let t10 = v(r, "x", "cast");
- if (!yb(e))
+function _z(r, e) {
+ let t6 = v(r, "x", "cast");
+ if (!db(e))
throw new Error(`Failed to cast to unknown dtype ${e}`);
- if (e === "string" && t10.dtype !== "string" || e !== "string" && t10.dtype === "string")
+ if (e === "string" && t6.dtype !== "string" || e !== "string" && t6.dtype === "string")
throw new Error("Only strings can be casted to strings");
- let o = { x: t10 }, n = { dtype: e };
- return N.runKernel(to, o, n);
+ let o = { x: t6 }, n = { dtype: e };
+ return T.runKernel(co, o, n);
}
-var qe = T({ cast_: iW });
-function uW(r) {
- let t10 = { x: v(r, "x", "clone", "string_or_numeric") };
- return N.runKernel(uo, t10);
+var Ke = N({ cast_: _z });
+function Ez(r) {
+ let t6 = { x: v(r, "x", "clone", "string_or_numeric") };
+ return T.runKernel(mo, t6);
}
-var zr = T({ clone_: uW });
-function ef(r, e = false) {
+var Br = N({ clone_: Ez });
+function Gm(r, e = false) {
console.log(r.toString(e));
}
-Vb();
-var pW = { buffer: ne, cast: qe, clone: zr, print: ef };
-L0(pW);
-var va = {};
-Be(va, { browserFiles: () => mv, browserHTTPRequest: () => hv, concatenateArrayBuffers: () => Lp, copyModel: () => iv, decodeWeights: () => jm, encodeWeights: () => H0, fromMemory: () => gv, fromMemorySync: () => nC, getLoadHandlers: () => Q0, getModelArtifactsForJSON: () => Bp, getModelArtifactsForJSONSync: () => qb, getModelArtifactsInfoForJSON: () => As, getSaveHandlers: () => Y0, getWeightSpecs: () => Ym, http: () => rf, isHTTPScheme: () => tf, listModels: () => sv, loadWeights: () => fv, moveModel: () => uv, registerLoadRouter: () => X0, registerSaveRouter: () => j0, removeModel: () => av, weightsLoaderFactory: () => rC, withSaveHandler: () => xv, withSaveHandlerSync: () => yv });
-var cW = "model";
-var lW = ".json";
-var mW = ".weights.bin";
-function lv(r) {
+Ob();
+var $z = { buffer: le, cast: Ke, clone: Br, print: Gm };
+mv($z);
+var Ea = {};
+Ue(Ea, { browserFiles: () => Vv, browserHTTPRequest: () => Uv, concatenateArrayBuffers: () => Fp, copyModel: () => Ov, decodeWeights: () => Lm, encodeWeights: () => bv, fromMemory: () => Gv, fromMemorySync: () => Jb, getLoadHandlers: () => kv, getModelArtifactsForJSON: () => Dp, getModelArtifactsForJSONSync: () => zb, getModelArtifactsInfoForJSON: () => Ps, getSaveHandlers: () => vv, getWeightSpecs: () => Vm, http: () => qm, isHTTPScheme: () => Hm, listModels: () => Fv, loadWeights: () => zv, moveModel: () => Pv, registerLoadRouter: () => Iv, registerSaveRouter: () => wv, removeModel: () => Dv, weightsLoaderFactory: () => Qb, withSaveHandler: () => Hv, withSaveHandlerSync: () => qv });
+var Az = "model";
+var Rz = ".json";
+var Fz = ".weights.bin";
+function Bv(r) {
return new Promise((e) => setTimeout(e)).then(r);
}
-var Sa = class {
+var _a = class {
constructor(e) {
- if (!P().getBool("IS_BROWSER"))
+ if (!O().getBool("IS_BROWSER"))
throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");
- e.startsWith(Sa.URL_SCHEME) && (e = e.slice(Sa.URL_SCHEME.length)), (e == null || e.length === 0) && (e = cW), this.modelJsonFileName = e + lW, this.weightDataFileName = e + mW;
+ e.startsWith(_a.URL_SCHEME) && (e = e.slice(_a.URL_SCHEME.length)), (e == null || e.length === 0) && (e = Az), this.modelJsonFileName = e + Rz, this.weightDataFileName = e + Fz;
}
async save(e) {
if (typeof document == "undefined")
throw new Error("Browser downloads are not supported in this environment since `document` is not present");
- let t10 = window.URL.createObjectURL(new Blob([e.weightData], { type: "application/octet-stream" }));
+ let t6 = window.URL.createObjectURL(new Blob([e.weightData], { type: "application/octet-stream" }));
if (e.modelTopology instanceof ArrayBuffer)
throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");
{
- let o = [{ paths: ["./" + this.weightDataFileName], weights: e.weightSpecs }], n = Xm(e, o), s = window.URL.createObjectURL(new Blob([JSON.stringify(n)], { type: "application/json" })), a = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor;
- if (a.download = this.modelJsonFileName, a.href = s, await lv(() => a.dispatchEvent(new MouseEvent("click"))), e.weightData != null) {
+ let o = [{ paths: ["./" + this.weightDataFileName], weights: e.weightSpecs }], n = Bm(e, o), s = window.URL.createObjectURL(new Blob([JSON.stringify(n)], { type: "application/json" })), a = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor;
+ if (a.download = this.modelJsonFileName, a.href = s, await Bv(() => a.dispatchEvent(new MouseEvent("click"))), e.weightData != null) {
let i = this.weightDataAnchor == null ? document.createElement("a") : this.weightDataAnchor;
- i.download = this.weightDataFileName, i.href = t10, await lv(() => i.dispatchEvent(new MouseEvent("click")));
+ i.download = this.weightDataFileName, i.href = t6, await Bv(() => i.dispatchEvent(new MouseEvent("click")));
}
- return { modelArtifactsInfo: As(e) };
+ return { modelArtifactsInfo: Ps(e) };
}
}
};
-Sa.URL_SCHEME = "downloads://";
-var Jb = class {
+_a.URL_SCHEME = "downloads://";
+var jb = class {
constructor(e) {
if (e == null || e.length < 1)
throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);
this.jsonFile = e[0], this.weightsFiles = e.slice(1);
}
async load() {
- return new Promise((e, t10) => {
+ return new Promise((e, t6) => {
let o = new FileReader();
o.onload = (n) => {
let s = JSON.parse(n.target.result), a = s.modelTopology;
if (a == null) {
- t10(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));
+ t6(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));
return;
}
if (s.weightsManifest == null) {
- t10(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));
+ t6(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));
return;
}
if (this.weightsFiles.length === 0) {
e({ modelTopology: a });
return;
}
- let p = Bp(s, (u) => this.loadWeights(u));
+ let p = Dp(s, (u) => this.loadWeights(u));
e(p);
- }, o.onerror = (n) => t10(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`), o.readAsText(this.jsonFile);
+ }, o.onerror = (n) => t6(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`), o.readAsText(this.jsonFile);
});
}
loadWeights(e) {
- let t10 = [], o = [];
+ let t6 = [], o = [];
for (let a of e)
- t10.push(...a.weights), o.push(...a.paths);
+ t6.push(...a.weights), o.push(...a.paths);
let n = this.checkManifestAndWeightFiles(e), s = o.map((a) => this.loadWeightsFile(a, n[a]));
- return Promise.all(s).then((a) => [t10, Lp(a)]);
+ return Promise.all(s).then((a) => [t6, Fp(a)]);
}
- loadWeightsFile(e, t10) {
+ loadWeightsFile(e, t6) {
return new Promise((o, n) => {
let s = new FileReader();
s.onload = (a) => {
let i = a.target.result;
o(i);
- }, s.onerror = (a) => n(`Failed to weights data from file of path '${e}'.`), s.readAsArrayBuffer(t10);
+ }, s.onerror = (a) => n(`Failed to weights data from file of path '${e}'.`), s.readAsArrayBuffer(t6);
});
}
checkManifestAndWeightFiles(e) {
- let t10 = [], o = this.weightsFiles.map((s) => Hb(s.name)), n = {};
+ let t6 = [], o = this.weightsFiles.map((s) => Vb(s.name)), n = {};
for (let s of e)
s.paths.forEach((a) => {
- let i = Hb(a);
- if (t10.indexOf(i) !== -1)
+ let i = Vb(a);
+ if (t6.indexOf(i) !== -1)
throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);
- if (t10.push(i), o.indexOf(i) === -1)
+ if (t6.push(i), o.indexOf(i) === -1)
throw new Error(`Weight file with basename '${i}' is not provided.`);
n[a] = this.weightsFiles[o.indexOf(i)];
});
- if (t10.length !== this.weightsFiles.length)
- throw new Error(`Mismatch in the number of files in weights manifest (${t10.length}) and the number of weight files provided (${this.weightsFiles.length}).`);
+ if (t6.length !== this.weightsFiles.length)
+ throw new Error(`Mismatch in the number of files in weights manifest (${t6.length}) and the number of weight files provided (${this.weightsFiles.length}).`);
return n;
}
};
-var fW = (r) => P().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(Sa.URL_SCHEME) ? dW(r.slice(Sa.URL_SCHEME.length)) : null;
-mt.registerSaveRouter(fW);
-function dW(r = "model") {
- return new Sa(r);
+var Dz = (r) => O().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(_a.URL_SCHEME) ? Oz(r.slice(_a.URL_SCHEME.length)) : null;
+lt.registerSaveRouter(Dz);
+function Oz(r = "model") {
+ return new _a(r);
}
-function mv(r) {
- return new Jb(r);
+function Vv(r) {
+ return new jb(r);
}
-function eC(r, e, t10, o) {
- a(r), t10 = t10 == null ? 0 : t10, o = o == null ? 1 : o, i(t10, o);
+function Xb(r, e, t6, o) {
+ a(r), t6 = t6 == null ? 0 : t6, o = o == null ? 1 : o, i(t6, o);
let n = 0, s = (p) => (p.then((u) => {
- let c = t10 + ++n / r.length * (o - t10);
+ let c = t6 + ++n / r.length * (o - t6);
return e(c), u;
}), p);
function a(p) {
- $(p != null && Array.isArray(p) && p.length > 0, () => "promises must be a none empty array");
+ E(p != null && Array.isArray(p) && p.length > 0, () => "promises must be a none empty array");
}
function i(p, u) {
- $(p >= 0 && p <= 1, () => `Progress fraction must be in range [0, 1], but got startFraction ${p}`), $(u >= 0 && u <= 1, () => `Progress fraction must be in range [0, 1], but got endFraction ${u}`), $(u >= p, () => `startFraction must be no more than endFraction, but got startFraction ${p} and endFraction ${u}`);
+ E(p >= 0 && p <= 1, () => `Progress fraction must be in range [0, 1], but got startFraction ${p}`), E(u >= 0 && u <= 1, () => `Progress fraction must be in range [0, 1], but got endFraction ${u}`), E(u >= p, () => `startFraction must be no more than endFraction, but got startFraction ${p} and endFraction ${u}`);
}
return Promise.all(r.map(s));
}
-async function tC(r, e) {
+async function Yb(r, e) {
e == null && (e = {});
- let t10 = e.fetchFunc == null ? P().platform.fetch : e.fetchFunc, o = r.map((l) => t10(l, e.requestInit, { isBinary: true })), n = 0, s = 0.5, i = (e.onProgress == null ? await Promise.all(o) : await eC(o, e.onProgress, n, s)).map((l) => l.arrayBuffer()), p = 0.5, u = 1;
- return e.onProgress == null ? await Promise.all(i) : await eC(i, e.onProgress, p, u);
+ let t6 = e.fetchFunc == null ? O().platform.fetch : e.fetchFunc, o = r.map((l) => t6(l, e.requestInit, { isBinary: true })), n = 0, s = 0.5, i = (e.onProgress == null ? await Promise.all(o) : await Xb(o, e.onProgress, n, s)).map((l) => l.arrayBuffer()), p = 0.5, u = 1;
+ return e.onProgress == null ? await Promise.all(i) : await Xb(i, e.onProgress, p, u);
}
-async function fv(r, e = "", t10, o) {
- return rC((a) => tC(a, { requestInit: o }))(r, e, t10);
+async function zv(r, e = "", t6, o) {
+ return Qb((a) => Yb(a, { requestInit: o }))(r, e, t6);
}
-function rC(r) {
- return async (e, t10 = "", o) => {
+function Qb(r) {
+ return async (e, t6 = "", o) => {
let n = e.map(() => false), s = {}, a = o != null ? o.map(() => false) : [], i = [];
- if (e.forEach((f, d) => {
+ if (e.forEach((d, f) => {
let h = 0;
- f.weights.forEach((g) => {
- let y = "quantization" in g ? g.quantization.dtype : g.dtype, b = al[y] * Ve(g.shape), C = () => {
- n[d] = true, s[d] == null && (s[d] = []), s[d].push({ manifestEntry: g, groupOffset: h, sizeBytes: b });
+ d.weights.forEach((g) => {
+ let x = "quantization" in g ? g.quantization.dtype : g.dtype, b = Zc[x] * ze(g.shape), C = () => {
+ n[f] = true, s[f] == null && (s[f] = []), s[f].push({ manifestEntry: g, groupOffset: h, sizeBytes: b });
};
o != null ? o.forEach((w, k) => {
w === g.name && (C(), a[k] = true);
}) : C(), i.push(g.name), h += b;
});
- }), !a.every((f) => f)) {
- let f = o.filter((d, h) => !a[h]);
- throw new Error(`Could not find weights in manifest with names: ${f.join(", ")}.
+ }), !a.every((d) => d)) {
+ let d = o.filter((f, h) => !a[h]);
+ throw new Error(`Could not find weights in manifest with names: ${d.join(", ")}.
Manifest JSON has weights with names: ${i.join(", ")}.`);
}
- let p = n.reduce((f, d, h) => (d && f.push(h), f), []), u = [];
- p.forEach((f) => {
- e[f].paths.forEach((d) => {
- let h = t10 + (t10.endsWith("/") ? "" : "/") + d;
+ let p = n.reduce((d, f, h) => (f && d.push(h), d), []), u = [];
+ p.forEach((d) => {
+ e[d].paths.forEach((f) => {
+ let h = t6 + (t6.endsWith("/") ? "" : "/") + f;
u.push(h);
});
});
let c = await r(u), l = {}, m = 0;
- return p.forEach((f) => {
- let d = e[f].paths.length, h = 0;
- for (let w = 0; w < d; w++)
+ return p.forEach((d) => {
+ let f = e[d].paths.length, h = 0;
+ for (let w = 0; w < f; w++)
h += c[m + w].byteLength;
- let g = new ArrayBuffer(h), y = new Uint8Array(g), b = 0;
- for (let w = 0; w < d; w++) {
+ let g = new ArrayBuffer(h), x = new Uint8Array(g), b = 0;
+ for (let w = 0; w < f; w++) {
let k = new Uint8Array(c[m + w]);
- y.set(k, b), b += k.byteLength;
+ x.set(k, b), b += k.byteLength;
}
- s[f].forEach((w) => {
- let k = g.slice(w.groupOffset, w.groupOffset + w.sizeBytes), _ = jm(k, [w.manifestEntry]);
- for (let E in _)
- l[E] = _[E];
- }), m += d;
+ s[d].forEach((w) => {
+ let k = g.slice(w.groupOffset, w.groupOffset + w.sizeBytes), _ = Lm(k, [w.manifestEntry]);
+ for (let $ in _)
+ l[$] = _[$];
+ }), m += f;
}), l;
};
}
-var hW = "application/octet-stream";
-var gW = "application/json";
-var il = class {
- constructor(e, t10) {
- if (this.DEFAULT_METHOD = "POST", t10 == null && (t10 = {}), this.weightPathPrefix = t10.weightPathPrefix, this.onProgress = t10.onProgress, this.weightUrlConverter = t10.weightUrlConverter, t10.fetchFunc != null ? ($(typeof t10.fetchFunc == "function", () => "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"), this.fetch = t10.fetchFunc) : this.fetch = P().platform.fetch, $(e != null && e.length > 0, () => "URL path for http must not be null, undefined or empty."), Array.isArray(e) && $(e.length === 2, () => `URL paths for http must have a length of 2, (actual length is ${e.length}).`), this.path = e, t10.requestInit != null && t10.requestInit.body != null)
+var Pz = "application/octet-stream";
+var Mz = "application/json";
+var Jc = class {
+ constructor(e, t6) {
+ if (this.DEFAULT_METHOD = "POST", t6 == null && (t6 = {}), this.weightPathPrefix = t6.weightPathPrefix, this.onProgress = t6.onProgress, this.weightUrlConverter = t6.weightUrlConverter, t6.fetchFunc != null ? (E(typeof t6.fetchFunc == "function", () => "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"), this.fetch = t6.fetchFunc) : this.fetch = O().platform.fetch, E(e != null && e.length > 0, () => "URL path for http must not be null, undefined or empty."), Array.isArray(e) && E(e.length === 2, () => `URL paths for http must have a length of 2, (actual length is ${e.length}).`), this.path = e, t6.requestInit != null && t6.requestInit.body != null)
throw new Error("requestInit is expected to have no pre-existing body, but has one.");
- this.requestInit = t10.requestInit || {};
+ this.requestInit = t6.requestInit || {};
}
async save(e) {
if (e.modelTopology instanceof ArrayBuffer)
throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");
- let t10 = Object.assign({ method: this.DEFAULT_METHOD }, this.requestInit);
- t10.body = new FormData();
- let o = [{ paths: ["./model.weights.bin"], weights: e.weightSpecs }], n = Xm(e, o);
- t10.body.append("model.json", new Blob([JSON.stringify(n)], { type: gW }), "model.json"), e.weightData != null && t10.body.append("model.weights.bin", new Blob([e.weightData], { type: hW }), "model.weights.bin");
- let s = await this.fetch(this.path, t10);
+ let t6 = Object.assign({ method: this.DEFAULT_METHOD }, this.requestInit);
+ t6.body = new FormData();
+ let o = [{ paths: ["./model.weights.bin"], weights: e.weightSpecs }], n = Bm(e, o);
+ t6.body.append("model.json", new Blob([JSON.stringify(n)], { type: Mz }), "model.json"), e.weightData != null && t6.body.append("model.weights.bin", new Blob([e.weightData], { type: Pz }), "model.weights.bin");
+ let s = await this.fetch(this.path, t6);
if (s.ok)
- return { modelArtifactsInfo: As(e), responses: [s] };
+ return { modelArtifactsInfo: Ps(e), responses: [s] };
throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${s.status}.`);
}
async load() {
let e = await this.fetch(this.path, this.requestInit);
if (!e.ok)
throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);
- let t10;
+ let t6;
try {
- t10 = await e.json();
+ t6 = await e.json();
} catch (s) {
let a = `Failed to parse model JSON of response from ${this.path}.`;
throw this.path.endsWith(".pb") ? a += " Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository." : a += " Please make sure the server is serving valid JSON for this request.", new Error(a);
}
- let o = t10.modelTopology, n = t10.weightsManifest;
+ let o = t6.modelTopology, n = t6.weightsManifest;
if (o == null && n == null)
throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);
- return Bp(t10, (s) => this.loadWeights(s));
+ return Dp(t6, (s) => this.loadWeights(s));
}
async loadWeights(e) {
- let t10 = Array.isArray(this.path) ? this.path[1] : this.path, [o, n] = xW(t10), s = this.weightPathPrefix || o, a = Ym(e), i = [], p = [];
+ let t6 = Array.isArray(this.path) ? this.path[1] : this.path, [o, n] = Lz(t6), s = this.weightPathPrefix || o, a = Vm(e), i = [], p = [];
for (let c of e)
for (let l of c.paths)
this.weightUrlConverter != null ? p.push(this.weightUrlConverter(l)) : i.push(s + l + n);
this.weightUrlConverter && i.push(...await Promise.all(p));
- let u = await tC(i, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress });
- return [a, Lp(u)];
+ let u = await Yb(i, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress });
+ return [a, Fp(u)];
}
};
-il.URL_SCHEME_REGEX = /^https?:\/\//;
-function xW(r) {
- let e = r.lastIndexOf("/"), t10 = r.lastIndexOf("?"), o = r.substring(0, e), n = t10 > e ? r.substring(t10) : "";
+Jc.URL_SCHEME_REGEX = /^https?:\/\//;
+function Lz(r) {
+ let e = r.lastIndexOf("/"), t6 = r.lastIndexOf("?"), o = r.substring(0, e), n = t6 > e ? r.substring(t6) : "";
return [o + "/", n];
}
-function tf(r) {
- return r.match(il.URL_SCHEME_REGEX) != null;
+function Hm(r) {
+ return r.match(Jc.URL_SCHEME_REGEX) != null;
}
-var dv = (r, e) => {
+var Wv = (r, e) => {
if (typeof fetch == "undefined" && (e == null || e.fetchFunc == null))
return null;
{
- let t10 = true;
- if (Array.isArray(r) ? t10 = r.every((o) => tf(o)) : t10 = tf(r), t10)
- return rf(r, e);
+ let t6 = true;
+ if (Array.isArray(r) ? t6 = r.every((o) => Hm(o)) : t6 = Hm(r), t6)
+ return qm(r, e);
}
return null;
};
-mt.registerSaveRouter(dv);
-mt.registerLoadRouter(dv);
-function rf(r, e) {
- return new il(r, e);
+lt.registerSaveRouter(Wv);
+lt.registerLoadRouter(Wv);
+function qm(r, e) {
+ return new Jc(r, e);
}
-function hv(r, e) {
- return rf(r, e);
+function Uv(r, e) {
+ return qm(r, e);
}
-var ul = class {
+var el = class {
constructor(e) {
this.modelArtifacts = e;
}
@@ -5522,7 +5529,7 @@ var ul = class {
return this.modelArtifacts;
}
};
-var of = class {
+var Km = class {
constructor(e) {
this.saveHandler = e;
}
@@ -5530,196 +5537,196 @@ var of = class {
return this.saveHandler(e);
}
};
-var oC = class {
+var Zb = class {
constructor(e) {
- e.load && (this.load = () => Promise.resolve(e.load())), e.save && (this.save = (t10) => Promise.resolve(e.save(t10)));
+ e.load && (this.load = () => Promise.resolve(e.load())), e.save && (this.save = (t6) => Promise.resolve(e.save(t6)));
}
};
-function gv(r, e, t10, o) {
+function Gv(r, e, t6, o) {
let n = arguments;
- return new oC(nC(...n));
+ return new Zb(Jb(...n));
}
-function nC(r, e, t10, o) {
- return arguments.length === 1 ? r.modelTopology != null || r.weightSpecs != null ? new ul(r) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new ul({ modelTopology: r })) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new ul({ modelTopology: r, weightSpecs: e, weightData: t10, trainingConfig: o }));
+function Jb(r, e, t6, o) {
+ return arguments.length === 1 ? r.modelTopology != null || r.weightSpecs != null ? new el(r) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new el({ modelTopology: r })) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new el({ modelTopology: r, weightSpecs: e, weightData: t6, trainingConfig: o }));
}
-function xv(r) {
- return new of(r);
+function Hv(r) {
+ return new Km(r);
}
-function yv(r) {
- return new of(r);
+function qv(r) {
+ return new Km(r);
}
-var Cv = {};
-Be(Cv, { confusionMatrix: () => bv });
-function yW(r, e, t10 = false, o = false) {
+var jv = {};
+Ue(jv, { confusionMatrix: () => Kv });
+function Bz(r, e, t6 = false, o = false) {
let n = v(r, "a", "matMul"), s = v(e, "b", "matMul");
[n, s] = Re(n, s);
- let a = { a: n, b: s }, i = { transposeA: t10, transposeB: o };
- return N.runKernel(cn, a, i);
+ let a = { a: n, b: s }, i = { transposeA: t6, transposeB: o };
+ return T.runKernel(Wo, a, i);
}
-var Xe = T({ matMul_: yW });
-function bW(r, e, t10 = 1, o = 0, n = "int32") {
+var Xe = N({ matMul_: Bz });
+function Vz(r, e, t6 = 1, o = 0, n = "int32") {
if (e < 2)
throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);
- let a = { indices: v(r, "indices", "oneHot", "int32") }, i = { dtype: n, depth: e, onValue: t10, offValue: o };
- return N.runKernel(ca, a, i);
+ let a = { indices: v(r, "indices", "oneHot", "int32") }, i = { dtype: n, depth: e, onValue: t6, offValue: o };
+ return T.runKernel(En, a, i);
}
-var pl = T({ oneHot_: bW });
-function Tie() {
- P().set("PROD", true);
+var tl = N({ oneHot_: Vz });
+function wie() {
+ O().set("PROD", true);
}
-function Nie() {
- P().set("DEBUG", true);
+function Iie() {
+ O().set("DEBUG", true);
}
-function _ie() {
- P().set("DEPRECATION_WARNINGS_ENABLED", false), console.warn("TensorFlow.js deprecation warnings have been disabled.");
+function vie() {
+ O().set("DEPRECATION_WARNINGS_ENABLED", false), console.warn("TensorFlow.js deprecation warnings have been disabled.");
}
-function sC(r) {
- P().getBool("DEPRECATION_WARNINGS_ENABLED") && console.warn(r + " You can disable deprecation warnings with tf.disableDeprecationWarnings().");
+function eC(r) {
+ O().getBool("DEPRECATION_WARNINGS_ENABLED") && console.warn(r + " You can disable deprecation warnings with tf.disableDeprecationWarnings().");
}
-B0(sC);
-function Eie() {
- N.disposeVariables();
+dv(eC);
+function kie() {
+ T.disposeVariables();
}
function cr() {
- return N;
+ return T;
+}
+function Nie() {
+ return T.memory();
+}
+function Tie(r) {
+ return T.profile(r);
+}
+function Ee(r, e) {
+ return T.tidy(r, e);
+}
+function Dt(r) {
+ Qc(r).forEach((t6) => t6.dispose());
+}
+function _r(r) {
+ return T.keep(r);
+}
+function _ie(r) {
+ return T.time(r);
+}
+function Eie(r) {
+ return T.setBackend(r);
}
function $ie() {
- return N.memory();
+ return T.ready();
+}
+function Aie() {
+ return T.backendName;
}
function Rie(r) {
- return N.profile(r);
-}
-function Ne(r, e) {
- return N.tidy(r, e);
-}
-function Ft(r) {
- sl(r).forEach((t10) => t10.dispose());
-}
-function So(r) {
- return N.keep(r);
-}
-function Aie(r) {
- return N.time(r);
+ T.removeBackend(r);
}
function Fie(r) {
- return N.setBackend(r);
+ return T.findBackend(r);
}
-function Die() {
- return N.ready();
+function Die(r) {
+ return T.findBackendFactory(r);
}
-function Pie() {
- return N.backendName;
+function Ci(r, e, t6 = 1) {
+ return T.registerBackend(r, e, t6);
}
-function Oie(r) {
- N.removeBackend(r);
+function Oie() {
+ return T.backend;
}
-function Mie(r) {
- return N.findBackend(r);
+function Pie(r, e) {
+ O().setPlatform(r, e);
}
-function Lie(r) {
- return N.findBackendFactory(r);
+function zz(r) {
+ let t6 = { input: v(r, "input", "imag") };
+ return T.runKernel(si, t6);
}
-function pi(r, e, t10 = 1) {
- return N.registerBackend(r, e, t10);
+var Si = N({ imag_: zz });
+function Wz(r) {
+ let t6 = { x: v(r, "x", "neg") };
+ return T.runKernel(ws, t6);
}
-function Bie() {
- return N.backend;
+var yr = N({ neg_: Wz });
+function Uz(r) {
+ let t6 = { input: v(r, "input", "real") };
+ return T.runKernel(ai, t6);
}
-function Vie(r, e) {
- P().setPlatform(r, e);
-}
-function CW(r) {
- let t10 = { input: v(r, "input", "imag") };
- return N.runKernel(Ya, t10);
-}
-var ci = T({ imag_: CW });
-function IW(r) {
- let t10 = { x: v(r, "x", "neg") };
- return N.runKernel(Pn, t10);
-}
-var yr = T({ neg_: IW });
-function wW(r) {
- let t10 = { input: v(r, "input", "real") };
- return N.runKernel(la, t10);
-}
-var ka = T({ real_: wW });
-function SW(r, e, t10) {
+var $a = N({ real_: Uz });
+function Gz(r, e, t6) {
let o = v(r, "x", "transpose");
- if (e == null && (e = o.shape.map((a, i) => i).reverse()), $(o.rank === e.length, () => `Error in transpose: rank of input ${o.rank} must match length of perm ${e}.`), e.forEach((a) => {
- $(a >= 0 && a < o.rank, () => `All entries in 'perm' must be between 0 and ${o.rank - 1} but got ${e}`);
+ if (e == null && (e = o.shape.map((a, i) => i).reverse()), E(o.rank === e.length, () => `Error in transpose: rank of input ${o.rank} must match length of perm ${e}.`), e.forEach((a) => {
+ E(a >= 0 && a < o.rank, () => `All entries in 'perm' must be between 0 and ${o.rank - 1} but got ${e}`);
}), o.rank <= 1)
return o.clone();
let n = { x: o }, s = { perm: e };
- return o.dtype === "complex64" ? Ne(() => {
- let a = ka(o), i = ci(o);
- return a = N.runKernel(Mr, { x: a }, s), i = N.runKernel(Mr, { x: i }, s), t10 && (i = yr(i)), Er(a, i);
- }) : N.runKernel(Mr, n, s);
+ return o.dtype === "complex64" ? Ee(() => {
+ let a = $a(o), i = Si(o);
+ return a = T.runKernel(ro, { x: a }, s), i = T.runKernel(ro, { x: i }, s), t6 && (i = yr(i)), Tr(a, i);
+ }) : T.runKernel(ro, n, s);
}
-var Wp = T({ transpose_: SW });
-function vW(r, e, t10) {
+var Mp = N({ transpose_: Gz });
+function Hz(r, e, t6) {
let o = v(r, "labels", "confusionMatrix"), n = v(e, "predictions", "confusionMatrix");
- $(t10 == null || t10 > 0 && Number.isInteger(t10), () => `If provided, numClasses must be a positive integer, but got ${t10}`), $(o.rank === 1, () => `Expected the rank of labels to be 1, but got ${o.rank}`), $(n.rank === 1, () => `Expected the rank of predictions to be 1, but got ${n.rank}`), $(o.shape[0] === n.shape[0], () => `Mismatch in the number of examples: ${o.shape[0]} vs. ${n.shape[0]}. Labels and predictions should have the same number of elements.`), $(t10 > 0 && Number.isInteger(t10), () => `numClasses is required to be a positive integer, but got ${t10}`);
- let s = pl(qe(o, "int32"), t10), a = pl(qe(n, "int32"), t10), i = Wp(s), p = Xe(i, a);
- return qe(p, "int32");
+ E(t6 == null || t6 > 0 && Number.isInteger(t6), () => `If provided, numClasses must be a positive integer, but got ${t6}`), E(o.rank === 1, () => `Expected the rank of labels to be 1, but got ${o.rank}`), E(n.rank === 1, () => `Expected the rank of predictions to be 1, but got ${n.rank}`), E(o.shape[0] === n.shape[0], () => `Mismatch in the number of examples: ${o.shape[0]} vs. ${n.shape[0]}. Labels and predictions should have the same number of elements.`), E(t6 > 0 && Number.isInteger(t6), () => `numClasses is required to be a positive integer, but got ${t6}`);
+ let s = tl(Ke(o, "int32"), t6), a = tl(Ke(n, "int32"), t6), i = Mp(s), p = Xe(i, a);
+ return Ke(p, "int32");
}
-var bv = T({ confusionMatrix_: vW });
+var Kv = N({ confusionMatrix_: Hz });
var br = {};
-Be(br, { assertAndGetBroadcastShape: () => Je, getBroadcastDims: () => Iv, getReductionAxes: () => nf });
-function Iv(r, e) {
- let t10 = r.length, o = [];
- for (let n = 0; n < t10; n++) {
- let s = t10 - 1 - n, a = r[s] || 1;
+Ue(br, { assertAndGetBroadcastShape: () => Je, getBroadcastDims: () => Xv, getReductionAxes: () => jm });
+function Xv(r, e) {
+ let t6 = r.length, o = [];
+ for (let n = 0; n < t6; n++) {
+ let s = t6 - 1 - n, a = r[s] || 1;
(e[e.length - 1 - n] || 1) > 1 && a === 1 && o.unshift(s);
}
return o;
}
-function nf(r, e) {
- let t10 = [];
+function jm(r, e) {
+ let t6 = [];
for (let o = 0; o < e.length; o++) {
let n = r[r.length - o - 1], s = e.length - o - 1, a = e[s];
- (n == null || n === 1 && a > 1) && t10.unshift(s);
+ (n == null || n === 1 && a > 1) && t6.unshift(s);
}
- return t10;
+ return t6;
}
function Je(r, e) {
- let t10 = [], o = Math.max(r.length, e.length);
+ let t6 = [], o = Math.max(r.length, e.length);
for (let n = 0; n < o; n++) {
let s = r[r.length - n - 1];
s == null && (s = 1);
let a = e[e.length - n - 1];
if (a == null && (a = 1), s === 1)
- t10.unshift(a);
+ t6.unshift(a);
else if (a === 1)
- t10.unshift(s);
+ t6.unshift(s);
else if (s !== a) {
let i = `Operands could not be broadcast together with shapes ${r} and ${e}.`;
throw Error(i);
} else
- t10.unshift(s);
+ t6.unshift(s);
}
- return t10;
+ return t6;
}
-var Sv = {};
-Be(Sv, { fromPixels: () => RW, fromPixelsAsync: () => EW, toPixels: () => $W });
-function sf(r, e, t10) {
- if (eo(r), e != null && e.length !== 3)
+var Qv = {};
+Ue(Qv, { fromPixels: () => Zz, fromPixelsAsync: () => Yz, toPixels: () => Qz });
+function Xm(r, e, t6) {
+ if (Jr(r), e != null && e.length !== 3)
throw new Error("tensor3d() requires shape to have three numbers");
- let o = or(r, t10);
+ let o = or(r, t6);
if (o.length !== 3 && o.length !== 1)
throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");
if (o.length === 1 && e == null)
throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");
- return xr(r, e, o, t10);
+ return xr(r, e, o, t6);
}
var su;
-function wv(r, e = 3) {
+function Yv(r, e = 3) {
if (e > 4)
throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");
if (r == null)
throw new Error("pixels passed to tf.browser.fromPixels() can not be null");
- let t10 = false, o = false, n = false, s = false, a = false, i = false;
+ let t6 = false, o = false, n = false, s = false, a = false, i = false;
if (r.data instanceof Uint8Array)
- t10 = true;
+ t6 = true;
else if (typeof ImageData != "undefined" && r instanceof ImageData)
o = true;
else if (typeof HTMLVideoElement != "undefined" && r instanceof HTMLVideoElement)
@@ -5732,14 +5739,14 @@ function wv(r, e = 3) {
i = true;
else
throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${r.constructor.name}`);
- if (el(Zi, N.backendName) != null) {
- let d = { pixels: r }, h = { numChannels: e };
- return N.runKernel(Zi, d, h);
+ if (qc(Zi, T.backendName) != null) {
+ let f = { pixels: r }, h = { numChannels: e };
+ return T.runKernel(Zi, f, h);
}
let [u, c] = n ? [r.videoWidth, r.videoHeight] : [r.width, r.height], l;
if (a)
l = r.getContext("2d").getImageData(0, 0, u, c).data;
- else if (o || t10)
+ else if (o || t6)
l = r.data;
else if (s || n || i) {
if (su == null)
@@ -5756,64 +5763,64 @@ function wv(r, e = 3) {
if (e === 4)
m = new Int32Array(l);
else {
- let d = u * c;
- m = new Int32Array(d * e);
- for (let h = 0; h < d; h++)
+ let f = u * c;
+ m = new Int32Array(f * e);
+ for (let h = 0; h < f; h++)
for (let g = 0; g < e; ++g)
m[h * e + g] = l[h * 4 + g];
}
- return sf(m, [c, u, e], "int32");
+ return Xm(m, [c, u, e], "int32");
}
-function kW(r) {
+function qz(r) {
return r != null && r.data instanceof Uint8Array;
}
-function TW() {
+function Kz() {
return typeof window != "undefined" && typeof ImageBitmap != "undefined" && window.hasOwnProperty("createImageBitmap");
}
-function NW(r) {
+function jz(r) {
return r != null && r.width !== 0 && r.height !== 0;
}
-function _W(r) {
- return TW() && !(r instanceof ImageBitmap) && NW(r) && !kW(r);
+function Xz(r) {
+ return Kz() && !(r instanceof ImageBitmap) && jz(r) && !qz(r);
}
-async function EW(r, e = 3) {
- let t10 = null;
- if (P().getBool("WRAP_TO_IMAGEBITMAP") && _W(r)) {
+async function Yz(r, e = 3) {
+ let t6 = null;
+ if (O().getBool("WRAP_TO_IMAGEBITMAP") && Xz(r)) {
let o;
try {
o = await createImageBitmap(r, { premultiplyAlpha: "none" });
} catch (n) {
o = null;
}
- o != null && o.width === r.width && o.height === r.height ? t10 = o : t10 = r;
+ o != null && o.width === r.width && o.height === r.height ? t6 = o : t6 = r;
} else
- t10 = r;
- return wv(t10, e);
+ t6 = r;
+ return Yv(t6, e);
}
-async function $W(r, e) {
- let t10 = v(r, "img", "toPixels");
- if (!(r instanceof ut)) {
- let u = t10;
- t10 = qe(u, "int32"), u.dispose();
+async function Qz(r, e) {
+ let t6 = v(r, "img", "toPixels");
+ if (!(r instanceof it)) {
+ let u = t6;
+ t6 = Ke(u, "int32"), u.dispose();
}
- if (t10.rank !== 2 && t10.rank !== 3)
- throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${t10.rank}.`);
- let [o, n] = t10.shape.slice(0, 2), s = t10.rank === 2 ? 1 : t10.shape[2];
+ if (t6.rank !== 2 && t6.rank !== 3)
+ throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${t6.rank}.`);
+ let [o, n] = t6.shape.slice(0, 2), s = t6.rank === 2 ? 1 : t6.shape[2];
if (s > 4 || s === 2)
throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${s}`);
- if (t10.dtype !== "float32" && t10.dtype !== "int32")
- throw new Error(`Unsupported type for toPixels: ${t10.dtype}. Please use float32 or int32 tensors.`);
- let a = await t10.data(), i = t10.dtype === "float32" ? 255 : 1, p = new Uint8ClampedArray(n * o * 4);
+ if (t6.dtype !== "float32" && t6.dtype !== "int32")
+ throw new Error(`Unsupported type for toPixels: ${t6.dtype}. Please use float32 or int32 tensors.`);
+ let a = await t6.data(), i = t6.dtype === "float32" ? 255 : 1, p = new Uint8ClampedArray(n * o * 4);
for (let u = 0; u < o * n; ++u) {
let c = [0, 0, 0, 255];
for (let m = 0; m < s; m++) {
- let f = a[u * s + m];
- if (t10.dtype === "float32") {
- if (f < 0 || f > 1)
- throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${f}.`);
- } else if (t10.dtype === "int32" && (f < 0 || f > 255))
- throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${f}.`);
- s === 1 ? (c[0] = f * i, c[1] = f * i, c[2] = f * i) : c[m] = f * i;
+ let d = a[u * s + m];
+ if (t6.dtype === "float32") {
+ if (d < 0 || d > 1)
+ throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${d}.`);
+ } else if (t6.dtype === "int32" && (d < 0 || d > 255))
+ throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${d}.`);
+ s === 1 ? (c[0] = d * i, c[1] = d * i, c[2] = d * i) : c[m] = d * i;
}
let l = u * 4;
p[l + 0] = Math.round(c[0]), p[l + 1] = Math.round(c[1]), p[l + 2] = Math.round(c[2]), p[l + 3] = Math.round(c[3]);
@@ -5823,22 +5830,22 @@ async function $W(r, e) {
let u = e.getContext("2d"), c = new ImageData(p, n, o);
u.putImageData(c, 0, 0);
}
- return t10 !== r && t10.dispose(), p;
+ return t6 !== r && t6.dispose(), p;
}
-var RW = T({ fromPixels_: wv });
-var af = {};
-Be(af, { prepareAndValidate: () => vv });
-function vv(r, e) {
- let t10 = r.shape.length, o = e.shape.length;
- if (t10 < 1)
- throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${t10}.`);
+var Zz = N({ fromPixels_: Yv });
+var Ym = {};
+Ue(Ym, { prepareAndValidate: () => Zv });
+function Zv(r, e) {
+ let t6 = r.shape.length, o = e.shape.length;
+ if (t6 < 1)
+ throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${t6}.`);
if (o < 1)
throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${o}.`);
if (e.dtype !== "int32")
throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);
- if (e.shape[o - 1] > t10)
- throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[o - 1]} vs. ${t10}`);
- if (Ve(r.shape) === 0)
+ if (e.shape[o - 1] > t6)
+ throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[o - 1]} vs. ${t6}`);
+ if (ze(r.shape) === 0)
throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${r.shape}.`);
let n = e.shape, s = n[n.length - 1], a = 1;
for (let l = 0; l < n.length - 1; ++l)
@@ -5846,119 +5853,119 @@ function vv(r, e) {
let i = r.shape, p = n.slice();
p.pop();
let u = 1;
- for (let l = s; l < t10; ++l)
+ for (let l = s; l < t6; ++l)
u *= i[l], p.push(i[l]);
- let c = [...ds(r.shape).map((l) => l / u), 1].slice(0, s);
+ let c = [...hs(r.shape).map((l) => l / u), 1].slice(0, s);
return [p, a, u, c];
}
-var cl = {};
-Be(cl, { calculateShapes: () => kv, validateInput: () => uf, validateUpdateShape: () => aC });
-function aC(r, e, t10) {
- let o = e.rank > 1 ? e.shape[e.rank - 1] : 1, n = e.rank > 1 ? e.rank - 1 : 1, s = `Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${t10.shape}, indices.shape: ${e.shape}, shape: ${r}, sliceDim: ${o}, and batchDim: ${n}.`;
- if (t10.rank < n)
+var rl = {};
+Ue(rl, { calculateShapes: () => Jv, validateInput: () => Qm, validateUpdateShape: () => tC });
+function tC(r, e, t6) {
+ let o = e.rank > 1 ? e.shape[e.rank - 1] : 1, n = e.rank > 1 ? e.rank - 1 : 1, s = `Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${t6.shape}, indices.shape: ${e.shape}, shape: ${r}, sliceDim: ${o}, and batchDim: ${n}.`;
+ if (t6.rank < n)
throw new Error(s + ` update.rank < ${n}. `);
- if (r.length < o + (t10.rank - n))
- throw new Error(s + ` Output shape length < ${o + (t10.rank - n)}`);
- if (t10.rank !== n + r.length - o)
+ if (r.length < o + (t6.rank - n))
+ throw new Error(s + ` Output shape length < ${o + (t6.rank - n)}`);
+ if (t6.rank !== n + r.length - o)
throw new Error(s + ` update.rank != ${n + r.length - o}`);
for (let a = 0; a < n; ++a)
- if (t10.shape[a] !== e.shape[a])
- throw new Error(s + ` updates.shape[${a}] (${t10.shape[a]}) != indices.shape[${a}] (${e.shape[a]}).`);
- for (let a = 0; a < t10.rank - n; ++a)
- if (t10.shape[a + n] !== r[a + o])
- throw new Error(s + ` updates.shape[${a + n}] (${t10.shape[a + n]}) != shape[${a + n}] (${r[a + n]})`);
+ if (t6.shape[a] !== e.shape[a])
+ throw new Error(s + ` updates.shape[${a}] (${t6.shape[a]}) != indices.shape[${a}] (${e.shape[a]}).`);
+ for (let a = 0; a < t6.rank - n; ++a)
+ if (t6.shape[a + n] !== r[a + o])
+ throw new Error(s + ` updates.shape[${a + n}] (${t6.shape[a + n]}) != shape[${a + n}] (${r[a + n]})`);
}
-function uf(r, e, t10) {
+function Qm(r, e, t6) {
if (e.rank < 1)
throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${e.rank}.`);
if (r.rank < 1)
throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${r.rank}.`);
if (e.dtype !== "int32")
throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${e.dtype}`);
- if (t10.length < 1)
- throw new Error(`Output rank must be greater or equal to 1, but got shape: ${t10}`);
- if (t10.length === 0) {
+ if (t6.length < 1)
+ throw new Error(`Output rank must be greater or equal to 1, but got shape: ${t6}`);
+ if (t6.length === 0) {
if (e.size === 0)
throw new Error(`Indices specified for empty output. indices shape: ${e.shape}`);
if (r.size === 0)
throw new Error(`Updates specified for empty output. updates shape: ${r.shape}`);
}
- aC(t10, e, r);
+ tC(t6, e, r);
}
-function kv(r, e, t10) {
- let o = e.shape.length, n = o > 1 ? e.shape[o - 1] : 1, s = t10.length, a = 1;
+function Jv(r, e, t6) {
+ let o = e.shape.length, n = o > 1 ? e.shape[o - 1] : 1, s = t6.length, a = 1;
for (let l = n; l < s; ++l)
- a *= t10[l];
- let i = n < 1 ? 1 : n, p = Ve(e.shape) / i, u = [...ds(t10.slice(0, n)), 1], c = Ve(t10);
+ a *= t6[l];
+ let i = n < 1 ? 1 : n, p = ze(e.shape) / i, u = [...hs(t6.slice(0, n)), 1], c = ze(t6);
return { sliceRank: n, numUpdates: p, sliceSize: a, strides: u, outputSize: c };
}
-var et = {};
-Be(et, { assertParamsValid: () => FW, computeFlatOffset: () => LW, computeOutShape: () => PW, getNormalizedAxes: () => OW, isSliceContinous: () => MW, maskToAxes: () => DW, parseSliceParams: () => BW, sliceInfo: () => VW, startForAxis: () => Fv, startIndicesWithElidedDims: () => $v, stopForAxis: () => Dv, stopIndicesWithElidedDims: () => Rv, stridesForAxis: () => Av, stridesWithElidedDims: () => Nv });
-var iC = -2;
-var AW = -1;
-function FW(r, e, t10) {
+var ut = {};
+Ue(ut, { assertParamsValid: () => eW, computeFlatOffset: () => sW, computeOutShape: () => rW, getNormalizedAxes: () => oW, isSliceContinous: () => nW, maskToAxes: () => tW, parseSliceParams: () => aW, sliceInfo: () => iW, startForAxis: () => i0, startIndicesWithElidedDims: () => n0, stopForAxis: () => u0, stopIndicesWithElidedDims: () => s0, stridesForAxis: () => a0, stridesWithElidedDims: () => t0 });
+var rC = -2;
+var Jz = -1;
+function eW(r, e, t6) {
let o = r.shape.length;
- $(o === e.length, () => `Error in slice${o}D: Length of begin ${e} must match the rank of the array (${o}).`), $(o === t10.length, () => `Error in slice${o}D: Length of size ${t10} must match the rank of the array (${o}).`);
+ E(o === e.length, () => `Error in slice${o}D: Length of begin ${e} must match the rank of the array (${o}).`), E(o === t6.length, () => `Error in slice${o}D: Length of size ${t6} must match the rank of the array (${o}).`);
for (let n = 0; n < o; ++n)
- $(e[n] + t10[n] <= r.shape[n], () => `Error in slice${o}D: begin[${n}] + size[${n}] (${e[n] + t10[n]}) would overflow input.shape[${n}] (${r.shape[n]})`);
+ E(e[n] + t6[n] <= r.shape[n], () => `Error in slice${o}D: begin[${n}] + size[${n}] (${e[n] + t6[n]}) would overflow input.shape[${n}] (${r.shape[n]})`);
}
-function DW(r) {
- let e = [], t10 = 0;
+function tW(r) {
+ let e = [], t6 = 0;
for (; r > 0; )
- r & 1 && e.push(t10), r /= 2, t10++;
+ r & 1 && e.push(t6), r /= 2, t6++;
return e;
}
-function PW(r, e, t10) {
+function rW(r, e, t6) {
let o = [];
for (let n = 0; n < r.length; n++)
- o[n] = Math.ceil((e[n] - r[n]) / t10[n]);
+ o[n] = Math.ceil((e[n] - r[n]) / t6[n]);
return o;
}
-function Nv(r, e, t10, o) {
+function t0(r, e, t6, o) {
let n = [...r];
for (let s = n.length; s < o.length; s++)
n.push(1);
- for (let s = 0; s < t10; s++)
+ for (let s = 0; s < t6; s++)
s === 0 ? n[e] = 1 : (n.splice(e, 0, 1), n.pop());
return n;
}
-function _v(r, e, t10) {
- return t10 <= r ? t10 : t10 - (e - 1);
+function r0(r, e, t6) {
+ return t6 <= r ? t6 : t6 - (e - 1);
}
-function Ev(r, e) {
- let t10 = [];
+function o0(r, e) {
+ let t6 = [];
for (let o = 0; o < r; o++)
- t10.push(e + o);
- return t10;
+ t6.push(e + o);
+ return t6;
}
-function OW(r, e, t10, o, n, s, a, i, p) {
+function oW(r, e, t6, o, n, s, a, i, p) {
let u = r.length, c = new Array(u), l = new Array(u), m = new Array(u);
- if (e.length && t10 > 0) {
- let f = e[0], d = t10 + 1;
- c = $v(a, f, d, o, r), l = Rv(i, f, d, n, r), m = Nv(s, f, d, r);
+ if (e.length && t6 > 0) {
+ let d = e[0], f = t6 + 1;
+ c = n0(a, d, f, o, r), l = s0(i, d, f, n, r), m = t0(s, d, f, r);
} else
- for (let f = 0; f < u; f++)
- c[f] = Fv(a, o, s, r, f, p), l[f] = Dv(i, n, s, r, f, p), m[f] = Av(s, f, p);
+ for (let d = 0; d < u; d++)
+ c[d] = i0(a, o, s, r, d, p), l[d] = u0(i, n, s, r, d, p), m[d] = a0(s, d, p);
return { begin: c, end: l, strides: m };
}
-function $v(r, e, t10, o, n) {
- let s = [...n], a = Ev(t10, e);
+function n0(r, e, t6, o, n) {
+ let s = [...n], a = o0(t6, e);
for (let i = 0; i < s.length; i++)
if (a.indexOf(i) > -1)
s[i] = 0;
else {
- let p = _v(e, t10, i), u = o[p];
+ let p = r0(e, t6, i), u = o[p];
r & 1 << p && (u = 0), s[i] = u;
}
return s;
}
-function Rv(r, e, t10, o, n) {
- let s = [...n], a = Ev(t10, e);
+function s0(r, e, t6, o, n) {
+ let s = [...n], a = o0(t6, e);
for (let i = 0; i < s.length; i++)
if (a.indexOf(i) > -1)
s[i] = Number.MAX_SAFE_INTEGER;
else {
- let p = _v(e, t10, i), u = o[p];
+ let p = r0(e, t6, i), u = o[p];
r & 1 << p && (u = Number.MAX_SAFE_INTEGER), s[i] = u;
}
for (let i = 0; i < s.length; i++) {
@@ -5967,59 +5974,59 @@ function Rv(r, e, t10, o, n) {
}
return s;
}
-function Av(r, e, t10) {
+function a0(r, e, t6) {
let o = r[e];
- return (t10 & 1 << e || o == null) && (o = 1), o;
+ return (t6 & 1 << e || o == null) && (o = 1), o;
}
-function Fv(r, e, t10, o, n, s) {
- let a = e[n], i = t10[n] || 1;
+function i0(r, e, t6, o, n, s) {
+ let a = e[n], i = t6[n] || 1;
(r & 1 << n || s & 1 << n || a == null) && (i > 0 ? a = Number.MIN_SAFE_INTEGER : a = Number.MAX_SAFE_INTEGER);
let p = o[n];
return a < 0 && (a += p), a = op(0, a, p - 1), a;
}
-function Dv(r, e, t10, o, n, s) {
- let a = e[n], i = t10[n] || 1;
+function u0(r, e, t6, o, n, s) {
+ let a = e[n], i = t6[n] || 1;
(r & 1 << n || s & 1 << n || a == null) && (i > 0 ? a = Number.MAX_SAFE_INTEGER : a = Number.MIN_SAFE_INTEGER);
let p = o[n];
return a < 0 && (a += p), i > 0 ? a = op(0, a, p) : a = op(-1, a, p - 1), a;
}
-function MW(r, e, t10) {
- let o = t10.length;
- for (let n = 0; n < t10.length; n++)
- if (t10[n] > 1) {
+function nW(r, e, t6) {
+ let o = t6.length;
+ for (let n = 0; n < t6.length; n++)
+ if (t6[n] > 1) {
o = n;
break;
}
- for (let n = o + 1; n < t10.length; n++)
- if (e[n] > 0 || t10[n] !== r[n])
+ for (let n = o + 1; n < t6.length; n++)
+ if (e[n] > 0 || t6[n] !== r[n])
return false;
return true;
}
-function LW(r, e) {
- let t10 = r.length > 0 ? r[r.length - 1] : 1;
+function sW(r, e) {
+ let t6 = r.length > 0 ? r[r.length - 1] : 1;
for (let o = 0; o < r.length - 1; o++)
- t10 += r[o] * e[o];
- return t10;
+ t6 += r[o] * e[o];
+ return t6;
}
-function BW(r, e, t10) {
+function aW(r, e, t6) {
let o, n = r.shape.length;
typeof e == "number" ? o = [e, ...new Array(n - 1).fill(0)] : e.length < n ? o = e.concat(new Array(n - e.length).fill(0)) : o = e.slice(), o.forEach((a) => {
- $(a !== -1, () => "slice() does not support negative begin indexing.");
+ E(a !== -1, () => "slice() does not support negative begin indexing.");
});
let s;
- return t10 == null ? s = new Array(n).fill(-1) : typeof t10 == "number" ? s = [t10, ...new Array(n - 1).fill(-1)] : t10.length < n ? s = t10.concat(new Array(n - t10.length).fill(-1)) : s = t10, s = s.map((a, i) => a >= 0 ? a : ($(a === -1, () => `Negative size values should be exactly -1 but got ${a} for the slice() size at index ${i}.`), r.shape[i] - o[i])), [o, s];
+ return t6 == null ? s = new Array(n).fill(-1) : typeof t6 == "number" ? s = [t6, ...new Array(n - 1).fill(-1)] : t6.length < n ? s = t6.concat(new Array(n - t6.length).fill(-1)) : s = t6, s = s.map((a, i) => a >= 0 ? a : (E(a === -1, () => `Negative size values should be exactly -1 but got ${a} for the slice() size at index ${i}.`), r.shape[i] - o[i])), [o, s];
}
-function VW(r, e, t10, o, n, s, a, i, p) {
+function iW(r, e, t6, o, n, s, a, i, p) {
let u;
if (o == null ? (u = new Array(e.length), u.fill(1)) : u = o, a != null && (a & a - 1) !== 0)
throw new Error("Multiple ellipses in slice is not allowed.");
- let c = false, l = { dims: u.length, numAddAxisAfterEllipsis: 0, begin: e.slice(), end: t10.slice(), strides: u.slice(), beginMask: n, endMask: s, ellipsisMask: a, newAxisMask: i, shrinkAxisMask: p };
+ let c = false, l = { dims: u.length, numAddAxisAfterEllipsis: 0, begin: e.slice(), end: t6.slice(), strides: u.slice(), beginMask: n, endMask: s, ellipsisMask: a, newAxisMask: i, shrinkAxisMask: p };
for (let C = 0; C < l.dims; C++)
c && (1 << C & i) !== 0 && l.numAddAxisAfterEllipsis++, 1 << C & a && (c = true);
c || (l.ellipsisMask |= 1 << l.dims, l.dims++);
let m = { dims: r.length, beginMask: 0, endMask: 0, beginValid: false, endValid: false };
- zW(l, m);
- let f = true, d = true, h = true, g = [], y = [];
+ uW(l, m);
+ let d = true, f = true, h = true, g = [], x = [];
for (let C = 0; C < r.length; ++C) {
if (m.strides[C] === 0)
throw Error(`strides[${C}] must be non-zero`);
@@ -6028,303 +6035,303 @@ function VW(r, e, t10, o, n, s, a, i, p) {
g.push(w ? 1 : -1);
continue;
}
- let _ = [m.beginMask & 1 << C, m.endMask & 1 << C], E = [m.strides[C] > 0 ? 0 : -1, m.strides[C] > 0 ? k : k - 1];
+ let _ = [m.beginMask & 1 << C, m.endMask & 1 << C], $ = [m.strides[C] > 0 ? 0 : -1, m.strides[C] > 0 ? k : k - 1];
if (w && m.strides[C] <= 0)
throw Error("only stride 1 allowed on non-range indexing.");
h = h && m.strides[C] === 1;
- let R = !!(m.beginMask & 1 << C && m.endMask & 1 << C);
+ let A = !!(m.beginMask & 1 << C && m.endMask & 1 << C);
if (m.beginValid && m.endValid) {
if (w) {
let M = m.begin[C] < 0 ? k + m.begin[C] : m.begin[C];
if (m.begin[C] = M, m.end[C] = m.begin[C] + 1, M < 0 || M >= k)
throw Error(`slice index ${m.begin[C]} of dimension ${C} out of bounds.`);
} else
- m.begin[C] = Tv(m.begin[C], 0, m.strides[C], k, _, E), m.end[C] = Tv(m.end[C], 1, m.strides[C], k, _, E);
- let O = m.strides[C] === 1 && m.begin[C] === 0 && m.end[C] === k;
- f = f && O, d = d && (C === 0 && m.strides[C] === 1 || O);
+ m.begin[C] = e0(m.begin[C], 0, m.strides[C], k, _, $), m.end[C] = e0(m.end[C], 1, m.strides[C], k, _, $);
+ let P = m.strides[C] === 1 && m.begin[C] === 0 && m.end[C] === k;
+ d = d && P, f = f && (C === 0 && m.strides[C] === 1 || P);
} else
- f = f && m.strides[C] === 1 && R, d = d && (C === 0 && m.strides[C] === 1 || R);
- let A, D = false;
- if (m.beginValid && m.endValid ? (A = m.end[C] - m.begin[C], D = true) : w ? (A = 1, D = true) : R && k >= 0 && (m.strides[C] < 0 ? A = -k : A = k, D = true), D) {
- let O;
- A === 0 || A < 0 != m.strides[C] < 0 ? O = 0 : O = Math.trunc(A / m.strides[C]) + (A % m.strides[C] !== 0 ? 1 : 0), g.push(O);
+ d = d && m.strides[C] === 1 && A, f = f && (C === 0 && m.strides[C] === 1 || A);
+ let R, D = false;
+ if (m.beginValid && m.endValid ? (R = m.end[C] - m.begin[C], D = true) : w ? (R = 1, D = true) : A && k >= 0 && (m.strides[C] < 0 ? R = -k : R = k, D = true), D) {
+ let P;
+ R === 0 || R < 0 != m.strides[C] < 0 ? P = 0 : P = Math.trunc(R / m.strides[C]) + (R % m.strides[C] !== 0 ? 1 : 0), g.push(P);
} else
g.push(-1);
}
for (let C = 0; C < m.finalShapeGatherIndices.length; ++C) {
let w = m.finalShapeGatherIndices[C];
- w >= 0 ? y.push(g[w]) : w === iC && y.push(1);
+ w >= 0 ? x.push(g[w]) : w === rC && x.push(1);
}
- return { finalShapeSparse: y.filter((C, w) => m.finalShapeGatherIndices[w] !== iC), finalShape: y, isIdentity: f, sliceDim0: d, isSimpleSlice: h, begin: m.begin, end: m.end, strides: m.strides };
+ return { finalShapeSparse: x.filter((C, w) => m.finalShapeGatherIndices[w] !== rC), finalShape: x, isIdentity: d, sliceDim0: f, isSimpleSlice: h, begin: m.begin, end: m.end, strides: m.strides };
}
-function zW(r, e) {
+function uW(r, e) {
e.beginMask = 0, e.endMask = 0, e.shrinkAxisMask = 0;
- let t10 = 0;
+ let t6 = 0;
e.beginValid = r.begin != null, e.endValid = r.end != null, e.begin = new Array(e.dims), e.end = new Array(e.dims), e.strides = new Array(e.dims), e.finalShapeGatherIndices = [], e.finalShapeGatherIndicesSparse = [], e.inputShapeGatherIndicesSparse = new Array(e.dims);
for (let o = 0; o < r.dims; o++)
if (1 << o & r.ellipsisMask) {
let n = Math.min(e.dims - (r.dims - o) + 1 + r.numAddAxisAfterEllipsis, e.dims);
- for (; t10 < n; t10++)
- e.begin[t10] = 0, e.end[t10] = 0, e.strides[t10] = 1, e.beginMask |= 1 << t10, e.endMask |= 1 << t10, e.finalShapeGatherIndices.push(t10), e.finalShapeGatherIndicesSparse.push(-1), e.inputShapeGatherIndicesSparse[t10] = o;
+ for (; t6 < n; t6++)
+ e.begin[t6] = 0, e.end[t6] = 0, e.strides[t6] = 1, e.beginMask |= 1 << t6, e.endMask |= 1 << t6, e.finalShapeGatherIndices.push(t6), e.finalShapeGatherIndicesSparse.push(-1), e.inputShapeGatherIndicesSparse[t6] = o;
} else if (1 << o & r.newAxisMask)
- e.finalShapeGatherIndices.push(iC), e.finalShapeGatherIndicesSparse.push(-1);
+ e.finalShapeGatherIndices.push(rC), e.finalShapeGatherIndicesSparse.push(-1);
else {
- if (t10 === e.begin.length)
- throw Error(`Index out of range using input dim ${t10}; input has only ${e.dims} dims, ${e.begin.length}.`);
- r.begin != null && (e.begin[t10] = r.begin[o]), r.end != null && (e.end[t10] = r.end[o]), e.strides[t10] = r.strides[o], r.beginMask & 1 << o && (e.beginMask |= 1 << t10), r.endMask & 1 << o && (e.endMask |= 1 << t10), r.shrinkAxisMask & 1 << o ? (e.finalShapeGatherIndices.push(AW), e.finalShapeGatherIndicesSparse.push(-1), e.shrinkAxisMask |= 1 << t10) : (e.finalShapeGatherIndices.push(t10), e.finalShapeGatherIndicesSparse.push(o)), e.inputShapeGatherIndicesSparse[t10] = o, t10++;
+ if (t6 === e.begin.length)
+ throw Error(`Index out of range using input dim ${t6}; input has only ${e.dims} dims, ${e.begin.length}.`);
+ r.begin != null && (e.begin[t6] = r.begin[o]), r.end != null && (e.end[t6] = r.end[o]), e.strides[t6] = r.strides[o], r.beginMask & 1 << o && (e.beginMask |= 1 << t6), r.endMask & 1 << o && (e.endMask |= 1 << t6), r.shrinkAxisMask & 1 << o ? (e.finalShapeGatherIndices.push(Jz), e.finalShapeGatherIndicesSparse.push(-1), e.shrinkAxisMask |= 1 << t6) : (e.finalShapeGatherIndices.push(t6), e.finalShapeGatherIndicesSparse.push(o)), e.inputShapeGatherIndicesSparse[t6] = o, t6++;
}
}
-function Tv(r, e, t10, o, n, s) {
+function e0(r, e, t6, o, n, s) {
if (n[e])
- return t10 > 0 ? s[e] : s[e + 1 & 1];
+ return t6 > 0 ? s[e] : s[e + 1 & 1];
{
let a = r < 0 ? o + r : r;
return a < s[0] ? s[0] : a > s[1] ? s[1] : a;
}
}
-var Pv = {};
-Be(Pv, { Serializable: () => ll, SerializationMap: () => Ps, registerClass: () => $r });
-var ll = class {
+var p0 = {};
+Ue(p0, { Serializable: () => ol, SerializationMap: () => Bs, registerClass: () => Er });
+var ol = class {
getClassName() {
return this.constructor.className;
}
- static fromConfig(e, t10) {
- return new e(t10);
+ static fromConfig(e, t6) {
+ return new e(t6);
}
};
-var Ps = class {
+var Bs = class {
constructor() {
this.classNameMap = {};
}
static getMap() {
- return Ps.instance == null && (Ps.instance = new Ps()), Ps.instance;
+ return Bs.instance == null && (Bs.instance = new Bs()), Bs.instance;
}
static register(e) {
- Ps.getMap().classNameMap[e.className] = [e, e.fromConfig];
+ Bs.getMap().classNameMap[e.className] = [e, e.fromConfig];
}
};
-function $r(r) {
- $(r.className != null, () => "Class being registered does not have the static className property defined."), $(typeof r.className == "string", () => "className is required to be a string, but got type " + typeof r.className), $(r.className.length > 0, () => "Class being registered has an empty-string as its className, which is disallowed."), Ps.register(r);
+function Er(r) {
+ E(r.className != null, () => "Class being registered does not have the static className property defined."), E(typeof r.className == "string", () => "className is required to be a string, but got type " + typeof r.className), E(r.className.length > 0, () => "Class being registered has an empty-string as its className, which is disallowed."), Bs.register(r);
}
-var Bv = {};
-Be(Bv, { TEST_EPSILON_FLOAT16: () => Ov, createVideoElement: () => jW, encodeStrings: () => Lv, expectArrayBuffersEqual: () => KW, expectArraysClose: () => UW, expectArraysEqual: () => HW, expectNumbersClose: () => Mv, expectPromiseToFail: () => GW, expectValuesInRange: () => qW, play: () => XW, testEpsilon: () => pf });
-var WW = 1e-3;
-var Ov = 0.1;
-function UW(r, e, t10) {
- return t10 == null && (t10 = pf()), uC(r, e, (o, n) => pC(o, n, t10));
+var d0 = {};
+Ue(d0, { TEST_EPSILON_FLOAT16: () => c0, createVideoElement: () => hW, encodeStrings: () => m0, expectArrayBuffersEqual: () => fW, expectArraysClose: () => cW, expectArraysEqual: () => mW, expectNumbersClose: () => l0, expectPromiseToFail: () => lW, expectValuesInRange: () => dW, play: () => gW, testEpsilon: () => Zm });
+var pW = 1e-3;
+var c0 = 0.1;
+function cW(r, e, t6) {
+ return t6 == null && (t6 = Zm()), oC(r, e, (o, n) => nC(o, n, t6));
}
-function pf() {
- return N.backend.floatPrecision() === 32 ? WW : Ov;
+function Zm() {
+ return T.backend.floatPrecision() === 32 ? pW : c0;
}
-function uC(r, e, t10) {
+function oC(r, e, t6) {
let o = true;
- if ((Ut(r) || Ut(e)) && (o = false), Ut(r) && Ut(e) && (o = true), o) {
+ if ((Wt(r) || Wt(e)) && (o = false), Wt(r) && Wt(e) && (o = true), o) {
let a = r.constructor.name, i = e.constructor.name;
if (a !== i)
throw new Error(`Arrays are of different type. Actual: ${a}. Expected: ${i}`);
}
if (Array.isArray(r) && Array.isArray(e)) {
let a = or(r), i = or(e);
- if (!Or(a, i))
+ if (!Pr(a, i))
throw new Error(`Arrays have different shapes. Actual: [${a}]. Expected: [${i}]`);
}
- let n = Ut(r) ? r : on(r), s = Ut(e) ? e : on(e);
+ let n = Wt(r) ? r : Oo(r), s = Wt(e) ? e : Oo(e);
if (n.length !== s.length)
throw new Error(`Arrays have different lengths actual: ${n.length} vs expected: ${s.length}.
Actual: ${n}.
Expected: ${s}.`);
for (let a = 0; a < s.length; ++a) {
let i = n[a], p = s[a];
- if (!t10(i, p))
+ if (!t6(i, p))
throw new Error(`Arrays differ: actual[${a}] = ${i}, expected[${a}] = ${p}.
Actual: ${n}.
Expected: ${s}.`);
}
typeof expect != "undefined" && expect().nothing();
}
-function GW(r, e) {
+function lW(r, e) {
r().then(() => e.fail(), () => e()), typeof expect != "undefined" && expect().nothing();
}
-function HW(r, e) {
- let t10 = typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? [e] : e;
- return nn(r) || nn(r[0]) || nn(e) || nn(e[0]) ? uC(r, t10, (o, n) => o == n) : uC(r, e, (o, n) => pC(o, n, 0));
+function mW(r, e) {
+ let t6 = typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? [e] : e;
+ return Po(r) || Po(r[0]) || Po(e) || Po(e[0]) ? oC(r, t6, (o, n) => o == n) : oC(r, e, (o, n) => nC(o, n, 0));
}
-function Mv(r, e, t10) {
- if (t10 == null && (t10 = pf()), !pC(r, e, t10))
+function l0(r, e, t6) {
+ if (t6 == null && (t6 = Zm()), !nC(r, e, t6))
throw new Error(`Numbers differ: actual === ${r}, expected === ${e}`);
typeof expect != "undefined" && expect().nothing();
}
-function pC(r, e, t10) {
- return !isFinite(r) && !isFinite(e) ? true : !(isNaN(r) || isNaN(e) || Math.abs(r - e) > t10);
+function nC(r, e, t6) {
+ return !isFinite(r) && !isFinite(e) ? true : !(isNaN(r) || isNaN(e) || Math.abs(r - e) > t6);
}
-function qW(r, e, t10) {
+function dW(r, e, t6) {
for (let o = 0; o < r.length; o++)
- if (r[o] < e || r[o] > t10)
- throw new Error(`Value out of range:${r[o]} low: ${e}, high: ${t10}`);
+ if (r[o] < e || r[o] > t6)
+ throw new Error(`Value out of range:${r[o]} low: ${e}, high: ${t6}`);
}
-function KW(r, e) {
- let t10 = new Float32Array(r), o = new Float32Array(e);
- if (t10.length !== o.length)
- throw new Error(`Expected ArrayBuffer to be of length ${o.length}, but it was ${t10.length}`);
+function fW(r, e) {
+ let t6 = new Float32Array(r), o = new Float32Array(e);
+ if (t6.length !== o.length)
+ throw new Error(`Expected ArrayBuffer to be of length ${o.length}, but it was ${t6.length}`);
for (let n = 0; n < o.length; n++)
- if (t10[n] !== o[n])
- throw new Error(`Expected ArrayBuffer value at ${n} to be ${o[n]} but got ${t10[n]} instead`);
+ if (t6[n] !== o[n])
+ throw new Error(`Expected ArrayBuffer value at ${n} to be ${o[n]} but got ${t6[n]} instead`);
}
-function Lv(r) {
+function m0(r) {
for (let e = 0; e < r.length; e++) {
- let t10 = r[e];
- Array.isArray(t10) ? Lv(t10) : r[e] = si(t10);
+ let t6 = r[e];
+ Array.isArray(t6) ? m0(t6) : r[e] = gi(t6);
}
return r;
}
-function jW(r) {
+function hW(r) {
let e = document.createElement("video");
- return "playsInline" in e && (e.playsInline = true), e.muted = true, e.loop = true, e.style.position = "fixed", e.style.left = "0px", e.style.top = "0px", e.preload = "auto", e.appendChild(r), new Promise((t10) => {
- e.addEventListener("loadeddata", (o) => t10(e)), e.load();
+ return "playsInline" in e && (e.playsInline = true), e.muted = true, e.loop = true, e.style.position = "fixed", e.style.left = "0px", e.style.top = "0px", e.preload = "auto", e.appendChild(r), new Promise((t6) => {
+ e.addEventListener("loadeddata", (o) => t6(e)), e.load();
});
}
-async function XW(r) {
+async function gW(r) {
await r.play(), "requestVideoFrameCallback" in r && await new Promise((e) => {
r.requestVideoFrameCallback(e);
});
}
-var YW = "4.0.0";
-function QW(r, e) {
- let t10 = v(r, "a", "add"), o = v(e, "b", "add");
- [t10, o] = Re(t10, o);
- let n = { a: t10, b: o };
- return N.runKernel(_r, n);
+var xW = "4.1.0";
+function yW(r, e) {
+ let t6 = v(r, "a", "add"), o = v(e, "b", "add");
+ [t6, o] = Re(t6, o);
+ let n = { a: t6, b: o };
+ return T.runKernel(eo, n);
}
-var ge = T({ add_: QW });
-function ZW(r, e) {
- let t10 = v(r, "a", "floorDiv"), o = v(e, "b", "floorDiv");
- [t10, o] = Re(t10, o);
- let n = { a: t10, b: o };
- return N.runKernel(vn, n);
+var xe = N({ add_: yW });
+function bW(r, e) {
+ let t6 = v(r, "a", "floorDiv"), o = v(e, "b", "floorDiv");
+ [t6, o] = Re(t6, o);
+ let n = { a: t6, b: o };
+ return T.runKernel(sn, n);
}
-var cf = T({ floorDiv_: ZW });
-function JW(r, e) {
- let t10 = v(r, "a", "div"), o = v(e, "b", "div");
- if ([t10, o] = Re(t10, o), t10.dtype === "int32" && o.dtype === "int32")
- return cf(t10, o);
- let n = { a: t10, b: o }, s = {};
- return N.runKernel(Cn, n, s);
+var Jm = N({ floorDiv_: bW });
+function CW(r, e) {
+ let t6 = v(r, "a", "div"), o = v(e, "b", "div");
+ if ([t6, o] = Re(t6, o), t6.dtype === "int32" && o.dtype === "int32")
+ return Jm(t6, o);
+ let n = { a: t6, b: o }, s = {};
+ return T.runKernel(Jo, n, s);
}
-var We = T({ div_: JW });
-function eU(r, e) {
- let t10 = v(r, "a", "mul"), o = v(e, "b", "mul");
- [t10, o] = Re(t10, o);
- let n = { a: t10, b: o };
- return N.runKernel(ho, n);
+var Ge = N({ div_: CW });
+function SW(r, e) {
+ let t6 = v(r, "a", "mul"), o = v(e, "b", "mul");
+ [t6, o] = Re(t6, o);
+ let n = { a: t6, b: o };
+ return T.runKernel(kn, n);
}
-var oe = T({ mul_: eU });
-function tU(r) {
+var ae = N({ mul_: SW });
+function wW(r) {
let e = v(r, "x", "abs");
if (e.dtype === "complex64") {
- let t10 = { x: e };
- return N.runKernel(cp, t10);
+ let t6 = { x: e };
+ return T.runKernel(pp, t6);
} else {
- let t10 = { x: e };
- return N.runKernel(sn, t10);
+ let t6 = { x: e };
+ return T.runKernel(gs, t6);
}
}
-var Qt = T({ abs_: tU });
-function rU(r) {
- let t10 = { x: v(r, "x", "acos") };
- return N.runKernel(Li, t10);
+var Yt = N({ abs_: wW });
+function IW(r) {
+ let t6 = { x: v(r, "x", "acos") };
+ return T.runKernel(sa, t6);
}
-var Vv = T({ acos_: rU });
-function oU(r) {
- let t10 = { x: v(r, "x", "acosh") };
- return N.runKernel(Bi, t10);
+var f0 = N({ acos_: IW });
+function vW(r) {
+ let t6 = { x: v(r, "x", "acosh") };
+ return T.runKernel(aa, t6);
}
-var zv = T({ acosh_: oU });
-function nU(r) {
- $(Array.isArray(r), () => "The argument passed to tf.addN() must be a list of tensors"), $(r.length >= 1, () => `Must pass at least one tensor to tf.addN(), but got ${r.length}`);
- let e = r.map((n, s) => v(n, `tensors${s}`, "addN")), t10 = e[0];
+var h0 = N({ acosh_: vW });
+function kW(r) {
+ E(Array.isArray(r), () => "The argument passed to tf.addN() must be a list of tensors"), E(r.length >= 1, () => `Must pass at least one tensor to tf.addN(), but got ${r.length}`);
+ let e = r.map((n, s) => v(n, `tensors${s}`, "addN")), t6 = e[0];
e.forEach((n) => {
- if (n.dtype !== t10.dtype)
+ if (n.dtype !== t6.dtype)
throw new Error("All tensors passed to tf.addN() must have the same dtype");
}), e.forEach((n) => {
- if (!Or(n.shape, t10.shape))
+ if (!Pr(n.shape, t6.shape))
throw new Error("All tensors passed to tf.addN() must have the same shape");
});
let o = e;
- return N.runKernel(an, o);
+ return T.runKernel(Mo, o);
}
-var Wv = T({ addN_: nU });
-function sU(r, e = null, t10 = false) {
- let n = { x: v(r, "x", "all", "bool") }, s = { axis: e, keepDims: t10 };
- return N.runKernel(oa, n, s);
+var g0 = N({ addN_: kW });
+function NW(r, e = null, t6 = false) {
+ let n = { x: v(r, "x", "all", "bool") }, s = { axis: e, keepDims: t6 };
+ return T.runKernel(Lo, n, s);
}
-var Uv = T({ all_: sU });
-function aU(r, e = null, t10 = false) {
- let n = { x: v(r, "x", "any", "bool") }, s = { axis: e, keepDims: t10 };
- return N.runKernel(na, n, s);
+var x0 = N({ all_: NW });
+function TW(r, e = null, t6 = false) {
+ let n = { x: v(r, "x", "any", "bool") }, s = { axis: e, keepDims: t6 };
+ return T.runKernel(Bo, n, s);
}
-var Gv = T({ any_: aU });
-function iU(r, e = 0) {
+var y0 = N({ any_: TW });
+function _W(r, e = 0) {
let o = { x: v(r, "x", "argMax") }, n = { axis: e };
- return N.runKernel(un, o, n);
+ return T.runKernel(Vo, o, n);
}
-var Hv = T({ argMax_: iU });
-function uU(r, e = 0) {
+var b0 = N({ argMax_: _W });
+function EW(r, e = 0) {
let o = { x: v(r, "x", "argMin") }, n = { axis: e };
- return N.runKernel(ja, o, n);
+ return T.runKernel(Za, o, n);
}
-var qv = T({ argMin_: uU });
-function pU(r) {
- let t10 = { x: v(r, "x", "asin") };
- return N.runKernel(Vi, t10);
+var C0 = N({ argMin_: EW });
+function $W(r) {
+ let t6 = { x: v(r, "x", "asin") };
+ return T.runKernel(ia, t6);
}
-var Kv = T({ asin_: pU });
-function cU(r) {
- let t10 = { x: v(r, "x", "asinh") };
- return N.runKernel(zi, t10);
+var S0 = N({ asin_: $W });
+function AW(r) {
+ let t6 = { x: v(r, "x", "asinh") };
+ return T.runKernel(ua, t6);
}
-var jv = T({ asinh_: cU });
-function lU(r) {
- let t10 = { x: v(r, "x", "atan") };
- return N.runKernel(Wi, t10);
+var w0 = N({ asinh_: AW });
+function RW(r) {
+ let t6 = { x: v(r, "x", "atan") };
+ return T.runKernel(pa, t6);
}
-var Xv = T({ atan_: lU });
-function mU(r, e) {
- let t10 = v(r, "a", "atan2"), o = v(e, "b", "atan2");
- [t10, o] = Re(t10, o);
- let n = { a: t10, b: o };
- return N.runKernel(sa, n);
+var I0 = N({ atan_: RW });
+function FW(r, e) {
+ let t6 = v(r, "a", "atan2"), o = v(e, "b", "atan2");
+ [t6, o] = Re(t6, o);
+ let n = { a: t6, b: o };
+ return T.runKernel(la, n);
}
-var Yv = T({ atan2_: mU });
-function fU(r) {
- let t10 = { x: v(r, "x", "atanh") };
- return N.runKernel(Ui, t10);
+var v0 = N({ atan2_: FW });
+function DW(r) {
+ let t6 = { x: v(r, "x", "atanh") };
+ return T.runKernel(ca, t6);
}
-var Qv = T({ atanh_: fU });
-function dU(r, e, t10, o, n = "NHWC", s) {
- let a = r[3], i = [...e, a], p = Jv(n);
- return uu(r, i, t10, s, o, null, null, p);
+var k0 = N({ atanh_: DW });
+function OW(r, e, t6, o, n = "NHWC", s) {
+ let a = r[3], i = [...e, a], p = T0(n);
+ return uu(r, i, t6, s, o, null, null, p);
}
-function lC(r, e, t10, o, n, s, a = "channelsLast") {
- let [i, p] = lf(e), u;
+function aC(r, e, t6, o, n, s, a = "channelsLast") {
+ let [i, p] = ed(e), u;
if (a === "channelsLast")
u = [i, p, r[3], r[3]];
else if (a === "channelsFirst")
u = [i, p, r[1], r[1]];
else
throw new Error(`Unknown dataFormat ${a}`);
- return uu(r, u, t10, o, n, s, false, a);
+ return uu(r, u, t6, o, n, s, false, a);
}
-function hU(r, e, t10, o, n, s, a = "NDHWC") {
- let [i, p, u] = cC(e), c, l;
+function PW(r, e, t6, o, n, s, a = "NDHWC") {
+ let [i, p, u] = sC(e), c, l;
if (a === "NDHWC")
l = "channelsLast", c = [i, p, u, r[4], r[4]];
else if (a === "NCDHW")
l = "channelsFirst", c = [i, p, u, r[1], r[1]];
else
throw new Error(`Unknown dataFormat ${a}`);
- return Zv(r, c, t10, o, n, false, l, s);
+ return N0(r, c, t6, o, n, false, l, s);
}
-function uu(r, e, t10, o, n, s, a = false, i = "channelsLast") {
+function uu(r, e, t6, o, n, s, a = false, i = "channelsLast") {
let [p, u, c, l] = [-1, -1, -1, -1];
if (i === "channelsLast")
[p, u, c, l] = r;
@@ -6332,10 +6339,10 @@ function uu(r, e, t10, o, n, s, a = false, i = "channelsLast") {
[p, l, u, c] = r;
else
throw new Error(`Unknown dataFormat ${i}`);
- let [m, f, , d] = e, [h, g] = lf(t10), [y, b] = lf(o), C = Up(m, y), w = Up(f, b), { padInfo: k, outHeight: _, outWidth: E } = yU(n, u, c, h, g, C, w, s, i), R = a ? d * l : d, A;
- return i === "channelsFirst" ? A = [p, R, _, E] : i === "channelsLast" && (A = [p, _, E, R]), { batchSize: p, dataFormat: i, inHeight: u, inWidth: c, inChannels: l, outHeight: _, outWidth: E, outChannels: R, padInfo: k, strideHeight: h, strideWidth: g, filterHeight: m, filterWidth: f, effectiveFilterHeight: C, effectiveFilterWidth: w, dilationHeight: y, dilationWidth: b, inShape: r, outShape: A, filterShape: e };
+ let [m, d, , f] = e, [h, g] = ed(t6), [x, b] = ed(o), C = Lp(m, x), w = Lp(d, b), { padInfo: k, outHeight: _, outWidth: $ } = BW(n, u, c, h, g, C, w, s, i), A = a ? f * l : f, R;
+ return i === "channelsFirst" ? R = [p, A, _, $] : i === "channelsLast" && (R = [p, _, $, A]), { batchSize: p, dataFormat: i, inHeight: u, inWidth: c, inChannels: l, outHeight: _, outWidth: $, outChannels: A, padInfo: k, strideHeight: h, strideWidth: g, filterHeight: m, filterWidth: d, effectiveFilterHeight: C, effectiveFilterWidth: w, dilationHeight: x, dilationWidth: b, inShape: r, outShape: R, filterShape: e };
}
-function Zv(r, e, t10, o, n, s = false, a = "channelsLast", i) {
+function N0(r, e, t6, o, n, s = false, a = "channelsLast", i) {
let [p, u, c, l, m] = [-1, -1, -1, -1, -1];
if (a === "channelsLast")
[p, u, c, l, m] = r;
@@ -6343,66 +6350,66 @@ function Zv(r, e, t10, o, n, s = false, a = "channelsLast", i) {
[p, m, u, c, l] = r;
else
throw new Error(`Unknown dataFormat ${a}`);
- let [f, d, h, , g] = e, [y, b, C] = cC(t10), [w, k, _] = cC(o), E = Up(f, w), R = Up(d, k), A = Up(h, _), { padInfo: D, outDepth: O, outHeight: M, outWidth: L } = bU(n, u, c, l, y, b, C, E, R, A, i), W = s ? g * m : g, V;
- return a === "channelsFirst" ? V = [p, W, O, M, L] : a === "channelsLast" && (V = [p, O, M, L, W]), { batchSize: p, dataFormat: a, inDepth: u, inHeight: c, inWidth: l, inChannels: m, outDepth: O, outHeight: M, outWidth: L, outChannels: W, padInfo: D, strideDepth: y, strideHeight: b, strideWidth: C, filterDepth: f, filterHeight: d, filterWidth: h, effectiveFilterDepth: E, effectiveFilterHeight: R, effectiveFilterWidth: A, dilationDepth: w, dilationHeight: k, dilationWidth: _, inShape: r, outShape: V, filterShape: e };
+ let [d, f, h, , g] = e, [x, b, C] = sC(t6), [w, k, _] = sC(o), $ = Lp(d, w), A = Lp(f, k), R = Lp(h, _), { padInfo: D, outDepth: P, outHeight: M, outWidth: L } = VW(n, u, c, l, x, b, C, $, A, R, i), W = s ? g * m : g, V;
+ return a === "channelsFirst" ? V = [p, W, P, M, L] : a === "channelsLast" && (V = [p, P, M, L, W]), { batchSize: p, dataFormat: a, inDepth: u, inHeight: c, inWidth: l, inChannels: m, outDepth: P, outHeight: M, outWidth: L, outChannels: W, padInfo: D, strideDepth: x, strideHeight: b, strideWidth: C, filterDepth: d, filterHeight: f, filterWidth: h, effectiveFilterDepth: $, effectiveFilterHeight: A, effectiveFilterWidth: R, dilationDepth: w, dilationHeight: k, dilationWidth: _, inShape: r, outShape: V, filterShape: e };
}
-function gU(r, e, t10, o, n) {
- o == null && (o = mC(r, e, t10));
- let s = r[0], a = r[1], i = au((s - e + 2 * o) / t10 + 1, n), p = au((a - e + 2 * o) / t10 + 1, n);
+function MW(r, e, t6, o, n) {
+ o == null && (o = iC(r, e, t6));
+ let s = r[0], a = r[1], i = au((s - e + 2 * o) / t6 + 1, n), p = au((a - e + 2 * o) / t6 + 1, n);
return [i, p];
}
-function xU(r, e, t10, o, n, s) {
- n == null && (n = mC(r, e, o));
+function LW(r, e, t6, o, n, s) {
+ n == null && (n = iC(r, e, o));
let a = r[0], i = r[1], p = r[2], u = au((a - e + 2 * n) / o + 1, s), c = au((i - e + 2 * n) / o + 1, s), l = au((p - e + 2 * n) / o + 1, s);
- return [u, c, l, t10];
+ return [u, c, l, t6];
}
-function mC(r, e, t10, o = 1) {
- let n = Up(e, o);
- return Math.floor((r[0] * (t10 - 1) - t10 + n) / 2);
+function iC(r, e, t6, o = 1) {
+ let n = Lp(e, o);
+ return Math.floor((r[0] * (t6 - 1) - t6 + n) / 2);
}
-function lf(r) {
+function ed(r) {
return typeof r == "number" ? [r, r, r] : r.length === 2 ? [r[0], r[1], 1] : r;
}
-function cC(r) {
+function sC(r) {
return typeof r == "number" ? [r, r, r] : r;
}
-function Up(r, e) {
+function Lp(r, e) {
return e <= 1 ? r : r + (r - 1) * (e - 1);
}
-function yU(r, e, t10, o, n, s, a, i, p) {
+function BW(r, e, t6, o, n, s, a, i, p) {
let u, c, l;
if (typeof r == "number") {
u = { top: r, bottom: r, left: r, right: r, type: r === 0 ? "VALID" : "NUMBER" };
- let f = gU([e, t10], s, o, r, i);
- c = f[0], l = f[1];
+ let d = MW([e, t6], s, o, r, i);
+ c = d[0], l = d[1];
} else if (r === "same") {
- c = Math.ceil(e / o), l = Math.ceil(t10 / n);
- let m = Math.max(0, (c - 1) * o + s - e), f = Math.max(0, (l - 1) * n + a - t10), d = Math.floor(m / 2), h = m - d, g = Math.floor(f / 2), y = f - g;
- u = { top: d, bottom: h, left: g, right: y, type: "SAME" };
+ c = Math.ceil(e / o), l = Math.ceil(t6 / n);
+ let m = Math.max(0, (c - 1) * o + s - e), d = Math.max(0, (l - 1) * n + a - t6), f = Math.floor(m / 2), h = m - f, g = Math.floor(d / 2), x = d - g;
+ u = { top: f, bottom: h, left: g, right: x, type: "SAME" };
} else if (r === "valid")
- u = { top: 0, bottom: 0, left: 0, right: 0, type: "VALID" }, c = Math.ceil((e - s + 1) / o), l = Math.ceil((t10 - a + 1) / n);
+ u = { top: 0, bottom: 0, left: 0, right: 0, type: "VALID" }, c = Math.ceil((e - s + 1) / o), l = Math.ceil((t6 - a + 1) / n);
else if (typeof r == "object") {
- let m = p === "channelsLast" ? r[1][0] : r[2][0], f = p === "channelsLast" ? r[1][1] : r[2][1], d = p === "channelsLast" ? r[2][0] : r[3][0], h = p === "channelsLast" ? r[2][1] : r[3][1];
- u = { top: m, bottom: f, left: d, right: h, type: m === 0 && f === 0 && d === 0 && h === 0 ? "VALID" : "EXPLICIT" }, c = au((e - s + m + f) / o + 1, i), l = au((t10 - a + d + h) / n + 1, i);
+ let m = p === "channelsLast" ? r[1][0] : r[2][0], d = p === "channelsLast" ? r[1][1] : r[2][1], f = p === "channelsLast" ? r[2][0] : r[3][0], h = p === "channelsLast" ? r[2][1] : r[3][1];
+ u = { top: m, bottom: d, left: f, right: h, type: m === 0 && d === 0 && f === 0 && h === 0 ? "VALID" : "EXPLICIT" }, c = au((e - s + m + d) / o + 1, i), l = au((t6 - a + f + h) / n + 1, i);
} else
throw Error(`Unknown padding parameter: ${r}`);
return { padInfo: u, outHeight: c, outWidth: l };
}
-function bU(r, e, t10, o, n, s, a, i, p, u, c) {
- let l, m, f, d;
+function VW(r, e, t6, o, n, s, a, i, p, u, c) {
+ let l, m, d, f;
if (typeof r == "number") {
l = { top: r, bottom: r, left: r, right: r, front: r, back: r, type: r === 0 ? "VALID" : "NUMBER" };
- let g = xU([e, t10, o, 1], i, 1, n, r, c);
- m = g[0], f = g[1], d = g[2];
+ let g = LW([e, t6, o, 1], i, 1, n, r, c);
+ m = g[0], d = g[1], f = g[2];
} else if (r === "same") {
- m = Math.ceil(e / n), f = Math.ceil(t10 / s), d = Math.ceil(o / a);
- let h = (m - 1) * n + i - e, g = (f - 1) * s + p - t10, y = (d - 1) * a + u - o, b = Math.floor(h / 2), C = h - b, w = Math.floor(g / 2), k = g - w, _ = Math.floor(y / 2), E = y - _;
- l = { top: w, bottom: k, left: _, right: E, front: b, back: C, type: "SAME" };
+ m = Math.ceil(e / n), d = Math.ceil(t6 / s), f = Math.ceil(o / a);
+ let h = (m - 1) * n + i - e, g = (d - 1) * s + p - t6, x = (f - 1) * a + u - o, b = Math.floor(h / 2), C = h - b, w = Math.floor(g / 2), k = g - w, _ = Math.floor(x / 2), $ = x - _;
+ l = { top: w, bottom: k, left: _, right: $, front: b, back: C, type: "SAME" };
} else if (r === "valid")
- l = { top: 0, bottom: 0, left: 0, right: 0, front: 0, back: 0, type: "VALID" }, m = Math.ceil((e - i + 1) / n), f = Math.ceil((t10 - p + 1) / s), d = Math.ceil((o - u + 1) / a);
+ l = { top: 0, bottom: 0, left: 0, right: 0, front: 0, back: 0, type: "VALID" }, m = Math.ceil((e - i + 1) / n), d = Math.ceil((t6 - p + 1) / s), f = Math.ceil((o - u + 1) / a);
else
throw Error(`Unknown padding parameter: ${r}`);
- return { padInfo: l, outDepth: m, outHeight: f, outWidth: d };
+ return { padInfo: l, outDepth: m, outHeight: d, outWidth: f };
}
function au(r, e) {
if (!e)
@@ -6419,868 +6426,867 @@ function au(r, e) {
}
}
function iu(r) {
- let [e, t10, o] = lf(r);
- return e === 1 && t10 === 1 && o === 1;
+ let [e, t6, o] = ed(r);
+ return e === 1 && t6 === 1 && o === 1;
}
function lr(r, e) {
return iu(r) || iu(e);
}
-function Jv(r) {
+function T0(r) {
if (r === "NHWC")
return "channelsLast";
if (r === "NCHW")
return "channelsFirst";
throw new Error(`Unknown dataFormat ${r}`);
}
-function Ot(r, e, t10) {
- if (t10 != null) {
+function Pt(r, e, t6) {
+ if (t6 != null) {
if (typeof e == "string")
- throw Error(`Error in ${r}: pad must be an integer when using dimRoundingMode ${t10} but got pad ${e}.`);
+ throw Error(`Error in ${r}: pad must be an integer when using dimRoundingMode ${t6} but got pad ${e}.`);
if (typeof e == "number")
- $(ra(e), () => `Error in ${r}: pad must be an integer when using dimRoundingMode ${t10} but got pad ${e}.`);
+ E(na(e), () => `Error in ${r}: pad must be an integer when using dimRoundingMode ${t6} but got pad ${e}.`);
else if (typeof e == "object")
e.forEach((o) => {
o.forEach((n) => {
- $(ra(n), () => `Error in ${r}: pad must be an integer when using dimRoundingMode ${t10} but got pad ${n}.`);
+ E(na(n), () => `Error in ${r}: pad must be an integer when using dimRoundingMode ${t6} but got pad ${n}.`);
});
});
else
throw Error(`Error in ${r}: Unknown padding parameter: ${e}`);
}
}
-function CU(r, e) {
+function zW(r, e) {
let o = { x: v(r, "x", "reshape", "string_or_numeric") }, n = { shape: e };
- return N.runKernel(Ss, o, n);
+ return T.runKernel(Ns, o, n);
}
-var z = T({ reshape_: CU });
-function IU(r, e, t10, o, n) {
+var z = N({ reshape_: zW });
+function WW(r, e, t6, o, n) {
let s = v(r, "x", "avgPool", "float32"), a = 1;
- $(lr(t10, a), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${t10} and dilations '${a}'`);
+ E(lr(t6, a), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${t6} and dilations '${a}'`);
let i = s, p = false;
- s.rank === 3 && (p = true, i = z(s, [1, s.shape[0], s.shape[1], s.shape[2]])), $(i.rank === 4, () => `Error in avgPool: x must be rank 4 but got rank ${i.rank}.`), Ot("avgPool", o, n);
- let u = { x: i }, c = { filterSize: e, strides: t10, pad: o, dimRoundingMode: n }, l = N.runKernel(pn, u, c);
- return l = qe(l, s.dtype), p ? z(l, [l.shape[1], l.shape[2], l.shape[3]]) : l;
+ s.rank === 3 && (p = true, i = z(s, [1, s.shape[0], s.shape[1], s.shape[2]])), E(i.rank === 4, () => `Error in avgPool: x must be rank 4 but got rank ${i.rank}.`), Pt("avgPool", o, n);
+ let u = { x: i }, c = { filterSize: e, strides: t6, pad: o, dimRoundingMode: n }, l = T.runKernel(zo, u, c);
+ return l = Ke(l, s.dtype), p ? z(l, [l.shape[1], l.shape[2], l.shape[3]]) : l;
}
-var mf = T({ avgPool_: IU });
-function wU(r, e, t10, o, n, s = "NDHWC") {
+var td = N({ avgPool_: WW });
+function UW(r, e, t6, o, n, s = "NDHWC") {
let a = v(r, "x", "avgPool3d", "float32"), i = a, p = false;
- a.rank === 4 && (p = true, i = z(a, [1, a.shape[0], a.shape[1], a.shape[2], a.shape[3]])), $(i.rank === 5, () => `Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`), $(s === "NDHWC", () => `Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`), Ot("avgPool3d", o, n);
- let u = { x: i }, c = { filterSize: e, strides: t10, pad: o, dimRoundingMode: n, dataFormat: s }, l = N.runKernel(ip, u, c);
- return l = qe(l, i.dtype), p ? z(l, [l.shape[1], l.shape[2], l.shape[3], l.shape[4]]) : l;
+ a.rank === 4 && (p = true, i = z(a, [1, a.shape[0], a.shape[1], a.shape[2], a.shape[3]])), E(i.rank === 5, () => `Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`), E(s === "NDHWC", () => `Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`), Pt("avgPool3d", o, n);
+ let u = { x: i }, c = { filterSize: e, strides: t6, pad: o, dimRoundingMode: n, dataFormat: s }, l = T.runKernel(ip, u, c);
+ return l = Ke(l, i.dtype), p ? z(l, [l.shape[1], l.shape[2], l.shape[3], l.shape[4]]) : l;
}
-var ek = T({ avgPool3d_: wU });
-function SU(r, e = 0) {
- $(r.length >= 1, () => "Pass at least one tensor to concat");
- let t10 = Ia(r, "tensors", "concat", "string_or_numeric");
- if (t10[0].dtype === "complex64" && t10.forEach((s) => {
+var _0 = N({ avgPool3d_: UW });
+function GW(r, e = 0) {
+ E(r.length >= 1, () => "Pass at least one tensor to concat");
+ let t6 = Na(r, "tensors", "concat", "string_or_numeric");
+ if (t6[0].dtype === "complex64" && t6.forEach((s) => {
if (s.dtype !== "complex64")
throw new Error(`Cannot concatenate complex64 tensors with a tensor
with dtype ${s.dtype}. `);
- }), t10.length === 1)
- return zr(t10[0]);
- let o = t10, n = { axis: e };
- return N.runKernel(gs, o, n);
+ }), t6.length === 1)
+ return Br(t6[0]);
+ let o = t6, n = { axis: e };
+ return T.runKernel(ys, o, n);
}
-var gt = T({ concat_: SU });
-function vU(r) {
- let t10 = { x: v(r, "x", "sigmoid", "float32") };
- return N.runKernel(yo, t10);
+var gt = N({ concat_: GW });
+function HW(r) {
+ let t6 = { x: v(r, "x", "sigmoid", "float32") };
+ return T.runKernel(Un, t6);
}
-var Ms = T({ sigmoid_: vU });
-function kU(r, e, t10) {
+var zs = N({ sigmoid_: HW });
+function qW(r, e, t6) {
let o = v(r, "x", "slice", "string_or_numeric");
if (o.rank === 0)
throw new Error("Slicing scalar is not possible");
- let n = { x: o }, s = { begin: e, size: t10 };
- return N.runKernel(qn, n, s);
+ let n = { x: o }, s = { begin: e, size: t6 };
+ return T.runKernel(_s, n, s);
}
-var Ue = T({ slice_: kU });
-function TU(r) {
- let t10 = { x: v(r, "x", "tanh", "float32") };
- return N.runKernel(Qn, t10);
+var He = N({ slice_: qW });
+function KW(r) {
+ let t6 = { x: v(r, "x", "tanh", "float32") };
+ return T.runKernel(Qn, t6);
}
-var ml = T({ tanh_: TU });
-function NU(r, e, t10, o, n, s) {
- let a = v(r, "forgetBias", "basicLSTMCell"), i = v(e, "lstmKernel", "basicLSTMCell"), p = v(t10, "lstmBias", "basicLSTMCell"), u = v(o, "data", "basicLSTMCell"), c = v(n, "c", "basicLSTMCell"), l = v(s, "h", "basicLSTMCell"), m = gt([u, l], 1), f = Xe(m, i), d = ge(f, p), h = d.shape[0], g = d.shape[1] / 4, y = [h, g], b = Ue(d, [0, 0], y), C = Ue(d, [0, g], y), w = Ue(d, [0, g * 2], y), k = Ue(d, [0, g * 3], y), _ = ge(oe(Ms(b), ml(C)), oe(c, Ms(ge(a, w)))), E = oe(ml(_), Ms(k));
- return [_, E];
+var nl = N({ tanh_: KW });
+function jW(r, e, t6, o, n, s) {
+ let a = v(r, "forgetBias", "basicLSTMCell"), i = v(e, "lstmKernel", "basicLSTMCell"), p = v(t6, "lstmBias", "basicLSTMCell"), u = v(o, "data", "basicLSTMCell"), c = v(n, "c", "basicLSTMCell"), l = v(s, "h", "basicLSTMCell"), m = gt([u, l], 1), d = Xe(m, i), f = xe(d, p), h = f.shape[0], g = f.shape[1] / 4, x = [h, g], b = He(f, [0, 0], x), C = He(f, [0, g], x), w = He(f, [0, g * 2], x), k = He(f, [0, g * 3], x), _ = xe(ae(zs(b), nl(C)), ae(c, zs(xe(a, w)))), $ = ae(nl(_), zs(k));
+ return [_, $];
}
-var tk = T({ basicLSTMCell_: NU });
-function _U(r, e, t10) {
+var E0 = N({ basicLSTMCell_: jW });
+function XW(r, e, t6) {
let o = v(r, "x", "batchToSpaceND"), n = e.reduce((i, p) => i * p);
- $(o.rank >= 1 + e.length, () => `input rank is ${o.rank} but should be > than blockShape.length ${e.length}`), $(t10.length === e.length, () => `crops.length is ${t10.length} but should be equal to blockShape.length ${e.length}`), $(o.shape[0] % n === 0, () => `input tensor batch is ${o.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${n}`);
- let s = { x: o }, a = { blockShape: e, crops: t10 };
- return N.runKernel(hs, s, a);
+ E(o.rank >= 1 + e.length, () => `input rank is ${o.rank} but should be > than blockShape.length ${e.length}`), E(t6.length === e.length, () => `crops.length is ${t6.length} but should be equal to blockShape.length ${e.length}`), E(o.shape[0] % n === 0, () => `input tensor batch is ${o.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${n}`);
+ let s = { x: o }, a = { blockShape: e, crops: t6 };
+ return T.runKernel(xs, s, a);
}
-var ff = T({ batchToSpaceND_: _U });
-function rk(r) {
+var rd = N({ batchToSpaceND_: XW });
+function $0(r) {
let e;
return r.rank === 0 || r.rank === 1 ? e = z(r, [1, 1, 1, r.size]) : r.rank === 2 ? e = z(r, [1, 1, r.shape[0], r.shape[1]]) : r.rank === 3 ? e = z(r, [1, r.shape[0], r.shape[1], r.shape[2]]) : e = r, e;
}
-function EU(r, e, t10, o, n, s) {
+function YW(r, e, t6, o, n, s) {
s == null && (s = 1e-3);
- let a = v(r, "x", "batchNorm"), i = v(e, "mean", "batchNorm"), p = v(t10, "variance", "batchNorm"), u;
+ let a = v(r, "x", "batchNorm"), i = v(e, "mean", "batchNorm"), p = v(t6, "variance", "batchNorm"), u;
n != null && (u = v(n, "scale", "batchNorm"));
let c;
- o != null && (c = v(o, "offset", "batchNorm")), $(i.rank === p.rank, () => "Batch normalization gradient requires mean and variance to have equal ranks."), $(c == null || i.rank === c.rank, () => "Batch normalization gradient requires mean and offset to have equal ranks."), $(u == null || i.rank === u.rank, () => "Batch normalization gradient requires mean and scale to have equal ranks.");
- let m = { x: rk(a), scale: u, offset: c, mean: i, variance: p }, f = { varianceEpsilon: s }, d = N.runKernel(kn, m, f);
- return z(d, a.shape);
+ o != null && (c = v(o, "offset", "batchNorm")), E(i.rank === p.rank, () => "Batch normalization gradient requires mean and variance to have equal ranks."), E(c == null || i.rank === c.rank, () => "Batch normalization gradient requires mean and offset to have equal ranks."), E(u == null || i.rank === u.rank, () => "Batch normalization gradient requires mean and scale to have equal ranks.");
+ let m = { x: $0(a), scale: u, offset: c, mean: i, variance: p }, d = { varianceEpsilon: s }, f = T.runKernel(an, m, d);
+ return z(f, a.shape);
}
-var li = T({ batchNorm_: EU });
-function $U(r, e, t10, o, n, s) {
- let a = v(r, "x", "batchNorm"), i = v(e, "mean", "batchNorm"), p = v(t10, "variance", "batchNorm"), u;
+var wi = N({ batchNorm_: YW });
+function QW(r, e, t6, o, n, s) {
+ let a = v(r, "x", "batchNorm"), i = v(e, "mean", "batchNorm"), p = v(t6, "variance", "batchNorm"), u;
n != null && (u = v(n, "scale", "batchNorm"));
let c;
- return o != null && (c = v(o, "offset", "batchNorm")), $(a.rank === 2, () => `Error in batchNorm2D: x must be rank 2 but got rank ${a.rank}.`), $(i.rank === 2 || i.rank === 1, () => `Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`), $(p.rank === 2 || p.rank === 1, () => `Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${p.rank}.`), u != null && $(u.rank === 2 || u.rank === 1, () => `Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${u.rank}.`), c != null && $(c.rank === 2 || c.rank === 1, () => `Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`), li(a, i, p, c, u, s);
+ return o != null && (c = v(o, "offset", "batchNorm")), E(a.rank === 2, () => `Error in batchNorm2D: x must be rank 2 but got rank ${a.rank}.`), E(i.rank === 2 || i.rank === 1, () => `Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`), E(p.rank === 2 || p.rank === 1, () => `Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${p.rank}.`), u != null && E(u.rank === 2 || u.rank === 1, () => `Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${u.rank}.`), c != null && E(c.rank === 2 || c.rank === 1, () => `Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`), wi(a, i, p, c, u, s);
}
-var ok = T({ batchNorm2d_: $U });
-function RU(r, e, t10, o, n, s) {
- let a = v(r, "x", "batchNorm"), i = v(e, "mean", "batchNorm"), p = v(t10, "variance", "batchNorm"), u;
+var A0 = N({ batchNorm2d_: QW });
+function ZW(r, e, t6, o, n, s) {
+ let a = v(r, "x", "batchNorm"), i = v(e, "mean", "batchNorm"), p = v(t6, "variance", "batchNorm"), u;
n != null && (u = v(n, "scale", "batchNorm"));
let c;
- return o != null && (c = v(o, "offset", "batchNorm")), $(a.rank === 3, () => `Error in batchNorm3D: x must be rank 3 but got rank ${a.rank}.`), $(i.rank === 3 || i.rank === 1, () => `Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`), $(p.rank === 3 || p.rank === 1, () => `Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${p.rank}.`), u != null && $(u.rank === 3 || u.rank === 1, () => `Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${u.rank}.`), c != null && $(c.rank === 3 || c.rank === 1, () => `Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`), li(a, i, p, c, u, s);
+ return o != null && (c = v(o, "offset", "batchNorm")), E(a.rank === 3, () => `Error in batchNorm3D: x must be rank 3 but got rank ${a.rank}.`), E(i.rank === 3 || i.rank === 1, () => `Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`), E(p.rank === 3 || p.rank === 1, () => `Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${p.rank}.`), u != null && E(u.rank === 3 || u.rank === 1, () => `Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${u.rank}.`), c != null && E(c.rank === 3 || c.rank === 1, () => `Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`), wi(a, i, p, c, u, s);
}
-var nk = T({ batchNorm3d_: RU });
-function AU(r, e, t10, o, n, s) {
- let a = v(r, "x", "batchNorm"), i = v(e, "mean", "batchNorm"), p = v(t10, "variance", "batchNorm"), u;
+var R0 = N({ batchNorm3d_: ZW });
+function JW(r, e, t6, o, n, s) {
+ let a = v(r, "x", "batchNorm"), i = v(e, "mean", "batchNorm"), p = v(t6, "variance", "batchNorm"), u;
n != null && (u = v(n, "scale", "batchNorm"));
let c;
- return o != null && (c = v(o, "offset", "batchNorm")), $(a.rank === 4, () => `Error in batchNorm4D: x must be rank 4 but got rank ${a.rank}.`), $(i.rank === 4 || i.rank === 1, () => `Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`), $(p.rank === 4 || p.rank === 1, () => `Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${p.rank}.`), u != null && $(u.rank === 4 || u.rank === 1, () => `Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${u.rank}.`), c != null && $(c.rank === 4 || c.rank === 1, () => `Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`), li(a, i, p, c, u, s);
+ return o != null && (c = v(o, "offset", "batchNorm")), E(a.rank === 4, () => `Error in batchNorm4D: x must be rank 4 but got rank ${a.rank}.`), E(i.rank === 4 || i.rank === 1, () => `Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`), E(p.rank === 4 || p.rank === 1, () => `Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${p.rank}.`), u != null && E(u.rank === 4 || u.rank === 1, () => `Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${u.rank}.`), c != null && E(c.rank === 4 || c.rank === 1, () => `Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`), wi(a, i, p, c, u, s);
}
-var sk = T({ batchNorm4d_: AU });
-function FU(r, e, t10) {
+var F0 = N({ batchNorm4d_: JW });
+function eU(r, e, t6) {
let o = v(r, "x", "bincount"), n = v(e, "weights", "bincount");
- $(o.dtype === "int32", () => `Error in bincount: input dtype must be int32, but got ${o.dtype}`), $(t10 >= 0, () => `size must be non-negative, but got ${t10}.`), $(n.size === o.size || n.size === 0, () => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${o.shape}, weights shape: ${n.shape}.`);
- let s = { x: o, weights: n }, a = { size: t10 };
- return N.runKernel(up, s, a);
+ E(o.dtype === "int32", () => `Error in bincount: input dtype must be int32, but got ${o.dtype}`), E(t6 >= 0, () => `size must be non-negative, but got ${t6}.`), E(n.size === o.size || n.size === 0, () => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${o.shape}, weights shape: ${n.shape}.`);
+ let s = { x: o, weights: n }, a = { size: t6 };
+ return T.runKernel(Ja, s, a);
}
-var df = T({ bincount_: FU });
-function DU(r, e) {
- let t10 = v(r, "s0", "broadcastArgs", "int32"), o = v(e, "s1", "broadcastArgs", "int32");
- if (t10.rank !== 1)
- throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${t10.rank}`);
+var od = N({ bincount_: eU });
+function tU(r, e) {
+ let t6 = v(r, "s0", "broadcastArgs", "int32"), o = v(e, "s1", "broadcastArgs", "int32");
+ if (t6.rank !== 1)
+ throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${t6.rank}`);
if (o.rank !== 1)
throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${o.rank}`);
- let n = { s0: t10, s1: o };
- return N.runKernel(pp, n);
+ let n = { s0: t6, s1: o };
+ return T.runKernel(up, n);
}
-var ak = T({ broadcastArgs_: DU });
-function PU(r, e) {
- let t10 = v(r, "broadcastTo", "x"), o = t10.shape;
- if (e.some((u) => !(u > 0) || u % 1 !== 0))
- throw new Error(`broadcastTo(): Invalid broadcast shape [${e}].`);
- if (e.length < t10.rank)
- throw new Error(`broadcastTo(): shape.length=${e.length} < input.rank=${t10.rank}.`);
- if (e.length > t10.rank) {
- let u = t10.shape.slice();
+var D0 = N({ broadcastArgs_: tU });
+function rU(r, e) {
+ let t6 = v(r, "broadcastTo", "x"), o = t6.shape;
+ if (yt(e), e.length < t6.rank)
+ throw new Error(`broadcastTo(): shape.length=${e.length} < input.rank=${t6.rank}.`);
+ if (e.length > t6.rank) {
+ let u = t6.shape.slice();
for (; u.length < e.length; )
u.unshift(1);
- t10 = z(t10, u);
+ t6 = z(t6, u);
}
- let n = t10.shape, s = Array.from(e);
+ let n = t6.shape, s = Array.from(e);
for (let u = e.length - 1; u >= 0; u--)
if (n[u] === e[u])
s[u] = 1;
- else if (t10.shape[u] !== 1)
+ else if (t6.shape[u] !== 1)
throw new Error(`broadcastTo(): [${o}] cannot be broadcast to [${e}].`);
if (s.map((u, c) => u > 1 ? c : -1).filter((u) => u >= 0).length === 0)
- return zr(t10);
- let i = { x: t10 }, p = { reps: s };
- return N.runKernel(wo, i, p);
+ return Br(t6);
+ let i = { x: t6 }, p = { reps: s };
+ return T.runKernel(to, i, p);
}
-var Ls = T({ broadcastTo_: PU });
-function OU(r) {
- let t10 = { x: v(r, "x", "ceil", "float32") };
- return N.runKernel(ro, t10);
+var Ii = N({ broadcastTo_: rU });
+function oU(r) {
+ let t6 = { x: v(r, "x", "ceil", "float32") };
+ return T.runKernel(Uo, t6);
}
-var ik = T({ ceil_: OU });
-function Bs(r, e, t10) {
- let o = { shape: r, value: e, dtype: t10 };
- return N.runKernel(ys, {}, o);
+var O0 = N({ ceil_: oU });
+function Ws(r, e, t6) {
+ yt(r);
+ let o = { shape: r, value: e, dtype: t6 };
+ return T.runKernel(Cs, {}, o);
}
-function MU(r, e, t10) {
+function nU(r, e, t6) {
let o = v(r, "x", "clipByValue");
- if ($(e <= t10, () => `Error in clip: min (${e}) must be less than or equal to max (${t10}).`), e === t10)
- return Bs(o.shape, e, o.dtype);
- let n = { x: o }, s = { clipValueMin: e, clipValueMax: t10 };
- return N.runKernel(Ro, n, s);
+ if (E(e <= t6, () => `Error in clip: min (${e}) must be less than or equal to max (${t6}).`), e === t6)
+ return Ws(o.shape, e, o.dtype);
+ let n = { x: o }, s = { clipValueMin: e, clipValueMax: t6 };
+ return T.runKernel(lo, n, s);
}
-var uk = T({ clipByValue_: MU });
-function LU(r) {
+var P0 = N({ clipByValue_: nU });
+function sU(r) {
return gt(r, 0);
}
-var pk = T({ concat1d_: LU });
-function BU(r, e) {
+var M0 = N({ concat1d_: sU });
+function aU(r, e) {
return gt(r, e);
}
-var ck = T({ concat2d_: BU });
-function VU(r, e) {
+var L0 = N({ concat2d_: aU });
+function iU(r, e) {
return gt(r, e);
}
-var lk = T({ concat3d_: VU });
-function zU(r, e) {
+var B0 = N({ concat3d_: iU });
+function uU(r, e) {
return gt(r, e);
}
-var mk = T({ concat4d_: zU });
-function WU(r, e, t10, o, n = "NHWC", s = [1, 1], a) {
+var V0 = N({ concat4d_: uU });
+function pU(r, e, t6, o, n = "NHWC", s = [1, 1], a) {
let i = v(r, "x", "conv2d", "float32"), p = v(e, "filter", "conv2d", "float32"), u = i, c = false;
- i.rank === 3 && (c = true, u = z(i, [1, i.shape[0], i.shape[1], i.shape[2]])), $(u.rank === 4, () => `Error in conv2d: input must be rank 4, but got rank ${u.rank}.`), $(p.rank === 4, () => `Error in conv2d: filter must be rank 4, but got rank ${p.rank}.`), Ot("conv2d", o, a);
+ i.rank === 3 && (c = true, u = z(i, [1, i.shape[0], i.shape[1], i.shape[2]])), E(u.rank === 4, () => `Error in conv2d: input must be rank 4, but got rank ${u.rank}.`), E(p.rank === 4, () => `Error in conv2d: filter must be rank 4, but got rank ${p.rank}.`), Pt("conv2d", o, a);
let l = n === "NHWC" ? u.shape[3] : u.shape[1];
- $(l === p.shape[2], () => `Error in conv2d: depth of input (${l}) must match input depth for filter ${p.shape[2]}.`), $(lr(t10, s), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${t10} and dilations '${s}'`);
- let m = { x: u, filter: p }, f = { strides: t10, pad: o, dataFormat: n, dilations: s, dimRoundingMode: a }, d = N.runKernel(ln, m, f);
- return c ? z(d, [d.shape[1], d.shape[2], d.shape[3]]) : d;
+ E(l === p.shape[2], () => `Error in conv2d: depth of input (${l}) must match input depth for filter ${p.shape[2]}.`), E(lr(t6, s), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${t6} and dilations '${s}'`);
+ let m = { x: u, filter: p }, d = { strides: t6, pad: o, dataFormat: n, dilations: s, dimRoundingMode: a }, f = T.runKernel(Go, m, d);
+ return c ? z(f, [f.shape[1], f.shape[2], f.shape[3]]) : f;
}
-var mi = T({ conv2d_: WU });
-function UU(r, e, t10, o, n = "NWC", s = 1, a) {
+var vi = N({ conv2d_: pU });
+function cU(r, e, t6, o, n = "NWC", s = 1, a) {
let i = v(r, "x", "conv1d"), p = v(e, "filter", "conv1d"), u = i, c = false;
- i.rank === 2 && (c = true, u = z(i, [1, i.shape[0], i.shape[1]])), $(u.rank === 3, () => `Error in conv1d: input must be rank 3, but got rank ${u.rank}.`), $(p.rank === 3, () => `Error in conv1d: filter must be rank 3, but got rank ${p.rank}.`), Ot("conv1d", o, a), $(u.shape[2] === p.shape[1], () => `Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${p.shape[1]}.`), $(lr(t10, s), () => `Error in conv1D: Either stride or dilation must be 1. Got stride ${t10} and dilation '${s}'`), $(n === "NWC", () => `Error in conv1d: got dataFormat of ${n} but only NWC is currently supported.`);
- let l = z(p, [1, p.shape[0], p.shape[1], p.shape[2]]), m = z(u, [u.shape[0], 1, u.shape[1], u.shape[2]]), g = mi(m, l, [1, t10], o, "NHWC", [1, s], a);
+ i.rank === 2 && (c = true, u = z(i, [1, i.shape[0], i.shape[1]])), E(u.rank === 3, () => `Error in conv1d: input must be rank 3, but got rank ${u.rank}.`), E(p.rank === 3, () => `Error in conv1d: filter must be rank 3, but got rank ${p.rank}.`), Pt("conv1d", o, a), E(u.shape[2] === p.shape[1], () => `Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${p.shape[1]}.`), E(lr(t6, s), () => `Error in conv1D: Either stride or dilation must be 1. Got stride ${t6} and dilation '${s}'`), E(n === "NWC", () => `Error in conv1d: got dataFormat of ${n} but only NWC is currently supported.`);
+ let l = z(p, [1, p.shape[0], p.shape[1], p.shape[2]]), m = z(u, [u.shape[0], 1, u.shape[1], u.shape[2]]), g = vi(m, l, [1, t6], o, "NHWC", [1, s], a);
return c ? z(g, [g.shape[2], g.shape[3]]) : z(g, [g.shape[0], g.shape[2], g.shape[3]]);
}
-var fk = T({ conv1d_: UU });
-function GU(r, e, t10, o, n, s = "NHWC", a) {
- $(r.length === e.rank, () => `Length of inShape (${r.length}) and rank of dy (${e.rank}) must match`);
+var z0 = N({ conv1d_: cU });
+function lU(r, e, t6, o, n, s = "NHWC", a) {
+ E(r.length === e.rank, () => `Length of inShape (${r.length}) and rank of dy (${e.rank}) must match`);
let i = r, p = e, u = false;
- e.rank === 3 && (u = true, p = z(e, [1, e.shape[0], e.shape[1], e.shape[2]]), i = [1, r[0], r[1], r[2]]), $(i.length === 4, () => `Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`), $(p.rank === 4, () => `Error in conv2dDerInput: dy must be rank 4, but got rank ${p.rank}`), $(t10.rank === 4, () => `Error in conv2dDerInput: filter must be rank 4, but got rank ${t10.rank}`);
+ e.rank === 3 && (u = true, p = z(e, [1, e.shape[0], e.shape[1], e.shape[2]]), i = [1, r[0], r[1], r[2]]), E(i.length === 4, () => `Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`), E(p.rank === 4, () => `Error in conv2dDerInput: dy must be rank 4, but got rank ${p.rank}`), E(t6.rank === 4, () => `Error in conv2dDerInput: filter must be rank 4, but got rank ${t6.rank}`);
let c = s === "NHWC" ? i[3] : i[1], l = s === "NHWC" ? p.shape[3] : p.shape[1];
- $(c === t10.shape[2], () => `Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${t10.shape[2]}.`), $(l === t10.shape[3], () => `Error in conv2dDerInput: depth of output (${l}) must match output depth for filter ${t10.shape[3]}.`), Ot("conv2dDerInput", n, a);
- let m = { dy: p, filter: t10 }, f = { strides: o, pad: n, dataFormat: s, dimRoundingMode: a, inputShape: i }, d = N.runKernel(mn, m, f);
- return u ? z(d, [d.shape[1], d.shape[2], d.shape[3]]) : d;
+ E(c === t6.shape[2], () => `Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${t6.shape[2]}.`), E(l === t6.shape[3], () => `Error in conv2dDerInput: depth of output (${l}) must match output depth for filter ${t6.shape[3]}.`), Pt("conv2dDerInput", n, a);
+ let m = { dy: p, filter: t6 }, d = { strides: o, pad: n, dataFormat: s, dimRoundingMode: a, inputShape: i }, f = T.runKernel(Ho, m, d);
+ return u ? z(f, [f.shape[1], f.shape[2], f.shape[3]]) : f;
}
-var hf = T({ conv2DBackpropInput_: GU });
-function HU(r, e, t10, o, n, s) {
+var nd = N({ conv2DBackpropInput_: lU });
+function mU(r, e, t6, o, n, s) {
let a = v(r, "x", "conv2dTranspose"), i = v(e, "filter", "conv2dTranspose");
- return hf(t10, a, i, o, n, "NHWC", s);
+ return nd(t6, a, i, o, n, "NHWC", s);
}
-var dk = T({ conv2dTranspose_: HU });
-function qU(r, e, t10, o, n = "NDHWC", s = [1, 1, 1]) {
+var W0 = N({ conv2dTranspose_: mU });
+function dU(r, e, t6, o, n = "NDHWC", s = [1, 1, 1]) {
let a = v(r, "x", "conv3d"), i = v(e, "filter", "conv3d"), p = a, u = false;
- a.rank === 4 && (u = true, p = z(a, [1, a.shape[0], a.shape[1], a.shape[2], a.shape[3]])), $(p.rank === 5, () => `Error in conv3d: input must be rank 5, but got rank ${p.rank}.`), $(i.rank === 5, () => `Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`), $(p.shape[4] === i.shape[3], () => `Error in conv3d: depth of input (${p.shape[4]}) must match input depth for filter ${i.shape[3]}.`), $(lr(t10, s), () => `Error in conv3D: Either strides or dilations must be 1. Got strides ${t10} and dilations '${s}'`), $(n === "NDHWC", () => `Error in conv3d: got dataFormat of ${n} but only NDHWC is currently supported.`);
- let c = { x: p, filter: i }, l = { strides: t10, pad: o, dataFormat: n, dilations: s }, m = N.runKernel(mp, c, l);
+ a.rank === 4 && (u = true, p = z(a, [1, a.shape[0], a.shape[1], a.shape[2], a.shape[3]])), E(p.rank === 5, () => `Error in conv3d: input must be rank 5, but got rank ${p.rank}.`), E(i.rank === 5, () => `Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`), E(p.shape[4] === i.shape[3], () => `Error in conv3d: depth of input (${p.shape[4]}) must match input depth for filter ${i.shape[3]}.`), E(lr(t6, s), () => `Error in conv3D: Either strides or dilations must be 1. Got strides ${t6} and dilations '${s}'`), E(n === "NDHWC", () => `Error in conv3d: got dataFormat of ${n} but only NDHWC is currently supported.`);
+ let c = { x: p, filter: i }, l = { strides: t6, pad: o, dataFormat: n, dilations: s }, m = T.runKernel(lp, c, l);
return u ? z(m, [m.shape[1], m.shape[2], m.shape[3], m.shape[4]]) : m;
}
-var hk = T({ conv3d_: qU });
-function KU(r, e, t10, o, n) {
- $(r.length === e.rank, () => `Length of inShape (${r.length}) and rank of dy (${e.rank}) must match`);
+var U0 = N({ conv3d_: dU });
+function fU(r, e, t6, o, n) {
+ E(r.length === e.rank, () => `Length of inShape (${r.length}) and rank of dy (${e.rank}) must match`);
let s = r, a = e, i = false;
e.rank === 4 && (i = true, a = z(e, [1, e.shape[0], e.shape[1], e.shape[2], e.shape[3]]), s = [1, r[0], r[1], r[2], r[3]]);
let p = s[4], u = a.shape[4];
- $(s.length === 5, () => `Error in conv3dDerInput: inShape must be length 5, but got length ${s.length}.`), $(a.rank === 5, () => `Error in conv3dDerInput: dy must be rank 5, but got rank ${a.rank}`), $(t10.rank === 5, () => `Error in conv3dDerInput: filter must be rank 5, but got rank ${t10.rank}`), $(p === t10.shape[3], () => `Error in conv3dDerInput: depth of input (${p}) must match input depth for filter ${t10.shape[3]}.`), $(u === t10.shape[4], () => `Error in conv3dDerInput: depth of output (${u}) must match output depth for filter ${t10.shape[4]}.`);
- let c = { dy: a, filter: t10 }, l = { pad: n, strides: o, inputShape: s }, m = N.runKernel(fp, c, l);
+ E(s.length === 5, () => `Error in conv3dDerInput: inShape must be length 5, but got length ${s.length}.`), E(a.rank === 5, () => `Error in conv3dDerInput: dy must be rank 5, but got rank ${a.rank}`), E(t6.rank === 5, () => `Error in conv3dDerInput: filter must be rank 5, but got rank ${t6.rank}`), E(p === t6.shape[3], () => `Error in conv3dDerInput: depth of input (${p}) must match input depth for filter ${t6.shape[3]}.`), E(u === t6.shape[4], () => `Error in conv3dDerInput: depth of output (${u}) must match output depth for filter ${t6.shape[4]}.`);
+ let c = { dy: a, filter: t6 }, l = { pad: n, strides: o, inputShape: s }, m = T.runKernel(mp, c, l);
return i ? z(m, [m.shape[1], m.shape[2], m.shape[3], m.shape[4]]) : m;
}
-var gk = T({ conv3DBackpropInput_: KU });
-function jU(r, e, t10, o, n) {
+var G0 = N({ conv3DBackpropInput_: fU });
+function hU(r, e, t6, o, n) {
let s = v(r, "x", "conv3dTranspose"), a = v(e, "filter", "conv3dTranspose");
- return gk(t10, s, a, o, n);
+ return G0(t6, s, a, o, n);
}
-var xk = T({ conv3dTranspose_: jU });
-function XU(r) {
- let t10 = { x: v(r, "x", "cos", "float32") };
- return N.runKernel(fn, t10);
+var H0 = N({ conv3dTranspose_: hU });
+function gU(r) {
+ let t6 = { x: v(r, "x", "cos", "float32") };
+ return T.runKernel(qo, t6);
}
-var yk = T({ cos_: XU });
-function YU(r) {
- let t10 = { x: v(r, "x", "cosh", "float32") };
- return N.runKernel(dn, t10);
+var q0 = N({ cos_: gU });
+function xU(r) {
+ let t6 = { x: v(r, "x", "cosh", "float32") };
+ return T.runKernel(Ko, t6);
}
-var bk = T({ cosh_: YU });
-function QU(r, e = 0, t10 = false, o = false) {
- let s = { x: v(r, "x", "cumprod") }, a = { axis: e, exclusive: t10, reverse: o };
- return N.runKernel(hn, s, a);
+var K0 = N({ cosh_: xU });
+function yU(r, e = 0, t6 = false, o = false) {
+ let s = { x: v(r, "x", "cumprod") }, a = { axis: e, exclusive: t6, reverse: o };
+ return T.runKernel(jo, s, a);
}
-var Ck = T({ cumprod_: QU });
-function ZU(r, e = 0, t10 = false, o = false) {
- let s = { x: v(r, "x", "cumsum") }, a = { axis: e, exclusive: t10, reverse: o };
- return N.runKernel(gn, s, a);
+var j0 = N({ cumprod_: yU });
+function bU(r, e = 0, t6 = false, o = false) {
+ let s = { x: v(r, "x", "cumsum") }, a = { axis: e, exclusive: t6, reverse: o };
+ return T.runKernel(Xo, s, a);
}
-var Ik = T({ cumsum_: ZU });
-function JU(r, e, t10, o = false) {
+var X0 = N({ cumsum_: bU });
+function CU(r, e, t6, o = false) {
let n = v(r, "x", "denseBincount"), s = v(e, "weights", "denseBincount");
- $(n.dtype === "int32", () => `Error in denseBincount: input dtype must be int32, but got ${n.dtype}`), $(n.rank <= 2, () => `Error in denseBincount: input must be at most rank 2, but got rank ${n.rank}.`), $(t10 >= 0, () => `size must be non-negative, but got ${t10}.`), $(s.size === n.size || s.size === 0, () => `Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${n.shape}, weights shape: ${s.shape}.`);
- let a = { x: n, weights: s }, i = { size: t10, binaryOutput: o };
- return N.runKernel(dp, a, i);
+ E(n.dtype === "int32", () => `Error in denseBincount: input dtype must be int32, but got ${n.dtype}`), E(n.rank <= 2, () => `Error in denseBincount: input must be at most rank 2, but got rank ${n.rank}.`), E(t6 >= 0, () => `size must be non-negative, but got ${t6}.`), E(s.size === n.size || s.size === 0, () => `Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${n.shape}, weights shape: ${s.shape}.`);
+ let a = { x: n, weights: s }, i = { size: t6, binaryOutput: o };
+ return T.runKernel(ti, a, i);
}
-var wk = T({ denseBincount_: JU });
-function eG(r, e, t10 = "NHWC") {
- let o = v(r, "x", "depthToSpace", "float32"), n = t10 === "NHWC" ? o.shape[1] : o.shape[2], s = t10 === "NHWC" ? o.shape[2] : o.shape[3], a = t10 === "NHWC" ? o.shape[3] : o.shape[1];
- $(e > 1, () => `blockSize should be > 1 for depthToSpace, but was: ${e}`), $(n * e >= 0, () => `Negative dimension size caused by overflow when multiplying
+var Y0 = N({ denseBincount_: CU });
+function SU(r, e, t6 = "NHWC") {
+ let o = v(r, "x", "depthToSpace", "float32"), n = t6 === "NHWC" ? o.shape[1] : o.shape[2], s = t6 === "NHWC" ? o.shape[2] : o.shape[3], a = t6 === "NHWC" ? o.shape[3] : o.shape[1];
+ E(e > 1, () => `blockSize should be > 1 for depthToSpace, but was: ${e}`), E(n * e >= 0, () => `Negative dimension size caused by overflow when multiplying
${n} and ${e} for depthToSpace with input shape
- ${o.shape}`), $(s * e >= 0, () => `Negative dimension size caused by overflow when multiplying
+ ${o.shape}`), E(s * e >= 0, () => `Negative dimension size caused by overflow when multiplying
${s} and ${e} for depthToSpace with input shape
- ${o.shape}`), $(a % (e * e) === 0, () => `Dimension size must be evenly divisible by ${e * e} but is ${a} for depthToSpace with input shape ${o.shape}`);
- let i = { x: o }, p = { blockSize: e, dataFormat: t10 };
- return N.runKernel(yn, i, p);
+ ${o.shape}`), E(a % (e * e) === 0, () => `Dimension size must be evenly divisible by ${e * e} but is ${a} for depthToSpace with input shape ${o.shape}`);
+ let i = { x: o }, p = { blockSize: e, dataFormat: t6 };
+ return T.runKernel(Qo, i, p);
}
-var Sk = T({ depthToSpace_: eG });
-function tG(r, e, t10, o, n = "NHWC", s = [1, 1], a) {
+var Q0 = N({ depthToSpace_: SU });
+function wU(r, e, t6, o, n = "NHWC", s = [1, 1], a) {
let i = v(r, "x", "depthwiseConv2d", "float32"), p = v(e, "filter", "depthwiseConv2d", "float32"), u = i, c = false;
- i.rank === 3 && (c = true, u = z(i, [1, i.shape[0], i.shape[1], i.shape[2]])), $(u.rank === 4, () => `Error in depthwiseConv2d: input must be rank 4, but got rank ${u.rank}.`), $(p.rank === 4, () => `Error in depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`);
+ i.rank === 3 && (c = true, u = z(i, [1, i.shape[0], i.shape[1], i.shape[2]])), E(u.rank === 4, () => `Error in depthwiseConv2d: input must be rank 4, but got rank ${u.rank}.`), E(p.rank === 4, () => `Error in depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`);
let l = n === "NHWC" ? u.shape[3] : u.shape[1];
- $(l === p.shape[2], () => `Error in depthwiseConv2d: number of input channels (${l}) must match the inChannels dimension in filter ${p.shape[2]}.`), Ot("depthwiseConv2d", o, a);
- let m = { x: u, filter: p }, f = { strides: t10, pad: o, dataFormat: n, dilations: s, dimRoundingMode: a }, d = N.runKernel(bn, m, f);
- return c ? z(d, [d.shape[1], d.shape[2], d.shape[3]]) : d;
+ E(l === p.shape[2], () => `Error in depthwiseConv2d: number of input channels (${l}) must match the inChannels dimension in filter ${p.shape[2]}.`), Pt("depthwiseConv2d", o, a);
+ let m = { x: u, filter: p }, d = { strides: t6, pad: o, dataFormat: n, dilations: s, dimRoundingMode: a }, f = T.runKernel(Zo, m, d);
+ return c ? z(f, [f.shape[1], f.shape[2], f.shape[3]]) : f;
}
-var Gp = T({ depthwiseConv2d_: tG });
-function rG(r) {
- let t10 = { x: v(r, "x", "diag") };
- return N.runKernel(xp, t10);
+var Bp = N({ depthwiseConv2d_: wU });
+function IU(r) {
+ let t6 = { x: v(r, "x", "diag") };
+ return T.runKernel(hp, t6);
}
-var vk = T({ diag_: rG });
-function oG(r, e, t10, o, n = [1, 1], s = "NHWC") {
+var Z0 = N({ diag_: IU });
+function vU(r, e, t6, o, n = [1, 1], s = "NHWC") {
let a = v(r, "x", "dilation2d"), i = v(e, "filter", "dilation2d");
- $(a.rank === 3 || a.rank === 4, () => `Error in dilation2d: input must be rank 3 or 4, but got rank ${a.rank}.`), $(i.rank === 3, () => `Error in dilation2d: filter must be rank 3, but got rank ${i.rank}.`), $(s === "NHWC", () => `Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${s}`);
+ E(a.rank === 3 || a.rank === 4, () => `Error in dilation2d: input must be rank 3 or 4, but got rank ${a.rank}.`), E(i.rank === 3, () => `Error in dilation2d: filter must be rank 3, but got rank ${i.rank}.`), E(s === "NHWC", () => `Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${s}`);
let p = a, u = false;
a.rank === 3 && (p = z(a, [1, a.shape[0], a.shape[1], a.shape[2]]), u = true);
- let c = { x: p, filter: i }, l = { strides: t10, pad: o, dilations: n }, m = N.runKernel(yp, c, l);
+ let c = { x: p, filter: i }, l = { strides: t6, pad: o, dilations: n }, m = T.runKernel(gp, c, l);
return u ? z(m, [m.shape[1], m.shape[2], m.shape[3]]) : m;
}
-var kk = T({ dilation2d_: oG });
-function nG(r, e) {
- let t10 = v(r, "a", "equal", "string_or_numeric"), o = v(e, "b", "equal", "string_or_numeric");
- [t10, o] = Re(t10, o), Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(oo, n);
+var J0 = N({ dilation2d_: vU });
+function kU(r, e) {
+ let t6 = v(r, "a", "equal", "string_or_numeric"), o = v(e, "b", "equal", "string_or_numeric");
+ [t6, o] = Re(t6, o), Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(tn, n);
}
-var gf = T({ equal_: nG });
-function sG(r, e, t10) {
- let o = v(e, "a", "where"), n = v(t10, "b", "where"), s = v(r, "condition", "where", "bool"), a = Je(Je(s.shape, o.shape), n.shape), i = Ls(s, a), p = Ls(o, a), u = Ls(n, a), c = { condition: i, t: p, e: u };
- return N.runKernel(vs, c);
+var sd = N({ equal_: kU });
+function NU(r, e, t6) {
+ let o = v(e, "a", "where"), n = v(t6, "b", "where"), s = v(r, "condition", "where", "bool"), a = Je(Je(s.shape, o.shape), n.shape), i = Ii(s, a), p = Ii(o, a), u = Ii(n, a), c = { condition: i, t: p, e: u };
+ return T.runKernel(Ts, c);
}
-var os = T({ where_: sG });
-function aG(r) {
- let t10 = { x: v(r, "x", "zerosLike") };
- return N.runKernel(Es, t10);
+var os = N({ where_: NU });
+function TU(r) {
+ let t6 = { x: v(r, "x", "zerosLike") };
+ return T.runKernel(Fs, t6);
}
-var Gt = T({ zerosLike_: aG });
-function iG(r, e) {
- let t10 = v(r, "a", "div"), o = v(e, "b", "div");
- [t10, o] = Re(t10, o);
- let n = We(t10, o), s = Gt(n), a = gf(o, s);
+var Ut = N({ zerosLike_: TU });
+function _U(r, e) {
+ let t6 = v(r, "a", "div"), o = v(e, "b", "div");
+ [t6, o] = Re(t6, o);
+ let n = Ge(t6, o), s = Ut(n), a = sd(o, s);
return os(a, s, n);
}
-var Tk = T({ divNoNan_: iG });
-function uG(r, e) {
- let t10 = v(r, "t1", "dot"), o = v(e, "t2", "dot");
- $((t10.rank === 1 || t10.rank === 2) && (o.rank === 1 || o.rank === 2), () => `Error in dot: inputs must all be rank 1 or 2, but got ranks ${t10.rank} and ${o.rank}.`);
- let n = t10.rank === 1 ? t10.size : t10.shape[1], s = o.rank === 1 ? o.size : o.shape[0];
- if ($(n === s, () => `Error in dot: inner dimensions of inputs must match, but got ${n} and ${s}.`), t10.rank === 1 && o.rank === 1) {
- let a = z(t10, [1, -1]), i = z(o, [-1, 1]), p = Xe(a, i);
+var ek = N({ divNoNan_: _U });
+function EU(r, e) {
+ let t6 = v(r, "t1", "dot"), o = v(e, "t2", "dot");
+ E((t6.rank === 1 || t6.rank === 2) && (o.rank === 1 || o.rank === 2), () => `Error in dot: inputs must all be rank 1 or 2, but got ranks ${t6.rank} and ${o.rank}.`);
+ let n = t6.rank === 1 ? t6.size : t6.shape[1], s = o.rank === 1 ? o.size : o.shape[0];
+ if (E(n === s, () => `Error in dot: inner dimensions of inputs must match, but got ${n} and ${s}.`), t6.rank === 1 && o.rank === 1) {
+ let a = z(t6, [1, -1]), i = z(o, [-1, 1]), p = Xe(a, i);
return z(p, []);
- } else if (t10.rank === 1 && o.rank === 2) {
- let a = z(t10, [1, -1]), i = z(o, [o.shape[0], o.shape[1]]), p = Xe(a, i);
+ } else if (t6.rank === 1 && o.rank === 2) {
+ let a = z(t6, [1, -1]), i = z(o, [o.shape[0], o.shape[1]]), p = Xe(a, i);
return z(p, [p.size]);
- } else if (t10.rank === 2 && o.rank === 1) {
- let a = z(o, [-1, 1]), i = Xe(t10, a);
+ } else if (t6.rank === 2 && o.rank === 1) {
+ let a = z(o, [-1, 1]), i = Xe(t6, a);
return z(i, [i.size]);
} else {
let a = z(o, [o.shape[0], o.shape[1]]);
- return Xe(t10, a);
+ return Xe(t6, a);
}
}
-var Nk = T({ dot_: uG });
-function pG(r, ...e) {
- let t10 = e.map((n, s) => v(n, `tensors${s}`, "einsum")), o = { equation: r };
- return N.runKernel(Xa, t10, o);
+var tk = N({ dot_: EU });
+function $U(r, ...e) {
+ let t6 = e.map((n, s) => v(n, `tensors${s}`, "einsum")), o = { equation: r };
+ return T.runKernel(ri, t6, o);
}
-var _k = T({ einsum_: pG });
-function cG(r) {
- let t10 = { x: v(r, "x", "elu", "float32") };
- return N.runKernel(In, t10);
+var rk = N({ einsum_: $U });
+function AU(r) {
+ let t6 = { x: v(r, "x", "elu", "float32") };
+ return T.runKernel(en, t6);
}
-var xf = T({ elu_: cG });
-function lG(r) {
+var ad = N({ elu_: AU });
+function RU(r) {
let e = v(r, "x", "erf");
- $(e.dtype === "int32" || e.dtype === "float32", () => "Input dtype must be `int32` or `float32`."), e.dtype === "int32" && (e = qe(e, "float32"));
- let t10 = { x: e };
- return N.runKernel(Gi, t10);
+ E(e.dtype === "int32" || e.dtype === "float32", () => "Input dtype must be `int32` or `float32`."), e.dtype === "int32" && (e = Ke(e, "float32"));
+ let t6 = { x: e };
+ return T.runKernel(ma, t6);
}
-var Ek = T({ erf_: lG });
-function fC(r, e) {
- for (let t10 = 0; t10 < r.length; ++t10)
- if (r[r.length - t10 - 1] !== e - 1 - t10)
+var ok = N({ erf_: RU });
+function uC(r, e) {
+ for (let t6 = 0; t6 < r.length; ++t6)
+ if (r[r.length - t6 - 1] !== e - 1 - t6)
return false;
return true;
}
-function $k(r, e, t10) {
+function nk(r, e, t6) {
let o = r.length + e.length, n = [], s = 0, a = 0;
for (let i = 0; i < o; i++)
- t10.indexOf(i) === -1 ? n.push(r[s++]) : n.push(e[a++]);
+ t6.indexOf(i) === -1 ? n.push(r[s++]) : n.push(e[a++]);
return n;
}
-function mG(r, e) {
- let t10 = [], o = r.length;
+function FU(r, e) {
+ let t6 = [], o = r.length;
for (let s = 0; s < o; s++)
- e.indexOf(s) === -1 && t10.push(r[s]);
+ e.indexOf(s) === -1 && t6.push(r[s]);
let n = e.map((s) => r[s]);
- return [t10, n];
+ return [t6, n];
}
-function Ta(r, e) {
- let t10 = e.map((o) => 1);
- return $k(r, t10, e);
+function Aa(r, e) {
+ let t6 = e.map((o) => 1);
+ return nk(r, t6, e);
}
-function fG(r, e, t10) {
- $(fC(e, t10), () => `${r} supports only inner-most axes for now. Got axes ${e} and rank-${t10} input.`);
+function DU(r, e, t6) {
+ E(uC(e, t6), () => `${r} supports only inner-most axes for now. Got axes ${e} and rank-${t6} input.`);
}
-function dG(r, e) {
- if (fC(r, e))
+function OU(r, e) {
+ if (uC(r, e))
return null;
- let t10 = [];
+ let t6 = [];
for (let o = 0; o < e; ++o)
- r.indexOf(o) === -1 && t10.push(o);
- return r.forEach((o) => t10.push(o)), t10;
+ r.indexOf(o) === -1 && t6.push(o);
+ return r.forEach((o) => t6.push(o)), t6;
}
-function hG(r) {
- return r.map((e, t10) => [t10, e]).sort((e, t10) => e[1] - t10[1]).map((e) => e[0]);
+function PU(r) {
+ return r.map((e, t6) => [t6, e]).sort((e, t6) => e[1] - t6[1]).map((e) => e[0]);
}
-function gG(r, e) {
- let t10 = [];
+function MU(r, e) {
+ let t6 = [];
for (let o = e - r; o < e; ++o)
- t10.push(o);
- return t10;
+ t6.push(o);
+ return t6;
}
-function yG(r, e = null, t10 = false) {
- let n = { x: v(r, "x", "max") }, s = { reductionIndices: e, keepDims: t10 };
- return N.runKernel($n, n, s);
+function BU(r, e = null, t6 = false) {
+ let n = { x: v(r, "x", "max") }, s = { reductionIndices: e, keepDims: t6 };
+ return T.runKernel(yn, n, s);
}
-var Vs = T({ max_: yG });
-function bG(r, e = null, t10 = false) {
- let n = { x: v(r, "x", "min") }, s = { axis: e, keepDims: t10 };
- return N.runKernel(Fn, n, s);
+var Us = N({ max_: BU });
+function VU(r, e = null, t6 = false) {
+ let n = { x: v(r, "x", "min") }, s = { axis: e, keepDims: t6 };
+ return T.runKernel(wn, n, s);
}
-var fl = T({ min_: bG });
-function CG(r, e) {
- let t10 = v(r, "base", "pow"), o = v(e, "exp", "pow");
- [t10, o] = Re(t10, o);
- let n = { a: t10, b: o };
- return N.runKernel(Bn, n);
+var sl = N({ min_: VU });
+function zU(r, e) {
+ let t6 = v(r, "base", "pow"), o = v(e, "exp", "pow");
+ [t6, o] = Re(t6, o);
+ let n = { a: t6, b: o };
+ return T.runKernel(An, n);
}
-var Na = T({ pow_: CG });
+var Ra = N({ pow_: zU });
function be(r, e) {
- if ((Ut(r) && e !== "string" || Array.isArray(r)) && e !== "complex64")
+ if ((Wt(r) && e !== "string" || Array.isArray(r)) && e !== "complex64")
throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");
- if (e === "string" && Ut(r) && !(r instanceof Uint8Array))
+ if (e === "string" && Wt(r) && !(r instanceof Uint8Array))
throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");
return xr(r, [], [], e);
}
-function IG(r) {
- let t10 = { x: v(r, "x", "sqrt", "float32") };
- return N.runKernel(bo, t10);
+function WU(r) {
+ let t6 = { x: v(r, "x", "sqrt", "float32") };
+ return T.runKernel(Gn, t6);
}
-var Rr = T({ sqrt_: IG });
-function wG(r) {
- let e = v(r, "x", "square"), t10 = {};
- return N.runKernel("Square", { x: e }, t10);
+var $r = N({ sqrt_: WU });
+function UU(r) {
+ let e = v(r, "x", "square"), t6 = {};
+ return T.runKernel("Square", { x: e }, t6);
}
-var Zt = T({ square_: wG });
-function SG(r, e = null, t10 = false) {
+var Qt = N({ square_: UU });
+function GU(r, e = null, t6 = false) {
let o = v(r, "x", "sum");
- o.dtype === "bool" && (o = qe(o, "int32"));
- let n = { x: o }, s = { axis: e, keepDims: t10 };
- return N.runKernel(jn, n, s);
+ o.dtype === "bool" && (o = Ke(o, "int32"));
+ let n = { x: o }, s = { axis: e, keepDims: t6 };
+ return T.runKernel(Hn, n, s);
}
-var tt = T({ sum_: SG });
-function vG(r, e = "euclidean", t10 = null, o = false) {
+var et = N({ sum_: GU });
+function HU(r, e = "euclidean", t6 = null, o = false) {
r = v(r, "x", "norm");
- let n = Rk(r, e, t10), s = n.shape;
+ let n = sk(r, e, t6), s = n.shape;
if (o) {
- let a = Ka(t10, r.shape);
- s = Ta(n.shape, a);
+ let a = Qa(t6, r.shape);
+ s = Aa(n.shape, a);
}
return z(n, s);
}
-function Rk(r, e, t10 = null) {
+function sk(r, e, t6 = null) {
if (r.rank === 0)
- return Qt(r);
- if (r.rank !== 1 && t10 === null)
- return Rk(z(r, [-1]), e, t10);
- if (r.rank === 1 || typeof t10 == "number" || Array.isArray(t10) && t10.length === 1) {
+ return Yt(r);
+ if (r.rank !== 1 && t6 === null)
+ return sk(z(r, [-1]), e, t6);
+ if (r.rank === 1 || typeof t6 == "number" || Array.isArray(t6) && t6.length === 1) {
if (e === 1)
- return tt(Qt(r), t10);
+ return et(Yt(r), t6);
if (e === 1 / 0)
- return Vs(Qt(r), t10);
+ return Us(Yt(r), t6);
if (e === -1 / 0)
- return fl(Qt(r), t10);
+ return sl(Yt(r), t6);
if (e === "euclidean" || e === 2)
- return Rr(tt(Na(Qt(r), be(2, "int32")), t10));
+ return $r(et(Ra(Yt(r), be(2, "int32")), t6));
throw new Error(`Error in norm: invalid ord value: ${e}`);
}
- if (Array.isArray(t10) && t10.length === 2) {
+ if (Array.isArray(t6) && t6.length === 2) {
if (e === 1)
- return Vs(tt(Qt(r), t10[0]), t10[1] - 1);
+ return Us(et(Yt(r), t6[0]), t6[1] - 1);
if (e === 1 / 0)
- return Vs(tt(Qt(r), t10[1]), t10[0]);
+ return Us(et(Yt(r), t6[1]), t6[0]);
if (e === -1 / 0)
- return fl(tt(Qt(r), t10[1]), t10[0]);
+ return sl(et(Yt(r), t6[1]), t6[0]);
if (e === "fro" || e === "euclidean")
- return Rr(tt(Zt(r), t10));
+ return $r(et(Qt(r), t6));
throw new Error(`Error in norm: invalid ord value: ${e}`);
}
- throw new Error(`Error in norm: invalid axis: ${t10}`);
+ throw new Error(`Error in norm: invalid axis: ${t6}`);
}
-var pu = T({ norm_: vG });
-function kG(r, e = null, t10 = false) {
- return pu(r, "euclidean", e, t10);
+var pu = N({ norm_: HU });
+function qU(r, e = null, t6 = false) {
+ return pu(r, "euclidean", e, t6);
}
-var Ak = T({ euclideanNorm_: kG });
-function TG(r) {
- let t10 = { x: v(r, "x", "exp") };
- return N.runKernel(no, t10);
+var ak = N({ euclideanNorm_: qU });
+function KU(r) {
+ let t6 = { x: v(r, "x", "exp") };
+ return T.runKernel(rn, t6);
}
-var Bo = T({ exp_: TG });
-function NG(r, e = 0) {
- let t10 = v(r, "x", "expandDims", "string_or_numeric");
- $(e <= t10.rank, () => "Axis must be <= rank of the tensor");
- let o = { input: t10 }, n = { dim: e };
- return N.runKernel(xs, o, n);
+var Co = N({ exp_: KU });
+function jU(r, e = 0) {
+ let t6 = v(r, "x", "expandDims", "string_or_numeric");
+ E(e <= t6.rank, () => "Axis must be <= rank of the tensor");
+ let o = { input: t6 }, n = { dim: e };
+ return T.runKernel(bs, o, n);
}
-var _a = T({ expandDims_: NG });
-function _G(r) {
- let t10 = { x: v(r, "x", "expm1") };
- return N.runKernel(wn, t10);
+var Fa = N({ expandDims_: jU });
+function XU(r) {
+ let t6 = { x: v(r, "x", "expm1") };
+ return T.runKernel(da, t6);
}
-var Fk = T({ expm1_: _G });
-function EG(r, e) {
- let t10 = v(r, "x", "tile", "string_or_numeric");
- $(t10.rank === e.length, () => `Error in transpose: rank of input ${t10.rank} must match length of reps ${e}.`);
- let o = { x: t10 }, n = { reps: e };
- return N.runKernel(wo, o, n);
+var ik = N({ expm1_: XU });
+function YU(r, e) {
+ let t6 = v(r, "x", "tile", "string_or_numeric");
+ E(t6.rank === e.length, () => `Error in transpose: rank of input ${t6.rank} must match length of reps ${e}.`);
+ let o = { x: t6 }, n = { reps: e };
+ return T.runKernel(to, o, n);
}
-var fi = T({ tile_: EG });
-function $G(r, e, t10, o = "float32") {
+var ki = N({ tile_: YU });
+function QU(r, e, t6, o = "float32") {
e == null && (e = r);
- let n = ne([r, e], o), s = r <= e ? r : e;
+ let n = le([r, e], o), s = r <= e ? r : e;
for (let i = 0; i < s; ++i)
n.set(1, i, i);
let a = z(n.toTensor(), [r, e]);
- if (t10 == null)
+ if (t6 == null)
return a;
- if (t10.length === 1)
- return fi(_a(a, 0), [t10[0], 1, 1]);
- if (t10.length === 2)
- return fi(_a(_a(a, 0), 0), [t10[0], t10[1], 1, 1]);
- if (t10.length === 3)
- return fi(_a(_a(_a(a, 0), 0), 0), [t10[0], t10[1], t10[2], 1, 1]);
- throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${t10.length}D.`);
+ if (t6.length === 1)
+ return ki(Fa(a, 0), [t6[0], 1, 1]);
+ if (t6.length === 2)
+ return ki(Fa(Fa(a, 0), 0), [t6[0], t6[1], 1, 1]);
+ if (t6.length === 3)
+ return ki(Fa(Fa(Fa(a, 0), 0), 0), [t6[0], t6[1], t6[2], 1, 1]);
+ throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${t6.length}D.`);
}
-var yf = T({ eye_: $G });
-function RG(r) {
- let t10 = { x: v(r, "x", "floor", "float32") };
- return N.runKernel(so, t10);
+var id = N({ eye_: QU });
+function ZU(r) {
+ let t6 = { x: v(r, "x", "floor", "float32") };
+ return T.runKernel(nn, t6);
}
-var bf = T({ floor_: RG });
-function AG(r, e, t10 = 0, o = 0) {
- let n = v(r, "x", "gather"), s = v(e, "indices", "gather", "int32"), a = { x: n, indices: s }, i = { axis: t10, batchDims: o };
- return N.runKernel(bs, a, i);
+var ud = N({ floor_: ZU });
+function JU(r, e, t6 = 0, o = 0) {
+ let n = v(r, "x", "gather"), s = v(e, "indices", "gather", "int32"), a = { x: n, indices: s }, i = { axis: t6, batchDims: o };
+ return T.runKernel(Ss, a, i);
}
-var Cf = T({ gather_: AG });
-function FG(r, e) {
- let t10 = v(r, "a", "greater", "string_or_numeric"), o = v(e, "b", "greater", "string_or_numeric");
- [t10, o] = Re(t10, o), Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(ao, n);
+var pd = N({ gather_: JU });
+function e4(r, e) {
+ let t6 = v(r, "a", "greater", "string_or_numeric"), o = v(e, "b", "greater", "string_or_numeric");
+ [t6, o] = Re(t6, o), Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(pn, n);
}
-var cu = T({ greater_: FG });
-function DG(r, e) {
- let t10 = v(r, "a", "greaterEqual", "string_or_numeric"), o = v(e, "b", "greaterEqual", "string_or_numeric");
- [t10, o] = Re(t10, o), Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(io, n);
+var cu = N({ greater_: e4 });
+function t4(r, e) {
+ let t6 = v(r, "a", "greaterEqual", "string_or_numeric"), o = v(e, "b", "greaterEqual", "string_or_numeric");
+ [t6, o] = Re(t6, o), Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(cn, n);
}
-var If = T({ greaterEqual_: DG });
-function PG(r) {
- let t10 = { x: v(r, "x", "isFinite") };
- return N.runKernel(Hi, t10);
+var cd = N({ greaterEqual_: t4 });
+function r4(r) {
+ let t6 = { x: v(r, "x", "isFinite") };
+ return T.runKernel(fa, t6);
}
-var Dk = T({ isFinite_: PG });
-function OG(r) {
- let t10 = { x: v(r, "x", "isInf") };
- return N.runKernel(qi, t10);
+var uk = N({ isFinite_: r4 });
+function o4(r) {
+ let t6 = { x: v(r, "x", "isInf") };
+ return T.runKernel(ha, t6);
}
-var Pk = T({ isInf_: OG });
-function MG(r) {
- let t10 = { x: v(r, "x", "isNaN") };
- return N.runKernel(ia, t10);
+var pk = N({ isInf_: o4 });
+function n4(r) {
+ let t6 = { x: v(r, "x", "isNaN") };
+ return T.runKernel(ln, t6);
}
-var Ok = T({ isNaN_: MG });
-function LG(r, e = 0.2) {
+var ck = N({ isNaN_: n4 });
+function s4(r, e = 0.2) {
let o = { x: v(r, "x", "leakyRelu") }, n = { alpha: e };
- return N.runKernel(Nn, o, n);
+ return T.runKernel(mn, o, n);
}
-var wf = T({ leakyRelu_: LG });
-function BG(r, e) {
- let t10 = v(r, "a", "less", "string_or_numeric"), o = v(e, "b", "less", "string_or_numeric");
- [t10, o] = Re(t10, o), Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(po, n);
+var ld = N({ leakyRelu_: s4 });
+function a4(r, e) {
+ let t6 = v(r, "a", "less", "string_or_numeric"), o = v(e, "b", "less", "string_or_numeric");
+ [t6, o] = Re(t6, o), Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(dn, n);
}
-var Mk = T({ less_: BG });
-function VG(r, e) {
- let t10 = v(r, "a", "lessEqual", "string_or_numeric"), o = v(e, "b", "lessEqual", "string_or_numeric");
- [t10, o] = Re(t10, o), Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(co, n);
+var lk = N({ less_: a4 });
+function i4(r, e) {
+ let t6 = v(r, "a", "lessEqual", "string_or_numeric"), o = v(e, "b", "lessEqual", "string_or_numeric");
+ [t6, o] = Re(t6, o), Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(fn, n);
}
-var Hp = T({ lessEqual_: VG });
-function Lk(r, e, t10) {
- if (t10 <= 0)
+var Vp = N({ lessEqual_: i4 });
+function mk(r, e, t6) {
+ if (t6 <= 0)
throw new Error("The number of values should be positive.");
- let o = { start: r, stop: e, num: t10 };
- return N.runKernel(Ip, {}, o);
+ let o = { start: r, stop: e, num: t6 };
+ return T.runKernel(xp, {}, o);
}
-function zG(r, e = 5, t10 = 1, o = 1, n = 0.5) {
+function u4(r, e = 5, t6 = 1, o = 1, n = 0.5) {
let s = v(r, "x", "localResponseNormalization");
- $(s.rank === 4 || s.rank === 3, () => `Error in localResponseNormalization: x must be rank 3 or 4 but got
- rank ${s.rank}.`), $(ra(e), () => `Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);
+ E(s.rank === 4 || s.rank === 3, () => `Error in localResponseNormalization: x must be rank 3 or 4 but got
+ rank ${s.rank}.`), E(na(e), () => `Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);
let a = s, i = false;
s.rank === 3 && (i = true, a = z(s, [1, s.shape[0], s.shape[1], s.shape[2]]));
- let p = { x: a }, u = { depthRadius: e, bias: t10, alpha: o, beta: n }, c = N.runKernel(wp, p, u);
+ let p = { x: a }, u = { depthRadius: e, bias: t6, alpha: o, beta: n }, c = T.runKernel(yp, p, u);
return i ? z(c, [c.shape[1], c.shape[2], c.shape[3]]) : c;
}
-var Bk = T({ localResponseNormalization_: zG });
-function WG(r) {
- let t10 = { x: v(r, "x", "log", "float32") };
- return N.runKernel(lo, t10);
+var dk = N({ localResponseNormalization_: u4 });
+function p4(r) {
+ let t6 = { x: v(r, "x", "log", "float32") };
+ return T.runKernel(hn, t6);
}
-var Ea = T({ log_: WG });
-function UG(r) {
- let t10 = { x: v(r, "x", "log1p") };
- return N.runKernel(Ki, t10);
+var Da = N({ log_: p4 });
+function c4(r) {
+ let t6 = { x: v(r, "x", "log1p") };
+ return T.runKernel(ga, t6);
}
-var Sf = T({ log1p_: UG });
-function GG(r) {
- return $(fs(r), () => "The f passed in grad(f) must be a function"), (e, t10) => {
- let o = v(e, "x", "tf.grad", "string_or_numeric"), n = t10 != null ? v(t10, "dy", "tf.grad") : null;
- return N.tidy(() => {
- let { value: s, grads: a } = N.gradients(() => r(o), [o], n);
- return n != null && ht(s.shape, n.shape, "The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"), vf(a), a[0];
+var md = N({ log1p_: c4 });
+function l4(r) {
+ return E(fs(r), () => "The f passed in grad(f) must be a function"), (e, t6) => {
+ let o = v(e, "x", "tf.grad", "string_or_numeric"), n = t6 != null ? v(t6, "dy", "tf.grad") : null;
+ return T.tidy(() => {
+ let { value: s, grads: a } = T.gradients(() => r(o), [o], n);
+ return n != null && ht(s.shape, n.shape, "The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"), dd(a), a[0];
});
};
}
-function HG(r) {
- return $(fs(r), () => "The f passed in grads(f) must be a function"), (e, t10) => {
- $(Array.isArray(e), () => "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");
- let o = Ia(e, "args", "tf.grads", "string_or_numeric"), n = t10 != null ? v(t10, "dy", "tf.grads") : null;
- return N.tidy(() => {
- let { value: s, grads: a } = N.gradients(() => r(...o), o, n);
- return n != null && ht(s.shape, n.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), vf(a), a;
+function m4(r) {
+ return E(fs(r), () => "The f passed in grads(f) must be a function"), (e, t6) => {
+ E(Array.isArray(e), () => "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");
+ let o = Na(e, "args", "tf.grads", "string_or_numeric"), n = t6 != null ? v(t6, "dy", "tf.grads") : null;
+ return T.tidy(() => {
+ let { value: s, grads: a } = T.gradients(() => r(...o), o, n);
+ return n != null && ht(s.shape, n.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), dd(a), a;
});
};
}
-function qG(r) {
- return $(fs(r), () => "The f passed in valueAndGrad(f) must be a function"), (e, t10) => {
- $(e instanceof ut, () => "The x passed in valueAndGrad(f)(x) must be a tensor"), $(t10 == null || t10 instanceof ut, () => "The dy passed in valueAndGrad(f)(x, dy) must be a tensor");
- let { grads: o, value: n } = N.gradients(() => r(e), [e], t10);
- return vf(o), { grad: o[0], value: n };
+function d4(r) {
+ return E(fs(r), () => "The f passed in valueAndGrad(f) must be a function"), (e, t6) => {
+ E(e instanceof it, () => "The x passed in valueAndGrad(f)(x) must be a tensor"), E(t6 == null || t6 instanceof it, () => "The dy passed in valueAndGrad(f)(x, dy) must be a tensor");
+ let { grads: o, value: n } = T.gradients(() => r(e), [e], t6);
+ return dd(o), { grad: o[0], value: n };
};
}
-function KG(r) {
- return $(fs(r), () => "The f passed in valueAndGrads(f) must be a function"), (e, t10) => {
- $(Array.isArray(e) && e.every((n) => n instanceof ut), () => "The args passed in valueAndGrads(f)(args) must be array of tensors"), $(t10 == null || t10 instanceof ut, () => "The dy passed in valueAndGrads(f)(args, dy) must be a tensor");
- let o = N.gradients(() => r(...e), e, t10);
- return t10 != null && ht(o.value.shape, t10.shape, "The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), vf(o.grads), o;
+function f4(r) {
+ return E(fs(r), () => "The f passed in valueAndGrads(f) must be a function"), (e, t6) => {
+ E(Array.isArray(e) && e.every((n) => n instanceof it), () => "The args passed in valueAndGrads(f)(args) must be array of tensors"), E(t6 == null || t6 instanceof it, () => "The dy passed in valueAndGrads(f)(args, dy) must be a tensor");
+ let o = T.gradients(() => r(...e), e, t6);
+ return t6 != null && ht(o.value.shape, t6.shape, "The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), dd(o.grads), o;
};
}
-function dC(r, e) {
- $(fs(r), () => "The f passed in variableGrads(f) must be a function"), $(e == null || Array.isArray(e) && e.every((u) => u instanceof ba), () => "The varList passed in variableGrads(f, varList) must be an array of variables");
- let t10 = e != null;
- if (!t10) {
+function pC(r, e) {
+ E(fs(r), () => "The f passed in variableGrads(f) must be a function"), E(e == null || Array.isArray(e) && e.every((u) => u instanceof va), () => "The varList passed in variableGrads(f, varList) must be an array of variables");
+ let t6 = e != null;
+ if (!t6) {
e = [];
- for (let u in N.registeredVariables)
- e.push(N.registeredVariables[u]);
+ for (let u in T.registeredVariables)
+ e.push(T.registeredVariables[u]);
}
- let o = t10 ? e.filter((u) => !u.trainable) : null, n = e.length;
- e = e.filter((u) => u.trainable), $(e.length > 0, () => `variableGrads() expects at least one of the input variables to be trainable, but none of the ${n} variables is trainable.`);
- let s = true, { value: a, grads: i } = N.gradients(r, e, null, s);
- $(i.some((u) => u != null), () => "Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."), $(a.rank === 0, () => `The f passed in variableGrads(f) must return a scalar, but it returned a rank-${a.rank} tensor`);
+ let o = t6 ? e.filter((u) => !u.trainable) : null, n = e.length;
+ e = e.filter((u) => u.trainable), E(e.length > 0, () => `variableGrads() expects at least one of the input variables to be trainable, but none of the ${n} variables is trainable.`);
+ let s = true, { value: a, grads: i } = T.gradients(r, e, null, s);
+ E(i.some((u) => u != null), () => "Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."), E(a.rank === 0, () => `The f passed in variableGrads(f) must return a scalar, but it returned a rank-${a.rank} tensor`);
let p = {};
return e.forEach((u, c) => {
i[c] != null && (p[u.name] = i[c]);
}), o != null && o.forEach((u) => p[u.name] = null), { value: a, grads: p };
}
function Cr(r) {
- return N.customGrad(r);
+ return T.customGrad(r);
}
-function vf(r) {
- if (r.filter((t10) => t10 == null).length > 0)
+function dd(r) {
+ if (r.filter((t6) => t6 == null).length > 0)
throw new Error(`Cannot compute gradient of y=f(x) with respect to x. Make sure that
the f you passed encloses all operations that lead from x to y.`);
}
-function jG(r) {
- let t10 = { x: v(r, "x", "softplus") };
- return N.runKernel(Qi, t10);
+function h4(r) {
+ let t6 = { x: v(r, "x", "softplus") };
+ return T.runKernel(Qi, t6);
}
-var kf = T({ softplus_: jG });
-function XG(r) {
+var fd = N({ softplus_: h4 });
+function g4(r) {
let e = v(r, "x", "logSigmoid");
- return Cr((o) => ({ value: yr(kf(yr(o))), gradFunc: (a) => oe(a, Ms(yr(o))) }))(e);
+ return Cr((o) => ({ value: yr(fd(yr(o))), gradFunc: (a) => ae(a, zs(yr(o))) }))(e);
}
-var Vk = T({ logSigmoid_: XG });
-function YG(r, e) {
- let t10 = v(r, "a", "sub"), o = v(e, "b", "sub");
- [t10, o] = Re(t10, o);
- let n = { a: t10, b: o };
- return N.runKernel(Io, n);
+var fk = N({ logSigmoid_: g4 });
+function x4(r, e) {
+ let t6 = v(r, "a", "sub"), o = v(e, "b", "sub");
+ [t6, o] = Re(t6, o);
+ let n = { a: t6, b: o };
+ return T.runKernel(Xn, n);
}
-var ke = T({ sub_: YG });
-function QG(r, e = -1) {
- let t10 = v(r, "logits", "logSoftmax");
- if (e === -1 && (e = t10.rank - 1), e !== t10.rank - 1)
- throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${t10.rank} and axis was ${e}`);
+var Ne = N({ sub_: x4 });
+function y4(r, e = -1) {
+ let t6 = v(r, "logits", "logSoftmax");
+ if (e === -1 && (e = t6.rank - 1), e !== t6.rank - 1)
+ throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${t6.rank} and axis was ${e}`);
return Cr((n, s) => {
- let i = Vs(n, e, true), p = ke(n, i), u = ke(qe(p, "float32"), Ea(tt(Bo(p), e, true)));
+ let i = Us(n, e, true), p = Ne(n, i), u = Ne(Ke(p, "float32"), Da(et(Co(p), e, true)));
return s([u]), { value: u, gradFunc: (l, m) => {
- let [f] = m, d = true, h = Bo(f);
- return ke(l, oe(tt(l, e, d), h));
+ let [d] = m, f = true, h = Co(d);
+ return Ne(l, ae(et(l, e, f), h));
} };
- })(t10);
+ })(t6);
}
-var zk = T({ logSoftmax_: QG });
-function ZG(r, e = null, t10 = false) {
- let o = v(r, "x", "logSumExp"), n = Ka(e, o.shape), s = Vs(o, n, true), a = ke(o, s), i = Bo(a), p = tt(i, n), u = Ea(p), c = ge(z(s, u.shape), u);
- if (t10) {
- let l = Ta(c.shape, n);
+var hk = N({ logSoftmax_: y4 });
+function b4(r, e = null, t6 = false) {
+ let o = v(r, "x", "logSumExp"), n = Qa(e, o.shape), s = Us(o, n, true), a = Ne(o, s), i = Co(a), p = et(i, n), u = Da(p), c = xe(z(s, u.shape), u);
+ if (t6) {
+ let l = Aa(c.shape, n);
return z(c, l);
}
return c;
}
-var Tf = T({ logSumExp_: ZG });
-function JG(r, e) {
- let t10 = v(r, "a", "logicalAnd", "bool"), o = v(e, "b", "logicalAnd", "bool");
- Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(_n, n);
+var hd = N({ logSumExp_: b4 });
+function C4(r, e) {
+ let t6 = v(r, "a", "logicalAnd", "bool"), o = v(e, "b", "logicalAnd", "bool");
+ Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(gn, n);
}
-var lu = T({ logicalAnd_: JG });
-function e4(r) {
- let t10 = { x: v(r, "x", "logicalNot", "bool") };
- return N.runKernel(En, t10);
+var lu = N({ logicalAnd_: C4 });
+function S4(r) {
+ let t6 = { x: v(r, "x", "logicalNot", "bool") };
+ return T.runKernel(xn, t6);
}
-var Nf = T({ logicalNot_: e4 });
-function t4(r, e) {
- let t10 = v(r, "a", "logicalOr", "bool"), o = v(e, "b", "logicalOr", "bool");
- Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(ua, n);
+var gd = N({ logicalNot_: S4 });
+function w4(r, e) {
+ let t6 = v(r, "a", "logicalOr", "bool"), o = v(e, "b", "logicalOr", "bool");
+ Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(xa, n);
}
-var _f = T({ logicalOr_: t4 });
-function r4(r, e) {
- let t10 = v(r, "a", "logicalXor", "bool"), o = v(e, "b", "logicalXor", "bool");
- return Je(t10.shape, o.shape), lu(_f(r, e), Nf(lu(r, e)));
+var xd = N({ logicalOr_: w4 });
+function I4(r, e) {
+ let t6 = v(r, "a", "logicalXor", "bool"), o = v(e, "b", "logicalXor", "bool");
+ return Je(t6.shape, o.shape), lu(xd(r, e), gd(lu(r, e)));
}
-var Wk = T({ logicalXor_: r4 });
-var Ef = 2147483648;
-function o4(r, e, t10 = "left") {
+var gk = N({ logicalXor_: I4 });
+var yd = 2147483648;
+function v4(r, e, t6 = "left") {
let o = v(r, "sortedSequence", "searchSorted"), n = v(e, "values", "searchSorted"), s = o.shape[o.shape.length - 1], a = n.shape[n.shape.length - 1], i = z(o, [-1, s]), p = z(n, [-1, a]);
if (i.rank < 2)
throw new Error("Sorted input argument must be at least 2-dimensional");
if (i.shape[0] !== p.shape[0])
throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");
- if (Ve(p.shape) >= Ef)
- throw new Error(`values tensor size must less than ${Ef}`);
- if (i.shape[1] >= Ef)
- throw new Error(`trailing dim_size must less than ${Ef} for int32 output type, was ${i.shape[1]}`);
- let u = { sortedSequence: i, values: p }, c = { side: t10 };
- return N.runKernel(Ep, u, c);
+ if (ze(p.shape) >= yd)
+ throw new Error(`values tensor size must less than ${yd}`);
+ if (i.shape[1] >= yd)
+ throw new Error(`trailing dim_size must less than ${yd} for int32 output type, was ${i.shape[1]}`);
+ let u = { sortedSequence: i, values: p }, c = { side: t6 };
+ return T.runKernel(ii, u, c);
}
-var dl = T({ searchSorted_: o4 });
-function Uk(r, e) {
- return dl(r, e, "left");
+var al = N({ searchSorted_: v4 });
+function xk(r, e) {
+ return al(r, e, "left");
}
-function n4(r, e, t10, o, n) {
+function k4(r, e, t6, o, n) {
let s = v(r, "x", "maxPool"), a = 1, i = s, p = false;
- s.rank === 3 && (p = true, i = z(s, [1, s.shape[0], s.shape[1], s.shape[2]])), $(i.rank === 4, () => `Error in maxPool: input must be rank 4 but got rank ${i.rank}.`), $(lr(t10, a), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${t10} and dilations '${a}'`), Ot("maxPool", o, n);
- let u = { x: i }, c = { filterSize: e, strides: t10, pad: o, dimRoundingMode: n }, l = N.runKernel(Rn, u, c);
+ s.rank === 3 && (p = true, i = z(s, [1, s.shape[0], s.shape[1], s.shape[2]])), E(i.rank === 4, () => `Error in maxPool: input must be rank 4 but got rank ${i.rank}.`), E(lr(t6, a), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${t6} and dilations '${a}'`), Pt("maxPool", o, n);
+ let u = { x: i }, c = { filterSize: e, strides: t6, pad: o, dimRoundingMode: n }, l = T.runKernel(Cn, u, c);
return p ? z(l, [l.shape[1], l.shape[2], l.shape[3]]) : l;
}
-var $f = T({ maxPool_: n4 });
-function s4(r, e = [1, 1, 1], t10, o, n, s = "NDHWC") {
+var bd = N({ maxPool_: k4 });
+function N4(r, e = [1, 1, 1], t6, o, n, s = "NDHWC") {
let a = v(r, "x", "maxPool3d"), i = a, p = false;
- a.rank === 4 && (p = true, i = z(a, [1, a.shape[0], a.shape[1], a.shape[2], a.shape[3]])), $(i.rank === 5, () => `Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`), $(s === "NDHWC", () => `Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`), Ot("maxPool3d", o, n);
- let u = { x: i }, c = { filterSize: e, strides: t10, pad: o, dimRoundingMode: n, dataFormat: s }, l = N.runKernel(Sp, u, c);
+ a.rank === 4 && (p = true, i = z(a, [1, a.shape[0], a.shape[1], a.shape[2], a.shape[3]])), E(i.rank === 5, () => `Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`), E(s === "NDHWC", () => `Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`), Pt("maxPool3d", o, n);
+ let u = { x: i }, c = { filterSize: e, strides: t6, pad: o, dimRoundingMode: n, dataFormat: s }, l = T.runKernel(bp, u, c);
return p ? z(l, [l.shape[1], l.shape[2], l.shape[3], l.shape[4]]) : l;
}
-var Gk = T({ maxPool3d_: s4 });
-function a4(r, e, t10, o, n = false) {
- let a = { x: v(r, "x", "maxPoolWithArgmax") }, i = { filterSize: e, strides: t10, pad: o, includeBatchInIndex: n }, p = N.runKernel(vp, a, i);
+var yk = N({ maxPool3d_: N4 });
+function T4(r, e, t6, o, n = false) {
+ let a = { x: v(r, "x", "maxPoolWithArgmax") }, i = { filterSize: e, strides: t6, pad: o, includeBatchInIndex: n }, p = T.runKernel(Cp, a, i);
return { result: p[0], indexes: p[1] };
}
-var Hk = T({ maxPoolWithArgmax_: a4 });
-function i4(r, e) {
- let t10 = v(r, "a", "maximum"), o = v(e, "b", "maximum");
- [t10, o] = Re(t10, o), t10.dtype === "bool" && (t10 = qe(t10, "int32"), o = qe(o, "int32")), Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(mo, n);
+var bk = N({ maxPoolWithArgmax_: T4 });
+function _4(r, e) {
+ let t6 = v(r, "a", "maximum"), o = v(e, "b", "maximum");
+ [t6, o] = Re(t6, o), t6.dtype === "bool" && (t6 = Ke(t6, "int32"), o = Ke(o, "int32")), Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(bn, n);
}
-var Rf = T({ maximum_: i4 });
-function u4(r, e = null, t10 = false) {
- let n = { x: v(r, "x", "mean") }, s = { axis: e, keepDims: t10 };
- return N.runKernel(An, n, s);
+var Cd = N({ maximum_: _4 });
+function E4(r, e = null, t6 = false) {
+ let n = { x: v(r, "x", "mean") }, s = { axis: e, keepDims: t6 };
+ return T.runKernel(Sn, n, s);
}
-var mu = T({ mean_: u4 });
-function Wr(r, e = "float32") {
- if (e === "complex64") {
- let o = Wr(r, "float32"), n = Wr(r, "float32");
- return Er(o, n);
+var mu = N({ mean_: E4 });
+function Vr(r, e = "float32") {
+ if (yt(r), e === "complex64") {
+ let o = Vr(r, "float32"), n = Vr(r, "float32");
+ return Tr(o, n);
}
- let t10 = ap(Ve(r), e);
- return N.makeTensor(t10, r, e);
+ let t6 = ap(ze(r), e);
+ return T.makeTensor(t6, r, e);
}
-function zs(r, e = "float32") {
- if (e === "complex64") {
- let o = zs(r, "float32"), n = Wr(r, "float32");
- return Er(o, n);
+function Gs(r, e = "float32") {
+ if (yt(r), e === "complex64") {
+ let o = Gs(r, "float32"), n = Vr(r, "float32");
+ return Tr(o, n);
}
- let t10 = jc(Ve(r), e);
- return N.makeTensor(t10, r, e);
+ let t6 = zc(ze(r), e);
+ return T.makeTensor(t6, r, e);
}
-function qk(r, e, { indexing: t10 = "xy" } = {}) {
- if (t10 !== "xy" && t10 !== "ij")
- throw new TypeError(`${t10} is not a valid third argument to meshgrid`);
+function Ck(r, e, { indexing: t6 = "xy" } = {}) {
+ if (t6 !== "xy" && t6 !== "ij")
+ throw new TypeError(`${t6} is not a valid third argument to meshgrid`);
if (r === void 0)
return [];
- let o = v(r, "x", "meshgrid", r instanceof ut ? r.dtype : "float32");
+ let o = v(r, "x", "meshgrid", r instanceof it ? r.dtype : "float32");
if (e === void 0)
return [o];
- let n = v(e, "y", "meshgrid", e instanceof ut ? e.dtype : "float32"), s = Ve(o.shape), a = Ve(n.shape);
- return t10 === "xy" ? (o = z(o, [1, -1]), n = z(n, [-1, 1]), [Xe(zs([a, 1], o.dtype), o), Xe(n, zs([1, s], n.dtype))]) : (o = z(o, [-1, 1]), n = z(n, [1, -1]), [Xe(o, zs([1, a], o.dtype)), Xe(zs([s, 1], n.dtype), n)]);
+ let n = v(e, "y", "meshgrid", e instanceof it ? e.dtype : "float32"), s = ze(o.shape), a = ze(n.shape);
+ return t6 === "xy" ? (o = z(o, [1, -1]), n = z(n, [-1, 1]), [Xe(Gs([a, 1], o.dtype), o), Xe(n, Gs([1, s], n.dtype))]) : (o = z(o, [-1, 1]), n = z(n, [1, -1]), [Xe(o, Gs([1, a], o.dtype)), Xe(Gs([s, 1], n.dtype), n)]);
}
-function p4(r, e) {
- let t10 = v(r, "a", "minimum"), o = v(e, "b", "minimum");
- [t10, o] = Re(t10, o), t10.dtype === "bool" && (t10 = qe(t10, "int32"), o = qe(o, "int32")), Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(fo, n);
+function $4(r, e) {
+ let t6 = v(r, "a", "minimum"), o = v(e, "b", "minimum");
+ [t6, o] = Re(t6, o), t6.dtype === "bool" && (t6 = Ke(t6, "int32"), o = Ke(o, "int32")), Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(In, n);
}
-var Af = T({ minimum_: p4 });
-function c4(r, e, t10) {
- $(t10 === "reflect" || t10 === "symmetric", () => `Invalid mode. Mode must be either reflect or symmetric. Got ${t10}.`);
+var Sd = N({ minimum_: $4 });
+function A4(r, e, t6) {
+ E(t6 === "reflect" || t6 === "symmetric", () => `Invalid mode. Mode must be either reflect or symmetric. Got ${t6}.`);
let o = v(r, "x", "mirrorPad");
if (o.rank === 0)
throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");
- $(e.length === o.rank, () => `Padding doesn't match input. Must be ${o.rank}. Got ${e.length}.`);
- let n = t10 === "reflect" ? 1 : 0;
+ E(e.length === o.rank, () => `Padding doesn't match input. Must be ${o.rank}. Got ${e.length}.`);
+ let n = t6 === "reflect" ? 1 : 0;
for (let i = 0; i < o.rank; i++)
- $(e[i].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), $(e[i][0] >= 0 && e[i][0] <= o.shape[i] - n && e[i][1] >= 0 && e[i][1] <= o.shape[i] - n, () => `Padding in dimension ${i} cannot be greater than or equal to ${o.shape[i] - n} or less than 0 for input of shape ${o.shape}`);
- let s = { paddings: e, mode: t10 }, a = { x: o };
- return N.runKernel(Dn, a, s);
+ E(e[i].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), E(e[i][0] >= 0 && e[i][0] <= o.shape[i] - n && e[i][1] >= 0 && e[i][1] <= o.shape[i] - n, () => `Padding in dimension ${i} cannot be greater than or equal to ${o.shape[i] - n} or less than 0 for input of shape ${o.shape}`);
+ let s = { paddings: e, mode: t6 }, a = { x: o };
+ return T.runKernel(vn, a, s);
}
-var Kk = T({ mirrorPad_: c4 });
-function l4(r, e) {
- let t10 = v(r, "a", "mod"), o = v(e, "b", "mod");
- [t10, o] = Re(t10, o);
- let n = { a: t10, b: o };
- return N.runKernel(ji, n);
+var Sk = N({ mirrorPad_: A4 });
+function R4(r, e) {
+ let t6 = v(r, "a", "mod"), o = v(e, "b", "mod");
+ [t6, o] = Re(t6, o);
+ let n = { a: t6, b: o };
+ return T.runKernel(ya, n);
}
-var jk = T({ mod_: l4 });
-function m4(r, e = null, t10 = false) {
+var wk = N({ mod_: R4 });
+function F4(r, e = null, t6 = false) {
r = v(r, "x", "moments");
- let o = Ka(e, r.shape), n = mu(r, o, t10), s = n.shape;
- t10 || (s = Ta(n.shape, o));
- let a = Zt(ke(qe(r, "float32"), z(n, s))), i = mu(a, o, t10);
+ let o = Qa(e, r.shape), n = mu(r, o, t6), s = n.shape;
+ t6 || (s = Aa(n.shape, o));
+ let a = Qt(Ne(Ke(r, "float32"), z(n, s))), i = mu(a, o, t6);
return { mean: n, variance: i };
}
-var Xk = T({ moments_: m4 });
-function f4(r, e, t10, o) {
- let n = v(e, "data", "multiRNNCell"), s = Ia(t10, "c", "multiRNNCell"), a = Ia(o, "h", "multiRNNCell"), i = n, p = [];
+var Ik = N({ moments_: F4 });
+function D4(r, e, t6, o) {
+ let n = v(e, "data", "multiRNNCell"), s = Na(t6, "c", "multiRNNCell"), a = Na(o, "h", "multiRNNCell"), i = n, p = [];
for (let l = 0; l < r.length; l++) {
let m = r[l](i, s[l], a[l]);
p.push(m[0]), p.push(m[1]), i = m[1];
@@ -7290,150 +7296,151 @@ function f4(r, e, t10, o) {
u.push(p[l]), c.push(p[l + 1]);
return [u, c];
}
-var Yk = T({ multiRNNCell_: f4 });
-function d4(r, e, t10, o = false) {
+var vk = N({ multiRNNCell_: D4 });
+function O4(r, e, t6, o = false) {
let n = v(r, "logits", "multinomial"), s = n.size, a = n.rank;
if (s < 2)
throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${s}.`);
if (a > 2)
throw new Error(`Rank of probabilities must be 1 or 2, but is ${a}`);
- t10 = t10 || Math.random();
- let p = { logits: a === 1 ? z(n, [1, -1]) : n }, u = { numSamples: e, seed: t10, normalized: o }, c = N.runKernel(kp, p, u);
+ t6 = t6 || Math.random();
+ let p = { logits: a === 1 ? z(n, [1, -1]) : n }, u = { numSamples: e, seed: t6, normalized: o }, c = T.runKernel(Sp, p, u);
return a === 1 ? z(c, [c.size]) : c;
}
-var Qk = T({ multinomial_: d4 });
-function h4(r, e) {
- let t10 = v(r, "a", "notEqual", "string_or_numeric"), o = v(e, "b", "notEqual", "string_or_numeric");
- [t10, o] = Re(t10, o), Je(t10.shape, o.shape);
- let n = { a: t10, b: o };
- return N.runKernel(go, n);
+var kk = N({ multinomial_: O4 });
+function P4(r, e) {
+ let t6 = v(r, "a", "notEqual", "string_or_numeric"), o = v(e, "b", "notEqual", "string_or_numeric");
+ [t6, o] = Re(t6, o), Je(t6.shape, o.shape);
+ let n = { a: t6, b: o };
+ return T.runKernel(Nn, n);
}
-var Ff = T({ notEqual_: h4 });
-function g4(r) {
- let t10 = { x: v(r, "x", "onesLike") };
- return N.runKernel(Cs, t10);
+var wd = N({ notEqual_: P4 });
+function M4(r) {
+ let t6 = { x: v(r, "x", "onesLike") };
+ return T.runKernel(Is, t6);
}
-var Zk = T({ onesLike_: g4 });
-function x4(r, e) {
- let t10 = v(r, "v1", "outerProduct"), o = v(e, "v2", "outerProduct");
- $(t10.rank === 1 && o.rank === 1, () => `Error in outerProduct: inputs must be rank 1, but got ranks ${t10.rank} and ${o.rank}.`);
- let n = z(t10, [-1, 1]), s = z(o, [1, -1]);
+var Nk = N({ onesLike_: M4 });
+function L4(r, e) {
+ let t6 = v(r, "v1", "outerProduct"), o = v(e, "v2", "outerProduct");
+ E(t6.rank === 1 && o.rank === 1, () => `Error in outerProduct: inputs must be rank 1, but got ranks ${t6.rank} and ${o.rank}.`);
+ let n = z(t6, [-1, 1]), s = z(o, [1, -1]);
return Xe(n, s);
}
-var Jk = T({ outerProduct_: x4 });
-function y4(r, e, t10 = 0) {
+var Tk = N({ outerProduct_: L4 });
+function B4(r, e, t6 = 0) {
let o = v(r, "x", "pad");
if (o.rank === 0)
throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");
- let n = { paddings: e, constantValue: t10 }, s = { x: o };
- return N.runKernel(Ln, s, n);
+ let n = { paddings: e, constantValue: t6 }, s = { x: o };
+ return T.runKernel($n, s, n);
}
-var Ws = T({ pad_: y4 });
-function b4(r, e, t10 = 0) {
- return $(e.length === 2, () => "Invalid number of paddings. Must be length of 2."), Ws(r, [e], t10);
+var Hs = N({ pad_: B4 });
+function V4(r, e, t6 = 0) {
+ return E(e.length === 2, () => "Invalid number of paddings. Must be length of 2."), Hs(r, [e], t6);
}
-var e1 = T({ pad1d_: b4 });
-function C4(r, e, t10 = 0) {
- return $(e.length === 2 && e[0].length === 2 && e[1].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), Ws(r, e, t10);
+var _k = N({ pad1d_: V4 });
+function z4(r, e, t6 = 0) {
+ return E(e.length === 2 && e[0].length === 2 && e[1].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), Hs(r, e, t6);
}
-var t1 = T({ pad2d_: C4 });
-function I4(r, e, t10 = 0) {
- return $(e.length === 3 && e[0].length === 2 && e[1].length === 2 && e[2].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), Ws(r, e, t10);
+var Ek = N({ pad2d_: z4 });
+function W4(r, e, t6 = 0) {
+ return E(e.length === 3 && e[0].length === 2 && e[1].length === 2 && e[2].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), Hs(r, e, t6);
}
-var r1 = T({ pad3d_: I4 });
-function w4(r, e, t10 = 0) {
- return $(e.length === 4 && e[0].length === 2 && e[1].length === 2 && e[2].length === 2 && e[3].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), Ws(r, e, t10);
+var $k = N({ pad3d_: W4 });
+function U4(r, e, t6 = 0) {
+ return E(e.length === 4 && e[0].length === 2 && e[1].length === 2 && e[2].length === 2 && e[3].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), Hs(r, e, t6);
}
-var o1 = T({ pad4d_: w4 });
-function S4(r, e, t10) {
+var Ak = N({ pad4d_: U4 });
+function G4(r, e, t6) {
let o = v(r, "x", "spaceToBatchND");
- $(o.rank >= 1 + e.length, () => `input rank ${o.rank} should be > than [blockShape] ${e.length}`), $(t10.length === e.length, () => `paddings.shape[0] ${t10.length} must be equal to [blockShape] ${e.length}`), $(o.shape.reduce((a, i, p) => p > 0 && p <= e.length ? a && (i + t10[p - 1][0] + t10[p - 1][1]) % e[p - 1] === 0 : a, true), () => `input spatial dimensions ${o.shape.slice(1)} with paddings ${t10.toString()} must be divisible by blockShapes ${e.toString()}`);
- let n = { x: o }, s = { blockShape: e, paddings: t10 };
- return N.runKernel(ks, n, s);
+ E(o.rank >= 1 + e.length, () => `input rank ${o.rank} should be > than [blockShape] ${e.length}`), E(t6.length === e.length, () => `paddings.shape[0] ${t6.length} must be equal to [blockShape] ${e.length}`), E(o.shape.reduce((a, i, p) => p > 0 && p <= e.length ? a && (i + t6[p - 1][0] + t6[p - 1][1]) % e[p - 1] === 0 : a, true), () => `input spatial dimensions ${o.shape.slice(1)} with paddings ${t6.toString()} must be divisible by blockShapes ${e.toString()}`);
+ let n = { x: o }, s = { blockShape: e, paddings: t6 };
+ return T.runKernel(Es, n, s);
}
-var Df = T({ spaceToBatchND_: S4 });
-function v4(r, e, t10, o, n, s, a) {
+var Id = N({ spaceToBatchND_: G4 });
+function H4(r, e, t6, o, n, s, a) {
n == null && (n = [1, 1]), s == null && (s = 1), o === 0 && (o = "valid");
let i = v(r, "x", "maxPool"), p = i, u = false;
- i.rank === 3 && (u = true, p = z(i, [1, i.shape[0], i.shape[1], i.shape[2]])), $(lr(s, n), () => `Error in pool: Either strides or dilations must be 1. Got strides ${s} and dilations '${n}'`);
- let c = lC(p.shape, e, s, n, o), l = [c.dilationHeight, c.dilationWidth], m;
- o === "same" ? m = T4([c.filterHeight, c.filterWidth], l) : m = [[0, 0], [0, 0]];
- let f = l[0] === 1 && l[1] === 1, [d, h] = k4([c.inHeight, c.inWidth], l, m), g = f ? o : "valid", y = f ? p : Df(p, l, d), C = (t10 === "avg" ? () => mf(y, e, s, g, a) : () => $f(y, e, s, g, a))(), w = f ? C : ff(C, l, h);
+ i.rank === 3 && (u = true, p = z(i, [1, i.shape[0], i.shape[1], i.shape[2]])), E(lr(s, n), () => `Error in pool: Either strides or dilations must be 1. Got strides ${s} and dilations '${n}'`);
+ let c = aC(p.shape, e, s, n, o), l = [c.dilationHeight, c.dilationWidth], m;
+ o === "same" ? m = K4([c.filterHeight, c.filterWidth], l) : m = [[0, 0], [0, 0]];
+ let d = l[0] === 1 && l[1] === 1, [f, h] = q4([c.inHeight, c.inWidth], l, m), g = d ? o : "valid", x = d ? p : Id(p, l, f), C = (t6 === "avg" ? () => td(x, e, s, g, a) : () => bd(x, e, s, g, a))(), w = d ? C : rd(C, l, h);
return u ? z(w, [w.shape[1], w.shape[2], w.shape[3]]) : w;
}
-function k4(r, e, t10) {
- let o = t10.map((c) => c[0]), n = t10.map((c) => c[1]), s = r.concat(o, n), a = e.map((c, l) => (c - s[l] % c) % c), i = n.map((c, l) => c + a[l]), p = e.map((c, l) => [o[l], i[l]]), u = e.map((c, l) => [0, a[l]]);
+function q4(r, e, t6) {
+ let o = t6.map((c) => c[0]), n = t6.map((c) => c[1]), s = r.concat(o, n), a = e.map((c, l) => (c - s[l] % c) % c), i = n.map((c, l) => c + a[l]), p = e.map((c, l) => [o[l], i[l]]), u = e.map((c, l) => [0, a[l]]);
return [p, u];
}
-function T4(r, e) {
+function K4(r, e) {
let o = r.map((a, i) => a + (a - 1) * (e[i] - 1)).map((a) => a - 1), n = o.map((a) => Math.floor(a / 2)), s = o.map((a, i) => a - n[i]);
return o.map((a, i) => [n[i], s[i]]);
}
-var n1 = T({ pool_: v4 });
-function N4(r, e) {
- let t10 = v(r, "x", "prelu"), o = v(e, "alpha", "prelu"), n = { x: t10, alpha: o };
- return N.runKernel(Vn, n);
+var Rk = N({ pool_: H4 });
+function j4(r, e) {
+ let t6 = v(r, "x", "prelu"), o = v(e, "alpha", "prelu"), n = { x: t6, alpha: o };
+ return T.runKernel(Rn, n);
}
-var Pf = T({ prelu_: N4 });
-function _4(r, e = null, t10 = false) {
+var vd = N({ prelu_: j4 });
+function X4(r, e = null, t6 = false) {
let o = v(r, "x", "prod");
- o.dtype === "bool" && (o = qe(o, "int32"));
- let n = { x: o }, s = { axis: e, keepDims: t10 };
- return N.runKernel(Ao, n, s);
+ o.dtype === "bool" && (o = Ke(o, "int32"));
+ let n = { x: o }, s = { axis: e, keepDims: t6 };
+ return T.runKernel(Fn, n, s);
}
-var s1 = T({ prod_: _4 });
-function E4(r, e, t10, o) {
- let n = r.map((c, l) => v(c, `tensors${l}`, "raggedGather", "int32")), s = v(e, "paramsDenseValues", "raggedGather"), a = v(t10, "indices", "raggedGather", "int32"), i = { paramsNestedSplits: n, paramsDenseValues: s, indices: a }, p = { outputRaggedRank: o }, u = N.runKernel(Tp, i, p);
+var Fk = N({ prod_: X4 });
+function Y4(r, e, t6, o) {
+ let n = r.map((c, l) => v(c, `tensors${l}`, "raggedGather", "int32")), s = v(e, "paramsDenseValues", "raggedGather"), a = v(t6, "indices", "raggedGather", "int32"), i = { paramsNestedSplits: n, paramsDenseValues: s, indices: a }, p = { outputRaggedRank: o }, u = T.runKernel(wp, i, p);
return { outputNestedSplits: u.slice(0, u.length - 1), outputDenseValues: u[u.length - 1] };
}
-var a1 = T({ raggedGather_: E4 });
-function $4(r, e, t10) {
- let o = v(r, "starts", "raggedRange"), n = v(e, "limits", "raggedRange", o.dtype), s = v(t10, "deltas", "raggedRange", o.dtype), a = { starts: o, limits: n, deltas: s }, i = N.runKernel(Np, a);
+var Dk = N({ raggedGather_: Y4 });
+function Q4(r, e, t6) {
+ let o = v(r, "starts", "raggedRange"), n = v(e, "limits", "raggedRange", o.dtype), s = v(t6, "deltas", "raggedRange", o.dtype), a = { starts: o, limits: n, deltas: s }, i = T.runKernel(Ip, a);
return { rtNestedSplits: i[0], rtDenseValues: i[1] };
}
-var i1 = T({ raggedRange_: $4 });
-function R4(r, e, t10, o, n) {
- let s = v(r, "shape", "raggedTensorToTensor", "int32"), a = v(e, "values", "raggedTensorToTensor"), i = v(t10, "defaultValue", "raggedTensorToTensor", a.dtype), p = o.map((l, m) => v(l, `tensors${m}`, "raggedTensorToTensor", "int32")), u = { shape: s, values: a, defaultValue: i, rowPartitionTensors: p }, c = { rowPartitionTypes: n };
- return N.runKernel(_p, u, c);
+var Ok = N({ raggedRange_: Q4 });
+function Z4(r, e, t6, o, n) {
+ let s = v(r, "shape", "raggedTensorToTensor", "int32"), a = v(e, "values", "raggedTensorToTensor"), i = v(t6, "defaultValue", "raggedTensorToTensor", a.dtype), p = o.map((l, m) => v(l, `tensors${m}`, "raggedTensorToTensor", "int32")), u = { shape: s, values: a, defaultValue: i, rowPartitionTensors: p }, c = { rowPartitionTypes: n };
+ return T.runKernel(vp, u, c);
}
-var u1 = T({ raggedTensorToTensor_: R4 });
-function A4(r, e, t10) {
- let o = Ve(r), n = null;
- if (t10 == null || t10 === "float32")
+var Pk = N({ raggedTensorToTensor_: Z4 });
+function J4(r, e, t6) {
+ yt(r);
+ let o = ze(r), n = null;
+ if (t6 == null || t6 === "float32")
n = new Float32Array(o);
- else if (t10 === "int32")
+ else if (t6 === "int32")
n = new Int32Array(o);
- else if (t10 === "bool")
+ else if (t6 === "bool")
n = new Uint8Array(o);
else
- throw new Error(`Unknown data type ${t10}`);
+ throw new Error(`Unknown data type ${t6}`);
for (let s = 0; s < o; s++)
n[s] = e();
- return N.makeTensor(n, r, t10);
+ return T.makeTensor(n, r, t6);
}
-var p1 = T({ rand_: A4 });
-var Bf = rp(IC());
-var du = class {
- constructor(e, t10, o, n, s) {
- this.mean = e, this.stdDev = t10, this.dtype = o, this.nextVal = NaN, this.truncated = n, this.truncated && (this.upper = this.mean + this.stdDev * 2, this.lower = this.mean - this.stdDev * 2);
+var Mk = N({ rand_: J4 });
+var _d = rp(gC());
+var fu = class {
+ constructor(e, t6, o, n, s) {
+ this.mean = e, this.stdDev = t6, this.dtype = o, this.nextVal = NaN, this.truncated = n, this.truncated && (this.upper = this.mean + this.stdDev * 2, this.lower = this.mean - this.stdDev * 2);
let a = s || Math.random();
- this.random = Bf.alea(a.toString());
+ this.random = _d.alea(a.toString());
}
nextValue() {
if (!isNaN(this.nextVal)) {
let n = this.nextVal;
return this.nextVal = NaN, n;
}
- let e, t10, o = false;
+ let e, t6, o = false;
for (; !o; ) {
let n, s, a;
do
n = 2 * this.random() - 1, s = 2 * this.random() - 1, a = n * n + s * s;
while (a >= 1 || a === 0);
let i = Math.sqrt(-2 * Math.log(a) / a);
- e = this.mean + this.stdDev * n * i, t10 = this.mean + this.stdDev * s * i, (!this.truncated || this.isValidTruncated(e)) && (o = true);
+ e = this.mean + this.stdDev * n * i, t6 = this.mean + this.stdDev * s * i, (!this.truncated || this.isValidTruncated(e)) && (o = true);
}
- return (!this.truncated || this.isValidTruncated(t10)) && (this.nextVal = this.convertValue(t10)), this.convertValue(e);
+ return (!this.truncated || this.isValidTruncated(t6)) && (this.nextVal = this.convertValue(t6)), this.convertValue(e);
}
convertValue(e) {
return this.dtype == null || this.dtype === "float32" ? e : Math.round(e);
@@ -7442,19 +7449,19 @@ var du = class {
return e <= this.upper && e >= this.lower;
}
};
-var Mf = class {
- constructor(e, t10, o, n) {
- this.alpha = e, this.beta = 1 / t10, this.dtype = o;
+var Nd = class {
+ constructor(e, t6, o, n) {
+ this.alpha = e, this.beta = 1 / t6, this.dtype = o;
let s = n || Math.random();
- this.randu = Bf.alea(s.toString()), this.randn = new du(0, 1, o, false, this.randu()), e < 1 ? this.d = e + 2 / 3 : this.d = e - 1 / 3, this.c = 1 / Math.sqrt(9 * this.d);
+ this.randu = _d.alea(s.toString()), this.randn = new fu(0, 1, o, false, this.randu()), e < 1 ? this.d = e + 2 / 3 : this.d = e - 1 / 3, this.c = 1 / Math.sqrt(9 * this.d);
}
nextValue() {
- let e, t10, o, n, s, a;
+ let e, t6, o, n, s, a;
for (; ; ) {
do
n = this.randn.nextValue(), a = 1 + this.c * n;
while (a <= 0);
- if (a *= a * a, e = n * n, t10 = 1 - 0.331 * e * e, o = 0.5 * e + this.d * (1 - a + Math.log(a)), s = this.randu(), s < t10 || Math.log(s) < o)
+ if (a *= a * a, e = n * n, t6 = 1 - 0.331 * e * e, o = 0.5 * e + this.d * (1 - a + Math.log(a)), s = this.randu(), s < t6 || Math.log(s) < o)
break;
}
return a = 1 / this.beta * this.d * a, this.alpha < 1 && (a *= Math.pow(this.randu(), 1 / this.alpha)), this.convertValue(a);
@@ -7463,11 +7470,11 @@ var Mf = class {
return this.dtype === "float32" ? e : Math.round(e);
}
};
-var Lf = class {
- constructor(e = 0, t10 = 1, o, n) {
- if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = e, this.range = t10 - e, this.dtype = o, n == null && (n = Math.random()), typeof n == "number" && (n = n.toString()), !this.canReturnFloat() && this.range <= 1)
- throw new Error(`The difference between ${e} - ${t10} <= 1 and dtype is not float`);
- this.random = Bf.alea(n);
+var Td = class {
+ constructor(e = 0, t6 = 1, o, n) {
+ if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = e, this.range = t6 - e, this.dtype = o, n == null && (n = Math.random()), typeof n == "number" && (n = n.toString()), !this.canReturnFloat() && this.range <= 1)
+ throw new Error(`The difference between ${e} - ${t6} <= 1 and dtype is not float`);
+ this.random = _d.alea(n);
}
convertValue(e) {
return this.canReturnFloat() ? e : Math.round(e);
@@ -7476,294 +7483,295 @@ var Lf = class {
return this.convertValue(this.min + this.range * this.random());
}
};
-function B4(r, e, t10 = 1, o = "float32", n) {
- if (t10 == null && (t10 = 1), o == null && (o = "float32"), o !== "float32" && o !== "int32")
+function aG(r, e, t6 = 1, o = "float32", n) {
+ if (yt(r), t6 == null && (t6 = 1), o == null && (o = "float32"), o !== "float32" && o !== "int32")
throw new Error(`Unsupported data type ${o}`);
- let s = new Mf(e, t10, o, n), a = ne(r, o);
+ let s = new Nd(e, t6, o, n), a = le(r, o);
for (let i = 0; i < a.values.length; i++)
a.values[i] = s.nextValue();
return a.toTensor();
}
-var T1 = T({ randomGamma_: B4 });
-function V4(r, e = 0, t10 = 1, o, n) {
- if (o != null && o === "bool")
+var e1 = N({ randomGamma_: aG });
+function iG(r, e = 0, t6 = 1, o, n) {
+ if (yt(r), o != null && o === "bool")
throw new Error(`Unsupported data type ${o}`);
- let s = new du(e, t10, o, false, n), a = ne(r, o);
+ let s = new fu(e, t6, o, false, n), a = le(r, o);
for (let i = 0; i < a.values.length; i++)
a.values[i] = s.nextValue();
return a.toTensor();
}
-var Vf = T({ randomNormal_: V4 });
-function z4(r, e, t10) {
+var Ed = N({ randomNormal_: iG });
+function uG(r, e, t6) {
if (e != null && e === "bool")
throw new Error(`Unsupported data type ${e}`);
- return Vf(r, 0, 1, e, t10);
+ return Ed(r, 0, 1, e, t6);
}
-var N1 = T({ randomStandardNormal_: z4 });
-function W4(r, e = 0, t10 = 1, o = "float32", n) {
- let s = ne(r, o), a = new Lf(e, t10, null, n);
+var t1 = N({ randomStandardNormal_: uG });
+function pG(r, e = 0, t6 = 1, o = "float32", n) {
+ yt(r);
+ let s = le(r, o), a = new Td(e, t6, null, n);
for (let i = 0; i < s.values.length; i++)
s.values[i] = a.nextValue();
return s.toTensor();
}
-var zf = T({ randomUniform_: W4 });
-function di(r, e, t10 = 1, o = "float32") {
- if (t10 === 0)
+var $d = N({ randomUniform_: pG });
+function Ni(r, e, t6 = 1, o = "float32") {
+ if (t6 === 0)
throw new Error("Cannot have a step of zero");
- let n = { start: r, stop: e, step: t10, dtype: o };
- return N.runKernel(ws, {}, n);
+ let n = { start: r, stop: e, step: t6, dtype: o };
+ return T.runKernel(ks, {}, n);
}
-function U4(r) {
- let t10 = { x: v(r, "x", "reciprocal") };
- return N.runKernel(ma, t10);
+function cG(r) {
+ let t6 = { x: v(r, "x", "reciprocal") };
+ return T.runKernel(Dn, t6);
}
-var _1 = T({ reciprocal_: U4 });
-function G4(r) {
- let t10 = { x: v(r, "x", "relu") };
- return N.runKernel(zn, t10);
+var r1 = N({ reciprocal_: cG });
+function lG(r) {
+ let t6 = { x: v(r, "x", "relu") };
+ return T.runKernel(On, t6);
}
-var hi = T({ relu_: G4 });
-function H4(r) {
- let t10 = { x: v(r, "x", "relu6") };
- return N.runKernel(Gn, t10);
+var Ti = N({ relu_: lG });
+function mG(r) {
+ let t6 = { x: v(r, "x", "relu6") };
+ return T.runKernel(Ln, t6);
}
-var Wf = T({ relu6_: H4 });
-function q4(r, e) {
+var Ad = N({ relu6_: mG });
+function dG(r, e) {
let o = { x: v(r, "x", "reverse") }, n = { dims: e };
- return N.runKernel(fa, o, n);
+ return T.runKernel(Bn, o, n);
}
-var vo = T({ reverse_: q4 });
-function K4(r) {
+var no = N({ reverse_: dG });
+function fG(r) {
let e = v(r, "x", "reverse");
- return $(e.rank === 1, () => `Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`), vo(e, 0);
+ return E(e.rank === 1, () => `Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`), no(e, 0);
}
-var E1 = T({ reverse1d_: K4 });
-function j4(r, e) {
- let t10 = v(r, "x", "reverse");
- return $(t10.rank === 2, () => `Error in reverse2D: x must be rank 2 but got rank ${t10.rank}.`), vo(t10, e);
+var o1 = N({ reverse1d_: fG });
+function hG(r, e) {
+ let t6 = v(r, "x", "reverse");
+ return E(t6.rank === 2, () => `Error in reverse2D: x must be rank 2 but got rank ${t6.rank}.`), no(t6, e);
}
-var $1 = T({ reverse2d_: j4 });
-function X4(r, e) {
- let t10 = v(r, "x", "reverse");
- return $(t10.rank === 3, () => `Error in reverse3D: x must be rank 3 but got rank ${t10.rank}.`), vo(t10, e);
+var n1 = N({ reverse2d_: hG });
+function gG(r, e) {
+ let t6 = v(r, "x", "reverse");
+ return E(t6.rank === 3, () => `Error in reverse3D: x must be rank 3 but got rank ${t6.rank}.`), no(t6, e);
}
-var R1 = T({ reverse3d_: X4 });
-function Y4(r, e) {
- let t10 = v(r, "x", "reverse");
- return $(t10.rank === 4, () => `Error in reverse4D: x must be rank 4 but got rank ${t10.rank}.`), vo(t10, e);
+var s1 = N({ reverse3d_: gG });
+function xG(r, e) {
+ let t6 = v(r, "x", "reverse");
+ return E(t6.rank === 4, () => `Error in reverse4D: x must be rank 4 but got rank ${t6.rank}.`), no(t6, e);
}
-var A1 = T({ reverse4d_: Y4 });
-function Q4(r) {
- let t10 = { x: v(r, "x", "round") };
- return N.runKernel(da, t10);
+var a1 = N({ reverse4d_: xG });
+function yG(r) {
+ let t6 = { x: v(r, "x", "round") };
+ return T.runKernel(Ca, t6);
}
-var Uf = T({ round_: Q4 });
-function Z4(r) {
- let t10 = { x: v(r, "x", "rsqrt", "float32") };
- return N.runKernel(xo, t10);
+var Rd = N({ round_: yG });
+function bG(r) {
+ let t6 = { x: v(r, "x", "rsqrt", "float32") };
+ return T.runKernel(Vn, t6);
}
-var F1 = T({ rsqrt_: Z4 });
-function J4(r) {
- let t10 = { x: v(r, "x", "selu") };
- return N.runKernel(Xi, t10);
+var i1 = N({ rsqrt_: bG });
+function CG(r) {
+ let t6 = { x: v(r, "x", "selu") };
+ return T.runKernel(Xi, t6);
}
-var D1 = T({ selu_: J4 });
-function eH(r, e, t10, o, n, s = [1, 1], a = "NHWC") {
- let i = v(r, "x", "separableConv2d"), p = v(e, "depthwiseFilter", "separableConv2d"), u = v(t10, "pointwiseFilter", "separableConv2d"), c = i, l = false;
+var u1 = N({ selu_: CG });
+function SG(r, e, t6, o, n, s = [1, 1], a = "NHWC") {
+ let i = v(r, "x", "separableConv2d"), p = v(e, "depthwiseFilter", "separableConv2d"), u = v(t6, "pointwiseFilter", "separableConv2d"), c = i, l = false;
if (i.rank === 3 && (l = true, c = z(i, [1, i.shape[0], i.shape[1], i.shape[2]])), a === "NCHW")
throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");
- $(c.rank === 4, () => `Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`), $(p.rank === 4, () => `Error in separableConv2d: depthwise filter must be rank 4, but got rank ${p.rank}.`), $(u.rank === 4, () => `Error in separableConv2d: pointwise filter must be rank 4, but got rank ${p.rank}.`), $(u.shape[0] === 1, () => `Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${u.shape[0]}.`), $(u.shape[1] === 1, () => `Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${u.shape[1]}.`);
- let m = p.shape[2], f = p.shape[3];
- $(u.shape[2] === m * f, () => `Error in separableConv2d: the third dimension of pointwise filter must be ${m * f}, but got ${u.shape[2]}.`);
- let d = Gp(c, p, o, n, a, s), g = mi(d, u, 1, "valid", a);
+ E(c.rank === 4, () => `Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`), E(p.rank === 4, () => `Error in separableConv2d: depthwise filter must be rank 4, but got rank ${p.rank}.`), E(u.rank === 4, () => `Error in separableConv2d: pointwise filter must be rank 4, but got rank ${p.rank}.`), E(u.shape[0] === 1, () => `Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${u.shape[0]}.`), E(u.shape[1] === 1, () => `Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${u.shape[1]}.`);
+ let m = p.shape[2], d = p.shape[3];
+ E(u.shape[2] === m * d, () => `Error in separableConv2d: the third dimension of pointwise filter must be ${m * d}, but got ${u.shape[2]}.`);
+ let f = Bp(c, p, o, n, a, s), g = vi(f, u, 1, "valid", a);
return l ? z(g, [g.shape[1], g.shape[2], g.shape[3]]) : g;
}
-var P1 = T({ separableConv2d_: eH });
-async function tH(r, e) {
- let t10 = v(r, "x", "setdiff1d"), o = v(e, "y", "setdiff1d");
- $(t10.dtype === o.dtype, () => `x and y should have the same dtype, but got x (${t10.dtype}) and y (${o.dtype}).`), $(t10.rank === 1, () => `x should be 1D tensor, but got x (${t10.shape}).`), $(o.rank === 1, () => `y should be 1D tensor, but got y (${o.shape}).`);
- let n = await t10.data(), s = await o.data(), a = new Set(s), i = 0;
+var p1 = N({ separableConv2d_: SG });
+async function wG(r, e) {
+ let t6 = v(r, "x", "setdiff1d"), o = v(e, "y", "setdiff1d");
+ E(t6.dtype === o.dtype, () => `x and y should have the same dtype, but got x (${t6.dtype}) and y (${o.dtype}).`), E(t6.rank === 1, () => `x should be 1D tensor, but got x (${t6.shape}).`), E(o.rank === 1, () => `y should be 1D tensor, but got y (${o.shape}).`);
+ let n = await t6.data(), s = await o.data(), a = new Set(s), i = 0;
for (let c = 0; c < n.length; c++)
a.has(n[c]) || i++;
- let p = new je([i], t10.dtype), u = new je([i], "int32");
+ let p = new st([i], t6.dtype), u = new st([i], "int32");
for (let c = 0, l = 0; c < n.length; c++)
a.has(n[c]) || (p.values[l] = n[c], u.values[l] = c, l++);
return [p.toTensor(), u.toTensor()];
}
-var O1 = tH;
-function rH(r) {
- let t10 = { x: v(r, "x", "sign") };
- return N.runKernel(Yi, t10);
+var c1 = wG;
+function IG(r) {
+ let t6 = { x: v(r, "x", "sign") };
+ return T.runKernel(Yi, t6);
}
-var M1 = T({ sign_: rH });
-function oH(r) {
- let t10 = { x: v(r, "x", "sin", "float32") };
- return N.runKernel(Kn, t10);
+var l1 = N({ sign_: IG });
+function vG(r) {
+ let t6 = { x: v(r, "x", "sin", "float32") };
+ return T.runKernel(Wn, t6);
}
-var L1 = T({ sin_: oH });
-function nH(r) {
- let t10 = { x: v(r, "x", "sinh") };
- return N.runKernel(ha, t10);
+var m1 = N({ sin_: vG });
+function kG(r) {
+ let t6 = { x: v(r, "x", "sinh") };
+ return T.runKernel(Sa, t6);
}
-var B1 = T({ sinh_: nH });
-function sH(r, e, t10) {
+var d1 = N({ sinh_: kG });
+function NG(r, e, t6) {
let o = v(r, "x", "slice1d");
- return $(o.rank === 1, () => `slice1d expects a rank-1 tensor, but got a rank-${o.rank} tensor`), Ue(o, [e], [t10]);
+ return E(o.rank === 1, () => `slice1d expects a rank-1 tensor, but got a rank-${o.rank} tensor`), He(o, [e], [t6]);
}
-var V1 = T({ slice1d_: sH });
-function aH(r, e, t10) {
+var f1 = N({ slice1d_: NG });
+function TG(r, e, t6) {
let o = v(r, "x", "slice2d");
- return $(o.rank === 2, () => `slice2d expects a rank-2 tensor, but got a rank-${o.rank} tensor`), Ue(o, e, t10);
+ return E(o.rank === 2, () => `slice2d expects a rank-2 tensor, but got a rank-${o.rank} tensor`), He(o, e, t6);
}
-var z1 = T({ slice2d_: aH });
-function iH(r, e, t10) {
+var h1 = N({ slice2d_: TG });
+function _G(r, e, t6) {
let o = v(r, "x", "slice3d");
- return $(o.rank === 3, () => `slice3d expects a rank-3 tensor, but got a rank-${o.rank} tensor`), Ue(o, e, t10);
+ return E(o.rank === 3, () => `slice3d expects a rank-3 tensor, but got a rank-${o.rank} tensor`), He(o, e, t6);
}
-var W1 = T({ slice3d_: iH });
-function uH(r, e, t10) {
+var g1 = N({ slice3d_: _G });
+function EG(r, e, t6) {
let o = v(r, "x", "slice4d");
- return $(o.rank === 4, () => `slice4d expects a rank-4 tensor, but got a rank-${o.rank} tensor`), Ue(o, e, t10);
+ return E(o.rank === 4, () => `slice4d expects a rank-4 tensor, but got a rank-${o.rank} tensor`), He(o, e, t6);
}
-var U1 = T({ slice4d_: uH });
-function pH(r, e = -1) {
- let t10 = v(r, "logits", "softmax", "float32");
- if (e === -1 && (e = t10.rank - 1), e !== t10.rank - 1)
- throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t10.rank} and dim was ${e}`);
- let o = { logits: t10 }, n = { dim: e };
- return N.runKernel(Xn, o, n);
+var x1 = N({ slice4d_: EG });
+function $G(r, e = -1) {
+ let t6 = v(r, "logits", "softmax", "float32");
+ if (e === -1 && (e = t6.rank - 1), e !== t6.rank - 1)
+ throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t6.rank} and dim was ${e}`);
+ let o = { logits: t6 }, n = { dim: e };
+ return T.runKernel(qn, o, n);
}
-var G1 = T({ softmax_: pH });
-function cH(r) {
- $(r.dtype === "complex64", () => `The dtype for tf.spectral.fft() must be complex64 but got ${r.dtype}.`);
+var y1 = N({ softmax_: $G });
+function AG(r) {
+ E(r.dtype === "complex64", () => `The dtype for tf.spectral.fft() must be complex64 but got ${r.dtype}.`);
let e = { input: r };
- return N.runKernel(bp, e);
+ return T.runKernel(oi, e);
}
-var qp = T({ fft_: cH });
-function lH(r) {
- $(r.dtype === "complex64", () => `The dtype for tf.spectral.ifft() must be complex64 but got ${r.dtype}.`);
+var zp = N({ fft_: AG });
+function RG(r) {
+ E(r.dtype === "complex64", () => `The dtype for tf.spectral.ifft() must be complex64 but got ${r.dtype}.`);
let e = { input: r };
- return N.runKernel(Cp, e);
+ return T.runKernel(ni, e);
}
-var hu = T({ ifft_: lH });
-function mH(r) {
- let e = r.shape[r.shape.length - 1], t10 = r.size / e, o;
+var hu = N({ ifft_: RG });
+function FG(r) {
+ let e = r.shape[r.shape.length - 1], t6 = r.size / e, o;
if (e <= 2) {
- let n = z(r, [t10, e]);
+ let n = z(r, [t6, e]);
o = hu(n);
} else {
- let n = [t10, 2 * (e - 1)], s = z(ka(r), [t10, e]), a = z(ci(r), [t10, e]), i = vo(Ue(s, [0, 1], [t10, e - 2]), 1), p = oe(vo(Ue(a, [0, 1], [t10, e - 2]), 1), be(-1)), u = gt([s, i], 1), c = gt([a, p], 1), l = z(Er(u, c), [n[0], n[1]]);
+ let n = [t6, 2 * (e - 1)], s = z($a(r), [t6, e]), a = z(Si(r), [t6, e]), i = no(He(s, [0, 1], [t6, e - 2]), 1), p = ae(no(He(a, [0, 1], [t6, e - 2]), 1), be(-1)), u = gt([s, i], 1), c = gt([a, p], 1), l = z(Tr(u, c), [n[0], n[1]]);
o = hu(l);
}
- if (o = ka(o), r.rank === 3 && r.shape[0] !== 0) {
+ if (o = $a(o), r.rank === 3 && r.shape[0] !== 0) {
let n = o, s = r.shape[0];
o = z(o, [s, o.shape[0] / s, o.shape[1]]), n.dispose();
}
return o;
}
-var Gf = T({ irfft_: mH });
-function fH(r, e, t10 = 0) {
- let n = { x: v(r, "x", "split") }, s = { numOrSizeSplits: e, axis: t10 };
- return N.runKernel(Ts, n, s);
+var Fd = N({ irfft_: FG });
+function DG(r, e, t6 = 0) {
+ let n = { x: v(r, "x", "split") }, s = { numOrSizeSplits: e, axis: t6 };
+ return T.runKernel($s, n, s);
}
-var $a = T({ split_: fH });
-function dH(r, e) {
- $(r.dtype === "float32", () => `The dtype for rfft() must be real value but got ${r.dtype}`);
- let t10 = r.shape[r.shape.length - 1], o = r.size / t10, n;
- if (e != null && e < t10) {
- let d = r.shape.map((g) => 0), h = r.shape.map((g) => g);
- h[r.shape.length - 1] = e, n = Ue(r, d, h), t10 = e;
- } else if (e != null && e > t10) {
- let d = r.shape.map((h) => h);
- d[r.shape.length - 1] = e - t10, n = gt([r, Wr(d)], r.shape.length - 1), t10 = e;
+var Oa = N({ split_: DG });
+function OG(r, e) {
+ E(r.dtype === "float32", () => `The dtype for rfft() must be real value but got ${r.dtype}`);
+ let t6 = r.shape[r.shape.length - 1], o = r.size / t6, n;
+ if (e != null && e < t6) {
+ let f = r.shape.map((g) => 0), h = r.shape.map((g) => g);
+ h[r.shape.length - 1] = e, n = He(r, f, h), t6 = e;
+ } else if (e != null && e > t6) {
+ let f = r.shape.map((h) => h);
+ f[r.shape.length - 1] = e - t6, n = gt([r, Vr(f)], r.shape.length - 1), t6 = e;
} else
n = r;
- let s = Gt(n), a = z(Er(n, s), [o, t10]), i = qp(a), p = Math.floor(t10 / 2) + 1, u = ka(i), c = ci(i), l = $a(u, [p, t10 - p], u.shape.length - 1), m = $a(c, [p, t10 - p], c.shape.length - 1), f = n.shape.slice();
- return f[n.shape.length - 1] = p, z(Er(l[0], m[0]), f);
+ let s = Ut(n), a = z(Tr(n, s), [o, t6]), i = zp(a), p = Math.floor(t6 / 2) + 1, u = $a(i), c = Si(i), l = Oa(u, [p, t6 - p], u.shape.length - 1), m = Oa(c, [p, t6 - p], c.shape.length - 1), d = n.shape.slice();
+ return d[n.shape.length - 1] = p, z(Tr(l[0], m[0]), d);
}
-var Kp = T({ rfft_: dH });
-function hH(r, e) {
- let t10 = v(r, "a", "squaredDifference"), o = v(e, "b", "squaredDifference");
- [t10, o] = Re(t10, o), Je(t10.shape, o.shape);
- let n = { a: t10, b: o }, s = {};
- return N.runKernel(Co, n, s);
+var Wp = N({ rfft_: OG });
+function PG(r, e) {
+ let t6 = v(r, "a", "squaredDifference"), o = v(e, "b", "squaredDifference");
+ [t6, o] = Re(t6, o), Je(t6.shape, o.shape);
+ let n = { a: t6, b: o }, s = {};
+ return T.runKernel(Kn, n, s);
}
-var Hf = T({ squaredDifference_: hH });
-function gH(r, e) {
- let t10 = v(r, "x", "squeeze", "string_or_numeric");
- return z(t10, db(t10.shape, e).newShape);
+var Dd = N({ squaredDifference_: PG });
+function MG(r, e) {
+ let t6 = v(r, "x", "squeeze", "string_or_numeric");
+ return z(t6, pb(t6.shape, e).newShape);
}
-var jp = T({ squeeze_: gH });
-function xH(r, e = 0) {
- let t10 = Ia(r, "tensors", "stack", "string_or_numeric");
- $(t10.length >= 1, () => "Pass at least one tensor to tf.stack"), t10.length > 0 && $(e <= t10[0].rank, () => "Axis must be <= rank of the tensor");
- let o = t10, n = { axis: e };
- return N.runKernel(Is, o, n);
+var Up = N({ squeeze_: MG });
+function LG(r, e = 0) {
+ let t6 = Na(r, "tensors", "stack", "string_or_numeric");
+ E(t6.length >= 1, () => "Pass at least one tensor to tf.stack"), t6.length > 0 && E(e <= t6[0].rank, () => "Axis must be <= rank of the tensor");
+ let o = t6, n = { axis: e };
+ return T.runKernel(vs, o, n);
}
-var Ir = T({ stack_: xH });
-function yH(r, e = 0) {
+var Sr = N({ stack_: LG });
+function BG(r, e = 0) {
let o = { x: v(r, "x", "step") }, n = { alpha: e };
- return N.runKernel($s, o, n);
+ return T.runKernel(Ds, o, n);
}
-var qf = T({ step_: yH });
-function bH(r, e, t10, o, n = 0, s = 0, a = 0, i = 0, p = 0) {
- let c = { x: v(r, "x", "stridedSlice", "string_or_numeric") }, l = { begin: e, end: t10, strides: o, beginMask: n, endMask: s, ellipsisMask: a, newAxisMask: i, shrinkAxisMask: p };
- return N.runKernel(Yn, c, l);
+var Od = N({ step_: BG });
+function VG(r, e, t6, o, n = 0, s = 0, a = 0, i = 0, p = 0) {
+ let c = { x: v(r, "x", "stridedSlice", "string_or_numeric") }, l = { begin: e, end: t6, strides: o, beginMask: n, endMask: s, ellipsisMask: a, newAxisMask: i, shrinkAxisMask: p };
+ return T.runKernel(jn, c, l);
}
-var H1 = T({ stridedSlice_: bH });
-function CH(r) {
- let t10 = { x: v(r, "x", "tan", "float32") };
- return N.runKernel(xa, t10);
+var b1 = N({ stridedSlice_: VG });
+function zG(r) {
+ let t6 = { x: v(r, "x", "tan", "float32") };
+ return T.runKernel(Yn, t6);
}
-var q1 = T({ tan_: CH });
+var C1 = N({ tan_: zG });
function mr(r, e) {
- eo(r);
- let t10 = or(r, e);
- if (t10.length !== 1)
+ Jr(r);
+ let t6 = or(r, e);
+ if (t6.length !== 1)
throw new Error("tensor1d() requires values to be a flat/TypedArray");
- return xr(r, null, t10, e);
+ return xr(r, null, t6, e);
}
-function gi(r, e, t10) {
- if (eo(r), e != null && e.length !== 2)
+function _i(r, e, t6) {
+ if (Jr(r), e != null && e.length !== 2)
throw new Error("tensor2d() requires shape to have two numbers");
- let o = or(r, t10);
+ let o = or(r, t6);
if (o.length !== 2 && o.length !== 1)
throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");
if (o.length === 1 && e == null)
throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");
- return xr(r, e, o, t10);
+ return xr(r, e, o, t6);
}
-function K1(r, e, t10) {
- if (eo(r), e != null && e.length !== 4)
+function S1(r, e, t6) {
+ if (Jr(r), e != null && e.length !== 4)
throw new Error("tensor4d() requires shape to have four numbers");
- let o = or(r, t10);
+ let o = or(r, t6);
if (o.length !== 4 && o.length !== 1)
throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");
if (o.length === 1 && e == null)
throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");
- return xr(r, e, o, t10);
+ return xr(r, e, o, t6);
}
-function j1(r, e, t10) {
- if (eo(r), e != null && e.length !== 5)
+function w1(r, e, t6) {
+ if (Jr(r), e != null && e.length !== 5)
throw new Error("tensor5d() requires shape to have five numbers");
- let o = or(r, t10);
+ let o = or(r, t6);
if (o.length !== 5 && o.length !== 1)
throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");
if (o.length === 1 && e == null)
throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");
- return xr(r, e, o, t10);
+ return xr(r, e, o, t6);
}
-function X1(r, e, t10) {
- if (eo(r), e != null && e.length !== 6)
+function I1(r, e, t6) {
+ if (Jr(r), e != null && e.length !== 6)
throw new Error("tensor6d() requires shape to have six numbers");
- let o = or(r, t10);
+ let o = or(r, t6);
if (o.length !== 6 && o.length !== 1)
throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");
if (o.length === 1 && e == null)
throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");
- return e = e || o, xr(r, e, o, t10);
+ return e = e || o, xr(r, e, o, t6);
}
-function IH(r, e = 1, t10 = true) {
+function WG(r, e = 1, t6 = true) {
let o = v(r, "x", "topk");
if (o.rank === 0)
throw new Error("topk() expects the input to be of rank 1 or higher");
@@ -7772,751 +7780,753 @@ function IH(r, e = 1, t10 = true) {
throw new Error(`'k' passed to topk() must be >= 0 but got ${e}`);
if (e > n)
throw new Error(`'k' passed to topk() must be <= the last dimension (${n}) but got ${e}`);
- let s = { x: o }, a = { k: e, sorted: t10 }, [i, p] = N.runKernel(Zn, s, a);
+ let s = { x: o }, a = { k: e, sorted: t6 }, [i, p] = T.runKernel(Zn, s, a);
return { values: i, indices: p };
}
-var Y1 = T({ topk_: IH });
-function wH(r, e = 0, t10 = 1, o, n) {
- if (o != null && o === "bool")
+var v1 = N({ topk_: WG });
+function UG(r, e = 0, t6 = 1, o, n) {
+ if (yt(r), o != null && o === "bool")
throw new Error("Unsupported data type $ { dtype }");
- let s = new du(e, t10, o, true, n), a = ne(r, o);
+ let s = new fu(e, t6, o, true, n), a = le(r, o);
for (let i = 0; i < a.values.length; i++)
a.values[i] = s.nextValue();
return a.toTensor();
}
-var Q1 = T({ truncatedNormal_: wH });
-function SH(r, e = 0) {
- let t10 = v(r, "x", "unique", "string_or_numeric");
- $(t10.rank > 0, () => "The input tensor must be at least 1D");
- let o = { x: t10 }, n = { axis: e }, [s, a] = N.runKernel($p, o, n);
+var k1 = N({ truncatedNormal_: UG });
+function GG(r, e = 0) {
+ let t6 = v(r, "x", "unique", "string_or_numeric");
+ E(t6.rank > 0, () => "The input tensor must be at least 1D");
+ let o = { x: t6 }, n = { axis: e }, [s, a] = T.runKernel(kp, o, n);
return { values: s, indices: a };
}
-var Z1 = T({ unique_: SH });
-function vH(r, e, t10) {
+var N1 = N({ unique_: GG });
+function HG(r, e, t6) {
let o = v(r, "x", "unsortedSegmentSum"), n = v(e, "segmentIds", "unsortedSegmentSum", "int32");
- $(ra(t10), () => "numSegments must be of dtype int");
- let s = { x: o, segmentIds: n }, a = { numSegments: t10 };
- return N.runKernel(Rp, s, a);
+ E(na(t6), () => "numSegments must be of dtype int");
+ let s = { x: o, segmentIds: n }, a = { numSegments: t6 };
+ return T.runKernel(Np, s, a);
}
-var J1 = T({ unsortedSegmentSum_: vH });
-function kH(r, e = 0) {
- let t10 = v(r, "x", "unstack", "string_or_numeric");
- $(e >= -t10.shape.length && e < t10.shape.length, () => `Axis = ${e} is not in [-${t10.shape.length}, ${t10.shape.length})`);
- let o = { value: t10 }, n = { axis: e };
- return N.runKernel(_s, o, n);
+var T1 = N({ unsortedSegmentSum_: HG });
+function qG(r, e = 0) {
+ let t6 = v(r, "x", "unstack", "string_or_numeric");
+ E(e >= -t6.shape.length && e < t6.shape.length, () => `Axis = ${e} is not in [-${t6.shape.length}, ${t6.shape.length})`);
+ let o = { value: t6 }, n = { axis: e };
+ return T.runKernel(Rs, o, n);
}
-var ko = T({ unstack_: kH });
-function eT(r, e) {
- return dl(r, e, "right");
+var so = N({ unstack_: qG });
+function _1(r, e) {
+ return al(r, e, "right");
}
-function tT(r, e = true, t10, o) {
- return N.makeVariable(r, e, t10, o);
+function E1(r, e = true, t6, o) {
+ return T.makeVariable(r, e, t6, o);
}
-function Kf(r, e) {
- let t10 = [];
+function Pd(r, e) {
+ let t6 = [];
for (let s = 0; s < e.length; s++)
- e[s] && t10.push(s);
- let o = ne(r, "int32"), n = ne([t10.length, r.length], "int32");
- for (let s = 0; s < t10.length; s++) {
- let a = o.indexToLoc(t10[s]), i = s * r.length;
+ e[s] && t6.push(s);
+ let o = le(r, "int32"), n = le([t6.length, r.length], "int32");
+ for (let s = 0; s < t6.length; s++) {
+ let a = o.indexToLoc(t6[s]), i = s * r.length;
n.values.set(a, i);
}
return n.toTensor();
}
-async function TH(r) {
- let e = v(r, "condition", "whereAsync", "bool"), t10 = await e.data(), o = Kf(e.shape, t10);
+async function KG(r) {
+ let e = v(r, "condition", "whereAsync", "bool"), t6 = await e.data(), o = Pd(e.shape, t6);
return r !== e && e.dispose(), o;
}
-var jf = TH;
-async function NH(r, e, t10) {
- let o = v(r, "tensor", "boolMask"), n = v(e, "mask", "boolMask", "bool"), s = t10 == null ? 0 : t10, a = n.rank, i = o.shape;
- $(a > 0, () => "mask cannot be scalar"), ht(i.slice(s, s + a), n.shape, "mask's shape must match the first K dimensions of tensor's shape,");
+var Md = KG;
+async function jG(r, e, t6) {
+ let o = v(r, "tensor", "boolMask"), n = v(e, "mask", "boolMask", "bool"), s = t6 == null ? 0 : t6, a = n.rank, i = o.shape;
+ E(a > 0, () => "mask cannot be scalar"), ht(i.slice(s, s + a), n.shape, "mask's shape must match the first K dimensions of tensor's shape,");
let p = 1;
for (let h = s; h < s + a; h++)
p *= i[h];
- let u = i.slice(0, s).concat([p], i.slice(s + a)), c = z(o, u), l = z(n, [-1]), m = await jf(l), f = jp(m, [1]), d = Cf(c, f, s);
- return r !== o && o.dispose(), e !== n && n.dispose(), f.dispose(), c.dispose(), l.dispose(), m.dispose(), d;
+ let u = i.slice(0, s).concat([p], i.slice(s + a)), c = z(o, u), l = z(n, [-1]), m = await Md(l), d = Up(m, [1]), f = pd(c, d, s);
+ return r !== o && o.dispose(), e !== n && n.dispose(), d.dispose(), c.dispose(), l.dispose(), m.dispose(), f;
}
-var _H = NH;
-function EH(r, e, t10, o, n = true) {
- let s = v(r, "v", "movingAverage"), a = v(e, "x", "movingAverage"), i = v(t10, "decay", "movingAverage");
- Lb(s, a), $(Or(s.shape, a.shape), () => "Shape mismatch in v and x");
- let p = be(1), u = ke(p, i), c = oe(ke(a, s), u);
+var XG = jG;
+function YG(r, e, t6, o, n = true) {
+ let s = v(r, "v", "movingAverage"), a = v(e, "x", "movingAverage"), i = v(t6, "decay", "movingAverage");
+ Fb(s, a), E(Pr(s.shape, a.shape), () => "Shape mismatch in v and x");
+ let p = be(1), u = Ne(p, i), c = ae(Ne(a, s), u);
if (n) {
- $(o != null, () => "When using zeroDebias: true, step is required.");
+ E(o != null, () => "When using zeroDebias: true, step is required.");
let l = v(o, "step", "movingAverage");
- c = We(c, ke(p, Na(i, l)));
+ c = Ge(c, Ne(p, Ra(i, l)));
}
- return ge(s, c);
+ return xe(s, c);
}
-var $H = T({ movingAverage_: EH });
-function RH(r, e, t10) {
+var QG = N({ movingAverage_: YG });
+function ZG(r, e, t6) {
+ yt(t6);
let o = v(r, "indices", "scatterND", "int32"), n = v(e, "updates", "scatterND");
- uf(n, o, t10);
- let s = { indices: o, updates: n }, a = { shape: t10 };
- return N.runKernel(Hn, s, a);
+ Qm(n, o, t6);
+ let s = { indices: o, updates: n }, a = { shape: t6 };
+ return T.runKernel(zn, s, a);
}
-var AH = T({ scatterND_: RH });
-function rT(r, e, t10, o) {
+var JG = N({ scatterND_: ZG });
+function $1(r, e, t6, o) {
if (r.dtype !== "int32")
throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${r.dtype}.`);
if (r.rank > 2)
throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${r.shape}.`);
let n = r.rank > 0 ? r.shape[0] : 1, s = r.rank > 1 ? r.shape[1] : 1;
- if (t10.length !== s)
- throw new Error(`outputShape has incorrect number of elements:, ${t10.length}, should be: ${s}.`);
+ if (t6.length !== s)
+ throw new Error(`outputShape has incorrect number of elements:, ${t6.length}, should be: ${s}.`);
let a = e.size;
if (!(e.rank === 0 || e.rank === 1 && a === n))
throw new Error(`sparseValues has incorrect shape ${e.shape}, should be [] or [${n}]`);
if (e.dtype !== o.dtype)
throw new Error("sparseValues.dtype must match defaultValues.dtype");
}
-function DH(r, e, t10, o = 0) {
+function tH(r, e, t6, o = 0) {
+ yt(t6);
let n = v(r, "sparseIndices", "sparseToDense", "int32"), s = v(e, "sparseValues", "sparseToDense", "string_or_numeric"), a = v(o, "defaultValue", "sparseToDense", s.dtype);
- rT(n, s, t10, a);
- let i = { sparseIndices: n, sparseValues: s, defaultValue: a }, p = { outputShape: t10 };
- return N.runKernel(ei, i, p);
+ $1(n, s, t6, a);
+ let i = { sparseIndices: n, sparseValues: s, defaultValue: a }, p = { outputShape: t6 };
+ return T.runKernel(li, i, p);
}
-var PH = T({ sparseToDense_: DH });
-function OH(r, e) {
- let t10 = v(e, "indices", "gatherND", "int32"), n = { params: v(r, "x", "gatherND", "string_or_numeric"), indices: t10 };
- return N.runKernel(Tn, n);
+var rH = N({ sparseToDense_: tH });
+function oH(r, e) {
+ let t6 = v(e, "indices", "gatherND", "int32"), n = { params: v(r, "x", "gatherND", "string_or_numeric"), indices: t6 };
+ return T.runKernel(un, n);
}
-var MH = T({ gatherND_: OH });
-function oT(r, e) {
+var nH = N({ gatherND_: oH });
+function A1(r, e) {
if (e == null)
return r.shape.slice();
- if (Or(r.shape, e))
+ if (Pr(r.shape, e))
return e;
if (r.shape.length === e.length) {
- let t10 = [];
+ let t6 = [];
for (let o = 0; o < r.shape.length; o++)
- e[o] == null && r.shape[o] != null ? t10.push(r.shape[o]) : t10.push(e[o]);
- return t10;
+ e[o] == null && r.shape[o] != null ? t6.push(r.shape[o]) : t6.push(e[o]);
+ return t6;
}
return e;
}
-function LH(r, e, t10, o) {
+function sH(r, e, t6, o) {
let n = v(r, "x", "dropout");
- if ($(n.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${n.dtype} tensor instead.`), $(e >= 0 && e < 1, () => `rate must be a float in the range [0, 1), but got ${e}.`), e === 0)
- return r instanceof ut ? n.clone() : n;
- let s = oT(n, t10), a = 1 - e, i = We(bf(ge(zf(s, 0, 1, "float32", o), a)), a);
- return oe(n, i);
+ if (E(n.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${n.dtype} tensor instead.`), E(e >= 0 && e < 1, () => `rate must be a float in the range [0, 1), but got ${e}.`), e === 0)
+ return r instanceof it ? n.clone() : n;
+ let s = A1(n, t6), a = 1 - e, i = Ge(ud(xe($d(s, 0, 1, "float32", o), a)), a);
+ return ae(n, i);
}
-var BH = T({ dropout_: LH });
-function wC(r) {
+var aH = N({ dropout_: sH });
+function xC(r) {
return Math.floor(Math.pow(2, Math.ceil(Math.log(r) / Math.log(2))));
}
-function hl(r, e, t10) {
+function il(r, e, t6) {
let o = 1 - r % 2, n = new Float32Array(r);
for (let s = 0; s < r; ++s) {
let a = 2 * Math.PI * s / (r + o - 1);
- n[s] = e - t10 * Math.cos(a);
+ n[s] = e - t6 * Math.cos(a);
}
return mr(n, "float32");
}
-async function VH(r, e, t10 = 1) {
+async function iH(r, e, t6 = 1) {
let o = v(r, "predictions", "inTopK"), n = v(e, "targets", "inTopK");
- $(o.rank > 1, () => `inTopK() expects the predictions to be of rank 2 or higher, but got ${o.rank}`), $(o.rank - 1 === n.rank, () => `predictions rank should be 1 larger than targets rank, but got predictions rank ${o.rank} and targets rank ${n.rank}`), ht(o.shape.slice(0, o.shape.length - 1), n.shape, "predictions's shape should be align with the targets' shape, except the last dimension.");
+ E(o.rank > 1, () => `inTopK() expects the predictions to be of rank 2 or higher, but got ${o.rank}`), E(o.rank - 1 === n.rank, () => `predictions rank should be 1 larger than targets rank, but got predictions rank ${o.rank} and targets rank ${n.rank}`), ht(o.shape.slice(0, o.shape.length - 1), n.shape, "predictions's shape should be align with the targets' shape, except the last dimension.");
let s = o.shape[o.shape.length - 1];
- $(t10 > 0 && t10 <= s, () => `'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${s}), but got ${t10}`);
- let a = await o.data(), i = await n.data(), [p, u] = [a.length / s, s], c = hb("bool", p);
+ E(t6 > 0 && t6 <= s, () => `'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${s}), but got ${t6}`);
+ let a = await o.data(), i = await n.data(), [p, u] = [a.length / s, s], c = cb("bool", p);
for (let l = 0; l < p; l++) {
- let m = l * u, f = a.subarray(m, m + u), d = [];
- for (let h = 0; h < f.length; h++)
- d.push({ value: f[h], index: h });
- d.sort((h, g) => g.value - h.value), c[l] = 0;
- for (let h = 0; h < t10; h++)
- if (d[h].index === i[l]) {
+ let m = l * u, d = a.subarray(m, m + u), f = [];
+ for (let h = 0; h < d.length; h++)
+ f.push({ value: d[h], index: h });
+ f.sort((h, g) => g.value - h.value), c[l] = 0;
+ for (let h = 0; h < t6; h++)
+ if (f[h].index === i[l]) {
c[l] = 1;
break;
}
}
return r !== o && o.dispose(), e !== n && n.dispose(), nr(c, n.shape, "bool");
}
-var zH = VH;
-var SC = {};
-Be(SC, { conv2d: () => sT, depthwiseConv2d: () => uT, matMul: () => pT });
-function WH(r, e, t10, o, n, s = "NHWC", a) {
+var uH = iH;
+var yC = {};
+Ue(yC, { conv2d: () => F1, depthwiseConv2d: () => P1, matMul: () => M1 });
+function pH(r, e, t6, o, n, s = "NHWC", a) {
let i = r;
r.rank === 3 && (i = z(r, [1, r.shape[0], r.shape[1], r.shape[2]]));
let p = e;
- p.rank === 3 && (p = z(e, [1, e.shape[0], e.shape[1], e.shape[2]])), $(i.rank === 4, () => `Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`), $(p.rank === 4, () => `Error in conv2dDerFilter: dy must be rank 4, but got shape ${p.shape}.`), $(t10.length === 4, () => `Error in conv2dDerFilter: filterShape must be length 4, but got ${t10}.`);
+ p.rank === 3 && (p = z(e, [1, e.shape[0], e.shape[1], e.shape[2]])), E(i.rank === 4, () => `Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`), E(p.rank === 4, () => `Error in conv2dDerFilter: dy must be rank 4, but got shape ${p.shape}.`), E(t6.length === 4, () => `Error in conv2dDerFilter: filterShape must be length 4, but got ${t6}.`);
let u = s === "NHWC" ? i.shape[3] : i.shape[1], c = s === "NHWC" ? p.shape[3] : p.shape[1];
- $(u === t10[2], () => `Error in conv2dDerFilter: depth of input ${u}) must match input depth in filter (${t10[2]}.`), $(c === t10[3], () => `Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${t10[3]}).`), Ot("conv2dDerFilter", n, a);
- let l = { x: i, dy: p }, m = { strides: o, pad: n, dataFormat: s, dimRoundingMode: a, filterShape: t10 };
- return N.runKernel(lp, l, m);
+ E(u === t6[2], () => `Error in conv2dDerFilter: depth of input ${u}) must match input depth in filter (${t6[2]}.`), E(c === t6[3], () => `Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${t6[3]}).`), Pt("conv2dDerFilter", n, a);
+ let l = { x: i, dy: p }, m = { strides: o, pad: n, dataFormat: s, dimRoundingMode: a, filterShape: t6 };
+ return T.runKernel(cp, l, m);
}
-var nT = T({ conv2DBackpropFilter_: WH });
-function gu(r, e, t10) {
- if (t10 == null || t10 === "linear")
+var R1 = N({ conv2DBackpropFilter_: pH });
+function gu(r, e, t6) {
+ if (t6 == null || t6 === "linear")
return r;
- if (t10 === "relu")
- return oe(r, qf(e));
- throw new Error(`Cannot compute gradient for fused activation ${t10}.`);
+ if (t6 === "relu")
+ return ae(r, Od(e));
+ throw new Error(`Cannot compute gradient for fused activation ${t6}.`);
}
function xu(r, e) {
- let t10 = e, o = nf(r.shape, e.shape);
- return o.length > 0 && (t10 = tt(t10, o)), z(t10, r.shape);
+ let t6 = e, o = jm(r.shape, e.shape);
+ return o.length > 0 && (t6 = et(t6, o)), z(t6, r.shape);
}
-function yu(r, e, t10, o) {
+function yu(r, e, t6, o) {
if (e === "linear")
return r;
if (e === "relu")
- return hi(r);
+ return Ti(r);
if (e === "elu")
- return xf(r);
+ return ad(r);
if (e === "relu6")
- return Wf(r);
+ return Ad(r);
if (e === "prelu")
- return Pf(r, t10);
+ return vd(r, t6);
if (e === "leakyrelu")
- return wf(r, o);
+ return ld(r, o);
if (e === "sigmoid")
- return Ms(r);
+ return zs(r);
throw new Error(`Unknown fused activation ${e}.`);
}
var bu = (r, e) => !(r > 0) || e === "linear";
-function UH({ x: r, filter: e, strides: t10, pad: o, dataFormat: n = "NHWC", dilations: s = [1, 1], dimRoundingMode: a, bias: i, activation: p = "linear", preluActivationWeights: u, leakyreluAlpha: c }) {
- if (p = p || "linear", bu(N.state.gradientDepth, p) === false) {
- $(n === "NHWC", () => `Error in fused conv2d: got dataFormat of ${n} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);
- let _ = mi(r, e, t10, o, n, s, a);
- return i != null && (_ = ge(_, i)), yu(_, p, u, c);
+function cH({ x: r, filter: e, strides: t6, pad: o, dataFormat: n = "NHWC", dilations: s = [1, 1], dimRoundingMode: a, bias: i, activation: p = "linear", preluActivationWeights: u, leakyreluAlpha: c }) {
+ if (p = p || "linear", bu(T.state.gradientDepth, p) === false) {
+ E(n === "NHWC", () => `Error in fused conv2d: got dataFormat of ${n} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);
+ let _ = vi(r, e, t6, o, n, s, a);
+ return i != null && (_ = xe(_, i)), yu(_, p, u, c);
}
- let l = v(r, "x", "conv2d", "float32"), m = v(e, "filter", "conv2d", "float32"), f = l, d = false;
- l.rank === 3 && (d = true, f = z(l, [1, l.shape[0], l.shape[1], l.shape[2]])), $(f.rank === 4, () => `Error in fused conv2d: input must be rank 4, but got rank ${f.rank}.`), $(m.rank === 4, () => `Error in fused conv2d: filter must be rank 4, but got rank ${m.rank}.`), Ot("fused conv2d", o, a);
- let h = n === "NHWC" ? f.shape[3] : f.shape[1];
- $(m.shape[2] === h, () => `Error in conv2d: depth of input (${h}) must match input depth for filter ${m.shape[2]}.`), $(lr(t10, s), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${t10} and dilations '${s}'`);
- let g = uu(f.shape, m.shape, t10, s, o, a), y;
- i != null && (y = v(i, "bias", "fused conv2d"), [y] = Re(y, l), n === "NHWC" ? Je(g.outShape, y.shape) : ($(y.shape.length <= 1, () => `Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${y.shape.length}.`), $(y.shape.length === 0 || y.shape[0] === g.outChannels || y.shape[0] === 1, () => `Error in fused conv2d: bias shape (${y.shape}) is not compatible with the number of output channels (${g.outChannels})`)));
+ let l = v(r, "x", "conv2d", "float32"), m = v(e, "filter", "conv2d", "float32"), d = l, f = false;
+ l.rank === 3 && (f = true, d = z(l, [1, l.shape[0], l.shape[1], l.shape[2]])), E(d.rank === 4, () => `Error in fused conv2d: input must be rank 4, but got rank ${d.rank}.`), E(m.rank === 4, () => `Error in fused conv2d: filter must be rank 4, but got rank ${m.rank}.`), Pt("fused conv2d", o, a);
+ let h = n === "NHWC" ? d.shape[3] : d.shape[1];
+ E(m.shape[2] === h, () => `Error in conv2d: depth of input (${h}) must match input depth for filter ${m.shape[2]}.`), E(lr(t6, s), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${t6} and dilations '${s}'`);
+ let g = uu(d.shape, m.shape, t6, s, o, a), x;
+ i != null && (x = v(i, "bias", "fused conv2d"), [x] = Re(x, l), n === "NHWC" ? Je(g.outShape, x.shape) : (E(x.shape.length <= 1, () => `Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${x.shape.length}.`), E(x.shape.length === 0 || x.shape[0] === g.outChannels || x.shape[0] === 1, () => `Error in fused conv2d: bias shape (${x.shape}) is not compatible with the number of output channels (${g.outChannels})`)));
let b;
if (u != null) {
let _ = u.shape;
- if ($(_.length <= 1 || _.length === 3, () => `Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${_.length}.`), _.length === 1)
- $(_[0] === 1 || _[0] === g.outChannels, () => `Error in fused conv2d: PReLU activation weights (${_}) is not compatible with the number of output channels (${g.outChannels}).`);
+ if (E(_.length <= 1 || _.length === 3, () => `Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${_.length}.`), _.length === 1)
+ E(_[0] === 1 || _[0] === g.outChannels, () => `Error in fused conv2d: PReLU activation weights (${_}) is not compatible with the number of output channels (${g.outChannels}).`);
else if (_.length === 3)
try {
Je(_, g.outShape);
- } catch (E) {
- let R = `Error in fused conv2d: PReLU activation weights (${_}) is not compatible with the output shape of the conv2d (${g.outShape}).`;
- throw Error(R);
+ } catch ($) {
+ let A = `Error in fused conv2d: PReLU activation weights (${_}) is not compatible with the output shape of the conv2d (${g.outShape}).`;
+ throw Error(A);
}
b = v(u, "prelu weights", "fused conv2d");
}
- let C = (_, E) => {
- $(n === "NHWC", () => `Error in gradient of fused conv2D: got dataFormat of ${n} but only NHWC is currently supported.`);
- let [R, A, D, O] = E, M = gu(_, D, p);
- $(iu(s), () => `Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);
- let L = hf(A.shape, M, R, t10, o), W = nT(A, M, R.shape, t10, o), V = [L, W];
- if (O != null) {
- let G = xu(O, M);
- V.push(G);
+ let C = (_, $) => {
+ E(n === "NHWC", () => `Error in gradient of fused conv2D: got dataFormat of ${n} but only NHWC is currently supported.`);
+ let [A, R, D, P] = $, M = gu(_, D, p);
+ E(iu(s), () => `Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);
+ let L = nd(R.shape, M, A, t6, o), W = R1(R, M, A.shape, t6, o), V = [L, W];
+ if (P != null) {
+ let U = xu(P, M);
+ V.push(U);
}
return V;
- }, w = { x: f, filter: m, bias: y, preluActivationWeights: b }, k = { strides: t10, pad: o, dataFormat: n, dilations: s, dimRoundingMode: a, activation: p, leakyreluAlpha: c };
- return i == null ? Cr((E, R, A) => {
- let D = N.runKernel(Do, w, k);
- return A([R, E, D]), d && (D = z(D, [D.shape[1], D.shape[2], D.shape[3]])), { value: D, gradFunc: C };
- })(f, m) : Cr((E, R, A, D) => {
- let O = N.runKernel(Do, w, k);
- return D([R, E, O, A]), d && (O = z(O, [O.shape[1], O.shape[2], O.shape[3]])), { value: O, gradFunc: C };
- })(f, m, y);
+ }, w = { x: d, filter: m, bias: x, preluActivationWeights: b }, k = { strides: t6, pad: o, dataFormat: n, dilations: s, dimRoundingMode: a, activation: p, leakyreluAlpha: c };
+ return i == null ? Cr(($, A, R) => {
+ let D = T.runKernel(ho, w, k);
+ return R([A, $, D]), f && (D = z(D, [D.shape[1], D.shape[2], D.shape[3]])), { value: D, gradFunc: C };
+ })(d, m) : Cr(($, A, R, D) => {
+ let P = T.runKernel(ho, w, k);
+ return D([A, $, P, R]), f && (P = z(P, [P.shape[1], P.shape[2], P.shape[3]])), { value: P, gradFunc: C };
+ })(d, m, x);
}
-var sT = T({ fusedConv2d_: UH });
-function GH(r, e, t10, o, n, s = [1, 1], a) {
+var F1 = N({ fusedConv2d_: cH });
+function lH(r, e, t6, o, n, s = [1, 1], a) {
let i = r;
r.rank === 3 && (i = z(r, [1, r.shape[0], r.shape[1], r.shape[2]]));
let p = e;
p.rank === 3 && (p = z(e, [1, e.shape[0], e.shape[1], e.shape[2]]));
- let u = { x: i, dy: p }, c = { strides: o, pad: n, dimRoundingMode: a, dilations: s, filterShape: t10 };
- return N.runKernel(hp, u, c);
+ let u = { x: i, dy: p }, c = { strides: o, pad: n, dimRoundingMode: a, dilations: s, filterShape: t6 };
+ return T.runKernel(dp, u, c);
}
-var aT = T({ depthwiseConv2dNativeBackpropFilter_: GH });
-function HH(r, e, t10, o, n, s = [1, 1], a) {
+var D1 = N({ depthwiseConv2dNativeBackpropFilter_: lH });
+function mH(r, e, t6, o, n, s = [1, 1], a) {
let i = e, p = false;
e.rank === 3 && (p = true, i = z(e, [1, e.shape[0], e.shape[1], e.shape[2]]));
- let u = { dy: i, filter: t10 }, c = { strides: o, pad: n, dimRoundingMode: a, dilations: s, inputShape: r }, l = N.runKernel(gp, u, c);
+ let u = { dy: i, filter: t6 }, c = { strides: o, pad: n, dimRoundingMode: a, dilations: s, inputShape: r }, l = T.runKernel(fp, u, c);
return p ? z(l, [l.shape[1], l.shape[2], l.shape[3]]) : l;
}
-var iT = T({ depthwiseConv2dNativeBackpropInput_: HH });
-function qH({ x: r, filter: e, strides: t10, pad: o, dataFormat: n = "NHWC", dilations: s = [1, 1], dimRoundingMode: a, bias: i, activation: p = "linear", preluActivationWeights: u, leakyreluAlpha: c }) {
- if (bu(N.state.gradientDepth, p) === false) {
- let k = Gp(r, e, t10, o, n, s, a);
- return i != null && (k = ge(k, i)), yu(k, p, u, c);
+var O1 = N({ depthwiseConv2dNativeBackpropInput_: mH });
+function dH({ x: r, filter: e, strides: t6, pad: o, dataFormat: n = "NHWC", dilations: s = [1, 1], dimRoundingMode: a, bias: i, activation: p = "linear", preluActivationWeights: u, leakyreluAlpha: c }) {
+ if (bu(T.state.gradientDepth, p) === false) {
+ let k = Bp(r, e, t6, o, n, s, a);
+ return i != null && (k = xe(k, i)), yu(k, p, u, c);
}
- let l = v(r, "x", "depthwiseConv2d", "float32"), m = v(e, "filter", "depthwiseConv2d", "float32"), f = l, d = false;
- l.rank === 3 && (d = true, f = z(l, [1, l.shape[0], l.shape[1], l.shape[2]])), $(f.rank === 4, () => `Error in fused depthwiseConv2d: input must be rank 4, but got rank ${f.rank}.`), $(m.rank === 4, () => `Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${m.rank}.`), $(f.shape[3] === m.shape[2], () => `Error in fused depthwiseConv2d: number of input channels (${f.shape[3]}) must match the inChannels dimension in filter ${m.shape[2]}.`), s == null && (s = [1, 1]), $(lr(t10, s), () => `Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${t10} and dilations '${s}'`), Ot("fused depthwiseConv2d", o, a);
- let h = uu(f.shape, m.shape, t10, s, o, a, true), g;
+ let l = v(r, "x", "depthwiseConv2d", "float32"), m = v(e, "filter", "depthwiseConv2d", "float32"), d = l, f = false;
+ l.rank === 3 && (f = true, d = z(l, [1, l.shape[0], l.shape[1], l.shape[2]])), E(d.rank === 4, () => `Error in fused depthwiseConv2d: input must be rank 4, but got rank ${d.rank}.`), E(m.rank === 4, () => `Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${m.rank}.`), E(d.shape[3] === m.shape[2], () => `Error in fused depthwiseConv2d: number of input channels (${d.shape[3]}) must match the inChannels dimension in filter ${m.shape[2]}.`), s == null && (s = [1, 1]), E(lr(t6, s), () => `Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${t6} and dilations '${s}'`), Pt("fused depthwiseConv2d", o, a);
+ let h = uu(d.shape, m.shape, t6, s, o, a, true), g;
i != null && (g = v(i, "bias", "fused conv2d"), [g] = Re(g, l), Je(h.outShape, g.shape));
- let y;
- u != null && (y = v(u, "prelu weights", "fused depthwiseConv2d"));
+ let x;
+ u != null && (x = v(u, "prelu weights", "fused depthwiseConv2d"));
let b = (k, _) => {
- $(iu(s), () => `Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`);
- let [E, R, A, D] = _, O = gu(k, A, p), M = iT(R.shape, O, E, t10, o, s, a), L = aT(R, O, E.shape, t10, o, s, a);
+ E(iu(s), () => `Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`);
+ let [$, A, R, D] = _, P = gu(k, R, p), M = O1(A.shape, P, $, t6, o, s, a), L = D1(A, P, $.shape, t6, o, s, a);
if (D != null) {
- let W = xu(g, O);
+ let W = xu(g, P);
return [M, L, W];
}
return [M, L];
- }, C = { x: f, filter: m, bias: g, preluActivationWeights: y }, w = { strides: t10, pad: o, dataFormat: n, dilations: s, dimRoundingMode: a, activation: p, leakyreluAlpha: c };
- return i == null ? Cr((_, E, R) => {
- let A = N.runKernel(Po, C, w);
- return R([E, _, A]), d && (A = z(A, [A.shape[1], A.shape[2], A.shape[3]])), { value: A, gradFunc: b };
- })(f, m) : Cr((_, E, R, A) => {
- let D = N.runKernel(Po, C, w);
- return A([E, _, D, R]), d && (D = z(D, [D.shape[1], D.shape[2], D.shape[3]])), { value: D, gradFunc: b };
- })(f, m, g);
+ }, C = { x: d, filter: m, bias: g, preluActivationWeights: x }, w = { strides: t6, pad: o, dataFormat: n, dilations: s, dimRoundingMode: a, activation: p, leakyreluAlpha: c };
+ return i == null ? Cr((_, $, A) => {
+ let R = T.runKernel(go, C, w);
+ return A([$, _, R]), f && (R = z(R, [R.shape[1], R.shape[2], R.shape[3]])), { value: R, gradFunc: b };
+ })(d, m) : Cr((_, $, A, R) => {
+ let D = T.runKernel(go, C, w);
+ return R([$, _, D, A]), f && (D = z(D, [D.shape[1], D.shape[2], D.shape[3]])), { value: D, gradFunc: b };
+ })(d, m, g);
}
-var uT = T({ fusedDepthwiseConv2d_: qH });
-function KH({ a: r, b: e, transposeA: t10 = false, transposeB: o = false, bias: n, activation: s = "linear", preluActivationWeights: a, leakyreluAlpha: i = 0.2 }) {
- if (bu(N.state.gradientDepth, s) === false) {
- let O = Xe(r, e, t10, o);
- return n != null && (O = ge(O, n)), yu(O, s, a, i);
+var P1 = N({ fusedDepthwiseConv2d_: dH });
+function fH({ a: r, b: e, transposeA: t6 = false, transposeB: o = false, bias: n, activation: s = "linear", preluActivationWeights: a, leakyreluAlpha: i = 0.2 }) {
+ if (bu(T.state.gradientDepth, s) === false) {
+ let P = Xe(r, e, t6, o);
+ return n != null && (P = xe(P, n)), yu(P, s, a, i);
}
let p = v(r, "a", "fused matMul"), u = v(e, "b", "fused matMul");
[p, u] = Re(p, u);
- let c = t10 ? p.shape[p.rank - 2] : p.shape[p.rank - 1], l = o ? u.shape[u.rank - 1] : u.shape[u.rank - 2], m = t10 ? p.shape[p.rank - 1] : p.shape[p.rank - 2], f = o ? u.shape[u.rank - 2] : u.shape[u.rank - 1], d = p.shape.slice(0, -2), h = u.shape.slice(0, -2), g = Ve(d), y = Ve(h);
- $(c === l, () => `Error in fused matMul: inner shapes (${c}) and (${l}) of Tensors with shapes ${p.shape} and ${u.shape} and transposeA=${t10} and transposeB=${o} must match.`);
- let C = Je(p.shape.slice(0, -2), u.shape.slice(0, -2)).concat([m, f]), w = t10 ? z(p, [g, c, m]) : z(p, [g, m, c]), k = o ? z(u, [y, f, l]) : z(u, [y, l, f]), _;
+ let c = t6 ? p.shape[p.rank - 2] : p.shape[p.rank - 1], l = o ? u.shape[u.rank - 1] : u.shape[u.rank - 2], m = t6 ? p.shape[p.rank - 1] : p.shape[p.rank - 2], d = o ? u.shape[u.rank - 2] : u.shape[u.rank - 1], f = p.shape.slice(0, -2), h = u.shape.slice(0, -2), g = ze(f), x = ze(h);
+ E(c === l, () => `Error in fused matMul: inner shapes (${c}) and (${l}) of Tensors with shapes ${p.shape} and ${u.shape} and transposeA=${t6} and transposeB=${o} must match.`);
+ let C = Je(p.shape.slice(0, -2), u.shape.slice(0, -2)).concat([m, d]), w = t6 ? z(p, [g, c, m]) : z(p, [g, m, c]), k = o ? z(u, [x, d, l]) : z(u, [x, l, d]), _;
n != null && (_ = v(n, "bias", "fused matMul"), [_] = Re(_, p), Je(C, _.shape));
- let E;
- a != null && (E = v(a, "prelu weights", "fused matMul"));
- let R = (O, M) => {
- let [L, W, V, G] = M, q = gu(z(O, V.shape), V, s), H, j;
- if (!t10 && !o ? (H = Xe(q, W, false, true), j = Xe(L, q, true, false)) : !t10 && o ? (H = Xe(q, W, false, false), j = Xe(q, L, true, false)) : t10 && !o ? (H = Xe(W, q, false, true), j = Xe(L, q, false, false)) : (H = Xe(W, q, true, true), j = Xe(q, L, true, true)), n != null) {
- let Y = xu(G, q);
- return [H, j, Y];
+ let $;
+ a != null && ($ = v(a, "prelu weights", "fused matMul"));
+ let A = (P, M) => {
+ let [L, W, V, U] = M, q = gu(z(P, V.shape), V, s), H, j;
+ if (!t6 && !o ? (H = Xe(q, W, false, true), j = Xe(L, q, true, false)) : !t6 && o ? (H = Xe(q, W, false, false), j = Xe(q, L, true, false)) : t6 && !o ? (H = Xe(W, q, false, true), j = Xe(L, q, false, false)) : (H = Xe(W, q, true, true), j = Xe(q, L, true, true)), n != null) {
+ let X = xu(U, q);
+ return [H, j, X];
} else
return [H, j];
- }, A = { a: w, b: k, bias: _, preluActivationWeights: E }, D = { transposeA: t10, transposeB: o, activation: s, leakyreluAlpha: i };
+ }, R = { a: w, b: k, bias: _, preluActivationWeights: $ }, D = { transposeA: t6, transposeB: o, activation: s, leakyreluAlpha: i };
return n == null ? Cr((M, L, W) => {
- let V = N.runKernel(Fo, A, D);
- return W([M, L, V]), { value: z(V, C), gradFunc: R };
+ let V = T.runKernel(fo, R, D);
+ return W([M, L, V]), { value: z(V, C), gradFunc: A };
})(w, k) : Cr((M, L, W, V) => {
- let G = N.runKernel(Fo, A, D);
- return V([M, L, G, W]), { value: z(G, C), gradFunc: R };
+ let U = T.runKernel(fo, R, D);
+ return V([M, L, U, W]), { value: z(U, C), gradFunc: A };
})(w, k, _);
}
-var pT = T({ fusedMatMul_: KH });
-function jH(r) {
- return hl(r, 0.54, 0.46);
+var M1 = N({ fusedMatMul_: fH });
+function hH(r) {
+ return il(r, 0.54, 0.46);
}
-var cT = T({ hammingWindow_: jH });
-function XH(r) {
- return hl(r, 0.5, 0.5);
+var L1 = N({ hammingWindow_: hH });
+function gH(r) {
+ return il(r, 0.5, 0.5);
}
-var Xf = T({ hannWindow_: XH });
-function YH(r, e, t10, o = false, n = 0) {
+var Ld = N({ hannWindow_: gH });
+function xH(r, e, t6, o = false, n = 0) {
let s = 0, a = [];
for (; s + e <= r.size; )
- a.push(Ue(r, s, e)), s += t10;
+ a.push(He(r, s, e)), s += t6;
if (o)
for (; s < r.size; ) {
- let i = s + e - r.size, p = gt([Ue(r, s, e - i), Bs([i], n)]);
- a.push(p), s += t10;
+ let i = s + e - r.size, p = gt([He(r, s, e - i), Ws([i], n)]);
+ a.push(p), s += t6;
}
- return a.length === 0 ? gi([], [0, e]) : z(gt(a), [a.length, e]);
+ return a.length === 0 ? _i([], [0, e]) : z(gt(a), [a.length, e]);
}
-var Yf = T({ frame_: YH });
-function QH(r, e, t10, o, n = Xf) {
- o == null && (o = wC(e));
- let s = Yf(r, e, t10), a = oe(s, n(e));
- return Kp(a, o);
+var Bd = N({ frame_: xH });
+function yH(r, e, t6, o, n = Ld) {
+ o == null && (o = xC(e));
+ let s = Bd(r, e, t6), a = ae(s, n(e));
+ return Wp(a, o);
}
-var lT = T({ stft_: QH });
-function ZH(r, e, t10, o, n = "bilinear", s = 0) {
- let a = v(r, "image", "cropAndResize"), i = v(e, "boxes", "cropAndResize", "float32"), p = v(t10, "boxInd", "cropAndResize", "int32"), u = i.shape[0];
- $(a.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${a.rank}.`), $(i.rank === 2 && i.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${u},4] but had shape ${i.shape}.`), $(p.rank === 1 && p.shape[0] === u, () => `Error in cropAndResize: boxInd must be have size [${u}] but had shape ${i.shape}.`), $(o.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${o.length}.`), $(o[0] >= 1 && o[1] >= 1, () => `cropSize must be atleast [1,1], but was ${o}`), $(n === "bilinear" || n === "nearest", () => `method must be bilinear or nearest, but was ${n}`);
+var B1 = N({ stft_: yH });
+function bH(r, e, t6, o, n = "bilinear", s = 0) {
+ let a = v(r, "image", "cropAndResize"), i = v(e, "boxes", "cropAndResize", "float32"), p = v(t6, "boxInd", "cropAndResize", "int32"), u = i.shape[0];
+ E(a.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${a.rank}.`), E(i.rank === 2 && i.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${u},4] but had shape ${i.shape}.`), E(p.rank === 1 && p.shape[0] === u, () => `Error in cropAndResize: boxInd must be have size [${u}] but had shape ${i.shape}.`), E(o.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${o.length}.`), E(o[0] >= 1 && o[1] >= 1, () => `cropSize must be atleast [1,1], but was ${o}`), E(n === "bilinear" || n === "nearest", () => `method must be bilinear or nearest, but was ${n}`);
let c = { image: a, boxes: i, boxInd: p }, l = { method: n, extrapolationValue: s, cropSize: o };
- return N.runKernel(xn, c, l);
+ return T.runKernel(Yo, c, l);
}
-var mT = T({ cropAndResize_: ZH });
-function JH(r) {
+var V1 = N({ cropAndResize_: bH });
+function CH(r) {
let e = v(r, "image", "flipLeftRight", "float32");
- $(e.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);
- let t10 = { image: e };
- return N.runKernel(Sn, t10, {});
+ E(e.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);
+ let t6 = { image: e };
+ return T.runKernel(on, t6, {});
}
-var fT = T({ flipLeftRight_: JH });
-function eq(r) {
- let e = v(r, "image", "grayscaleToRGB"), t10 = e.rank - 1, o = e.shape[t10];
- $(e.rank >= 2, () => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`), $(o === 1, () => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${o}.`);
+var z1 = N({ flipLeftRight_: CH });
+function SH(r) {
+ let e = v(r, "image", "grayscaleToRGB"), t6 = e.rank - 1, o = e.shape[t6];
+ E(e.rank >= 2, () => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`), E(o === 1, () => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${o}.`);
let n = new Array(e.rank);
- return n.fill(1, 0, t10), n[t10] = 3, fi(e, n);
+ return n.fill(1, 0, t6), n[t6] = 3, ki(e, n);
}
-var dT = T({ grayscaleToRGB_: eq });
-function tq(r, e, t10 = 0, o = 0.5) {
+var W1 = N({ grayscaleToRGB_: SH });
+function wH(r, e, t6 = 0, o = 0.5) {
let n = v(r, "image", "rotateWithOffset", "float32");
- $(n.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${n.rank}.`);
- let s = { image: n }, a = { radians: e, fillValue: t10, center: o };
- return N.runKernel(es, s, a);
+ E(n.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${n.rank}.`);
+ let s = { image: n }, a = { radians: e, fillValue: t6, center: o };
+ return T.runKernel(es, s, a);
}
-var hT = T({ rotateWithOffset_: tq });
-function Vo(r, e, t10, o, n, s) {
+var U1 = N({ rotateWithOffset_: wH });
+function So(r, e, t6, o, n, s) {
o == null && (o = 0.5), n == null && (n = Number.NEGATIVE_INFINITY), s == null && (s = 0);
let a = r.shape[0];
- return t10 = Math.min(t10, a), $(0 <= o && o <= 1, () => `iouThreshold must be in [0, 1], but was '${o}'`), $(r.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${r.rank}'`), $(r.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${r.shape[1]}`), $(e.rank === 1, () => "scores must be a 1D tensor"), $(e.shape[0] === a, () => `scores has incompatible shape with boxes. Expected ${a}, but was ${e.shape[0]}`), $(0 <= s && s <= 1, () => `softNmsSigma must be in [0, 1], but was '${s}'`), { maxOutputSize: t10, iouThreshold: o, scoreThreshold: n, softNmsSigma: s };
+ return t6 = Math.min(t6, a), E(0 <= o && o <= 1, () => `iouThreshold must be in [0, 1], but was '${o}'`), E(r.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${r.rank}'`), E(r.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${r.shape[1]}`), E(e.rank === 1, () => "scores must be a 1D tensor"), E(e.shape[0] === a, () => `scores has incompatible shape with boxes. Expected ${a}, but was ${e.shape[0]}`), E(0 <= s && s <= 1, () => `softNmsSigma must be in [0, 1], but was '${s}'`), { maxOutputSize: t6, iouThreshold: o, scoreThreshold: n, softNmsSigma: s };
}
-function rq(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY) {
- let s = v(r, "boxes", "nonMaxSuppression", "float32"), a = v(e, "scores", "nonMaxSuppression", "float32"), i = Vo(s, a, t10, o, n);
- t10 = i.maxOutputSize, o = i.iouThreshold, n = i.scoreThreshold;
- let p = { maxOutputSize: t10, iouThreshold: o, scoreThreshold: n };
- return N.runKernel(On, { boxes: s, scores: a }, p);
+function IH(r, e, t6, o = 0.5, n = Number.NEGATIVE_INFINITY) {
+ let s = v(r, "boxes", "nonMaxSuppression", "float32"), a = v(e, "scores", "nonMaxSuppression", "float32"), i = So(s, a, t6, o, n);
+ t6 = i.maxOutputSize, o = i.iouThreshold, n = i.scoreThreshold;
+ let p = { maxOutputSize: t6, iouThreshold: o, scoreThreshold: n };
+ return T.runKernel(Tn, { boxes: s, scores: a }, p);
}
-var gT = T({ nonMaxSuppression_: rq });
-function xT(r, e, t10) {
- let o = oq(r, e, t10), n = o < 0 ? -(o + 1) : o;
+var G1 = N({ nonMaxSuppression_: IH });
+function H1(r, e, t6) {
+ let o = vH(r, e, t6), n = o < 0 ? -(o + 1) : o;
r.splice(n, 0, e);
}
-function oq(r, e, t10) {
- return sq(r, e, t10 || nq);
+function vH(r, e, t6) {
+ return NH(r, e, t6 || kH);
}
-function nq(r, e) {
+function kH(r, e) {
return r > e ? 1 : r < e ? -1 : 0;
}
-function sq(r, e, t10) {
+function NH(r, e, t6) {
let o = 0, n = r.length, s = 0, a = false;
for (; o < n; ) {
s = o + (n - o >>> 1);
- let i = t10(e, r[s]);
+ let i = t6(e, r[s]);
i > 0 ? o = s + 1 : (n = s, a = !i);
}
return a ? o : -o - 1;
}
-function Qf(r, e, t10, o, n) {
- return vC(r, e, t10, o, n, 0);
+function Vd(r, e, t6, o, n) {
+ return bC(r, e, t6, o, n, 0);
}
-function Zf(r, e, t10, o, n, s) {
- return vC(r, e, t10, o, n, 0, false, s, true);
+function zd(r, e, t6, o, n, s) {
+ return bC(r, e, t6, o, n, 0, false, s, true);
}
-function Jf(r, e, t10, o, n, s) {
- return vC(r, e, t10, o, n, s, true);
+function Wd(r, e, t6, o, n, s) {
+ return bC(r, e, t6, o, n, s, true);
}
-function vC(r, e, t10, o, n, s, a = false, i = false, p = false) {
+function bC(r, e, t6, o, n, s, a = false, i = false, p = false) {
let u = [];
for (let g = 0; g < e.length; g++)
e[g] > n && u.push({ score: e[g], boxIndex: g, suppressBeginIndex: 0 });
- u.sort(yT);
+ u.sort(q1);
let c = s > 0 ? -0.5 / s : 0, l = [], m = [];
- for (; l.length < t10 && u.length > 0; ) {
- let g = u.pop(), { score: y, boxIndex: b, suppressBeginIndex: C } = g;
- if (y < n)
+ for (; l.length < t6 && u.length > 0; ) {
+ let g = u.pop(), { score: x, boxIndex: b, suppressBeginIndex: C } = g;
+ if (x < n)
break;
let w = false;
for (let k = l.length - 1; k >= C; --k) {
- let _ = aq(r, b, l[k]);
+ let _ = TH(r, b, l[k]);
if (_ >= o) {
w = true;
break;
}
- if (g.score = g.score * iq(o, c, _), g.score <= n)
+ if (g.score = g.score * _H(o, c, _), g.score <= n)
break;
}
- g.suppressBeginIndex = l.length, w || (g.score === y ? (l.push(b), m.push(g.score)) : g.score > n && xT(u, g, yT));
+ g.suppressBeginIndex = l.length, w || (g.score === x ? (l.push(b), m.push(g.score)) : g.score > n && H1(u, g, q1));
}
- let f = l.length, d = t10 - f;
- i && d > 0 && (l.push(...new Array(d).fill(0)), m.push(...new Array(d).fill(0)));
+ let d = l.length, f = t6 - d;
+ i && f > 0 && (l.push(...new Array(f).fill(0)), m.push(...new Array(f).fill(0)));
let h = { selectedIndices: l };
- return a && (h.selectedScores = m), p && (h.validOutputs = f), h;
+ return a && (h.selectedScores = m), p && (h.validOutputs = d), h;
}
-function aq(r, e, t10) {
- let o = r.subarray(e * 4, e * 4 + 4), n = r.subarray(t10 * 4, t10 * 4 + 4), s = Math.min(o[0], o[2]), a = Math.min(o[1], o[3]), i = Math.max(o[0], o[2]), p = Math.max(o[1], o[3]), u = Math.min(n[0], n[2]), c = Math.min(n[1], n[3]), l = Math.max(n[0], n[2]), m = Math.max(n[1], n[3]), f = (i - s) * (p - a), d = (l - u) * (m - c);
- if (f <= 0 || d <= 0)
+function TH(r, e, t6) {
+ let o = r.subarray(e * 4, e * 4 + 4), n = r.subarray(t6 * 4, t6 * 4 + 4), s = Math.min(o[0], o[2]), a = Math.min(o[1], o[3]), i = Math.max(o[0], o[2]), p = Math.max(o[1], o[3]), u = Math.min(n[0], n[2]), c = Math.min(n[1], n[3]), l = Math.max(n[0], n[2]), m = Math.max(n[1], n[3]), d = (i - s) * (p - a), f = (l - u) * (m - c);
+ if (d <= 0 || f <= 0)
return 0;
- let h = Math.max(s, u), g = Math.max(a, c), y = Math.min(i, l), b = Math.min(p, m), C = Math.max(y - h, 0) * Math.max(b - g, 0);
- return C / (f + d - C);
+ let h = Math.max(s, u), g = Math.max(a, c), x = Math.min(i, l), b = Math.min(p, m), C = Math.max(x - h, 0) * Math.max(b - g, 0);
+ return C / (d + f - C);
}
-function iq(r, e, t10) {
- let o = Math.exp(e * t10 * t10);
- return t10 <= r ? o : 0;
+function _H(r, e, t6) {
+ let o = Math.exp(e * t6 * t6);
+ return t6 <= r ? o : 0;
}
-function yT(r, e) {
+function q1(r, e) {
return r.score - e.score || r.score === e.score && e.boxIndex - r.boxIndex;
}
-async function uq(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY) {
- let s = v(r, "boxes", "nonMaxSuppressionAsync"), a = v(e, "scores", "nonMaxSuppressionAsync"), i = Vo(s, a, t10, o, n);
- t10 = i.maxOutputSize, o = i.iouThreshold, n = i.scoreThreshold;
- let p = await Promise.all([s.data(), a.data()]), u = p[0], c = p[1], { selectedIndices: l } = Qf(u, c, t10, o, n);
+async function EH(r, e, t6, o = 0.5, n = Number.NEGATIVE_INFINITY) {
+ let s = v(r, "boxes", "nonMaxSuppressionAsync"), a = v(e, "scores", "nonMaxSuppressionAsync"), i = So(s, a, t6, o, n);
+ t6 = i.maxOutputSize, o = i.iouThreshold, n = i.scoreThreshold;
+ let p = await Promise.all([s.data(), a.data()]), u = p[0], c = p[1], { selectedIndices: l } = Vd(u, c, t6, o, n);
return s !== r && s.dispose(), a !== e && a.dispose(), mr(l, "int32");
}
-var bT = uq;
-function pq(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY, s = 0) {
- let a = v(r, "boxes", "nonMaxSuppression"), i = v(e, "scores", "nonMaxSuppression"), p = Vo(a, i, t10, o, n, s);
- t10 = p.maxOutputSize, o = p.iouThreshold, n = p.scoreThreshold, s = p.softNmsSigma;
- let u = { boxes: a, scores: i }, c = { maxOutputSize: t10, iouThreshold: o, scoreThreshold: n, softNmsSigma: s }, l = N.runKernel(Mn, u, c);
+var K1 = EH;
+function $H(r, e, t6, o = 0.5, n = Number.NEGATIVE_INFINITY, s = 0) {
+ let a = v(r, "boxes", "nonMaxSuppression"), i = v(e, "scores", "nonMaxSuppression"), p = So(a, i, t6, o, n, s);
+ t6 = p.maxOutputSize, o = p.iouThreshold, n = p.scoreThreshold, s = p.softNmsSigma;
+ let u = { boxes: a, scores: i }, c = { maxOutputSize: t6, iouThreshold: o, scoreThreshold: n, softNmsSigma: s }, l = T.runKernel(_n, u, c);
return { selectedIndices: l[0], selectedScores: l[1] };
}
-var CT = T({ nonMaxSuppressionWithScore_: pq });
-async function cq(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY, s = 0) {
- let a = v(r, "boxes", "nonMaxSuppressionAsync"), i = v(e, "scores", "nonMaxSuppressionAsync"), p = Vo(a, i, t10, o, n, s);
- t10 = p.maxOutputSize, o = p.iouThreshold, n = p.scoreThreshold, s = p.softNmsSigma;
- let u = await Promise.all([a.data(), i.data()]), c = u[0], l = u[1], { selectedIndices: m, selectedScores: f } = Jf(c, l, t10, o, n, s);
- return a !== r && a.dispose(), i !== e && i.dispose(), { selectedIndices: mr(m, "int32"), selectedScores: mr(f) };
+var j1 = N({ nonMaxSuppressionWithScore_: $H });
+async function AH(r, e, t6, o = 0.5, n = Number.NEGATIVE_INFINITY, s = 0) {
+ let a = v(r, "boxes", "nonMaxSuppressionAsync"), i = v(e, "scores", "nonMaxSuppressionAsync"), p = So(a, i, t6, o, n, s);
+ t6 = p.maxOutputSize, o = p.iouThreshold, n = p.scoreThreshold, s = p.softNmsSigma;
+ let u = await Promise.all([a.data(), i.data()]), c = u[0], l = u[1], { selectedIndices: m, selectedScores: d } = Wd(c, l, t6, o, n, s);
+ return a !== r && a.dispose(), i !== e && i.dispose(), { selectedIndices: mr(m, "int32"), selectedScores: mr(d) };
}
-var IT = cq;
-function lq(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY, s = false) {
- let a = v(r, "boxes", "nonMaxSuppression"), i = v(e, "scores", "nonMaxSuppression"), p = Vo(a, i, t10, o, n, null), u = p.maxOutputSize, c = p.iouThreshold, l = p.scoreThreshold, m = { boxes: a, scores: i }, f = { maxOutputSize: u, iouThreshold: c, scoreThreshold: l, padToMaxOutputSize: s }, d = N.runKernel(pa, m, f);
- return { selectedIndices: d[0], validOutputs: d[1] };
+var X1 = AH;
+function RH(r, e, t6, o = 0.5, n = Number.NEGATIVE_INFINITY, s = false) {
+ let a = v(r, "boxes", "nonMaxSuppression"), i = v(e, "scores", "nonMaxSuppression"), p = So(a, i, t6, o, n, null), u = p.maxOutputSize, c = p.iouThreshold, l = p.scoreThreshold, m = { boxes: a, scores: i }, d = { maxOutputSize: u, iouThreshold: c, scoreThreshold: l, padToMaxOutputSize: s }, f = T.runKernel(ba, m, d);
+ return { selectedIndices: f[0], validOutputs: f[1] };
}
-var wT = T({ nonMaxSuppressionPadded_: lq });
-async function mq(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY, s = false) {
- let a = v(r, "boxes", "nonMaxSuppressionAsync"), i = v(e, "scores", "nonMaxSuppressionAsync"), p = Vo(a, i, t10, o, n, null), u = p.maxOutputSize, c = p.iouThreshold, l = p.scoreThreshold, [m, f] = await Promise.all([a.data(), i.data()]), { selectedIndices: d, validOutputs: h } = Zf(m, f, u, c, l, s);
- return a !== r && a.dispose(), i !== e && i.dispose(), { selectedIndices: mr(d, "int32"), validOutputs: be(h, "int32") };
+var Y1 = N({ nonMaxSuppressionPadded_: RH });
+async function FH(r, e, t6, o = 0.5, n = Number.NEGATIVE_INFINITY, s = false) {
+ let a = v(r, "boxes", "nonMaxSuppressionAsync"), i = v(e, "scores", "nonMaxSuppressionAsync"), p = So(a, i, t6, o, n, null), u = p.maxOutputSize, c = p.iouThreshold, l = p.scoreThreshold, [m, d] = await Promise.all([a.data(), i.data()]), { selectedIndices: f, validOutputs: h } = zd(m, d, u, c, l, s);
+ return a !== r && a.dispose(), i !== e && i.dispose(), { selectedIndices: mr(f, "int32"), validOutputs: be(h, "int32") };
}
-var ST = mq;
-function fq(r, e, t10 = false, o = false) {
+var Q1 = FH;
+function DH(r, e, t6 = false, o = false) {
let n = v(r, "images", "resizeBilinear");
- $(n.rank === 3 || n.rank === 4, () => `Error in resizeBilinear: x must be rank 3 or 4, but got rank ${n.rank}.`), $(e.length === 2, () => `Error in resizeBilinear: new shape must 2D, but got shape ${e}.`), $(o === false || t10 === false, () => "Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");
+ E(n.rank === 3 || n.rank === 4, () => `Error in resizeBilinear: x must be rank 3 or 4, but got rank ${n.rank}.`), E(e.length === 2, () => `Error in resizeBilinear: new shape must 2D, but got shape ${e}.`), E(o === false || t6 === false, () => "Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");
let s = n, a = false;
n.rank === 3 && (a = true, s = z(n, [1, n.shape[0], n.shape[1], n.shape[2]]));
- let [] = e, i = { images: s }, p = { alignCorners: t10, halfPixelCenters: o, size: e }, u = N.runKernel(Un, i, p);
+ let [] = e, i = { images: s }, p = { alignCorners: t6, halfPixelCenters: o, size: e }, u = T.runKernel(Mn, i, p);
return a ? z(u, [u.shape[1], u.shape[2], u.shape[3]]) : u;
}
-var vT = T({ resizeBilinear_: fq });
-function dq(r, e, t10 = false, o = false) {
+var Z1 = N({ resizeBilinear_: DH });
+function OH(r, e, t6 = false, o = false) {
let n = v(r, "images", "resizeNearestNeighbor");
- $(n.rank === 3 || n.rank === 4, () => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${n.rank}.`), $(e.length === 2, () => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`), $(n.dtype === "float32" || n.dtype === "int32", () => "`images` must have `int32` or `float32` as dtype"), $(o === false || t10 === false, () => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");
+ E(n.rank === 3 || n.rank === 4, () => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${n.rank}.`), E(e.length === 2, () => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`), E(n.dtype === "float32" || n.dtype === "int32", () => "`images` must have `int32` or `float32` as dtype"), E(o === false || t6 === false, () => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");
let s = n, a = false;
n.rank === 3 && (a = true, s = z(n, [1, n.shape[0], n.shape[1], n.shape[2]]));
- let [] = e, i = { images: s }, p = { alignCorners: t10, halfPixelCenters: o, size: e }, u = N.runKernel(Wn, i, p);
+ let [] = e, i = { images: s }, p = { alignCorners: t6, halfPixelCenters: o, size: e }, u = T.runKernel(Pn, i, p);
return a ? z(u, [u.shape[1], u.shape[2], u.shape[3]]) : u;
}
-var kT = T({ resizeNearestNeighbor_: dq });
-function hq(r, e = "binary", t10 = false, o = 0.5) {
- let n = v(r, "image", "threshold"), s = 0.2989, a = 0.587, i = 0.114, p = n.shape[0] * n.shape[1], u = oe(mr([o]), 255), c, l, m, f;
- if ($(n.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${n.rank}.`), $(n.shape[2] === 3 || n.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${n.shape[2]}.`), $(n.dtype === "int32" || n.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${n.dtype}.`), $(e === "otsu" || e === "binary", () => `Method must be binary or otsu, but was ${e}`), n.shape[2] === 3) {
- [c, l, m] = $a(n, [1, 1, 1], -1);
- let g = oe(c, s), y = oe(l, a), b = oe(m, i);
- f = ge(ge(g, y), b);
+var J1 = N({ resizeNearestNeighbor_: OH });
+function PH(r, e = "binary", t6 = false, o = 0.5) {
+ let n = v(r, "image", "threshold"), s = 0.2989, a = 0.587, i = 0.114, p = n.shape[0] * n.shape[1], u = ae(mr([o]), 255), c, l, m, d;
+ if (E(n.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${n.rank}.`), E(n.shape[2] === 3 || n.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${n.shape[2]}.`), E(n.dtype === "int32" || n.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${n.dtype}.`), E(e === "otsu" || e === "binary", () => `Method must be binary or otsu, but was ${e}`), n.shape[2] === 3) {
+ [c, l, m] = Oa(n, [1, 1, 1], -1);
+ let g = ae(c, s), x = ae(l, a), b = ae(m, i);
+ d = xe(xe(g, x), b);
} else
- f = r;
+ d = r;
if (e === "otsu") {
- let g = df(qe(Uf(f), "int32"), nr([]), 256);
- u = gq(g, p);
+ let g = od(Ke(Rd(d), "int32"), nr([]), 256);
+ u = MH(g, p);
}
- let d = t10 ? Hp(f, u) : cu(f, u);
- return qe(oe(d, 255), "int32");
+ let f = t6 ? Vp(d, u) : cu(d, u);
+ return Ke(ae(f, 255), "int32");
}
-function gq(r, e) {
- let t10 = mr([-1]), o = mr([0]), n = mr([0]), s, a, i, p, u, c;
+function MH(r, e) {
+ let t6 = mr([-1]), o = mr([0]), n = mr([0]), s, a, i, p, u, c;
for (let l = 0; l < r.size - 1; l++) {
- s = Ue(r, 0, l + 1), a = Ue(r, l + 1), u = We(tt(s), e), c = We(tt(a), e);
- let m = tt(oe(s, di(0, s.size)));
- i = We(m, tt(s));
- let f = Bs(a.shape, s.size), d = ge(di(0, a.size), f), h = oe(a, d);
- p = We(tt(h), tt(a));
- let g = ke(i, p), y = ke(i, p), b = oe(u, c);
- n = oe(oe(b, g), y);
+ s = He(r, 0, l + 1), a = He(r, l + 1), u = Ge(et(s), e), c = Ge(et(a), e);
+ let m = et(ae(s, Ni(0, s.size)));
+ i = Ge(m, et(s));
+ let d = Ws(a.shape, s.size), f = xe(Ni(0, a.size), d), h = ae(a, f);
+ p = Ge(et(h), et(a));
+ let g = Ne(i, p), x = Ne(i, p), b = ae(u, c);
+ n = ae(ae(b, g), x);
let C = cu(n, o);
- o = os(C, n, o), t10 = os(C, mr([l]), t10);
+ o = os(C, n, o), t6 = os(C, mr([l]), t6);
}
- return t10;
+ return t6;
}
-var TT = T({ threshold_: hq });
-function xq(r, e, t10 = "nearest", o = "constant", n = 0, s) {
+var eN = N({ threshold_: PH });
+function LH(r, e, t6 = "nearest", o = "constant", n = 0, s) {
let a = v(r, "image", "transform", "float32"), i = v(e, "transforms", "transform", "float32");
- $(a.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${a.rank}.`), $(i.rank === 2 && (i.shape[0] === a.shape[0] || i.shape[0] === 1) && i.shape[1] === 8, () => "Error in transform: Input transform should be batch x 8 or 1 x 8"), $(s == null || s.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${s}.`);
- let p = { image: a, transforms: i }, u = { interpolation: t10, fillMode: o, fillValue: n, outputShape: s };
- return N.runKernel(Jn, p, u);
+ E(a.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${a.rank}.`), E(i.rank === 2 && (i.shape[0] === a.shape[0] || i.shape[0] === 1) && i.shape[1] === 8, () => "Error in transform: Input transform should be batch x 8 or 1 x 8"), E(s == null || s.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${s}.`);
+ let p = { image: a, transforms: i }, u = { interpolation: t6, fillMode: o, fillValue: n, outputShape: s };
+ return T.runKernel(Jn, p, u);
}
-var NT = T({ transform_: xq });
-function yq(r, e, t10) {
- $(e % 1 === 0, () => `bandPart(): numLower must be an integer, got ${e}.`), $(t10 % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${t10}.`);
+var tN = N({ transform_: LH });
+function BH(r, e, t6) {
+ E(e % 1 === 0, () => `bandPart(): numLower must be an integer, got ${e}.`), E(t6 % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${t6}.`);
let o = v(r, "a", "bandPart");
- $(o.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${o.rank}.`);
+ E(o.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${o.rank}.`);
let n = o.shape, [s, a] = o.shape.slice(-2);
if (!(e <= s))
throw new Error(`bandPart(): numLower (${e}) must not be greater than the number of rows (${s}).`);
- if (!(t10 <= a))
- throw new Error(`bandPart(): numUpper (${t10}) must not be greater than the number of columns (${a}).`);
- e < 0 && (e = s), t10 < 0 && (t10 = a);
- let i = z(di(0, s, 1, "int32"), [-1, 1]), p = di(0, a, 1, "int32"), u = ke(i, p), c = lu(Hp(u, be(+e, "int32")), If(u, be(-t10, "int32"))), l = Wr([s, a], o.dtype);
- return z(Ir(ko(z(o, [-1, s, a])).map((m) => os(c, m, l))), n);
+ if (!(t6 <= a))
+ throw new Error(`bandPart(): numUpper (${t6}) must not be greater than the number of columns (${a}).`);
+ e < 0 && (e = s), t6 < 0 && (t6 = a);
+ let i = z(Ni(0, s, 1, "int32"), [-1, 1]), p = Ni(0, a, 1, "int32"), u = Ne(i, p), c = lu(Vp(u, be(+e, "int32")), cd(u, be(-t6, "int32"))), l = Vr([s, a], o.dtype);
+ return z(Sr(so(z(o, [-1, s, a])).map((m) => os(c, m, l))), n);
}
-var _T = T({ bandPart_: yq });
-function bq(r) {
+var rN = N({ bandPart_: BH });
+function VH(r) {
let e;
if (Array.isArray(r)) {
- e = false, $(r != null && r.length > 0, () => "Gram-Schmidt process: input must not be null, undefined, or empty");
+ e = false, E(r != null && r.length > 0, () => "Gram-Schmidt process: input must not be null, undefined, or empty");
let n = r[0].shape[0];
for (let s = 1; s < r.length; ++s)
- $(r[s].shape[0] === n, () => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${r[s].shape[0]} vs. ${n})`);
+ E(r[s].shape[0] === n, () => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${r[s].shape[0]} vs. ${n})`);
} else
- e = true, r = $a(r, r.shape[0], 0).map((n) => jp(n, [0]));
- $(r.length <= r[0].shape[0], () => `Gram-Schmidt: Number of vectors (${r.length}) exceeds number of dimensions (${r[0].shape[0]}).`);
- let t10 = [], o = r;
+ e = true, r = Oa(r, r.shape[0], 0).map((n) => Up(n, [0]));
+ E(r.length <= r[0].shape[0], () => `Gram-Schmidt: Number of vectors (${r.length}) exceeds number of dimensions (${r[0].shape[0]}).`);
+ let t6 = [], o = r;
for (let n = 0; n < r.length; ++n)
- t10.push(N.tidy(() => {
+ t6.push(T.tidy(() => {
let s = o[n];
if (n > 0)
for (let a = 0; a < n; ++a) {
- let i = oe(tt(oe(t10[a], s)), t10[a]);
- s = ke(s, i);
+ let i = ae(et(ae(t6[a], s)), t6[a]);
+ s = Ne(s, i);
}
- return We(s, pu(s, "euclidean"));
+ return Ge(s, pu(s, "euclidean"));
}));
- return e ? Ir(t10, 0) : t10;
+ return e ? Sr(t6, 0) : t6;
}
-var ET = T({ gramSchmidt_: bq });
-function Cq(r, e = false) {
- if ($(r.rank >= 2, () => `qr() requires input tensor to have a rank >= 2, but got rank ${r.rank}`), r.rank === 2)
- return $T(r, e);
+var oN = N({ gramSchmidt_: VH });
+function zH(r, e = false) {
+ if (E(r.rank >= 2, () => `qr() requires input tensor to have a rank >= 2, but got rank ${r.rank}`), r.rank === 2)
+ return nN(r, e);
{
- let t10 = r.shape.slice(0, r.shape.length - 2).reduce((p, u) => p * u), o = ko(z(r, [t10, r.shape[r.shape.length - 2], r.shape[r.shape.length - 1]]), 0), n = [], s = [];
+ let t6 = r.shape.slice(0, r.shape.length - 2).reduce((p, u) => p * u), o = so(z(r, [t6, r.shape[r.shape.length - 2], r.shape[r.shape.length - 1]]), 0), n = [], s = [];
o.forEach((p) => {
- let [u, c] = $T(p, e);
+ let [u, c] = nN(p, e);
n.push(u), s.push(c);
});
- let a = z(Ir(n, 0), r.shape), i = z(Ir(s, 0), r.shape);
+ let a = z(Sr(n, 0), r.shape), i = z(Sr(s, 0), r.shape);
return [a, i];
}
}
-function $T(r, e = false) {
- return N.tidy(() => {
- $(r.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${r.shape.length}D Tensor.`);
- let t10 = r.shape[0], o = r.shape[1], n = yf(t10), s = zr(r), a = gi([[1]], [1, 1]), i = zr(a), p = t10 >= o ? o : t10;
+function nN(r, e = false) {
+ return T.tidy(() => {
+ E(r.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${r.shape.length}D Tensor.`);
+ let t6 = r.shape[0], o = r.shape[1], n = id(t6), s = Br(r), a = _i([[1]], [1, 1]), i = Br(a), p = t6 >= o ? o : t6;
for (let u = 0; u < p; ++u) {
let c = s, l = i, m = n;
- [i, s, n] = N.tidy(() => {
- let f = Ue(s, [u, u], [t10 - u, 1]), d = pu(f), h = Ue(s, [u, u], [1, 1]), g = os(cu(h, 0), gi([[-1]]), gi([[1]])), y = ke(h, oe(g, d)), b = We(f, y);
- b.shape[0] === 1 ? i = zr(a) : i = gt([a, Ue(b, [1, 0], [b.shape[0] - 1, b.shape[1]])], 0);
- let C = yr(We(Xe(g, y), d)), w = Ue(s, [u, 0], [t10 - u, o]), k = oe(C, i), _ = Wp(i);
+ [i, s, n] = T.tidy(() => {
+ let d = He(s, [u, u], [t6 - u, 1]), f = pu(d), h = He(s, [u, u], [1, 1]), g = os(cu(h, 0), _i([[-1]]), _i([[1]])), x = Ne(h, ae(g, f)), b = Ge(d, x);
+ b.shape[0] === 1 ? i = Br(a) : i = gt([a, He(b, [1, 0], [b.shape[0] - 1, b.shape[1]])], 0);
+ let C = yr(Ge(Xe(g, x), f)), w = He(s, [u, 0], [t6 - u, o]), k = ae(C, i), _ = Mp(i);
if (u === 0)
- s = ke(w, Xe(k, Xe(_, w)));
+ s = Ne(w, Xe(k, Xe(_, w)));
else {
- let A = ke(w, Xe(k, Xe(_, w)));
- s = gt([Ue(s, [0, 0], [u, o]), A], 0);
+ let R = Ne(w, Xe(k, Xe(_, w)));
+ s = gt([He(s, [0, 0], [u, o]), R], 0);
}
- let E = Wp(k), R = Ue(n, [0, u], [t10, n.shape[1] - u]);
+ let $ = Mp(k), A = He(n, [0, u], [t6, n.shape[1] - u]);
if (u === 0)
- n = ke(R, Xe(Xe(R, i), E));
+ n = Ne(A, Xe(Xe(A, i), $));
else {
- let A = ke(R, Xe(Xe(R, i), E));
- n = gt([Ue(n, [0, 0], [t10, u]), A], 1);
+ let R = Ne(A, Xe(Xe(A, i), $));
+ n = gt([He(n, [0, 0], [t6, u]), R], 1);
}
return [i, s, n];
- }), Ft([c, l, m]);
+ }), Dt([c, l, m]);
}
- return !e && t10 > o && (n = Ue(n, [0, 0], [t10, o]), s = Ue(s, [0, 0], [o, o])), [n, s];
+ return !e && t6 > o && (n = He(n, [0, 0], [t6, o]), s = He(s, [0, 0], [o, o])), [n, s];
});
}
-var RT = T({ qr_: Cq });
+var sN = N({ qr_: zH });
var Et;
(function(r) {
r[r.NONE = 0] = "NONE", r[r.MEAN = 1] = "MEAN", r[r.SUM = 2] = "SUM", r[r.SUM_BY_NONZERO_WEIGHTS = 3] = "SUM_BY_NONZERO_WEIGHTS";
})(Et || (Et = {}));
-function Iq(r, e, t10 = Et.SUM_BY_NONZERO_WEIGHTS) {
+function WH(r, e, t6 = Et.SUM_BY_NONZERO_WEIGHTS) {
let o = v(r, "losses", "computeWeightedLoss"), n = null;
e != null && (n = v(e, "weights", "computeWeightedLoss"));
- let s = n == null ? o : oe(o, n);
- if (t10 === Et.NONE)
+ let s = n == null ? o : ae(o, n);
+ if (t6 === Et.NONE)
return s;
- if (t10 === Et.SUM)
- return tt(s);
- if (t10 === Et.MEAN) {
+ if (t6 === Et.SUM)
+ return et(s);
+ if (t6 === Et.MEAN) {
if (n == null)
return mu(s);
{
- let a = o.size / n.size, i = We(tt(s), tt(n));
- return a > 1 ? We(i, be(a)) : i;
+ let a = o.size / n.size, i = Ge(et(s), et(n));
+ return a > 1 ? Ge(i, be(a)) : i;
}
}
- if (t10 === Et.SUM_BY_NONZERO_WEIGHTS) {
+ if (t6 === Et.SUM_BY_NONZERO_WEIGHTS) {
if (n == null)
- return We(tt(s), be(o.size));
+ return Ge(et(s), be(o.size));
{
- let a = oe(n, zs(o.shape)), i = qe(tt(Ff(a, be(0))), "float32");
- return We(tt(s), i);
+ let a = ae(n, Gs(o.shape)), i = Ke(et(wd(a, be(0))), "float32");
+ return Ge(et(s), i);
}
}
- throw Error(`Unknown reduction: ${t10}`);
+ throw Error(`Unknown reduction: ${t6}`);
}
-var sr = T({ computeWeightedLoss_: Iq });
-function wq(r, e, t10, o = Et.SUM_BY_NONZERO_WEIGHTS) {
+var sr = N({ computeWeightedLoss_: WH });
+function UH(r, e, t6, o = Et.SUM_BY_NONZERO_WEIGHTS) {
let n = v(r, "labels", "absoluteDifference"), s = v(e, "predictions", "absoluteDifference"), a = null;
- t10 != null && (a = v(t10, "weights", "absoluteDifference")), ht(n.shape, s.shape, "Error in absoluteDifference: ");
- let i = Qt(ke(n, s));
+ t6 != null && (a = v(t6, "weights", "absoluteDifference")), ht(n.shape, s.shape, "Error in absoluteDifference: ");
+ let i = Yt(Ne(n, s));
return sr(i, a, o);
}
-var AT = T({ absoluteDifference_: wq });
-function Sq(r, e, t10, o, n = Et.SUM_BY_NONZERO_WEIGHTS) {
+var aN = N({ absoluteDifference_: UH });
+function GH(r, e, t6, o, n = Et.SUM_BY_NONZERO_WEIGHTS) {
let s = v(r, "labels", "cosineDistance"), a = v(e, "predictions", "cosineDistance"), i = null;
o != null && (i = v(o, "weights", "cosineDistance")), ht(s.shape, a.shape, "Error in cosineDistance: ");
- let p = be(1), u = ke(p, tt(oe(s, a), t10, true));
+ let p = be(1), u = Ne(p, et(ae(s, a), t6, true));
return sr(u, i, n);
}
-var FT = T({ cosineDistance_: Sq });
-function vq(r, e, t10, o = Et.SUM_BY_NONZERO_WEIGHTS) {
+var iN = N({ cosineDistance_: GH });
+function HH(r, e, t6, o = Et.SUM_BY_NONZERO_WEIGHTS) {
let n = v(r, "labels", "hingeLoss"), s = v(e, "predictions", "hingeLoss"), a = null;
- t10 != null && (a = v(t10, "weights", "hingeLoss")), ht(n.shape, s.shape, "Error in hingeLoss: ");
+ t6 != null && (a = v(t6, "weights", "hingeLoss")), ht(n.shape, s.shape, "Error in hingeLoss: ");
let i = be(1);
- n = ke(oe(be(2), n), i);
- let p = hi(ke(i, oe(n, s)));
+ n = Ne(ae(be(2), n), i);
+ let p = Ti(Ne(i, ae(n, s)));
return sr(p, a, o);
}
-var DT = T({ hingeLoss_: vq });
-function kq(r, e, t10, o = 1, n = Et.SUM_BY_NONZERO_WEIGHTS) {
+var uN = N({ hingeLoss_: HH });
+function qH(r, e, t6, o = 1, n = Et.SUM_BY_NONZERO_WEIGHTS) {
let s = v(r, "labels", "huberLoss"), a = v(e, "predictions", "huberLoss"), i = null;
- t10 != null && (i = v(t10, "weights", "huberLoss")), ht(s.shape, a.shape, "Error in huberLoss: ");
- let p = be(o), u = Qt(ke(a, s)), c = Af(u, p), l = ke(u, c), m = ge(oe(be(0.5), Zt(c)), oe(p, l));
+ t6 != null && (i = v(t6, "weights", "huberLoss")), ht(s.shape, a.shape, "Error in huberLoss: ");
+ let p = be(o), u = Yt(Ne(a, s)), c = Sd(u, p), l = Ne(u, c), m = xe(ae(be(0.5), Qt(c)), ae(p, l));
return sr(m, i, n);
}
-var PT = T({ huberLoss_: kq });
-function Tq(r, e, t10, o = 1e-7, n = Et.SUM_BY_NONZERO_WEIGHTS) {
+var pN = N({ huberLoss_: qH });
+function KH(r, e, t6, o = 1e-7, n = Et.SUM_BY_NONZERO_WEIGHTS) {
let s = v(r, "labels", "logLoss"), a = v(e, "predictions", "logLoss"), i = null;
- t10 != null && (i = v(t10, "weights", "logLoss")), ht(s.shape, a.shape, "Error in logLoss: ");
- let p = be(1), u = be(o), c = yr(oe(s, Ea(ge(a, u)))), l = oe(ke(p, s), Ea(ge(ke(p, a), u))), m = ke(c, l);
+ t6 != null && (i = v(t6, "weights", "logLoss")), ht(s.shape, a.shape, "Error in logLoss: ");
+ let p = be(1), u = be(o), c = yr(ae(s, Da(xe(a, u)))), l = ae(Ne(p, s), Da(xe(Ne(p, a), u))), m = Ne(c, l);
return sr(m, i, n);
}
-var OT = T({ logLoss_: Tq });
-function Nq(r, e, t10, o = Et.SUM_BY_NONZERO_WEIGHTS) {
+var cN = N({ logLoss_: KH });
+function jH(r, e, t6, o = Et.SUM_BY_NONZERO_WEIGHTS) {
let n = v(r, "labels", "meanSquaredError"), s = v(e, "predictions", "meanSquaredError"), a = null;
- t10 != null && (a = v(t10, "weights", "meanSquaredError")), ht(n.shape, s.shape, "Error in meanSquaredError: ");
- let i = Hf(n, s);
+ t6 != null && (a = v(t6, "weights", "meanSquaredError")), ht(n.shape, s.shape, "Error in meanSquaredError: ");
+ let i = Dd(n, s);
return sr(i, a, o);
}
-var MT = T({ meanSquaredError_: Nq });
-function _q(r, e) {
- let t10 = v(r, "labels", "sigmoidCrossEntropyWithLogits"), o = v(e, "logits", "sigmoidCrossEntropyWithLogits");
- ht(t10.shape, o.shape, "Error in sigmoidCrossEntropyWithLogits: ");
- let n = hi(o), s = oe(o, t10), a = Sf(Bo(yr(Qt(o))));
- return ge(ke(n, s), a);
+var lN = N({ meanSquaredError_: jH });
+function XH(r, e) {
+ let t6 = v(r, "labels", "sigmoidCrossEntropyWithLogits"), o = v(e, "logits", "sigmoidCrossEntropyWithLogits");
+ ht(t6.shape, o.shape, "Error in sigmoidCrossEntropyWithLogits: ");
+ let n = Ti(o), s = ae(o, t6), a = md(Co(yr(Yt(o))));
+ return xe(Ne(n, s), a);
}
-function Eq(r, e, t10, o = 0, n = Et.SUM_BY_NONZERO_WEIGHTS) {
+function YH(r, e, t6, o = 0, n = Et.SUM_BY_NONZERO_WEIGHTS) {
let s = v(r, "multiClassLabels", "sigmoidCrossEntropy"), a = v(e, "logits", "sigmoidCrossEntropy"), i = null;
- if (t10 != null && (i = v(t10, "weights", "sigmoidCrossEntropy")), ht(s.shape, a.shape, "Error in sigmoidCrossEntropy: "), o > 0) {
+ if (t6 != null && (i = v(t6, "weights", "sigmoidCrossEntropy")), ht(s.shape, a.shape, "Error in sigmoidCrossEntropy: "), o > 0) {
let u = be(o), c = be(1), l = be(0.5);
- s = ge(oe(s, ke(c, u)), oe(l, u));
+ s = xe(ae(s, Ne(c, u)), ae(l, u));
}
- let p = _q(s, a);
+ let p = XH(s, a);
return sr(p, i, n);
}
-var LT = T({ sigmoidCrossEntropy_: Eq });
-function $q(r, e, t10 = -1) {
- if (t10 === -1 && (t10 = e.rank - 1), t10 !== e.rank - 1)
- throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${e.rank} and dim was ${t10}`);
+var mN = N({ sigmoidCrossEntropy_: YH });
+function QH(r, e, t6 = -1) {
+ if (t6 === -1 && (t6 = e.rank - 1), t6 !== e.rank - 1)
+ throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${e.rank} and dim was ${t6}`);
return Cr((n, s, a) => {
- let p = Tf(s, [t10], true), u = ke(qe(s, "float32"), p);
+ let p = hd(s, [t6], true), u = Ne(Ke(s, "float32"), p);
a([n, u]);
- let c = yr(oe(u, n));
- return { value: tt(c, [t10]), gradFunc: (f, d) => {
- let [h, g] = d, y = Ta(f.shape, [t10]);
- return [oe(z(f, y), ke(qe(h, "float32"), Bo(g))), oe(z(f, y), ke(Bo(g), qe(h, "float32")))];
+ let c = yr(ae(u, n));
+ return { value: et(c, [t6]), gradFunc: (d, f) => {
+ let [h, g] = f, x = Aa(d.shape, [t6]);
+ return [ae(z(d, x), Ne(Ke(h, "float32"), Co(g))), ae(z(d, x), Ne(Co(g), Ke(h, "float32")))];
} };
})(r, e);
}
-function Rq(r, e, t10, o = 0, n = Et.SUM_BY_NONZERO_WEIGHTS) {
+function ZH(r, e, t6, o = 0, n = Et.SUM_BY_NONZERO_WEIGHTS) {
let s = v(r, "onehotLabels", "softmaxCrossEntropy"), a = v(e, "logits", "softmaxCrossEntropy"), i = null;
- if (t10 != null && (i = v(t10, "weights", "softmaxCrossEntropy")), ht(s.shape, a.shape, "Error in softmaxCrossEntropy: "), o > 0) {
+ if (t6 != null && (i = v(t6, "weights", "softmaxCrossEntropy")), ht(s.shape, a.shape, "Error in softmaxCrossEntropy: "), o > 0) {
let u = be(o), c = be(1), l = be(s.shape[1]);
- s = ge(oe(s, ke(c, u)), We(u, l));
+ s = xe(ae(s, Ne(c, u)), Ge(u, l));
}
- let p = $q(s, a);
+ let p = QH(s, a);
return sr(p, i, n);
}
-var BT = T({ softmaxCrossEntropy_: Rq });
-function Aq(r, e, t10, o) {
- let n = v(r, "indices", "sparseFillEmptyRows", "int32"), s = v(e, "values", "sparseFillEmptyRows"), a = v(t10, "denseShape", "sparseFillEmptyRows", "int32"), i = v(o, "defaultValue", "sparseFillEmptyRows", s.dtype);
+var dN = N({ softmaxCrossEntropy_: ZH });
+function JH(r, e, t6, o) {
+ let n = v(r, "indices", "sparseFillEmptyRows", "int32"), s = v(e, "values", "sparseFillEmptyRows"), a = v(t6, "denseShape", "sparseFillEmptyRows", "int32"), i = v(o, "defaultValue", "sparseFillEmptyRows", s.dtype);
if (n.rank !== 2)
throw new Error(`Indices should be Tensor2D but received shape
${n.shape}`);
@@ -8526,12 +8536,12 @@ function Aq(r, e, t10, o) {
throw new Error(`Dense shape should be Tensor1D but received shape ${a.shape}`);
if (i.rank !== 0)
throw new Error(`Default value should be a scalar but received shape ${i.shape}`);
- let p = { indices: n, values: s, denseShape: a, defaultValue: i }, u = N.runKernel(Qa, p);
+ let p = { indices: n, values: s, denseShape: a, defaultValue: i }, u = T.runKernel(ui, p);
return { outputIndices: u[0], outputValues: u[1], emptyRowIndicator: u[2], reverseIndexMap: u[3] };
}
-var VT = T({ sparseFillEmptyRows_: Aq });
-function Fq(r, e, t10) {
- let o = v(r, "inputIndices", "sparseReshape", "int32"), n = v(e, "inputShape", "sparseReshape", "int32"), s = v(t10, "newShape", "sparseReshape", "int32");
+var fN = N({ sparseFillEmptyRows_: JH });
+function eq(r, e, t6) {
+ let o = v(r, "inputIndices", "sparseReshape", "int32"), n = v(e, "inputShape", "sparseReshape", "int32"), s = v(t6, "newShape", "sparseReshape", "int32");
if (o.rank !== 2)
throw new Error(`Input indices should be Tensor2D but received shape
${o.shape}`);
@@ -8539,12 +8549,12 @@ function Fq(r, e, t10) {
throw new Error(`Input shape should be Tensor1D but received shape ${n.shape}`);
if (s.rank !== 1)
throw new Error(`New shape should be Tensor1D but received shape ${s.shape}`);
- let a = { inputIndices: o, inputShape: n, newShape: s }, i = N.runKernel(ga, a);
+ let a = { inputIndices: o, inputShape: n, newShape: s }, i = T.runKernel(wa, a);
return { outputIndices: i[0], outputShape: i[1] };
}
-var zT = T({ sparseReshape_: Fq });
-function Dq(r, e, t10) {
- let o = v(r, "data", "sparseSegmentMean"), n = v(e, "indices", "sparseSegmentMean", "int32"), s = v(t10, "segmentIds", "sparseSegmentMean", "int32");
+var hN = N({ sparseReshape_: eq });
+function tq(r, e, t6) {
+ let o = v(r, "data", "sparseSegmentMean"), n = v(e, "indices", "sparseSegmentMean", "int32"), s = v(t6, "segmentIds", "sparseSegmentMean", "int32");
if (o.rank < 1)
throw new Error("Data should be at least 1 dimensional but received scalar");
if (n.rank !== 1)
@@ -8554,11 +8564,11 @@ function Dq(r, e, t10) {
throw new Error(`Segment ids should be Tensor1D but received shape
${s.shape}`);
let a = { data: o, indices: n, segmentIds: s };
- return N.runKernel(Za, a);
+ return T.runKernel(pi, a);
}
-var WT = T({ sparseSegmentMean_: Dq });
-function Pq(r, e, t10) {
- let o = v(r, "data", "sparseSegmentSum"), n = v(e, "indices", "sparseSegmentSum", "int32"), s = v(t10, "segmentIds", "sparseSegmentSum", "int32");
+var gN = N({ sparseSegmentMean_: tq });
+function rq(r, e, t6) {
+ let o = v(r, "data", "sparseSegmentSum"), n = v(e, "indices", "sparseSegmentSum", "int32"), s = v(t6, "segmentIds", "sparseSegmentSum", "int32");
if (o.rank < 1)
throw new Error("Data should be at least 1 dimensional but received scalar");
if (n.rank !== 1)
@@ -8568,10 +8578,10 @@ function Pq(r, e, t10) {
throw new Error(`Segment ids should be Tensor1D but received shape
${s.shape}`);
let a = { data: o, indices: n, segmentIds: s };
- return N.runKernel(Ja, a);
+ return T.runKernel(ci, a);
}
-var UT = T({ sparseSegmentSum_: Pq });
-function Oq(r, e, t10, o, n, s, a, i) {
+var xN = N({ sparseSegmentSum_: rq });
+function oq(r, e, t6, o, n, s, a, i) {
let p = v(r, "data", "stringNGrams", "string");
if (p.dtype !== "string")
throw new Error("Data must be of datatype string");
@@ -8580,44 +8590,44 @@ function Oq(r, e, t10, o, n, s, a, i) {
let u = v(e, "dataSplits", "stringNGrams");
if (u.dtype !== "int32")
throw new Error("Data splits must be of datatype int32");
- let c = { separator: t10, nGramWidths: o, leftPad: n, rightPad: s, padWidth: a, preserveShortSequences: i }, l = { data: p, dataSplits: u }, m = N.runKernel(Ns, l, c);
+ let c = { separator: t6, nGramWidths: o, leftPad: n, rightPad: s, padWidth: a, preserveShortSequences: i }, l = { data: p, dataSplits: u }, m = T.runKernel(As, l, c);
return { nGrams: m[0], nGramsSplits: m[1] };
}
-var GT = T({ stringNGrams_: Oq });
-function Mq(r, e, t10 = true) {
+var yN = N({ stringNGrams_: oq });
+function nq(r, e, t6 = true) {
let o = v(r, "input", "stringSplit", "string"), n = v(e, "delimiter", "stringSplit", "string");
if (o.rank !== 1)
throw new Error(`Input should be Tensor1D but received shape ${o.shape}`);
if (n.rank !== 0)
throw new Error(`Delimiter should be a scalar but received shape ${n.shape}`);
- let s = { skipEmpty: t10 }, a = { input: o, delimiter: n }, i = N.runKernel(ri, a, s);
+ let s = { skipEmpty: t6 }, a = { input: o, delimiter: n }, i = T.runKernel(di, a, s);
return { indices: i[0], values: i[1], shape: i[2] };
}
-var HT = T({ stringSplit_: Mq });
-function Lq(r, e) {
- let t10 = v(r, "input", "stringToHashBucketFast", "string"), o = { numBuckets: e };
+var bN = N({ stringSplit_: nq });
+function sq(r, e) {
+ let t6 = v(r, "input", "stringToHashBucketFast", "string"), o = { numBuckets: e };
if (e <= 0)
throw new Error("Number of buckets must be at least 1");
- let n = { input: t10 };
- return N.runKernel(oi, n, o);
+ let n = { input: t6 };
+ return T.runKernel(fi, n, o);
}
-var qT = T({ stringToHashBucketFast_: Lq });
-var Bq = { fft: qp, ifft: hu, rfft: Kp, irfft: Gf };
-var Vq = { hammingWindow: cT, hannWindow: Xf, frame: Yf, stft: lT };
-var zq = { flipLeftRight: fT, grayscaleToRGB: dT, resizeNearestNeighbor: kT, resizeBilinear: vT, rotateWithOffset: hT, cropAndResize: mT, nonMaxSuppression: gT, nonMaxSuppressionAsync: bT, nonMaxSuppressionWithScore: CT, nonMaxSuppressionWithScoreAsync: IT, nonMaxSuppressionPadded: wT, nonMaxSuppressionPaddedAsync: ST, threshold: TT, transform: NT };
-var Wq = { bandPart: _T, gramSchmidt: ET, qr: RT };
-var Uq = { absoluteDifference: AT, computeWeightedLoss: sr, cosineDistance: FT, hingeLoss: DT, huberLoss: PT, logLoss: OT, meanSquaredError: MT, sigmoidCrossEntropy: LT, softmaxCrossEntropy: BT };
-var Gq = { sparseFillEmptyRows: VT, sparseReshape: zT, sparseSegmentMean: WT, sparseSegmentSum: UT };
-var Hq = { stringNGrams: GT, stringSplit: HT, stringToHashBucketFast: qT };
-var wr = class extends ll {
- minimize(e, t10 = false, o) {
+var CN = N({ stringToHashBucketFast_: sq });
+var aq = { fft: zp, ifft: hu, rfft: Wp, irfft: Fd };
+var iq = { hammingWindow: L1, hannWindow: Ld, frame: Bd, stft: B1 };
+var uq = { flipLeftRight: z1, grayscaleToRGB: W1, resizeNearestNeighbor: J1, resizeBilinear: Z1, rotateWithOffset: U1, cropAndResize: V1, nonMaxSuppression: G1, nonMaxSuppressionAsync: K1, nonMaxSuppressionWithScore: j1, nonMaxSuppressionWithScoreAsync: X1, nonMaxSuppressionPadded: Y1, nonMaxSuppressionPaddedAsync: Q1, threshold: eN, transform: tN };
+var pq = { bandPart: rN, gramSchmidt: oN, qr: sN };
+var cq = { absoluteDifference: aN, computeWeightedLoss: sr, cosineDistance: iN, hingeLoss: uN, huberLoss: pN, logLoss: cN, meanSquaredError: lN, sigmoidCrossEntropy: mN, softmaxCrossEntropy: dN };
+var lq = { sparseFillEmptyRows: fN, sparseReshape: hN, sparseSegmentMean: gN, sparseSegmentSum: xN };
+var mq = { stringNGrams: yN, stringSplit: bN, stringToHashBucketFast: CN };
+var wr = class extends ol {
+ minimize(e, t6 = false, o) {
let { value: n, grads: s } = this.computeGradients(e, o);
if (o != null) {
let a = o.map((i) => ({ name: i.name, tensor: s[i.name] }));
this.applyGradients(a);
} else
this.applyGradients(s);
- return Ft(s), t10 ? n : (n.dispose(), null);
+ return Dt(s), t6 ? n : (n.dispose(), null);
}
get iterations() {
return this.iterations_ == null && (this.iterations_ = 0), this.iterations_;
@@ -8625,11 +8635,11 @@ var wr = class extends ll {
incrementIterations() {
this.iterations_ = this.iterations + 1;
}
- computeGradients(e, t10) {
- return dC(e, t10);
+ computeGradients(e, t6) {
+ return pC(e, t6);
}
dispose() {
- this.iterations_ != null && Ft(this.iterations_);
+ this.iterations_ != null && Dt(this.iterations_);
}
async saveIterations() {
return this.iterations_ == null && (this.iterations_ = 0), { name: "iter", tensor: be(this.iterations_, "int32") };
@@ -8645,158 +8655,158 @@ var wr = class extends ll {
}
};
Object.defineProperty(wr, Symbol.hasInstance, { value: (r) => r.minimize != null && r.computeGradients != null && r.applyGradients != null });
-var xi = class extends wr {
- constructor(e, t10, o = null) {
- super(), this.learningRate = e, this.rho = t10, this.epsilon = o, this.accumulatedGrads = [], this.accumulatedUpdates = [], o == null && (this.epsilon = N.backend.epsilon());
+var Ei = class extends wr {
+ constructor(e, t6, o = null) {
+ super(), this.learningRate = e, this.rho = t6, this.epsilon = o, this.accumulatedGrads = [], this.accumulatedUpdates = [], o == null && (this.epsilon = T.backend.epsilon());
}
applyGradients(e) {
(Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e)).forEach((o, n) => {
- let s = N.registeredVariables[o], a = false;
- this.accumulatedGrads[n] == null && (this.accumulatedGrads[n] = { originalName: `${o}/accum_grad`, variable: Ne(() => Gt(s).variable(a)) }), this.accumulatedUpdates[n] == null && (this.accumulatedUpdates[n] = { originalName: `${o}/accum_var`, variable: Ne(() => Gt(s).variable(a)) });
+ let s = T.registeredVariables[o], a = false;
+ this.accumulatedGrads[n] == null && (this.accumulatedGrads[n] = { originalName: `${o}/accum_grad`, variable: Ee(() => Ut(s).variable(a)) }), this.accumulatedUpdates[n] == null && (this.accumulatedUpdates[n] = { originalName: `${o}/accum_var`, variable: Ee(() => Ut(s).variable(a)) });
let i = Array.isArray(e) ? e[n].tensor : e[o];
if (i == null)
return;
let p = this.accumulatedGrads[n].variable, u = this.accumulatedUpdates[n].variable;
- Ne(() => {
- let c = ge(oe(p, this.rho), oe(Zt(i), 1 - this.rho)), l = oe(We(Rr(ge(u, this.epsilon)), Rr(ge(p, this.epsilon))), i), m = ge(oe(u, this.rho), oe(Zt(l), 1 - this.rho));
+ Ee(() => {
+ let c = xe(ae(p, this.rho), ae(Qt(i), 1 - this.rho)), l = ae(Ge($r(xe(u, this.epsilon)), $r(xe(p, this.epsilon))), i), m = xe(ae(u, this.rho), ae(Qt(l), 1 - this.rho));
p.assign(c), u.assign(m);
- let f = ge(oe(l, -this.learningRate), s);
- s.assign(f);
+ let d = xe(ae(l, -this.learningRate), s);
+ s.assign(d);
});
}), this.incrementIterations();
}
dispose() {
- this.accumulatedUpdates != null && (Ft(this.accumulatedGrads.map((e) => e.variable)), Ft(this.accumulatedUpdates.map((e) => e.variable)));
+ this.accumulatedUpdates != null && (Dt(this.accumulatedGrads.map((e) => e.variable)), Dt(this.accumulatedUpdates.map((e) => e.variable)));
}
async getWeights() {
let e = [...this.accumulatedGrads, ...this.accumulatedUpdates];
- return [await this.saveIterations()].concat(e.map((t10) => ({ name: t10.originalName, tensor: t10.variable })));
+ return [await this.saveIterations()].concat(e.map((t6) => ({ name: t6.originalName, tensor: t6.variable })));
}
async setWeights(e) {
e = await this.extractIterations(e);
- let t10 = e.length / 2, o = false;
- this.accumulatedGrads = e.slice(0, t10).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })), this.accumulatedUpdates = e.slice(t10, t10 * 2).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) }));
+ let t6 = e.length / 2, o = false;
+ this.accumulatedGrads = e.slice(0, t6).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })), this.accumulatedUpdates = e.slice(t6, t6 * 2).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) }));
}
getConfig() {
return { learningRate: this.learningRate, rho: this.rho, epsilon: this.epsilon };
}
- static fromConfig(e, t10) {
- return new e(t10.learningRate, t10.rho, t10.epsilon);
+ static fromConfig(e, t6) {
+ return new e(t6.learningRate, t6.rho, t6.epsilon);
}
};
-xi.className = "Adadelta";
-$r(xi);
-var yi = class extends wr {
- constructor(e, t10 = 0.1) {
- super(), this.learningRate = e, this.initialAccumulatorValue = t10, this.accumulatedGrads = [];
+Ei.className = "Adadelta";
+Er(Ei);
+var $i = class extends wr {
+ constructor(e, t6 = 0.1) {
+ super(), this.learningRate = e, this.initialAccumulatorValue = t6, this.accumulatedGrads = [];
}
applyGradients(e) {
(Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e)).forEach((o, n) => {
- let s = N.registeredVariables[o];
- this.accumulatedGrads[n] == null && (this.accumulatedGrads[n] = { originalName: `${o}/accumulator`, variable: Ne(() => Bs(s.shape, this.initialAccumulatorValue).variable(false)) });
+ let s = T.registeredVariables[o];
+ this.accumulatedGrads[n] == null && (this.accumulatedGrads[n] = { originalName: `${o}/accumulator`, variable: Ee(() => Ws(s.shape, this.initialAccumulatorValue).variable(false)) });
let a = Array.isArray(e) ? e[n].tensor : e[o];
if (a == null)
return;
let i = this.accumulatedGrads[n].variable;
- Ne(() => {
- let p = ge(i, Zt(a));
+ Ee(() => {
+ let p = xe(i, Qt(a));
i.assign(p);
- let u = ge(oe(We(a, Rr(ge(p, N.backend.epsilon()))), -this.learningRate), s);
+ let u = xe(ae(Ge(a, $r(xe(p, T.backend.epsilon()))), -this.learningRate), s);
s.assign(u);
});
}), this.incrementIterations();
}
dispose() {
- this.accumulatedGrads != null && Ft(this.accumulatedGrads.map((e) => e.variable));
+ this.accumulatedGrads != null && Dt(this.accumulatedGrads.map((e) => e.variable));
}
async getWeights() {
return [await this.saveIterations()].concat(this.accumulatedGrads.map((e) => ({ name: e.originalName, tensor: e.variable })));
}
async setWeights(e) {
e = await this.extractIterations(e);
- let t10 = false;
- this.accumulatedGrads = e.map((o) => ({ originalName: o.name, variable: o.tensor.variable(t10) }));
+ let t6 = false;
+ this.accumulatedGrads = e.map((o) => ({ originalName: o.name, variable: o.tensor.variable(t6) }));
}
getConfig() {
return { learningRate: this.learningRate, initialAccumulatorValue: this.initialAccumulatorValue };
}
- static fromConfig(e, t10) {
- return new e(t10.learningRate, t10.initialAccumulatorValue);
+ static fromConfig(e, t6) {
+ return new e(t6.learningRate, t6.initialAccumulatorValue);
}
};
-yi.className = "Adagrad";
-$r(yi);
-var bi = class extends wr {
- constructor(e, t10, o, n = null) {
- super(), this.learningRate = e, this.beta1 = t10, this.beta2 = o, this.epsilon = n, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], Ne(() => {
- this.accBeta1 = be(t10).variable(), this.accBeta2 = be(o).variable();
- }), n == null && (this.epsilon = N.backend.epsilon());
+$i.className = "Adagrad";
+Er($i);
+var Ai = class extends wr {
+ constructor(e, t6, o, n = null) {
+ super(), this.learningRate = e, this.beta1 = t6, this.beta2 = o, this.epsilon = n, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], Ee(() => {
+ this.accBeta1 = be(t6).variable(), this.accBeta2 = be(o).variable();
+ }), n == null && (this.epsilon = T.backend.epsilon());
}
applyGradients(e) {
- let t10 = Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e);
- Ne(() => {
- let o = ke(1, this.accBeta1), n = ke(1, this.accBeta2);
- t10.forEach((s, a) => {
- let i = N.registeredVariables[s], p = false;
- this.accumulatedFirstMoment[a] == null && (this.accumulatedFirstMoment[a] = { originalName: `${s}/m`, variable: Ne(() => Gt(i).variable(p)) }), this.accumulatedSecondMoment[a] == null && (this.accumulatedSecondMoment[a] = { originalName: `${s}/v`, variable: Ne(() => Gt(i).variable(p)) });
+ let t6 = Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e);
+ Ee(() => {
+ let o = Ne(1, this.accBeta1), n = Ne(1, this.accBeta2);
+ t6.forEach((s, a) => {
+ let i = T.registeredVariables[s], p = false;
+ this.accumulatedFirstMoment[a] == null && (this.accumulatedFirstMoment[a] = { originalName: `${s}/m`, variable: Ee(() => Ut(i).variable(p)) }), this.accumulatedSecondMoment[a] == null && (this.accumulatedSecondMoment[a] = { originalName: `${s}/v`, variable: Ee(() => Ut(i).variable(p)) });
let u = Array.isArray(e) ? e[a].tensor : e[s];
if (u == null)
return;
- let c = this.accumulatedFirstMoment[a].variable, l = this.accumulatedSecondMoment[a].variable, m = ge(oe(c, this.beta1), oe(u, 1 - this.beta1)), f = ge(oe(l, this.beta2), oe(Zt(u), 1 - this.beta2)), d = We(m, o), h = We(f, n);
- c.assign(m), l.assign(f);
- let g = ge(oe(We(d, ge(Rr(h), this.epsilon)), -this.learningRate), i);
+ let c = this.accumulatedFirstMoment[a].variable, l = this.accumulatedSecondMoment[a].variable, m = xe(ae(c, this.beta1), ae(u, 1 - this.beta1)), d = xe(ae(l, this.beta2), ae(Qt(u), 1 - this.beta2)), f = Ge(m, o), h = Ge(d, n);
+ c.assign(m), l.assign(d);
+ let g = xe(ae(Ge(f, xe($r(h), this.epsilon)), -this.learningRate), i);
i.assign(g);
- }), this.accBeta1.assign(oe(this.accBeta1, this.beta1)), this.accBeta2.assign(oe(this.accBeta2, this.beta2));
+ }), this.accBeta1.assign(ae(this.accBeta1, this.beta1)), this.accBeta2.assign(ae(this.accBeta2, this.beta2));
}), this.incrementIterations();
}
dispose() {
- this.accBeta1.dispose(), this.accBeta2.dispose(), this.accumulatedFirstMoment != null && Ft(this.accumulatedFirstMoment.map((e) => e.variable)), this.accumulatedSecondMoment != null && Ft(this.accumulatedSecondMoment.map((e) => e.variable));
+ this.accBeta1.dispose(), this.accBeta2.dispose(), this.accumulatedFirstMoment != null && Dt(this.accumulatedFirstMoment.map((e) => e.variable)), this.accumulatedSecondMoment != null && Dt(this.accumulatedSecondMoment.map((e) => e.variable));
}
async getWeights() {
let e = [...this.accumulatedFirstMoment, ...this.accumulatedSecondMoment];
- return [await this.saveIterations()].concat(e.map((t10) => ({ name: t10.originalName, tensor: t10.variable })));
+ return [await this.saveIterations()].concat(e.map((t6) => ({ name: t6.originalName, tensor: t6.variable })));
}
async setWeights(e) {
- e = await this.extractIterations(e), Ne(() => {
- this.accBeta1.assign(Na(this.beta1, this.iterations_ + 1)), this.accBeta2.assign(Na(this.beta2, this.iterations_ + 1));
+ e = await this.extractIterations(e), Ee(() => {
+ this.accBeta1.assign(Ra(this.beta1, this.iterations_ + 1)), this.accBeta2.assign(Ra(this.beta2, this.iterations_ + 1));
});
- let t10 = e.length / 2, o = false;
- this.accumulatedFirstMoment = e.slice(0, t10).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })), this.accumulatedSecondMoment = e.slice(t10, t10 * 2).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) }));
+ let t6 = e.length / 2, o = false;
+ this.accumulatedFirstMoment = e.slice(0, t6).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })), this.accumulatedSecondMoment = e.slice(t6, t6 * 2).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) }));
}
getConfig() {
return { learningRate: this.learningRate, beta1: this.beta1, beta2: this.beta2, epsilon: this.epsilon };
}
- static fromConfig(e, t10) {
- return new e(t10.learningRate, t10.beta1, t10.beta2, t10.epsilon);
+ static fromConfig(e, t6) {
+ return new e(t6.learningRate, t6.beta1, t6.beta2, t6.epsilon);
}
};
-bi.className = "Adam";
-$r(bi);
-var Ci = class extends wr {
- constructor(e, t10, o, n = null, s = 0) {
- super(), this.learningRate = e, this.beta1 = t10, this.beta2 = o, this.epsilon = n, this.decay = s, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], Ne(() => {
- this.iteration = be(0).variable(), this.accBeta1 = be(t10).variable();
- }), n == null && (this.epsilon = N.backend.epsilon());
+Ai.className = "Adam";
+Er(Ai);
+var Ri = class extends wr {
+ constructor(e, t6, o, n = null, s = 0) {
+ super(), this.learningRate = e, this.beta1 = t6, this.beta2 = o, this.epsilon = n, this.decay = s, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], Ee(() => {
+ this.iteration = be(0).variable(), this.accBeta1 = be(t6).variable();
+ }), n == null && (this.epsilon = T.backend.epsilon());
}
applyGradients(e) {
- let t10 = Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e);
- Ne(() => {
- let o = ke(1, this.accBeta1), n = We(-this.learningRate, ge(oe(this.iteration, this.decay), 1));
- t10.forEach((s, a) => {
- let i = N.registeredVariables[s], p = false;
- this.accumulatedFirstMoment[a] == null && (this.accumulatedFirstMoment[a] = { originalName: `${s}/m`, variable: Gt(i).variable(p) }), this.accumulatedWeightedInfNorm[a] == null && (this.accumulatedWeightedInfNorm[a] = { originalName: `${s}/v`, variable: Gt(i).variable(p) });
+ let t6 = Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e);
+ Ee(() => {
+ let o = Ne(1, this.accBeta1), n = Ge(-this.learningRate, xe(ae(this.iteration, this.decay), 1));
+ t6.forEach((s, a) => {
+ let i = T.registeredVariables[s], p = false;
+ this.accumulatedFirstMoment[a] == null && (this.accumulatedFirstMoment[a] = { originalName: `${s}/m`, variable: Ut(i).variable(p) }), this.accumulatedWeightedInfNorm[a] == null && (this.accumulatedWeightedInfNorm[a] = { originalName: `${s}/v`, variable: Ut(i).variable(p) });
let u = Array.isArray(e) ? e[a].tensor : e[s];
if (u == null)
return;
- let c = this.accumulatedFirstMoment[a].variable, l = this.accumulatedWeightedInfNorm[a].variable, m = ge(oe(c, this.beta1), oe(u, 1 - this.beta1)), f = oe(l, this.beta2), d = Qt(u), h = Rf(f, d);
+ let c = this.accumulatedFirstMoment[a].variable, l = this.accumulatedWeightedInfNorm[a].variable, m = xe(ae(c, this.beta1), ae(u, 1 - this.beta1)), d = ae(l, this.beta2), f = Yt(u), h = Cd(d, f);
c.assign(m), l.assign(h);
- let g = ge(oe(We(n, o), We(m, ge(h, this.epsilon))), i);
+ let g = xe(ae(Ge(n, o), Ge(m, xe(h, this.epsilon))), i);
i.assign(g);
- }), this.iteration.assign(ge(this.iteration, 1)), this.accBeta1.assign(oe(this.accBeta1, this.beta1));
+ }), this.iteration.assign(xe(this.iteration, 1)), this.accBeta1.assign(ae(this.accBeta1, this.beta1));
}), this.incrementIterations();
}
dispose() {
- this.accBeta1.dispose(), this.iteration.dispose(), this.accumulatedFirstMoment != null && Ft(this.accumulatedFirstMoment.map((e) => e.variable)), this.accumulatedWeightedInfNorm != null && Ft(this.accumulatedWeightedInfNorm.map((e) => e.variable));
+ this.accBeta1.dispose(), this.iteration.dispose(), this.accumulatedFirstMoment != null && Dt(this.accumulatedFirstMoment.map((e) => e.variable)), this.accumulatedWeightedInfNorm != null && Dt(this.accumulatedWeightedInfNorm.map((e) => e.variable));
}
async getWeights() {
throw new Error("getWeights() is not implemented for Adamax yet.");
@@ -8807,13 +8817,13 @@ var Ci = class extends wr {
getConfig() {
return { learningRate: this.learningRate, beta1: this.beta1, beta2: this.beta2, epsilon: this.epsilon, decay: this.decay };
}
- static fromConfig(e, t10) {
- return new e(t10.learningRate, t10.beta1, t10.beta2, t10.epsilon, t10.decay);
+ static fromConfig(e, t6) {
+ return new e(t6.learningRate, t6.beta1, t6.beta2, t6.epsilon, t6.decay);
}
};
-Ci.className = "Adamax";
-$r(Ci);
-var Us = class extends wr {
+Ri.className = "Adamax";
+Er(Ri);
+var qs = class extends wr {
constructor(e) {
super(), this.learningRate = e, this.setLearningRate(e);
}
@@ -8822,15 +8832,15 @@ var Us = class extends wr {
let s = Array.isArray(e) ? e[n].tensor : e[o];
if (s == null)
return;
- let a = N.registeredVariables[o];
- Ne(() => {
- let i = ge(oe(this.c, s), a);
+ let a = T.registeredVariables[o];
+ Ee(() => {
+ let i = xe(ae(this.c, s), a);
a.assign(i);
});
}), this.incrementIterations();
}
setLearningRate(e) {
- this.learningRate = e, this.c != null && this.c.dispose(), this.c = So(be(-e));
+ this.learningRate = e, this.c != null && this.c.dispose(), this.c = _r(be(-e));
}
dispose() {
this.c.dispose();
@@ -8845,29 +8855,29 @@ var Us = class extends wr {
getConfig() {
return { learningRate: this.learningRate };
}
- static fromConfig(e, t10) {
- return new e(t10.learningRate);
+ static fromConfig(e, t6) {
+ return new e(t6.learningRate);
}
};
-Us.className = "SGD";
-$r(Us);
-var Ii = class extends Us {
- constructor(e, t10, o = false) {
- super(e), this.learningRate = e, this.momentum = t10, this.useNesterov = o, this.accumulations = [], this.m = be(this.momentum);
+qs.className = "SGD";
+Er(qs);
+var Fi = class extends qs {
+ constructor(e, t6, o = false) {
+ super(e), this.learningRate = e, this.momentum = t6, this.useNesterov = o, this.accumulations = [], this.m = be(this.momentum);
}
applyGradients(e) {
(Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e)).forEach((o, n) => {
- let s = N.registeredVariables[o];
- this.accumulations[n] == null && (this.accumulations[n] = { originalName: `${o}/momentum`, variable: Ne(() => Gt(s).variable(false)) });
+ let s = T.registeredVariables[o];
+ this.accumulations[n] == null && (this.accumulations[n] = { originalName: `${o}/momentum`, variable: Ee(() => Ut(s).variable(false)) });
let a = this.accumulations[n].variable, i = Array.isArray(e) ? e[n].tensor : e[o];
- i != null && Ne(() => {
- let p, u = ge(oe(this.m, a), i);
- this.useNesterov ? p = ge(oe(this.c, ge(i, oe(u, this.m))), s) : p = ge(oe(this.c, u), s), a.assign(u), s.assign(p);
+ i != null && Ee(() => {
+ let p, u = xe(ae(this.m, a), i);
+ this.useNesterov ? p = xe(ae(this.c, xe(i, ae(u, this.m))), s) : p = xe(ae(this.c, u), s), a.assign(u), s.assign(p);
});
}), this.incrementIterations();
}
dispose() {
- this.m.dispose(), this.accumulations != null && Ft(this.accumulations.map((e) => e.variable));
+ this.m.dispose(), this.accumulations != null && Dt(this.accumulations.map((e) => e.variable));
}
setMomentum(e) {
this.momentum = e;
@@ -8877,134 +8887,134 @@ var Ii = class extends Us {
}
async setWeights(e) {
e = await this.extractIterations(e);
- let t10 = false;
- this.accumulations = e.map((o) => ({ originalName: o.name, variable: o.tensor.variable(t10) }));
+ let t6 = false;
+ this.accumulations = e.map((o) => ({ originalName: o.name, variable: o.tensor.variable(t6) }));
}
getConfig() {
return { learningRate: this.learningRate, momentum: this.momentum, useNesterov: this.useNesterov };
}
- static fromConfig(e, t10) {
- return new e(t10.learningRate, t10.momentum, t10.useNesterov);
+ static fromConfig(e, t6) {
+ return new e(t6.learningRate, t6.momentum, t6.useNesterov);
}
};
-Ii.className = "Momentum";
-$r(Ii);
-var wi = class extends wr {
- constructor(e, t10 = 0.9, o = 0, n = null, s = false) {
- if (super(), this.learningRate = e, this.decay = t10, this.momentum = o, this.epsilon = n, this.accumulatedMeanSquares = [], this.accumulatedMoments = [], this.accumulatedMeanGrads = [], this.centered = s, n == null && (this.epsilon = N.backend.epsilon()), e == null)
+Fi.className = "Momentum";
+Er(Fi);
+var Di = class extends wr {
+ constructor(e, t6 = 0.9, o = 0, n = null, s = false) {
+ if (super(), this.learningRate = e, this.decay = t6, this.momentum = o, this.epsilon = n, this.accumulatedMeanSquares = [], this.accumulatedMoments = [], this.accumulatedMeanGrads = [], this.centered = s, n == null && (this.epsilon = T.backend.epsilon()), e == null)
throw new Error("learningRate for RMSPropOptimizer must be defined.");
}
applyGradients(e) {
(Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e)).forEach((o, n) => {
- let s = N.registeredVariables[o], a = false;
- this.accumulatedMeanSquares[n] == null && (this.accumulatedMeanSquares[n] = { originalName: `${o}/rms`, variable: Ne(() => Gt(s).variable(a)) }), this.accumulatedMoments[n] == null && (this.accumulatedMoments[n] = { originalName: `${o}/momentum`, variable: Ne(() => Gt(s).variable(a)) }), this.accumulatedMeanGrads[n] == null && this.centered && (this.accumulatedMeanGrads[n] = { originalName: `${o}/mg`, variable: Ne(() => Gt(s).variable(a)) });
+ let s = T.registeredVariables[o], a = false;
+ this.accumulatedMeanSquares[n] == null && (this.accumulatedMeanSquares[n] = { originalName: `${o}/rms`, variable: Ee(() => Ut(s).variable(a)) }), this.accumulatedMoments[n] == null && (this.accumulatedMoments[n] = { originalName: `${o}/momentum`, variable: Ee(() => Ut(s).variable(a)) }), this.accumulatedMeanGrads[n] == null && this.centered && (this.accumulatedMeanGrads[n] = { originalName: `${o}/mg`, variable: Ee(() => Ut(s).variable(a)) });
let i = Array.isArray(e) ? e[n].tensor : e[o];
if (i == null)
return;
let p = this.accumulatedMeanSquares[n].variable, u = this.accumulatedMoments[n].variable;
- Ne(() => {
- let c = ge(oe(p, this.decay), oe(Zt(i), 1 - this.decay));
+ Ee(() => {
+ let c = xe(ae(p, this.decay), ae(Qt(i), 1 - this.decay));
if (this.centered) {
- let l = this.accumulatedMeanGrads[n].variable, m = ge(oe(l, this.decay), oe(i, 1 - this.decay)), f = We(oe(i, this.learningRate), Rr(ke(c, ge(Zt(m), this.epsilon)))), d = ge(oe(u, this.momentum), f);
- p.assign(c), l.assign(m), u.assign(d);
- let h = ke(s, d);
+ let l = this.accumulatedMeanGrads[n].variable, m = xe(ae(l, this.decay), ae(i, 1 - this.decay)), d = Ge(ae(i, this.learningRate), $r(Ne(c, xe(Qt(m), this.epsilon)))), f = xe(ae(u, this.momentum), d);
+ p.assign(c), l.assign(m), u.assign(f);
+ let h = Ne(s, f);
s.assign(h);
} else {
- let l = ge(oe(p, this.decay), oe(Zt(i), 1 - this.decay)), m = ge(oe(u, this.momentum), We(oe(i, this.learningRate), Rr(ge(l, this.epsilon))));
+ let l = xe(ae(p, this.decay), ae(Qt(i), 1 - this.decay)), m = xe(ae(u, this.momentum), Ge(ae(i, this.learningRate), $r(xe(l, this.epsilon))));
p.assign(l), u.assign(m);
- let f = ke(s, m);
- s.assign(f);
+ let d = Ne(s, m);
+ s.assign(d);
}
});
}), this.incrementIterations();
}
dispose() {
- this.accumulatedMeanSquares != null && Ft(this.accumulatedMeanSquares.map((e) => e.variable)), this.accumulatedMeanGrads != null && this.centered && Ft(this.accumulatedMeanGrads.map((e) => e.variable)), this.accumulatedMoments != null && Ft(this.accumulatedMoments.map((e) => e.variable));
+ this.accumulatedMeanSquares != null && Dt(this.accumulatedMeanSquares.map((e) => e.variable)), this.accumulatedMeanGrads != null && this.centered && Dt(this.accumulatedMeanGrads.map((e) => e.variable)), this.accumulatedMoments != null && Dt(this.accumulatedMoments.map((e) => e.variable));
}
async getWeights() {
let e = [...this.accumulatedMeanSquares, ...this.accumulatedMoments];
- return this.centered && e.push(...this.accumulatedMeanGrads), [await this.saveIterations()].concat(e.map((t10) => ({ name: t10.originalName, tensor: t10.variable })));
+ return this.centered && e.push(...this.accumulatedMeanGrads), [await this.saveIterations()].concat(e.map((t6) => ({ name: t6.originalName, tensor: t6.variable })));
}
async setWeights(e) {
e = await this.extractIterations(e);
- let t10 = this.centered ? e.length / 3 : e.length / 2, o = false;
- this.accumulatedMeanSquares = e.slice(0, t10).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })), this.accumulatedMoments = e.slice(t10, t10 * 2).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })), this.centered && (this.accumulatedMeanGrads = e.slice(t10 * 2, t10 * 3).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })));
+ let t6 = this.centered ? e.length / 3 : e.length / 2, o = false;
+ this.accumulatedMeanSquares = e.slice(0, t6).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })), this.accumulatedMoments = e.slice(t6, t6 * 2).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })), this.centered && (this.accumulatedMeanGrads = e.slice(t6 * 2, t6 * 3).map((n) => ({ originalName: n.name, variable: n.tensor.variable(o) })));
}
getConfig() {
return { learningRate: this.learningRate, decay: this.decay, momentum: this.momentum, epsilon: this.epsilon, centered: this.centered };
}
- static fromConfig(e, t10) {
- return new e(t10.learningRate, t10.decay, t10.momentum, t10.epsilon, t10.centered);
+ static fromConfig(e, t6) {
+ return new e(t6.learningRate, t6.decay, t6.momentum, t6.epsilon, t6.centered);
}
};
-wi.className = "RMSProp";
-$r(wi);
+Di.className = "RMSProp";
+Er(Di);
var ns = class {
static sgd(e) {
- return new Us(e);
+ return new qs(e);
}
- static momentum(e, t10, o = false) {
- return new Ii(e, t10, o);
+ static momentum(e, t6, o = false) {
+ return new Fi(e, t6, o);
}
- static rmsprop(e, t10 = 0.9, o = 0, n = null, s = false) {
- return new wi(e, t10, o, n, s);
+ static rmsprop(e, t6 = 0.9, o = 0, n = null, s = false) {
+ return new Di(e, t6, o, n, s);
}
- static adam(e = 1e-3, t10 = 0.9, o = 0.999, n = null) {
- return new bi(e, t10, o, n);
+ static adam(e = 1e-3, t6 = 0.9, o = 0.999, n = null) {
+ return new Ai(e, t6, o, n);
}
- static adadelta(e = 1e-3, t10 = 0.95, o = null) {
- return new xi(e, t10, o);
+ static adadelta(e = 1e-3, t6 = 0.95, o = null) {
+ return new Ei(e, t6, o);
}
- static adamax(e = 2e-3, t10 = 0.9, o = 0.999, n = null, s = 0) {
- return new Ci(e, t10, o, n, s);
+ static adamax(e = 2e-3, t6 = 0.9, o = 0.999, n = null, s = 0) {
+ return new Ri(e, t6, o, n, s);
}
- static adagrad(e, t10 = 0.1) {
- return new yi(e, t10);
+ static adagrad(e, t6 = 0.1) {
+ return new $i(e, t6);
}
};
-var pMe = { sgd: ns.sgd, momentum: ns.momentum, adadelta: ns.adadelta, adagrad: ns.adagrad, rmsprop: ns.rmsprop, adamax: ns.adamax, adam: ns.adam };
-var qq = (() => typeof requestAnimationFrame != "undefined" ? requestAnimationFrame : typeof setImmediate != "undefined" ? setImmediate : (r) => r())();
-function kC() {
- return new Promise((r) => qq(() => r()));
+var hMe = { sgd: ns.sgd, momentum: ns.momentum, adadelta: ns.adadelta, adagrad: ns.adagrad, rmsprop: ns.rmsprop, adamax: ns.adamax, adam: ns.adam };
+var dq = (() => typeof requestAnimationFrame != "undefined" ? requestAnimationFrame : typeof setImmediate != "undefined" ? setImmediate : (r) => r())();
+function CC() {
+ return new Promise((r) => dq(() => r()));
}
-var I = {};
-Be(I, { ERF_A1: () => pK, ERF_A2: () => cK, ERF_A3: () => lK, ERF_A4: () => mK, ERF_A5: () => fK, ERF_P: () => uK, PARALLELIZE_THRESHOLD: () => ed, RowPartitionType: () => Gs, SELU_SCALE: () => iK, SELU_SCALEALPHA: () => aK, applyActivation: () => yu, assertAndGetBroadcastShape: () => Je, assertAxesAreInnerMostDims: () => fG, assertParamsConsistent: () => Kq, assignToTypedArray: () => bK, axesAreInnerMostDims: () => fC, calculateShapes: () => kv, checkEinsumDimSizes: () => kK, checkPadOnDimRoundingMode: () => Ot, combineLocations: () => $k, combineRaggedTensorToTensorShapes: () => Xq, complexWithEvenIndex: () => gK, complexWithOddIndex: () => xK, computeConv2DInfo: () => uu, computeConv3DInfo: () => Zv, computeDefaultPad: () => mC, computeDilation2DInfo: () => dU, computeOptimalWindowSize: () => Jq, computeOutAndReduceShapes: () => mG, computeOutShape: () => jq, computePool2DInfo: () => lC, computePool3DInfo: () => hU, convertConv2DDataFormat: () => Jv, decodeEinsumEquation: () => SK, eitherStridesOrDilationsAreOne: () => lr, expandShapeToKeepDim: () => Ta, exponent: () => IK, exponents: () => CK, fromStringArrayToUint8: () => qK, fromUint8ToStringArray: () => HK, getAxesPermutation: () => dG, getBroadcastDims: () => Iv, getComplexWithIndex: () => yK, getEinsumComputePath: () => TK, getEinsumPermutation: () => vK, getFusedBiasGradient: () => xu, getFusedDyActivation: () => gu, getImageCenter: () => eK, getInnerMostAxes: () => gG, getPermuted: () => rK, getRaggedRank: () => Qq, getReductionAxes: () => nf, getReshaped: () => tK, getReshapedPermuted: () => oK, getRowPartitionTypesHelper: () => Yq, getSliceBeginCoords: () => nK, getSliceSize: () => sK, getSparseFillEmptyRowsIndicesDenseShapeMismatch: () => $K, getSparseFillEmptyRowsNegativeIndexErrorMessage: () => RK, getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: () => AK, getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: () => PK, getSparseReshapeInputOutputMismatchErrorMessage: () => MK, getSparseReshapeInputOutputMultipleErrorMessage: () => OK, getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: () => FK, getSparseReshapeNegativeOutputDimErrorMessage: () => DK, getSparseSegmentReductionIndicesOutOfRangeErrorMessage: () => zK, getSparseSegmentReductionNegativeSegmentIdsErrorMessage: () => LK, getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: () => BK, getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: () => VK, getUndoAxesPermutation: () => hG, isIdentityPermutation: () => NK, log: () => Sz, mergeRealAndImagArrays: () => dK, prepareAndValidate: () => vv, prepareSplitSize: () => EK, segment_util: () => NC, shouldFuse: () => bu, slice_util: () => et, splitRealAndImagArrays: () => hK, tupleValuesAreOne: () => iu, upcastType: () => ct, validateDefaultValueShape: () => Zq, validateInput: () => uf, validateUpdateShape: () => aC, warn: () => Rs });
-function Kq(r, e) {
- let t10 = r[0].length;
+var S = {};
+Ue(S, { ERF_A1: () => $q, ERF_A2: () => Aq, ERF_A3: () => Rq, ERF_A4: () => Fq, ERF_A5: () => Dq, ERF_P: () => Eq, PARALLELIZE_THRESHOLD: () => Ud, RowPartitionType: () => Ks, SELU_SCALE: () => _q, SELU_SCALEALPHA: () => Tq, applyActivation: () => yu, assertAndGetBroadcastShape: () => Je, assertAxesAreInnerMostDims: () => DU, assertParamsConsistent: () => fq, assignToTypedArray: () => Vq, axesAreInnerMostDims: () => uC, calculateShapes: () => Jv, checkEinsumDimSizes: () => qq, checkPadOnDimRoundingMode: () => Pt, combineLocations: () => nk, combineRaggedTensorToTensorShapes: () => gq, complexWithEvenIndex: () => Mq, complexWithOddIndex: () => Lq, computeConv2DInfo: () => uu, computeConv3DInfo: () => N0, computeDefaultPad: () => iC, computeDilation2DInfo: () => OW, computeOptimalWindowSize: () => Cq, computeOutAndReduceShapes: () => FU, computeOutShape: () => hq, computePool2DInfo: () => aC, computePool3DInfo: () => PW, convertConv2DDataFormat: () => T0, decodeEinsumEquation: () => Gq, eitherStridesOrDilationsAreOne: () => lr, expandShapeToKeepDim: () => Aa, exponent: () => Wq, exponents: () => zq, fromStringArrayToUint8: () => dK, fromUint8ToStringArray: () => mK, getAxesPermutation: () => OU, getBroadcastDims: () => Xv, getComplexWithIndex: () => Bq, getEinsumComputePath: () => Kq, getEinsumPermutation: () => Hq, getFusedBiasGradient: () => xu, getFusedDyActivation: () => gu, getImageCenter: () => Sq, getInnerMostAxes: () => MU, getPermuted: () => Iq, getRaggedRank: () => yq, getReductionAxes: () => jm, getReshaped: () => wq, getReshapedPermuted: () => vq, getRowPartitionTypesHelper: () => xq, getSliceBeginCoords: () => kq, getSliceSize: () => Nq, getSparseFillEmptyRowsIndicesDenseShapeMismatch: () => Qq, getSparseFillEmptyRowsNegativeIndexErrorMessage: () => Zq, getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: () => Jq, getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: () => rK, getSparseReshapeInputOutputMismatchErrorMessage: () => nK, getSparseReshapeInputOutputMultipleErrorMessage: () => oK, getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: () => eK, getSparseReshapeNegativeOutputDimErrorMessage: () => tK, getSparseSegmentReductionIndicesOutOfRangeErrorMessage: () => uK, getSparseSegmentReductionNegativeSegmentIdsErrorMessage: () => sK, getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: () => aK, getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: () => iK, getUndoAxesPermutation: () => PU, isIdentityPermutation: () => jq, log: () => GV, mergeRealAndImagArrays: () => Oq, prepareAndValidate: () => Zv, prepareSplitSize: () => Yq, segment_util: () => wC, shouldFuse: () => bu, slice_util: () => ut, splitRealAndImagArrays: () => Pq, tupleValuesAreOne: () => iu, upcastType: () => dt, validateDefaultValueShape: () => bq, validateInput: () => Qm, validateUpdateShape: () => tC, warn: () => Os });
+function fq(r, e) {
+ let t6 = r[0].length;
r.forEach((n, s) => {
- $(n.length === t10, () => `Error in concat${t10}D: rank of tensors[${s}] must be the same as the rank of the rest (${t10})`);
- }), $(e >= 0 && e < t10, () => `Error in concat${t10}D: axis must be between 0 and ${t10 - 1}.`);
+ E(n.length === t6, () => `Error in concat${t6}D: rank of tensors[${s}] must be the same as the rank of the rest (${t6})`);
+ }), E(e >= 0 && e < t6, () => `Error in concat${t6}D: axis must be between 0 and ${t6 - 1}.`);
let o = r[0];
r.forEach((n, s) => {
- for (let a = 0; a < t10; a++)
- $(a === e || n[a] === o[a], () => `Error in concat${t10}D: Shape of tensors[${s}] (${n}) does not match the shape of the rest (${o}) along the non-concatenated axis ${s}.`);
+ for (let a = 0; a < t6; a++)
+ E(a === e || n[a] === o[a], () => `Error in concat${t6}D: Shape of tensors[${s}] (${n}) does not match the shape of the rest (${o}) along the non-concatenated axis ${s}.`);
});
}
-function jq(r, e) {
- let t10 = r[0].slice();
+function hq(r, e) {
+ let t6 = r[0].slice();
for (let o = 1; o < r.length; o++)
- t10[e] += r[o][e];
- return t10;
+ t6[e] += r[o][e];
+ return t6;
}
-var Gs;
+var Ks;
(function(r) {
r[r.FIRST_DIM_SIZE = 0] = "FIRST_DIM_SIZE", r[r.VALUE_ROWIDS = 1] = "VALUE_ROWIDS", r[r.ROW_LENGTHS = 2] = "ROW_LENGTHS", r[r.ROW_SPLITS = 3] = "ROW_SPLITS", r[r.ROW_LIMITS = 4] = "ROW_LIMITS", r[r.ROW_STARTS = 5] = "ROW_STARTS";
-})(Gs || (Gs = {}));
-function Xq(r, e, t10) {
+})(Ks || (Ks = {}));
+function gq(r, e, t6) {
let o = new Array();
- if (t10 == null && e == null)
+ if (t6 == null && e == null)
return o;
if (e == null)
- for (; o.length < r + t10.length; )
+ for (; o.length < r + t6.length; )
o.push(-1);
else
o = e.slice();
- if (t10 == null)
+ if (t6 == null)
return o;
- if (r + t10.length !== o.length)
- throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.rank = ${r + t10.length}, but shape.rank = ${o.length}`);
- for (let n = 1; n < t10.length; ++n) {
- let s = t10[n], a = o[o.length - t10.length + n], i = o[a];
+ if (r + t6.length !== o.length)
+ throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.rank = ${r + t6.length}, but shape.rank = ${o.length}`);
+ for (let n = 1; n < t6.length; ++n) {
+ let s = t6[n], a = o[o.length - t6.length + n], i = o[a];
if (s >= 0)
if (i >= 0) {
if (i !== s)
@@ -9014,42 +9024,42 @@ function Xq(r, e, t10) {
}
return o;
}
-function Yq(r) {
- let e = { FIRST_DIM_SIZE: Gs.FIRST_DIM_SIZE, VALUE_ROWIDS: Gs.VALUE_ROWIDS, ROW_LENGTHS: Gs.ROW_LENGTHS, ROW_SPLITS: Gs.ROW_SPLITS, ROW_LIMITS: Gs.ROW_LIMITS, ROW_STARTS: Gs.ROW_STARTS }, t10 = [];
+function xq(r) {
+ let e = { FIRST_DIM_SIZE: Ks.FIRST_DIM_SIZE, VALUE_ROWIDS: Ks.VALUE_ROWIDS, ROW_LENGTHS: Ks.ROW_LENGTHS, ROW_SPLITS: Ks.ROW_SPLITS, ROW_LIMITS: Ks.ROW_LIMITS, ROW_STARTS: Ks.ROW_STARTS }, t6 = [];
for (let o of r)
if (o in e)
- t10.push(e[o]);
+ t6.push(e[o]);
else
break;
- return t10;
+ return t6;
}
-function Qq(r) {
- return r.length === 0 ? 0 : r[0] === Gs.FIRST_DIM_SIZE ? r.length - 1 : r.length;
+function yq(r) {
+ return r.length === 0 ? 0 : r[0] === Ks.FIRST_DIM_SIZE ? r.length - 1 : r.length;
}
-function Zq(r, e) {
+function bq(r, e) {
if (r == null || e == null)
return;
- let t10 = r.length, o = e.length;
- if (t10 >= o)
- throw new Error(`defaultValue.shape=${r} and ragged tensor flatValues.shape=${e}, are incompatible: defaultValue.rank = ${t10} must be less than ragged tensor input flatValues.rank = ${o})`);
- for (let n = 0; n < Math.min(t10, o - 1); ++n) {
+ let t6 = r.length, o = e.length;
+ if (t6 >= o)
+ throw new Error(`defaultValue.shape=${r} and ragged tensor flatValues.shape=${e}, are incompatible: defaultValue.rank = ${t6} must be less than ragged tensor input flatValues.rank = ${o})`);
+ for (let n = 0; n < Math.min(t6, o - 1); ++n) {
let s = r[n], a = e[n + 1];
if (s >= 0 && a >= 0 && s !== 1 && s !== a)
throw new Error(`defaultValue.shape=${r}, and ragged tensor input flatValues.shape=${e} are incompatible: defaultValue.shape[${n - r.length}] = ${s} but ragged tensor input.flatValues.shape[${n - r.length}] = ${a}`);
}
}
-var ed = 30;
-function Jq(r) {
- return r <= ed ? r : sp(r, Math.floor(Math.sqrt(r)));
+var Ud = 30;
+function Cq(r) {
+ return r <= Ud ? r : sp(r, Math.floor(Math.sqrt(r)));
}
-function eK(r, e, t10) {
- let o = t10 * (typeof r == "number" ? r : r[0]), n = e * (typeof r == "number" ? r : r[1]);
+function Sq(r, e, t6) {
+ let o = t6 * (typeof r == "number" ? r : r[0]), n = e * (typeof r == "number" ? r : r[1]);
return [o, n];
}
-function tK(r, e, t10, o = true) {
+function wq(r, e, t6, o = true) {
let n = [];
if (o)
- n = n.concat(e.slice(0)), n.push(r[0] / t10), n = n.concat(r.slice(1));
+ n = n.concat(e.slice(0)), n.push(r[0] / t6), n = n.concat(r.slice(1));
else {
n = n.concat(r[0]);
let s = e.length;
@@ -9059,9 +9069,9 @@ function tK(r, e, t10, o = true) {
}
return n;
}
-function rK(r, e, t10 = true) {
+function Iq(r, e, t6 = true) {
let o = [];
- if (t10) {
+ if (t6) {
o.push(e);
for (let n = e + 1; n < r; ++n)
n <= 2 * e ? (o.push(n), o.push(n - (e + 1))) : o.push(n);
@@ -9073,336 +9083,336 @@ function rK(r, e, t10 = true) {
}
return o;
}
-function oK(r, e, t10, o = true) {
+function vq(r, e, t6, o = true) {
let n = [];
- o ? n.push(r[0] / t10) : n.push(r[0] * t10);
+ o ? n.push(r[0] / t6) : n.push(r[0] * t6);
for (let s = 1; s < r.length; ++s)
s <= e.length ? o ? n.push(e[s - 1] * r[s]) : n.push(r[s] / e[s - 1]) : n.push(r[s]);
return n;
}
-function nK(r, e) {
- let t10 = [0];
+function kq(r, e) {
+ let t6 = [0];
for (let o = 0; o < e; ++o)
- t10.push(r[o][0]);
- return t10;
+ t6.push(r[o][0]);
+ return t6;
}
-function sK(r, e, t10) {
+function Nq(r, e, t6) {
let o = r.slice(0, 1);
- for (let n = 0; n < t10; ++n)
+ for (let n = 0; n < t6; ++n)
o.push(r[n + 1] - e[n][0] - e[n][1]);
return o;
}
-var aK = 1.7580993408473768;
-var iK = 1.0507009873554805;
-var uK = 0.3275911;
-var pK = 0.254829592;
-var cK = -0.284496736;
-var lK = 1.421413741;
-var mK = -1.453152027;
-var fK = 1.061405429;
-function dK(r, e) {
+var Tq = 1.7580993408473768;
+var _q = 1.0507009873554805;
+var Eq = 0.3275911;
+var $q = 0.254829592;
+var Aq = -0.284496736;
+var Rq = 1.421413741;
+var Fq = -1.453152027;
+var Dq = 1.061405429;
+function Oq(r, e) {
if (r.length !== e.length)
throw new Error(`Cannot merge real and imag arrays of different lengths. real:${r.length}, imag: ${e.length}.`);
- let t10 = new Float32Array(r.length * 2);
- for (let o = 0; o < t10.length; o += 2)
- t10[o] = r[o / 2], t10[o + 1] = e[o / 2];
- return t10;
+ let t6 = new Float32Array(r.length * 2);
+ for (let o = 0; o < t6.length; o += 2)
+ t6[o] = r[o / 2], t6[o + 1] = e[o / 2];
+ return t6;
}
-function hK(r) {
- let e = new Float32Array(r.length / 2), t10 = new Float32Array(r.length / 2);
+function Pq(r) {
+ let e = new Float32Array(r.length / 2), t6 = new Float32Array(r.length / 2);
for (let o = 0; o < r.length; o += 2)
- e[o / 2] = r[o], t10[o / 2] = r[o + 1];
- return { real: e, imag: t10 };
+ e[o / 2] = r[o], t6[o / 2] = r[o + 1];
+ return { real: e, imag: t6 };
}
-function gK(r) {
- let e = Math.ceil(r.length / 4), t10 = new Float32Array(e), o = new Float32Array(e);
+function Mq(r) {
+ let e = Math.ceil(r.length / 4), t6 = new Float32Array(e), o = new Float32Array(e);
for (let n = 0; n < r.length; n += 4)
- t10[Math.floor(n / 4)] = r[n], o[Math.floor(n / 4)] = r[n + 1];
- return { real: t10, imag: o };
+ t6[Math.floor(n / 4)] = r[n], o[Math.floor(n / 4)] = r[n + 1];
+ return { real: t6, imag: o };
}
-function xK(r) {
- let e = Math.floor(r.length / 4), t10 = new Float32Array(e), o = new Float32Array(e);
+function Lq(r) {
+ let e = Math.floor(r.length / 4), t6 = new Float32Array(e), o = new Float32Array(e);
for (let n = 2; n < r.length; n += 4)
- t10[Math.floor(n / 4)] = r[n], o[Math.floor(n / 4)] = r[n + 1];
- return { real: t10, imag: o };
+ t6[Math.floor(n / 4)] = r[n], o[Math.floor(n / 4)] = r[n + 1];
+ return { real: t6, imag: o };
}
-function yK(r, e) {
- let t10 = r[e * 2], o = r[e * 2 + 1];
- return { real: t10, imag: o };
+function Bq(r, e) {
+ let t6 = r[e * 2], o = r[e * 2 + 1];
+ return { real: t6, imag: o };
}
-function bK(r, e, t10, o) {
- r[o * 2] = e, r[o * 2 + 1] = t10;
+function Vq(r, e, t6, o) {
+ r[o * 2] = e, r[o * 2 + 1] = t6;
}
-function CK(r, e) {
- let t10 = new Float32Array(r / 2), o = new Float32Array(r / 2);
+function zq(r, e) {
+ let t6 = new Float32Array(r / 2), o = new Float32Array(r / 2);
for (let n = 0; n < Math.ceil(r / 2); n++) {
let s = (e ? 2 : -2) * Math.PI * (n / r);
- t10[n] = Math.cos(s), o[n] = Math.sin(s);
+ t6[n] = Math.cos(s), o[n] = Math.sin(s);
}
- return { real: t10, imag: o };
+ return { real: t6, imag: o };
}
-function IK(r, e, t10) {
- let o = (t10 ? 2 : -2) * Math.PI * (r / e), n = Math.cos(o), s = Math.sin(o);
+function Wq(r, e, t6) {
+ let o = (t6 ? 2 : -2) * Math.PI * (r / e), n = Math.cos(o), s = Math.sin(o);
return { real: n, imag: s };
}
-var TC = "->";
-var wK = /->/g;
-var KT = ",";
-var jT = "...";
-function SK(r, e) {
+var SC = "->";
+var Uq = /->/g;
+var SN = ",";
+var wN = "...";
+function Gq(r, e) {
r = r.replace(/\s/g, "");
- let t10 = (r.length - r.replace(wK, "").length) / TC.length;
- if (t10 < 1)
+ let t6 = (r.length - r.replace(Uq, "").length) / SC.length;
+ if (t6 < 1)
throw new Error("Equations without an arrow are not supported.");
- if (t10 > 1)
- throw new Error(`Equation must contain exactly one arrow ("${TC}").`);
- let [o, n] = r.split(TC);
- $(o.indexOf(jT) === -1, () => `The ellipsis notation ("${jT}") is not supported yet.`);
- let s = o.split(KT), a = s.length;
+ if (t6 > 1)
+ throw new Error(`Equation must contain exactly one arrow ("${SC}").`);
+ let [o, n] = r.split(SC);
+ E(o.indexOf(wN) === -1, () => `The ellipsis notation ("${wN}") is not supported yet.`);
+ let s = o.split(SN), a = s.length;
if (e !== a)
throw new Error(`Expected ${a} input tensors, received ${e}`);
if (a > 2)
throw new Error("Support for more than 2 input tensors is not implemented yet.");
let i = [];
for (let m = 0; m < n.length; ++m) {
- let f = n[m];
- if (!s.some((d) => d.indexOf(f) !== -1))
- throw new Error(`Output subscripts contain the label ${f} not present in the input subscripts.`);
- i.indexOf(f) === -1 && i.push(f);
+ let d = n[m];
+ if (!s.some((f) => f.indexOf(d) !== -1))
+ throw new Error(`Output subscripts contain the label ${d} not present in the input subscripts.`);
+ i.indexOf(d) === -1 && i.push(d);
}
for (let m = 0; m < o.length; ++m) {
- let f = o[m];
- i.indexOf(f) === -1 && f !== KT && i.push(f);
+ let d = o[m];
+ i.indexOf(d) === -1 && d !== SN && i.push(d);
}
let p = new Array(s.length);
for (let m = 0; m < a; ++m) {
if (new Set(s[m].split("")).size !== s[m].length)
throw new Error(`Found duplicate axes in input component ${s[m]}. Support for duplicate axes in input is not implemented yet.`);
p[m] = [];
- for (let f = 0; f < s[m].length; ++f)
- p[m].push(i.indexOf(s[m][f]));
+ for (let d = 0; d < s[m].length; ++d)
+ p[m].push(i.indexOf(s[m][d]));
}
let u = i.length, c = n.length, l = [];
for (let m = c; m < u; ++m)
l.push(m);
return { allDims: i, summedDims: l, idDims: p };
}
-function vK(r, e) {
- let t10 = new Array(r);
- t10.fill(-1);
+function Hq(r, e) {
+ let t6 = new Array(r);
+ t6.fill(-1);
for (let n = 0; n < e.length; ++n)
- t10[e[n]] = n;
+ t6[e[n]] = n;
let o = [];
for (let n = 0; n < r; ++n)
- t10[n] === -1 && o.push(n);
- return t10 = t10.filter((n) => n !== -1), { permutationIndices: t10, expandDims: o };
+ t6[n] === -1 && o.push(n);
+ return t6 = t6.filter((n) => n !== -1), { permutationIndices: t6, expandDims: o };
}
-function kK(r, e, t10) {
+function qq(r, e, t6) {
let o = new Array(r);
- for (let n = 0; n < t10.length; ++n) {
- let s = t10[n].shape;
+ for (let n = 0; n < t6.length; ++n) {
+ let s = t6[n].shape;
for (let a = 0; a < e[n].length; ++a)
- o[e[n][a]] === void 0 ? o[e[n][a]] = s[a] : $(o[e[n][a]] === s[a], () => `Expected dimension ${o[e[n][a]]} at axis ${a} of input shaped ${JSON.stringify(s)}, but got dimension ${s[a]}`);
+ o[e[n][a]] === void 0 ? o[e[n][a]] = s[a] : E(o[e[n][a]] === s[a], () => `Expected dimension ${o[e[n][a]]} at axis ${a} of input shaped ${JSON.stringify(s)}, but got dimension ${s[a]}`);
}
}
-function TK(r, e) {
- let t10 = r, o = [], n = 0;
- r.length === 0 && t10.push(-1), n = r.length + 1;
+function Kq(r, e) {
+ let t6 = r, o = [], n = 0;
+ r.length === 0 && t6.push(-1), n = r.length + 1;
for (let a = 0; a < n; ++a)
o.push([]);
let s = [];
- for (let a = 0; a < t10.length; ++a) {
- let i = t10[a], p = _K(e, i);
+ for (let a = 0; a < t6.length; ++a) {
+ let i = t6[a], p = Xq(e, i);
for (let u of p)
s.indexOf(u) === -1 && (o[a].push(u), s.push(u));
}
- return { path: t10, steps: o };
+ return { path: t6, steps: o };
}
-function NK(r) {
- return r.every((e, t10) => e === t10);
+function jq(r) {
+ return r.every((e, t6) => e === t6);
}
-function _K(r, e) {
- let t10 = [];
+function Xq(r, e) {
+ let t6 = [];
for (let o = 0; o < r.length; ++o)
- (r[o].length === 0 || r[o].indexOf(e) !== -1 || e === -1) && t10.push(o);
- return t10;
+ (r[o].length === 0 || r[o].indexOf(e) !== -1 || e === -1) && t6.push(o);
+ return t6;
}
-function EK(r, e, t10 = 0) {
+function Yq(r, e, t6 = 0) {
let o = [];
if (typeof e == "number")
- $(r.shape[t10] % e === 0, () => "Number of splits must evenly divide the axis."), o = new Array(e).fill(r.shape[t10] / e);
+ E(r.shape[t6] % e === 0, () => "Number of splits must evenly divide the axis."), o = new Array(e).fill(r.shape[t6] / e);
else {
let n = e.reduce((a, i) => (i === -1 && (a += 1), a), 0);
- $(n <= 1, () => "There should be only one negative value in split array.");
+ E(n <= 1, () => "There should be only one negative value in split array.");
let s = e.indexOf(-1);
if (s !== -1) {
let a = e.reduce((i, p) => p > 0 ? i + p : i);
- e[s] = r.shape[t10] - a;
+ e[s] = r.shape[t6] - a;
}
- $(r.shape[t10] === e.reduce((a, i) => a + i), () => "The sum of sizes must match the size of the axis dimension."), o = e;
+ E(r.shape[t6] === e.reduce((a, i) => a + i), () => "The sum of sizes must match the size of the axis dimension."), o = e;
}
return o;
}
-function $K(r) {
+function Qq(r) {
return `Received SparseTensor with denseShape[0] = 0 but
indices.shape[0] = ${r}`;
}
-function RK(r, e) {
+function Zq(r, e) {
return `indices(${r}, 0) is invalid: ${e} < 0`;
}
-function AK(r, e, t10) {
- return `indices(${r}, 0) is invalid: ${e} >= ${t10}`;
+function Jq(r, e, t6) {
+ return `indices(${r}, 0) is invalid: ${e} >= ${t6}`;
}
-function FK(r, e) {
+function eK(r, e) {
return `only one output dimension may be -1, not both ${r} and ${e}`;
}
-function DK(r, e) {
+function tK(r, e) {
return `size ${r} must be non-negative, not ${e}`;
}
-function PK() {
+function rK() {
return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";
}
-function OK(r, e) {
- let t10 = Ve(r), o = Ve(e);
- return `Input to reshape is a SparseTensor with ${t10}
+function oK(r, e) {
+ let t6 = ze(r), o = ze(e);
+ return `Input to reshape is a SparseTensor with ${t6}
dense values, but the requested shape requires a multiple of ${o}. inputShape=${r} outputShape= ${e}`;
}
-function MK(r, e) {
- let t10 = Ve(r), o = Ve(e);
- return `Input to reshape is a tensor with ${t10} dense values, but the requested shape has ${o}. inputShape=${r} outputShape=${e}`;
+function nK(r, e) {
+ let t6 = ze(r), o = ze(e);
+ return `Input to reshape is a tensor with ${t6} dense values, but the requested shape has ${o}. inputShape=${r} outputShape=${e}`;
}
-function LK() {
+function sK() {
return "segment ids must be >= 0";
}
-function BK() {
+function aK() {
return "segment ids are not increasing";
}
-function VK(r, e) {
+function iK(r, e) {
return `Segment id ${r} out of range [0, ${e}), possibly because segmentIds input is not sorted.`;
}
-function zK(r, e, t10) {
- return `Bad: indices[${r}] == ${e} out of range [0, ${t10})`;
+function uK(r, e, t6) {
+ return `Bad: indices[${r}] == ${e} out of range [0, ${t6})`;
}
-var NC = {};
-Be(NC, { collectGatherOpShapeInfo: () => GK, computeOutShape: () => UK, segOpComputeOptimalWindowSize: () => WK });
-function WK(r, e) {
- let t10 = false, o;
- for (r <= ed ? (o = r, t10 = true) : o = sp(r, Math.floor(Math.sqrt(r))); !t10; )
- o > e || o === r ? t10 = true : o = sp(r, o + 1);
+var wC = {};
+Ue(wC, { collectGatherOpShapeInfo: () => lK, computeOutShape: () => cK, segOpComputeOptimalWindowSize: () => pK });
+function pK(r, e) {
+ let t6 = false, o;
+ for (r <= Ud ? (o = r, t6 = true) : o = sp(r, Math.floor(Math.sqrt(r))); !t6; )
+ o > e || o === r ? t6 = true : o = sp(r, o + 1);
return o;
}
-function UK(r, e, t10) {
+function cK(r, e, t6) {
let o = [], n = r.length;
for (let s = 0; s < n; s++)
- s !== e ? o.push(r[s]) : o.push(t10);
+ s !== e ? o.push(r[s]) : o.push(t6);
return o;
}
-function GK(r, e, t10, o) {
+function lK(r, e, t6, o) {
let n = e.shape.length, s = r.shape.length;
if (o !== 0 && (o < -n || o > n))
throw new Error(`Expect batchDims in the range of [-${n}, ${n}], but got ${o}`);
if (o < 0 && (o += n), o > s)
throw new Error(`batchDims (${o}) must be less than rank(x) (
${s}).`);
- if (t10 < o)
- throw new Error(`batchDims (${o}) must be less than or equal to axis (${t10}).`);
+ if (t6 < o)
+ throw new Error(`batchDims (${o}) must be less than or equal to axis (${t6}).`);
for (let l = 0; l < o; ++l)
if (r.shape[l] !== e.shape[l])
throw new Error(`x.shape[${l}]: ${r.shape[l]} should be equal to indices.shape[${l}]: ${e.shape[l]}.`);
- let a = r.shape[t10], i = [], p = 1, u = 1, c = 1;
+ let a = r.shape[t6], i = [], p = 1, u = 1, c = 1;
for (let l = 0; l < o; ++l)
i.push(r.shape[l]), p *= r.shape[l];
- for (let l = o; l < t10; l++)
+ for (let l = o; l < t6; l++)
i.push(r.shape[l]), u *= r.shape[l];
for (let l = o; l < n; l++)
i.push(e.shape[l]);
- for (let l = t10 + 1; l < s; l++)
+ for (let l = t6 + 1; l < s; l++)
i.push(r.shape[l]), c *= r.shape[l];
return { batchSize: p, sliceSize: c, outerSize: u, dimSize: a, outputShape: i };
}
-function HK(r) {
+function mK(r) {
try {
- return r.map((e) => Op(e));
+ return r.map((e) => Ap(e));
} catch (e) {
throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`);
}
}
-function qK(r) {
- return r.map((e) => si(e));
+function dK(r) {
+ return r.map((e) => gi(e));
}
-var Bt = {};
-Be(Bt, { nonMaxSuppressionV3Impl: () => Qf, nonMaxSuppressionV4Impl: () => Zf, nonMaxSuppressionV5Impl: () => Jf, whereImpl: () => Kf });
-var KK = P();
-KK.registerFlag("KEEP_INTERMEDIATE_TENSORS", () => false, (r) => {
+var Lt = {};
+Ue(Lt, { nonMaxSuppressionV3Impl: () => Vd, nonMaxSuppressionV4Impl: () => zd, nonMaxSuppressionV5Impl: () => Wd, whereImpl: () => Pd });
+var fK = O();
+fK.registerFlag("KEEP_INTERMEDIATE_TENSORS", () => false, (r) => {
r && console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.");
});
-var To;
+var ao;
(function(r) {
r[r.DT_INVALID = 0] = "DT_INVALID", r[r.DT_FLOAT = 1] = "DT_FLOAT", r[r.DT_DOUBLE = 2] = "DT_DOUBLE", r[r.DT_INT32 = 3] = "DT_INT32", r[r.DT_UINT8 = 4] = "DT_UINT8", r[r.DT_INT16 = 5] = "DT_INT16", r[r.DT_INT8 = 6] = "DT_INT8", r[r.DT_STRING = 7] = "DT_STRING", r[r.DT_COMPLEX64 = 8] = "DT_COMPLEX64", r[r.DT_INT64 = 9] = "DT_INT64", r[r.DT_BOOL = 10] = "DT_BOOL", r[r.DT_QINT8 = 11] = "DT_QINT8", r[r.DT_QUINT8 = 12] = "DT_QUINT8", r[r.DT_QINT32 = 13] = "DT_QINT32", r[r.DT_BFLOAT16 = 14] = "DT_BFLOAT16", r[r.DT_QINT16 = 15] = "DT_QINT16", r[r.DT_QUINT16 = 16] = "DT_QUINT16", r[r.DT_UINT16 = 17] = "DT_UINT16", r[r.DT_COMPLEX128 = 18] = "DT_COMPLEX128", r[r.DT_HALF = 19] = "DT_HALF", r[r.DT_RESOURCE = 20] = "DT_RESOURCE", r[r.DT_VARIANT = 21] = "DT_VARIANT", r[r.DT_UINT32 = 22] = "DT_UINT32", r[r.DT_UINT64 = 23] = "DT_UINT64", r[r.DT_FLOAT_REF = 101] = "DT_FLOAT_REF", r[r.DT_DOUBLE_REF = 102] = "DT_DOUBLE_REF", r[r.DT_INT32_REF = 103] = "DT_INT32_REF", r[r.DT_UINT8_REF = 104] = "DT_UINT8_REF", r[r.DT_INT16_REF = 105] = "DT_INT16_REF", r[r.DT_INT8_REF = 106] = "DT_INT8_REF", r[r.DT_STRING_REF = 107] = "DT_STRING_REF", r[r.DT_COMPLEX64_REF = 108] = "DT_COMPLEX64_REF", r[r.DT_INT64_REF = 109] = "DT_INT64_REF", r[r.DT_BOOL_REF = 110] = "DT_BOOL_REF", r[r.DT_QINT8_REF = 111] = "DT_QINT8_REF", r[r.DT_QUINT8_REF = 112] = "DT_QUINT8_REF", r[r.DT_QINT32_REF = 113] = "DT_QINT32_REF", r[r.DT_BFLOAT16_REF = 114] = "DT_BFLOAT16_REF", r[r.DT_QINT16_REF = 115] = "DT_QINT16_REF", r[r.DT_QUINT16_REF = 116] = "DT_QUINT16_REF", r[r.DT_UINT16_REF = 117] = "DT_UINT16_REF", r[r.DT_COMPLEX128_REF = 118] = "DT_COMPLEX128_REF", r[r.DT_HALF_REF = 119] = "DT_HALF_REF", r[r.DT_RESOURCE_REF = 120] = "DT_RESOURCE_REF", r[r.DT_VARIANT_REF = 121] = "DT_VARIANT_REF", r[r.DT_UINT32_REF = 122] = "DT_UINT32_REF", r[r.DT_UINT64_REF = 123] = "DT_UINT64_REF";
-})(To || (To = {}));
-var XT;
+})(ao || (ao = {}));
+var IN;
(function(r) {
let e;
- (function(t10) {
- t10[t10.LEGACY = 0] = "LEGACY", t10[t10.V1 = 1] = "V1", t10[t10.V2 = 2] = "V2";
+ (function(t6) {
+ t6[t6.LEGACY = 0] = "LEGACY", t6[t6.V1 = 1] = "V1", t6[t6.V2 = 2] = "V2";
})(e = r.CheckpointFormatVersion || (r.CheckpointFormatVersion = {}));
-})(XT || (XT = {}));
-var EC = {};
-function XK(r, e) {
- let t10 = { tfOpName: r, category: "custom", inputs: [], attrs: [], customExecutor: e };
- EC[r] = t10;
+})(IN || (IN = {}));
+var vC = {};
+function gK(r, e) {
+ let t6 = { tfOpName: r, category: "custom", inputs: [], attrs: [], customExecutor: e };
+ vC[r] = t6;
}
-function td(r) {
- return EC[r];
+function Gd(r) {
+ return vC[r];
}
-function YK(r) {
- delete EC[r];
+function xK(r) {
+ delete vC[r];
}
-function S(r, e, t10, o, n) {
+function I(r, e, t6, o, n) {
let s = e.inputParams[r];
if (s && s.inputIndexStart !== void 0) {
let i = s.inputIndexStart, p = s.inputIndexEnd === 0 ? void 0 : s.inputIndexEnd === void 0 ? i + 1 : s.inputIndexEnd;
if (s.type === "tensor")
- return Ht(e.inputNames[s.inputIndexStart], t10, o, n);
+ return Gt(e.inputNames[s.inputIndexStart], t6, o, n);
if (s.type === "tensors")
- return e.inputNames.slice(i, p).map((m) => Ht(m, t10, o, n));
- let u = Ht(e.inputNames.slice(i)[0], t10, o, n), c = u.dataSync();
- return s.type === "number" ? c[0] : x.toNestedArray(u.shape, c);
+ return e.inputNames.slice(i, p).map((m) => Gt(m, t6, o, n));
+ let u = Gt(e.inputNames.slice(i)[0], t6, o, n), c = u.dataSync();
+ return s.type === "number" ? c[0] : y.toNestedArray(u.shape, c);
}
let a = e.attrParams[r];
return a && a.value;
}
-function Ht(r, e, t10, o) {
- let [n, s] = Sr(r);
+function Gt(r, e, t6, o) {
+ let [n, s] = Ir(r);
if (o != null) {
let i = o.getHashTableHandleByName(n);
if (i != null)
return i;
}
- let a = t10.currentContextIds.find((i) => !!e[rd(n, i)]);
- return a !== void 0 ? e[rd(n, a)][s] : void 0;
+ let a = t6.currentContextIds.find((i) => !!e[Hd(n, i)]);
+ return a !== void 0 ? e[Hd(n, a)][s] : void 0;
}
-function YT(r, e, t10) {
- return e[rd(r, t10.currentContextId)];
+function vN(r, e, t6) {
+ return e[Hd(r, t6.currentContextId)];
}
-function zo(r, e) {
- let [t10, o, n] = Sr(r);
- return [rd(t10, e && e.currentContextId), o, n];
+function ss(r, e) {
+ let [t6, o, n] = Ir(r);
+ return [Hd(t6, e && e.currentContextId), o, n];
}
-function rd(r, e) {
+function Hd(r, e) {
return e ? `${r}-${e}` : r;
}
-function Sr(r) {
+function Ir(r) {
let e = r.split(":");
if (e.length === 1)
return [r, 0, void 0];
- let t10 = e[0], o = e.length === 3 ? e[1] : void 0, n = Number(e[e.length - 1]);
- return [t10, n, o];
+ let t6 = e[0], o = e.length === 3 ? e[1] : void 0, n = Number(e[e.length - 1]);
+ return [t6, n, o];
}
-function gl(r, e, t10) {
- let o = S("pad", r, e, t10);
+function ul(r, e, t6) {
+ let o = I("pad", r, e, t6);
if (o === "explicit") {
- o = S("explicitPaddings", r, e, t10);
+ o = I("explicitPaddings", r, e, t6);
let n = [[0, 0], [0, 0], [0, 0], [0, 0]];
for (let s = 0; s < 4; s++)
n[s][0] = o[s * 2], n[s][1] = o[s * 2 + 1];
@@ -9410,87 +9420,87 @@ function gl(r, e, t10) {
}
return o;
}
-function ss(r) {
- return r.kept ? r : zr(r);
+function as(r) {
+ return r.kept ? r : Br(r);
}
+var kC = {};
+Ue(kC, { json: () => yK });
+var yK = [{ tfOpName: "Add", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "AddV2", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "AddN", category: "arithmetic", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "BiasAdd", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }] }, { tfOpName: "Sub", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "RealDiv", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Div", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "DivNoNan", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "FloorDiv", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Mul", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Maximum", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Minimum", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Pow", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "SquaredDifference", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Mod", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "FloorMod", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }];
+var NC = {};
+Ue(NC, { json: () => bK });
+var bK = [{ tfOpName: "Abs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Acos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Asin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Atan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Atan2", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Ceil", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ClipByValue", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "clipValueMin", type: "number" }, { start: 2, name: "clipValueMax", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Complex", category: "basic_math", inputs: [{ start: 0, name: "real", type: "tensor" }, { start: 1, name: "imag", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ComplexAbs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Cos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Cosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Elu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Exp", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Floor", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Log", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Imag", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: true }] }, { tfOpName: "Neg", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Real", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: true }] }, { tfOpName: "Prelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "alpha", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Relu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Relu6", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Selu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sigmoid", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Rsqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Square", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Tan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Tanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sign", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Round", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Expm1", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Log1p", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Reciprocal", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Softplus", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Asinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Acosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Atanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Erf", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Prod", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axes", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool", notSupported: true }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LeakyRelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "alpha", name: "alpha", type: "number", defaultValue: 0.2 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "IsNan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }];
+var TC = {};
+Ue(TC, { json: () => CK });
+var CK = [{ tfOpName: "EmptyTensorList", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "maxNumElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "LoopCond", category: "control", inputs: [{ start: 0, name: "pred", type: "tensor" }] }, { tfOpName: "Switch", category: "control", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "pred", type: "tensor" }] }, { tfOpName: "Merge", category: "control", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "Enter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "frame_name", name: "frameName", type: "string" }, { tfName: "is_constant", name: "isConstant", type: "bool" }] }, { tfOpName: "Exit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "NextIteration", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayV3", category: "control", inputs: [{ start: 0, name: "size", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "dynamic_size", name: "dynamicSize", type: "bool" }, { tfName: "clear_after_read", name: "clearAfterRead", type: "bool" }, { tfName: "identical_element_shapes", name: "identicalElementShapes", type: "bool" }, { tfName: "tensor_array_name", name: "name", type: "string" }] }, { tfOpName: "TensorArrayWriteV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayReadV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayGatherV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }] }, { tfOpName: "TensorArrayScatterV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArrayConcatV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape_except0", name: "elementShapeExcept0", type: "shape", notSupported: true }] }, { tfOpName: "TensorArraySplitV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }, { start: 2, name: "lengths", type: "number[]" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArraySizeV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }] }, { tfOpName: "TensorArrayCloseV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }] }, { tfOpName: "StatelessIf", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "If", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "StatelessWhile", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "While", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "TensorListScatter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListScatterV2", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }, { start: 3, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGather", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListSetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListReserve", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListFromTensor", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListStack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }, { tfName: "num_elements", name: "numElements", type: "dtype" }] }, { tfOpName: "TensorListSplit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }, { start: 2, name: "lengths", type: "number[]" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcat", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcatV2", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPopBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPushBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListLength", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }] }, { tfOpName: "TensorListResize", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "size", type: "number" }] }];
+var _C = {};
+Ue(_C, { json: () => SK });
+var SK = [{ tfOpName: "AvgPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MaxPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [], notSupported: true }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MaxPoolWithArgmax", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "include_batch_in_index", name: "includeBatchInIndex", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "AvgPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MaxPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Conv1D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "stride", name: "stride", type: "number" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NWC" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "dilation", name: "dilation", type: "number", defaultValue: 1 }] }, { tfOpName: "Conv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "useCudnnOnGpu", name: "useCudnnOnGpu", type: "bool" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "_FusedConv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "use_cudnn_on_gpu", name: "useCudnnOnGpu", type: "bool", defaultValue: true }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-4 }, { tfName: "leakyrelu_alpha", name: "leakyreluAlpha", type: "number", defaultValue: 0.2 }] }, { tfOpName: "Conv2DBackpropInput", category: "convolution", inputs: [{ start: 2, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 0, name: "outputShape", type: "number[]" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]", notSupported: true }] }, { tfOpName: "DepthwiseConv2d", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "DepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "FusedDepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }] }, { tfOpName: "Conv3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "Dilation2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "rates", name: "dilations", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }] }];
+var EC = {};
+Ue(EC, { json: () => wK });
+var wK = [{ tfOpName: "Fill", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }, { start: 1, name: "value", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "LinSpace", category: "creation", inputs: [{ start: 0, name: "start", type: "number" }, { start: 1, name: "stop", type: "number" }, { start: 2, name: "num", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "OneHot", category: "creation", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "depth", type: "number" }, { start: 2, name: "onValue", type: "number", defaultValue: 1 }, { start: 3, name: "offValue", type: "number", defaultValue: 0 }], attrs: [{ tfName: "axis", name: "axis", type: "number", notSupported: true }, { tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "Ones", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "OnesLike", category: "creation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "RandomStandardNormal", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: true }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "T", name: "T", type: "number", notSupported: true }] }, { tfOpName: "RandomUniform", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "minval", name: "minval", type: "number", defaultValue: 0 }, { tfName: "maxval", name: "maxval", type: "number", defaultValue: 1 }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: true }, { tfName: "T", name: "T", type: "number", notSupported: true }] }, { tfOpName: "Range", category: "creation", inputs: [{ start: 0, name: "start", type: "number" }, { start: 1, name: "stop", type: "number" }, { start: 2, name: "step", type: "number", defaultValue: 0 }], attrs: [{ tfName: "Tidx", name: "dtype", type: "dtype" }] }, { tfOpName: "TruncatedNormal", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "means", name: "mean", type: "number", defaultValue: 0 }, { tfName: "stddev", name: "stdDev", type: "number", defaultValue: 1 }, { tfName: "seed", name: "seed", type: "number" }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: true }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "T", name: "T", type: "number", notSupported: true }] }, { tfOpName: "Zeros", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "ZerosLike", category: "creation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "Multinomial", category: "creation", inputs: [{ start: 0, name: "logits", type: "tensor" }, { start: 1, name: "numSamples", type: "number" }], attrs: [{ tfName: "seed", name: "seed", type: "number" }, { tfName: "seed2", name: "seed2", type: "number" }, { tfName: "T", name: "dtype", type: "dtype" }, { tfName: "output_dtype", name: "output_dtype", type: "dtype" }] }];
var $C = {};
-Be($C, { json: () => QK });
-var QK = [{ tfOpName: "Add", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "AddV2", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "AddN", category: "arithmetic", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "BiasAdd", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }] }, { tfOpName: "Sub", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "RealDiv", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Div", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "DivNoNan", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "FloorDiv", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Mul", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Maximum", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Minimum", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Pow", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "SquaredDifference", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Mod", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "FloorMod", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }];
-var RC = {};
-Be(RC, { json: () => ZK });
-var ZK = [{ tfOpName: "Abs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Acos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Asin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Atan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Atan2", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Ceil", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ClipByValue", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "clipValueMin", type: "number" }, { start: 2, name: "clipValueMax", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Complex", category: "basic_math", inputs: [{ start: 0, name: "real", type: "tensor" }, { start: 1, name: "imag", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ComplexAbs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Cos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Cosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Elu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Exp", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Floor", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Log", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Imag", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: true }] }, { tfOpName: "Neg", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Real", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: true }] }, { tfOpName: "Prelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "alpha", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Relu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Relu6", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Selu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sigmoid", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Rsqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Square", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Tan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Tanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sign", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Round", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Expm1", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Log1p", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Reciprocal", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Softplus", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Asinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Acosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Atanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Erf", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Prod", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axes", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool", notSupported: true }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LeakyRelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "alpha", name: "alpha", type: "number", defaultValue: 0.2 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "IsNan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }];
+Ue($C, { json: () => IK });
+var IK = [{ tfOpName: "NonMaxSuppressionV2", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }] }, { tfOpName: "NonMaxSuppressionV3", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }] }, { tfOpName: "NonMaxSuppressionV4", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "T_threshold", name: "threshold", type: "dtype", notSupported: true }, { tfName: "pad_to_max_output_size", name: "padToMaxOutputSize", type: "bool" }] }, { tfOpName: "NonMaxSuppressionV5", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }, { start: 5, name: "softNmsSigma", type: "number" }] }, { tfOpName: "Where", category: "dynamic", inputs: [{ start: 0, name: "condition", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ListDiff", category: "dynamic", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }];
var AC = {};
-Be(AC, { json: () => JK });
-var JK = [{ tfOpName: "EmptyTensorList", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "maxNumElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "LoopCond", category: "control", inputs: [{ start: 0, name: "pred", type: "tensor" }] }, { tfOpName: "Switch", category: "control", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "pred", type: "tensor" }] }, { tfOpName: "Merge", category: "control", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "Enter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "frame_name", name: "frameName", type: "string" }, { tfName: "is_constant", name: "isConstant", type: "bool" }] }, { tfOpName: "Exit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "NextIteration", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayV3", category: "control", inputs: [{ start: 0, name: "size", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "dynamic_size", name: "dynamicSize", type: "bool" }, { tfName: "clear_after_read", name: "clearAfterRead", type: "bool" }, { tfName: "identical_element_shapes", name: "identicalElementShapes", type: "bool" }, { tfName: "tensor_array_name", name: "name", type: "string" }] }, { tfOpName: "TensorArrayWriteV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayReadV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayGatherV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }] }, { tfOpName: "TensorArrayScatterV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArrayConcatV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape_except0", name: "elementShapeExcept0", type: "shape", notSupported: true }] }, { tfOpName: "TensorArraySplitV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }, { start: 2, name: "lengths", type: "number[]" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArraySizeV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }] }, { tfOpName: "TensorArrayCloseV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }] }, { tfOpName: "StatelessIf", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "If", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "StatelessWhile", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "While", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "TensorListScatter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListScatterV2", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }, { start: 3, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGather", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListSetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListReserve", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListFromTensor", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListStack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }, { tfName: "num_elements", name: "numElements", type: "dtype" }] }, { tfOpName: "TensorListSplit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }, { start: 2, name: "lengths", type: "number[]" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcat", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcatV2", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPopBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPushBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListLength", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }] }, { tfOpName: "TensorListResize", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "size", type: "number" }] }];
+Ue(AC, { json: () => vK });
+var vK = [{ tfOpName: "LowerBound", category: "evaluation", inputs: [{ start: 0, name: "sortedSequence", type: "tensor" }, { start: 1, name: "values", type: "tensor" }] }, { tfOpName: "TopKV2", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "k", type: "number" }], attrs: [{ tfName: "sorted", name: "sorted", type: "bool" }] }, { tfOpName: "UpperBound", category: "evaluation", inputs: [{ start: 0, name: "sortedSequence", type: "tensor" }, { start: 1, name: "values", type: "tensor" }] }, { tfOpName: "Unique", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "UniqueV2", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }];
+var RC = {};
+Ue(RC, { json: () => kK });
+var kK = [{ tfOpName: "PlaceholderWithDefault", category: "graph", inputs: [{ start: 0, name: "default", type: "tensor" }], attrs: [{ tfName: "shape", name: "shape", type: "shape" }, { tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "Placeholder", category: "graph", attrs: [{ tfName: "shape", name: "shape", type: "shape" }, { tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "Const", category: "graph" }, { tfOpName: "Identity", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "IdentityN", category: "graph", inputs: [{ start: 0, end: 0, name: "x", type: "tensors" }] }, { tfOpName: "Snapshot", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Rank", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Size", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Shape", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "ShapeN", category: "graph", inputs: [{ start: 0, end: 0, name: "x", type: "tensors" }] }, { tfOpName: "Print", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "data", type: "tensors" }], attrs: [{ tfName: "message", name: "message", type: "string" }, { tfName: "first_n", name: "firstN", type: "number", notSupported: true }, { tfName: "summarize", name: "summarize", type: "number", defaultValue: 3 }] }, { tfOpName: "NoOp", category: "graph", inputs: [] }, { tfOpName: "StopGradient", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "FakeQuantWithMinMaxVars", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "min", name: "min", type: "number" }, { tfName: "max", name: "max", type: "number" }] }];
var FC = {};
-Be(FC, { json: () => e6 });
-var e6 = [{ tfOpName: "AvgPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MaxPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [], notSupported: true }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MaxPoolWithArgmax", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "include_batch_in_index", name: "includeBatchInIndex", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "AvgPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MaxPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Conv1D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "stride", name: "stride", type: "number" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NWC" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "dilation", name: "dilation", type: "number", defaultValue: 1 }] }, { tfOpName: "Conv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "useCudnnOnGpu", name: "useCudnnOnGpu", type: "bool" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "_FusedConv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "use_cudnn_on_gpu", name: "useCudnnOnGpu", type: "bool", defaultValue: true }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-4 }, { tfName: "leakyrelu_alpha", name: "leakyreluAlpha", type: "number", defaultValue: 0.2 }] }, { tfOpName: "Conv2DBackpropInput", category: "convolution", inputs: [{ start: 2, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 0, name: "outputShape", type: "number[]" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]", notSupported: true }] }, { tfOpName: "DepthwiseConv2d", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "DepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "FusedDepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }] }, { tfOpName: "Conv3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "Dilation2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "rates", name: "dilations", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }] }];
+Ue(FC, { json: () => NK });
+var NK = [{ tfOpName: "HashTable", category: "hash_table", inputs: [], attrs: [{ tfName: "shared_name", name: "sharedName", type: "string" }, { tfName: "use_node_name_sharing", name: "useNodeNameSharing", type: "bool" }, { tfName: "key_dtype", name: "keyDType", type: "dtype" }, { tfName: "value_dtype", name: "valueDType", type: "dtype" }] }, { tfOpName: "HashTableV2", category: "hash_table", inputs: [], attrs: [{ tfName: "shared_name", name: "sharedName", type: "string" }, { tfName: "use_node_name_sharing", name: "useNodeNameSharing", type: "bool" }, { tfName: "key_dtype", name: "keyDType", type: "dtype" }, { tfName: "value_dtype", name: "valueDType", type: "dtype" }] }, { tfOpName: "LookupTableImport", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: true }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: true }] }, { tfOpName: "LookupTableImportV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: true }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: true }] }, { tfOpName: "LookupTableFind", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: true }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: true }] }, { tfOpName: "LookupTableFindV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: true }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: true }] }, { tfOpName: "LookupTableSize", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }] }, { tfOpName: "LookupTableSizeV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }] }, { tfOpName: "InitializeTable", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }] }, { tfOpName: "InitializeTableV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }] }];
var DC = {};
-Be(DC, { json: () => t6 });
-var t6 = [{ tfOpName: "Fill", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }, { start: 1, name: "value", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "LinSpace", category: "creation", inputs: [{ start: 0, name: "start", type: "number" }, { start: 1, name: "stop", type: "number" }, { start: 2, name: "num", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "OneHot", category: "creation", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "depth", type: "number" }, { start: 2, name: "onValue", type: "number", defaultValue: 1 }, { start: 3, name: "offValue", type: "number", defaultValue: 0 }], attrs: [{ tfName: "axis", name: "axis", type: "number", notSupported: true }, { tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "Ones", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "OnesLike", category: "creation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "RandomStandardNormal", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: true }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "T", name: "T", type: "number", notSupported: true }] }, { tfOpName: "RandomUniform", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "minval", name: "minval", type: "number", defaultValue: 0 }, { tfName: "maxval", name: "maxval", type: "number", defaultValue: 1 }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: true }, { tfName: "T", name: "T", type: "number", notSupported: true }] }, { tfOpName: "Range", category: "creation", inputs: [{ start: 0, name: "start", type: "number" }, { start: 1, name: "stop", type: "number" }, { start: 2, name: "step", type: "number", defaultValue: 0 }], attrs: [{ tfName: "Tidx", name: "dtype", type: "dtype" }] }, { tfOpName: "TruncatedNormal", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "means", name: "mean", type: "number", defaultValue: 0 }, { tfName: "stddev", name: "stdDev", type: "number", defaultValue: 1 }, { tfName: "seed", name: "seed", type: "number" }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: true }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "T", name: "T", type: "number", notSupported: true }] }, { tfOpName: "Zeros", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "ZerosLike", category: "creation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "Multinomial", category: "creation", inputs: [{ start: 0, name: "logits", type: "tensor" }, { start: 1, name: "numSamples", type: "number" }], attrs: [{ tfName: "seed", name: "seed", type: "number" }, { tfName: "seed2", name: "seed2", type: "number" }, { tfName: "T", name: "dtype", type: "dtype" }, { tfName: "output_dtype", name: "output_dtype", type: "dtype" }] }];
-var PC = {};
-Be(PC, { json: () => r6 });
-var r6 = [{ tfOpName: "NonMaxSuppressionV2", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }] }, { tfOpName: "NonMaxSuppressionV3", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }] }, { tfOpName: "NonMaxSuppressionV4", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "T_threshold", name: "threshold", type: "dtype", notSupported: true }, { tfName: "pad_to_max_output_size", name: "padToMaxOutputSize", type: "bool" }] }, { tfOpName: "NonMaxSuppressionV5", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }, { start: 5, name: "softNmsSigma", type: "number" }] }, { tfOpName: "Where", category: "dynamic", inputs: [{ start: 0, name: "condition", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ListDiff", category: "dynamic", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }];
+Ue(DC, { json: () => TK });
+var TK = [{ tfOpName: "ResizeBilinear", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "size", type: "number[]" }], attrs: [{ tfName: "align_corners", name: "alignCorners", type: "bool" }, { tfName: "half_pixel_centers", name: "halfPixelCenters", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ResizeNearestNeighbor", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "size", type: "number[]" }], attrs: [{ tfName: "align_corners", name: "alignCorners", type: "bool" }, { tfName: "half_pixel_centers", name: "halfPixelCenters", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "CropAndResize", category: "image", inputs: [{ start: 0, name: "image", type: "tensor" }, { start: 1, name: "boxes", type: "tensor" }, { start: 2, name: "boxInd", type: "tensor" }, { start: 3, name: "cropSize", type: "number[]" }], attrs: [{ tfName: "method", name: "method", type: "string" }, { tfName: "extrapolation_value", name: "extrapolationValue", type: "number" }] }, { tfOpName: "ImageProjectiveTransformV3", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "transforms", type: "tensor" }, { start: 2, name: "outputShape", type: "number[]" }, { start: 3, name: "fillValue", type: "number" }], attrs: [{ tfName: "interpolation", name: "interpolation", type: "string" }, { tfName: "fill_mode", name: "fillMode", type: "string" }] }];
var OC = {};
-Be(OC, { json: () => o6 });
-var o6 = [{ tfOpName: "LowerBound", category: "evaluation", inputs: [{ start: 0, name: "sortedSequence", type: "tensor" }, { start: 1, name: "values", type: "tensor" }] }, { tfOpName: "TopKV2", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "k", type: "number" }], attrs: [{ tfName: "sorted", name: "sorted", type: "bool" }] }, { tfOpName: "UpperBound", category: "evaluation", inputs: [{ start: 0, name: "sortedSequence", type: "tensor" }, { start: 1, name: "values", type: "tensor" }] }, { tfOpName: "Unique", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "UniqueV2", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }];
+Ue(OC, { json: () => _K });
+var _K = [{ tfOpName: "Equal", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "NotEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Greater", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "GreaterEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Less", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LessEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LogicalAnd", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LogicalNot", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LogicalOr", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Select", category: "logical", inputs: [{ start: 0, name: "condition", type: "tensor" }, { start: 1, name: "a", type: "tensor" }, { start: 2, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "SelectV2", category: "logical", inputs: [{ start: 0, name: "condition", type: "tensor" }, { start: 1, name: "a", type: "tensor" }, { start: 2, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }];
+var PC = {};
+Ue(PC, { json: () => EK });
+var EK = [{ tfOpName: "_FusedMatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-4 }, { tfName: "transpose_a", name: "transposeA", type: "bool", defaultValue: false }, { tfName: "transpose_b", name: "transposeB", type: "bool", defaultValue: false }, { tfName: "leakyrelu_alpha", name: "leakyreluAlpha", type: "number", defaultValue: 0.2 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "transpose_a", name: "transposeA", type: "bool", defaultValue: false }, { tfName: "transpose_b", name: "transposeB", type: "bool", defaultValue: false }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "BatchMatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "adj_x", name: "transposeA", type: "bool", defaultValue: false }, { tfName: "adj_y", name: "transposeB", type: "bool", defaultValue: false }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "BatchMatMulV2", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "adj_x", name: "transposeA", type: "bool", defaultValue: false }, { tfName: "adj_y", name: "transposeB", type: "bool", defaultValue: false }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Transpose", category: "matrices", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "perm", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Einsum", category: "matrices", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }], attrs: [{ tfName: "equation", name: "equation", type: "string" }, { tfName: "N", name: "n", type: "number", defaultValue: 2 }, { tfName: "T", name: "dtype", type: "dtype" }] }];
var MC = {};
-Be(MC, { json: () => n6 });
-var n6 = [{ tfOpName: "PlaceholderWithDefault", category: "graph", inputs: [{ start: 0, name: "default", type: "tensor" }], attrs: [{ tfName: "shape", name: "shape", type: "shape" }, { tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "Placeholder", category: "graph", attrs: [{ tfName: "shape", name: "shape", type: "shape" }, { tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "Const", category: "graph" }, { tfOpName: "Identity", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "IdentityN", category: "graph", inputs: [{ start: 0, end: 0, name: "x", type: "tensors" }] }, { tfOpName: "Snapshot", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Rank", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Size", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Shape", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "ShapeN", category: "graph", inputs: [{ start: 0, end: 0, name: "x", type: "tensors" }] }, { tfOpName: "Print", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "data", type: "tensors" }], attrs: [{ tfName: "message", name: "message", type: "string" }, { tfName: "first_n", name: "firstN", type: "number", notSupported: true }, { tfName: "summarize", name: "summarize", type: "number", defaultValue: 3 }] }, { tfOpName: "NoOp", category: "graph", inputs: [] }, { tfOpName: "StopGradient", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "FakeQuantWithMinMaxVars", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "min", name: "min", type: "number" }, { tfName: "max", name: "max", type: "number" }] }];
+Ue(MC, { json: () => $K });
+var $K = [{ tfOpName: "EuclideanNorm", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool", defaultValue: false }] }, { tfOpName: "FusedBatchNorm", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-3 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }] }, { tfOpName: "FusedBatchNormV2", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-3 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }] }, { tfOpName: "FusedBatchNormV3", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-3 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }] }, { tfOpName: "LRN", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "depth_radius", name: "radius", type: "number", defaultValue: 5 }, { tfName: "bias", name: "bias", type: "number", defaultValue: 1 }, { tfName: "alpha", name: "alpha", type: "number", defaultValue: 1 }, { tfName: "beta", name: "beta", type: "number", defaultValue: 0.5 }] }, { tfOpName: "Softmax", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "LogSoftmax", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "SparseToDense", category: "normalization", inputs: [{ start: 0, name: "sparseIndices", type: "tensor" }, { start: 1, name: "outputShape", type: "number[]" }, { start: 2, name: "sparseValues", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", defaultValue: true, notSupported: true }] }];
var LC = {};
-Be(LC, { json: () => s6 });
-var s6 = [{ tfOpName: "HashTable", category: "hash_table", inputs: [], attrs: [{ tfName: "shared_name", name: "sharedName", type: "string" }, { tfName: "use_node_name_sharing", name: "useNodeNameSharing", type: "bool" }, { tfName: "key_dtype", name: "keyDType", type: "dtype" }, { tfName: "value_dtype", name: "valueDType", type: "dtype" }] }, { tfOpName: "HashTableV2", category: "hash_table", inputs: [], attrs: [{ tfName: "shared_name", name: "sharedName", type: "string" }, { tfName: "use_node_name_sharing", name: "useNodeNameSharing", type: "bool" }, { tfName: "key_dtype", name: "keyDType", type: "dtype" }, { tfName: "value_dtype", name: "valueDType", type: "dtype" }] }, { tfOpName: "LookupTableImport", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: true }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: true }] }, { tfOpName: "LookupTableImportV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: true }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: true }] }, { tfOpName: "LookupTableFind", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: true }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: true }] }, { tfOpName: "LookupTableFindV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: true }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: true }] }, { tfOpName: "LookupTableSize", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }] }, { tfOpName: "LookupTableSizeV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }] }];
+Ue(LC, { json: () => AK });
+var AK = [{ tfOpName: "Bincount", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "size", type: "number" }, { start: 2, name: "weights", type: "tensor" }] }, { tfOpName: "DenseBincount", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "size", type: "number" }, { start: 2, name: "weights", type: "tensor" }], attrs: [{ tfName: "binary_output", name: "binaryOutput", type: "bool" }] }, { tfOpName: "Max", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Mean", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Min", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Sum", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "All", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Any", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "ArgMax", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "ArgMin", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "Prod", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Cumprod", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }], attrs: [{ tfName: "exclusive", name: "exclusive", type: "bool" }, { tfName: "reverse", name: "reverse", type: "bool" }] }, { tfOpName: "Cumsum", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }], attrs: [{ tfName: "exclusive", name: "exclusive", type: "bool" }, { tfName: "reverse", name: "reverse", type: "bool" }] }];
var BC = {};
-Be(BC, { json: () => a6 });
-var a6 = [{ tfOpName: "ResizeBilinear", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "size", type: "number[]" }], attrs: [{ tfName: "align_corners", name: "alignCorners", type: "bool" }, { tfName: "half_pixel_centers", name: "halfPixelCenters", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ResizeNearestNeighbor", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "size", type: "number[]" }], attrs: [{ tfName: "align_corners", name: "alignCorners", type: "bool" }, { tfName: "half_pixel_centers", name: "halfPixelCenters", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "CropAndResize", category: "image", inputs: [{ start: 0, name: "image", type: "tensor" }, { start: 1, name: "boxes", type: "tensor" }, { start: 2, name: "boxInd", type: "tensor" }, { start: 3, name: "cropSize", type: "number[]" }], attrs: [{ tfName: "method", name: "method", type: "string" }, { tfName: "extrapolation_value", name: "extrapolationValue", type: "number" }] }, { tfOpName: "ImageProjectiveTransformV3", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "transforms", type: "tensor" }, { start: 2, name: "outputShape", type: "number[]" }, { start: 3, name: "fillValue", type: "number" }], attrs: [{ tfName: "interpolation", name: "interpolation", type: "string" }, { tfName: "fill_mode", name: "fillMode", type: "string" }] }];
+Ue(BC, { json: () => RK });
+var RK = [{ tfOpName: "ConcatV2", category: "slice_join", inputs: [{ start: 0, end: -1, name: "tensors", type: "tensors" }, { start: -1, name: "axis", type: "number" }], attrs: [{ tfName: "N", name: "n", type: "number", defaultValue: 2 }] }, { tfOpName: "Concat", category: "slice_join", inputs: [{ start: 1, end: 0, name: "tensors", type: "tensors" }, { start: 0, name: "axis", type: "number" }], attrs: [{ tfName: "N", name: "n", type: "number", defaultValue: 2 }] }, { tfOpName: "GatherV2", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "axis", type: "number", defaultValue: 0 }], attrs: [{ tfName: "batch_dims", name: "batchDims", type: "number", defaultValue: 0 }] }, { tfOpName: "Gather", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", notSupported: true }] }, { tfOpName: "Reverse", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "dims", type: "bool[]" }] }, { tfOpName: "ReverseV2", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }] }, { tfOpName: "Slice", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "begin", type: "number[]" }, { start: 2, name: "size", type: "number[]" }] }, { tfOpName: "StridedSlice", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "begin", type: "number[]" }, { start: 2, name: "end", type: "number[]" }, { start: 3, name: "strides", type: "number[]" }], attrs: [{ tfName: "begin_mask", name: "beginMask", type: "number", defaultValue: 0 }, { tfName: "end_mask", name: "endMask", type: "number", defaultValue: 0 }, { tfName: "new_axis_mask", name: "newAxisMask", type: "number", defaultValue: 0 }, { tfName: "ellipsis_mask", name: "ellipsisMask", type: "number", defaultValue: 0 }, { tfName: "shrink_axis_mask", name: "shrinkAxisMask", type: "number", defaultValue: 0 }] }, { tfOpName: "Pack", category: "slice_join", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }], attrs: [{ tfName: "axis", name: "axis", type: "number", defaultValue: 0 }] }, { tfOpName: "Unpack", category: "slice_join", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "axis", name: "axis", type: "number", defaultValue: 0 }, { tfName: "num", name: "num", type: "number", defaultValue: 0, notSupported: true }] }, { tfOpName: "Tile", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "reps", type: "number[]" }] }, { tfOpName: "Split", category: "slice_join", inputs: [{ start: 0, name: "axis", type: "number", defaultValue: 0 }, { start: 1, name: "x", type: "tensor" }], attrs: [{ tfName: "num_split", name: "numOrSizeSplits", type: "number", defaultValue: 1 }] }, { tfOpName: "SplitV", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "numOrSizeSplits", type: "number[]" }, { start: 2, name: "axis", type: "number", defaultValue: 0 }] }, { tfOpName: "ScatterNd", category: "slice_join", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "values", type: "tensor" }, { start: 2, name: "shape", type: "number[]" }] }, { tfOpName: "GatherNd", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }] }, { tfOpName: "SparseToDense", category: "slice_join", inputs: [{ start: 0, name: "sparseIndices", type: "tensor" }, { start: 1, name: "outputShape", type: "number[]" }, { start: 2, name: "sparseValues", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", defaultValue: false, notSupported: true }] }];
var VC = {};
-Be(VC, { json: () => i6 });
-var i6 = [{ tfOpName: "Equal", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "NotEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Greater", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "GreaterEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Less", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LessEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LogicalAnd", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LogicalNot", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LogicalOr", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Select", category: "logical", inputs: [{ start: 0, name: "condition", type: "tensor" }, { start: 1, name: "a", type: "tensor" }, { start: 2, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "SelectV2", category: "logical", inputs: [{ start: 0, name: "condition", type: "tensor" }, { start: 1, name: "a", type: "tensor" }, { start: 2, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }];
+Ue(VC, { json: () => FK });
+var FK = [{ tfOpName: "SparseFillEmptyRows", category: "sparse", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "values", type: "tensor" }, { start: 2, name: "denseShape", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }] }, { tfOpName: "SparseReshape", category: "sparse", inputs: [{ start: 0, name: "inputIndices", type: "tensor" }, { start: 1, name: "inputShape", type: "tensor" }, { start: 2, name: "newShape", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "SparseSegmentMean", category: "sparse", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "segmentIds", type: "tensor" }] }, { tfOpName: "SparseSegmentSum", category: "sparse", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "segmentIds", type: "tensor" }] }];
var zC = {};
-Be(zC, { json: () => u6 });
-var u6 = [{ tfOpName: "_FusedMatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-4 }, { tfName: "transpose_a", name: "transposeA", type: "bool", defaultValue: false }, { tfName: "transpose_b", name: "transposeB", type: "bool", defaultValue: false }, { tfName: "leakyrelu_alpha", name: "leakyreluAlpha", type: "number", defaultValue: 0.2 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "transpose_a", name: "transposeA", type: "bool", defaultValue: false }, { tfName: "transpose_b", name: "transposeB", type: "bool", defaultValue: false }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "BatchMatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "adj_x", name: "transposeA", type: "bool", defaultValue: false }, { tfName: "adj_y", name: "transposeB", type: "bool", defaultValue: false }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "BatchMatMulV2", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "adj_x", name: "transposeA", type: "bool", defaultValue: false }, { tfName: "adj_y", name: "transposeB", type: "bool", defaultValue: false }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Transpose", category: "matrices", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "perm", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Einsum", category: "matrices", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }], attrs: [{ tfName: "equation", name: "equation", type: "string" }, { tfName: "N", name: "n", type: "number", defaultValue: 2 }, { tfName: "T", name: "dtype", type: "dtype" }] }];
+Ue(zC, { json: () => DK });
+var DK = [{ tfOpName: "FFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "IFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "RFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "fft_length", type: "number", notSupported: true }] }, { tfOpName: "IRFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "fft_length", type: "number", notSupported: true }] }];
var WC = {};
-Be(WC, { json: () => p6 });
-var p6 = [{ tfOpName: "EuclideanNorm", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool", defaultValue: false }] }, { tfOpName: "FusedBatchNorm", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-3 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }] }, { tfOpName: "FusedBatchNormV2", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-3 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }] }, { tfOpName: "FusedBatchNormV3", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-3 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }] }, { tfOpName: "LRN", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "depth_radius", name: "radius", type: "number", defaultValue: 5 }, { tfName: "bias", name: "bias", type: "number", defaultValue: 1 }, { tfName: "alpha", name: "alpha", type: "number", defaultValue: 1 }, { tfName: "beta", name: "beta", type: "number", defaultValue: 0.5 }] }, { tfOpName: "Softmax", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "LogSoftmax", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "SparseToDense", category: "normalization", inputs: [{ start: 0, name: "sparseIndices", type: "tensor" }, { start: 1, name: "outputShape", type: "number[]" }, { start: 2, name: "sparseValues", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", defaultValue: true, notSupported: true }] }];
+Ue(WC, { json: () => OK });
+var OK = [{ tfOpName: "StringNGrams", category: "string", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "dataSplits", type: "tensor" }], attrs: [{ tfName: "separator", name: "separator", type: "string" }, { tfName: "ngram_widths", name: "nGramWidths", type: "number[]" }, { tfName: "left_pad", name: "leftPad", type: "string" }, { tfName: "right_pad", name: "rightPad", type: "string" }, { tfName: "pad_width", name: "padWidth", type: "number" }, { tfName: "preserve_short_sequences", name: "preserveShortSequences", type: "bool" }], outputs: ["ngrams", "ngrams_splits"] }, { tfOpName: "StringSplit", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "delimiter", type: "tensor" }], attrs: [{ tfName: "skip_empty", name: "skipEmpty", type: "bool" }], outputs: ["indices", "values", "shape"] }, { tfOpName: "StringToHashBucketFast", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }], attrs: [{ tfName: "num_buckets", name: "numBuckets", type: "number" }] }];
var UC = {};
-Be(UC, { json: () => c6 });
-var c6 = [{ tfOpName: "Bincount", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "size", type: "number" }, { start: 2, name: "weights", type: "tensor" }] }, { tfOpName: "DenseBincount", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "size", type: "number" }, { start: 2, name: "weights", type: "tensor" }], attrs: [{ tfName: "binary_output", name: "binaryOutput", type: "bool" }] }, { tfOpName: "Max", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Mean", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Min", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Sum", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "All", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Any", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "ArgMax", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "ArgMin", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "Prod", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Cumprod", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }], attrs: [{ tfName: "exclusive", name: "exclusive", type: "bool" }, { tfName: "reverse", name: "reverse", type: "bool" }] }, { tfOpName: "Cumsum", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }], attrs: [{ tfName: "exclusive", name: "exclusive", type: "bool" }, { tfName: "reverse", name: "reverse", type: "bool" }] }];
-var GC = {};
-Be(GC, { json: () => l6 });
-var l6 = [{ tfOpName: "ConcatV2", category: "slice_join", inputs: [{ start: 0, end: -1, name: "tensors", type: "tensors" }, { start: -1, name: "axis", type: "number" }], attrs: [{ tfName: "N", name: "n", type: "number", defaultValue: 2 }] }, { tfOpName: "Concat", category: "slice_join", inputs: [{ start: 1, end: 0, name: "tensors", type: "tensors" }, { start: 0, name: "axis", type: "number" }], attrs: [{ tfName: "N", name: "n", type: "number", defaultValue: 2 }] }, { tfOpName: "GatherV2", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "axis", type: "number", defaultValue: 0 }], attrs: [{ tfName: "batch_dims", name: "batchDims", type: "number", defaultValue: 0 }] }, { tfOpName: "Gather", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", notSupported: true }] }, { tfOpName: "Reverse", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "dims", type: "bool[]" }] }, { tfOpName: "ReverseV2", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }] }, { tfOpName: "Slice", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "begin", type: "number[]" }, { start: 2, name: "size", type: "number[]" }] }, { tfOpName: "StridedSlice", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "begin", type: "number[]" }, { start: 2, name: "end", type: "number[]" }, { start: 3, name: "strides", type: "number[]" }], attrs: [{ tfName: "begin_mask", name: "beginMask", type: "number", defaultValue: 0 }, { tfName: "end_mask", name: "endMask", type: "number", defaultValue: 0 }, { tfName: "new_axis_mask", name: "newAxisMask", type: "number", defaultValue: 0 }, { tfName: "ellipsis_mask", name: "ellipsisMask", type: "number", defaultValue: 0 }, { tfName: "shrink_axis_mask", name: "shrinkAxisMask", type: "number", defaultValue: 0 }] }, { tfOpName: "Pack", category: "slice_join", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }], attrs: [{ tfName: "axis", name: "axis", type: "number", defaultValue: 0 }] }, { tfOpName: "Unpack", category: "slice_join", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "axis", name: "axis", type: "number", defaultValue: 0 }, { tfName: "num", name: "num", type: "number", defaultValue: 0, notSupported: true }] }, { tfOpName: "Tile", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "reps", type: "number[]" }] }, { tfOpName: "Split", category: "slice_join", inputs: [{ start: 0, name: "axis", type: "number", defaultValue: 0 }, { start: 1, name: "x", type: "tensor" }], attrs: [{ tfName: "num_split", name: "numOrSizeSplits", type: "number", defaultValue: 1 }] }, { tfOpName: "SplitV", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "numOrSizeSplits", type: "number[]" }, { start: 2, name: "axis", type: "number", defaultValue: 0 }] }, { tfOpName: "ScatterNd", category: "slice_join", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "values", type: "tensor" }, { start: 2, name: "shape", type: "number[]" }] }, { tfOpName: "GatherNd", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }] }, { tfOpName: "SparseToDense", category: "slice_join", inputs: [{ start: 0, name: "sparseIndices", type: "tensor" }, { start: 1, name: "outputShape", type: "number[]" }, { start: 2, name: "sparseValues", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", defaultValue: false, notSupported: true }] }];
-var HC = {};
-Be(HC, { json: () => m6 });
-var m6 = [{ tfOpName: "SparseFillEmptyRows", category: "sparse", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "values", type: "tensor" }, { start: 2, name: "denseShape", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }] }, { tfOpName: "SparseReshape", category: "sparse", inputs: [{ start: 0, name: "inputIndices", type: "tensor" }, { start: 1, name: "inputShape", type: "tensor" }, { start: 2, name: "newShape", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "SparseSegmentMean", category: "sparse", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "segmentIds", type: "tensor" }] }, { tfOpName: "SparseSegmentSum", category: "sparse", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "segmentIds", type: "tensor" }] }];
-var qC = {};
-Be(qC, { json: () => f6 });
-var f6 = [{ tfOpName: "FFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "IFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "RFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "fft_length", type: "number", notSupported: true }] }, { tfOpName: "IRFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "fft_length", type: "number", notSupported: true }] }];
-var KC = {};
-Be(KC, { json: () => d6 });
-var d6 = [{ tfOpName: "StringNGrams", category: "string", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "dataSplits", type: "tensor" }], attrs: [{ tfName: "separator", name: "separator", type: "string" }, { tfName: "ngram_widths", name: "nGramWidths", type: "number[]" }, { tfName: "left_pad", name: "leftPad", type: "string" }, { tfName: "right_pad", name: "rightPad", type: "string" }, { tfName: "pad_width", name: "padWidth", type: "number" }, { tfName: "preserve_short_sequences", name: "preserveShortSequences", type: "bool" }], outputs: ["ngrams", "ngrams_splits"] }, { tfOpName: "StringSplit", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "delimiter", type: "tensor" }], attrs: [{ tfName: "skip_empty", name: "skipEmpty", type: "bool" }], outputs: ["indices", "values", "shape"] }, { tfOpName: "StringToHashBucketFast", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }], attrs: [{ tfName: "num_buckets", name: "numBuckets", type: "number" }] }];
-var jC = {};
-Be(jC, { json: () => h6 });
-var h6 = [{ tfOpName: "Cast", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "SrcT", name: "sdtype", type: "dtype", notSupported: true }, { tfName: "DstT", name: "dtype", type: "dtype" }] }, { tfOpName: "ExpandDims", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "MirrorPad", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }], attrs: [{ tfName: "mode", name: "mode", type: "string" }] }, { tfOpName: "Pad", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }], attrs: [{ tfName: "constant_value", name: "constantValue", type: "number", defaultValue: 0 }] }, { tfOpName: "PadV2", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }, { start: 2, name: "constantValue", type: "number", defaultValue: 0 }] }, { tfOpName: "Reshape", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }] }, { tfOpName: "Squeeze", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "axis", tfDeprecatedName: "squeeze_dims", name: "axis", type: "number[]" }] }, { tfOpName: "SpaceToBatchND", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "blockShape", type: "number[]" }, { start: 2, name: "paddings", type: "number[]" }] }, { tfOpName: "BatchToSpaceND", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "blockShape", type: "number[]" }, { start: 2, name: "crops", type: "number[]" }] }, { tfOpName: "DepthToSpace", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "block_size", name: "blockSize", type: "number" }, { tfName: "data_format", name: "dataFormat", type: "string" }] }, { tfOpName: "BroadcastTo", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }], attrs: [] }, { tfOpName: "BroadcastArgs", category: "transformation", inputs: [{ start: 0, name: "s0", type: "tensor" }, { start: 1, name: "s1", type: "tensor" }], attrs: [] }];
-var xl = class {
+Ue(UC, { json: () => PK });
+var PK = [{ tfOpName: "Cast", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "SrcT", name: "sdtype", type: "dtype", notSupported: true }, { tfName: "DstT", name: "dtype", type: "dtype" }] }, { tfOpName: "ExpandDims", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "MirrorPad", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }], attrs: [{ tfName: "mode", name: "mode", type: "string" }] }, { tfOpName: "Pad", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }], attrs: [{ tfName: "constant_value", name: "constantValue", type: "number", defaultValue: 0 }] }, { tfOpName: "PadV2", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }, { start: 2, name: "constantValue", type: "number", defaultValue: 0 }] }, { tfOpName: "Reshape", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }] }, { tfOpName: "Squeeze", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "axis", tfDeprecatedName: "squeeze_dims", name: "axis", type: "number[]" }] }, { tfOpName: "SpaceToBatchND", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "blockShape", type: "number[]" }, { start: 2, name: "paddings", type: "number[]" }] }, { tfOpName: "BatchToSpaceND", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "blockShape", type: "number[]" }, { start: 2, name: "crops", type: "number[]" }] }, { tfOpName: "DepthToSpace", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "block_size", name: "blockSize", type: "number" }, { tfName: "data_format", name: "dataFormat", type: "string" }] }, { tfOpName: "BroadcastTo", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }], attrs: [] }, { tfOpName: "BroadcastArgs", category: "transformation", inputs: [{ start: 0, name: "s0", type: "tensor" }, { start: 1, name: "s1", type: "tensor" }], attrs: [] }];
+var pl = class {
constructor() {
- let e = [$C, RC, AC, FC, DC, PC, OC, MC, LC, BC, VC, zC, WC, UC, GC, HC, qC, KC, jC], t10 = [].concat(...e.map((o) => o.json));
- this.opMappers = t10.reduce((o, n) => (o[n.tfOpName] = n, o), {});
+ let e = [kC, NC, TC, _C, EC, $C, AC, RC, FC, DC, OC, PC, MC, LC, BC, VC, zC, WC, UC], t6 = [].concat(...e.map((o) => o.json));
+ this.opMappers = t6.reduce((o, n) => (o[n.tfOpName] = n, o), {});
}
static get Instance() {
return this._instance || (this._instance = new this());
}
- transformGraph(e, t10 = {}) {
+ transformGraph(e, t6 = {}) {
let o = e.node, n = [], s = [], a = [], i = o.reduce((h, g) => (h[g.name] = this.mapNode(g), g.op.startsWith("Placeholder") ? n.push(h[g.name]) : g.op === "Const" ? s.push(h[g.name]) : (g.input == null || g.input.length === 0) && a.push(h[g.name]), h), {}), p = [], u = [], c = {}, l = {};
- t10 != null && (c = this.mapSignatureEntries(t10.inputs), l = this.mapSignatureEntries(t10.outputs));
+ t6 != null && (c = this.mapSignatureEntries(t6.inputs), l = this.mapSignatureEntries(t6.outputs));
let m = Object.keys(i);
m.forEach((h) => {
let g = i[h];
- g.inputNames.forEach((y, b) => {
- let [C, , w] = zo(y), k = i[C];
+ g.inputNames.forEach((x, b) => {
+ let [C, , w] = ss(x), k = i[C];
if (k.outputs != null) {
let _ = k.outputs.indexOf(w);
if (_ !== -1) {
- let E = `${C}:${_}`;
- g.inputNames[b] = E;
+ let $ = `${C}:${_}`;
+ g.inputNames[b] = $;
}
}
g.inputs.push(k), k.children.push(g);
@@ -9499,59 +9509,59 @@ var xl = class {
let g = i[h];
g.children.length === 0 && u.push(g);
}) : Object.keys(l).forEach((h) => {
- let [g] = zo(h), y = i[g];
- y != null && (y.signatureKey = l[h], u.push(y));
+ let [g] = ss(h), x = i[g];
+ x != null && (x.signatureKey = l[h], u.push(x));
}), Object.keys(c).length > 0 ? Object.keys(c).forEach((h) => {
- let [g] = zo(h), y = i[g];
- y && (y.signatureKey = c[h], p.push(y));
+ let [g] = ss(h), x = i[g];
+ x && (x.signatureKey = c[h], p.push(x));
}) : p = n;
- let f = {};
- e.library != null && e.library.function != null && (f = e.library.function.reduce((h, g) => (h[g.signature.name] = this.mapFunction(g), h), {}));
- let d = { nodes: i, inputs: p, outputs: u, weights: s, placeholders: n, signature: t10, functions: f };
- return a.length > 0 && (d.initNodes = a), d;
+ let d = {};
+ e.library != null && e.library.function != null && (d = e.library.function.reduce((h, g) => (h[g.signature.name] = this.mapFunction(g), h), {}));
+ let f = { nodes: i, inputs: p, outputs: u, weights: s, placeholders: n, signature: t6, functions: d };
+ return a.length > 0 && (f.initNodes = a), f;
}
mapSignatureEntries(e) {
- return Object.keys(e || {}).reduce((t10, o) => (t10[e[o].name] = o, t10), {});
+ return Object.keys(e || {}).reduce((t6, o) => (t6[e[o].name] = o, t6), {});
}
mapNode(e) {
- let t10 = td(e.op) || this.opMappers[e.op] || {};
+ let t6 = Gd(e.op) || this.opMappers[e.op] || {};
e.attr == null && (e.attr = {});
- let o = { name: e.name, op: e.op, category: t10.category, inputNames: (e.input || []).map((n) => n.startsWith("^") ? n.slice(1) : n), inputs: [], children: [], inputParams: {}, attrParams: {}, rawAttrs: e.attr, outputs: t10.outputs };
- return t10.inputs != null && (o.inputParams = t10.inputs.reduce((n, s) => (n[s.name] = { type: s.type, inputIndexStart: s.start, inputIndexEnd: s.end }, n), {})), t10.attrs != null && (o.attrParams = t10.attrs.reduce((n, s) => {
+ let o = { name: e.name, op: e.op, category: t6.category, inputNames: (e.input || []).map((n) => n.startsWith("^") ? n.slice(1) : n), inputs: [], children: [], inputParams: {}, attrParams: {}, rawAttrs: e.attr, outputs: t6.outputs };
+ return t6.inputs != null && (o.inputParams = t6.inputs.reduce((n, s) => (n[s.name] = { type: s.type, inputIndexStart: s.start, inputIndexEnd: s.end }, n), {})), t6.attrs != null && (o.attrParams = t6.attrs.reduce((n, s) => {
let a = s.type, i;
switch (s.type) {
case "string":
- i = od(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = od(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = qd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = qd(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "string[]":
- i = cd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = cd(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = Jd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = Jd(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "number":
- i = sd(e.attr, s.tfName, s.defaultValue || 0), i === void 0 && !!s.tfDeprecatedName && (i = sd(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = jd(e.attr, s.tfName, s.defaultValue || 0), i === void 0 && !!s.tfDeprecatedName && (i = jd(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "number[]":
- i = pd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = pd(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = Zd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = Zd(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "bool":
- i = nd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = nd(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = Kd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = Kd(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "bool[]":
- i = md(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = md(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = tf(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = tf(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "shape":
- i = ud(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = ud(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = Qd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = Qd(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "shape[]":
- i = ld(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = ld(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = ef(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = ef(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "dtype":
- i = ad(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = ad(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = Xd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = Xd(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "dtype[]":
- i = id(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = id(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = Yd(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = Yd(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "func":
- i = QT(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = QT(e.attr, s.tfDeprecatedName, s.defaultValue));
+ i = kN(e.attr, s.tfName, s.defaultValue), i === void 0 && !!s.tfDeprecatedName && (i = kN(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "tensor":
case "tensors":
@@ -9563,326 +9573,326 @@ var xl = class {
}, {})), o;
}
mapFunction(e) {
- let t10 = e.nodeDef, o = [], n = [], s = {};
- t10 != null && (s = t10.reduce((l, m) => (l[m.name] = this.mapNode(m), m.op === "Const" && n.push(l[m.name]), l), {}));
+ let t6 = e.nodeDef, o = [], n = [], s = {};
+ t6 != null && (s = t6.reduce((l, m) => (l[m.name] = this.mapNode(m), m.op === "Const" && n.push(l[m.name]), l), {}));
let a = [], i = [];
e.signature.inputArg.forEach((l) => {
- let [m] = zo(l.name), f = { name: m, op: "Placeholder", inputs: [], inputNames: [], category: "graph", inputParams: {}, attrParams: { dtype: { value: XC(l.type), type: "dtype" } }, children: [] };
- f.signatureKey = l.name, a.push(f), s[m] = f;
+ let [m] = ss(l.name), d = { name: m, op: "Placeholder", inputs: [], inputNames: [], category: "graph", inputParams: {}, attrParams: { dtype: { value: GC(l.type), type: "dtype" } }, children: [] };
+ d.signatureKey = l.name, a.push(d), s[m] = d;
}), Object.keys(s).forEach((l) => {
let m = s[l];
- m.inputNames.forEach((f, d) => {
- let [h, , g] = zo(f), y = s[h];
- if (y.outputs != null) {
- let b = y.outputs.indexOf(g);
+ m.inputNames.forEach((d, f) => {
+ let [h, , g] = ss(d), x = s[h];
+ if (x.outputs != null) {
+ let b = x.outputs.indexOf(g);
if (b !== -1) {
let C = `${h}:${b}`;
- m.inputNames[d] = C;
+ m.inputNames[f] = C;
}
}
- m.inputs.push(y), y.children.push(m);
+ m.inputs.push(x), x.children.push(m);
});
});
let u = e.ret;
e.signature.outputArg.forEach((l) => {
- let [m, f] = zo(u[l.name]), d = s[m];
- d != null && (d.defaultOutput = f, i.push(d));
+ let [m, d] = ss(u[l.name]), f = s[m];
+ f != null && (f.defaultOutput = d, i.push(f));
});
let c = this.mapArgsToSignature(e);
return { nodes: s, inputs: a, outputs: i, weights: n, placeholders: o, signature: c };
}
mapArgsToSignature(e) {
- return { methodName: e.signature.name, inputs: e.signature.inputArg.reduce((t10, o) => (t10[o.name] = this.mapArgToTensorInfo(o), t10), {}), outputs: e.signature.outputArg.reduce((t10, o) => (t10[o.name] = this.mapArgToTensorInfo(o, e.ret), t10), {}) };
+ return { methodName: e.signature.name, inputs: e.signature.inputArg.reduce((t6, o) => (t6[o.name] = this.mapArgToTensorInfo(o), t6), {}), outputs: e.signature.outputArg.reduce((t6, o) => (t6[o.name] = this.mapArgToTensorInfo(o, e.ret), t6), {}) };
}
- mapArgToTensorInfo(e, t10) {
+ mapArgToTensorInfo(e, t6) {
let o = e.name;
- return t10 != null && (o = t10[o]), { name: o, dtype: e.type };
+ return t6 != null && (o = t6[o]), { name: o, dtype: e.type };
}
};
-function g6(r) {
- let e = P().global;
+function MK(r) {
+ let e = O().global;
if (typeof e.atob != "undefined")
return e.atob(r);
if (typeof Buffer != "undefined")
return new Buffer(r, "base64").toString();
throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()");
}
-function ZT(r, e) {
- let t10 = Array.isArray(r) ? String.fromCharCode.apply(null, r) : g6(r);
- return e ? t10 : t10.toLowerCase();
+function NN(r, e) {
+ let t6 = Array.isArray(r) ? String.fromCharCode.apply(null, r) : MK(r);
+ return e ? t6 : t6.toLowerCase();
}
-function od(r, e, t10, o = false) {
+function qd(r, e, t6, o = false) {
let n = r[e];
- return n != null ? ZT(n.s, o) : t10;
+ return n != null ? NN(n.s, o) : t6;
}
-function nd(r, e, t10) {
+function Kd(r, e, t6) {
let o = r[e];
- return o ? o.b : t10;
+ return o ? o.b : t6;
}
-function sd(r, e, t10) {
- let o = r[e] || {}, n = o.i != null ? o.i : o.f != null ? o.f : t10;
+function jd(r, e, t6) {
+ let o = r[e] || {}, n = o.i != null ? o.i : o.f != null ? o.f : t6;
return typeof n == "number" ? n : parseInt(n, 10);
}
-function XC(r) {
- switch (typeof r == "string" && (r = To[r]), r) {
- case To.DT_FLOAT:
- case To.DT_HALF:
+function GC(r) {
+ switch (typeof r == "string" && (r = ao[r]), r) {
+ case ao.DT_FLOAT:
+ case ao.DT_HALF:
return "float32";
- case To.DT_INT32:
- case To.DT_INT64:
- case To.DT_INT8:
- case To.DT_UINT8:
+ case ao.DT_INT32:
+ case ao.DT_INT64:
+ case ao.DT_INT8:
+ case ao.DT_UINT8:
return "int32";
- case To.DT_BOOL:
+ case ao.DT_BOOL:
return "bool";
- case To.DT_DOUBLE:
+ case ao.DT_DOUBLE:
return "float32";
- case To.DT_STRING:
+ case ao.DT_STRING:
return "string";
default:
return null;
}
}
-function QT(r, e, t10) {
+function kN(r, e, t6) {
let o = r[e];
- return o && o.func ? o.func.name : t10;
+ return o && o.func ? o.func.name : t6;
}
-function ad(r, e, t10) {
+function Xd(r, e, t6) {
let o = r[e];
- return o && o.type ? XC(o.type) : t10;
+ return o && o.type ? GC(o.type) : t6;
}
-function id(r, e, t10) {
+function Yd(r, e, t6) {
let o = r[e];
- return o && o.list && o.list.type ? o.list.type.map((n) => XC(n)) : t10;
+ return o && o.list && o.list.type ? o.list.type.map((n) => GC(n)) : t6;
}
-function JT(r) {
+function TN(r) {
if (!r.unknownRank)
return r.dim != null ? r.dim.map((e) => typeof e.size == "number" ? e.size : parseInt(e.size, 10)) : [];
}
-function ud(r, e, t10) {
+function Qd(r, e, t6) {
let o = r[e];
- return o && o.shape ? JT(o.shape) : t10;
+ return o && o.shape ? TN(o.shape) : t6;
}
-function pd(r, e, t10) {
+function Zd(r, e, t6) {
let o = r[e];
- return o ? ((o.list.f && o.list.f.length ? o.list.f : o.list.i) || []).map((n) => typeof n == "number" ? n : parseInt(n, 10)) : t10;
+ return o ? ((o.list.f && o.list.f.length ? o.list.f : o.list.i) || []).map((n) => typeof n == "number" ? n : parseInt(n, 10)) : t6;
}
-function cd(r, e, t10, o = false) {
+function Jd(r, e, t6, o = false) {
let n = r[e];
- return n && n.list && n.list.s ? n.list.s.map((s) => ZT(s, o)) : t10;
+ return n && n.list && n.list.s ? n.list.s.map((s) => NN(s, o)) : t6;
}
-function ld(r, e, t10) {
+function ef(r, e, t6) {
let o = r[e];
- return o && o.list && o.list.shape ? o.list.shape.map((n) => JT(n)) : t10;
+ return o && o.list && o.list.shape ? o.list.shape.map((n) => TN(n)) : t6;
}
-function md(r, e, t10) {
+function tf(r, e, t6) {
let o = r[e];
- return o && o.list && o.list.b ? o.list.b : t10;
+ return o && o.list && o.list.b ? o.list.b : t6;
}
-var fd = class {
- constructor(e, t10, o) {
- this.node = e, this.tensorMap = t10, this.context = o, this.inputs = [], this.attrs = {}, this.inputs = e.inputNames.map((n) => this.getInput(n)), e.rawAttrs != null && (this.attrs = Object.keys(e.rawAttrs).reduce((n, s) => (n[s] = this.getAttr(s), n), {}));
+var rf = class {
+ constructor(e, t6, o) {
+ this.node = e, this.tensorMap = t6, this.context = o, this.inputs = [], this.attrs = {}, this.inputs = e.inputNames.map((n) => this.getInput(n)), e.rawAttrs != null && (this.attrs = Object.keys(e.rawAttrs).reduce((n, s) => (n[s] = this.getAttr(s), n), {}));
}
getInput(e) {
- return Ht(e, this.tensorMap, this.context);
+ return Gt(e, this.tensorMap, this.context);
}
- getAttr(e, t10) {
+ getAttr(e, t6) {
let o = this.node.rawAttrs[e];
if (o.tensor != null)
- return Ht(e, this.tensorMap, this.context);
+ return Gt(e, this.tensorMap, this.context);
if (o.i != null || o.f != null)
- return sd(this.node.rawAttrs, e, t10);
+ return jd(this.node.rawAttrs, e, t6);
if (o.s != null)
- return od(this.node.rawAttrs, e, t10);
+ return qd(this.node.rawAttrs, e, t6);
if (o.b != null)
- return nd(this.node.rawAttrs, e, t10);
+ return Kd(this.node.rawAttrs, e, t6);
if (o.shape != null)
- return ud(this.node.rawAttrs, e, t10);
+ return Qd(this.node.rawAttrs, e, t6);
if (o.type != null)
- return ad(this.node.rawAttrs, e, t10);
+ return Xd(this.node.rawAttrs, e, t6);
if (o.list != null) {
if (o.list.i != null || o.list.f != null)
- return pd(this.node.rawAttrs, e, t10);
+ return Zd(this.node.rawAttrs, e, t6);
if (o.list.s != null)
- return cd(this.node.rawAttrs, e, t10);
+ return Jd(this.node.rawAttrs, e, t6);
if (o.list.shape != null)
- return ld(this.node.rawAttrs, e, t10);
+ return ef(this.node.rawAttrs, e, t6);
if (o.list.b != null)
- return md(this.node.rawAttrs, e, t10);
+ return tf(this.node.rawAttrs, e, t6);
if (o.list.type != null)
- return id(this.node.rawAttrs, e, t10);
+ return Yd(this.node.rawAttrs, e, t6);
}
- return t10;
+ return t6;
}
};
-var rt = {};
-Be(rt, { OP_SCOPE_SUFFIX: () => Ub, abs: () => Qt, acos: () => Vv, acosh: () => zv, add: () => ge, addN: () => Wv, all: () => Uv, any: () => Gv, argMax: () => Hv, argMin: () => qv, asin: () => Kv, asinh: () => jv, atan: () => Xv, atan2: () => Yv, atanh: () => Qv, avgPool: () => mf, avgPool3d: () => ek, basicLSTMCell: () => tk, batchNorm: () => li, batchNorm2d: () => ok, batchNorm3d: () => nk, batchNorm4d: () => sk, batchToSpaceND: () => ff, bincount: () => df, booleanMaskAsync: () => _H, broadcastArgs: () => ak, broadcastTo: () => Ls, buffer: () => ne, cast: () => qe, ceil: () => ik, clipByValue: () => uk, clone: () => zr, complex: () => Er, concat: () => gt, concat1d: () => pk, concat2d: () => ck, concat3d: () => lk, concat4d: () => mk, conv1d: () => fk, conv2d: () => mi, conv2dTranspose: () => dk, conv3d: () => hk, conv3dTranspose: () => xk, cos: () => yk, cosh: () => bk, cosineWindow: () => hl, cumprod: () => Ck, cumsum: () => Ik, denseBincount: () => wk, depthToSpace: () => Sk, depthwiseConv2d: () => Gp, diag: () => vk, dilation2d: () => kk, div: () => We, divNoNan: () => Tk, dot: () => Nk, dropout: () => BH, einsum: () => _k, elu: () => xf, enclosingPowerOfTwo: () => wC, equal: () => gf, erf: () => Ek, euclideanNorm: () => Ak, exp: () => Bo, expandDims: () => _a, expm1: () => Fk, eye: () => yf, fft: () => qp, fill: () => Bs, floor: () => bf, floorDiv: () => cf, fused: () => SC, gather: () => Cf, gatherND: () => MH, greater: () => cu, greaterEqual: () => If, ifft: () => hu, imag: () => ci, image: () => zq, inTopKAsync: () => zH, irfft: () => Gf, isFinite: () => Dk, isInf: () => Pk, isNaN: () => Ok, leakyRelu: () => wf, less: () => Mk, lessEqual: () => Hp, linalg: () => Wq, linspace: () => Lk, localResponseNormalization: () => Bk, log: () => Ea, log1p: () => Sf, logSigmoid: () => Vk, logSoftmax: () => zk, logSumExp: () => Tf, logicalAnd: () => lu, logicalNot: () => Nf, logicalOr: () => _f, logicalXor: () => Wk, losses: () => Uq, lowerBound: () => Uk, matMul: () => Xe, max: () => Vs, maxPool: () => $f, maxPool3d: () => Gk, maxPoolWithArgmax: () => Hk, maximum: () => Rf, mean: () => mu, meshgrid: () => qk, min: () => fl, minimum: () => Af, mirrorPad: () => Kk, mod: () => jk, moments: () => Xk, movingAverage: () => $H, mul: () => oe, multiRNNCell: () => Yk, multinomial: () => Qk, neg: () => yr, norm: () => pu, notEqual: () => Ff, oneHot: () => pl, ones: () => zs, onesLike: () => Zk, op: () => T, outerProduct: () => Jk, pad: () => Ws, pad1d: () => e1, pad2d: () => t1, pad3d: () => r1, pad4d: () => o1, pool: () => n1, pow: () => Na, prelu: () => Pf, print: () => ef, prod: () => s1, raggedGather: () => a1, raggedRange: () => i1, raggedTensorToTensor: () => u1, rand: () => p1, randomGamma: () => T1, randomNormal: () => Vf, randomStandardNormal: () => N1, randomUniform: () => zf, range: () => di, real: () => ka, reciprocal: () => _1, relu: () => hi, relu6: () => Wf, reshape: () => z, reverse: () => vo, reverse1d: () => E1, reverse2d: () => $1, reverse3d: () => R1, reverse4d: () => A1, rfft: () => Kp, round: () => Uf, rsqrt: () => F1, scalar: () => be, scatterND: () => AH, searchSorted: () => dl, selu: () => D1, separableConv2d: () => P1, setdiff1dAsync: () => O1, sigmoid: () => Ms, sign: () => M1, signal: () => Vq, sin: () => L1, sinh: () => B1, slice: () => Ue, slice1d: () => V1, slice2d: () => z1, slice3d: () => W1, slice4d: () => U1, softmax: () => G1, softplus: () => kf, spaceToBatchND: () => Df, sparse: () => Gq, sparseToDense: () => PH, spectral: () => Bq, split: () => $a, sqrt: () => Rr, square: () => Zt, squaredDifference: () => Hf, squeeze: () => jp, stack: () => Ir, step: () => qf, stridedSlice: () => H1, string: () => Hq, sub: () => ke, sum: () => tt, tan: () => q1, tanh: () => ml, tensor: () => nr, tensor1d: () => mr, tensor2d: () => gi, tensor3d: () => sf, tensor4d: () => K1, tensor5d: () => j1, tensor6d: () => X1, tile: () => fi, topk: () => Y1, transpose: () => Wp, truncatedNormal: () => Q1, unique: () => Z1, unsortedSegmentSum: () => J1, unstack: () => ko, upperBound: () => eT, variable: () => tT, where: () => os, whereAsync: () => jf, zeros: () => Wr, zerosLike: () => Gt });
-var eN = (r, e, t10, o = rt) => {
+var Ye = {};
+Ue(Ye, { OP_SCOPE_SUFFIX: () => Lb, abs: () => Yt, acos: () => f0, acosh: () => h0, add: () => xe, addN: () => g0, all: () => x0, any: () => y0, argMax: () => b0, argMin: () => C0, asin: () => S0, asinh: () => w0, atan: () => I0, atan2: () => v0, atanh: () => k0, avgPool: () => td, avgPool3d: () => _0, basicLSTMCell: () => E0, batchNorm: () => wi, batchNorm2d: () => A0, batchNorm3d: () => R0, batchNorm4d: () => F0, batchToSpaceND: () => rd, bincount: () => od, booleanMaskAsync: () => XG, broadcastArgs: () => D0, broadcastTo: () => Ii, buffer: () => le, cast: () => Ke, ceil: () => O0, clipByValue: () => P0, clone: () => Br, complex: () => Tr, concat: () => gt, concat1d: () => M0, concat2d: () => L0, concat3d: () => B0, concat4d: () => V0, conv1d: () => z0, conv2d: () => vi, conv2dTranspose: () => W0, conv3d: () => U0, conv3dTranspose: () => H0, cos: () => q0, cosh: () => K0, cosineWindow: () => il, cumprod: () => j0, cumsum: () => X0, denseBincount: () => Y0, depthToSpace: () => Q0, depthwiseConv2d: () => Bp, diag: () => Z0, dilation2d: () => J0, div: () => Ge, divNoNan: () => ek, dot: () => tk, dropout: () => aH, einsum: () => rk, elu: () => ad, enclosingPowerOfTwo: () => xC, equal: () => sd, erf: () => ok, euclideanNorm: () => ak, exp: () => Co, expandDims: () => Fa, expm1: () => ik, eye: () => id, fft: () => zp, fill: () => Ws, floor: () => ud, floorDiv: () => Jm, fused: () => yC, gather: () => pd, gatherND: () => nH, greater: () => cu, greaterEqual: () => cd, ifft: () => hu, imag: () => Si, image: () => uq, inTopKAsync: () => uH, irfft: () => Fd, isFinite: () => uk, isInf: () => pk, isNaN: () => ck, leakyRelu: () => ld, less: () => lk, lessEqual: () => Vp, linalg: () => pq, linspace: () => mk, localResponseNormalization: () => dk, log: () => Da, log1p: () => md, logSigmoid: () => fk, logSoftmax: () => hk, logSumExp: () => hd, logicalAnd: () => lu, logicalNot: () => gd, logicalOr: () => xd, logicalXor: () => gk, losses: () => cq, lowerBound: () => xk, matMul: () => Xe, max: () => Us, maxPool: () => bd, maxPool3d: () => yk, maxPoolWithArgmax: () => bk, maximum: () => Cd, mean: () => mu, meshgrid: () => Ck, min: () => sl, minimum: () => Sd, mirrorPad: () => Sk, mod: () => wk, moments: () => Ik, movingAverage: () => QG, mul: () => ae, multiRNNCell: () => vk, multinomial: () => kk, neg: () => yr, norm: () => pu, notEqual: () => wd, oneHot: () => tl, ones: () => Gs, onesLike: () => Nk, op: () => N, outerProduct: () => Tk, pad: () => Hs, pad1d: () => _k, pad2d: () => Ek, pad3d: () => $k, pad4d: () => Ak, pool: () => Rk, pow: () => Ra, prelu: () => vd, print: () => Gm, prod: () => Fk, raggedGather: () => Dk, raggedRange: () => Ok, raggedTensorToTensor: () => Pk, rand: () => Mk, randomGamma: () => e1, randomNormal: () => Ed, randomStandardNormal: () => t1, randomUniform: () => $d, range: () => Ni, real: () => $a, reciprocal: () => r1, relu: () => Ti, relu6: () => Ad, reshape: () => z, reverse: () => no, reverse1d: () => o1, reverse2d: () => n1, reverse3d: () => s1, reverse4d: () => a1, rfft: () => Wp, round: () => Rd, rsqrt: () => i1, scalar: () => be, scatterND: () => JG, searchSorted: () => al, selu: () => u1, separableConv2d: () => p1, setdiff1dAsync: () => c1, sigmoid: () => zs, sign: () => l1, signal: () => iq, sin: () => m1, sinh: () => d1, slice: () => He, slice1d: () => f1, slice2d: () => h1, slice3d: () => g1, slice4d: () => x1, softmax: () => y1, softplus: () => fd, spaceToBatchND: () => Id, sparse: () => lq, sparseToDense: () => rH, spectral: () => aq, split: () => Oa, sqrt: () => $r, square: () => Qt, squaredDifference: () => Dd, squeeze: () => Up, stack: () => Sr, step: () => Od, stridedSlice: () => b1, string: () => mq, sub: () => Ne, sum: () => et, tan: () => C1, tanh: () => nl, tensor: () => nr, tensor1d: () => mr, tensor2d: () => _i, tensor3d: () => Xm, tensor4d: () => S1, tensor5d: () => w1, tensor6d: () => I1, tile: () => ki, topk: () => v1, transpose: () => Mp, truncatedNormal: () => k1, unique: () => N1, unsortedSegmentSum: () => T1, unstack: () => so, upperBound: () => _1, variable: () => E1, where: () => os, whereAsync: () => Md, zeros: () => Vr, zerosLike: () => Ut });
+var _N = (r, e, t6, o = Ye) => {
switch (r.op) {
case "BiasAdd":
case "AddV2":
case "Add":
- return [o.add(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.add(I("a", r, e, t6), I("b", r, e, t6))];
case "AddN":
- return [o.addN(S("tensors", r, e, t10))];
+ return [o.addN(I("tensors", r, e, t6))];
case "FloorMod":
case "Mod":
- return [o.mod(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.mod(I("a", r, e, t6), I("b", r, e, t6))];
case "Mul":
- return [o.mul(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.mul(I("a", r, e, t6), I("b", r, e, t6))];
case "RealDiv":
case "Div":
- return [o.div(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.div(I("a", r, e, t6), I("b", r, e, t6))];
case "DivNoNan":
- return [o.divNoNan(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.divNoNan(I("a", r, e, t6), I("b", r, e, t6))];
case "FloorDiv":
- return [o.floorDiv(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.floorDiv(I("a", r, e, t6), I("b", r, e, t6))];
case "Sub":
- return [o.sub(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.sub(I("a", r, e, t6), I("b", r, e, t6))];
case "Minimum":
- return [o.minimum(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.minimum(I("a", r, e, t6), I("b", r, e, t6))];
case "Maximum":
- return [o.maximum(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.maximum(I("a", r, e, t6), I("b", r, e, t6))];
case "Pow":
- return [o.pow(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.pow(I("a", r, e, t6), I("b", r, e, t6))];
case "SquaredDifference":
- return [o.squaredDifference(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.squaredDifference(I("a", r, e, t6), I("b", r, e, t6))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var tN = (r, e, t10, o = rt) => {
+var EN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "Abs":
case "ComplexAbs":
- return [o.abs(S("x", r, e, t10))];
+ return [o.abs(I("x", r, e, t6))];
case "Acos":
- return [o.acos(S("x", r, e, t10))];
+ return [o.acos(I("x", r, e, t6))];
case "Acosh":
- return [o.acosh(S("x", r, e, t10))];
+ return [o.acosh(I("x", r, e, t6))];
case "Asin":
- return [o.asin(S("x", r, e, t10))];
+ return [o.asin(I("x", r, e, t6))];
case "Asinh":
- return [o.asinh(S("x", r, e, t10))];
+ return [o.asinh(I("x", r, e, t6))];
case "Atan":
- return [o.atan(S("x", r, e, t10))];
+ return [o.atan(I("x", r, e, t6))];
case "Atan2":
- return [o.atan2(S("x", r, e, t10), S("y", r, e, t10))];
+ return [o.atan2(I("x", r, e, t6), I("y", r, e, t6))];
case "Atanh":
- return [o.atanh(S("x", r, e, t10))];
+ return [o.atanh(I("x", r, e, t6))];
case "Ceil":
- return [o.ceil(S("x", r, e, t10))];
+ return [o.ceil(I("x", r, e, t6))];
case "Complex":
- return [o.complex(S("real", r, e, t10), S("imag", r, e, t10))];
+ return [o.complex(I("real", r, e, t6), I("imag", r, e, t6))];
case "Cos":
- return [o.cos(S("x", r, e, t10))];
+ return [o.cos(I("x", r, e, t6))];
case "Cosh":
- return [o.cosh(S("x", r, e, t10))];
+ return [o.cosh(I("x", r, e, t6))];
case "Elu":
- return [o.elu(S("x", r, e, t10))];
+ return [o.elu(I("x", r, e, t6))];
case "Erf":
- return [o.erf(S("x", r, e, t10))];
+ return [o.erf(I("x", r, e, t6))];
case "Exp":
- return [o.exp(S("x", r, e, t10))];
+ return [o.exp(I("x", r, e, t6))];
case "Expm1":
- return [o.expm1(S("x", r, e, t10))];
+ return [o.expm1(I("x", r, e, t6))];
case "Floor":
- return [o.floor(S("x", r, e, t10))];
+ return [o.floor(I("x", r, e, t6))];
case "Log":
- return [o.log(S("x", r, e, t10))];
+ return [o.log(I("x", r, e, t6))];
case "Log1p":
- return [o.log1p(S("x", r, e, t10))];
+ return [o.log1p(I("x", r, e, t6))];
case "Imag":
- return [o.imag(S("x", r, e, t10))];
+ return [o.imag(I("x", r, e, t6))];
case "Neg":
- return [o.neg(S("x", r, e, t10))];
+ return [o.neg(I("x", r, e, t6))];
case "Reciprocal":
- return [o.reciprocal(S("x", r, e, t10))];
+ return [o.reciprocal(I("x", r, e, t6))];
case "Real":
- return [o.real(S("x", r, e, t10))];
+ return [o.real(I("x", r, e, t6))];
case "Relu":
- return [o.relu(S("x", r, e, t10))];
+ return [o.relu(I("x", r, e, t6))];
case "Round":
- return [o.round(S("x", r, e, t10))];
+ return [o.round(I("x", r, e, t6))];
case "Selu":
- return [o.selu(S("x", r, e, t10))];
+ return [o.selu(I("x", r, e, t6))];
case "Sigmoid":
- return [o.sigmoid(S("x", r, e, t10))];
+ return [o.sigmoid(I("x", r, e, t6))];
case "Sin":
- return [o.sin(S("x", r, e, t10))];
+ return [o.sin(I("x", r, e, t6))];
case "Sign":
- return [o.sign(S("x", r, e, t10))];
+ return [o.sign(I("x", r, e, t6))];
case "Sinh":
- return [o.sinh(S("x", r, e, t10))];
+ return [o.sinh(I("x", r, e, t6))];
case "Softplus":
- return [o.softplus(S("x", r, e, t10))];
+ return [o.softplus(I("x", r, e, t6))];
case "Sqrt":
- return [o.sqrt(S("x", r, e, t10))];
+ return [o.sqrt(I("x", r, e, t6))];
case "Square":
- return [o.square(S("x", r, e, t10))];
+ return [o.square(I("x", r, e, t6))];
case "Tanh":
- return [o.tanh(S("x", r, e, t10))];
+ return [o.tanh(I("x", r, e, t6))];
case "Tan":
- return [o.tan(S("x", r, e, t10))];
+ return [o.tan(I("x", r, e, t6))];
case "ClipByValue":
- return [o.clipByValue(S("x", r, e, t10), S("clipValueMin", r, e, t10), S("clipValueMax", r, e, t10))];
+ return [o.clipByValue(I("x", r, e, t6), I("clipValueMin", r, e, t6), I("clipValueMax", r, e, t6))];
case "Relu6":
- return [o.relu6(S("x", r, e, t10))];
+ return [o.relu6(I("x", r, e, t6))];
case "Rsqrt":
- return [o.rsqrt(Ht(r.inputNames[0], e, t10))];
+ return [o.rsqrt(Gt(r.inputNames[0], e, t6))];
case "Prod":
- return [o.prod(S("x", r, e, t10), S("axes", r, e, t10))];
+ return [o.prod(I("x", r, e, t6), I("axes", r, e, t6))];
case "LeakyRelu":
- return [o.leakyRelu(S("x", r, e, t10), S("alpha", r, e, t10))];
+ return [o.leakyRelu(I("x", r, e, t6), I("alpha", r, e, t6))];
case "Prelu":
- return [o.prelu(S("x", r, e, t10), S("alpha", r, e, t10))];
+ return [o.prelu(I("x", r, e, t6), I("alpha", r, e, t6))];
case "IsNan":
- return [o.isNaN(Ht(r.inputNames[0], e, t10))];
+ return [o.isNaN(Gt(r.inputNames[0], e, t6))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-function Ur(r, e, t10 = "") {
+function zr(r, e, t6 = "") {
if (!(typeof r == "number" || typeof e == "number")) {
- x.assert(r.length === e.length, () => t10 + ` Shapes ${r} and ${e} must match`);
+ y.assert(r.length === e.length, () => t6 + ` Shapes ${r} and ${e} must match`);
for (let o = 0; o < r.length; o++) {
let n = r[o], s = e[o];
- x.assert(n < 0 || s < 0 || n === s, () => t10 + ` Shapes ${r} and ${e} must match`);
+ y.assert(n < 0 || s < 0 || n === s, () => t6 + ` Shapes ${r} and ${e} must match`);
}
}
}
-function rN(r) {
+function $N(r) {
return !(typeof r == "number" || r.some((e) => e < 0));
}
-function Xp(r, e, t10) {
- let o = dd(r, t10), n = !rN(o);
+function Gp(r, e, t6) {
+ let o = of(r, t6), n = !$N(o);
if (n && e.length === 0)
throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${o}`);
if (n && e.forEach((s) => {
- o = dd(s.shape, o);
- }), !rN(o))
+ o = of(s.shape, o);
+ }), !$N(o))
throw new Error(`Non-fully-defined elementShape: ${o}`);
return o;
}
-function dd(r, e) {
+function of(r, e) {
if (typeof r == "number")
return e;
if (typeof e == "number")
return r;
if (r.length !== e.length)
throw new Error(`Incompatible ranks during merge: ${r} vs. ${e}`);
- let t10 = [];
+ let t6 = [];
for (let o = 0; o < r.length; ++o) {
let n = r[o], s = e[o];
if (n >= 0 && s >= 0 && n !== s)
throw new Error(`Incompatible shape during merge: ${r} vs. ${e}`);
- t10[o] = n >= 0 ? n : s;
+ t6[o] = n >= 0 ? n : s;
}
- return t10;
+ return t6;
}
-var hd = class {
- constructor(e, t10, o, n, s, a, i) {
- this.name = e, this.dtype = t10, this.maxSize = o, this.elementShape = n, this.identicalElementShapes = s, this.dynamicSize = a, this.clearAfterRead = i, this.tensors = [], this.closed_ = false, this.idTensor = be(0), So(this.idTensor);
+var nf = class {
+ constructor(e, t6, o, n, s, a, i) {
+ this.name = e, this.dtype = t6, this.maxSize = o, this.elementShape = n, this.identicalElementShapes = s, this.dynamicSize = a, this.clearAfterRead = i, this.tensors = [], this.closed_ = false, this.idTensor = be(0), _r(this.idTensor);
}
get id() {
return this.idTensor.id;
@@ -9891,8 +9901,8 @@ var hd = class {
return this.closed_;
}
clearAndClose(e) {
- this.tensors.forEach((t10) => {
- (e == null || !e.has(t10.tensor.id)) && t10.tensor.dispose();
+ this.tensors.forEach((t6) => {
+ (e == null || !e.has(t6.tensor.id)) && t6.tensor.dispose();
}), this.tensors = [], this.closed_ = true, this.idTensor.dispose();
}
size() {
@@ -9903,37 +9913,37 @@ var hd = class {
throw new Error(`TensorArray ${this.name} has already been closed.`);
if (e < 0 || e >= this.size())
throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);
- let t10 = this.tensors[e];
- if (t10.cleared)
+ let t6 = this.tensors[e];
+ if (t6.cleared)
throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);
- return this.clearAfterRead && (t10.cleared = true), t10.read = true, t10.tensor;
+ return this.clearAfterRead && (t6.cleared = true), t6.read = true, t6.tensor;
}
readMany(e) {
- return e.map((t10) => this.read(t10));
+ return e.map((t6) => this.read(t6));
}
- write(e, t10) {
+ write(e, t6) {
if (this.closed_)
throw new Error(`TensorArray ${this.name} has already been closed.`);
if (e < 0 || !this.dynamicSize && e >= this.maxSize)
throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);
let o = this.tensors[e] || {};
- if (t10.dtype !== this.dtype)
+ if (t6.dtype !== this.dtype)
throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},
- because the value dtype is ${t10.dtype}, but TensorArray dtype is ${this.dtype}.`);
- if (this.size() === 0 && (this.elementShape == null || this.elementShape.length === 0) && (this.elementShape = t10.shape), Ur(this.elementShape, t10.shape, `TensorArray ${this.name}: Could not write to TensorArray index ${e}.`), o.read)
+ because the value dtype is ${t6.dtype}, but TensorArray dtype is ${this.dtype}.`);
+ if (this.size() === 0 && (this.elementShape == null || this.elementShape.length === 0) && (this.elementShape = t6.shape), zr(this.elementShape, t6.shape, `TensorArray ${this.name}: Could not write to TensorArray index ${e}.`), o.read)
throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);
if (o.written)
throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);
- o.tensor = t10, So(t10), o.written = true, this.tensors[e] = o;
+ o.tensor = t6, _r(t6), o.written = true, this.tensors[e] = o;
}
- writeMany(e, t10) {
- if (e.length !== t10.length)
- throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t10.length}.`);
- e.forEach((o, n) => this.write(o, t10[n]));
+ writeMany(e, t6) {
+ if (e.length !== t6.length)
+ throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t6.length}.`);
+ e.forEach((o, n) => this.write(o, t6[n]));
}
- gather(e, t10) {
- if (!!t10 && t10 !== this.dtype)
- throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t10}`);
+ gather(e, t6) {
+ if (!!t6 && t6 !== this.dtype)
+ throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t6}`);
if (e)
e = e.slice(0, this.size());
else {
@@ -9944,45 +9954,45 @@ var hd = class {
if (e.length === 0)
return nr([], [0].concat(this.elementShape));
let o = this.readMany(e);
- return Ur(this.elementShape, o[0].shape, "TensorArray shape mismatch: "), Ir(o, 0);
+ return zr(this.elementShape, o[0].shape, "TensorArray shape mismatch: "), Sr(o, 0);
}
concat(e) {
if (!!e && e !== this.dtype)
throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`);
if (this.size() === 0)
return nr([], [0].concat(this.elementShape));
- let t10 = [];
+ let t6 = [];
for (let n = 0; n < this.size(); n++)
- t10.push(n);
- let o = this.readMany(t10);
- return Ur(this.elementShape, o[0].shape, `TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${o[0].shape})`), gt(o, 0);
+ t6.push(n);
+ let o = this.readMany(t6);
+ return zr(this.elementShape, o[0].shape, `TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${o[0].shape})`), gt(o, 0);
}
- scatter(e, t10) {
- if (t10.dtype !== this.dtype)
- throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t10.dtype}`);
- if (e.length !== t10.shape[0])
- throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t10.shape[0]}`);
+ scatter(e, t6) {
+ if (t6.dtype !== this.dtype)
+ throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t6.dtype}`);
+ if (e.length !== t6.shape[0])
+ throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t6.shape[0]}`);
let o = Math.max(...e);
if (!this.dynamicSize && o >= this.maxSize)
throw new Error(`Max index must be < array size (${o} vs. ${this.maxSize})`);
- this.writeMany(e, ko(t10, 0));
+ this.writeMany(e, so(t6, 0));
}
- split(e, t10) {
- if (t10.dtype !== this.dtype)
- throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t10.dtype}`);
+ split(e, t6) {
+ if (t6.dtype !== this.dtype)
+ throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t6.dtype}`);
let o = 0, n = e.map((p) => (o += p, o));
- if (o !== t10.shape[0])
+ if (o !== t6.shape[0])
throw new Error(`Expected sum of lengths to be equal to
tensor.shape[0], but sum of lengths is
- ${o}, and tensor's shape is: ${t10.shape}`);
+ ${o}, and tensor's shape is: ${t6.shape}`);
if (!this.dynamicSize && e.length !== this.maxSize)
throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);
- let s = o === 0 ? 0 : t10.size / o, a = [];
- Ne(() => {
- t10 = z(t10, [1, o, s]);
+ let s = o === 0 ? 0 : t6.size / o, a = [];
+ Ee(() => {
+ t6 = z(t6, [1, o, s]);
for (let p = 0; p < e.length; ++p) {
let c = [0, p === 0 ? 0 : n[p - 1], 0], l = [1, e[p], s];
- a[p] = z(Ue(t10, c, l), this.elementShape);
+ a[p] = z(He(t6, c, l), this.elementShape);
}
return a;
});
@@ -9992,304 +10002,304 @@ var hd = class {
this.writeMany(i, a);
}
};
-var Ra = class {
- constructor(e, t10, o, n = -1) {
- this.tensors = e, this.elementShape = t10, this.elementDtype = o, e != null && e.forEach((s) => {
+var Pa = class {
+ constructor(e, t6, o, n = -1) {
+ this.tensors = e, this.elementShape = t6, this.elementDtype = o, e != null && e.forEach((s) => {
if (o !== s.dtype)
throw new Error(`Invalid data types; op elements ${o}, but list elements ${s.dtype}`);
- Ur(t10, s.shape, "TensorList shape mismatch: "), So(s);
- }), this.idTensor = be(0), this.maxNumElements = n, So(this.idTensor);
+ zr(t6, s.shape, "TensorList shape mismatch: "), _r(s);
+ }), this.idTensor = be(0), this.maxNumElements = n, _r(this.idTensor);
}
get id() {
return this.idTensor.id;
}
copy() {
- return new Ra([...this.tensors], this.elementShape, this.elementDtype);
+ return new Pa([...this.tensors], this.elementShape, this.elementDtype);
}
clearAndClose(e) {
- this.tensors.forEach((t10) => {
- (e == null || !e.has(t10.id)) && t10.dispose();
+ this.tensors.forEach((t6) => {
+ (e == null || !e.has(t6.id)) && t6.dispose();
}), this.tensors.length = 0, this.idTensor.dispose();
}
size() {
return this.tensors.length;
}
- stack(e, t10, o = -1) {
- if (t10 !== this.elementDtype)
- throw new Error(`Invalid data types; op elements ${t10}, but list elements ${this.elementDtype}`);
+ stack(e, t6, o = -1) {
+ if (t6 !== this.elementDtype)
+ throw new Error(`Invalid data types; op elements ${t6}, but list elements ${this.elementDtype}`);
if (o !== -1 && this.tensors.length !== o)
throw new Error(`Operation expected a list with ${o} elements but got a list with ${this.tensors.length} elements.`);
- Ur(e, this.elementShape, "TensorList shape mismatch: ");
- let n = Xp(this.elementShape, this.tensors, e);
- return Ne(() => {
+ zr(e, this.elementShape, "TensorList shape mismatch: ");
+ let n = Gp(this.elementShape, this.tensors, e);
+ return Ee(() => {
let s = this.tensors.map((a) => z(a, n));
- return Ir(s, 0);
+ return Sr(s, 0);
});
}
- popBack(e, t10) {
- if (t10 !== this.elementDtype)
- throw new Error(`Invalid data types; op elements ${t10}, but list elements ${this.elementDtype}`);
+ popBack(e, t6) {
+ if (t6 !== this.elementDtype)
+ throw new Error(`Invalid data types; op elements ${t6}, but list elements ${this.elementDtype}`);
if (this.size() === 0)
throw new Error("Trying to pop from an empty list.");
- let o = Xp(this.elementShape, this.tensors, e), n = this.tensors.pop();
- return n.kept = false, Ur(n.shape, e, "TensorList shape mismatch: "), z(n, o);
+ let o = Gp(this.elementShape, this.tensors, e), n = this.tensors.pop();
+ return n.kept = false, zr(n.shape, e, "TensorList shape mismatch: "), z(n, o);
}
pushBack(e) {
if (e.dtype !== this.elementDtype)
throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);
- if (Ur(e.shape, this.elementShape, "TensorList shape mismatch: "), this.maxNumElements === this.size())
+ if (zr(e.shape, this.elementShape, "TensorList shape mismatch: "), this.maxNumElements === this.size())
throw new Error("Trying to push element into a full list.");
- So(e), this.tensors.push(e);
+ _r(e), this.tensors.push(e);
}
resize(e) {
if (e < 0)
throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);
if (this.maxNumElements !== -1 && e > this.maxNumElements)
throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);
- let t10 = new Ra([], this.elementShape, this.elementDtype, this.maxNumElements);
- t10.tensors.length = e;
+ let t6 = new Pa([], this.elementShape, this.elementDtype, this.maxNumElements);
+ t6.tensors.length = e;
for (let o = 0; o < Math.min(this.tensors.length, e); ++o)
- t10.tensors[o] = this.tensors[o];
- return t10;
+ t6.tensors[o] = this.tensors[o];
+ return t6;
}
- getItem(e, t10, o) {
+ getItem(e, t6, o) {
if (o !== this.elementDtype)
throw new Error(`Invalid data types; op elements ${o}, but list elements ${this.elementDtype}`);
if (e < 0 || e > this.tensors.length)
throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);
if (this.tensors[e] == null)
throw new Error(`element at index ${e} is null.`);
- Ur(this.tensors[e].shape, t10, "TensorList shape mismatch: ");
- let n = Xp(this.elementShape, this.tensors, t10);
+ zr(this.tensors[e].shape, t6, "TensorList shape mismatch: ");
+ let n = Gp(this.elementShape, this.tensors, t6);
return z(this.tensors[e], n);
}
- setItem(e, t10) {
- if (t10.dtype !== this.elementDtype)
- throw new Error(`Invalid data types; op elements ${t10.dtype}, but list elements ${this.elementDtype}`);
+ setItem(e, t6) {
+ if (t6.dtype !== this.elementDtype)
+ throw new Error(`Invalid data types; op elements ${t6.dtype}, but list elements ${this.elementDtype}`);
if (e < 0 || this.maxNumElements !== -1 && e >= this.maxNumElements)
throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);
- Ur(this.elementShape, t10.shape, "TensorList shape mismatch: "), So(t10), this.tensors[e] != null && (this.tensors[e].kept = false), this.tensors[e] = t10;
+ zr(this.elementShape, t6.shape, "TensorList shape mismatch: "), _r(t6), this.tensors[e] != null && (this.tensors[e].kept = false), this.tensors[e] = t6;
}
- gather(e, t10, o) {
- if (t10 !== this.elementDtype)
- throw new Error(`Invalid data types; op elements ${t10}, but list elements ${this.elementDtype}`);
- Ur(this.elementShape, o, "TensorList shape mismatch: "), e = e.slice(0, this.size());
- let n = Xp(this.elementShape, this.tensors, o);
- return e.length === 0 ? nr([], [0].concat(n)) : Ne(() => {
+ gather(e, t6, o) {
+ if (t6 !== this.elementDtype)
+ throw new Error(`Invalid data types; op elements ${t6}, but list elements ${this.elementDtype}`);
+ zr(this.elementShape, o, "TensorList shape mismatch: "), e = e.slice(0, this.size());
+ let n = Gp(this.elementShape, this.tensors, o);
+ return e.length === 0 ? nr([], [0].concat(n)) : Ee(() => {
let s = e.map((a) => z(this.tensors[a], n));
- return Ir(s, 0);
+ return Sr(s, 0);
});
}
- concat(e, t10) {
+ concat(e, t6) {
if (!!e && e !== this.elementDtype)
throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);
- Ur(this.elementShape, t10, "TensorList shape mismatch: ");
- let o = Xp(this.elementShape, this.tensors, t10);
- return this.size() === 0 ? nr([], [0].concat(o)) : Ne(() => {
+ zr(this.elementShape, t6, "TensorList shape mismatch: ");
+ let o = Gp(this.elementShape, this.tensors, t6);
+ return this.size() === 0 ? nr([], [0].concat(o)) : Ee(() => {
let n = this.tensors.map((s) => z(s, o));
return gt(n, 0);
});
}
};
-function oN(r, e, t10) {
+function AN(r, e, t6) {
let o = r.dtype;
if (r.shape.length < 1)
throw new Error(`Tensor must be at least a vector, but saw shape: ${r.shape}`);
- if (r.dtype !== t10)
- throw new Error(`Invalid data types; op elements ${r.dtype}, but list elements ${t10}`);
+ if (r.dtype !== t6)
+ throw new Error(`Invalid data types; op elements ${r.dtype}, but list elements ${t6}`);
let n = r.shape.slice(1);
- Ur(n, e, "TensorList shape mismatch: ");
- let s = ko(r);
- return new Ra(s, e, o);
+ zr(n, e, "TensorList shape mismatch: ");
+ let s = so(r);
+ return new Pa(s, e, o);
}
-function nN(r, e, t10, o) {
- return new Ra([], r, e, o);
+function RN(r, e, t6, o) {
+ return new Pa([], r, e, o);
}
-function sN(r, e, t10, o) {
+function FN(r, e, t6, o) {
if (e.length !== r.shape[0])
throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${r.shape[0]}`);
let n = Math.max(...e);
if (o != null && o !== -1 && n >= o)
throw new Error(`Max index must be < array size (${n} vs. ${o})`);
- let s = new Ra([], t10, r.dtype, o), a = ko(r, 0);
+ let s = new Pa([], t6, r.dtype, o), a = so(r, 0);
return e.forEach((i, p) => {
s.setItem(i, a[p]);
}), s;
}
-function aN(r, e, t10) {
+function DN(r, e, t6) {
let o = 0, n = e.map((c) => (o += c, o));
if (o !== r.shape[0])
throw new Error(`Expected sum of lengths to be equal to
tensor.shape[0], but sum of lengths is
${o}, and tensor's shape is: ${r.shape}`);
- let s = r.shape.slice(1), a = dd(s, t10), i = o === 0 ? 0 : r.size / o, p = Ne(() => {
+ let s = r.shape.slice(1), a = of(s, t6), i = o === 0 ? 0 : r.size / o, p = Ee(() => {
let c = [];
r = z(r, [1, o, i]);
for (let l = 0; l < e.length; ++l) {
- let f = [0, l === 0 ? 0 : n[l - 1], 0], d = [1, e[l], i];
- c[l] = z(Ue(r, f, d), a);
+ let d = [0, l === 0 ? 0 : n[l - 1], 0], f = [1, e[l], i];
+ c[l] = z(He(r, d, f), a);
}
return r.dispose(), c;
- }), u = new Ra([], t10, r.dtype, e.length);
+ }), u = new Pa([], t6, r.dtype, e.length);
for (let c = 0; c < p.length; c++)
u.setItem(c, p[c]);
return u;
}
-var iN = async (r, e, t10) => {
+var ON = async (r, e, t6) => {
switch (r.op) {
case "If":
case "StatelessIf": {
- let o = S("thenBranch", r, e, t10), n = S("elseBranch", r, e, t10), s = S("cond", r, e, t10), a = S("args", r, e, t10);
- return (await s.data())[0] ? t10.functionMap[o].executeFunctionAsync(a, t10.tensorArrayMap, t10.tensorListMap) : t10.functionMap[n].executeFunctionAsync(a, t10.tensorArrayMap, t10.tensorListMap);
+ let o = I("thenBranch", r, e, t6), n = I("elseBranch", r, e, t6), s = I("cond", r, e, t6), a = I("args", r, e, t6);
+ return (await s.data())[0] ? t6.functionMap[o].executeFunctionAsync(a, t6.tensorArrayMap, t6.tensorListMap) : t6.functionMap[n].executeFunctionAsync(a, t6.tensorArrayMap, t6.tensorListMap);
}
case "While":
case "StatelessWhile": {
- let o = S("body", r, e, t10), n = S("cond", r, e, t10), s = S("args", r, e, t10), a = await t10.functionMap[n].executeFunctionAsync(s, t10.tensorArrayMap, t10.tensorListMap), i = s.map((c) => c.id), p = await a[0].data();
+ let o = I("body", r, e, t6), n = I("cond", r, e, t6), s = I("args", r, e, t6), a = await t6.functionMap[n].executeFunctionAsync(s, t6.tensorArrayMap, t6.tensorListMap), i = s.map((c) => c.id), p = await a[0].data();
a.forEach((c) => {
!c.kept && i.indexOf(c.id) === -1 && c.dispose();
});
let u = s;
for (; p[0]; ) {
let c = u;
- u = await t10.functionMap[o].executeFunctionAsync(u, t10.tensorArrayMap, t10.tensorListMap);
- let l = u.map((f) => f.id);
- c.forEach((f) => {
- !f.kept && i.indexOf(f.id) === -1 && l.indexOf(f.id) === -1 && f.dispose();
+ u = await t6.functionMap[o].executeFunctionAsync(u, t6.tensorArrayMap, t6.tensorListMap);
+ let l = u.map((d) => d.id);
+ c.forEach((d) => {
+ !d.kept && i.indexOf(d.id) === -1 && l.indexOf(d.id) === -1 && d.dispose();
});
- let m = await t10.functionMap[n].executeFunctionAsync(u, t10.tensorArrayMap, t10.tensorListMap);
- p = await m[0].data(), m.forEach((f) => {
- !f.kept && i.indexOf(f.id) === -1 && l.indexOf(f.id) === -1 && f.dispose();
+ let m = await t6.functionMap[n].executeFunctionAsync(u, t6.tensorArrayMap, t6.tensorListMap);
+ p = await m[0].data(), m.forEach((d) => {
+ !d.kept && i.indexOf(d.id) === -1 && l.indexOf(d.id) === -1 && d.dispose();
});
}
return u;
}
case "LoopCond": {
- let o = S("pred", r, e, t10);
- return [ss(o)];
+ let o = I("pred", r, e, t6);
+ return [as(o)];
}
case "Switch": {
- let o = S("pred", r, e, t10), n = S("data", r, e, t10);
- return n.kept || (n = ss(n)), (await o.data())[0] ? [void 0, n] : [n, void 0];
+ let o = I("pred", r, e, t6), n = I("data", r, e, t6);
+ return n.kept || (n = as(n)), (await o.data())[0] ? [void 0, n] : [n, void 0];
}
case "Merge": {
- let o = r.inputNames.find((n) => Ht(n, e, t10) !== void 0);
+ let o = r.inputNames.find((n) => Gt(n, e, t6) !== void 0);
if (o) {
- let n = Ht(o, e, t10);
- return [ss(n)];
+ let n = Gt(o, e, t6);
+ return [as(n)];
}
return;
}
case "Enter": {
- let o = S("frameName", r, e, t10), n = S("tensor", r, e, t10);
- return t10.enterFrame(o), [ss(n)];
+ let o = I("frameName", r, e, t6), n = I("tensor", r, e, t6);
+ return t6.enterFrame(o), [as(n)];
}
case "Exit": {
- let o = S("tensor", r, e, t10);
- return t10.exitFrame(), [ss(o)];
+ let o = I("tensor", r, e, t6);
+ return t6.exitFrame(), [as(o)];
}
case "NextIteration": {
- let o = S("tensor", r, e, t10);
- return t10.nextIteration(), [ss(o)];
+ let o = I("tensor", r, e, t6);
+ return t6.nextIteration(), [as(o)];
}
case "TensorArrayV3": {
- let o = S("size", r, e, t10), n = S("dtype", r, e, t10), s = S("elementShape", r, e, t10), a = S("dynamicSize", r, e, t10), i = S("clearAfterRead", r, e, t10), p = S("identicalElementShapes", r, e, t10), u = S("name", r, e, t10), c = new hd(u, n, o, s, p, a, i);
- return t10.addTensorArray(c), [c.idTensor, be(1)];
+ let o = I("size", r, e, t6), n = I("dtype", r, e, t6), s = I("elementShape", r, e, t6), a = I("dynamicSize", r, e, t6), i = I("clearAfterRead", r, e, t6), p = I("identicalElementShapes", r, e, t6), u = I("name", r, e, t6), c = new nf(u, n, o, s, p, a, i);
+ return t6.addTensorArray(c), [c.idTensor, be(1)];
}
case "TensorArrayWriteV3": {
- let o = S("tensorArrayId", r, e, t10), n = S("index", r, e, t10), s = S("tensor", r, e, t10), a = t10.getTensorArray(o.id);
+ let o = I("tensorArrayId", r, e, t6), n = I("index", r, e, t6), s = I("tensor", r, e, t6), a = t6.getTensorArray(o.id);
return a.write(n, s), [a.idTensor];
}
case "TensorArrayReadV3": {
- let o = S("tensorArrayId", r, e, t10), n = S("index", r, e, t10);
- return [t10.getTensorArray(o.id).read(n)];
+ let o = I("tensorArrayId", r, e, t6), n = I("index", r, e, t6);
+ return [t6.getTensorArray(o.id).read(n)];
}
case "TensorArrayGatherV3": {
- let o = S("tensorArrayId", r, e, t10), n = S("indices", r, e, t10), s = S("dtype", r, e, t10);
- return [t10.getTensorArray(o.id).gather(n, s)];
+ let o = I("tensorArrayId", r, e, t6), n = I("indices", r, e, t6), s = I("dtype", r, e, t6);
+ return [t6.getTensorArray(o.id).gather(n, s)];
}
case "TensorArrayScatterV3": {
- let o = S("tensorArrayId", r, e, t10), n = S("indices", r, e, t10), s = S("tensor", r, e, t10), a = t10.getTensorArray(o.id);
+ let o = I("tensorArrayId", r, e, t6), n = I("indices", r, e, t6), s = I("tensor", r, e, t6), a = t6.getTensorArray(o.id);
return a.scatter(n, s), [a.idTensor];
}
case "TensorArrayConcatV3": {
- let o = S("tensorArrayId", r, e, t10), n = t10.getTensorArray(o.id), s = S("dtype", r, e, t10);
+ let o = I("tensorArrayId", r, e, t6), n = t6.getTensorArray(o.id), s = I("dtype", r, e, t6);
return [n.concat(s)];
}
case "TensorArraySplitV3": {
- let o = S("tensorArrayId", r, e, t10), n = S("tensor", r, e, t10), s = S("lengths", r, e, t10), a = t10.getTensorArray(o.id);
+ let o = I("tensorArrayId", r, e, t6), n = I("tensor", r, e, t6), s = I("lengths", r, e, t6), a = t6.getTensorArray(o.id);
return a.split(s, n), [a.idTensor];
}
case "TensorArraySizeV3": {
- let o = S("tensorArrayId", r, e, t10), n = t10.getTensorArray(o.id);
+ let o = I("tensorArrayId", r, e, t6), n = t6.getTensorArray(o.id);
return [be(n.size(), "int32")];
}
case "TensorArrayCloseV3": {
- let o = S("tensorArrayId", r, e, t10), n = t10.getTensorArray(o.id);
+ let o = I("tensorArrayId", r, e, t6), n = t6.getTensorArray(o.id);
return n.clearAndClose(), [n.idTensor];
}
case "TensorListSetItem": {
- let o = S("tensorListId", r, e, t10), n = S("index", r, e, t10), s = S("tensor", r, e, t10), a = t10.getTensorList(o.id);
+ let o = I("tensorListId", r, e, t6), n = I("index", r, e, t6), s = I("tensor", r, e, t6), a = t6.getTensorList(o.id);
return a.setItem(n, s), [a.idTensor];
}
case "TensorListGetItem": {
- let o = S("tensorListId", r, e, t10), n = S("index", r, e, t10), s = S("elementShape", r, e, t10), a = S("elementDType", r, e, t10);
- return [t10.getTensorList(o.id).getItem(n, s, a)];
+ let o = I("tensorListId", r, e, t6), n = I("index", r, e, t6), s = I("elementShape", r, e, t6), a = I("elementDType", r, e, t6);
+ return [t6.getTensorList(o.id).getItem(n, s, a)];
}
case "TensorListScatterV2":
case "TensorListScatter": {
- let o = S("indices", r, e, t10), n = S("tensor", r, e, t10), s = S("elementShape", r, e, t10), a = S("numElements", r, e, t10), i = sN(n, o, s, a);
- return t10.addTensorList(i), [i.idTensor];
+ let o = I("indices", r, e, t6), n = I("tensor", r, e, t6), s = I("elementShape", r, e, t6), a = I("numElements", r, e, t6), i = FN(n, o, s, a);
+ return t6.addTensorList(i), [i.idTensor];
}
case "TensorListReserve":
case "EmptyTensorList": {
- let o = S("elementShape", r, e, t10), n = S("elementDType", r, e, t10), s;
+ let o = I("elementShape", r, e, t6), n = I("elementDType", r, e, t6), s;
r.op === "TensorListReserve" ? s = "numElements" : s = "maxNumElements";
- let a = S(s, r, e, t10), i = r.op === "TensorListReserve" ? -1 : a, p = nN(o, n, a, i);
- return t10.addTensorList(p), [p.idTensor];
+ let a = I(s, r, e, t6), i = r.op === "TensorListReserve" ? -1 : a, p = RN(o, n, a, i);
+ return t6.addTensorList(p), [p.idTensor];
}
case "TensorListGather": {
- let o = S("tensorListId", r, e, t10), n = S("indices", r, e, t10), s = S("elementShape", r, e, t10), a = S("elementDType", r, e, t10);
- return [t10.getTensorList(o.id).gather(n, a, s)];
+ let o = I("tensorListId", r, e, t6), n = I("indices", r, e, t6), s = I("elementShape", r, e, t6), a = I("elementDType", r, e, t6);
+ return [t6.getTensorList(o.id).gather(n, a, s)];
}
case "TensorListStack": {
- let o = S("tensorListId", r, e, t10), n = S("elementShape", r, e, t10), s = S("elementDType", r, e, t10), a = S("numElements", r, e, t10);
- return [t10.getTensorList(o.id).stack(n, s, a)];
+ let o = I("tensorListId", r, e, t6), n = I("elementShape", r, e, t6), s = I("elementDType", r, e, t6), a = I("numElements", r, e, t6);
+ return [t6.getTensorList(o.id).stack(n, s, a)];
}
case "TensorListFromTensor": {
- let o = S("tensor", r, e, t10), n = S("elementShape", r, e, t10), s = S("elementDType", r, e, t10), a = oN(o, n, s);
- return t10.addTensorList(a), [a.idTensor];
+ let o = I("tensor", r, e, t6), n = I("elementShape", r, e, t6), s = I("elementDType", r, e, t6), a = AN(o, n, s);
+ return t6.addTensorList(a), [a.idTensor];
}
case "TensorListConcat":
case "TensorListConcatV2": {
- let o = S("tensorListId", r, e, t10), n = t10.getTensorList(o.id), s = S("dtype", r, e, t10), a = S("elementShape", r, e, t10);
+ let o = I("tensorListId", r, e, t6), n = t6.getTensorList(o.id), s = I("dtype", r, e, t6), a = I("elementShape", r, e, t6);
return [n.concat(s, a)];
}
case "TensorListPushBack": {
- let o = S("tensorListId", r, e, t10), n = S("tensor", r, e, t10), s = t10.getTensorList(o.id);
+ let o = I("tensorListId", r, e, t6), n = I("tensor", r, e, t6), s = t6.getTensorList(o.id);
return s.pushBack(n), [s.idTensor];
}
case "TensorListPopBack": {
- let o = S("tensorListId", r, e, t10), n = S("elementShape", r, e, t10), s = S("elementDType", r, e, t10);
- return [t10.getTensorList(o.id).popBack(n, s)];
+ let o = I("tensorListId", r, e, t6), n = I("elementShape", r, e, t6), s = I("elementDType", r, e, t6);
+ return [t6.getTensorList(o.id).popBack(n, s)];
}
case "TensorListSplit": {
- let o = S("tensor", r, e, t10), n = S("elementShape", r, e, t10), s = S("lengths", r, e, t10), a = aN(o, s, n);
- return t10.addTensorList(a), [a.idTensor];
+ let o = I("tensor", r, e, t6), n = I("elementShape", r, e, t6), s = I("lengths", r, e, t6), a = DN(o, s, n);
+ return t6.addTensorList(a), [a.idTensor];
}
case "TensorListLength": {
- let o = S("tensorListId", r, e, t10), n = t10.getTensorList(o.id);
+ let o = I("tensorListId", r, e, t6), n = t6.getTensorList(o.id);
return [be(n.size(), "int32")];
}
case "TensorListResize": {
- let o = S("tensorListId", r, e, t10), n = S("size", r, e, t10), a = t10.getTensorList(o.id).resize(n);
- return t10.addTensorList(a), [a.idTensor];
+ let o = I("tensorListId", r, e, t6), n = I("size", r, e, t6), a = t6.getTensorList(o.id).resize(n);
+ return t6.addTensorList(a), [a.idTensor];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-function uN(r, e, t10) {
- let [o, n] = S("fusedOps", r, e, t10), s = o === "biasadd", a = !s, i = n === "prelu", p = o === "fusedbatchnorm", u = S("numArgs", r, e, t10);
+function PN(r, e, t6) {
+ let [o, n] = I("fusedOps", r, e, t6), s = o === "biasadd", a = !s, i = n === "prelu", p = o === "fusedbatchnorm", u = I("numArgs", r, e, t6);
if (s) {
if (i && u !== 2)
throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");
@@ -10298,200 +10308,200 @@ function uN(r, e, t10) {
}
if (p)
throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");
- let c = S("strides", r, e, t10), l = gl(r, e, t10), m = S("dataFormat", r, e, t10).toUpperCase(), f = S("dilations", r, e, t10), [d, h] = S("args", r, e, t10);
- a && (h = d, d = void 0);
- let g = S("leakyreluAlpha", r, e, t10);
- return { stride: c, pad: l, dataFormat: m, dilations: f, biasArg: d, preluArg: h, activationFunc: n, leakyreluAlpha: g };
+ let c = I("strides", r, e, t6), l = ul(r, e, t6), m = I("dataFormat", r, e, t6).toUpperCase(), d = I("dilations", r, e, t6), [f, h] = I("args", r, e, t6);
+ a && (h = f, f = void 0);
+ let g = I("leakyreluAlpha", r, e, t6);
+ return { stride: c, pad: l, dataFormat: m, dilations: d, biasArg: f, preluArg: h, activationFunc: n, leakyreluAlpha: g };
}
-var pN = (r, e, t10, o = rt) => {
+var MN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "Conv1D": {
- let n = S("stride", r, e, t10), s = S("pad", r, e, t10), a = S("dataFormat", r, e, t10).toUpperCase(), i = S("dilation", r, e, t10);
- return [o.conv1d(S("x", r, e, t10), S("filter", r, e, t10), n, s, a, i)];
+ let n = I("stride", r, e, t6), s = I("pad", r, e, t6), a = I("dataFormat", r, e, t6).toUpperCase(), i = I("dilation", r, e, t6);
+ return [o.conv1d(I("x", r, e, t6), I("filter", r, e, t6), n, s, a, i)];
}
case "Conv2D": {
- let n = S("strides", r, e, t10), s = gl(r, e, t10), a = S("dataFormat", r, e, t10).toUpperCase(), i = S("dilations", r, e, t10);
- return [o.conv2d(S("x", r, e, t10), S("filter", r, e, t10), [n[1], n[2]], s, a, [i[1], i[2]])];
+ let n = I("strides", r, e, t6), s = ul(r, e, t6), a = I("dataFormat", r, e, t6).toUpperCase(), i = I("dilations", r, e, t6);
+ return [o.conv2d(I("x", r, e, t6), I("filter", r, e, t6), [n[1], n[2]], s, a, [i[1], i[2]])];
}
case "_FusedConv2D": {
- let { stride: n, pad: s, dataFormat: a, dilations: i, biasArg: p, preluArg: u, activationFunc: c, leakyreluAlpha: l } = uN(r, e, t10);
- return [o.fused.conv2d({ x: S("x", r, e, t10), filter: S("filter", r, e, t10), strides: [n[1], n[2]], pad: s, dataFormat: a, dilations: [i[1], i[2]], bias: p, activation: c, preluActivationWeights: u, leakyreluAlpha: l })];
+ let { stride: n, pad: s, dataFormat: a, dilations: i, biasArg: p, preluArg: u, activationFunc: c, leakyreluAlpha: l } = PN(r, e, t6);
+ return [o.fused.conv2d({ x: I("x", r, e, t6), filter: I("filter", r, e, t6), strides: [n[1], n[2]], pad: s, dataFormat: a, dilations: [i[1], i[2]], bias: p, activation: c, preluActivationWeights: u, leakyreluAlpha: l })];
}
case "FusedDepthwiseConv2dNative": {
- let { stride: n, pad: s, dataFormat: a, dilations: i, biasArg: p, preluArg: u, activationFunc: c, leakyreluAlpha: l } = uN(r, e, t10);
- return [o.fused.depthwiseConv2d({ x: S("x", r, e, t10), filter: S("filter", r, e, t10), strides: [n[1], n[2]], pad: s, dataFormat: a, dilations: [i[1], i[2]], bias: p, activation: c, preluActivationWeights: u, leakyreluAlpha: l })];
+ let { stride: n, pad: s, dataFormat: a, dilations: i, biasArg: p, preluArg: u, activationFunc: c, leakyreluAlpha: l } = PN(r, e, t6);
+ return [o.fused.depthwiseConv2d({ x: I("x", r, e, t6), filter: I("filter", r, e, t6), strides: [n[1], n[2]], pad: s, dataFormat: a, dilations: [i[1], i[2]], bias: p, activation: c, preluActivationWeights: u, leakyreluAlpha: l })];
}
case "Conv2DBackpropInput":
case "Conv2dTranspose": {
- let n = S("outputShape", r, e, t10), s = S("strides", r, e, t10), a = gl(r, e, t10);
- return [o.conv2dTranspose(S("x", r, e, t10), S("filter", r, e, t10), n, [s[1], s[2]], a)];
+ let n = I("outputShape", r, e, t6), s = I("strides", r, e, t6), a = ul(r, e, t6);
+ return [o.conv2dTranspose(I("x", r, e, t6), I("filter", r, e, t6), n, [s[1], s[2]], a)];
}
case "DepthwiseConv2dNative":
case "DepthwiseConv2d": {
- let n = S("strides", r, e, t10), s = gl(r, e, t10), a = S("dilations", r, e, t10), i = S("dataFormat", r, e, t10).toUpperCase();
- return [o.depthwiseConv2d(S("input", r, e, t10), S("filter", r, e, t10), [n[1], n[2]], s, i, [a[1], a[2]])];
+ let n = I("strides", r, e, t6), s = ul(r, e, t6), a = I("dilations", r, e, t6), i = I("dataFormat", r, e, t6).toUpperCase();
+ return [o.depthwiseConv2d(I("input", r, e, t6), I("filter", r, e, t6), [n[1], n[2]], s, i, [a[1], a[2]])];
}
case "Conv3D": {
- let n = S("strides", r, e, t10), s = S("pad", r, e, t10), a = S("dataFormat", r, e, t10).toUpperCase(), i = S("dilations", r, e, t10);
- return [o.conv3d(S("x", r, e, t10), S("filter", r, e, t10), [n[1], n[2], n[3]], s, a, [i[1], i[2], i[3]])];
+ let n = I("strides", r, e, t6), s = I("pad", r, e, t6), a = I("dataFormat", r, e, t6).toUpperCase(), i = I("dilations", r, e, t6);
+ return [o.conv3d(I("x", r, e, t6), I("filter", r, e, t6), [n[1], n[2], n[3]], s, a, [i[1], i[2], i[3]])];
}
case "AvgPool": {
- let n = S("strides", r, e, t10), s = S("pad", r, e, t10), a = S("kernelSize", r, e, t10);
- return [o.avgPool(S("x", r, e, t10), [a[1], a[2]], [n[1], n[2]], s)];
+ let n = I("strides", r, e, t6), s = I("pad", r, e, t6), a = I("kernelSize", r, e, t6);
+ return [o.avgPool(I("x", r, e, t6), [a[1], a[2]], [n[1], n[2]], s)];
}
case "MaxPool": {
- let n = S("strides", r, e, t10), s = S("pad", r, e, t10), a = S("kernelSize", r, e, t10);
- return [o.maxPool(S("x", r, e, t10), [a[1], a[2]], [n[1], n[2]], s)];
+ let n = I("strides", r, e, t6), s = I("pad", r, e, t6), a = I("kernelSize", r, e, t6);
+ return [o.maxPool(I("x", r, e, t6), [a[1], a[2]], [n[1], n[2]], s)];
}
case "MaxPoolWithArgmax": {
- let n = S("strides", r, e, t10), s = S("pad", r, e, t10), a = S("kernelSize", r, e, t10), i = S("includeBatchInIndex", r, e, t10), { result: p, indexes: u } = o.maxPoolWithArgmax(S("x", r, e, t10), [a[1], a[2]], [n[1], n[2]], s, i);
+ let n = I("strides", r, e, t6), s = I("pad", r, e, t6), a = I("kernelSize", r, e, t6), i = I("includeBatchInIndex", r, e, t6), { result: p, indexes: u } = o.maxPoolWithArgmax(I("x", r, e, t6), [a[1], a[2]], [n[1], n[2]], s, i);
return [p, u];
}
case "AvgPool3D": {
- let n = S("strides", r, e, t10), s = S("pad", r, e, t10), a = S("kernelSize", r, e, t10);
- return [o.avgPool3d(S("x", r, e, t10), [a[1], a[2], a[3]], [n[1], n[2], n[3]], s)];
+ let n = I("strides", r, e, t6), s = I("pad", r, e, t6), a = I("kernelSize", r, e, t6);
+ return [o.avgPool3d(I("x", r, e, t6), [a[1], a[2], a[3]], [n[1], n[2], n[3]], s)];
}
case "MaxPool3D": {
- let n = S("strides", r, e, t10), s = S("pad", r, e, t10), a = S("kernelSize", r, e, t10);
- return [o.maxPool3d(S("x", r, e, t10), [a[1], a[2], a[3]], [n[1], n[2], n[3]], s)];
+ let n = I("strides", r, e, t6), s = I("pad", r, e, t6), a = I("kernelSize", r, e, t6);
+ return [o.maxPool3d(I("x", r, e, t6), [a[1], a[2], a[3]], [n[1], n[2], n[3]], s)];
}
case "Dilation2D": {
- let n = S("strides", r, e, t10), s = S("pad", r, e, t10), a = S("dilations", r, e, t10), i = n[1], p = n[2], u = a[1], c = a[2];
- return [o.dilation2d(S("x", r, e, t10), S("filter", r, e, t10), [i, p], s, [u, c], "NHWC")];
+ let n = I("strides", r, e, t6), s = I("pad", r, e, t6), a = I("dilations", r, e, t6), i = n[1], p = n[2], u = a[1], c = a[2];
+ return [o.dilation2d(I("x", r, e, t6), I("filter", r, e, t6), [i, p], s, [u, c], "NHWC")];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var cN = (r, e, t10, o = rt) => {
+var LN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "Fill": {
- let n = S("shape", r, e, t10), s = S("dtype", r, e, t10), a = S("value", r, e, t10);
+ let n = I("shape", r, e, t6), s = I("dtype", r, e, t6), a = I("value", r, e, t6);
return [o.fill(n, a, s)];
}
case "LinSpace": {
- let n = S("start", r, e, t10), s = S("stop", r, e, t10), a = S("num", r, e, t10);
+ let n = I("start", r, e, t6), s = I("stop", r, e, t6), a = I("num", r, e, t6);
return [o.linspace(n, s, a)];
}
case "Multinomial": {
- let n = S("logits", r, e, t10), s = S("numSamples", r, e, t10), a = S("seed", r, e, t10);
+ let n = I("logits", r, e, t6), s = I("numSamples", r, e, t6), a = I("seed", r, e, t6);
return [o.multinomial(n, s, a)];
}
case "OneHot": {
- let n = S("indices", r, e, t10), s = S("depth", r, e, t10), a = S("onValue", r, e, t10), i = S("offValue", r, e, t10), p = S("dtype", r, e, t10);
+ let n = I("indices", r, e, t6), s = I("depth", r, e, t6), a = I("onValue", r, e, t6), i = I("offValue", r, e, t6), p = I("dtype", r, e, t6);
return [o.oneHot(n, s, a, i, p)];
}
case "Ones":
- return [o.ones(S("shape", r, e, t10), S("dtype", r, e, t10))];
+ return [o.ones(I("shape", r, e, t6), I("dtype", r, e, t6))];
case "OnesLike":
- return [o.onesLike(S("x", r, e, t10))];
+ return [o.onesLike(I("x", r, e, t6))];
case "RandomStandardNormal":
- return [o.randomStandardNormal(S("shape", r, e, t10), S("dtype", r, e, t10), S("seed", r, e, t10))];
+ return [o.randomStandardNormal(I("shape", r, e, t6), I("dtype", r, e, t6), I("seed", r, e, t6))];
case "RandomUniform":
- return [o.randomUniform(S("shape", r, e, t10), S("minval", r, e, t10), S("maxval", r, e, t10), S("dtype", r, e, t10))];
+ return [o.randomUniform(I("shape", r, e, t6), I("minval", r, e, t6), I("maxval", r, e, t6), I("dtype", r, e, t6))];
case "Range": {
- let n = S("start", r, e, t10), s = S("stop", r, e, t10), a = S("step", r, e, t10);
- return [o.range(n, s, a, S("dtype", r, e, t10))];
+ let n = I("start", r, e, t6), s = I("stop", r, e, t6), a = I("step", r, e, t6);
+ return [o.range(n, s, a, I("dtype", r, e, t6))];
}
case "TruncatedNormal": {
- let n = S("shape", r, e, t10), s = S("mean", r, e, t10), a = S("stdDev", r, e, t10), i = S("seed", r, e, t10);
- return [o.truncatedNormal(n, s, a, S("dtype", r, e, t10), i)];
+ let n = I("shape", r, e, t6), s = I("mean", r, e, t6), a = I("stdDev", r, e, t6), i = I("seed", r, e, t6);
+ return [o.truncatedNormal(n, s, a, I("dtype", r, e, t6), i)];
}
case "Zeros":
- return [o.zeros(S("shape", r, e, t10), S("dtype", r, e, t10))];
+ return [o.zeros(I("shape", r, e, t6), I("dtype", r, e, t6))];
case "ZerosLike":
- return [o.zerosLike(S("x", r, e, t10))];
+ return [o.zerosLike(I("x", r, e, t6))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-function YC(r, e, t10) {
- let o = S("boxes", r, e, t10), n = S("scores", r, e, t10), s = S("maxOutputSize", r, e, t10), a = S("iouThreshold", r, e, t10), i = S("scoreThreshold", r, e, t10), p = S("softNmsSigma", r, e, t10);
+function HC(r, e, t6) {
+ let o = I("boxes", r, e, t6), n = I("scores", r, e, t6), s = I("maxOutputSize", r, e, t6), a = I("iouThreshold", r, e, t6), i = I("scoreThreshold", r, e, t6), p = I("softNmsSigma", r, e, t6);
return { boxes: o, scores: n, maxOutputSize: s, iouThreshold: a, scoreThreshold: i, softNmsSigma: p };
}
-var lN = async (r, e, t10, o, n = rt) => {
+var BN = async (r, e, t6, o, n = Ye) => {
switch (r.op) {
case "NonMaxSuppressionV5": {
- let { boxes: s, scores: a, maxOutputSize: i, iouThreshold: p, scoreThreshold: u, softNmsSigma: c } = YC(r, e, t10), l = await n.image.nonMaxSuppressionWithScoreAsync(s, a, i, p, u, c);
+ let { boxes: s, scores: a, maxOutputSize: i, iouThreshold: p, scoreThreshold: u, softNmsSigma: c } = HC(r, e, t6), l = await n.image.nonMaxSuppressionWithScoreAsync(s, a, i, p, u, c);
return [l.selectedIndices, l.selectedScores];
}
case "NonMaxSuppressionV4": {
- let { boxes: s, scores: a, maxOutputSize: i, iouThreshold: p, scoreThreshold: u } = YC(r, e, t10), c = S("padToMaxOutputSize", r, e, t10), l = await n.image.nonMaxSuppressionPaddedAsync(s, a, i, p, u, c);
+ let { boxes: s, scores: a, maxOutputSize: i, iouThreshold: p, scoreThreshold: u } = HC(r, e, t6), c = I("padToMaxOutputSize", r, e, t6), l = await n.image.nonMaxSuppressionPaddedAsync(s, a, i, p, u, c);
return [l.selectedIndices, l.validOutputs];
}
case "NonMaxSuppressionV3":
case "NonMaxSuppressionV2": {
- let { boxes: s, scores: a, maxOutputSize: i, iouThreshold: p, scoreThreshold: u } = YC(r, e, t10);
+ let { boxes: s, scores: a, maxOutputSize: i, iouThreshold: p, scoreThreshold: u } = HC(r, e, t6);
return [await n.image.nonMaxSuppressionAsync(s, a, i, p, u)];
}
case "Where": {
- let s = n.cast(S("condition", r, e, t10), "bool"), a = [await n.whereAsync(s)];
+ let s = n.cast(I("condition", r, e, t6), "bool"), a = [await n.whereAsync(s)];
return s.dispose(), a;
}
case "ListDiff":
- return n.setdiff1dAsync(S("x", r, e, t10), S("y", r, e, t10));
+ return n.setdiff1dAsync(I("x", r, e, t6), I("y", r, e, t6));
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var mN = (r, e, t10, o = rt) => {
+var VN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "LowerBound": {
- let n = S("sortedSequence", r, e, t10), s = S("values", r, e, t10);
+ let n = I("sortedSequence", r, e, t6), s = I("values", r, e, t6);
return [o.lowerBound(n, s)];
}
case "TopKV2": {
- let n = S("x", r, e, t10), s = S("k", r, e, t10), a = S("sorted", r, e, t10), i = o.topk(n, s, a);
+ let n = I("x", r, e, t6), s = I("k", r, e, t6), a = I("sorted", r, e, t6), i = o.topk(n, s, a);
return [i.values, i.indices];
}
case "UpperBound": {
- let n = S("sortedSequence", r, e, t10), s = S("values", r, e, t10);
+ let n = I("sortedSequence", r, e, t6), s = I("values", r, e, t6);
return [o.upperBound(n, s)];
}
case "Unique": {
- let n = S("x", r, e, t10), s = o.unique(n);
+ let n = I("x", r, e, t6), s = o.unique(n);
return [s.values, s.indices];
}
case "UniqueV2": {
- let n = S("x", r, e, t10), s = S("axis", r, e, t10), a = o.unique(n, s);
+ let n = I("x", r, e, t6), s = I("axis", r, e, t6), a = o.unique(n, s);
return [a.values, a.indices];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var fN = (r, e, t10, o = rt) => {
+var zN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "Const":
return e[r.name];
case "PlaceholderWithDefault":
- let n = S("default", r, e, t10);
- return [Ht(r.name, e, t10) || n];
+ let n = I("default", r, e, t6);
+ return [Gt(r.name, e, t6) || n];
case "Placeholder":
- return [Ht(r.name, e, t10)];
+ return [Gt(r.name, e, t6)];
case "Identity":
case "StopGradient":
case "FakeQuantWithMinMaxVars": {
- let c = S("x", r, e, t10);
- return [ss(c)];
+ let c = I("x", r, e, t6);
+ return [as(c)];
}
case "IdentityN":
- return S("x", r, e, t10).map((c) => ss(c));
+ return I("x", r, e, t6).map((c) => as(c));
case "Snapshot":
- let s = S("x", r, e, t10);
- return [ss(s)];
+ let s = I("x", r, e, t6);
+ return [as(s)];
case "Shape":
- return [o.tensor1d(S("x", r, e, t10).shape, "int32")];
+ return [o.tensor1d(I("x", r, e, t6).shape, "int32")];
case "ShapeN":
- return S("x", r, e, t10).map((c) => o.tensor1d(c.shape));
+ return I("x", r, e, t6).map((c) => o.tensor1d(c.shape));
case "Size":
- return [o.scalar(S("x", r, e, t10).size, "int32")];
+ return [o.scalar(I("x", r, e, t6).size, "int32")];
case "Rank":
- return [o.scalar(S("x", r, e, t10).rank, "int32")];
+ return [o.scalar(I("x", r, e, t6).rank, "int32")];
case "NoOp":
return [o.scalar(1)];
case "Print":
- let a = S("x", r, e, t10), i = S("data", r, e, t10), p = S("message", r, e, t10), u = S("summarize", r, e, t10);
+ let a = I("x", r, e, t6), i = I("data", r, e, t6), p = I("message", r, e, t6), u = I("summarize", r, e, t6);
console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."), console.log(p);
for (let c = 0; c < i.length; c++)
console.log(Array.prototype.slice.call(i[c].dataSync()).slice(0, u));
@@ -10500,9 +10510,9 @@ var fN = (r, e, t10, o = rt) => {
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var gd = class {
- constructor(e, t10) {
- this.keyDType = e, this.valueDType = t10, this.handle = be(0), this.tensorMap = /* @__PURE__ */ new Map(), So(this.handle);
+var sf = class {
+ constructor(e, t6) {
+ this.keyDType = e, this.valueDType = t6, this.handle = be(0), this.tensorMap = /* @__PURE__ */ new Map(), _r(this.handle);
}
get id() {
return this.handle.id;
@@ -10516,43 +10526,43 @@ var gd = class {
tensorSize() {
return be(this.size(), "int32");
}
- async import(e, t10) {
- this.checkKeyAndValueTensor(e, t10);
+ async import(e, t6) {
+ this.checkKeyAndValueTensor(e, t6);
let o = await e.data();
- return this.tensorMap.forEach((n) => n.dispose()), this.tensorMap.clear(), Ne(() => {
- let n = ko(t10), s = o.length, a = n.length;
- x.assert(s === a, () => `The number of elements doesn't match, keys has ${s} elements, the values has ${a} elements.`);
+ return this.tensorMap.forEach((n) => n.dispose()), this.tensorMap.clear(), Ee(() => {
+ let n = so(t6), s = o.length, a = n.length;
+ y.assert(s === a, () => `The number of elements doesn't match, keys has ${s} elements, the values has ${a} elements.`);
for (let i = 0; i < s; i++) {
let p = o[i], u = n[i];
- So(u), this.tensorMap.set(p, u);
+ _r(u), this.tensorMap.set(p, u);
}
return this.handle;
});
}
- async find(e, t10) {
- this.checkKeyAndValueTensor(e, t10);
+ async find(e, t6) {
+ this.checkKeyAndValueTensor(e, t6);
let o = await e.data();
- return Ne(() => {
+ return Ee(() => {
let n = [];
for (let s = 0; s < o.length; s++) {
- let a = o[s], i = this.findWithDefault(a, t10);
+ let a = o[s], i = this.findWithDefault(a, t6);
n.push(i);
}
- return Ir(n);
+ return Sr(n);
});
}
- findWithDefault(e, t10) {
+ findWithDefault(e, t6) {
let o = this.tensorMap.get(e);
- return o != null ? o : t10;
+ return o != null ? o : t6;
}
- checkKeyAndValueTensor(e, t10) {
+ checkKeyAndValueTensor(e, t6) {
if (e.dtype !== this.keyDType)
throw new Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`);
- if (t10.dtype !== this.valueDType)
- throw new Error(`Expect value dtype ${this.valueDType}, but got ${t10.dtype}`);
+ if (t6.dtype !== this.valueDType)
+ throw new Error(`Expect value dtype ${this.valueDType}, but got ${t6.dtype}`);
}
};
-var dN = async (r, e, t10, o) => {
+var WN = async (r, e, t6, o) => {
switch (r.op) {
case "HashTable":
case "HashTableV2": {
@@ -10560,398 +10570,418 @@ var dN = async (r, e, t10, o) => {
if (n != null)
return [n];
{
- let s = S("keyDType", r, e, t10), a = S("valueDType", r, e, t10), i = new gd(s, a);
+ let s = I("keyDType", r, e, t6), a = I("valueDType", r, e, t6), i = new sf(s, a);
return o.addHashTable(r.name, i), [i.handle];
}
}
+ case "InitializeTable":
+ case "InitializeTableV2":
case "LookupTableImport":
case "LookupTableImportV2": {
- let n = S("tableHandle", r, e, t10, o), s = S("keys", r, e, t10), a = S("values", r, e, t10);
+ let n = I("tableHandle", r, e, t6, o), s = I("keys", r, e, t6), a = I("values", r, e, t6);
return [await o.getHashTableById(n.id).import(s, a)];
}
case "LookupTableFind":
case "LookupTableFindV2": {
- let n = S("tableHandle", r, e, t10, o), s = S("keys", r, e, t10), a = S("defaultValue", r, e, t10);
+ let n = I("tableHandle", r, e, t6, o), s = I("keys", r, e, t6), a = I("defaultValue", r, e, t6);
return [await o.getHashTableById(n.id).find(s, a)];
}
case "LookupTableSize":
case "LookupTableSizeV2": {
- let n = S("tableHandle", r, e, t10, o);
+ let n = I("tableHandle", r, e, t6, o);
return [o.getHashTableById(n.id).tensorSize()];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var hN = (r, e, t10, o = rt) => {
+var UN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "ResizeBilinear": {
- let n = S("images", r, e, t10), s = S("size", r, e, t10), a = S("alignCorners", r, e, t10), i = S("halfPixelCenters", r, e, t10);
+ let n = I("images", r, e, t6), s = I("size", r, e, t6), a = I("alignCorners", r, e, t6), i = I("halfPixelCenters", r, e, t6);
return [o.image.resizeBilinear(n, [s[0], s[1]], a, i)];
}
case "ResizeNearestNeighbor": {
- let n = S("images", r, e, t10), s = S("size", r, e, t10), a = S("alignCorners", r, e, t10), i = S("halfPixelCenters", r, e, t10);
+ let n = I("images", r, e, t6), s = I("size", r, e, t6), a = I("alignCorners", r, e, t6), i = I("halfPixelCenters", r, e, t6);
return [o.image.resizeNearestNeighbor(n, [s[0], s[1]], a, i)];
}
case "CropAndResize": {
- let n = S("image", r, e, t10), s = S("boxes", r, e, t10), a = S("boxInd", r, e, t10), i = S("cropSize", r, e, t10), p = S("method", r, e, t10), u = S("extrapolationValue", r, e, t10);
+ let n = I("image", r, e, t6), s = I("boxes", r, e, t6), a = I("boxInd", r, e, t6), i = I("cropSize", r, e, t6), p = I("method", r, e, t6), u = I("extrapolationValue", r, e, t6);
return [o.image.cropAndResize(n, s, a, i, p, u)];
}
case "ImageProjectiveTransformV3": {
- let n = S("images", r, e, t10), s = S("transforms", r, e, t10), a = S("outputShape", r, e, t10), i = S("fillValue", r, e, t10), p = S("interpolation", r, e, t10), u = S("fillMode", r, e, t10);
+ let n = I("images", r, e, t6), s = I("transforms", r, e, t6), a = I("outputShape", r, e, t6), i = I("fillValue", r, e, t6), p = I("interpolation", r, e, t6), u = I("fillMode", r, e, t6);
return [o.image.transform(n, s, p.toLowerCase(), u.toLowerCase(), i, a)];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var gN = (r, e, t10, o = rt) => {
+var GN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "Equal":
- return [o.equal(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.equal(I("a", r, e, t6), I("b", r, e, t6))];
case "NotEqual":
- return [o.notEqual(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.notEqual(I("a", r, e, t6), I("b", r, e, t6))];
case "Greater":
- return [o.greater(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.greater(I("a", r, e, t6), I("b", r, e, t6))];
case "GreaterEqual":
- return [o.greaterEqual(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.greaterEqual(I("a", r, e, t6), I("b", r, e, t6))];
case "Less":
- return [o.less(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.less(I("a", r, e, t6), I("b", r, e, t6))];
case "LessEqual":
- return [o.lessEqual(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.lessEqual(I("a", r, e, t6), I("b", r, e, t6))];
case "LogicalAnd":
- return [o.logicalAnd(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.logicalAnd(I("a", r, e, t6), I("b", r, e, t6))];
case "LogicalNot":
- return [o.logicalNot(S("a", r, e, t10))];
+ return [o.logicalNot(I("a", r, e, t6))];
case "LogicalOr":
- return [o.logicalOr(S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.logicalOr(I("a", r, e, t6), I("b", r, e, t6))];
case "Select":
case "SelectV2":
- return [o.where(S("condition", r, e, t10), S("a", r, e, t10), S("b", r, e, t10))];
+ return [o.where(I("condition", r, e, t6), I("a", r, e, t6), I("b", r, e, t6))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var xN = (r, e, t10, o = rt) => {
+var HN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "BatchMatMul":
case "BatchMatMulV2":
case "MatMul":
- return [o.matMul(S("a", r, e, t10), S("b", r, e, t10), S("transposeA", r, e, t10), S("transposeB", r, e, t10))];
+ return [o.matMul(I("a", r, e, t6), I("b", r, e, t6), I("transposeA", r, e, t6), I("transposeB", r, e, t6))];
case "Einsum":
- return [o.einsum(S("equation", r, e, t10), ...S("tensors", r, e, t10))];
+ return [o.einsum(I("equation", r, e, t6), ...I("tensors", r, e, t6))];
case "Transpose":
- return [o.transpose(S("x", r, e, t10), S("perm", r, e, t10))];
+ return [o.transpose(I("x", r, e, t6), I("perm", r, e, t6))];
case "_FusedMatMul":
- let [n, s] = S("fusedOps", r, e, t10), a = n === "biasadd", i = s === "prelu", p = S("numArgs", r, e, t10), u = S("leakyreluAlpha", r, e, t10);
+ let [n, s] = I("fusedOps", r, e, t6), a = n === "biasadd", i = s === "prelu", p = I("numArgs", r, e, t6), u = I("leakyreluAlpha", r, e, t6);
if (a) {
if (i && p !== 2)
throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");
if (!i && p !== 1)
throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.");
}
- let [c, l] = S("args", r, e, t10);
- return [o.fused.matMul({ a: S("a", r, e, t10), b: S("b", r, e, t10), transposeA: S("transposeA", r, e, t10), transposeB: S("transposeB", r, e, t10), bias: c, activation: s, preluActivationWeights: l, leakyreluAlpha: u })];
+ let [c, l] = I("args", r, e, t6);
+ return [o.fused.matMul({ a: I("a", r, e, t6), b: I("b", r, e, t6), transposeA: I("transposeA", r, e, t6), transposeB: I("transposeB", r, e, t6), bias: c, activation: s, preluActivationWeights: l, leakyreluAlpha: u })];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var yN = (r, e, t10, o = rt) => {
+var qN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "EuclideanNorm":
- return [o.euclideanNorm(S("x", r, e, t10), S("axis", r, e, t10), S("keepDims", r, e, t10))];
+ return [o.euclideanNorm(I("x", r, e, t6), I("axis", r, e, t6), I("keepDims", r, e, t6))];
case "FusedBatchNorm":
case "FusedBatchNormV2":
- return [o.batchNorm(S("x", r, e, t10), S("mean", r, e, t10), S("variance", r, e, t10), S("offset", r, e, t10), S("scale", r, e, t10), S("epsilon", r, e, t10))];
+ return [o.batchNorm(I("x", r, e, t6), I("mean", r, e, t6), I("variance", r, e, t6), I("offset", r, e, t6), I("scale", r, e, t6), I("epsilon", r, e, t6))];
case "FusedBatchNormV3":
- return [o.batchNorm(S("x", r, e, t10), S("mean", r, e, t10), S("variance", r, e, t10), S("offset", r, e, t10), S("scale", r, e, t10), S("epsilon", r, e, t10))];
+ return [o.batchNorm(I("x", r, e, t6), I("mean", r, e, t6), I("variance", r, e, t6), I("offset", r, e, t6), I("scale", r, e, t6), I("epsilon", r, e, t6))];
case "LRN":
- return [o.localResponseNormalization(S("x", r, e, t10), S("radius", r, e, t10), S("bias", r, e, t10), S("alpha", r, e, t10), S("beta", r, e, t10))];
+ return [o.localResponseNormalization(I("x", r, e, t6), I("radius", r, e, t6), I("bias", r, e, t6), I("alpha", r, e, t6), I("beta", r, e, t6))];
case "Softmax":
- return [o.softmax(S("x", r, e, t10))];
+ return [o.softmax(I("x", r, e, t6))];
case "LogSoftmax":
- return [o.logSoftmax(S("x", r, e, t10))];
+ return [o.logSoftmax(I("x", r, e, t6))];
case "SparseToDense":
- return [o.sparseToDense(S("sparseIndices", r, e, t10), S("outputShape", r, e, t10), S("sparseValues", r, e, t10), S("defaultValue", r, e, t10))];
+ return [o.sparseToDense(I("sparseIndices", r, e, t6), I("outputShape", r, e, t6), I("sparseValues", r, e, t6), I("defaultValue", r, e, t6))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var bN = (r, e, t10, o = rt) => {
+var KN = (r, e, t6, o = Ye) => {
+ switch (r.op) {
+ case "RaggedGather": {
+ let { outputNestedSplits: n, outputDenseValues: s } = o.raggedGather(I("paramsNestedSplits", r, e, t6), I("paramsDenseValues", r, e, t6), I("indices", r, e, t6), I("outputRaggedRank", r, e, t6));
+ return n.concat(s);
+ }
+ case "RaggedRange": {
+ let { rtNestedSplits: n, rtDenseValues: s } = o.raggedRange(I("starts", r, e, t6), I("limits", r, e, t6), I("splits", r, e, t6));
+ return [n, s];
+ }
+ case "RaggedTensorToTensor":
+ return [o.raggedTensorToTensor(I("shape", r, e, t6), I("values", r, e, t6), I("defaultValue", r, e, t6), I("rowPartitionTensors", r, e, t6), I("rowPartitionTypes", r, e, t6))];
+ default:
+ throw TypeError(`Node type ${r.op} is not implemented`);
+ }
+};
+var jN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "Max": {
- let i = S("axis", r, e, t10), p = S("keepDims", r, e, t10);
- return [o.max(S("x", r, e, t10), i, p)];
+ let i = I("axis", r, e, t6), p = I("keepDims", r, e, t6);
+ return [o.max(I("x", r, e, t6), i, p)];
}
case "Mean": {
- let i = S("axis", r, e, t10), p = S("keepDims", r, e, t10);
- return [o.mean(S("x", r, e, t10), i, p)];
+ let i = I("axis", r, e, t6), p = I("keepDims", r, e, t6);
+ return [o.mean(I("x", r, e, t6), i, p)];
}
case "Min": {
- let i = S("axis", r, e, t10), p = S("keepDims", r, e, t10);
- return [o.min(S("x", r, e, t10), i, p)];
+ let i = I("axis", r, e, t6), p = I("keepDims", r, e, t6);
+ return [o.min(I("x", r, e, t6), i, p)];
}
case "Sum": {
- let i = S("axis", r, e, t10), p = S("keepDims", r, e, t10);
- return [o.sum(S("x", r, e, t10), i, p)];
+ let i = I("axis", r, e, t6), p = I("keepDims", r, e, t6);
+ return [o.sum(I("x", r, e, t6), i, p)];
}
case "All": {
- let i = S("axis", r, e, t10), p = S("keepDims", r, e, t10);
- return [o.all(S("x", r, e, t10), i, p)];
+ let i = I("axis", r, e, t6), p = I("keepDims", r, e, t6);
+ return [o.all(I("x", r, e, t6), i, p)];
}
case "Any": {
- let i = S("axis", r, e, t10), p = S("keepDims", r, e, t10);
- return [o.any(S("x", r, e, t10), i, p)];
+ let i = I("axis", r, e, t6), p = I("keepDims", r, e, t6);
+ return [o.any(I("x", r, e, t6), i, p)];
}
case "ArgMax": {
- let i = S("axis", r, e, t10);
- return [o.argMax(S("x", r, e, t10), i)];
+ let i = I("axis", r, e, t6);
+ return [o.argMax(I("x", r, e, t6), i)];
}
case "ArgMin": {
- let i = S("axis", r, e, t10);
- return [o.argMin(S("x", r, e, t10), i)];
+ let i = I("axis", r, e, t6);
+ return [o.argMin(I("x", r, e, t6), i)];
}
case "Prod": {
- let i = S("axis", r, e, t10), p = S("keepDims", r, e, t10);
- return [o.prod(S("x", r, e, t10), i, p)];
+ let i = I("axis", r, e, t6), p = I("keepDims", r, e, t6);
+ return [o.prod(I("x", r, e, t6), i, p)];
}
case "Cumprod": {
- let i = S("axis", r, e, t10), p = S("exclusive", r, e, t10), u = S("reverse", r, e, t10);
- return [o.cumprod(S("x", r, e, t10), i, p, u)];
+ let i = I("axis", r, e, t6), p = I("exclusive", r, e, t6), u = I("reverse", r, e, t6);
+ return [o.cumprod(I("x", r, e, t6), i, p, u)];
}
case "Cumsum": {
- let i = S("axis", r, e, t10), p = S("exclusive", r, e, t10), u = S("reverse", r, e, t10);
- return [o.cumsum(S("x", r, e, t10), i, p, u)];
+ let i = I("axis", r, e, t6), p = I("exclusive", r, e, t6), u = I("reverse", r, e, t6);
+ return [o.cumsum(I("x", r, e, t6), i, p, u)];
}
case "Bincount":
- let n = S("x", r, e, t10), s = S("weights", r, e, t10), a = S("size", r, e, t10);
+ let n = I("x", r, e, t6), s = I("weights", r, e, t6), a = I("size", r, e, t6);
return [o.bincount(n, s, a)];
case "DenseBincount": {
- let i = S("x", r, e, t10), p = S("weights", r, e, t10), u = S("size", r, e, t10), c = S("binaryOutput", r, e, t10);
+ let i = I("x", r, e, t6), p = I("weights", r, e, t6), u = I("size", r, e, t6), c = I("binaryOutput", r, e, t6);
return [o.denseBincount(i, p, u, c)];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var CN = (r, e, t10, o = rt) => {
+var XN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "ConcatV2":
case "Concat": {
- let n = S("n", r, e, t10), s = S("axis", r, e, t10), a = S("tensors", r, e, t10);
+ let n = I("n", r, e, t6), s = I("axis", r, e, t6), a = I("tensors", r, e, t6);
return a = a.slice(0, n), [o.concat(a, s)];
}
case "Gather": {
- let n = S("x", r, e, t10), s = S("indices", r, e, t10);
+ let n = I("x", r, e, t6), s = I("indices", r, e, t6);
return [o.gather(n, o.cast(s, "int32"), 0)];
}
case "GatherV2": {
- let n = S("axis", r, e, t10), s = S("batchDims", r, e, t10), a = S("x", r, e, t10), i = S("indices", r, e, t10);
+ let n = I("axis", r, e, t6), s = I("batchDims", r, e, t6), a = I("x", r, e, t6), i = I("indices", r, e, t6);
return [o.gather(a, o.cast(i, "int32"), n, s)];
}
case "Reverse": {
- let n = S("dims", r, e, t10), s = [];
+ let n = I("dims", r, e, t6), s = [];
for (let i = 0; i < n.length; i++)
n[i] && s.push(i);
- let a = S("x", r, e, t10);
+ let a = I("x", r, e, t6);
return [o.reverse(a, s)];
}
case "ReverseV2": {
- let n = S("axis", r, e, t10), s = S("x", r, e, t10);
+ let n = I("axis", r, e, t6), s = I("x", r, e, t6);
return [o.reverse(s, n)];
}
case "Slice": {
- let n = S("begin", r, e, t10), s = S("size", r, e, t10);
- return [o.slice(S("x", r, e, t10), n, s)];
+ let n = I("begin", r, e, t6), s = I("size", r, e, t6);
+ return [o.slice(I("x", r, e, t6), n, s)];
}
case "StridedSlice": {
- let n = S("begin", r, e, t10), s = S("end", r, e, t10), a = S("strides", r, e, t10), i = S("beginMask", r, e, t10), p = S("endMask", r, e, t10), u = S("ellipsisMask", r, e, t10), c = S("newAxisMask", r, e, t10), l = S("shrinkAxisMask", r, e, t10), m = S("x", r, e, t10);
+ let n = I("begin", r, e, t6), s = I("end", r, e, t6), a = I("strides", r, e, t6), i = I("beginMask", r, e, t6), p = I("endMask", r, e, t6), u = I("ellipsisMask", r, e, t6), c = I("newAxisMask", r, e, t6), l = I("shrinkAxisMask", r, e, t6), m = I("x", r, e, t6);
return [o.stridedSlice(m, n, s, a, i, p, u, c, l)];
}
case "Pack":
- return Ne(() => {
- let n = S("axis", r, e, t10), s = S("tensors", r, e, t10), a = s[0].shape, i = o.squeeze(s[0]).shape, p = s.map((u) => {
- let c = x.arraysEqual(u.shape, a);
- if (!c && !x.arraysEqual(o.squeeze(u).shape, i))
+ return Ee(() => {
+ let n = I("axis", r, e, t6), s = I("tensors", r, e, t6), a = s[0].shape, i = o.squeeze(s[0]).shape, p = s.map((u) => {
+ let c = y.arraysEqual(u.shape, a);
+ if (!c && !y.arraysEqual(o.squeeze(u).shape, i))
throw new Error("the input tensors shape does not match");
return c ? u : o.reshape(u, a);
});
return [o.stack(p, n)];
});
case "Unpack": {
- let n = S("axis", r, e, t10), s = S("tensor", r, e, t10);
+ let n = I("axis", r, e, t6), s = I("tensor", r, e, t6);
return o.unstack(s, n);
}
case "Tile": {
- let n = S("reps", r, e, t10);
- return [o.tile(S("x", r, e, t10), n)];
+ let n = I("reps", r, e, t6);
+ return [o.tile(I("x", r, e, t6), n)];
}
case "Split":
case "SplitV": {
- let n = S("axis", r, e, t10), s = S("numOrSizeSplits", r, e, t10), a = S("x", r, e, t10);
+ let n = I("axis", r, e, t6), s = I("numOrSizeSplits", r, e, t6), a = I("x", r, e, t6);
return o.split(a, s, n);
}
case "ScatterNd": {
- let n = S("indices", r, e, t10), s = S("values", r, e, t10), a = S("shape", r, e, t10);
+ let n = I("indices", r, e, t6), s = I("values", r, e, t6), a = I("shape", r, e, t6);
return [o.scatterND(n, s, a)];
}
case "GatherNd": {
- let n = S("x", r, e, t10), s = S("indices", r, e, t10);
+ let n = I("x", r, e, t6), s = I("indices", r, e, t6);
return [o.gatherND(n, s)];
}
case "SparseToDense": {
- let n = S("sparseIndices", r, e, t10), s = S("outputShape", r, e, t10), a = S("sparseValues", r, e, t10), i = S("defaultValue", r, e, t10);
+ let n = I("sparseIndices", r, e, t6), s = I("outputShape", r, e, t6), a = I("sparseValues", r, e, t6), i = I("defaultValue", r, e, t6);
return [o.sparseToDense(n, a, s, a.dtype === i.dtype ? i : o.cast(i, a.dtype))];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var IN = (r, e, t10, o = rt) => {
+var YN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "SparseFillEmptyRows": {
- let { outputIndices: n, outputValues: s, emptyRowIndicator: a, reverseIndexMap: i } = o.sparse.sparseFillEmptyRows(S("indices", r, e, t10), S("values", r, e, t10), S("denseShape", r, e, t10), S("defaultValue", r, e, t10));
+ let { outputIndices: n, outputValues: s, emptyRowIndicator: a, reverseIndexMap: i } = o.sparse.sparseFillEmptyRows(I("indices", r, e, t6), I("values", r, e, t6), I("denseShape", r, e, t6), I("defaultValue", r, e, t6));
return [n, s, a, i];
}
case "SparseReshape": {
- let { outputIndices: n, outputShape: s } = o.sparse.sparseReshape(S("inputIndices", r, e, t10), S("inputShape", r, e, t10), S("newShape", r, e, t10));
+ let { outputIndices: n, outputShape: s } = o.sparse.sparseReshape(I("inputIndices", r, e, t6), I("inputShape", r, e, t6), I("newShape", r, e, t6));
return [n, s];
}
case "SparseSegmentMean":
- return [o.sparse.sparseSegmentMean(S("data", r, e, t10), S("indices", r, e, t10), S("segmentIds", r, e, t10))];
+ return [o.sparse.sparseSegmentMean(I("data", r, e, t6), I("indices", r, e, t6), I("segmentIds", r, e, t6))];
case "SparseSegmentSum":
- return [o.sparse.sparseSegmentSum(S("data", r, e, t10), S("indices", r, e, t10), S("segmentIds", r, e, t10))];
+ return [o.sparse.sparseSegmentSum(I("data", r, e, t6), I("indices", r, e, t6), I("segmentIds", r, e, t6))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var wN = (r, e, t10, o = rt) => {
+var QN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "FFT":
- return [o.fft(S("x", r, e, t10))];
+ return [o.fft(I("x", r, e, t6))];
case "IFFT":
- return [o.ifft(S("x", r, e, t10))];
+ return [o.ifft(I("x", r, e, t6))];
case "RFFT":
- return [o.rfft(S("x", r, e, t10))];
+ return [o.rfft(I("x", r, e, t6))];
case "IRFFT":
- return [o.irfft(S("x", r, e, t10))];
+ return [o.irfft(I("x", r, e, t6))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var SN = (r, e, t10, o = rt) => {
+var ZN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "StringNGrams": {
- let { nGrams: n, nGramsSplits: s } = o.string.stringNGrams(S("data", r, e, t10), S("dataSplits", r, e, t10), S("separator", r, e, t10), S("nGramWidths", r, e, t10), S("leftPad", r, e, t10), S("rightPad", r, e, t10), S("padWidth", r, e, t10), S("preserveShortSequences", r, e, t10));
+ let { nGrams: n, nGramsSplits: s } = o.string.stringNGrams(I("data", r, e, t6), I("dataSplits", r, e, t6), I("separator", r, e, t6), I("nGramWidths", r, e, t6), I("leftPad", r, e, t6), I("rightPad", r, e, t6), I("padWidth", r, e, t6), I("preserveShortSequences", r, e, t6));
return [n, s];
}
case "StringSplit": {
- let { indices: n, values: s, shape: a } = o.string.stringSplit(S("input", r, e, t10), S("delimiter", r, e, t10), S("skipEmpty", r, e, t10));
+ let { indices: n, values: s, shape: a } = o.string.stringSplit(I("input", r, e, t6), I("delimiter", r, e, t6), I("skipEmpty", r, e, t6));
return [n, s, a];
}
case "StringToHashBucketFast":
- return [o.string.stringToHashBucketFast(S("input", r, e, t10), S("numBuckets", r, e, t10))];
+ return [o.string.stringToHashBucketFast(I("input", r, e, t6), I("numBuckets", r, e, t6))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-var vN = (r, e, t10, o = rt) => {
+var JN = (r, e, t6, o = Ye) => {
switch (r.op) {
case "Cast":
- return [o.cast(S("x", r, e, t10), S("dtype", r, e, t10))];
+ return [o.cast(I("x", r, e, t6), I("dtype", r, e, t6))];
case "ExpandDims": {
- let n = S("axis", r, e, t10);
- return [o.expandDims(S("x", r, e, t10), n)];
+ let n = I("axis", r, e, t6);
+ return [o.expandDims(I("x", r, e, t6), n)];
}
case "Squeeze": {
- let n = S("axis", r, e, t10);
- return [o.squeeze(S("x", r, e, t10), n)];
+ let n = I("axis", r, e, t6);
+ return [o.squeeze(I("x", r, e, t6), n)];
}
case "Reshape":
- return [o.reshape(S("x", r, e, t10), S("shape", r, e, t10))];
+ return [o.reshape(I("x", r, e, t6), I("shape", r, e, t6))];
case "MirrorPad":
- return [o.mirrorPad(S("x", r, e, t10), S("padding", r, e, t10), S("mode", r, e, t10))];
+ return [o.mirrorPad(I("x", r, e, t6), I("padding", r, e, t6), I("mode", r, e, t6))];
case "PadV2":
case "Pad":
- return [o.pad(S("x", r, e, t10), S("padding", r, e, t10), S("constantValue", r, e, t10))];
+ return [o.pad(I("x", r, e, t6), I("padding", r, e, t6), I("constantValue", r, e, t6))];
case "SpaceToBatchND": {
- let n = S("blockShape", r, e, t10), s = S("paddings", r, e, t10);
- return [o.spaceToBatchND(S("x", r, e, t10), n, s)];
+ let n = I("blockShape", r, e, t6), s = I("paddings", r, e, t6);
+ return [o.spaceToBatchND(I("x", r, e, t6), n, s)];
}
case "BatchToSpaceND": {
- let n = S("blockShape", r, e, t10), s = S("crops", r, e, t10);
- return [o.batchToSpaceND(S("x", r, e, t10), n, s)];
+ let n = I("blockShape", r, e, t6), s = I("crops", r, e, t6);
+ return [o.batchToSpaceND(I("x", r, e, t6), n, s)];
}
case "DepthToSpace": {
- let n = S("blockSize", r, e, t10), s = S("dataFormat", r, e, t10).toUpperCase();
- return [o.depthToSpace(S("x", r, e, t10), n, s)];
+ let n = I("blockSize", r, e, t6), s = I("dataFormat", r, e, t6).toUpperCase();
+ return [o.depthToSpace(I("x", r, e, t6), n, s)];
}
case "BroadcastTo":
- return [o.broadcastTo(S("x", r, e, t10), S("shape", r, e, t10))];
+ return [o.broadcastTo(I("x", r, e, t6), I("shape", r, e, t6))];
case "BroadcastArgs":
- return [o.broadcastArgs(S("s0", r, e, t10), S("s1", r, e, t10))];
+ return [o.broadcastArgs(I("s0", r, e, t6), I("s1", r, e, t6))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
-function QC(r, e, t10, o, n = Ne) {
+function qC(r, e, t6, o, n = Ee) {
let s = ((a, i, p) => {
switch (a.category) {
case "arithmetic":
- return n(() => eN(a, i, p));
+ return n(() => _N(a, i, p));
case "basic_math":
- return n(() => tN(a, i, p));
+ return n(() => EN(a, i, p));
case "control":
- return iN(a, i, p);
+ return ON(a, i, p);
case "convolution":
- return n(() => pN(a, i, p));
+ return n(() => MN(a, i, p));
case "creation":
- return n(() => cN(a, i, p));
+ return n(() => LN(a, i, p));
case "dynamic":
- return lN(a, i, p);
+ return BN(a, i, p);
case "evaluation":
- return n(() => mN(a, i, p));
+ return n(() => VN(a, i, p));
case "image":
- return n(() => hN(a, i, p));
+ return n(() => UN(a, i, p));
case "graph":
- return n(() => fN(a, i, p));
+ return n(() => zN(a, i, p));
case "logical":
- return n(() => gN(a, i, p));
+ return n(() => GN(a, i, p));
case "matrices":
- return n(() => xN(a, i, p));
+ return n(() => HN(a, i, p));
case "normalization":
- return n(() => yN(a, i, p));
+ return n(() => qN(a, i, p));
+ case "ragged":
+ return n(() => KN(a, i, p));
case "reduction":
- return n(() => bN(a, i, p));
+ return n(() => jN(a, i, p));
case "slice_join":
- return n(() => CN(a, i, p));
+ return n(() => XN(a, i, p));
case "sparse":
- return n(() => IN(a, i, p));
+ return n(() => YN(a, i, p));
case "spectral":
- return n(() => wN(a, i, p));
+ return n(() => QN(a, i, p));
case "string":
- return n(() => SN(a, i, p));
+ return n(() => ZN(a, i, p));
case "transformation":
- return n(() => vN(a, i, p));
+ return n(() => JN(a, i, p));
case "hash_table":
- return dN(a, i, p, o);
+ return WN(a, i, p, o);
case "custom":
- let u = td(a.op);
+ let u = Gd(a.op);
if (u && u.customExecutor)
- return u.customExecutor(new fd(a, i, p));
+ return u.customExecutor(new rf(a, i, p));
throw TypeError(`Custom op ${a.op} is not registered.`);
default:
throw TypeError(`Unknown op '${a.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`);
}
- })(r, e, t10);
- return x.isPromise(s) ? s.then((a) => [].concat(a)) : [].concat(s);
+ })(r, e, t6);
+ return y.isPromise(s) ? s.then((a) => [].concat(a)) : [].concat(s);
}
-var yl = class {
- constructor(e = {}, t10 = {}, o = {}, n = {}) {
- this.weightMap = e, this.tensorArrayMap = t10, this.tensorListMap = o, this.functionMap = n, this.rootContext = { id: 0, frameName: "", iterationId: 0 }, this.contexts = [this.rootContext], this.lastId = 0, this.generateCurrentContextIds();
+var cl = class {
+ constructor(e = {}, t6 = {}, o = {}, n = {}) {
+ this.weightMap = e, this.tensorArrayMap = t6, this.tensorListMap = o, this.functionMap = n, this.rootContext = { id: 0, frameName: "", iterationId: 0 }, this.contexts = [this.rootContext], this.lastId = 0, this.generateCurrentContextIds();
}
- newFrame(e, t10) {
- return { id: e, frameName: t10, iterationId: 0 };
+ newFrame(e, t6) {
+ return { id: e, frameName: t6, iterationId: 0 };
}
set currentContext(e) {
this.contexts !== e && (this.contexts = e, this.generateCurrentContextIds());
@@ -10967,14 +10997,14 @@ var yl = class {
}
generateCurrentContextIds() {
let e = [];
- for (let t10 = 0; t10 < this.contexts.length - 1; t10++) {
- let o = this.contexts.slice(0, this.contexts.length - t10);
+ for (let t6 = 0; t6 < this.contexts.length - 1; t6++) {
+ let o = this.contexts.slice(0, this.contexts.length - t6);
e.push(this.contextIdforContexts(o));
}
e.push(""), this._currentContextIds = e;
}
contextIdforContexts(e) {
- return e ? e.map((t10) => t10.id === 0 && t10.iterationId === 0 ? "" : `${t10.frameName}-${t10.iterationId}`).join("/") : "";
+ return e ? e.map((t6) => t6.id === 0 && t6.iterationId === 0 ? "" : `${t6.frameName}-${t6.iterationId}`).join("/") : "";
}
enterFrame(e) {
this.contexts && (this.lastId++, this.contexts = this.contexts.slice(), this.contexts.push(this.newFrame(this.lastId, e)), this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)));
@@ -11009,32 +11039,32 @@ var yl = class {
return this.tensorListMap[e];
}
dispose(e) {
- for (let t10 in this.tensorArrayMap)
- this.tensorArrayMap[t10].clearAndClose(e);
- for (let t10 in this.tensorListMap)
- this.tensorListMap[t10].clearAndClose(e);
+ for (let t6 in this.tensorArrayMap)
+ this.tensorArrayMap[t6].clearAndClose(e);
+ for (let t6 in this.tensorListMap)
+ this.tensorListMap[t6].clearAndClose(e);
}
};
-function ZC(r, e, t10, o) {
- let n = /* @__PURE__ */ new Set(), s = [], a = null, i = null, p = /* @__PURE__ */ new Set(), u = Object.keys(r).map((m) => Sr(m)[0]), c = [];
- o != null && (c = o.map((m) => Sr(m.name)[0]));
+function KC(r, e, t6, o) {
+ let n = /* @__PURE__ */ new Set(), s = [], a = null, i = null, p = /* @__PURE__ */ new Set(), u = Object.keys(r).map((m) => Ir(m)[0]), c = [];
+ o != null && (c = o.map((m) => Ir(m.name)[0]));
let l = [...e];
for (; l.length > 0; ) {
let m = l.pop();
- if ((JC(m) || B6(m) || V6(m)) && a == null && (a = m, i = a.children.map((f) => f.name).filter((f) => n.has(f))), n.add(m.name), t10[m.name] == null && u.indexOf(m.name) === -1 && c.indexOf(m.name) === -1) {
+ if ((jC(m) || i6(m) || u6(m)) && a == null && (a = m, i = a.children.map((d) => d.name).filter((d) => n.has(d))), n.add(m.name), t6[m.name] == null && u.indexOf(m.name) === -1 && c.indexOf(m.name) === -1) {
if (m.inputs.length === 0) {
s.push(m.name);
continue;
}
- m.inputs.forEach((f) => {
- p.has(f.name) || (p.add(f.name), l.push(f));
+ m.inputs.forEach((d) => {
+ p.has(d.name) || (p.add(d.name), l.push(d));
});
}
}
return { inputs: r, outputs: e, usedNodes: n, missingInputs: s, dynamicNode: a, syncInputs: i };
}
-function kN(r, e, t10) {
- let { usedNodes: o, inputs: n } = t10, s = [], a = Object.keys(n).map((c) => Sr(c)[0]).map((c) => r.nodes[c]), i = r.initNodes;
+function eT(r, e, t6) {
+ let { usedNodes: o, inputs: n } = t6, s = [], a = Object.keys(n).map((c) => Ir(c)[0]).map((c) => r.nodes[c]), i = r.initNodes;
a.forEach((c) => {
o.has(c.name) && s.push(c);
}), r.weights.forEach((c) => {
@@ -11051,21 +11081,21 @@ function kN(r, e, t10) {
}
return u;
}
-var O6 = ["Switch", "Merge", "Enter", "Exit", "NextIteration", "StatelessIf", "StatelessWhile", "if", "While"];
-var M6 = ["NonMaxSuppressionV2", "NonMaxSuppressionV3", "NonMaxSuppressionV5", "Where"];
-var L6 = ["HashTable", "HashTableV2", "LookupTableImport", "LookupTableImportV2", "LookupTableFind", "LookupTableFindV2", "LookupTableSize", "LookupTableSizeV2"];
-function JC(r) {
- return O6.indexOf(r.op) >= 0;
+var n6 = ["Switch", "Merge", "Enter", "Exit", "NextIteration", "StatelessIf", "StatelessWhile", "if", "While"];
+var s6 = ["NonMaxSuppressionV2", "NonMaxSuppressionV3", "NonMaxSuppressionV5", "Where"];
+var a6 = ["HashTable", "HashTableV2", "LookupTableImport", "LookupTableImportV2", "LookupTableFind", "LookupTableFindV2", "LookupTableSize", "LookupTableSizeV2"];
+function jC(r) {
+ return n6.indexOf(r.op) >= 0;
}
-function B6(r) {
- return M6.indexOf(r.op) >= 0;
+function i6(r) {
+ return s6.indexOf(r.op) >= 0;
}
-function V6(r) {
- return L6.indexOf(r.op) >= 0;
+function u6(r) {
+ return a6.indexOf(r.op) >= 0;
}
var Cu = class {
- constructor(e, t10) {
- this.graph = e, this.parent = t10, this.compiledMap = /* @__PURE__ */ new Map(), this._weightMap = {}, this.SEPERATOR = ",", this._functions = {}, this._functionExecutorMap = {}, this.intermediateTensors = {}, this.keepTensorForDebug = false, this._outputs = e.outputs, this._inputs = e.inputs, this._initNodes = e.initNodes, this._signature = e.signature, this._functions = e.functions, e.functions != null && Object.keys(e.functions).forEach((o) => {
+ constructor(e, t6) {
+ this.graph = e, this.parent = t6, this.compiledMap = /* @__PURE__ */ new Map(), this._weightMap = {}, this.SEPERATOR = ",", this._functions = {}, this._functionExecutorMap = {}, this.keepIntermediateTensors = false, this._outputs = e.outputs, this._inputs = e.inputs, this._initNodes = e.initNodes, this._signature = e.signature, this._functions = e.functions, e.functions != null && Object.keys(e.functions).forEach((o) => {
this._functionExecutorMap[o] = new Cu(e.functions[o], this);
});
}
@@ -11079,8 +11109,8 @@ var Cu = class {
return this.parent ? this.parent.weightMap : this._weightMap;
}
set weightMap(e) {
- let t10 = Object.keys(e).map((o) => e[o].map((n) => n.id));
- this._weightIds = [].concat(...t10), this._weightMap = e;
+ let t6 = Object.keys(e).map((o) => e[o].map((n) => n.id));
+ this._weightIds = [].concat(...t6), this._weightMap = e;
}
set resourceManager(e) {
this._resourceManager = e;
@@ -11096,211 +11126,217 @@ var Cu = class {
}
get outputNodes() {
return this._outputs.map((e) => {
- let t10 = e.signatureKey || e.name;
- return e.defaultOutput ? `${t10}:${e.defaultOutput}` : t10;
+ let t6 = e.signatureKey || e.name;
+ return e.defaultOutput ? `${t6}:${e.defaultOutput}` : t6;
});
}
get functions() {
- return Object.keys(this._functions).reduce((e, t10) => (e[t10] = this._functions[t10].signature, e), {});
+ return Object.keys(this._functions).reduce((e, t6) => (e[t6] = this._functions[t6].signature, e), {});
}
- getCompilationKey(e, t10) {
- let o = e.map((s) => s.name).sort(), n = t10.map((s) => s.name).sort();
+ getCompilationKey(e, t6) {
+ let o = e.map((s) => s.name).sort(), n = t6.map((s) => s.name).sort();
return o.join(this.SEPERATOR) + "--" + n.join(this.SEPERATOR);
}
- compile(e, t10) {
- let o = ZC(e, t10, this.weightMap, this._initNodes), { missingInputs: n, dynamicNode: s, syncInputs: a } = o;
+ compile(e, t6) {
+ let o = KC(e, t6, this.weightMap, this._initNodes), { missingInputs: n, dynamicNode: s, syncInputs: a } = o;
if (s != null)
throw new Error(`This execution contains the node '${s.name}', which has the dynamic op '${s.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${a}]`);
if (n.length > 0) {
- let i = t10.map((u) => u.name), p = Object.keys(e);
+ let i = t6.map((u) => u.name), p = Object.keys(e);
throw new Error(`Cannot compute the outputs [${i}] from the provided inputs [${p}]. Missing the following inputs: [${n}]`);
}
- return kN(this.graph, this.weightMap, o);
+ return eT(this.graph, this.weightMap, o);
}
- execute(e, t10) {
- e = this.mapInputs(e);
+ cloneAndKeepTensor(e) {
+ if (e == null)
+ return null;
+ let t6 = e.clone();
+ return _r(t6), t6;
+ }
+ cloneTensorList(e) {
+ return e ? e.map((o) => this.cloneAndKeepTensor(o)) : null;
+ }
+ cloneTensorMap(e) {
+ return Object.fromEntries(Object.entries(e).map(([t6, o]) => [t6, this.cloneTensorList(o)]));
+ }
+ execute(e, t6) {
+ this.disposeIntermediateTensors(), e = this.mapInputs(e);
let o = Object.keys(e).sort();
- this.checkInputs(e), this.checkInputShapeAndType(e), t10 = this.mapOutputs(t10), this.checkOutputs(t10);
- let n = o.map((l) => this.graph.nodes[Sr(l)[0]]), s = t10.map((l) => Sr(l)[0]), a = s.map((l) => this.graph.nodes[l]);
- this.resetIntermediateTensors(), a.length === 0 && (a = this._outputs);
+ this.checkInputs(e), this.checkInputShapeAndType(e), t6 = this.mapOutputs(t6), this.checkOutputs(t6);
+ let n = o.map((l) => this.graph.nodes[Ir(l)[0]]), s = t6.map((l) => Ir(l)[0]), a = s.map((l) => this.graph.nodes[l]);
+ a.length === 0 && (a = this._outputs);
let i = this.getCompilationKey(n, a), p = this.compiledMap.get(i);
p == null && (p = this.compile(e, a), this.compiledMap.set(i, p));
+ try {
+ this.keepIntermediateTensors = O().getBool("KEEP_INTERMEDIATE_TENSORS");
+ } catch (l) {
+ this.keepIntermediateTensors = false, console.warn(l.message);
+ }
let u = {}, c = {};
- return Ne(() => {
- let l = new yl(this.weightMap, u, c, this.functionExecutorMap), m = Object.assign({}, this.weightMap);
- Object.keys(e).forEach((h) => {
- let [g, y] = Sr(h), b = [];
- b[y] = e[h], m[g] = b;
+ return Ee(() => {
+ let l = new cl(this.weightMap, u, c, this.functionExecutorMap), m = Object.assign({}, this.weightMap);
+ this.keepIntermediateTensors && (this.clonedTensorsMap = this.cloneTensorMap(this.weightMap)), Object.keys(e).forEach((h) => {
+ let [g, x] = Ir(h), b = [];
+ b[x] = e[h], m[g] = b, this.keepIntermediateTensors && (this.clonedTensorsMap[g] = this.cloneTensorList(b));
});
- let f = this.getFrozenTensorIds(m), d = {};
+ let d = this.getFrozenTensorIds(m), f = {};
for (let h = 0; h < p.length; h++) {
let g = p[h];
if (!m[g.name]) {
- let y = QC(g, m, l, this._resourceManager);
- if (x.isPromise(y))
+ let x = qC(g, m, l, this._resourceManager);
+ if (y.isPromise(x))
throw new Error(`The execution of the op '${g.op}' returned a promise. Please use model.executeAsync() instead.`);
- m[g.name] = y, this.checkTensorForDisposal(g.name, g, m, l, f, s, d);
+ m[g.name] = x, this.keepIntermediateTensors && (this.clonedTensorsMap[g.name] = this.cloneTensorList(x)), this.checkTensorForDisposal(g.name, g, m, l, d, s, f);
}
}
- return this.parent == null && l.dispose(f), t10.map((h) => Ht(h, m, l));
+ return this.parent == null && l.dispose(d), t6.map((h) => Gt(h, m, l));
});
}
getFrozenTensorIds(e) {
- let t10 = [].concat.apply([], Object.keys(e).map((o) => e[o]).map((o) => o.map((n) => n.id)));
- return new Set(t10);
+ let t6 = [].concat.apply([], Object.keys(e).map((o) => e[o]).map((o) => o.map((n) => n.id)));
+ return new Set(t6);
}
- checkTensorForDisposal(e, t10, o, n, s, a, i) {
- t10.category === "control" || a.indexOf(e) !== -1 || (o[e].forEach((p) => {
- p != null && (i[p.id] = (i[p.id] || 0) + t10.children.length);
- }), t10.inputs.forEach((p) => {
+ checkTensorForDisposal(e, t6, o, n, s, a, i) {
+ t6.category === "control" || a.indexOf(e) !== -1 || (o[e].forEach((p) => {
+ p != null && (i[p.id] = (i[p.id] || 0) + t6.children.length);
+ }), t6.inputs.forEach((p) => {
if (p.category !== "control") {
- let u = YT(p.name, o, n);
+ let u = vN(p.name, o, n);
u != null && u.forEach((c) => {
if (c && !c.kept && !s.has(c.id)) {
let l = i[c.id];
- if (l === 1) {
- if (!this.keepTensorForDebug)
- c.dispose();
- else {
- let [m, f] = zo(t10.name, n);
- this.intermediateTensors[m] ? this.intermediateTensors[m][f] = c : (this.intermediateTensors[m] = [], this.intermediateTensors[m][f] = c);
- }
- delete i[c.id];
- } else
- l != null && i[c.id]--;
+ l === 1 ? (c.dispose(), delete i[c.id]) : l != null && i[c.id]--;
}
});
}
}));
}
- async executeAsync(e, t10) {
- return this._executeAsync(e, t10);
+ async executeAsync(e, t6) {
+ return this._executeAsync(e, t6);
}
disposeIntermediateTensors() {
- !this.intermediateTensors || (Object.keys(this.intermediateTensors).forEach((e) => this.intermediateTensors[e].forEach((t10) => t10.dispose())), this.disposeTensorsMap());
- }
- disposeTensorsMap() {
- !this.tensorsMap || Object.keys(this.tensorsMap).forEach((e) => {
- this.tensorsMap[e].forEach((o) => {
- o && !o.kept && !o.isDisposed && !this.keepIds.has(o.id) && o.dispose();
- });
- });
+ !this.clonedTensorsMap || (Object.values(this.clonedTensorsMap).forEach((e) => {
+ for (let t6 of e)
+ t6 && !t6.isDisposed && t6.dispose();
+ }), this.clonedTensorsMap = null);
}
getIntermediateTensors() {
- return this.tensorsMap;
+ return this.clonedTensorsMap;
}
- resetIntermediateTensors() {
- for (let e in this.intermediateTensors)
- this.intermediateTensors[e].forEach((t10) => t10.dispose()), delete this.intermediateTensors[e];
- }
- async _executeAsync(e, t10, o = false, n = {}, s = {}) {
- o || (e = this.mapInputs(e), this.checkInputs(e), this.checkInputShapeAndType(e), t10 = this.mapOutputs(t10), this.checkOutputs(t10));
+ async _executeAsync(e, t6, o = false, n = {}, s = {}) {
+ this.disposeIntermediateTensors(), o || (e = this.mapInputs(e), this.checkInputs(e), this.checkInputShapeAndType(e), t6 = this.mapOutputs(t6), this.checkOutputs(t6));
try {
- this.keepTensorForDebug = P().getBool("KEEP_INTERMEDIATE_TENSORS");
- } catch (c) {
- console.warn(c.message);
+ this.keepIntermediateTensors = O().getBool("KEEP_INTERMEDIATE_TENSORS");
+ } catch (m) {
+ this.keepIntermediateTensors = false, console.warn(m.message);
}
- this.resetIntermediateTensors();
- let a = new yl(this.weightMap, n, s, this.functionExecutorMap);
- this.tensorsMap = await this.executeWithControlFlow(e, a, t10, o);
- let i = t10.map((c) => Ht(c, this.tensorsMap, a)), p = i.map((c) => c.id), u = Object.keys(e).map((c) => e[c].id);
- return this.keepIds = /* @__PURE__ */ new Set([...p, ...u, ...this.weightIds]), this.keepTensorForDebug || this.disposeTensorsMap(), this.parent == null && a.dispose(this.keepIds), i;
+ let a = new cl(this.weightMap, n, s, this.functionExecutorMap);
+ this.keepIntermediateTensors && (this.clonedTensorsMap = this.cloneTensorMap(this.weightMap));
+ let i = await this.executeWithControlFlow(e, a, t6, o), p = t6.map((m) => Gt(m, i, a)), u = p.map((m) => m.id), c = Object.keys(e).map((m) => e[m].id), l = /* @__PURE__ */ new Set([...u, ...c, ...this.weightIds]);
+ return Object.values(i).forEach((m) => {
+ m.forEach((d) => {
+ d && !d.isDisposed && !l.has(d.id) && d.dispose();
+ });
+ }), this.parent == null && a.dispose(l), p;
}
- async executeFunctionAsync(e, t10, o) {
+ async executeFunctionAsync(e, t6, o) {
let n = e.reduce((s, a, i) => (s[this.inputs[i].name] = a, s), {});
- return this._executeAsync(n, this.outputNodes, true, t10, o);
+ return this._executeAsync(n, this.outputNodes, true, t6, o);
}
- async executeWithControlFlow(e, t10, o, n) {
- let s = Object.keys(e), a = s.map((C) => this.graph.nodes[Sr(C)[0]]), i = o.map((C) => Sr(C)[0]), p = i.map((C) => this.graph.nodes[C]);
+ async executeWithControlFlow(e, t6, o, n) {
+ let s = Object.keys(e), a = s.map((C) => this.graph.nodes[Ir(C)[0]]), i = o.map((C) => Ir(C)[0]), p = i.map((C) => this.graph.nodes[C]);
p.length === 0 && (p = this._outputs);
- let { usedNodes: u, missingInputs: c, dynamicNode: l, syncInputs: m } = ZC(e, p, this.weightMap, this._initNodes), f = [...a, ...this.graph.weights, ...this._initNodes || []].map((C) => ({ node: C, contexts: t10.currentContext })), d = Object.assign({}, this.weightMap);
+ let { usedNodes: u, missingInputs: c, dynamicNode: l, syncInputs: m } = KC(e, p, this.weightMap, this._initNodes), d = [...a, ...this.graph.weights, ...this._initNodes || []].map((C) => ({ node: C, contexts: t6.currentContext })), f = Object.assign({}, this.weightMap);
Object.keys(e).forEach((C) => {
- let [w, k] = Sr(C), _ = [];
- _[k] = e[C], d[w] = _;
+ let [w, k] = Ir(C), _ = [];
+ _[k] = e[C], f[w] = _;
});
- let h = {}, g = this.getFrozenTensorIds(d), y = {};
- for (; f.length > 0; ) {
- let C = this.processStack(a, f, t10, d, y, g, i, h, u);
+ let h = {}, g = this.getFrozenTensorIds(f), x = {};
+ for (; d.length > 0; ) {
+ let C = this.processStack(a, d, t6, f, x, g, i, h, u);
await Promise.all(C);
}
l == null && !n && console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");
- let b = p.filter((C) => !JC(C) && !Ht(C.name, d, t10)).map((C) => C.name);
+ let b = p.filter((C) => !jC(C) && !Gt(C.name, f, t6)).map((C) => C.name);
if (b.length > 0) {
let C = "";
throw l != null && (C = `Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${m}]`), new Error(`Cannot compute the outputs [${b}] from the provided inputs [${s}]. Consider providing the following inputs: [${c}]. ${C}`);
}
- return d;
+ return f;
}
- processStack(e, t10, o, n, s, a, i, p, u) {
+ processStack(e, t6, o, n, s, a, i, p, u) {
let c = [];
- for (; t10.length > 0; ) {
- let l = t10.pop();
+ for (; t6.length > 0; ) {
+ let l = t6.pop();
o.currentContext = l.contexts;
let m = "";
- if (l.node.op === "Enter" && S("isConstant", l.node, n, o) && ([m] = zo(l.node.name, o)), n[l.node.name] == null) {
- let f = QC(l.node, n, o, this._resourceManager);
- m || ([m] = zo(l.node.name, o));
- let d = o.currentContext;
- x.isPromise(f) ? c.push(f.then((h) => (n[m] = h, o.currentContext = d, this.checkTensorForDisposal(m, l.node, n, o, a, i, p), this.processChildNodes(l.node, t10, o, n, s, u), h))) : (n[m] = f, this.checkTensorForDisposal(m, l.node, n, o, a, i, p), this.processChildNodes(l.node, t10, o, n, s, u));
+ if (l.node.op === "Enter" && I("isConstant", l.node, n, o) && ([m] = ss(l.node.name, o)), n[l.node.name] == null) {
+ let d = qC(l.node, n, o, this._resourceManager);
+ m || ([m] = ss(l.node.name, o));
+ let f = o.currentContext;
+ y.isPromise(d) ? c.push(d.then((h) => (n[m] = h, this.keepIntermediateTensors && (this.clonedTensorsMap[m] = this.cloneTensorList(h)), o.currentContext = f, this.checkTensorForDisposal(m, l.node, n, o, a, i, p), this.processChildNodes(l.node, t6, o, n, s, u), h))) : (n[m] = d, this.keepIntermediateTensors && (this.clonedTensorsMap[m] = this.cloneTensorList(d)), this.checkTensorForDisposal(m, l.node, n, o, a, i, p), this.processChildNodes(l.node, t6, o, n, s, u));
} else
- this.processChildNodes(l.node, t10, o, n, s, u);
+ this.processChildNodes(l.node, t6, o, n, s, u);
}
return c;
}
- processChildNodes(e, t10, o, n, s, a) {
+ processChildNodes(e, t6, o, n, s, a) {
e.children.forEach((i) => {
- let [p] = zo(i.name, o);
- s[p] || !a.has(i.name) || (i.op === "Merge" ? i.inputNames.some((u) => !!Ht(u, n, o)) && (s[p] = true, t10.push({ contexts: o.currentContext, node: i })) : i.inputNames.every((u) => !!Ht(u, n, o)) && (s[p] = true, t10.push({ contexts: o.currentContext, node: i })));
+ let [p] = ss(i.name, o);
+ s[p] || !a.has(i.name) || (i.op === "Merge" ? i.inputNames.some((u) => !!Gt(u, n, o)) && (s[p] = true, t6.push({ contexts: o.currentContext, node: i })) : i.inputNames.every((u) => !!Gt(u, n, o)) && (s[p] = true, t6.push({ contexts: o.currentContext, node: i })));
});
}
dispose() {
- Object.keys(this.weightMap).forEach((e) => this.weightMap[e].forEach((t10) => t10.dispose()));
+ Object.keys(this.weightMap).forEach((e) => this.weightMap[e].forEach((t6) => t6.dispose()));
}
checkInputShapeAndType(e) {
- Object.keys(e).forEach((t10) => {
- let o = e[t10], [n] = Sr(t10), s = this.graph.nodes[n];
+ Object.keys(e).forEach((t6) => {
+ let o = e[t6], [n] = Ir(t6), s = this.graph.nodes[n];
if (s.attrParams.shape && s.attrParams.shape.value) {
let a = s.attrParams.shape.value, i = a.length === o.shape.length && o.shape.every((p, u) => a[u] === -1 || a[u] === p);
- x.assert(i, () => `The shape of dict['${s.name}'] provided in model.execute(dict) must be [${a}], but was [${o.shape}]`);
+ y.assert(i, () => `The shape of dict['${s.name}'] provided in model.execute(dict) must be [${a}], but was [${o.shape}]`);
}
- s.attrParams.dtype && s.attrParams.dtype.value && x.assert(o.dtype === s.attrParams.dtype.value, () => `The dtype of dict['${s.name}'] provided in model.execute(dict) must be ${s.attrParams.dtype.value}, but was ${o.dtype}`);
+ s.attrParams.dtype && s.attrParams.dtype.value && y.assert(o.dtype === s.attrParams.dtype.value, () => `The dtype of dict['${s.name}'] provided in model.execute(dict) must be ${s.attrParams.dtype.value}, but was ${o.dtype}`);
});
}
mapInputs(e) {
- let t10 = {};
- for (let o in e)
- if (this._signature != null && this._signature.inputs != null && this._signature.inputs[o] != null) {
- let n = this._signature.inputs[o];
- t10[n.name] = e[o];
- } else
- t10[o] = e[o];
- return t10;
+ var t6, o;
+ let n = {};
+ for (let s in e) {
+ let a = (o = (t6 = this._signature) === null || t6 === void 0 ? void 0 : t6.inputs) === null || o === void 0 ? void 0 : o[s];
+ a != null ? n[a.name] = e[s] : n[s] = e[s];
+ }
+ return n;
}
checkInputs(e) {
- let t10 = Object.keys(e).filter((o) => {
- let [n] = Sr(o);
+ let t6 = Object.keys(e).filter((o) => {
+ let [n] = Ir(o);
return this.graph.nodes[n] == null;
});
- if (t10.length > 0)
- throw new Error(`The dict provided in model.execute(dict) has keys: [${t10}] that are not part of graph`);
+ if (t6.length > 0)
+ throw new Error(`The dict provided in model.execute(dict) has keys: [${t6}] that are not part of graph`);
}
mapOutputs(e) {
- return e.map((t10) => this._signature != null && this._signature.outputs != null && this._signature.outputs[t10] != null ? this._signature.outputs[t10].name : t10, {});
+ return e.map((t6) => {
+ var o, n;
+ let s = (n = (o = this._signature) === null || o === void 0 ? void 0 : o.outputs) === null || n === void 0 ? void 0 : n[t6];
+ return s != null ? s.name : t6;
+ }, {});
}
checkOutputs(e) {
- e.forEach((t10) => {
- let [o] = Sr(t10);
+ e.forEach((t6) => {
+ let [o] = Ir(t6);
if (!this.graph.nodes[o])
- throw new Error(`The output '${t10}' is not found in the graph`);
+ throw new Error(`The output '${t6}' is not found in the graph`);
});
}
};
-var xd = class {
- constructor(e = {}, t10 = {}) {
- this.hashTableNameToHandle = e, this.hashTableMap = t10;
+var af = class {
+ constructor(e = {}, t6 = {}) {
+ this.hashTableNameToHandle = e, this.hashTableMap = t6;
}
- addHashTable(e, t10) {
- this.hashTableNameToHandle[e] = t10.handle, this.hashTableMap[t10.id] = t10;
+ addHashTable(e, t6) {
+ this.hashTableNameToHandle[e] = t6.handle, this.hashTableMap[t6.id] = t6;
}
getHashTableHandleByName(e) {
return this.hashTableNameToHandle[e];
@@ -11315,11 +11351,11 @@ var xd = class {
this.hashTableNameToHandle[e].dispose(), delete this.hashTableNameToHandle[e];
}
};
-var z6 = "?tfjs-format=file";
-var W6 = "model.json";
-var bl = class {
- constructor(e, t10 = {}, o = va) {
- this.modelUrl = e, this.loadOptions = t10, this.version = "n/a", this.io = o, t10 == null && (this.loadOptions = {}), this.resourceManager = new xd();
+var p6 = "?tfjs-format=file";
+var c6 = "model.json";
+var ll = class {
+ constructor(e, t6 = {}, o = Ea) {
+ this.modelUrl = e, this.loadOptions = t6, this.version = "n/a", this.io = o, t6 == null && (this.loadOptions = {}), this.resourceManager = new af();
}
get modelVersion() {
return this.version;
@@ -11355,36 +11391,36 @@ var bl = class {
else if (this.loadOptions.requestInit != null)
this.handler = this.io.browserHTTPRequest(e, this.loadOptions);
else {
- let t10 = this.io.getLoadHandlers(e, this.loadOptions);
- if (t10.length === 0)
- t10.push(this.io.browserHTTPRequest(e, this.loadOptions));
- else if (t10.length > 1)
- throw new Error(`Found more than one (${t10.length}) load handlers for URL '${[e]}'`);
- this.handler = t10[0];
+ let t6 = this.io.getLoadHandlers(e, this.loadOptions);
+ if (t6.length === 0)
+ t6.push(this.io.browserHTTPRequest(e, this.loadOptions));
+ else if (t6.length > 1)
+ throw new Error(`Found more than one (${t6.length}) load handlers for URL '${[e]}'`);
+ this.handler = t6[0];
}
}
load() {
if (this.findIOHandler(), this.handler.load == null)
throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");
let e = this.handler.load();
- return x.isPromise(e) ? e.then((t10) => this.loadSync(t10)) : this.loadSync(e);
+ return y.isPromise(e) ? e.then((t6) => this.loadSync(t6)) : this.loadSync(e);
}
loadSync(e) {
this.artifacts = e;
- let t10 = this.artifacts.modelTopology, o = this.artifacts.signature;
+ let t6 = this.artifacts.modelTopology, o = this.artifacts.signature;
if (this.artifacts.userDefinedMetadata != null) {
let s = this.artifacts.userDefinedMetadata;
s.signature != null && (o = s.signature), s.structuredOutputKeys != null && (this.structuredOutputKeys = s.structuredOutputKeys);
}
- this.signature = o, this.version = `${t10.versions.producer}.${t10.versions.minConsumer}`;
+ this.signature = o, this.version = `${t6.versions.producer}.${t6.versions.minConsumer}`;
let n = this.io.decodeWeights(this.artifacts.weightData, this.artifacts.weightSpecs);
- if (this.executor = new Cu(xl.Instance.transformGraph(t10, this.signature)), this.executor.weightMap = this.convertTensorMapToTensorsMap(n), this.executor.resourceManager = this.resourceManager, e.modelInitializer != null && e.modelInitializer.node != null) {
- let s = xl.Instance.transformGraph(e.modelInitializer);
+ if (this.executor = new Cu(pl.Instance.transformGraph(t6, this.signature)), this.executor.weightMap = this.convertTensorMapToTensorsMap(n), this.executor.resourceManager = this.resourceManager, e.modelInitializer != null && e.modelInitializer.node != null) {
+ let s = pl.Instance.transformGraph(e.modelInitializer);
this.initializer = new Cu(s), this.initializer.weightMap = this.executor.weightMap, this.initializer.resourceManager = this.resourceManager, this.initializerSignature = e.initializerSignature;
}
return true;
}
- async save(e, t10) {
+ async save(e, t6) {
if (typeof e == "string") {
let o = this.io.getSaveHandlers(e);
if (o.length === 0)
@@ -11397,31 +11433,41 @@ var bl = class {
throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");
return e.save(this.artifacts);
}
- predict(e, t10) {
- let o = this.execute(e, this.outputNodes);
+ addStructuredOutputNames(e) {
if (this.structuredOutputKeys) {
- let n = o instanceof ut ? [o] : o, s = {};
- return n.forEach((a, i) => s[this.structuredOutputKeys[i]] = a), s;
+ let t6 = e instanceof it ? [e] : e, o = {};
+ return t6.forEach((n, s) => o[this.structuredOutputKeys[s]] = n), o;
}
- return o;
+ return e;
+ }
+ predict(e, t6) {
+ let o = this.execute(e, this.outputNodes);
+ return this.addStructuredOutputNames(o);
+ }
+ async predictAsync(e, t6) {
+ let o = await this.executeAsync(e, this.outputNodes);
+ return this.addStructuredOutputNames(o);
}
normalizeInputs(e) {
- if (!(e instanceof ut) && !Array.isArray(e)) {
- if (this.signature != null && this.signature.inputs != null)
- for (let n in this.signature.inputs) {
- let s = this.signature.inputs[n];
- s.resourceId != null && (e[n] = this.resourceIdToCapturedInput[s.resourceId]);
+ var t6;
+ if (!(e instanceof it) && !Array.isArray(e)) {
+ let s = (t6 = this.signature) === null || t6 === void 0 ? void 0 : t6.inputs;
+ if (s != null)
+ for (let a in s) {
+ let i = s[a];
+ i.resourceId != null && (e[a] = this.resourceIdToCapturedInput[i.resourceId]);
}
return e;
}
e = Array.isArray(e) ? e : [e];
- let t10 = Object.keys(this.resourceIdToCapturedInput).length;
- if (e.length + t10 !== this.inputNodes.length)
- throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length - t10} non-resource placeholders, while there are ${e.length} input tensors provided.`);
- let o = 0;
- return this.inputNodes.reduce((n, s) => {
- let a = this.signature ? this.signature.inputs[s] : null;
- return a != null && a.resourceId != null ? n[s] = this.resourceIdToCapturedInput[a.resourceId] : n[s] = e[o++], n;
+ let o = Object.keys(this.resourceIdToCapturedInput).length;
+ if (e.length + o !== this.inputNodes.length)
+ throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length - o} non-resource placeholders, while there are ${e.length} input tensors provided.`);
+ let n = 0;
+ return this.inputNodes.reduce((s, a) => {
+ var i, p, u;
+ let c = (u = (p = (i = this.signature) === null || i === void 0 ? void 0 : i.inputs) === null || p === void 0 ? void 0 : p[a]) === null || u === void 0 ? void 0 : u.resourceId;
+ return c != null ? s[a] = this.resourceIdToCapturedInput[c] : s[a] = e[n++], s;
}, {});
}
normalizeOutputs(e) {
@@ -11435,21 +11481,21 @@ var bl = class {
}
setResourceIdToCapturedInput(e) {
if (this.resourceIdToCapturedInput = {}, this.initializerSignature) {
- let t10 = Object.keys(this.initializerSignature.outputs);
- for (let o = 0; o < t10.length; o++) {
- let n = t10[o], s = this.initializerSignature.outputs[n];
- this.resourceIdToCapturedInput[s.resourceId] = e[o];
+ let t6 = this.initializerSignature.outputs, o = Object.keys(t6);
+ for (let n = 0; n < o.length; n++) {
+ let s = o[n], a = t6[s];
+ this.resourceIdToCapturedInput[a.resourceId] = e[n];
}
}
}
- execute(e, t10) {
- this.resourceIdToCapturedInput == null && this.setResourceIdToCapturedInput(this.executeInitializerGraph()), e = this.normalizeInputs(e), t10 = this.normalizeOutputs(t10);
- let o = this.executor.execute(e, t10);
+ execute(e, t6) {
+ this.resourceIdToCapturedInput == null && this.setResourceIdToCapturedInput(this.executeInitializerGraph()), e = this.normalizeInputs(e), t6 = this.normalizeOutputs(t6);
+ let o = this.executor.execute(e, t6);
return o.length > 1 ? o : o[0];
}
- async executeAsync(e, t10) {
- this.resourceIdToCapturedInput == null && this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()), e = this.normalizeInputs(e), t10 = this.normalizeOutputs(t10);
- let o = await this.executor.executeAsync(e, t10);
+ async executeAsync(e, t6) {
+ this.resourceIdToCapturedInput == null && this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()), e = this.normalizeInputs(e), t6 = this.normalizeOutputs(t6);
+ let o = await this.executor.executeAsync(e, t6);
return o.length > 1 ? o : o[0];
}
getIntermediateTensors() {
@@ -11459,20 +11505,20 @@ var bl = class {
this.executor.disposeIntermediateTensors();
}
convertTensorMapToTensorsMap(e) {
- return Object.keys(e).reduce((t10, o) => (t10[o] = [e[o]], t10), {});
+ return Object.keys(e).reduce((t6, o) => (t6[o] = [e[o]], t6), {});
}
dispose() {
- this.executor.dispose(), this.initializer && (this.initializer.dispose(), this.resourceIdToCapturedInput && Ft(this.resourceIdToCapturedInput)), this.resourceManager.dispose();
+ this.executor.dispose(), this.initializer && (this.initializer.dispose(), this.resourceIdToCapturedInput && Dt(this.resourceIdToCapturedInput)), this.resourceManager.dispose();
}
};
-async function U6(r, e = {}, t10 = va) {
+async function l6(r, e = {}, t6 = Ea) {
if (r == null)
throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");
- e == null && (e = {}), e.fromTFHub && typeof r == "string" && (r = H6(r));
- let o = new bl(r, e, t10);
+ e == null && (e = {}), e.fromTFHub && typeof r == "string" && (r = d6(r));
+ let o = new ll(r, e, t6);
return await o.load(), o;
}
-function G6(r) {
+function m6(r) {
if (r == null)
throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide model artifacts or an IOHandler that loads the model");
let e;
@@ -11486,66 +11532,66 @@ function G6(r) {
throw new Error("Model JSON is missing 'modelTopology'");
if (!("weightsManifest" in o))
throw new Error("Model JSON is missing 'weightsManifest'");
- let s = va.getWeightSpecs(o.weightsManifest), a = va.getModelArtifactsForJSONSync(o, s, n);
- e = va.fromMemorySync(a);
+ let s = Ea.getWeightSpecs(o.weightsManifest), a = Ea.getModelArtifactsForJSONSync(o, s, n);
+ e = Ea.fromMemorySync(a);
} else if ("load" in r)
e = r;
else if ("modelTopology" in r && "weightSpecs" in r && "weightData" in r)
- e = va.fromMemorySync(r);
+ e = Ea.fromMemorySync(r);
else
throw new Error("Unknown model format");
- let t10 = new bl(e);
- return t10.load(), t10;
+ let t6 = new ll(e);
+ return t6.load(), t6;
}
-function H6(r) {
- return r.endsWith("/") || (r = r + "/"), `${r}${W6}${z6}`;
+function d6(r) {
+ return r.endsWith("/") || (r = r + "/"), `${r}${c6}${p6}`;
}
-var q6 = "4.0.0";
+var f6 = "4.1.0";
function K(r, e) {
- Array.isArray(r) || (r = [r]), r.forEach((t10) => {
- t10 != null && x.assert(t10.dtype !== "complex64", () => `${e} does not support complex64 tensors in the CPU backend.`);
+ Array.isArray(r) || (r = [r]), r.forEach((t6) => {
+ t6 != null && y.assert(t6.dtype !== "complex64", () => `${e} does not support complex64 tensors in the CPU backend.`);
});
}
-var K6 = Bt.whereImpl;
-var Si = class extends Jr {
+var h6 = Lt.whereImpl;
+var Oi = class extends Zr {
constructor() {
- super(), this.blockSize = 48, this.firstUse = true, this.data = new rn(this, cr());
+ super(), this.blockSize = 48, this.firstUse = true, this.data = new Do(this, cr());
}
nextDataId() {
- return Si.nextDataId++;
+ return Oi.nextDataId++;
}
- write(e, t10, o) {
- this.firstUse && (this.firstUse = false, P().get("IS_NODE") && I.warn(`
+ write(e, t6, o) {
+ this.firstUse && (this.firstUse = false, O().get("IS_NODE") && S.warn(`
============================
Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details.
============================`));
let n = { id: this.nextDataId() };
return this.data.set(n, { values: e, dtype: o, refCount: 1 }), n;
}
- makeTensorInfo(e, t10, o) {
+ makeTensorInfo(e, t6, o) {
let n;
- if (t10 === "string" && o != null && o.length > 0 && x.isString(o[0])) {
- let s = o.map((a) => x.encodeString(a));
- n = this.write(s, e, t10);
+ if (t6 === "string" && o != null && o.length > 0 && y.isString(o[0])) {
+ let s = o.map((a) => y.encodeString(a));
+ n = this.write(s, e, t6);
} else
- n = this.write(o, e, t10);
- return { dataId: n, shape: e, dtype: t10 };
+ n = this.write(o, e, t6);
+ return { dataId: n, shape: e, dtype: t6 };
}
refCount(e) {
return this.data.has(e) ? this.data.get(e).refCount : 0;
}
incRef(e) {
- let t10 = this.data.get(e);
- t10.refCount++;
+ let t6 = this.data.get(e);
+ t6.refCount++;
}
decRef(e) {
if (this.data.has(e)) {
- let t10 = this.data.get(e);
- t10.refCount--;
+ let t6 = this.data.get(e);
+ t6.refCount--;
}
}
- move(e, t10, o, n, s) {
- this.data.set(e, { values: t10, dtype: n, refCount: s });
+ move(e, t6, o, n, s) {
+ this.data.set(e, { values: t6, dtype: n, refCount: s });
}
numDataIds() {
return this.data.numDataIds();
@@ -11554,30 +11600,30 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram
return this.readSync(e);
}
readSync(e) {
- let { dtype: t10, complexTensorInfos: o } = this.data.get(e);
- if (t10 === "complex64") {
+ let { dtype: t6, complexTensorInfos: o } = this.data.get(e);
+ if (t6 === "complex64") {
let n = this.readSync(o.real.dataId), s = this.readSync(o.imag.dataId);
- return I.mergeRealAndImagArrays(n, s);
+ return S.mergeRealAndImagArrays(n, s);
}
return this.data.get(e).values;
}
bufferSync(e) {
- let t10 = this.readSync(e.dataId);
+ let t6 = this.readSync(e.dataId);
if (e.dtype === "string")
try {
- let o = t10.map((n) => x.decodeString(n));
- return ne(e.shape, e.dtype, o);
+ let o = t6.map((n) => y.decodeString(n));
+ return le(e.shape, e.dtype, o);
} catch (o) {
throw new Error("Failed to decode encoded string bytes into utf-8");
}
- return ne(e.shape, e.dtype, t10);
+ return le(e.shape, e.dtype, t6);
}
- makeOutput(e, t10, o) {
- return cr().makeTensorFromTensorInfo(this.makeTensorInfo(t10, o, e), this);
+ makeOutput(e, t6, o) {
+ return cr().makeTensorFromTensorInfo(this.makeTensorInfo(t6, o, e), this);
}
- disposeData(e, t10 = false) {
+ disposeData(e, t6 = false) {
if (this.data.has(e)) {
- if (this.data.get(e).refCount--, !t10 && this.data.get(e).refCount > 0)
+ if (this.data.get(e).refCount--, !t6 && this.data.get(e).refCount > 0)
return false;
let { complexTensorInfos: o } = this.data.get(e);
o != null && (this.disposeData(o.real.dataId, true), this.disposeData(o.imag.dataId, true)), this.data.delete(e);
@@ -11588,16 +11634,16 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram
this.disposeData(e.dataId);
}
async time(e) {
- let t10 = x.now();
- return e(), { kernelMs: x.now() - t10 };
+ let t6 = y.now();
+ return e(), { kernelMs: y.now() - t6 };
}
memory() {
return { unreliable: true, reasons: ["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."] };
}
where(e) {
K([e], "where");
- let t10 = this.readSync(e.dataId);
- return K6(e.shape, t10);
+ let t6 = this.readSync(e.dataId);
+ return h6(e.shape, t6);
}
dispose() {
}
@@ -11608,137 +11654,137 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram
return super.epsilon();
}
};
-Si.nextDataId = 0;
-var Ad = {};
-Be(Ad, { addImpl: () => rI, bincountImpl: () => Zp, bincountReduceImpl: () => yd, castImpl: () => tI, ceilImpl: () => oI, concatImpl: () => Iu, equalImpl: () => nI, expImpl: () => aI, expm1Impl: () => uI, floorImpl: () => pI, gatherNdImpl: () => bd, gatherV2Impl: () => Cd, greaterEqualImpl: () => lI, greaterImpl: () => cI, lessEqualImpl: () => fI, lessImpl: () => mI, linSpaceImpl: () => Id, logImpl: () => dI, maxImpl: () => wd, maximumImpl: () => hI, minimumImpl: () => gI, multiplyImpl: () => Cl, negImpl: () => xI, notEqualImpl: () => yI, prodImpl: () => bI, raggedGatherImpl: () => Sd, raggedRangeImpl: () => vd, raggedTensorToTensorImpl: () => kd, rangeImpl: () => Su, rsqrtImpl: () => CI, scatterImpl: () => Aa, sigmoidImpl: () => e2, simpleAbsImpl: () => eI, sliceImpl: () => vu, sparseFillEmptyRowsImpl: () => Td, sparseReshapeImpl: () => Nd, sparseSegmentReductionImpl: () => tc, sqrtImpl: () => o2, squaredDifferenceImpl: () => wI, stridedSliceImpl: () => _d, stringNGramsImpl: () => ku, stringSplitImpl: () => Tu, stringToHashBucketFastImpl: () => Nu, subImpl: () => vI, tileImpl: () => Ed, topKImpl: () => $d, transposeImpl: () => Jp, uniqueImpl: () => Rd });
-function eI(r) {
+Oi.nextDataId = 0;
+var Qp = {};
+Ue(Qp, { addImpl: () => QC, bincountImpl: () => Kp, bincountReduceImpl: () => uf, castImpl: () => YC, ceilImpl: () => ZC, concatImpl: () => Su, equalImpl: () => JC, expImpl: () => tS, expm1Impl: () => oS, floorImpl: () => nS, gatherNdImpl: () => pf, gatherV2Impl: () => cf, greaterEqualImpl: () => aS, greaterImpl: () => sS, lessEqualImpl: () => uS, lessImpl: () => iS, linSpaceImpl: () => lf, logImpl: () => pS, maxImpl: () => mf, maximumImpl: () => cS, minimumImpl: () => lS, multiplyImpl: () => ml, negImpl: () => mS, notEqualImpl: () => dS, prodImpl: () => fS, raggedGatherImpl: () => df, raggedRangeImpl: () => ff, raggedTensorToTensorImpl: () => hf, rangeImpl: () => Iu, rsqrtImpl: () => hS, scatterImpl: () => Ma, sigmoidImpl: () => ET, simpleAbsImpl: () => XC, sliceImpl: () => vu, sparseFillEmptyRowsImpl: () => gf, sparseReshapeImpl: () => xf, sparseSegmentReductionImpl: () => Yp, sqrtImpl: () => RT, squaredDifferenceImpl: () => xS, stridedSliceImpl: () => yf, stringNGramsImpl: () => ku, stringSplitImpl: () => Nu, stringToHashBucketFastImpl: () => Tu, subImpl: () => bS, tileImpl: () => bf, topKImpl: () => Cf, transposeImpl: () => jp, uniqueImpl: () => Sf });
+function XC(r) {
let e = new Float32Array(r.length);
- for (let t10 = 0; t10 < r.length; ++t10)
- e[t10] = Math.abs(r[t10]);
+ for (let t6 = 0; t6 < r.length; ++t6)
+ e[t6] = Math.abs(r[t6]);
return e;
}
-var j6 = (r) => {
- let { x: e } = r.inputs, t10 = r.backend;
+var g6 = (r) => {
+ let { x: e } = r.inputs, t6 = r.backend;
K(e, "abs");
- let o = new Float32Array(x.sizeFromShape(e.shape)), n = t10.data.get(e.dataId).values;
- return o = eI(n), t10.makeOutput(o, e.shape, e.dtype);
+ let o = new Float32Array(y.sizeFromShape(e.shape)), n = t6.data.get(e.dataId).values;
+ return o = XC(n), t6.makeOutput(o, e.shape, e.dtype);
};
-var TN = { kernelName: sn, backendName: "cpu", kernelFunc: j6 };
-function Le(r) {
- return (e, t10, o, n, s) => {
- let a = I.assertAndGetBroadcastShape(e, t10), i = a.length, p = x.computeStrides(a), u = x.sizeFromShape(a), c = x.getTypedArrayFromDType(s, u), l = e.length, m = t10.length, f = x.computeStrides(e), d = x.computeStrides(t10), h = I.getBroadcastDims(e, a), g = I.getBroadcastDims(t10, a);
+var tT = { kernelName: gs, backendName: "cpu", kernelFunc: g6 };
+function Be(r) {
+ return (e, t6, o, n, s) => {
+ let a = S.assertAndGetBroadcastShape(e, t6), i = a.length, p = y.computeStrides(a), u = y.sizeFromShape(a), c = y.getTypedArrayFromDType(s, u), l = e.length, m = t6.length, d = y.computeStrides(e), f = y.computeStrides(t6), h = S.getBroadcastDims(e, a), g = S.getBroadcastDims(t6, a);
if (h.length + g.length === 0)
- for (let y = 0; y < c.length; ++y)
- c[y] = r(o[y % o.length], n[y % n.length]);
+ for (let x = 0; x < c.length; ++x)
+ c[x] = r(o[x % o.length], n[x % n.length]);
else
- for (let y = 0; y < c.length; ++y) {
- let b = x.indexToLoc(y, i, p), C = b.slice(-l);
- h.forEach((E) => C[E] = 0);
- let w = x.locToIndex(C, l, f), k = b.slice(-m);
- g.forEach((E) => k[E] = 0);
- let _ = x.locToIndex(k, m, d);
- c[y] = r(o[w], n[_]);
+ for (let x = 0; x < c.length; ++x) {
+ let b = y.indexToLoc(x, i, p), C = b.slice(-l);
+ h.forEach(($) => C[$] = 0);
+ let w = y.locToIndex(C, l, d), k = b.slice(-m);
+ g.forEach(($) => k[$] = 0);
+ let _ = y.locToIndex(k, m, f);
+ c[x] = r(o[w], n[_]);
}
return [c, a];
};
}
-function qt(r) {
- let { inputs: e, backend: t10 } = r, { real: o, imag: n } = e, s = t10.data.get(o.dataId).values, a = t10.data.get(n.dataId).values, i = t10.makeTensorInfo(o.shape, "complex64"), p = t10.data.get(i.dataId);
- return p.complexTensorInfos = { real: t10.makeTensorInfo(o.shape, "float32", s), imag: t10.makeTensorInfo(n.shape, "float32", a) }, i;
+function Ht(r) {
+ let { inputs: e, backend: t6 } = r, { real: o, imag: n } = e, s = t6.data.get(o.dataId).values, a = t6.data.get(n.dataId).values, i = t6.makeTensorInfo(o.shape, "complex64"), p = t6.data.get(i.dataId);
+ return p.complexTensorInfos = { real: t6.makeTensorInfo(o.shape, "float32", s), imag: t6.makeTensorInfo(n.shape, "float32", a) }, i;
}
-var NN = { kernelName: aa, backendName: "cpu", kernelFunc: qt };
-function Yp(r, e, t10 = "float32") {
- if (t10 === "complex64") {
- let n = Yp(r, e, "float32"), s = Yp(r, e, "float32");
- return qt({ inputs: { real: n, imag: s }, backend: r });
+var rT = { kernelName: ei, backendName: "cpu", kernelFunc: Ht };
+function Hp(r, e, t6 = "float32") {
+ if (t6 === "complex64") {
+ let n = Hp(r, e, "float32"), s = Hp(r, e, "float32");
+ return Ht({ inputs: { real: n, imag: s }, backend: r });
}
- let o = x.makeZerosTypedArray(x.sizeFromShape(e), t10);
- return r.makeTensorInfo(e, t10, o);
+ let o = y.makeZerosTypedArray(y.sizeFromShape(e), t6);
+ return r.makeTensorInfo(e, t6, o);
}
function ar(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
- return t10.incRef(o.dataId), { dataId: o.dataId, shape: o.shape, dtype: o.dtype };
+ let { inputs: e, backend: t6 } = r, { x: o } = e;
+ return t6.incRef(o.dataId), { dataId: o.dataId, shape: o.shape, dtype: o.dtype };
}
-var _N = { kernelName: uo, backendName: "cpu", kernelFunc: ar };
-function Wo(r) {
- let { inputs: e, backend: t10 } = r, { input: o } = e, n = t10.data.get(o.dataId).complexTensorInfos.real, s = t10.data.get(n.dataId).values;
- return t10.makeTensorInfo(n.shape, n.dtype, s);
+var oT = { kernelName: mo, backendName: "cpu", kernelFunc: ar };
+function wo(r) {
+ let { inputs: e, backend: t6 } = r, { input: o } = e, n = t6.data.get(o.dataId).complexTensorInfos.real, s = t6.data.get(n.dataId).values;
+ return t6.makeTensorInfo(n.shape, n.dtype, s);
}
-var EN = { kernelName: la, backendName: "cpu", kernelFunc: Wo };
-function tI(r, e, t10, o) {
+var nT = { kernelName: ai, backendName: "cpu", kernelFunc: wo };
+function YC(r, e, t6, o) {
if (o === "int32") {
let n = Int32Array.from(r);
return [e, "int32", n];
}
if (o === "bool") {
- let n = x.toTypedArray([0], t10), [s, a] = Le((i, p) => i !== p ? 1 : 0)(e, [], r, n, "bool");
+ let n = y.toTypedArray([0], t6), [s, a] = Be((i, p) => i !== p ? 1 : 0)(e, [], r, n, "bool");
return [a, "bool", s];
}
- throw new Error(`Error in Cast: failed to cast ${t10} to ${o}`);
+ throw new Error(`Error in Cast: failed to cast ${t6} to ${o}`);
}
-function Uo(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { dtype: s } = o;
+function Io(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { dtype: s } = o;
if (s === "complex64") {
if (n.dtype === "complex64")
- return ar({ inputs: { x: n }, backend: t10 });
- let c = Yp(t10, n.shape, n.dtype), l = Uo({ inputs: { x: n }, backend: t10, attrs: { dtype: "float32" } }), m = qt({ inputs: { real: l, imag: c }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(c), t10.disposeIntermediateTensorInfo(l), m;
+ return ar({ inputs: { x: n }, backend: t6 });
+ let c = Hp(t6, n.shape, n.dtype), l = Io({ inputs: { x: n }, backend: t6, attrs: { dtype: "float32" } }), m = Ht({ inputs: { real: l, imag: c }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(c), t6.disposeIntermediateTensorInfo(l), m;
}
if (n.dtype === "complex64") {
- let c = Wo({ inputs: { input: n }, backend: t10 }), l = Uo({ inputs: { x: c }, backend: t10, attrs: { dtype: s } });
- return t10.disposeIntermediateTensorInfo(c), l;
+ let c = wo({ inputs: { input: n }, backend: t6 }), l = Io({ inputs: { x: c }, backend: t6, attrs: { dtype: s } });
+ return t6.disposeIntermediateTensorInfo(c), l;
}
- if (!x.hasEncodingLoss(n.dtype, s)) {
- let c = ar({ inputs: { x: n }, backend: t10 });
+ if (!y.hasEncodingLoss(n.dtype, s)) {
+ let c = ar({ inputs: { x: n }, backend: t6 });
return { dataId: c.dataId, shape: c.shape, dtype: s };
}
- let a = t10.data.get(n.dataId).values, [i, p, u] = tI(a, n.shape, n.dtype, s);
- return t10.makeTensorInfo(i, p, u);
+ let a = t6.data.get(n.dataId).values, [i, p, u] = YC(a, n.shape, n.dtype, s);
+ return t6.makeTensorInfo(i, p, u);
}
-var $N = { kernelName: to, backendName: "cpu", kernelFunc: Uo };
-function Ye(r, e, t10, o) {
- return t10 == null ? ({ inputs: n, backend: s }) => {
+var sT = { kernelName: co, backendName: "cpu", kernelFunc: Io };
+function Qe(r, e, t6, o) {
+ return t6 == null ? ({ inputs: n, backend: s }) => {
let { a, b: i } = n, p = s;
K([a, i], r);
- let u = p.data.get(a.dataId).values, c = p.data.get(i.dataId).values, l = a.dtype === "string" ? I.fromUint8ToStringArray(u) : u, m = a.dtype === "string" ? I.fromUint8ToStringArray(c) : c, f = o || a.dtype, [d, h] = e(a.shape, i.shape, l, m, f);
- return p.makeTensorInfo(h, f, d);
+ let u = p.data.get(a.dataId).values, c = p.data.get(i.dataId).values, l = a.dtype === "string" ? S.fromUint8ToStringArray(u) : u, m = a.dtype === "string" ? S.fromUint8ToStringArray(c) : c, d = o || a.dtype, [f, h] = e(a.shape, i.shape, l, m, d);
+ return p.makeTensorInfo(h, d, f);
} : ({ inputs: n, backend: s }) => {
let { a, b: i } = n, p = s;
if (a.dtype === "complex64" || i.dtype === "complex64") {
- let u = Uo({ inputs: { x: a }, backend: p, attrs: { dtype: "complex64" } }), c = p.data.get(u.dataId), l = c.complexTensorInfos.real, m = c.complexTensorInfos.imag, f = p.data.get(l.dataId).values, d = p.data.get(m.dataId).values, h = Uo({ inputs: { x: i }, backend: p, attrs: { dtype: "complex64" } }), g = p.data.get(h.dataId), y = g.complexTensorInfos.real, b = g.complexTensorInfos.imag, C = p.data.get(y.dataId).values, w = p.data.get(b.dataId).values, [k, _, E] = t10(a.shape, i.shape, f, d, C, w), R = p.makeTensorInfo(E, "float32", k), A = p.makeTensorInfo(E, "float32", _), D = qt({ inputs: { real: R, imag: A }, backend: p });
- return p.disposeIntermediateTensorInfo(u), p.disposeIntermediateTensorInfo(h), p.disposeIntermediateTensorInfo(R), p.disposeIntermediateTensorInfo(A), D;
+ let u = Io({ inputs: { x: a }, backend: p, attrs: { dtype: "complex64" } }), c = p.data.get(u.dataId), l = c.complexTensorInfos.real, m = c.complexTensorInfos.imag, d = p.data.get(l.dataId).values, f = p.data.get(m.dataId).values, h = Io({ inputs: { x: i }, backend: p, attrs: { dtype: "complex64" } }), g = p.data.get(h.dataId), x = g.complexTensorInfos.real, b = g.complexTensorInfos.imag, C = p.data.get(x.dataId).values, w = p.data.get(b.dataId).values, [k, _, $] = t6(a.shape, i.shape, d, f, C, w), A = p.makeTensorInfo($, "float32", k), R = p.makeTensorInfo($, "float32", _), D = Ht({ inputs: { real: A, imag: R }, backend: p });
+ return p.disposeIntermediateTensorInfo(u), p.disposeIntermediateTensorInfo(h), p.disposeIntermediateTensorInfo(A), p.disposeIntermediateTensorInfo(R), D;
} else {
- let u = p.data.get(a.dataId).values, c = p.data.get(i.dataId).values, l = o || a.dtype, [m, f] = e(a.shape, i.shape, u, c, l);
- return p.makeTensorInfo(f, l, m);
+ let u = p.data.get(a.dataId).values, c = p.data.get(i.dataId).values, l = o || a.dtype, [m, d] = e(a.shape, i.shape, u, c, l);
+ return p.makeTensorInfo(d, l, m);
}
};
}
-function Qp(r) {
- return (e, t10, o, n, s, a) => {
- let i = I.assertAndGetBroadcastShape(e, t10), p = x.sizeFromShape(i), u = i.length, c = x.computeStrides(i), l = x.getTypedArrayFromDType("float32", p), m = x.getTypedArrayFromDType("float32", p), f = I.getBroadcastDims(e, i), d = I.getBroadcastDims(t10, i), h = I.mergeRealAndImagArrays(o, n), g = I.mergeRealAndImagArrays(s, a), y = e.length, b = x.computeStrides(e), C = t10.length, w = x.computeStrides(t10);
- if (f.length + d.length === 0)
+function qp(r) {
+ return (e, t6, o, n, s, a) => {
+ let i = S.assertAndGetBroadcastShape(e, t6), p = y.sizeFromShape(i), u = i.length, c = y.computeStrides(i), l = y.getTypedArrayFromDType("float32", p), m = y.getTypedArrayFromDType("float32", p), d = S.getBroadcastDims(e, i), f = S.getBroadcastDims(t6, i), h = S.mergeRealAndImagArrays(o, n), g = S.mergeRealAndImagArrays(s, a), x = e.length, b = y.computeStrides(e), C = t6.length, w = y.computeStrides(t6);
+ if (d.length + f.length === 0)
for (let k = 0; k < l.length; k++) {
- let _ = k % h.length, E = k % g.length, R = r(h[_ * 2], h[_ * 2 + 1], g[E * 2], g[E * 2 + 1]);
- l[k] = R.real, m[k] = R.imag;
+ let _ = k % h.length, $ = k % g.length, A = r(h[_ * 2], h[_ * 2 + 1], g[$ * 2], g[$ * 2 + 1]);
+ l[k] = A.real, m[k] = A.imag;
}
else
for (let k = 0; k < l.length; k++) {
- let _ = x.indexToLoc(k, u, c), E = _.slice(-y);
- f.forEach((M) => E[M] = 0);
- let R = x.locToIndex(E, y, b), A = _.slice(-C);
- d.forEach((M) => A[M] = 0);
- let D = x.locToIndex(A, C, w), O = r(h[R * 2], h[R * 2 + 1], g[D * 2], g[D * 2 + 1]);
- l[k] = O.real, m[k] = O.imag;
+ let _ = y.indexToLoc(k, u, c), $ = _.slice(-x);
+ d.forEach((M) => $[M] = 0);
+ let A = y.locToIndex($, x, b), R = _.slice(-C);
+ f.forEach((M) => R[M] = 0);
+ let D = y.locToIndex(R, C, w), P = r(h[A * 2], h[A * 2 + 1], g[D * 2], g[D * 2 + 1]);
+ l[k] = P.real, m[k] = P.imag;
}
return [l, m, i];
};
}
-var rI = Le((r, e) => r + e);
-var X6 = Qp((r, e, t10, o) => ({ real: r + t10, imag: e + o }));
-var Hs = Ye(_r, rI, X6);
-var RN = { kernelName: _r, backendName: "cpu", kernelFunc: Hs };
-function Zp(r, e, t10, o, n) {
- let s = x.sizeFromShape(o), a = x.makeZerosTypedArray(n, t10);
+var QC = Be((r, e) => r + e);
+var x6 = qp((r, e, t6, o) => ({ real: r + t6, imag: e + o }));
+var js = Qe(eo, QC, x6);
+var aT = { kernelName: eo, backendName: "cpu", kernelFunc: js };
+function Kp(r, e, t6, o, n) {
+ let s = y.sizeFromShape(o), a = y.makeZerosTypedArray(n, t6);
for (let i = 0; i < r.length; i++) {
let p = r[i];
if (p < 0)
@@ -11747,60 +11793,60 @@ function Zp(r, e, t10, o, n) {
}
return a;
}
-function yd(r, e, t10, o = false) {
- let n = r.shape[0], s = r.shape[1], a = ne([n, t10], e.dtype);
+function uf(r, e, t6, o = false) {
+ let n = r.shape[0], s = r.shape[1], a = le([n, t6], e.dtype);
for (let i = 0; i < n; i++)
for (let p = 0; p < s; p++) {
let u = r.get(i, p);
if (u < 0)
throw new Error("Input x must be non-negative!");
- u >= t10 || (o ? a.set(1, i, u) : e.size > 0 ? a.set(a.get(i, u) + e.get(i, p), i, u) : a.set(a.get(i, u) + 1, i, u));
+ u >= t6 || (o ? a.set(1, i, u) : e.size > 0 ? a.set(a.get(i, u) + e.get(i, p), i, u) : a.set(a.get(i, u) + 1, i, u));
}
return a;
}
function vr(r) {
- return (e, t10, o) => {
- let n = x.getTypedArrayFromDType(t10, e.length);
+ return (e, t6, o) => {
+ let n = y.getTypedArrayFromDType(t6, e.length);
for (let s = 0; s < e.length; ++s)
n[s] = r(e[s], o);
return n;
};
}
-function we(r, e, t10) {
+function Ie(r, e, t6) {
return ({ inputs: o, attrs: n, backend: s }) => {
let { x: a } = o;
- if (K(a, r), a.dtype === "string" || t10 === "string")
+ if (K(a, r), a.dtype === "string" || t6 === "string")
throw new Error("unaryKernelFunc does not support string input/output");
- let i = s, p = i.data.get(a.dataId).values, u = x.sizeFromShape(a.shape), c = t10 || a.dtype, l = x.getArrayFromDType(c, u);
+ let i = s, p = i.data.get(a.dataId).values, u = y.sizeFromShape(a.shape), c = t6 || a.dtype, l = y.getArrayFromDType(c, u);
for (let m = 0; m < u; ++m)
l[m] = e(p[m], n);
return i.makeTensorInfo(a.shape, c, l);
};
}
-function Go(r, e, t10) {
+function vo(r, e, t6) {
return ({ inputs: o, attrs: n, backend: s }) => {
let { x: a } = o;
- if (K(a, r), a.dtype === "string" || t10 === "string")
+ if (K(a, r), a.dtype === "string" || t6 === "string")
throw new Error("unaryKernelFunc does not support string input/output");
- let i = s, p = i.data.get(a.dataId).values, u = t10 || a.dtype, c = e(p, u, n);
+ let i = s, p = i.data.get(a.dataId).values, u = t6 || a.dtype, c = e(p, u, n);
return i.makeTensorInfo(a.shape, u, c);
};
}
-var oI = vr((r) => Math.ceil(r));
-var Y6 = Go(ro, oI);
-var AN = { kernelName: ro, backendName: "cpu", kernelFunc: Y6 };
-function Iu(r, e, t10, o) {
- let n = x.getArrayFromDType(t10, x.sizeFromShape(e));
- if (o && t10 !== "string") {
+var ZC = vr((r) => Math.ceil(r));
+var y6 = vo(Uo, ZC);
+var iT = { kernelName: Uo, backendName: "cpu", kernelFunc: y6 };
+function Su(r, e, t6, o) {
+ let n = y.getArrayFromDType(t6, y.sizeFromShape(e));
+ if (o && t6 !== "string") {
let s = 0;
r.forEach((a) => {
- let i = x.sizeFromShape(a.shape);
+ let i = y.sizeFromShape(a.shape);
n.set(a.vals, s), s += i;
});
} else {
let s = 0;
r.forEach((a) => {
- let i = t10 === "string" ? I.fromUint8ToStringArray(a.vals) : a.vals, p = 0;
+ let i = t6 === "string" ? S.fromUint8ToStringArray(a.vals) : a.vals, p = 0;
for (let u = 0; u < a.shape[0]; ++u) {
let c = u * e[1] + s;
for (let l = 0; l < a.shape[1]; ++l)
@@ -11811,35 +11857,35 @@ function Iu(r, e, t10, o) {
}
return n;
}
-var nI = Le((r, e) => r === e ? 1 : 0);
-var sI = Ye(oo, nI, null, "bool");
-var FN = { kernelName: oo, backendName: "cpu", kernelFunc: sI };
-var aI = vr((r) => Math.exp(r));
-var iI = Go(no, aI, "float32");
-var DN = { kernelName: no, backendName: "cpu", kernelFunc: iI };
-var uI = vr((r) => Math.expm1(r));
-var Q6 = Go(wn, uI);
-var PN = { kernelName: wn, backendName: "cpu", kernelFunc: Q6 };
-var pI = vr((r) => Math.floor(r));
-var Z6 = Go(so, pI);
-var ON = { kernelName: so, backendName: "cpu", kernelFunc: Z6 };
-function bd(r, e, t10, o, n, s, a, i, p) {
- let u = ne([o, s], t10);
+var JC = Be((r, e) => r === e ? 1 : 0);
+var eS = Qe(tn, JC, null, "bool");
+var uT = { kernelName: tn, backendName: "cpu", kernelFunc: eS };
+var tS = vr((r) => Math.exp(r));
+var rS = vo(rn, tS, "float32");
+var pT = { kernelName: rn, backendName: "cpu", kernelFunc: rS };
+var oS = vr((r) => Math.expm1(r));
+var b6 = vo(da, oS);
+var cT = { kernelName: da, backendName: "cpu", kernelFunc: b6 };
+var nS = vr((r) => Math.floor(r));
+var C6 = vo(nn, nS);
+var lT = { kernelName: nn, backendName: "cpu", kernelFunc: C6 };
+function pf(r, e, t6, o, n, s, a, i, p) {
+ let u = le([o, s], t6);
for (let c = 0; c < o; c++) {
let l = [], m = 0;
- for (let f = 0; f < n; f++) {
- let d = r[c * n + f];
- m += d * a[f], l.push(d);
+ for (let d = 0; d < n; d++) {
+ let f = r[c * n + d];
+ m += f * a[d], l.push(f);
}
if (m < 0 || m >= p / s)
throw new Error(`Invalid indices: ${l} does not index into ${i}`);
- for (let f = 0; f < s; f++)
- u.values[c * s + f] = e.get(...e.indexToLoc(m * s + f));
+ for (let d = 0; d < s; d++)
+ u.values[c * s + d] = e.get(...e.indexToLoc(m * s + d));
}
return u;
}
-function Cd(r, e, t10) {
- let o = ne(t10, r.dtype);
+function cf(r, e, t6) {
+ let o = le(t6, r.dtype);
for (let n = 0; n < o.size; ++n) {
let a = o.indexToLoc(n).slice(), i = a[0], p = a[2], u = e.locToIndex([i, p]);
a[2] = e.values[u];
@@ -11848,30 +11894,30 @@ function Cd(r, e, t10) {
}
return o;
}
-var cI = Le((r, e) => r > e ? 1 : 0);
-var J6 = Ye(ao, cI, null, "bool");
-var MN = { kernelName: ao, backendName: "cpu", kernelFunc: J6 };
-var lI = Le((r, e) => r >= e ? 1 : 0);
-var ej = Ye(io, lI, null, "bool");
-var LN = { kernelName: io, backendName: "cpu", kernelFunc: ej };
-var mI = Le((r, e) => r < e ? 1 : 0);
-var tj = Ye(po, mI, null, "bool");
-var BN = { kernelName: po, backendName: "cpu", kernelFunc: tj };
-var fI = Le((r, e) => r <= e ? 1 : 0);
-var rj = Ye(co, fI, null, "bool");
-var VN = { kernelName: co, backendName: "cpu", kernelFunc: rj };
-function Id(r, e, t10) {
- let o = (e - r) / (t10 - 1), n = x.makeZerosTypedArray(t10, "float32");
+var sS = Be((r, e) => r > e ? 1 : 0);
+var S6 = Qe(pn, sS, null, "bool");
+var mT = { kernelName: pn, backendName: "cpu", kernelFunc: S6 };
+var aS = Be((r, e) => r >= e ? 1 : 0);
+var w6 = Qe(cn, aS, null, "bool");
+var dT = { kernelName: cn, backendName: "cpu", kernelFunc: w6 };
+var iS = Be((r, e) => r < e ? 1 : 0);
+var I6 = Qe(dn, iS, null, "bool");
+var fT = { kernelName: dn, backendName: "cpu", kernelFunc: I6 };
+var uS = Be((r, e) => r <= e ? 1 : 0);
+var v6 = Qe(fn, uS, null, "bool");
+var hT = { kernelName: fn, backendName: "cpu", kernelFunc: v6 };
+function lf(r, e, t6) {
+ let o = (e - r) / (t6 - 1), n = y.makeZerosTypedArray(t6, "float32");
n[0] = r;
for (let s = 1; s < n.length; s++)
n[s] = n[s - 1] + o;
return n;
}
-var dI = vr((r) => Math.log(r));
-var oj = Go(lo, dI);
-var zN = { kernelName: lo, backendName: "cpu", kernelFunc: oj };
-function wd(r, e, t10, o) {
- let n = x.getTypedArrayFromDType(o, x.sizeFromShape(t10));
+var pS = vr((r) => Math.log(r));
+var k6 = vo(hn, pS);
+var gT = { kernelName: hn, backendName: "cpu", kernelFunc: k6 };
+function mf(r, e, t6, o) {
+ let n = y.getTypedArrayFromDType(o, y.sizeFromShape(t6));
for (let s = 0; s < n.length; ++s) {
let a = s * e, i = r[a];
for (let p = 0; p < e; ++p) {
@@ -11882,81 +11928,81 @@ function wd(r, e, t10, o) {
}
return n;
}
-var hI = Le((r, e) => Math.max(r, e));
-var nj = Ye(mo, hI);
-var WN = { kernelName: mo, backendName: "cpu", kernelFunc: nj };
-var gI = Le((r, e) => Math.min(r, e));
-var sj = Ye(fo, gI);
-var UN = { kernelName: fo, backendName: "cpu", kernelFunc: sj };
-var Cl = Le((r, e) => r * e);
-var aj = Qp((r, e, t10, o) => ({ real: r * t10 - e * o, imag: r * o + e * t10 }));
-var wu = Ye(ho, Cl, aj);
-var GN = { kernelName: ho, backendName: "cpu", kernelFunc: wu };
-function xI(r, e, t10) {
- let o = x.createScalarValue(-1, t10);
- return Cl([], e, o, r, t10);
+var cS = Be((r, e) => Math.max(r, e));
+var N6 = Qe(bn, cS);
+var xT = { kernelName: bn, backendName: "cpu", kernelFunc: N6 };
+var lS = Be((r, e) => Math.min(r, e));
+var T6 = Qe(In, lS);
+var yT = { kernelName: In, backendName: "cpu", kernelFunc: T6 };
+var ml = Be((r, e) => r * e);
+var _6 = qp((r, e, t6, o) => ({ real: r * t6 - e * o, imag: r * o + e * t6 }));
+var wu = Qe(kn, ml, _6);
+var bT = { kernelName: kn, backendName: "cpu", kernelFunc: wu };
+function mS(r, e, t6) {
+ let o = y.createScalarValue(-1, t6);
+ return ml([], e, o, r, t6);
}
-function ij(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
+function E6(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e;
K(o, "neg");
- let n = t10.data.get(o.dataId).values, [s, a] = xI(n, o.shape, o.dtype);
- return t10.makeTensorInfo(a, o.dtype, s);
+ let n = t6.data.get(o.dataId).values, [s, a] = mS(n, o.shape, o.dtype);
+ return t6.makeTensorInfo(a, o.dtype, s);
}
-var HN = { kernelName: Pn, backendName: "cpu", kernelFunc: ij };
-var yI = Le((r, e) => r !== e ? 1 : 0);
-var uj = Ye(go, yI, null, "bool");
-var qN = { kernelName: go, backendName: "cpu", kernelFunc: uj };
-function Jp(r, e, t10, o, n) {
- let s = e.length, a = x.sizeFromShape(e), i = x.computeStrides(e), p = x.computeStrides(n), u = x.getTypedArrayFromDType(t10, x.sizeFromShape(n));
+var CT = { kernelName: ws, backendName: "cpu", kernelFunc: E6 };
+var dS = Be((r, e) => r !== e ? 1 : 0);
+var $6 = Qe(Nn, dS, null, "bool");
+var ST = { kernelName: Nn, backendName: "cpu", kernelFunc: $6 };
+function jp(r, e, t6, o, n) {
+ let s = e.length, a = y.sizeFromShape(e), i = y.computeStrides(e), p = y.computeStrides(n), u = y.getTypedArrayFromDType(t6, y.sizeFromShape(n));
for (let c = 0; c < a; ++c) {
- let l = x.indexToLoc(c, s, i), m = new Array(l.length);
- for (let d = 0; d < m.length; d++)
- m[d] = l[o[d]];
- let f = x.locToIndex(m, s, p);
- u[f] = r[c];
+ let l = y.indexToLoc(c, s, i), m = new Array(l.length);
+ for (let f = 0; f < m.length; f++)
+ m[f] = l[o[f]];
+ let d = y.locToIndex(m, s, p);
+ u[d] = r[c];
}
return u;
}
-function bt(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { x: n } = e, { perm: s } = t10;
+function Ct(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { x: n } = e, { perm: s } = t6;
K(n, "transpose");
let a = n.shape.length, i = new Array(a);
for (let l = 0; l < i.length; l++)
i[l] = n.shape[s[l]];
- let p = o.data.get(n.dataId).values, u = Jp(p, n.shape, n.dtype, s, i);
+ let p = o.data.get(n.dataId).values, u = jp(p, n.shape, n.dtype, s, i);
return { dataId: o.write(u, i, n.dtype), shape: i, dtype: n.dtype };
}
-var KN = { kernelName: Mr, backendName: "cpu", kernelFunc: bt };
-function bI(r, e, t10, o) {
- let [n, s] = I.computeOutAndReduceShapes(r, o), a = ct(e, "int32"), i = x.makeZerosTypedArray(x.sizeFromShape(n), a), p = x.sizeFromShape(s);
+var wT = { kernelName: ro, backendName: "cpu", kernelFunc: Ct };
+function fS(r, e, t6, o) {
+ let [n, s] = S.computeOutAndReduceShapes(r, o), a = dt(e, "int32"), i = y.makeZerosTypedArray(y.sizeFromShape(n), a), p = y.sizeFromShape(s);
for (let u = 0; u < i.length; ++u) {
let c = u * p, l = 1;
for (let m = 0; m < p; ++m)
- l *= t10[c + m];
+ l *= t6[c + m];
i[u] = l;
}
return { outVals: i, outShape: n, outDtype: a };
}
-function pj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
+function A6(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
K(n, "prod");
- let i = n.shape.length, p = x.parseAxisParam(s, n.shape), u = I.getAxesPermutation(p, i), c = p, l = n, m = [];
- u != null && (l = bt({ inputs: { x: n }, backend: t10, attrs: { perm: u } }), m.push(l), c = I.getInnerMostAxes(c.length, i));
- let f = t10.data.get(l.dataId).values, { outVals: d, outShape: h, outDtype: g } = bI(l.shape, l.dtype, f, c), y = h;
- return a && (y = I.expandShapeToKeepDim(h, p)), m.forEach((b) => t10.disposeIntermediateTensorInfo(b)), t10.makeTensorInfo(y, g, d);
+ let i = n.shape.length, p = y.parseAxisParam(s, n.shape), u = S.getAxesPermutation(p, i), c = p, l = n, m = [];
+ u != null && (l = Ct({ inputs: { x: n }, backend: t6, attrs: { perm: u } }), m.push(l), c = S.getInnerMostAxes(c.length, i));
+ let d = t6.data.get(l.dataId).values, { outVals: f, outShape: h, outDtype: g } = fS(l.shape, l.dtype, d, c), x = h;
+ return a && (x = S.expandShapeToKeepDim(h, p)), m.forEach((b) => t6.disposeIntermediateTensorInfo(b)), t6.makeTensorInfo(x, g, f);
}
-var jN = { kernelName: Ao, backendName: "cpu", kernelFunc: pj };
-function cj(r, e, t10) {
+var IT = { kernelName: Fn, backendName: "cpu", kernelFunc: A6 };
+function R6(r, e, t6) {
r.forEach((o, n) => {
- if (o < 0 || o >= t10) {
- let s = x.indexToLoc(n, e.length, x.computeStrides(e)).join(",");
- throw new Error(`indices[${s}] = ${o} is not in [0, ${t10})`);
+ if (o < 0 || o >= t6) {
+ let s = y.indexToLoc(n, e.length, y.computeStrides(e)).join(",");
+ throw new Error(`indices[${s}] = ${o} is not in [0, ${t6})`);
}
});
}
-function lj(r, e) {
- for (let t10 = 0; t10 < r.length; ++t10) {
- let o = r[t10], n = t10 === r.length - 1 ? e : r[t10 + 1].length;
+function F6(r, e) {
+ for (let t6 = 0; t6 < r.length; ++t6) {
+ let o = r[t6], n = t6 === r.length - 1 ? e : r[t6 + 1].length;
if (o.length === 0)
throw new Error("Ragged splits may not be empty");
if (o[0] < 0)
@@ -11968,9 +12014,9 @@ function lj(r, e) {
throw new Error("Ragged splits must be sorted in ascending order");
}
}
-function mj(r, e, t10, o) {
- let n = [], s = 0, a = e.length - 1 + t10.length, i = new Array(a).fill(null).map(() => [0]);
- lj(t10, o);
+function D6(r, e, t6, o) {
+ let n = [], s = 0, a = e.length - 1 + t6.length, i = new Array(a).fill(null).map(() => [0]);
+ F6(t6, o);
let p = 1;
for (let u = 0; u < e.length - 1; ++u) {
p *= e[u];
@@ -11980,63 +12026,63 @@ function mj(r, e, t10, o) {
}
for (let u = 0; u < r.length; ++u) {
let c = r[u], l = r[u] + 1;
- for (let m = 0; m < t10.length; ++m) {
- let f = t10[m], d = m + e.length - 1;
- if (d >= 0) {
- let h = i[d], g = h[h.length - 1] - f[c];
- for (let y = c; y < l; ++y)
- i[d].push(f[y + 1] + g);
+ for (let m = 0; m < t6.length; ++m) {
+ let d = t6[m], f = m + e.length - 1;
+ if (f >= 0) {
+ let h = i[f], g = h[h.length - 1] - d[c];
+ for (let x = c; x < l; ++x)
+ i[f].push(d[x + 1] + g);
}
- c = f[c], l = f[l];
+ c = d[c], l = d[l];
}
l !== c && (n.push([c, l]), s += l - c);
}
return { outSplits: i, valueSlices: n, numValues: s };
}
-function fj(r) {
+function O6(r) {
let e = [];
- for (let t10 = 0; t10 < r.length; ++t10) {
- let o = r[t10].length, n = x.getArrayFromDType("int32", o);
- e.push(n), r[t10].forEach((s, a) => n[a] = s);
+ for (let t6 = 0; t6 < r.length; ++t6) {
+ let o = r[t6].length, n = y.getArrayFromDType("int32", o);
+ e.push(n), r[t6].forEach((s, a) => n[a] = s);
}
return e;
}
-function XN(r, e) {
- let t10 = r.slice(0, e);
- for (; t10.length < e; )
- t10.push(1);
+function vT(r, e) {
+ let t6 = r.slice(0, e);
+ for (; t6.length < e; )
+ t6.push(1);
for (let o = e; o < r.length; o++)
- t10[e - 1] *= r[o];
- return t10;
+ t6[e - 1] *= r[o];
+ return t6;
}
-function dj(r, e, t10, o, n, s) {
- let a = XN(e, 2)[1], i = XN(s, 2)[1], p = 0;
- for (let u of t10)
+function P6(r, e, t6, o, n, s) {
+ let a = vT(e, 2)[1], i = vT(s, 2)[1], p = 0;
+ for (let u of t6)
for (let c = u[0]; c < u[1]; ++c) {
for (let l = 0; l < o; ++l)
n[p * i + l] = r[c * a + l];
++p;
}
}
-function hj(r, e, t10, o, n) {
+function M6(r, e, t6, o, n) {
let s = e.slice();
s[0] = n;
- let a = x.getArrayFromDType(t10, x.sizeFromShape(s)), i = r.length, p = i === 0 ? 0 : i / e[0];
- return dj(r, e, o, p, a, s), [a, s];
+ let a = y.getArrayFromDType(t6, y.sizeFromShape(s)), i = r.length, p = i === 0 ? 0 : i / e[0];
+ return P6(r, e, o, p, a, s), [a, s];
}
-function Sd(r, e, t10, o, n, s, a, i) {
+function df(r, e, t6, o, n, s, a, i) {
if (r.length === 0)
throw new Error("paramsNestedSplits must be non empty");
if (e[0].length === 0)
throw new Error("Split tensors must not be scalars");
let p = e[0][0] - 1;
- if (cj(s, a, p), o.length === 0)
+ if (R6(s, a, p), o.length === 0)
throw new Error("params.rank must be nonzero");
- let u = o[0], { outSplits: c, valueSlices: l, numValues: m } = mj(s, a, r, u), f = fj(c), d = hj(t10, o, n, l, m);
- return [f, d[0], d[1]];
+ let u = o[0], { outSplits: c, valueSlices: l, numValues: m } = D6(s, a, r, u), d = O6(c), f = M6(t6, o, n, l, m);
+ return [d, f[0], f[1]];
}
-var YN = 2147483647;
-function vd(r, e, t10, o, n, s, a) {
+var kT = 2147483647;
+function ff(r, e, t6, o, n, s, a) {
if (e.length > 1)
throw new Error("starts must be a scalar or vector");
if (n.length > 1)
@@ -12048,100 +12094,100 @@ function vd(r, e, t10, o, n, s, a) {
for (let g = 1; g < c.length; ++g)
if (c[g] !== c[g - 1])
throw new Error("starts, limits, and deltas must have the same shape");
- let l = c.length === 0 ? 1 : c[0], m = x.getArrayFromDType("int32", l + 1);
+ let l = c.length === 0 ? 1 : c[0], m = y.getArrayFromDType("int32", l + 1);
m[0] = 0;
for (let g = 0; g < l; ++g) {
- let y = i ? r[0] : r[g], b = p ? o[0] : o[g], C = u ? s[0] : s[g];
+ let x = i ? r[0] : r[g], b = p ? o[0] : o[g], C = u ? s[0] : s[g];
if (C === 0)
throw new Error("Requires delta != 0");
let w;
- if (C > 0 && b < y || C < 0 && b > y)
+ if (C > 0 && b < x || C < 0 && b > x)
w = 0;
- else if (w = Math.ceil(Math.abs((b - y) / C)), w > YN)
- throw new Error(`Requires ((limit - start) / delta) <= ${YN}`);
+ else if (w = Math.ceil(Math.abs((b - x) / C)), w > kT)
+ throw new Error(`Requires ((limit - start) / delta) <= ${kT}`);
m[g + 1] = m[g] + w;
}
- let f = m[l], d = x.getArrayFromDType(t10, f), h = 0;
+ let d = m[l], f = y.getArrayFromDType(t6, d), h = 0;
for (let g = 0; g < l; ++g) {
- let y = m[g + 1] - m[g], b = i ? r[0] : r[g], C = u ? s[0] : s[g];
- for (let w = 0; w < y; ++w)
- d[h++] = b, b += C;
+ let x = m[g + 1] - m[g], b = i ? r[0] : r[g], C = u ? s[0] : s[g];
+ for (let w = 0; w < x; ++w)
+ f[h++] = b, b += C;
}
- return [m, d];
+ return [m, f];
}
-var Ho = I.RowPartitionType;
-var ec = class {
- constructor(e, t10, o, n, s, a, i, p, u, c) {
- this.shape = e, this.shapeShape = t10, this.values = o, this.valuesShape = n, this.valuesDType = s, this.defaultValue = a, this.defaultValueShape = i, this.rowPartitionValues = p, this.rowPartitionValuesShapes = u, this.rowPartitionTypes = I.getRowPartitionTypesHelper(c), this.raggedRank = I.getRaggedRank(this.rowPartitionTypes);
+var ko = S.RowPartitionType;
+var Xp = class {
+ constructor(e, t6, o, n, s, a, i, p, u, c) {
+ this.shape = e, this.shapeShape = t6, this.values = o, this.valuesShape = n, this.valuesDType = s, this.defaultValue = a, this.defaultValueShape = i, this.rowPartitionValues = p, this.rowPartitionValuesShapes = u, this.rowPartitionTypes = S.getRowPartitionTypesHelper(c), this.raggedRank = S.getRaggedRank(this.rowPartitionTypes);
}
getRowPartitionTypeByDimension(e) {
- return this.rowPartitionTypes[0] === Ho.FIRST_DIM_SIZE ? this.rowPartitionTypes[e + 1] : this.rowPartitionTypes[e];
+ return this.rowPartitionTypes[0] === ko.FIRST_DIM_SIZE ? this.rowPartitionTypes[e + 1] : this.rowPartitionTypes[e];
}
getRowPartitionTensor(e) {
- return this.rowPartitionTypes[0] === Ho.FIRST_DIM_SIZE ? this.rowPartitionValues[e + 1] : this.rowPartitionValues[e];
+ return this.rowPartitionTypes[0] === ko.FIRST_DIM_SIZE ? this.rowPartitionValues[e + 1] : this.rowPartitionValues[e];
}
getMaxWidth(e) {
- let t10 = this.getRowPartitionTensor(e - 1);
+ let t6 = this.getRowPartitionTensor(e - 1);
switch (this.getRowPartitionTypeByDimension(e - 1)) {
- case Ho.VALUE_ROWIDS:
- return ec.getMaxWidthValueRowID(t10);
- case Ho.ROW_SPLITS:
- return ec.getMaxWidthRowSplit(t10);
+ case ko.VALUE_ROWIDS:
+ return Xp.getMaxWidthValueRowID(t6);
+ case ko.ROW_SPLITS:
+ return Xp.getMaxWidthRowSplit(t6);
default:
- throw new Error(`Cannot handle partition type ${Ho[this.getRowPartitionTypeByDimension(e - 1)]}`);
+ throw new Error(`Cannot handle partition type ${ko[this.getRowPartitionTypeByDimension(e - 1)]}`);
}
}
static getMaxWidthRowSplit(e) {
- let t10 = e.length;
- if (t10 === 0 || t10 === 1)
+ let t6 = e.length;
+ if (t6 === 0 || t6 === 1)
return 0;
let o = 0;
- for (let n = 0; n < t10 - 1; ++n) {
+ for (let n = 0; n < t6 - 1; ++n) {
let s = e[n + 1] - e[n];
s > o && (o = s);
}
return o;
}
static getMaxWidthValueRowID(e) {
- let t10 = e.length;
- if (t10 === 0)
+ let t6 = e.length;
+ if (t6 === 0)
return 0;
let o = 0, n = e[0], s = 0;
- for (let a = 1; a < t10; ++a) {
+ for (let a = 1; a < t6; ++a) {
let i = e[a];
i !== n && (n = i, s = Math.max(a - o, s), o = a);
}
- return Math.max(t10 - o, s);
+ return Math.max(t6 - o, s);
}
- tensorShapeFromTensor(e, t10, o = true) {
- if (t10.length === 0) {
+ tensorShapeFromTensor(e, t6, o = true) {
+ if (t6.length === 0) {
if (e[0] === -1)
return [];
throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.");
}
- return ZN(e, o);
+ return TT(e, o);
}
calculateOutputSize(e) {
- let t10 = this.valuesShape, o = this.defaultValueShape;
- I.validateDefaultValueShape(o, t10);
- let n = this.tensorShapeFromTensor(this.shape, this.shapeShape), a = I.combineRaggedTensorToTensorShapes(this.raggedRank, n, t10);
+ let t6 = this.valuesShape, o = this.defaultValueShape;
+ S.validateDefaultValueShape(o, t6);
+ let n = this.tensorShapeFromTensor(this.shape, this.shapeShape), a = S.combineRaggedTensorToTensorShapes(this.raggedRank, n, t6);
a[0] < 0 && (a[0] = e);
for (let i = 1; i <= this.raggedRank; ++i)
a[i] < 0 && (a[i] = this.getMaxWidth(i));
return a;
}
- calculateFirstParentOutputIndex(e, t10, o) {
+ calculateFirstParentOutputIndex(e, t6, o) {
let n = Math.min(e, o), s = [], a = 0;
- for (let i = 0; i < n; ++i, a += t10)
+ for (let i = 0; i < n; ++i, a += t6)
s.push(a);
for (let i = n; i < e; ++i)
s.push(-1);
- return x.assert(s.length === e, () => "Final length of result must be equal to firstDimension."), s;
+ return y.assert(s.length === e, () => "Final length of result must be equal to firstDimension."), s;
}
- calculateOutputIndexRowSplit(e, t10, o, n) {
+ calculateOutputIndexRowSplit(e, t6, o, n) {
let s = e.length, a = [];
for (let i = 0; i < s - 1; ++i) {
- let p = e[i + 1] - e[i], u = Math.min(n, p), c = t10[i];
+ let p = e[i + 1] - e[i], u = Math.min(n, p), c = t6[i];
c === -1 && (u = 0);
for (let l = 0; l < u; ++l)
a.push(c), c += o;
@@ -12152,23 +12198,23 @@ var ec = class {
throw new Error("Invalid row split size.");
return a;
}
- calculateOutputIndexValueRowID(e, t10, o, n) {
+ calculateOutputIndexValueRowID(e, t6, o, n) {
let s = e.length, a = [];
if (s === 0)
return [];
let i = 0, p = e[0];
- if (p >= t10.length)
- throw new Error(`Got currentValueRowId=${p}, which is not less than ${t10.length}`);
- let u = t10[p];
+ if (p >= t6.length)
+ throw new Error(`Got currentValueRowId=${p}, which is not less than ${t6.length}`);
+ let u = t6[p];
a.push(u);
for (let c = 1; c < s; ++c) {
let l = e[c];
if (l === p)
u >= 0 && (++i, i < n ? u += o : u = -1);
else {
- if (i = 0, p = l, l >= t10.length)
- throw new Error(`Got nextValueRowId=${l} which is not less than ${t10.length}`);
- u = t10[l];
+ if (i = 0, p = l, l >= t6.length)
+ throw new Error(`Got nextValueRowId=${l} which is not less than ${t6.length}`);
+ u = t6[l];
}
a.push(u);
}
@@ -12176,97 +12222,97 @@ var ec = class {
throw new Error("Invalid row ids.");
return a;
}
- calculateOutputIndex(e, t10, o, n) {
+ calculateOutputIndex(e, t6, o, n) {
let s = this.getRowPartitionTensor(e), a = this.getRowPartitionTypeByDimension(e);
switch (a) {
- case Ho.VALUE_ROWIDS:
- return this.calculateOutputIndexValueRowID(s, t10, o, n);
- case Ho.ROW_SPLITS:
- if (s.length - 1 > t10.length)
- throw new Error(`Row partition size is greater than output size: ${s.length - 1} > ${t10.length}`);
- return this.calculateOutputIndexRowSplit(s, t10, o, n);
+ case ko.VALUE_ROWIDS:
+ return this.calculateOutputIndexValueRowID(s, t6, o, n);
+ case ko.ROW_SPLITS:
+ if (s.length - 1 > t6.length)
+ throw new Error(`Row partition size is greater than output size: ${s.length - 1} > ${t6.length}`);
+ return this.calculateOutputIndexRowSplit(s, t6, o, n);
default:
- throw new Error(`Unsupported partition type: ${Ho[a]}`);
+ throw new Error(`Unsupported partition type: ${ko[a]}`);
}
}
getFirstDimensionSize() {
let e = this.rowPartitionValues[0];
if (this.rowPartitionTypes.length === 0)
throw new Error("No row_partition_types given.");
- let t10 = this.rowPartitionTypes[0];
- switch (t10) {
- case Ho.FIRST_DIM_SIZE:
+ let t6 = this.rowPartitionTypes[0];
+ switch (t6) {
+ case ko.FIRST_DIM_SIZE:
return e[0];
- case Ho.VALUE_ROWIDS:
+ case ko.VALUE_ROWIDS:
throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");
- case Ho.ROW_SPLITS:
+ case ko.ROW_SPLITS:
return this.rowPartitionValuesShapes[0][0] - 1;
default:
- throw new Error(`Cannot handle type ${Ho[t10]}`);
+ throw new Error(`Cannot handle type ${ko[t6]}`);
}
}
compute() {
if (this.rowPartitionValues[0].length <= 0)
throw new Error("Invalid first partition input. Tensor requires at least one element.");
- let t10 = this.getFirstDimensionSize(), o = this.calculateOutputSize(t10), n = new Array(this.raggedRank + 1);
+ let t6 = this.getFirstDimensionSize(), o = this.calculateOutputSize(t6), n = new Array(this.raggedRank + 1);
n[n.length - 1] = 1;
for (let p = n.length - 2; p >= 0; --p)
n[p] = n[p + 1] * o[p + 1];
- let s = ZN(o, false), a = x.getArrayFromDType(this.valuesDType, x.sizeFromShape(s));
+ let s = TT(o, false), a = y.getArrayFromDType(this.valuesDType, y.sizeFromShape(s));
if (n[0] * o[0] > 0) {
- let p = this.calculateFirstParentOutputIndex(t10, n[0], o[0]);
+ let p = this.calculateFirstParentOutputIndex(t6, n[0], o[0]);
for (let u = 1; u <= this.raggedRank; ++u)
p = this.calculateOutputIndex(u - 1, p, n[u], o[u]);
this.setOutput(this.raggedRank, p, a, s);
}
return [s, a];
}
- setOutput(e, t10, o, n) {
+ setOutput(e, t6, o, n) {
if (o.length === 0)
return;
let s = this.values, a = o, i = n.slice();
i = i.slice(e + 1);
- let p = x.sizeFromShape(i), u = t10.length, c = this.defaultValue;
+ let p = y.sizeFromShape(i), u = t6.length, c = this.defaultValue;
if (c.length !== p && c.length !== 1) {
- let d = this.defaultValueShape;
- Ne(() => {
- let h = z(c, d);
- c = Ls(h, i).dataSync();
+ let f = this.defaultValueShape;
+ Ee(() => {
+ let h = z(c, f);
+ c = Ii(h, i).dataSync();
});
}
- let l = 0, m = 0, f = 0;
- for (let d = 0; d <= u; ++d) {
- let h = d < u ? t10[d] : -1;
- if (h === f) {
- ++f;
+ let l = 0, m = 0, d = 0;
+ for (let f = 0; f <= u; ++f) {
+ let h = f < u ? t6[f] : -1;
+ if (h === d) {
+ ++d;
continue;
}
- if (m < f) {
- let g = s.subarray(l * p), y = a.subarray(m * p), b = (f - m) * p;
- QN(y, g, b);
+ if (m < d) {
+ let g = s.subarray(l * p), x = a.subarray(m * p), b = (d - m) * p;
+ NT(x, g, b);
}
- if (d >= u) {
+ if (f >= u) {
let g = o.length;
h = Math.floor(g / p);
}
- if (h > f)
+ if (h > d)
if (this.defaultValue.length === 1)
- a.subarray(f * p, h * p).fill(this.defaultValue[0]), f = h;
+ a.subarray(d * p, h * p).fill(this.defaultValue[0]), d = h;
else
- for (; h > f; ) {
- let g = a.slice(f * p);
- QN(g, c, p), ++f;
+ for (; h > d; ) {
+ let g = a.slice(d * p);
+ NT(g, c, p), ++d;
}
- h < 0 ? (l = d + 1, m = f) : (l = d, m = f, f = m + 1);
+ h < 0 ? (l = f + 1, m = d) : (l = f, m = d, d = m + 1);
}
}
};
-function QN(r, e, t10) {
- for (let o = 0; o < t10; o++)
+function NT(r, e, t6) {
+ for (let o = 0; o < t6; o++)
r[o] = e[o];
}
-function ZN(r, e) {
- let t10 = [];
+function TT(r, e) {
+ let t6 = [];
for (let o of r) {
if (o < 0) {
if (!e)
@@ -12275,175 +12321,175 @@ function ZN(r, e) {
throw new Error(`Dimension ${o} must be >= -1`);
o = -1;
}
- t10.push(o);
+ t6.push(o);
}
- return t10;
+ return t6;
}
-function kd(r, e, t10, o, n, s, a, i, p, u) {
- return new ec(r, e, t10, o, n, s, a, i, p, u).compute();
+function hf(r, e, t6, o, n, s, a, i, p, u) {
+ return new Xp(r, e, t6, o, n, s, a, i, p, u).compute();
}
-function Su(r, e, t10, o) {
- let n = r === e, s = r < e && t10 < 0, a = e < r && t10 > 1;
+function Iu(r, e, t6, o) {
+ let n = r === e, s = r < e && t6 < 0, a = e < r && t6 > 1;
if (n || s || a)
- return x.makeZerosTypedArray(0, o);
- let i = Math.abs(Math.ceil((e - r) / t10)), p = x.makeZerosTypedArray(i, o);
- e < r && t10 === 1 && (t10 = -1), p[0] = r;
+ return y.makeZerosTypedArray(0, o);
+ let i = Math.abs(Math.ceil((e - r) / t6)), p = y.makeZerosTypedArray(i, o);
+ e < r && t6 === 1 && (t6 = -1), p[0] = r;
for (let u = 1; u < p.length; u++)
- p[u] = p[u - 1] + t10;
+ p[u] = p[u - 1] + t6;
return p;
}
-var CI = vr((r) => 1 / Math.sqrt(r));
-var gj = Go(xo, CI);
-var JN = { kernelName: xo, backendName: "cpu", kernelFunc: gj };
-function Aa(r, e, t10, o, n, s, a, i, p, u) {
+var hS = vr((r) => 1 / Math.sqrt(r));
+var L6 = vo(Vn, hS);
+var _T = { kernelName: Vn, backendName: "cpu", kernelFunc: L6 };
+function Ma(r, e, t6, o, n, s, a, i, p, u) {
let c = [o / n, n], l = r.values, m = e.values;
if (o === 0)
- return ne(t10, e.dtype);
- let f = ne(c, e.dtype);
- typeof p == "string" || typeof p == "number" ? f.values.fill(p) : typeof p == "boolean" && f.values.fill(+p);
- for (let d = 0; d < s; d++) {
+ return le(t6, e.dtype);
+ let d = le(c, e.dtype);
+ typeof p == "string" || typeof p == "number" ? d.values.fill(p) : typeof p == "boolean" && d.values.fill(+p);
+ for (let f = 0; f < s; f++) {
let h = [], g = 0;
- for (let y = 0; y < a; y++) {
- let b = l[d * a + y];
- h.push(b), g += b * i[y];
+ for (let x = 0; x < a; x++) {
+ let b = l[f * a + x];
+ h.push(b), g += b * i[x];
}
if (g < 0 || g >= o / n)
- throw new Error(`Invalid indices: ${h} does not index into ${t10}`);
- for (let y = 0; y < n; y++)
- u ? f.values[g * n + y] += m[d * n + y] : f.values[g * n + y] = e.rank === 0 ? m[0] : m[d * n + y];
+ throw new Error(`Invalid indices: ${h} does not index into ${t6}`);
+ for (let x = 0; x < n; x++)
+ u ? d.values[g * n + x] += m[f * n + x] : d.values[g * n + x] = e.rank === 0 ? m[0] : m[f * n + x];
}
- return f;
+ return d;
}
-var e2 = vr((r) => 1 / (1 + Math.exp(-r)));
-var II = we(yo, (r) => 1 / (1 + Math.exp(-r)));
-var t2 = { kernelName: yo, backendName: "cpu", kernelFunc: II };
-function vu(r, e, t10, o, n) {
- let s = et.isSliceContinous(o, e, t10), a = x.sizeFromShape(t10), i = x.computeStrides(o);
+var ET = vr((r) => 1 / (1 + Math.exp(-r)));
+var gS = Ie(Un, (r) => 1 / (1 + Math.exp(-r)));
+var $T = { kernelName: Un, backendName: "cpu", kernelFunc: gS };
+function vu(r, e, t6, o, n) {
+ let s = ut.isSliceContinous(o, e, t6), a = y.sizeFromShape(t6), i = y.computeStrides(o);
if (s) {
- let l = et.computeFlatOffset(e, i);
+ let l = ut.computeFlatOffset(e, i);
return n === "string" ? r.slice(l, l + a) : r.subarray(l, l + a);
}
- let p = n === "string" ? I.fromUint8ToStringArray(r) : r, u = ne(o, n, p), c = ne(t10, n);
+ let p = n === "string" ? S.fromUint8ToStringArray(r) : r, u = le(o, n, p), c = le(t6, n);
for (let l = 0; l < c.size; ++l) {
- let m = c.indexToLoc(l), f = m.map((d, h) => d + e[h]);
- c.set(u.get(...f), ...m);
+ let m = c.indexToLoc(l), d = m.map((f, h) => f + e[h]);
+ c.set(u.get(...d), ...m);
}
- return n === "string" ? I.fromStringArrayToUint8(c.values) : c.values;
+ return n === "string" ? S.fromStringArrayToUint8(c.values) : c.values;
}
-function qo(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { begin: s, size: a } = o;
+function No(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { begin: s, size: a } = o;
K(n, "slice");
- let [i, p] = et.parseSliceParams(n, s, a);
- et.assertParamsValid(n, i, p);
- let u = t10.data.get(n.dataId).values, c = vu(u, i, p, n.shape, n.dtype);
- return t10.makeTensorInfo(p, n.dtype, c);
+ let [i, p] = ut.parseSliceParams(n, s, a);
+ ut.assertParamsValid(n, i, p);
+ let u = t6.data.get(n.dataId).values, c = vu(u, i, p, n.shape, n.dtype);
+ return t6.makeTensorInfo(p, n.dtype, c);
}
-var r2 = { kernelName: qn, backendName: "cpu", kernelFunc: qo };
-function Td(r, e, t10, o, n, s, a) {
+var AT = { kernelName: _s, backendName: "cpu", kernelFunc: No };
+function gf(r, e, t6, o, n, s, a) {
let i = e[0], p = s[0], u = new Array(p), c = new Array(i), l = e[1];
if (p === 0) {
if (i !== 0)
- throw new Error(I.getSparseFillEmptyRowsIndicesDenseShapeMismatch(i));
- let g = x.getArrayFromDType(t10, 0), y = x.getArrayFromDType(n, 0);
- return [g, [0, l], y, u, c];
+ throw new Error(S.getSparseFillEmptyRowsIndicesDenseShapeMismatch(i));
+ let g = y.getArrayFromDType(t6, 0), x = y.getArrayFromDType(n, 0);
+ return [g, [0, l], x, u, c];
}
- let m = true, f = 0, d = new Array(p).fill(0);
+ let m = true, d = 0, f = new Array(p).fill(0);
for (let g = 0; g < i; ++g) {
- let y = r[g * l];
- if (y < 0)
- throw new Error(I.getSparseFillEmptyRowsNegativeIndexErrorMessage(g, y));
- if (y >= p)
- throw new Error(I.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(g, y, p));
- ++d[y], m = m && y >= f, f = y;
+ let x = r[g * l];
+ if (x < 0)
+ throw new Error(S.getSparseFillEmptyRowsNegativeIndexErrorMessage(g, x));
+ if (x >= p)
+ throw new Error(S.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(g, x, p));
+ ++f[x], m = m && x >= d, d = x;
}
let h = true;
for (let g = 0; g < p; ++g) {
- let y = d[g] === 0;
- u[g] = y, h = h && !y, d[g] = Math.max(d[g], 1), g > 0 && (d[g] += d[g - 1]);
+ let x = f[g] === 0;
+ u[g] = x, h = h && !x, f[g] = Math.max(f[g], 1), g > 0 && (f[g] += f[g - 1]);
}
if (h && m) {
- let g = r, y = o;
+ let g = r, x = o;
for (let b = 0; b < i; ++b)
c[b] = b;
- return [g, [i, l], y, u, c];
+ return [g, [i, l], x, u, c];
} else {
- let g = d[p - 1], y = x.getArrayFromDType(t10, g * l), b = x.getArrayFromDType(n, g), C = new Array(p).fill(0);
+ let g = f[p - 1], x = y.getArrayFromDType(t6, g * l), b = y.getArrayFromDType(n, g), C = new Array(p).fill(0);
for (let w = 0; w < i; ++w) {
- let k = r[w * l], _ = C[k], E = (k === 0 ? 0 : d[k - 1]) + _;
+ let k = r[w * l], _ = C[k], $ = (k === 0 ? 0 : f[k - 1]) + _;
C[k]++;
- for (let R = 0; R < l; ++R)
- y[E * l + R] = r[w * l + R];
- b[E] = o[w], c[w] = E;
+ for (let A = 0; A < l; ++A)
+ x[$ * l + A] = r[w * l + A];
+ b[$] = o[w], c[w] = $;
}
for (let w = 0; w < p; ++w)
if (C[w] === 0) {
- let _ = w === 0 ? 0 : d[w - 1];
- y[_ * l + 0] = w;
- for (let E = 1; E < l; ++E)
- y[_ * l + E] = 0;
+ let _ = w === 0 ? 0 : f[w - 1];
+ x[_ * l + 0] = w;
+ for (let $ = 1; $ < l; ++$)
+ x[_ * l + $] = 0;
b[_] = a;
}
- return [y, [g, l], b, u, c];
+ return [x, [g, l], b, u, c];
}
}
-function Nd(r, e, t10, o, n) {
- let s = x.sizeFromShape(o), a = e[0], i = n.length, p = [], u = 1, c = -1;
+function xf(r, e, t6, o, n) {
+ let s = y.sizeFromShape(o), a = e[0], i = n.length, p = [], u = 1, c = -1;
for (let g = 0; g < i; ++g) {
- let y = n[g];
- if (y === -1) {
+ let x = n[g];
+ if (x === -1) {
if (c !== -1)
- throw new Error(I.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(c, g));
+ throw new Error(S.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(c, g));
c = g, p.push(1);
} else {
- if (y < 0)
- throw new Error(I.getSparseReshapeNegativeOutputDimErrorMessage(g, y));
- u *= y, p.push(y);
+ if (x < 0)
+ throw new Error(S.getSparseReshapeNegativeOutputDimErrorMessage(g, x));
+ u *= x, p.push(x);
}
}
if (c !== -1) {
if (u <= 0)
- throw new Error(I.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage());
+ throw new Error(S.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage());
let g = Math.trunc(s / u);
if (u * g !== s)
- throw new Error(I.getSparseReshapeInputOutputMultipleErrorMessage(o, p));
+ throw new Error(S.getSparseReshapeInputOutputMultipleErrorMessage(o, p));
p[c] = g;
}
- if (x.sizeFromShape(p) !== s)
- throw new Error(I.getSparseReshapeInputOutputMismatchErrorMessage(o, p));
- let m = o.length, f = [];
+ if (y.sizeFromShape(p) !== s)
+ throw new Error(S.getSparseReshapeInputOutputMismatchErrorMessage(o, p));
+ let m = o.length, d = [];
if (m > 0) {
- f[m - 1] = 1;
+ d[m - 1] = 1;
for (let g = m - 2; g >= 0; --g)
- f[g] = f[g + 1] * o[g + 1];
+ d[g] = d[g + 1] * o[g + 1];
}
- let d = [];
+ let f = [];
if (i > 0) {
- d[i - 1] = 1;
+ f[i - 1] = 1;
for (let g = i - 2; g >= 0; --g)
- d[g] = d[g + 1] * p[g + 1];
+ f[g] = f[g + 1] * p[g + 1];
}
- let h = x.getArrayFromDType(t10, a * i);
+ let h = y.getArrayFromDType(t6, a * i);
for (let g = 0; g < a; ++g) {
- let y = 0;
+ let x = 0;
for (let b = 0; b < m; ++b)
- y += r[g * m + b] * f[b];
+ x += r[g * m + b] * d[b];
for (let b = 0; b < i; ++b)
- h[g * i + b] = Math.trunc(y / d[b]), y %= d[b];
+ h[g * i + b] = Math.trunc(x / f[b]), x %= f[b];
}
return [h, [a, i], p];
}
-function tc(r, e, t10, o, n, s = false, a = 0) {
+function Yp(r, e, t6, o, n, s = false, a = 0) {
let i = o.length, p = [e[0], r.length / e[0]], u = p[1], l = i > 0 ? n[i - 1] + 1 : 0;
if (l < 0)
- throw new Error(I.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
+ throw new Error(S.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
let m = e.slice();
m[0] = l;
- let f = m.reduce((C, w) => C * w, 1), d = x.getArrayFromDType(t10, f);
+ let d = m.reduce((C, w) => C * w, 1), f = y.getArrayFromDType(t6, d);
if (i === 0)
- return l > 0 && d.fill(a), [d, m];
+ return l > 0 && f.fill(a), [f, m];
if (l <= 0)
- throw new Error(I.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
- let h = 0, g = 1, y = 0, b = n[h];
+ throw new Error(S.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
+ let h = 0, g = 1, x = 0, b = n[h];
for (; ; ) {
let C = 0;
if (g < i) {
@@ -12452,97 +12498,97 @@ function tc(r, e, t10, o, n, s = false, a = 0) {
continue;
}
if (b >= C)
- throw new Error(I.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage());
+ throw new Error(S.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage());
}
if (b < 0 || b >= l)
- throw new Error(I.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(b, l));
- b > y && d.fill(a, y * u, b * u);
+ throw new Error(S.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(b, l));
+ b > x && f.fill(a, x * u, b * u);
for (let w = h; w < g; ++w) {
let k = o[w];
if (k < 0 || k >= p[0])
- throw new Error(I.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(w, o[w], p[0]));
+ throw new Error(S.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(w, o[w], p[0]));
for (let _ = 0; _ < u; _++)
- d[b * u + _] += r[k * u + _];
+ f[b * u + _] += r[k * u + _];
}
if (s)
for (let w = 0; w < u; w++)
- d[b * u + w] /= g - h;
- if (h = g, ++g, y = b + 1, b = C, g > i)
+ f[b * u + w] /= g - h;
+ if (h = g, ++g, x = b + 1, b = C, g > i)
break;
}
- return y < l && d.fill(a, y * u, l * u), [d, m];
+ return x < l && f.fill(a, x * u, l * u), [f, m];
}
-var o2 = vr((r) => Math.sqrt(r));
-var xj = we(bo, (r) => Math.sqrt(r));
-var n2 = { kernelName: bo, backendName: "cpu", kernelFunc: xj };
-var wI = Le((r, e) => {
- let t10 = r - e;
- return t10 * t10;
+var RT = vr((r) => Math.sqrt(r));
+var B6 = Ie(Gn, (r) => Math.sqrt(r));
+var FT = { kernelName: Gn, backendName: "cpu", kernelFunc: B6 };
+var xS = Be((r, e) => {
+ let t6 = r - e;
+ return t6 * t6;
});
-var yj = Ye(Co, wI);
-var s2 = { kernelName: Co, backendName: "cpu", kernelFunc: yj };
-function _d(r, e, t10, o) {
- let n = ne(r, e.dtype);
+var V6 = Qe(Kn, xS);
+var DT = { kernelName: Kn, backendName: "cpu", kernelFunc: V6 };
+function yf(r, e, t6, o) {
+ let n = le(r, e.dtype);
for (let s = 0; s < n.size; s++) {
let a = n.indexToLoc(s), i = new Array(a.length);
for (let p = 0; p < i.length; p++)
- i[p] = a[p] * t10[p] + o[p];
+ i[p] = a[p] * t6[p] + o[p];
n.set(e.get(...i), ...a);
}
return n;
}
-var SI = class {
- constructor(e, t10, o, n, s, a) {
- this.separator = x.encodeString(e), this.nGramWidths = t10, this.leftPad = x.encodeString(o), this.rightPad = x.encodeString(n), this.padWidth = s, this.preserveShort = a;
+var yS = class {
+ constructor(e, t6, o, n, s, a) {
+ this.separator = y.encodeString(e), this.nGramWidths = t6, this.leftPad = y.encodeString(o), this.rightPad = y.encodeString(n), this.padWidth = s, this.preserveShort = a;
}
getPadWidth(e) {
return Math.min(this.padWidth < 0 ? e - 1 : this.padWidth, e - 1);
}
- getNumNGrams(e, t10) {
- let o = this.getPadWidth(t10);
- return Math.max(0, e + 2 * o - t10 + 1);
+ getNumNGrams(e, t6) {
+ let o = this.getPadWidth(t6);
+ return Math.max(0, e + 2 * o - t6 + 1);
}
- createNGrams(e, t10, o, n, s, a) {
+ createNGrams(e, t6, o, n, s, a) {
for (let i = 0; i < s; ++i) {
- let p = this.getPadWidth(a), u = Math.max(0, p - i), c = Math.max(0, p - (s - (i + 1))), l = a - (u + c), m = t10 + (u > 0 ? 0 : i - p), f = 0;
- f += u * this.leftPad.length;
+ let p = this.getPadWidth(a), u = Math.max(0, p - i), c = Math.max(0, p - (s - (i + 1))), l = a - (u + c), m = t6 + (u > 0 ? 0 : i - p), d = 0;
+ d += u * this.leftPad.length;
for (let b = 0; b < l; ++b)
- f += e[m + b].length;
- f += c * this.rightPad.length;
- let d = u + c + l - 1;
- f += d * this.separator.length, o[n + i] = new Uint8Array(f);
- let h = o[n + i], g = 0, y = (b) => b.forEach((C) => h[g++] = C);
+ d += e[m + b].length;
+ d += c * this.rightPad.length;
+ let f = u + c + l - 1;
+ d += f * this.separator.length, o[n + i] = new Uint8Array(d);
+ let h = o[n + i], g = 0, x = (b) => b.forEach((C) => h[g++] = C);
for (let b = 0; b < u; ++b)
- y(this.leftPad), y(this.separator);
+ x(this.leftPad), x(this.separator);
for (let b = 0; b < l - 1; ++b)
- y(e[m + b]), y(this.separator);
+ x(e[m + b]), x(this.separator);
if (l > 0) {
- y(e[m + l - 1]);
+ x(e[m + l - 1]);
for (let b = 0; b < c; ++b)
- y(this.separator), y(this.rightPad);
+ x(this.separator), x(this.rightPad);
} else {
for (let b = 0; b < c - 1; ++b)
- y(this.rightPad), y(this.separator);
- y(this.rightPad);
+ x(this.rightPad), x(this.separator);
+ x(this.rightPad);
}
}
}
- compute(e, t10) {
- let o = e.length, n = t10.length;
+ compute(e, t6) {
+ let o = e.length, n = t6.length;
if (n > 0) {
- let p = t10[0];
+ let p = t6[0];
if (p !== 0)
throw new Error(`First split value must be 0, got ${p}`);
for (let u = 1; u < n; ++u) {
- let c = t10[u] >= p;
- if (c = c && t10[u] <= o, !c)
- throw new Error(`Invalid split value ${t10[u]}, must be in [${p}, ${o}]`);
- p = t10[u];
+ let c = t6[u] >= p;
+ if (c = c && t6[u] <= o, !c)
+ throw new Error(`Invalid split value ${t6[u]}, must be in [${p}, ${o}]`);
+ p = t6[u];
}
if (p !== o)
throw new Error(`Last split value must be data size. Expected ${o}, got ${p}`);
}
- let s = n - 1, a = x.getArrayFromDType("int32", n);
+ let s = n - 1, a = y.getArrayFromDType("int32", n);
if (o === 0 || n === 0) {
let p = new Array(o);
for (let u = 0; u <= s; ++u)
@@ -12551,32 +12597,32 @@ var SI = class {
}
a[0] = 0;
for (let p = 1; p <= s; ++p) {
- let u = t10[p] - t10[p - 1], c = 0;
+ let u = t6[p] - t6[p - 1], c = 0;
this.nGramWidths.forEach((l) => {
c += this.getNumNGrams(u, l);
}), this.preserveShort && u > 0 && c === 0 && (c = 1), a[p] = a[p - 1] + c;
}
let i = new Array(a[s]);
for (let p = 0; p < s; ++p) {
- let u = t10[p], c = a[p];
+ let u = t6[p], c = a[p];
if (this.nGramWidths.forEach((l) => {
- let m = t10[p + 1] - t10[p], f = this.getNumNGrams(m, l);
- this.createNGrams(e, u, i, c, f, l), c += f;
+ let m = t6[p + 1] - t6[p], d = this.getNumNGrams(m, l);
+ this.createNGrams(e, u, i, c, d, l), c += d;
}), this.preserveShort && c === a[p]) {
- let l = t10[p + 1] - t10[p];
+ let l = t6[p + 1] - t6[p];
if (l === 0)
continue;
- let m = l + 2 * this.padWidth, f = 1;
- this.createNGrams(e, u, i, c, f, m);
+ let m = l + 2 * this.padWidth, d = 1;
+ this.createNGrams(e, u, i, c, d, m);
}
}
return [i, a];
}
};
-function ku(r, e, t10, o, n, s, a, i) {
- return new SI(t10, o, n, s, a, i).compute(r, e);
+function ku(r, e, t6, o, n, s, a, i) {
+ return new yS(t6, o, n, s, a, i).compute(r, e);
}
-function bj(r, e, t10, o) {
+function z6(r, e, t6, o) {
if (!r.length)
return;
if (e.length === 0) {
@@ -12588,47 +12634,47 @@ function bj(r, e, t10, o) {
let s = e[0], a = r.indexOf(s);
for (; a !== -1; ) {
let i = r.subarray(0, a);
- (!t10 || i.length !== 0) && o.push(i), r = r.subarray(a + 1), a = r.indexOf(s);
+ (!t6 || i.length !== 0) && o.push(i), r = r.subarray(a + 1), a = r.indexOf(s);
}
- (!t10 || r.length !== 0) && o.push(r);
+ (!t6 || r.length !== 0) && o.push(r);
return;
}
let n = 0;
for (let s = 0; s < r.length + 1; s++)
if (s === r.length || e.indexOf(r[s]) !== -1) {
let a = r.subarray(n, s);
- (!t10 || a.length !== 0) && o.push(a), n = s + 1;
+ (!t6 || a.length !== 0) && o.push(a), n = s + 1;
}
}
-function Tu(r, e, t10) {
+function Nu(r, e, t6) {
let o = r.length, n = [], s = 0, a = 0, i = new Array(o);
for (let m = 0; m < o; ++m) {
- let f = n.length;
- bj(r[m], e, t10, n);
- let d = n.length - f;
- i[m] = d, s += d, a = Math.max(a, d);
+ let d = n.length;
+ z6(r[m], e, t6, n);
+ let f = n.length - d;
+ i[m] = f, s += f, a = Math.max(a, f);
}
- let p = x.getArrayFromDType("int32", s * 2), u = new Array(s), c = [o, a], l = 0;
+ let p = y.getArrayFromDType("int32", s * 2), u = new Array(s), c = [o, a], l = 0;
for (let m = 0; m < o; ++m)
- for (let f = 0; f < i[m]; ++f)
- p[l * 2] = m, p[l * 2 + 1] = f, u[l] = n[l], ++l;
+ for (let d = 0; d < i[m]; ++d)
+ p[l * 2] = m, p[l * 2 + 1] = d, u[l] = n[l], ++l;
return [p, u, c];
}
-function Nu(r, e) {
- let t10 = x.getArrayFromDType("int32", r.length);
+function Tu(r, e) {
+ let t6 = y.getArrayFromDType("int32", r.length);
for (let o = 0; o < r.length; ++o)
- t10[o] = x.fingerPrint64(r[o]).modulo(e).getLowBitsUnsigned();
- return t10;
+ t6[o] = y.fingerPrint64(r[o]).modulo(e).getLowBitsUnsigned();
+ return t6;
}
-var vI = Le((r, e) => r - e);
-var Cj = Qp((r, e, t10, o) => ({ real: r - t10, imag: e - o }));
-var Il = Ye(Io, vI, Cj);
-var a2 = { kernelName: Io, backendName: "cpu", kernelFunc: Il };
-function Ed(r, e) {
- let t10 = new Array(r.rank);
- for (let n = 0; n < t10.length; n++)
- t10[n] = r.shape[n] * e[n];
- let o = ne(t10, r.dtype);
+var bS = Be((r, e) => r - e);
+var W6 = qp((r, e, t6, o) => ({ real: r - t6, imag: e - o }));
+var dl = Qe(Xn, bS, W6);
+var OT = { kernelName: Xn, backendName: "cpu", kernelFunc: dl };
+function bf(r, e) {
+ let t6 = new Array(r.rank);
+ for (let n = 0; n < t6.length; n++)
+ t6[n] = r.shape[n] * e[n];
+ let o = le(t6, r.dtype);
for (let n = 0; n < o.values.length; ++n) {
let s = o.indexToLoc(n), a = new Array(r.rank);
for (let p = 0; p < a.length; p++)
@@ -12638,663 +12684,663 @@ function Ed(r, e) {
}
return o;
}
-var wl = (r, e) => {
- let t10 = e.value - r.value;
- return t10 === 0 ? r.index - e.index : t10;
+var fl = (r, e) => {
+ let t6 = e.value - r.value;
+ return t6 === 0 ? r.index - e.index : t6;
};
-function i2(r, e, t10 = 0, o = r.length - 1) {
- for (; o > t10; ) {
- if (o - t10 > 600) {
- let i = o - t10 + 1, p = e - t10 + 1, u = Math.log(i), c = 0.5 * Math.exp(2 * u / 3), l = 0.5 * Math.sqrt(u * c * (i - c) / i) * Math.sign(p - i / 2), m = Math.max(t10, Math.floor(e - p * c / i + l)), f = Math.min(o, Math.floor(e + (i - p) * c / i + l));
- i2(r, e, m, f);
+function PT(r, e, t6 = 0, o = r.length - 1) {
+ for (; o > t6; ) {
+ if (o - t6 > 600) {
+ let i = o - t6 + 1, p = e - t6 + 1, u = Math.log(i), c = 0.5 * Math.exp(2 * u / 3), l = 0.5 * Math.sqrt(u * c * (i - c) / i) * Math.sign(p - i / 2), m = Math.max(t6, Math.floor(e - p * c / i + l)), d = Math.min(o, Math.floor(e + (i - p) * c / i + l));
+ PT(r, e, m, d);
}
- let n = r[e], s = t10, a = o;
- for (x.swap(r, t10, e), wl(r[o], n) > 0 && x.swap(r, t10, o); s < a; ) {
- for (x.swap(r, s, a), s++, a--; wl(r[s], n) < 0; )
+ let n = r[e], s = t6, a = o;
+ for (y.swap(r, t6, e), fl(r[o], n) > 0 && y.swap(r, t6, o); s < a; ) {
+ for (y.swap(r, s, a), s++, a--; fl(r[s], n) < 0; )
s = s + 1;
- for (; wl(r[a], n) > 0; )
+ for (; fl(r[a], n) > 0; )
a = a - 1;
}
- wl(r[t10], n) === 0 ? x.swap(r, t10, a) : (a = a + 1, x.swap(r, a, o)), a <= e && (t10 = a + 1), e <= a && (o = a - 1);
+ fl(r[t6], n) === 0 ? y.swap(r, t6, a) : (a = a + 1, y.swap(r, a, o)), a <= e && (t6 = a + 1), e <= a && (o = a - 1);
}
}
-function $d(r, e, t10, o, n) {
- let s = e[e.length - 1], [a, i] = [r.length / s, s], p = x.getTypedArrayFromDType(t10, a * o), u = x.getTypedArrayFromDType("int32", a * o);
+function Cf(r, e, t6, o, n) {
+ let s = e[e.length - 1], [a, i] = [r.length / s, s], p = y.getTypedArrayFromDType(t6, a * o), u = y.getTypedArrayFromDType("int32", a * o);
for (let l = 0; l < a; l++) {
- let m = l * i, f = r.subarray(m, m + i), d = new Array(f.length);
- f.forEach((b, C) => d[C] = { value: b, index: C }), o < d.length && (i2(d, o), d = d.slice(0, o)), n && d.sort(wl);
- let h = l * o, g = p.subarray(h, h + o), y = u.subarray(h, h + o);
+ let m = l * i, d = r.subarray(m, m + i), f = new Array(d.length);
+ d.forEach((b, C) => f[C] = { value: b, index: C }), o < f.length && (PT(f, o), f = f.slice(0, o)), n && f.sort(fl);
+ let h = l * o, g = p.subarray(h, h + o), x = u.subarray(h, h + o);
for (let b = 0; b < o; b++)
- g[b] = d[b].value, y[b] = d[b].index;
+ g[b] = f[b].value, x[b] = f[b].index;
}
let c = e.slice();
- return c[c.length - 1] = o, [ne(c, t10, p), ne(c, "int32", u)];
+ return c[c.length - 1] = o, [le(c, t6, p), le(c, "int32", u)];
}
-function Rd(r, e, t10, o) {
- let n = x.parseAxisParam(e, t10)[0], s = [1, t10[0], 1];
- for (let d = 0; d < n; d++)
- s[0] *= t10[d];
- s[1] = t10[n];
- for (let d = n + 1; d < t10.length; d++)
- s[2] *= t10[d];
- let a = {}, i = new Int32Array(t10[n]), p = new je(s, o, r), u = [], c = s[0] === 1 && s[2] === 1;
- for (let d = 0; d < t10[n]; d++) {
+function Sf(r, e, t6, o) {
+ let n = y.parseAxisParam(e, t6)[0], s = [1, t6[0], 1];
+ for (let f = 0; f < n; f++)
+ s[0] *= t6[f];
+ s[1] = t6[n];
+ for (let f = n + 1; f < t6.length; f++)
+ s[2] *= t6[f];
+ let a = {}, i = new Int32Array(t6[n]), p = new st(s, o, r), u = [], c = s[0] === 1 && s[2] === 1;
+ for (let f = 0; f < t6[n]; f++) {
let h;
if (c)
- h = r[d].toString();
+ h = r[f].toString();
else {
let g = [];
- for (let y = 0; y < s[0]; y++)
+ for (let x = 0; x < s[0]; x++)
for (let b = 0; b < s[2]; b++)
- g.push(p.get(y, d, b));
+ g.push(p.get(x, f, b));
h = g.join(",");
}
if (a[h] !== void 0)
- i[d] = a[h];
+ i[f] = a[h];
else {
let g = Object.keys(a).length;
- a[h] = g, i[d] = g, u.push(d);
+ a[h] = g, i[f] = g, u.push(f);
}
}
let l = s.slice();
l[1] = Object.keys(a).length;
- let m = new je(l, o);
- u.forEach((d, h) => {
+ let m = new st(l, o);
+ u.forEach((f, h) => {
for (let g = 0; g < s[0]; g++)
- for (let y = 0; y < s[2]; y++)
- m.set(p.get(g, d, y), g, h, y);
+ for (let x = 0; x < s[2]; x++)
+ m.set(p.get(g, f, x), g, h, x);
});
- let f = t10.slice();
- return f[n] = l[1], { outputValues: m.values, outputShape: f, indices: i };
+ let d = t6.slice();
+ return d[n] = l[1], { outputValues: m.values, outputShape: d, indices: i };
}
-var Ij = "4.0.0";
-pi("cpu", () => new Si(), 1);
-var kI = we(In, (r) => r >= 0 ? r : Math.exp(r) - 1);
-var u2 = { kernelName: In, backendName: "cpu", kernelFunc: kI };
-function TI(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { alpha: s } = o;
+var U6 = "4.1.0";
+Ci("cpu", () => new Oi(), 1);
+var CS = Ie(en, (r) => r >= 0 ? r : Math.exp(r) - 1);
+var MT = { kernelName: en, backendName: "cpu", kernelFunc: CS };
+function SS(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { alpha: s } = o;
K([n], "leakyRelu");
- let a = x.sizeFromShape(n.shape), i = t10.data.get(n.dataId).values, p = x.getTypedArrayFromDType("float32", a);
+ let a = y.sizeFromShape(n.shape), i = t6.data.get(n.dataId).values, p = y.getTypedArrayFromDType("float32", a);
for (let u = 0; u < i.length; u++)
p[u] = i[u] < 0 ? s * i[u] : i[u];
- return t10.makeTensorInfo(n.shape, "float32", p);
+ return t6.makeTensorInfo(n.shape, "float32", p);
}
-var p2 = { kernelName: Nn, backendName: "cpu", kernelFunc: TI };
-var wj = Le((r, e) => r < 0 ? e * r : r);
-function NI(r) {
- let { inputs: e, backend: t10 } = r, { x: o, alpha: n } = e;
+var LT = { kernelName: mn, backendName: "cpu", kernelFunc: SS };
+var G6 = Be((r, e) => r < 0 ? e * r : r);
+function wS(r) {
+ let { inputs: e, backend: t6 } = r, { x: o, alpha: n } = e;
K([o, n], "prelu");
- let s = t10.data.get(o.dataId).values, a = t10.data.get(n.dataId).values, [i, p] = wj(o.shape, n.shape, s, a, "float32");
- return t10.makeTensorInfo(p, "float32", i);
+ let s = t6.data.get(o.dataId).values, a = t6.data.get(n.dataId).values, [i, p] = G6(o.shape, n.shape, s, a, "float32");
+ return t6.makeTensorInfo(p, "float32", i);
}
-var c2 = { kernelName: Vn, backendName: "cpu", kernelFunc: NI };
-var _I = we(zn, (r) => Math.max(0, r));
-var l2 = { kernelName: zn, backendName: "cpu", kernelFunc: _I };
-var EI = we(Gn, (r) => Math.min(Math.max(0, r), 6));
-var m2 = { kernelName: Gn, backendName: "cpu", kernelFunc: EI };
-function _u(r, e, t10, o, n) {
- if (t10 === "linear")
+var BT = { kernelName: Rn, backendName: "cpu", kernelFunc: wS };
+var IS = Ie(On, (r) => Math.max(0, r));
+var VT = { kernelName: On, backendName: "cpu", kernelFunc: IS };
+var vS = Ie(Ln, (r) => Math.min(Math.max(0, r), 6));
+var zT = { kernelName: Ln, backendName: "cpu", kernelFunc: vS };
+function _u(r, e, t6, o, n) {
+ if (t6 === "linear")
return ar({ inputs: { x: e }, backend: r });
- if (t10 === "relu")
- return _I({ inputs: { x: e }, backend: r });
- if (t10 === "elu")
- return kI({ inputs: { x: e }, backend: r });
- if (t10 === "relu6")
- return EI({ inputs: { x: e }, backend: r });
- if (t10 === "prelu")
- return NI({ inputs: { x: e, alpha: o }, backend: r });
- if (t10 === "leakyrelu")
- return TI({ inputs: { x: e }, backend: r, attrs: { alpha: n } });
- if (t10 === "sigmoid")
- return II({ inputs: { x: e }, backend: r });
- throw new Error(`Activation ${t10} has not been implemented for the CPU backend.`);
+ if (t6 === "relu")
+ return IS({ inputs: { x: e }, backend: r });
+ if (t6 === "elu")
+ return CS({ inputs: { x: e }, backend: r });
+ if (t6 === "relu6")
+ return vS({ inputs: { x: e }, backend: r });
+ if (t6 === "prelu")
+ return wS({ inputs: { x: e, alpha: o }, backend: r });
+ if (t6 === "leakyrelu")
+ return SS({ inputs: { x: e }, backend: r, attrs: { alpha: n } });
+ if (t6 === "sigmoid")
+ return gS({ inputs: { x: e }, backend: r });
+ throw new Error(`Activation ${t6} has not been implemented for the CPU backend.`);
}
-function Oe(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { shape: s } = o, a = x.sizeFromShape(n.shape), i = x.inferFromImplicitShape(s, a), p = x.sizeFromShape(i);
- x.assert(a === p, () => `The new shape (${i}) has ${p} elements and the old shape (${n.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`), t10.incRef(n.dataId);
- let u = t10.data.get(n.dataId);
+function Me(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { shape: s } = o, a = y.sizeFromShape(n.shape), i = y.inferFromImplicitShape(s, a), p = y.sizeFromShape(i);
+ y.assert(a === p, () => `The new shape (${i}) has ${p} elements and the old shape (${n.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`), t6.incRef(n.dataId);
+ let u = t6.data.get(n.dataId);
if (u.complexTensorInfos != null) {
let c = u.complexTensorInfos.real, l = u.complexTensorInfos.imag;
c.shape = i, l.shape = i;
}
return { dataId: n.dataId, shape: i, dtype: n.dtype };
}
-var f2 = { kernelName: Ss, backendName: "cpu", kernelFunc: Oe };
-function $I(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { a: n, b: s } = e, { transposeA: a, transposeB: i } = o;
+var WT = { kernelName: Ns, backendName: "cpu", kernelFunc: Me };
+function kS(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { a: n, b: s } = e, { transposeA: a, transposeB: i } = o;
K([n, s], "matMul");
- let p = n.shape.length, u = s.shape.length, c = a ? n.shape[p - 2] : n.shape[p - 1], l = i ? s.shape[u - 1] : s.shape[u - 2], m = a ? n.shape[p - 1] : n.shape[p - 2], f = i ? s.shape[u - 2] : s.shape[u - 1], d = n.shape.slice(0, -2), h = s.shape.slice(0, -2), g = x.sizeFromShape(d), y = x.sizeFromShape(h), C = br.assertAndGetBroadcastShape(n.shape.slice(0, -2), s.shape.slice(0, -2)).concat([m, f]);
- x.assert(c === l, () => `Error in matMul: inner shapes (${c}) and (${l}) of Tensors with shapes ${n.shape} and ${s.shape} and transposeA=${a} and transposeB=${i} must match.`);
- let w = a ? [g, c, m] : [g, m, c], k = i ? [y, f, l] : [y, l, f], _ = Oe({ inputs: { x: n }, backend: t10, attrs: { shape: w } }), E = Oe({ inputs: { x: s }, backend: t10, attrs: { shape: k } }), R = a ? _.shape[1] : _.shape[2], A = a ? _.shape[2] : _.shape[1], D = i ? E.shape[1] : E.shape[2], O = Math.max(g, y), M = t10.data.get(_.dataId).values, L = t10.data.get(E.dataId).values, W = x.computeStrides(_.shape), V = x.computeStrides(E.shape), [G, q, H] = a ? [W[0], 1, W[1]] : [W[0], W[1], 1], [j, Y, Z] = i ? [1, V[1], V[0]] : [V[1], 1, V[0]], ee = A * D, X = ne([O, A, D], _.dtype), Q = X.values, se = t10.blockSize;
- for (let ie = 0; ie < O; ie++)
- for (let de = 0; de < A; de += se)
- for (let Ie = 0; Ie < D; Ie += se)
- for (let Se = 0; Se < R; Se += se) {
- let Ee = Math.min(de + se, A), Me = Math.min(Ie + se, D), st = Math.min(Se + se, R);
- for (let pt = de; pt < Ee; pt++)
- for (let De = Ie; De < Me; De++) {
- let ft = 0;
- for (let at = Se; at < st; at++) {
- let dt = Math.min(ie, g - 1) * G, It = Math.min(ie, y - 1) * Z, Fr = M[dt + pt * q + at * H], Pt = L[at * j + De * Y + It];
- ft += Fr * Pt;
+ let p = n.shape.length, u = s.shape.length, c = a ? n.shape[p - 2] : n.shape[p - 1], l = i ? s.shape[u - 1] : s.shape[u - 2], m = a ? n.shape[p - 1] : n.shape[p - 2], d = i ? s.shape[u - 2] : s.shape[u - 1], f = n.shape.slice(0, -2), h = s.shape.slice(0, -2), g = y.sizeFromShape(f), x = y.sizeFromShape(h), C = br.assertAndGetBroadcastShape(n.shape.slice(0, -2), s.shape.slice(0, -2)).concat([m, d]);
+ y.assert(c === l, () => `Error in matMul: inner shapes (${c}) and (${l}) of Tensors with shapes ${n.shape} and ${s.shape} and transposeA=${a} and transposeB=${i} must match.`);
+ let w = a ? [g, c, m] : [g, m, c], k = i ? [x, d, l] : [x, l, d], _ = Me({ inputs: { x: n }, backend: t6, attrs: { shape: w } }), $ = Me({ inputs: { x: s }, backend: t6, attrs: { shape: k } }), A = a ? _.shape[1] : _.shape[2], R = a ? _.shape[2] : _.shape[1], D = i ? $.shape[1] : $.shape[2], P = Math.max(g, x), M = t6.data.get(_.dataId).values, L = t6.data.get($.dataId).values, W = y.computeStrides(_.shape), V = y.computeStrides($.shape), [U, q, H] = a ? [W[0], 1, W[1]] : [W[0], W[1], 1], [j, X, Z] = i ? [1, V[1], V[0]] : [V[1], 1, V[0]], ee = R * D, Y = le([P, R, D], _.dtype), J = Y.values, ie = t6.blockSize;
+ for (let pe = 0; pe < P; pe++)
+ for (let he = 0; he < R; he += ie)
+ for (let we = 0; we < D; we += ie)
+ for (let ve = 0; ve < A; ve += ie) {
+ let $e = Math.min(he + ie, R), Le = Math.min(we + ie, D), nt = Math.min(ve + ie, A);
+ for (let pt = he; pt < $e; pt++)
+ for (let Oe = we; Oe < Le; Oe++) {
+ let mt = 0;
+ for (let at = ve; at < nt; at++) {
+ let ft = Math.min(pe, g - 1) * U, wt = Math.min(pe, x - 1) * Z, Fr = M[ft + pt * q + at * H], Ot = L[at * j + Oe * X + wt];
+ mt += Fr * Ot;
}
- Q[ie * ee + (pt * D + De)] += ft;
+ J[pe * ee + (pt * D + Oe)] += mt;
}
}
- return t10.disposeIntermediateTensorInfo(_), t10.disposeIntermediateTensorInfo(E), t10.makeTensorInfo(C, X.dtype, X.values);
+ return t6.disposeIntermediateTensorInfo(_), t6.disposeIntermediateTensorInfo($), t6.makeTensorInfo(C, Y.dtype, Y.values);
}
-var d2 = { kernelName: cn, backendName: "cpu", kernelFunc: $I };
-function Sj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { a: n, b: s, bias: a, preluActivationWeights: i } = e, { transposeA: p, transposeB: u, activation: c, leakyreluAlpha: l } = o, m, f, d, h = [];
- m = $I({ inputs: { a: n, b: s }, attrs: { transposeA: p, transposeB: u }, backend: t10 }), a && (f = Hs({ inputs: { a: m, b: a }, backend: t10 }), h.push(m), m = f), c && (d = _u(t10, m, c, i, l), h.push(m), m = d);
- for (let y of h)
- t10.disposeIntermediateTensorInfo(y);
+var UT = { kernelName: Wo, backendName: "cpu", kernelFunc: kS };
+function H6(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { a: n, b: s, bias: a, preluActivationWeights: i } = e, { transposeA: p, transposeB: u, activation: c, leakyreluAlpha: l } = o, m, d, f, h = [];
+ m = kS({ inputs: { a: n, b: s }, attrs: { transposeA: p, transposeB: u }, backend: t6 }), a && (d = js({ inputs: { a: m, b: a }, backend: t6 }), h.push(m), m = d), c && (f = _u(t6, m, c, i, l), h.push(m), m = f);
+ for (let x of h)
+ t6.disposeIntermediateTensorInfo(x);
return m;
}
-var h2 = { kernelName: Fo, backendName: "cpu", kernelFunc: Sj };
-var vj = we(Li, (r) => Math.acos(r));
-var g2 = { kernelName: Li, backendName: "cpu", kernelFunc: vj };
-var kj = we(Bi, (r) => Math.acosh(r));
-var x2 = { kernelName: Bi, backendName: "cpu", kernelFunc: kj };
-function Tj(r) {
- let { inputs: e, backend: t10 } = r, o = e;
+var GT = { kernelName: fo, backendName: "cpu", kernelFunc: H6 };
+var q6 = Ie(sa, (r) => Math.acos(r));
+var HT = { kernelName: sa, backendName: "cpu", kernelFunc: q6 };
+var K6 = Ie(aa, (r) => Math.acosh(r));
+var qT = { kernelName: aa, backendName: "cpu", kernelFunc: K6 };
+function j6(r) {
+ let { inputs: e, backend: t6 } = r, o = e;
K(e, "addN");
- let n = o.map((i) => t10.data.get(i.dataId).values), s = ne(o[0].shape, o[0].dtype), a = s.values;
+ let n = o.map((i) => t6.data.get(i.dataId).values), s = le(o[0].shape, o[0].dtype), a = s.values;
for (let i = 0; i < o.length; i++) {
let p = n[i];
for (let u = 0; u < a.length; u++)
a[u] += p[u];
}
- return t10.makeTensorInfo(s.shape, s.dtype, s.values);
+ return t6.makeTensorInfo(s.shape, s.dtype, s.values);
}
-var y2 = { kernelName: an, backendName: "cpu", kernelFunc: Tj };
-function Nj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
+var KT = { kernelName: Mo, backendName: "cpu", kernelFunc: j6 };
+function X6(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
K(n, "all");
- let i = x.parseAxisParam(s, n.shape), p = i, u = I.getAxesPermutation(p, n.shape.length), c = n;
- u != null && (c = bt({ inputs: { x: n }, backend: t10, attrs: { perm: u } }), p = I.getInnerMostAxes(p.length, n.shape.length)), I.assertAxesAreInnerMostDims("all", p, c.shape.length);
- let [l, m] = I.computeOutAndReduceShapes(c.shape, p), f = x.sizeFromShape(m), d = x.makeZerosTypedArray(x.sizeFromShape(l), c.dtype), h = t10.data.get(c.dataId).values;
- for (let y = 0; y < d.length; ++y) {
- let b = y * f, C = h[b];
- for (let w = 0; w < f; ++w) {
+ let i = y.parseAxisParam(s, n.shape), p = i, u = S.getAxesPermutation(p, n.shape.length), c = n;
+ u != null && (c = Ct({ inputs: { x: n }, backend: t6, attrs: { perm: u } }), p = S.getInnerMostAxes(p.length, n.shape.length)), S.assertAxesAreInnerMostDims("all", p, c.shape.length);
+ let [l, m] = S.computeOutAndReduceShapes(c.shape, p), d = y.sizeFromShape(m), f = y.makeZerosTypedArray(y.sizeFromShape(l), c.dtype), h = t6.data.get(c.dataId).values;
+ for (let x = 0; x < f.length; ++x) {
+ let b = x * d, C = h[b];
+ for (let w = 0; w < d; ++w) {
let k = h[b + w];
C = C && k;
}
- d[y] = C;
+ f[x] = C;
}
- u != null && t10.disposeIntermediateTensorInfo(c);
- let g = t10.makeTensorInfo(l, c.dtype, d);
+ u != null && t6.disposeIntermediateTensorInfo(c);
+ let g = t6.makeTensorInfo(l, c.dtype, f);
if (a) {
- let y = I.expandShapeToKeepDim(l, i), b = Oe({ inputs: { x: g }, backend: t10, attrs: { shape: y } });
- return t10.disposeIntermediateTensorInfo(g), b;
+ let x = S.expandShapeToKeepDim(l, i), b = Me({ inputs: { x: g }, backend: t6, attrs: { shape: x } });
+ return t6.disposeIntermediateTensorInfo(g), b;
}
return g;
}
-var b2 = { kernelName: oa, backendName: "cpu", kernelFunc: Nj };
-function _j(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
+var jT = { kernelName: Lo, backendName: "cpu", kernelFunc: X6 };
+function Y6(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
K(n, "any");
- let i = x.parseAxisParam(s, n.shape), p = i, u = I.getAxesPermutation(p, n.shape.length), c = n;
- u != null && (c = bt({ inputs: { x: n }, backend: t10, attrs: { perm: u } }), p = I.getInnerMostAxes(p.length, n.shape.length)), I.assertAxesAreInnerMostDims("any", p, c.shape.length);
- let [l, m] = I.computeOutAndReduceShapes(c.shape, p), f = x.sizeFromShape(m), d = x.makeZerosTypedArray(x.sizeFromShape(l), c.dtype), h = t10.data.get(c.dataId).values;
- for (let y = 0; y < d.length; ++y) {
- let b = y * f, C = h[b];
- for (let w = 0; w < f; ++w) {
+ let i = y.parseAxisParam(s, n.shape), p = i, u = S.getAxesPermutation(p, n.shape.length), c = n;
+ u != null && (c = Ct({ inputs: { x: n }, backend: t6, attrs: { perm: u } }), p = S.getInnerMostAxes(p.length, n.shape.length)), S.assertAxesAreInnerMostDims("any", p, c.shape.length);
+ let [l, m] = S.computeOutAndReduceShapes(c.shape, p), d = y.sizeFromShape(m), f = y.makeZerosTypedArray(y.sizeFromShape(l), c.dtype), h = t6.data.get(c.dataId).values;
+ for (let x = 0; x < f.length; ++x) {
+ let b = x * d, C = h[b];
+ for (let w = 0; w < d; ++w) {
let k = h[b + w];
C = C || k;
}
- d[y] = C;
+ f[x] = C;
}
- u != null && t10.disposeIntermediateTensorInfo(c);
- let g = t10.makeTensorInfo(l, c.dtype, d);
+ u != null && t6.disposeIntermediateTensorInfo(c);
+ let g = t6.makeTensorInfo(l, c.dtype, f);
if (a) {
- let y = I.expandShapeToKeepDim(l, i), b = Oe({ inputs: { x: g }, backend: t10, attrs: { shape: y } });
- return t10.disposeIntermediateTensorInfo(g), b;
+ let x = S.expandShapeToKeepDim(l, i), b = Me({ inputs: { x: g }, backend: t6, attrs: { shape: x } });
+ return t6.disposeIntermediateTensorInfo(g), b;
}
return g;
}
-var C2 = { kernelName: na, backendName: "cpu", kernelFunc: _j };
-function Ej(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s } = o;
+var XT = { kernelName: Bo, backendName: "cpu", kernelFunc: Y6 };
+function Q6(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s } = o;
K(n, "argMax");
- let a = x.parseAxisParam(s, n.shape), i = I.getAxesPermutation(a, n.shape.length), p = n, u = [];
- i != null && (p = bt({ inputs: { x: n }, backend: t10, attrs: { perm: i } }), u.push(p), a = I.getInnerMostAxes(a.length, p.shape.length)), a = [a[0]], I.assertAxesAreInnerMostDims("argMax", a, p.shape.length);
- let [c, l] = I.computeOutAndReduceShapes(p.shape, a), m = x.sizeFromShape(c), f = x.makeZerosTypedArray(m, "int32"), d = x.sizeFromShape(l), h = t10.data.get(p.dataId).values;
- for (let g = 0; g < f.length; ++g) {
- let y = g * d, b = h[y], C = 0;
- for (let w = 0; w < d; ++w) {
- let k = h[y + w];
+ let a = y.parseAxisParam(s, n.shape), i = S.getAxesPermutation(a, n.shape.length), p = n, u = [];
+ i != null && (p = Ct({ inputs: { x: n }, backend: t6, attrs: { perm: i } }), u.push(p), a = S.getInnerMostAxes(a.length, p.shape.length)), a = [a[0]], S.assertAxesAreInnerMostDims("argMax", a, p.shape.length);
+ let [c, l] = S.computeOutAndReduceShapes(p.shape, a), m = y.sizeFromShape(c), d = y.makeZerosTypedArray(m, "int32"), f = y.sizeFromShape(l), h = t6.data.get(p.dataId).values;
+ for (let g = 0; g < d.length; ++g) {
+ let x = g * f, b = h[x], C = 0;
+ for (let w = 0; w < f; ++w) {
+ let k = h[x + w];
k > b && (b = k, C = w);
}
- f[g] = C;
+ d[g] = C;
}
- return u.forEach((g) => t10.disposeIntermediateTensorInfo(g)), t10.makeTensorInfo(c, "int32", f);
+ return u.forEach((g) => t6.disposeIntermediateTensorInfo(g)), t6.makeTensorInfo(c, "int32", d);
}
-var I2 = { kernelName: un, backendName: "cpu", kernelFunc: Ej };
-function $j(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s } = o;
+var YT = { kernelName: Vo, backendName: "cpu", kernelFunc: Q6 };
+function Z6(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s } = o;
K(n, "argMin");
- let a = x.parseAxisParam(s, n.shape), i = I.getAxesPermutation(a, n.shape.length), p = n, u = [];
- i != null && (p = bt({ inputs: { x: n }, backend: t10, attrs: { perm: i } }), u.push(p), a = I.getInnerMostAxes(a.length, p.shape.length)), a = [a[0]], I.assertAxesAreInnerMostDims("argMin", a, p.shape.length);
- let [c, l] = I.computeOutAndReduceShapes(p.shape, a), m = x.sizeFromShape(c), f = x.makeZerosTypedArray(m, "int32"), d = x.sizeFromShape(l), h = t10.data.get(p.dataId).values;
- for (let g = 0; g < f.length; ++g) {
- let y = g * d, b = h[y], C = 0;
- for (let w = 0; w < d; ++w) {
- let k = h[y + w];
+ let a = y.parseAxisParam(s, n.shape), i = S.getAxesPermutation(a, n.shape.length), p = n, u = [];
+ i != null && (p = Ct({ inputs: { x: n }, backend: t6, attrs: { perm: i } }), u.push(p), a = S.getInnerMostAxes(a.length, p.shape.length)), a = [a[0]], S.assertAxesAreInnerMostDims("argMin", a, p.shape.length);
+ let [c, l] = S.computeOutAndReduceShapes(p.shape, a), m = y.sizeFromShape(c), d = y.makeZerosTypedArray(m, "int32"), f = y.sizeFromShape(l), h = t6.data.get(p.dataId).values;
+ for (let g = 0; g < d.length; ++g) {
+ let x = g * f, b = h[x], C = 0;
+ for (let w = 0; w < f; ++w) {
+ let k = h[x + w];
k < b && (b = k, C = w);
}
- f[g] = C;
+ d[g] = C;
}
- return u.forEach((g) => t10.disposeIntermediateTensorInfo(g)), t10.makeTensorInfo(c, "int32", f);
+ return u.forEach((g) => t6.disposeIntermediateTensorInfo(g)), t6.makeTensorInfo(c, "int32", d);
}
-var w2 = { kernelName: ja, backendName: "cpu", kernelFunc: $j };
-var Rj = we(Vi, (r) => Math.asin(r));
-var S2 = { kernelName: Vi, backendName: "cpu", kernelFunc: Rj };
-var Aj = we(zi, (r) => Math.asinh(r));
-var v2 = { kernelName: zi, backendName: "cpu", kernelFunc: Aj };
-var Fj = we(Wi, (r) => Math.atan(r));
-var k2 = { kernelName: Wi, backendName: "cpu", kernelFunc: Fj };
-var Dj = Le((r, e) => Math.atan2(r, e));
-var Pj = Ye(sa, Dj);
-var T2 = { kernelName: sa, backendName: "cpu", kernelFunc: Pj };
-var Oj = we(Ui, (r) => Math.atanh(r));
-var N2 = { kernelName: Ui, backendName: "cpu", kernelFunc: Oj };
-function rc(r, e, t10, o, n, s) {
- let a = n.strideHeight, i = n.strideWidth, p = n.dilationHeight, u = n.dilationWidth, c = n.effectiveFilterHeight, l = n.effectiveFilterWidth, m = n.padInfo.top, f = n.padInfo.left, d = s === "max" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, h = ne(n.outShape, t10), g = h.values, y = n.outShape[1] * n.outShape[2] * n.outShape[3], b = n.outShape[2] * n.outShape[3], C = n.outShape[3];
+var QT = { kernelName: Za, backendName: "cpu", kernelFunc: Z6 };
+var J6 = Ie(ia, (r) => Math.asin(r));
+var ZT = { kernelName: ia, backendName: "cpu", kernelFunc: J6 };
+var ej = Ie(ua, (r) => Math.asinh(r));
+var JT = { kernelName: ua, backendName: "cpu", kernelFunc: ej };
+var tj = Ie(pa, (r) => Math.atan(r));
+var e2 = { kernelName: pa, backendName: "cpu", kernelFunc: tj };
+var rj = Be((r, e) => Math.atan2(r, e));
+var oj = Qe(la, rj);
+var t2 = { kernelName: la, backendName: "cpu", kernelFunc: oj };
+var nj = Ie(ca, (r) => Math.atanh(r));
+var r2 = { kernelName: ca, backendName: "cpu", kernelFunc: nj };
+function Zp(r, e, t6, o, n, s) {
+ let a = n.strideHeight, i = n.strideWidth, p = n.dilationHeight, u = n.dilationWidth, c = n.effectiveFilterHeight, l = n.effectiveFilterWidth, m = n.padInfo.top, d = n.padInfo.left, f = s === "max" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, h = le(n.outShape, t6), g = h.values, x = n.outShape[1] * n.outShape[2] * n.outShape[3], b = n.outShape[2] * n.outShape[3], C = n.outShape[3];
for (let w = 0; w < n.batchSize; ++w) {
- let k = w * y, _ = w * o[0];
- for (let E = 0; E < n.inChannels; ++E)
- for (let R = 0; R < n.outHeight; ++R) {
- let A = R * a - m, D = Math.max(0, A), O = Math.min(n.inHeight, c + A), M = k + R * b;
+ let k = w * x, _ = w * o[0];
+ for (let $ = 0; $ < n.inChannels; ++$)
+ for (let A = 0; A < n.outHeight; ++A) {
+ let R = A * a - m, D = Math.max(0, R), P = Math.min(n.inHeight, c + R), M = k + A * b;
for (let L = 0; L < n.outWidth; ++L) {
- let W = L * i - f, V = Math.max(0, W), G = Math.min(n.inWidth, l + W), q = d, H = 0, j = 0;
- for (let Z = D; Z < O; Z += p) {
+ let W = L * i - d, V = Math.max(0, W), U = Math.min(n.inWidth, l + W), q = f, H = 0, j = 0;
+ for (let Z = D; Z < P; Z += p) {
let ee = _ + Z * o[1];
- for (let X = V; X < G; X += u) {
- let Q = ee + X * o[2], se = r[Q + E];
- s === "max" && se > q ? q = se : s === "avg" && (H += se, j++);
+ for (let Y = V; Y < U; Y += u) {
+ let J = ee + Y * o[2], ie = r[J + $];
+ s === "max" && ie > q ? q = ie : s === "avg" && (H += ie, j++);
}
if (isNaN(q))
break;
}
- let Y = M + L * C + E;
- g[Y] = s === "avg" ? H / j : q;
+ let X = M + L * C + $;
+ g[X] = s === "avg" ? H / j : q;
}
}
}
return h;
}
-function Fd(r, e, t10, o, n = false, s = false) {
- let a = ne(o.outShape, "int32"), i = o.strideHeight, p = o.strideWidth, u = o.dilationHeight, c = o.dilationWidth, l = o.effectiveFilterHeight, m = o.effectiveFilterWidth, f = o.padInfo.top, d = o.padInfo.left, h = ne(e, t10, r);
+function wf(r, e, t6, o, n = false, s = false) {
+ let a = le(o.outShape, "int32"), i = o.strideHeight, p = o.strideWidth, u = o.dilationHeight, c = o.dilationWidth, l = o.effectiveFilterHeight, m = o.effectiveFilterWidth, d = o.padInfo.top, f = o.padInfo.left, h = le(e, t6, r);
for (let g = 0; g < o.batchSize; ++g)
- for (let y = 0; y < o.inChannels; ++y)
+ for (let x = 0; x < o.inChannels; ++x)
for (let b = 0; b < o.outHeight; ++b) {
- let C = b * i - f, w = C;
+ let C = b * i - d, w = C;
for (; w < 0; )
w += u;
let k = Math.min(o.inHeight, l + C);
for (let _ = 0; _ < o.outWidth; ++_) {
- let E = _ * p - d, R = E;
- for (; R < 0; )
- R += c;
- let A = Math.min(o.inWidth, m + E), D = Number.NEGATIVE_INFINITY, O = -1;
+ let $ = _ * p - f, A = $;
+ for (; A < 0; )
+ A += c;
+ let R = Math.min(o.inWidth, m + $), D = Number.NEGATIVE_INFINITY, P = -1;
for (let M = w; M < k; M += u) {
let L = M - C;
- for (let W = R; W < A; W += c) {
- let V = W - E, G = h.get(g, M, W, y);
- G > D && (D = G, n ? O = s ? ((g * o.inHeight + M) * o.inWidth + W) * o.inChannels + y : (M * o.inWidth + W) * o.inChannels + y : O = L * m + V);
+ for (let W = A; W < R; W += c) {
+ let V = W - $, U = h.get(g, M, W, x);
+ U > D && (D = U, n ? P = s ? ((g * o.inHeight + M) * o.inWidth + W) * o.inChannels + x : (M * o.inWidth + W) * o.inChannels + x : P = L * m + V);
}
}
- a.set(O, g, b, _, y);
+ a.set(P, g, b, _, x);
}
}
return a;
}
-function Dd(r, e, t10, o, n, s) {
- let a = n.strideDepth, i = n.strideHeight, p = n.strideWidth, u = n.dilationDepth, c = n.dilationHeight, l = n.dilationWidth, m = n.effectiveFilterDepth, f = n.effectiveFilterHeight, d = n.effectiveFilterWidth, h = n.padInfo.front, g = n.padInfo.top, y = n.padInfo.left, b = s === "max" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, C = ne(n.outShape, t10), w = C.values, k = n.outShape[1] * n.outShape[2] * n.outShape[3] * n.outShape[4], _ = n.outShape[2] * n.outShape[3] * n.outShape[4], E = n.outShape[3] * n.outShape[4], R = n.outShape[4];
- for (let A = 0; A < n.batchSize; ++A) {
- let D = A * k, O = A * o[0];
+function If(r, e, t6, o, n, s) {
+ let a = n.strideDepth, i = n.strideHeight, p = n.strideWidth, u = n.dilationDepth, c = n.dilationHeight, l = n.dilationWidth, m = n.effectiveFilterDepth, d = n.effectiveFilterHeight, f = n.effectiveFilterWidth, h = n.padInfo.front, g = n.padInfo.top, x = n.padInfo.left, b = s === "max" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, C = le(n.outShape, t6), w = C.values, k = n.outShape[1] * n.outShape[2] * n.outShape[3] * n.outShape[4], _ = n.outShape[2] * n.outShape[3] * n.outShape[4], $ = n.outShape[3] * n.outShape[4], A = n.outShape[4];
+ for (let R = 0; R < n.batchSize; ++R) {
+ let D = R * k, P = R * o[0];
for (let M = 0; M < n.inChannels; ++M)
for (let L = 0; L < n.outDepth; ++L) {
let W = L * a - h, V = W;
for (; V < 0; )
V += u;
- let G = Math.min(n.inDepth, m + W), q = D + L * _;
+ let U = Math.min(n.inDepth, m + W), q = D + L * _;
for (let H = 0; H < n.outHeight; ++H) {
- let j = H * i - g, Y = j;
- for (; Y < 0; )
- Y += c;
- let Z = Math.min(n.inHeight, f + j), ee = q + H * E;
- for (let X = 0; X < n.outWidth; ++X) {
- let Q = X * p - y, se = Q;
- for (; se < 0; )
- se += l;
- let ie = Math.min(n.inWidth, d + Q), de = ee + X * R, Ie = b, Se = 0, Ee = 0;
- for (let st = V; st < G; st += u) {
- let pt = O + st * o[1];
- for (let De = Y; De < Z; De += c) {
- let ft = pt + De * o[2];
- for (let at = se; at < ie; at += l) {
- let dt = ft + at * o[3], It = r[dt + M];
- if (s === "max" && It > Ie ? Ie = It : s === "avg" && (Se += It, Ee++), isNaN(Ie))
+ let j = H * i - g, X = j;
+ for (; X < 0; )
+ X += c;
+ let Z = Math.min(n.inHeight, d + j), ee = q + H * $;
+ for (let Y = 0; Y < n.outWidth; ++Y) {
+ let J = Y * p - x, ie = J;
+ for (; ie < 0; )
+ ie += l;
+ let pe = Math.min(n.inWidth, f + J), he = ee + Y * A, we = b, ve = 0, $e = 0;
+ for (let nt = V; nt < U; nt += u) {
+ let pt = P + nt * o[1];
+ for (let Oe = X; Oe < Z; Oe += c) {
+ let mt = pt + Oe * o[2];
+ for (let at = ie; at < pe; at += l) {
+ let ft = mt + at * o[3], wt = r[ft + M];
+ if (s === "max" && wt > we ? we = wt : s === "avg" && (ve += wt, $e++), isNaN(we))
break;
}
- if (isNaN(Ie))
+ if (isNaN(we))
break;
}
- if (isNaN(Ie))
+ if (isNaN(we))
break;
}
- let Me = de + M;
- w[Me] = s === "avg" ? Se / Ee : Ie;
+ let Le = he + M;
+ w[Le] = s === "avg" ? ve / $e : we;
}
}
}
}
return C;
}
-function _2(r, e) {
- let t10 = ne(e.outShape, "int32"), o = e.strideDepth, n = e.strideHeight, s = e.strideWidth, a = e.dilationDepth, i = e.dilationHeight, p = e.dilationWidth, u = e.effectiveFilterDepth, c = e.effectiveFilterHeight, l = e.effectiveFilterWidth, m = e.padInfo.front, f = e.padInfo.top, d = e.padInfo.left;
+function o2(r, e) {
+ let t6 = le(e.outShape, "int32"), o = e.strideDepth, n = e.strideHeight, s = e.strideWidth, a = e.dilationDepth, i = e.dilationHeight, p = e.dilationWidth, u = e.effectiveFilterDepth, c = e.effectiveFilterHeight, l = e.effectiveFilterWidth, m = e.padInfo.front, d = e.padInfo.top, f = e.padInfo.left;
for (let h = 0; h < e.batchSize; ++h)
for (let g = 0; g < e.inChannels; ++g)
- for (let y = 0; y < e.outDepth; ++y) {
- let b = y * o - m, C = b;
+ for (let x = 0; x < e.outDepth; ++x) {
+ let b = x * o - m, C = b;
for (; C < 0; )
C += a;
let w = Math.min(e.inDepth, u + b);
for (let k = 0; k < e.outHeight; ++k) {
- let _ = k * n - f, E = _;
- for (; E < 0; )
- E += i;
- let R = Math.min(e.inHeight, c + _);
- for (let A = 0; A < e.outWidth; ++A) {
- let D = A * s - d, O = D;
- for (; O < 0; )
- O += p;
+ let _ = k * n - d, $ = _;
+ for (; $ < 0; )
+ $ += i;
+ let A = Math.min(e.inHeight, c + _);
+ for (let R = 0; R < e.outWidth; ++R) {
+ let D = R * s - f, P = D;
+ for (; P < 0; )
+ P += p;
let M = Math.min(e.inWidth, l + D), L = Number.NEGATIVE_INFINITY, W = -1;
for (let V = C; V < w; V += a) {
- let G = V - b;
- for (let q = E; q < R; q += i) {
+ let U = V - b;
+ for (let q = $; q < A; q += i) {
let H = q - _;
- for (let j = O; j < M; j += p) {
- let Y = j - D, Z = r.get(h, V, q, j, g);
- Z >= L && (L = Z, W = G * c * l + H * c + Y);
+ for (let j = P; j < M; j += p) {
+ let X = j - D, Z = r.get(h, V, q, j, g);
+ Z >= L && (L = Z, W = U * c * l + H * c + X);
}
}
}
- t10.set(W, h, y, k, A, g);
+ t6.set(W, h, x, k, R, g);
}
}
}
- return t10;
+ return t6;
}
-function Mj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e;
+function sj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e;
K(n, "avgPool");
let { filterSize: s, strides: a, pad: i, dimRoundingMode: p } = o, u = 1;
- x.assert(I.eitherStridesOrDilationsAreOne(a, u), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
- let c = I.computePool2DInfo(n.shape, s, a, u, i, p), l;
- if (c.filterWidth === 1 && c.filterHeight === 1 && x.arraysEqual(c.inShape, c.outShape))
- l = ar({ inputs: { x: n }, backend: t10 });
+ y.assert(S.eitherStridesOrDilationsAreOne(a, u), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
+ let c = S.computePool2DInfo(n.shape, s, a, u, i, p), l;
+ if (c.filterWidth === 1 && c.filterHeight === 1 && y.arraysEqual(c.inShape, c.outShape))
+ l = ar({ inputs: { x: n }, backend: t6 });
else {
- let m = t10.data.get(n.dataId).values, f = x.computeStrides(n.shape), d = rc(m, n.shape, n.dtype, f, c, "avg");
- l = t10.makeTensorInfo(c.outShape, n.dtype, d.values);
+ let m = t6.data.get(n.dataId).values, d = y.computeStrides(n.shape), f = Zp(m, n.shape, n.dtype, d, c, "avg");
+ l = t6.makeTensorInfo(c.outShape, n.dtype, f.values);
}
return l;
}
-var E2 = { kernelName: pn, backendName: "cpu", kernelFunc: Mj };
-function Lj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { filterSize: s, strides: a, pad: i, dimRoundingMode: p, dataFormat: u } = o;
+var n2 = { kernelName: zo, backendName: "cpu", kernelFunc: sj };
+function aj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { filterSize: s, strides: a, pad: i, dimRoundingMode: p, dataFormat: u } = o;
K(n, "avgPool3d");
- let c = I.computePool3DInfo(n.shape, s, a, 1, i, p, u), l = t10.data.get(n.dataId).values, m = Dd(l, n.shape, n.dtype, x.computeStrides(n.shape), c, "avg");
- return t10.makeTensorInfo(m.shape, "float32", m.values);
+ let c = S.computePool3DInfo(n.shape, s, a, 1, i, p, u), l = t6.data.get(n.dataId).values, m = If(l, n.shape, n.dtype, y.computeStrides(n.shape), c, "avg");
+ return t6.makeTensorInfo(m.shape, "float32", m.values);
}
-var $2 = { kernelName: ip, backendName: "cpu", kernelFunc: Lj };
-function Bj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, input: s } = e, { filterSize: a, strides: i, pad: p, dimRoundingMode: u } = o;
+var s2 = { kernelName: ip, backendName: "cpu", kernelFunc: aj };
+function ij(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, input: s } = e, { filterSize: a, strides: i, pad: p, dimRoundingMode: u } = o;
K([n, s], "avgPool3DGrad");
- let c = I.computePool3DInfo(s.shape, a, i, 1, p, u), l = c.strideDepth, m = c.strideHeight, f = c.strideWidth, d = c.filterDepth, h = c.filterHeight, g = c.filterWidth, y = c.dilationDepth, b = c.dilationHeight, C = c.dilationWidth, w = c.effectiveFilterDepth, k = c.effectiveFilterHeight, _ = c.effectiveFilterWidth, E = w - 1 - c.padInfo.front, R = _ - 1 - c.padInfo.left, A = k - 1 - c.padInfo.top, D = ne(s.shape, "float32"), O = 1 / (d * h * g), M = t10.bufferSync(n);
+ let c = S.computePool3DInfo(s.shape, a, i, 1, p, u), l = c.strideDepth, m = c.strideHeight, d = c.strideWidth, f = c.filterDepth, h = c.filterHeight, g = c.filterWidth, x = c.dilationDepth, b = c.dilationHeight, C = c.dilationWidth, w = c.effectiveFilterDepth, k = c.effectiveFilterHeight, _ = c.effectiveFilterWidth, $ = w - 1 - c.padInfo.front, A = _ - 1 - c.padInfo.left, R = k - 1 - c.padInfo.top, D = le(s.shape, "float32"), P = 1 / (f * h * g), M = t6.bufferSync(n);
for (let L = 0; L < c.batchSize; ++L)
for (let W = 0; W < c.inChannels; ++W)
for (let V = 0; V < c.inDepth; ++V)
- for (let G = 0; G < c.inHeight; ++G)
+ for (let U = 0; U < c.inHeight; ++U)
for (let q = 0; q < c.inWidth; ++q) {
- let H = V - E, j = G - A, Y = q - R, Z = 0;
- for (let ee = 0; ee < w; ee += y) {
- let X = (H + ee) / l;
- if (!(X < 0 || X >= c.outDepth || Math.floor(X) !== X))
- for (let Q = 0; Q < k; Q += b) {
- let se = (j + Q) / m;
- if (!(se < 0 || se >= c.outHeight || Math.floor(se) !== se))
- for (let ie = 0; ie < _; ie += C) {
- let de = (Y + ie) / f;
- if (de < 0 || de >= c.outWidth || Math.floor(de) !== de)
+ let H = V - $, j = U - R, X = q - A, Z = 0;
+ for (let ee = 0; ee < w; ee += x) {
+ let Y = (H + ee) / l;
+ if (!(Y < 0 || Y >= c.outDepth || Math.floor(Y) !== Y))
+ for (let J = 0; J < k; J += b) {
+ let ie = (j + J) / m;
+ if (!(ie < 0 || ie >= c.outHeight || Math.floor(ie) !== ie))
+ for (let pe = 0; pe < _; pe += C) {
+ let he = (X + pe) / d;
+ if (he < 0 || he >= c.outWidth || Math.floor(he) !== he)
continue;
- let Ie = M.get(L, X, se, de, W);
- Z += Ie;
+ let we = M.get(L, Y, ie, he, W);
+ Z += we;
}
}
}
- D.set(Z * O, L, V, G, q, W);
+ D.set(Z * P, L, V, U, q, W);
}
- return t10.makeTensorInfo(D.shape, D.dtype, D.values);
+ return t6.makeTensorInfo(D.shape, D.dtype, D.values);
}
-var R2 = { kernelName: Fm, backendName: "cpu", kernelFunc: Bj };
-function Vj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, input: s } = e, a = s;
+var a2 = { kernelName: Im, backendName: "cpu", kernelFunc: ij };
+function uj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, input: s } = e, a = s;
K([n, s], "avgPoolGrad");
- let { filterSize: i, strides: p, pad: u } = o, c = I.computePool2DInfo(a.shape, i, p, 1, u), l = c.strideHeight, m = c.strideWidth, f = c.filterHeight, d = c.filterWidth, h = c.dilationHeight, g = c.dilationWidth, y = c.effectiveFilterHeight, b = c.effectiveFilterWidth, C = b - 1 - c.padInfo.left, w = y - 1 - c.padInfo.top, k = ne(a.shape, "float32"), _ = 1 / (f * d), E = t10.data.get(n.dataId).values, R = ne(n.shape, "float32", E);
- for (let A = 0; A < c.batchSize; ++A)
+ let { filterSize: i, strides: p, pad: u } = o, c = S.computePool2DInfo(a.shape, i, p, 1, u), l = c.strideHeight, m = c.strideWidth, d = c.filterHeight, f = c.filterWidth, h = c.dilationHeight, g = c.dilationWidth, x = c.effectiveFilterHeight, b = c.effectiveFilterWidth, C = b - 1 - c.padInfo.left, w = x - 1 - c.padInfo.top, k = le(a.shape, "float32"), _ = 1 / (d * f), $ = t6.data.get(n.dataId).values, A = le(n.shape, "float32", $);
+ for (let R = 0; R < c.batchSize; ++R)
for (let D = 0; D < c.inChannels; ++D)
- for (let O = 0; O < c.inHeight; ++O)
+ for (let P = 0; P < c.inHeight; ++P)
for (let M = 0; M < c.inWidth; ++M) {
- let L = O - w, W = M - C, V = 0;
- for (let G = 0; G < y; G += h) {
- let q = (L + G) / l;
+ let L = P - w, W = M - C, V = 0;
+ for (let U = 0; U < x; U += h) {
+ let q = (L + U) / l;
if (!(q < 0 || q >= c.outHeight || Math.floor(q) !== q))
for (let H = 0; H < b; H += g) {
let j = (W + H) / m;
if (j < 0 || j >= c.outWidth || Math.floor(j) !== j)
continue;
- let Y = R.get(A, q, j, D);
- V += Y;
+ let X = A.get(R, q, j, D);
+ V += X;
}
}
- k.set(V * _, A, O, M, D);
+ k.set(V * _, R, P, M, D);
}
- return t10.makeTensorInfo(k.shape, k.dtype, k.values);
+ return t6.makeTensorInfo(k.shape, k.dtype, k.values);
}
-var A2 = { kernelName: Am, backendName: "cpu", kernelFunc: Vj };
-function zj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, scale: s, offset: a, mean: i, variance: p } = e;
- x.assert(i.shape.length === p.shape.length, () => "Batch normalization gradient requires mean and variance to have equal ranks."), x.assert(a == null || i.shape.length === a.shape.length, () => "Batch normalization gradient requires mean and offset to have equal ranks."), x.assert(s == null || i.shape.length === s.shape.length, () => "Batch normalization gradient requires mean and scale to have equal ranks."), K([n, i, p, s, a], "batchNorm");
+var i2 = { kernelName: wm, backendName: "cpu", kernelFunc: uj };
+function pj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, scale: s, offset: a, mean: i, variance: p } = e;
+ y.assert(i.shape.length === p.shape.length, () => "Batch normalization gradient requires mean and variance to have equal ranks."), y.assert(a == null || i.shape.length === a.shape.length, () => "Batch normalization gradient requires mean and offset to have equal ranks."), y.assert(s == null || i.shape.length === s.shape.length, () => "Batch normalization gradient requires mean and scale to have equal ranks."), K([n, i, p, s, a], "batchNorm");
let { varianceEpsilon: u } = o;
u == null && (u = 1e-3);
- let c = t10.data.get(n.dataId).values, l = t10.data.get(i.dataId).values, m = t10.data.get(p.dataId).values, f = s ? t10.data.get(s.dataId).values : new Float32Array([1]), d = a ? t10.data.get(a.dataId).values : new Float32Array([0]), h = new Float32Array(c.length), g = d.length, y = f.length, b = m.length, C = l.length, w = 0, k = 0, _ = 0, E = 0;
- for (let R = 0; R < c.length; ++R)
- h[R] = d[w++] + (c[R] - l[k++]) * f[_++] / Math.sqrt(m[E++] + u), w >= g && (w = 0), k >= C && (k = 0), _ >= y && (_ = 0), E >= b && (E = 0);
- return t10.makeTensorInfo(n.shape, n.dtype, h);
+ let c = t6.data.get(n.dataId).values, l = t6.data.get(i.dataId).values, m = t6.data.get(p.dataId).values, d = s ? t6.data.get(s.dataId).values : new Float32Array([1]), f = a ? t6.data.get(a.dataId).values : new Float32Array([0]), h = new Float32Array(c.length), g = f.length, x = d.length, b = m.length, C = l.length, w = 0, k = 0, _ = 0, $ = 0;
+ for (let A = 0; A < c.length; ++A)
+ h[A] = f[w++] + (c[A] - l[k++]) * d[_++] / Math.sqrt(m[$++] + u), w >= g && (w = 0), k >= C && (k = 0), _ >= x && (_ = 0), $ >= b && ($ = 0);
+ return t6.makeTensorInfo(n.shape, n.dtype, h);
}
-var F2 = { kernelName: kn, backendName: "cpu", kernelFunc: zj };
-function Wj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { blockShape: s, crops: a } = o;
+var u2 = { kernelName: an, backendName: "cpu", kernelFunc: pj };
+function cj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { blockShape: s, crops: a } = o;
K([n], "batchToSpaceND");
- let i = s.reduce((y, b) => y * b), p = I.getReshaped(n.shape, s, i), u = I.getPermuted(p.length, s.length), c = I.getReshapedPermuted(n.shape, s, i), l = I.getSliceBeginCoords(a, s.length), m = I.getSliceSize(c, a, s.length), f = Oe({ inputs: { x: n }, backend: t10, attrs: { shape: p } }), d = bt({ inputs: { x: f }, backend: t10, attrs: { perm: u } }), h = Oe({ inputs: { x: d }, backend: t10, attrs: { shape: c } }), g = qo({ inputs: { x: h }, backend: t10, attrs: { begin: l, size: m } });
- return t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(d), t10.disposeIntermediateTensorInfo(h), g;
+ let i = s.reduce((x, b) => x * b), p = S.getReshaped(n.shape, s, i), u = S.getPermuted(p.length, s.length), c = S.getReshapedPermuted(n.shape, s, i), l = S.getSliceBeginCoords(a, s.length), m = S.getSliceSize(c, a, s.length), d = Me({ inputs: { x: n }, backend: t6, attrs: { shape: p } }), f = Ct({ inputs: { x: d }, backend: t6, attrs: { perm: u } }), h = Me({ inputs: { x: f }, backend: t6, attrs: { shape: c } }), g = No({ inputs: { x: h }, backend: t6, attrs: { begin: l, size: m } });
+ return t6.disposeIntermediateTensorInfo(d), t6.disposeIntermediateTensorInfo(f), t6.disposeIntermediateTensorInfo(h), g;
}
-var D2 = { kernelName: hs, backendName: "cpu", kernelFunc: Wj };
-function Uj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, weights: s } = e, { size: a } = o, i = t10.data.get(n.dataId).values, p = t10.data.get(s.dataId).values, u = Zp(i, p, s.dtype, s.shape, a);
- return t10.makeTensorInfo([a], s.dtype, u);
+var p2 = { kernelName: xs, backendName: "cpu", kernelFunc: cj };
+function lj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, weights: s } = e, { size: a } = o, i = t6.data.get(n.dataId).values, p = t6.data.get(s.dataId).values, u = Kp(i, p, s.dtype, s.shape, a);
+ return t6.makeTensorInfo([a], s.dtype, u);
}
-var P2 = { kernelName: up, backendName: "cpu", kernelFunc: Uj };
-function Gj(r) {
- let { inputs: e, backend: t10 } = r, { s0: o, s1: n } = e, s = t10.data.get(o.dataId).values, a = t10.data.get(n.dataId).values, i = I.assertAndGetBroadcastShape(Array.from(s), Array.from(a));
- return t10.makeTensorInfo([i.length], "int32", Int32Array.from(i));
+var c2 = { kernelName: Ja, backendName: "cpu", kernelFunc: lj };
+function mj(r) {
+ let { inputs: e, backend: t6 } = r, { s0: o, s1: n } = e, s = t6.data.get(o.dataId).values, a = t6.data.get(n.dataId).values, i = S.assertAndGetBroadcastShape(Array.from(s), Array.from(a));
+ return t6.makeTensorInfo([i.length], "int32", Int32Array.from(i));
}
-var O2 = { kernelName: pp, backendName: "cpu", kernelFunc: Gj };
-var Hj = we(Ro, (r, e) => {
- let t10 = e;
- return r > t10.clipValueMax ? t10.clipValueMax : r < t10.clipValueMin ? t10.clipValueMin : r;
+var l2 = { kernelName: up, backendName: "cpu", kernelFunc: mj };
+var dj = Ie(lo, (r, e) => {
+ let t6 = e;
+ return r > t6.clipValueMax ? t6.clipValueMax : r < t6.clipValueMin ? t6.clipValueMin : r;
});
-var M2 = { kernelName: Ro, backendName: "cpu", kernelFunc: Hj };
-var qj = (r) => {
- let { x: e } = r.inputs, t10 = r.backend, o = new Float32Array(x.sizeFromShape(e.shape)), n = t10.data.get(e.dataId), s = n.complexTensorInfos.real, a = n.complexTensorInfos.imag, i = t10.data.get(s.dataId).values, p = t10.data.get(a.dataId).values;
+var m2 = { kernelName: lo, backendName: "cpu", kernelFunc: dj };
+var fj = (r) => {
+ let { x: e } = r.inputs, t6 = r.backend, o = new Float32Array(y.sizeFromShape(e.shape)), n = t6.data.get(e.dataId), s = n.complexTensorInfos.real, a = n.complexTensorInfos.imag, i = t6.data.get(s.dataId).values, p = t6.data.get(a.dataId).values;
for (let u = 0; u < i.length; u++) {
let c = i[u], l = p[u];
o[u] = Math.hypot(c, l);
}
- return t10.makeOutput(o, e.shape, "float32");
+ return t6.makeOutput(o, e.shape, "float32");
};
-var L2 = { kernelName: cp, backendName: "cpu", kernelFunc: qj };
-function qs(r) {
- let { inputs: e, backend: t10 } = r, { input: o } = e, n = t10.data.get(o.dataId).complexTensorInfos.imag, s = t10.data.get(n.dataId).values;
- return t10.makeTensorInfo(n.shape, n.dtype, s);
+var d2 = { kernelName: pp, backendName: "cpu", kernelFunc: fj };
+function Xs(r) {
+ let { inputs: e, backend: t6 } = r, { input: o } = e, n = t6.data.get(o.dataId).complexTensorInfos.imag, s = t6.data.get(n.dataId).values;
+ return t6.makeTensorInfo(n.shape, n.dtype, s);
}
-var B2 = { kernelName: Ya, backendName: "cpu", kernelFunc: qs };
-function vi(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { axis: n } = o, s = x.parseAxisParam(n, e[0].shape)[0], a = e.map((h) => h.shape);
- I.assertParamsConsistent(a, s);
- let i = I.computeOutShape(e.map((h) => h.shape), s);
- if (x.sizeFromShape(i) === 0)
- return t10.makeTensorInfo(i, e[0].dtype, []);
- let p = e.filter((h) => x.sizeFromShape(h.shape) > 0);
+var f2 = { kernelName: si, backendName: "cpu", kernelFunc: Xs };
+function Pi(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { axis: n } = o, s = y.parseAxisParam(n, e[0].shape)[0], a = e.map((h) => h.shape);
+ S.assertParamsConsistent(a, s);
+ let i = S.computeOutShape(e.map((h) => h.shape), s);
+ if (y.sizeFromShape(i) === 0)
+ return t6.makeTensorInfo(i, e[0].dtype, []);
+ let p = e.filter((h) => y.sizeFromShape(h.shape) > 0);
if (p.length === 1)
- return ar({ inputs: { x: p[0] }, backend: t10 });
+ return ar({ inputs: { x: p[0] }, backend: t6 });
if (p[0].dtype === "complex64") {
- let h = p.map((w) => Wo({ inputs: { input: w }, backend: t10 })), g = p.map((w) => qs({ inputs: { input: w }, backend: t10 })), y = vi({ inputs: h, backend: t10, attrs: { axis: s } }), b = vi({ inputs: g, backend: t10, attrs: { axis: s } }), C = qt({ inputs: { real: y, imag: b }, backend: t10 });
- return h.forEach((w) => t10.disposeIntermediateTensorInfo(w)), g.forEach((w) => t10.disposeIntermediateTensorInfo(w)), t10.disposeIntermediateTensorInfo(y), t10.disposeIntermediateTensorInfo(b), C;
+ let h = p.map((w) => wo({ inputs: { input: w }, backend: t6 })), g = p.map((w) => Xs({ inputs: { input: w }, backend: t6 })), x = Pi({ inputs: h, backend: t6, attrs: { axis: s } }), b = Pi({ inputs: g, backend: t6, attrs: { axis: s } }), C = Ht({ inputs: { real: x, imag: b }, backend: t6 });
+ return h.forEach((w) => t6.disposeIntermediateTensorInfo(w)), g.forEach((w) => t6.disposeIntermediateTensorInfo(w)), t6.disposeIntermediateTensorInfo(x), t6.disposeIntermediateTensorInfo(b), C;
}
let u = p.map((h) => {
- let y = [-1, x.sizeFromShape(h.shape.slice(s))];
- return Oe({ inputs: { x: h }, backend: t10, attrs: { shape: y } });
- }), c = u.map((h) => ({ vals: t10.data.get(h.dataId).values, shape: h.shape }));
- i = I.computeOutShape(u.map((h) => h.shape), 1);
- let l = u[0].shape[0] === 1, m = Iu(c, i, e[0].dtype, l), f = I.computeOutShape(p.map((h) => h.shape), s), d = t10.makeTensorInfo(f, e[0].dtype, m);
- return u.forEach((h) => t10.disposeIntermediateTensorInfo(h)), d;
+ let x = [-1, y.sizeFromShape(h.shape.slice(s))];
+ return Me({ inputs: { x: h }, backend: t6, attrs: { shape: x } });
+ }), c = u.map((h) => ({ vals: t6.data.get(h.dataId).values, shape: h.shape }));
+ i = S.computeOutShape(u.map((h) => h.shape), 1);
+ let l = u[0].shape[0] === 1, m = Su(c, i, e[0].dtype, l), d = S.computeOutShape(p.map((h) => h.shape), s), f = t6.makeTensorInfo(d, e[0].dtype, m);
+ return u.forEach((h) => t6.disposeIntermediateTensorInfo(h)), f;
}
-var V2 = { kernelName: gs, backendName: "cpu", kernelFunc: vi };
-function RI(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dataFormat: p, dilations: u, dimRoundingMode: c } = o;
+var h2 = { kernelName: ys, backendName: "cpu", kernelFunc: Pi };
+function NS(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dataFormat: p, dilations: u, dimRoundingMode: c } = o;
K([n, s], "conv2d");
- let l = I.convertConv2DDataFormat(p), m = I.computeConv2DInfo(n.shape, s.shape, a, u, i, c, false, l), f = m.filterHeight, d = m.filterWidth, h = m.dilationHeight, g = m.dilationWidth, y = m.padInfo.left, b = m.padInfo.top, C = m.dataFormat === "channelsLast", w = new je(m.outShape, n.dtype), k = x.computeStrides(n.shape), _ = x.computeStrides(s.shape), E = k[0], R = C ? k[1] : k[2], A = C ? k[2] : 1, D = C ? 1 : k[1], O = w.strides[0], M = C ? w.strides[1] : w.strides[2], L = C ? w.strides[2] : 1, W = C ? 1 : w.strides[1], V = t10.data.get(n.dataId).values, G = t10.data.get(s.dataId).values, q = w.values;
+ let l = S.convertConv2DDataFormat(p), m = S.computeConv2DInfo(n.shape, s.shape, a, u, i, c, false, l), d = m.filterHeight, f = m.filterWidth, h = m.dilationHeight, g = m.dilationWidth, x = m.padInfo.left, b = m.padInfo.top, C = m.dataFormat === "channelsLast", w = new st(m.outShape, n.dtype), k = y.computeStrides(n.shape), _ = y.computeStrides(s.shape), $ = k[0], A = C ? k[1] : k[2], R = C ? k[2] : 1, D = C ? 1 : k[1], P = w.strides[0], M = C ? w.strides[1] : w.strides[2], L = C ? w.strides[2] : 1, W = C ? 1 : w.strides[1], V = t6.data.get(n.dataId).values, U = t6.data.get(s.dataId).values, q = w.values;
for (let H = 0; H < m.batchSize; ++H) {
- let j = H * E, Y = H * O;
+ let j = H * $, X = H * P;
for (let Z = 0; Z < m.outHeight; ++Z) {
- let ee = Y + Z * M, X = Z * m.strideHeight - b;
- for (let Q = 0; Q < f; ++Q) {
- let se = X + Q * h;
- if (se < 0 || se >= m.inHeight)
+ let ee = X + Z * M, Y = Z * m.strideHeight - b;
+ for (let J = 0; J < d; ++J) {
+ let ie = Y + J * h;
+ if (ie < 0 || ie >= m.inHeight)
continue;
- let ie = Q * _[0], de = j + se * R;
- for (let Ie = 0; Ie < m.outWidth; ++Ie) {
- let Se = ee + Ie * L, Ee = Ie * m.strideWidth - y;
- for (let Me = 0; Me < d; ++Me) {
- let st = Ee + Me * g;
- if (st < 0 || st >= m.inWidth)
+ let pe = J * _[0], he = j + ie * A;
+ for (let we = 0; we < m.outWidth; ++we) {
+ let ve = ee + we * L, $e = we * m.strideWidth - x;
+ for (let Le = 0; Le < f; ++Le) {
+ let nt = $e + Le * g;
+ if (nt < 0 || nt >= m.inWidth)
continue;
- let pt = ie + Me * _[1], De = de + st * A, ft = pt;
+ let pt = pe + Le * _[1], Oe = he + nt * R, mt = pt;
for (let at = 0; at < m.inChannels; ++at) {
- let dt = V[De + at * D];
- for (let It = 0; It < m.outChannels; ++It)
- q[Se + It * W] += dt * G[ft + It];
- ft += m.outChannels;
+ let ft = V[Oe + at * D];
+ for (let wt = 0; wt < m.outChannels; ++wt)
+ q[ve + wt * W] += ft * U[mt + wt];
+ mt += m.outChannels;
}
}
}
}
}
}
- return t10.makeTensorInfo(w.shape, w.dtype, q);
+ return t6.makeTensorInfo(w.shape, w.dtype, q);
}
-var z2 = { kernelName: ln, backendName: "cpu", kernelFunc: RI };
-function Kj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, dy: s } = e, { strides: a, pad: i, dataFormat: p, dimRoundingMode: u, filterShape: c } = o;
+var g2 = { kernelName: Go, backendName: "cpu", kernelFunc: NS };
+function hj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, dy: s } = e, { strides: a, pad: i, dataFormat: p, dimRoundingMode: u, filterShape: c } = o;
K([n, s], "conv2dBackpropFilter");
- let l = I.convertConv2DDataFormat(p), m = I.computeConv2DInfo(n.shape, c, a, 1, i, u, false, l), { strideHeight: f, strideWidth: d, filterHeight: h, filterWidth: g } = m, y = m.dataFormat === "channelsLast", b = new je(m.filterShape, "float32"), C = m.padInfo.left, w = m.padInfo.top, k = t10.data.get(n.dataId).values, _ = t10.data.get(s.dataId).values, E = new je(n.shape, n.dtype, k), R = new je(s.shape, s.dtype, _);
- for (let A = 0; A < h; ++A) {
- let D = Math.max(0, Math.ceil((w - A) / f)), O = Math.min(m.outHeight, (m.inHeight + w - A) / f);
+ let l = S.convertConv2DDataFormat(p), m = S.computeConv2DInfo(n.shape, c, a, 1, i, u, false, l), { strideHeight: d, strideWidth: f, filterHeight: h, filterWidth: g } = m, x = m.dataFormat === "channelsLast", b = new st(m.filterShape, "float32"), C = m.padInfo.left, w = m.padInfo.top, k = t6.data.get(n.dataId).values, _ = t6.data.get(s.dataId).values, $ = new st(n.shape, n.dtype, k), A = new st(s.shape, s.dtype, _);
+ for (let R = 0; R < h; ++R) {
+ let D = Math.max(0, Math.ceil((w - R) / d)), P = Math.min(m.outHeight, (m.inHeight + w - R) / d);
for (let M = 0; M < g; ++M) {
- let L = Math.max(0, Math.ceil((C - M) / d)), W = Math.min(m.outWidth, (m.inWidth + C - M) / d);
+ let L = Math.max(0, Math.ceil((C - M) / f)), W = Math.min(m.outWidth, (m.inWidth + C - M) / f);
for (let V = 0; V < m.inChannels; ++V)
- for (let G = 0; G < m.outChannels; ++G) {
+ for (let U = 0; U < m.outChannels; ++U) {
let q = 0;
for (let H = 0; H < m.batchSize; ++H)
- for (let j = D; j < O; ++j) {
- let Y = A + j * f - w;
+ for (let j = D; j < P; ++j) {
+ let X = R + j * d - w;
for (let Z = L; Z < W; ++Z) {
- let ee = M + Z * d - C;
- y ? q += E.get(H, Y, ee, V) * R.get(H, j, Z, G) : q += E.get(H, V, Y, ee) * R.get(H, G, j, Z);
+ let ee = M + Z * f - C;
+ x ? q += $.get(H, X, ee, V) * A.get(H, j, Z, U) : q += $.get(H, V, X, ee) * A.get(H, U, j, Z);
}
}
- b.set(q, A, M, V, G);
+ b.set(q, R, M, V, U);
}
}
}
- return t10.makeTensorInfo(b.shape, b.dtype, b.values);
+ return t6.makeTensorInfo(b.shape, b.dtype, b.values);
}
-var W2 = { kernelName: lp, backendName: "cpu", kernelFunc: Kj };
-function jj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, filter: s } = e, { inputShape: a, strides: i, pad: p, dataFormat: u, dimRoundingMode: c } = o;
+var x2 = { kernelName: cp, backendName: "cpu", kernelFunc: hj };
+function gj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, filter: s } = e, { inputShape: a, strides: i, pad: p, dataFormat: u, dimRoundingMode: c } = o;
K([n, s], "conv2dBackpropInput");
- let l = x.computeStrides(s.shape), m = x.computeStrides(n.shape), f = I.convertConv2DDataFormat(u), d = I.computeConv2DInfo(a, s.shape, i, 1, p, c, false, f), h = new je(d.inShape, "float32"), g = h.values, y = t10.data.get(n.dataId).values, b = t10.data.get(s.dataId).values, [C, w, k] = l, { batchSize: _, filterHeight: E, filterWidth: R, inChannels: A, inHeight: D, inWidth: O, outChannels: M, outHeight: L, outWidth: W, strideHeight: V, strideWidth: G } = d;
- f = d.dataFormat;
- let q = E - 1 - d.padInfo.top, H = R - 1 - d.padInfo.left, j = f === "channelsLast", Y = h.strides[0], Z = j ? h.strides[1] : h.strides[2], ee = j ? h.strides[2] : 1, X = j ? 1 : h.strides[1], Q = m[0], se = j ? m[1] : m[2], ie = j ? m[2] : 1, de = j ? 1 : m[1];
- for (let Ie = 0; Ie < _; ++Ie)
- for (let Se = 0; Se < A; ++Se)
- for (let Ee = 0; Ee < D; ++Ee) {
- let Me = Ee - q, st = Math.max(0, Math.ceil(Me / V)), pt = Math.min(L, (E + Me) / V);
- for (let De = 0; De < O; ++De) {
- let ft = De - H, at = Math.max(0, Math.ceil(ft / G)), dt = Math.min(W, (R + ft) / G), It = 0;
- for (let Pt = st; Pt < pt; ++Pt) {
- let jr = Pt * V - Me;
- for (let er = at; er < dt; ++er) {
- let Tt = er * G - ft, tr = Q * Ie + se * Pt + ie * er, rr = C * (E - 1 - jr) + w * (R - 1 - Tt) + k * Se;
- for (let Xr = 0; Xr < M; ++Xr) {
- let Yr = y[tr + de * Xr], pr = b[rr + Xr];
- It += Yr * pr;
+ let l = y.computeStrides(s.shape), m = y.computeStrides(n.shape), d = S.convertConv2DDataFormat(u), f = S.computeConv2DInfo(a, s.shape, i, 1, p, c, false, d), h = new st(f.inShape, "float32"), g = h.values, x = t6.data.get(n.dataId).values, b = t6.data.get(s.dataId).values, [C, w, k] = l, { batchSize: _, filterHeight: $, filterWidth: A, inChannels: R, inHeight: D, inWidth: P, outChannels: M, outHeight: L, outWidth: W, strideHeight: V, strideWidth: U } = f;
+ d = f.dataFormat;
+ let q = $ - 1 - f.padInfo.top, H = A - 1 - f.padInfo.left, j = d === "channelsLast", X = h.strides[0], Z = j ? h.strides[1] : h.strides[2], ee = j ? h.strides[2] : 1, Y = j ? 1 : h.strides[1], J = m[0], ie = j ? m[1] : m[2], pe = j ? m[2] : 1, he = j ? 1 : m[1];
+ for (let we = 0; we < _; ++we)
+ for (let ve = 0; ve < R; ++ve)
+ for (let $e = 0; $e < D; ++$e) {
+ let Le = $e - q, nt = Math.max(0, Math.ceil(Le / V)), pt = Math.min(L, ($ + Le) / V);
+ for (let Oe = 0; Oe < P; ++Oe) {
+ let mt = Oe - H, at = Math.max(0, Math.ceil(mt / U)), ft = Math.min(W, (A + mt) / U), wt = 0;
+ for (let Ot = nt; Ot < pt; ++Ot) {
+ let Kr = Ot * V - Le;
+ for (let er = at; er < ft; ++er) {
+ let Nt = er * U - mt, tr = J * we + ie * Ot + pe * er, rr = C * ($ - 1 - Kr) + w * (A - 1 - Nt) + k * ve;
+ for (let jr = 0; jr < M; ++jr) {
+ let Xr = x[tr + he * jr], pr = b[rr + jr];
+ wt += Xr * pr;
}
}
}
- let Fr = Y * Ie + Z * Ee + ee * De + X * Se;
- g[Fr] = It;
+ let Fr = X * we + Z * $e + ee * Oe + Y * ve;
+ g[Fr] = wt;
}
}
- return t10.makeTensorInfo(h.shape, h.dtype, h.values);
+ return t6.makeTensorInfo(h.shape, h.dtype, h.values);
}
-var U2 = { kernelName: mn, backendName: "cpu", kernelFunc: jj };
-function Xj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p } = o;
+var y2 = { kernelName: Ho, backendName: "cpu", kernelFunc: gj };
+function xj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p } = o;
K([n, s], "conv3d");
- let u = I.computeConv3DInfo(n.shape, s.shape, a, p, i), { filterDepth: c, filterHeight: l, filterWidth: m, dilationDepth: f, dilationHeight: d, dilationWidth: h, padInfo: g } = u, y = g.front, b = g.left, C = g.top, w = new je(u.outShape, n.dtype), k = t10.data.get(n.dataId).values, _ = t10.data.get(s.dataId).values, E = w.values, R = x.computeStrides(n.shape), A = x.computeStrides(s.shape);
+ let u = S.computeConv3DInfo(n.shape, s.shape, a, p, i), { filterDepth: c, filterHeight: l, filterWidth: m, dilationDepth: d, dilationHeight: f, dilationWidth: h, padInfo: g } = u, x = g.front, b = g.left, C = g.top, w = new st(u.outShape, n.dtype), k = t6.data.get(n.dataId).values, _ = t6.data.get(s.dataId).values, $ = w.values, A = y.computeStrides(n.shape), R = y.computeStrides(s.shape);
for (let D = 0; D < u.batchSize; ++D) {
- let O = D * R[0], M = D * w.strides[0];
+ let P = D * A[0], M = D * w.strides[0];
for (let L = 0; L < u.outDepth; ++L) {
- let W = M + L * w.strides[1], V = L * u.strideDepth - y;
- for (let G = 0; G < c; ++G) {
- let q = V + G * f;
+ let W = M + L * w.strides[1], V = L * u.strideDepth - x;
+ for (let U = 0; U < c; ++U) {
+ let q = V + U * d;
if (q < 0 || q >= u.inDepth)
continue;
- let H = G * A[0], j = O + q * R[1];
- for (let Y = 0; Y < u.outHeight; ++Y) {
- let Z = W + Y * w.strides[2], ee = Y * u.strideHeight - C;
- for (let X = 0; X < l; ++X) {
- let Q = ee + X * d;
- if (Q < 0 || Q >= u.inHeight)
+ let H = U * R[0], j = P + q * A[1];
+ for (let X = 0; X < u.outHeight; ++X) {
+ let Z = W + X * w.strides[2], ee = X * u.strideHeight - C;
+ for (let Y = 0; Y < l; ++Y) {
+ let J = ee + Y * f;
+ if (J < 0 || J >= u.inHeight)
continue;
- let se = H + X * A[1], ie = j + Q * R[2];
- for (let de = 0; de < u.outWidth; ++de) {
- let Ie = Z + de * u.outChannels, Se = de * u.strideWidth - b;
- for (let Ee = 0; Ee < m; ++Ee) {
- let Me = Se + Ee * h;
- if (Me < 0 || Me >= u.inWidth)
+ let ie = H + Y * R[1], pe = j + J * A[2];
+ for (let he = 0; he < u.outWidth; ++he) {
+ let we = Z + he * u.outChannels, ve = he * u.strideWidth - b;
+ for (let $e = 0; $e < m; ++$e) {
+ let Le = ve + $e * h;
+ if (Le < 0 || Le >= u.inWidth)
continue;
- let st = se + Ee * A[2], pt = ie + Me * u.inChannels, De = st;
- for (let ft = 0; ft < u.inChannels; ++ft) {
- let at = k[pt + ft];
- for (let dt = 0; dt < u.outChannels; ++dt)
- E[Ie + dt] += at * _[De + dt];
- De += u.outChannels;
+ let nt = ie + $e * R[2], pt = pe + Le * u.inChannels, Oe = nt;
+ for (let mt = 0; mt < u.inChannels; ++mt) {
+ let at = k[pt + mt];
+ for (let ft = 0; ft < u.outChannels; ++ft)
+ $[we + ft] += at * _[Oe + ft];
+ Oe += u.outChannels;
}
}
}
@@ -13303,549 +13349,549 @@ function Xj(r) {
}
}
}
- return t10.makeTensorInfo(w.shape, w.dtype, w.values);
+ return t6.makeTensorInfo(w.shape, w.dtype, w.values);
}
-var G2 = { kernelName: mp, backendName: "cpu", kernelFunc: Xj };
-function Yj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, dy: s } = e, { strides: a, pad: i, filterShape: p } = o;
+var b2 = { kernelName: lp, backendName: "cpu", kernelFunc: xj };
+function yj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, dy: s } = e, { strides: a, pad: i, filterShape: p } = o;
K([n, s], "conv3dBackpropFilterV2");
- let u = x.computeStrides(n.shape), c = x.computeStrides(s.shape), l = I.computeConv3DInfo(n.shape, p, a, 1, i), m = l.strideDepth, f = l.strideHeight, d = l.strideWidth, h = l.filterDepth, g = l.filterHeight, y = l.filterWidth, b = new je(l.filterShape, "float32"), C = b.values, [w, k, _, E] = b.strides, R = t10.data.get(s.dataId).values, [A, D, O, M] = c, L = t10.data.get(n.dataId).values, [W, V, G, q] = u, H = l.padInfo.front, j = l.padInfo.left, Y = l.padInfo.top;
+ let u = y.computeStrides(n.shape), c = y.computeStrides(s.shape), l = S.computeConv3DInfo(n.shape, p, a, 1, i), m = l.strideDepth, d = l.strideHeight, f = l.strideWidth, h = l.filterDepth, g = l.filterHeight, x = l.filterWidth, b = new st(l.filterShape, "float32"), C = b.values, [w, k, _, $] = b.strides, A = t6.data.get(s.dataId).values, [R, D, P, M] = c, L = t6.data.get(n.dataId).values, [W, V, U, q] = u, H = l.padInfo.front, j = l.padInfo.left, X = l.padInfo.top;
for (let Z = 0; Z < h; ++Z) {
- let ee = Math.max(0, Math.ceil((H - Z) / m)), X = Math.min(l.outDepth, (l.inDepth + H - Z) / m), Q = Z * w;
- for (let se = 0; se < g; ++se) {
- let ie = Math.max(0, Math.ceil((Y - se) / f)), de = Math.min(l.outHeight, (l.inHeight + Y - se) / f), Ie = se * k + Q;
- for (let Se = 0; Se < y; ++Se) {
- let Ee = Math.max(0, Math.ceil((j - Se) / d)), Me = Math.min(l.outWidth, (l.inWidth + j - Se) / d), st = Se * _ + Ie;
+ let ee = Math.max(0, Math.ceil((H - Z) / m)), Y = Math.min(l.outDepth, (l.inDepth + H - Z) / m), J = Z * w;
+ for (let ie = 0; ie < g; ++ie) {
+ let pe = Math.max(0, Math.ceil((X - ie) / d)), he = Math.min(l.outHeight, (l.inHeight + X - ie) / d), we = ie * k + J;
+ for (let ve = 0; ve < x; ++ve) {
+ let $e = Math.max(0, Math.ceil((j - ve) / f)), Le = Math.min(l.outWidth, (l.inWidth + j - ve) / f), nt = ve * _ + we;
for (let pt = 0; pt < l.inChannels; ++pt) {
- let De = pt * E + st;
- for (let ft = 0; ft < l.outChannels; ++ft) {
+ let Oe = pt * $ + nt;
+ for (let mt = 0; mt < l.outChannels; ++mt) {
let at = 0;
- for (let dt = 0; dt < l.batchSize; ++dt) {
- let It = dt * W, Fr = dt * A;
- for (let Pt = ee; Pt < X; ++Pt) {
- let er = (Z + Pt * m - H) * V + It, Tt = Pt * D + Fr;
- for (let tr = ie; tr < de; ++tr) {
- let Xr = (se + tr * f - Y) * G + er, Yr = tr * O + Tt;
- for (let pr = Ee; pr < Me; ++pr) {
- let tn = (Se + pr * d - j) * q + Xr, Ua = pr * M + Yr;
- at += L[tn + pt] * R[Ua + ft];
+ for (let ft = 0; ft < l.batchSize; ++ft) {
+ let wt = ft * W, Fr = ft * R;
+ for (let Ot = ee; Ot < Y; ++Ot) {
+ let er = (Z + Ot * m - H) * V + wt, Nt = Ot * D + Fr;
+ for (let tr = pe; tr < he; ++tr) {
+ let jr = (ie + tr * d - X) * U + er, Xr = tr * P + Nt;
+ for (let pr = $e; pr < Le; ++pr) {
+ let Fo = (ve + pr * f - j) * q + jr, Ka = pr * M + Xr;
+ at += L[Fo + pt] * A[Ka + mt];
}
}
}
}
- C[De + ft] = at;
+ C[Oe + mt] = at;
}
}
}
}
}
- return t10.makeTensorInfo(b.shape, b.dtype, b.values);
+ return t6.makeTensorInfo(b.shape, b.dtype, b.values);
}
-var H2 = { kernelName: Dm, backendName: "cpu", kernelFunc: Yj };
-function Qj(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, filter: s } = e, { pad: a, strides: i, inputShape: p } = o;
+var C2 = { kernelName: vm, backendName: "cpu", kernelFunc: yj };
+function bj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, filter: s } = e, { pad: a, strides: i, inputShape: p } = o;
K([n], "conv3dBackpropInputV2");
- let u = x.computeStrides(n.shape), c = x.computeStrides(s.shape), l = I.computeConv3DInfo(p, s.shape, i, 1, a), m = new je(l.inShape, "float32"), f = m.values, [d, h, g, y] = m.strides, b = t10.data.get(n.dataId).values, [C, w, k, _] = u, E = t10.data.get(s.dataId).values, [R, A, D, O] = c, { batchSize: M, filterDepth: L, filterHeight: W, filterWidth: V, inChannels: G, inDepth: q, inHeight: H, inWidth: j, outChannels: Y, outDepth: Z, outHeight: ee, outWidth: X, strideDepth: Q, strideHeight: se, strideWidth: ie } = l, de = L - 1 - l.padInfo.front, Ie = W - 1 - l.padInfo.top, Se = V - 1 - l.padInfo.left;
- for (let Ee = 0; Ee < M; ++Ee)
- for (let Me = 0; Me < G; ++Me)
- for (let st = 0; st < q; ++st) {
- let pt = st - de, De = Math.max(0, Math.ceil(pt / Q)), ft = Math.min(Z, (L + pt) / Q);
+ let u = y.computeStrides(n.shape), c = y.computeStrides(s.shape), l = S.computeConv3DInfo(p, s.shape, i, 1, a), m = new st(l.inShape, "float32"), d = m.values, [f, h, g, x] = m.strides, b = t6.data.get(n.dataId).values, [C, w, k, _] = u, $ = t6.data.get(s.dataId).values, [A, R, D, P] = c, { batchSize: M, filterDepth: L, filterHeight: W, filterWidth: V, inChannels: U, inDepth: q, inHeight: H, inWidth: j, outChannels: X, outDepth: Z, outHeight: ee, outWidth: Y, strideDepth: J, strideHeight: ie, strideWidth: pe } = l, he = L - 1 - l.padInfo.front, we = W - 1 - l.padInfo.top, ve = V - 1 - l.padInfo.left;
+ for (let $e = 0; $e < M; ++$e)
+ for (let Le = 0; Le < U; ++Le)
+ for (let nt = 0; nt < q; ++nt) {
+ let pt = nt - he, Oe = Math.max(0, Math.ceil(pt / J)), mt = Math.min(Z, (L + pt) / J);
for (let at = 0; at < H; ++at) {
- let dt = at - Ie, It = Math.max(0, Math.ceil(dt / se)), Fr = Math.min(ee, (W + dt) / se);
- for (let Pt = 0; Pt < j; ++Pt) {
- let jr = Pt - Se, er = Math.max(0, Math.ceil(jr / ie)), Tt = Math.min(X, (V + jr) / ie), tr = 0;
- for (let rr = De; rr < ft; ++rr) {
- let Xr = rr * Q - pt;
- for (let Yr = It; Yr < Fr; ++Yr) {
- let pr = Yr * se - dt;
- for (let Qs = er; Qs < Tt; ++Qs) {
- let tn = Qs * ie - jr, Ua = C * Ee + w * rr + k * Yr + _ * Qs, jt = R * (L - 1 - Xr) + A * (W - 1 - pr) + D * (V - 1 - tn) + O * Me;
- for (let Zs = 0; Zs < Y; ++Zs) {
- let Lc = b[Ua + Zs], Bc = E[jt + Zs];
- tr += Lc * Bc;
+ let ft = at - we, wt = Math.max(0, Math.ceil(ft / ie)), Fr = Math.min(ee, (W + ft) / ie);
+ for (let Ot = 0; Ot < j; ++Ot) {
+ let Kr = Ot - ve, er = Math.max(0, Math.ceil(Kr / pe)), Nt = Math.min(Y, (V + Kr) / pe), tr = 0;
+ for (let rr = Oe; rr < mt; ++rr) {
+ let jr = rr * J - pt;
+ for (let Xr = wt; Xr < Fr; ++Xr) {
+ let pr = Xr * ie - ft;
+ for (let Js = er; Js < Nt; ++Js) {
+ let Fo = Js * pe - Kr, Ka = C * $e + w * rr + k * Xr + _ * Js, Kt = A * (L - 1 - jr) + R * (W - 1 - pr) + D * (V - 1 - Fo) + P * Le;
+ for (let ea = 0; ea < X; ++ea) {
+ let Ac = b[Ka + ea], Rc = $[Kt + ea];
+ tr += Ac * Rc;
}
}
}
}
- f[d * Ee + h * st + g * at + y * Pt + Me] = tr;
+ d[f * $e + h * nt + g * at + x * Ot + Le] = tr;
}
}
}
- return t10.makeTensorInfo(m.shape, m.dtype, m.values);
+ return t6.makeTensorInfo(m.shape, m.dtype, m.values);
}
-var q2 = { kernelName: fp, backendName: "cpu", kernelFunc: Qj };
-var Zj = we(fn, (r) => Math.cos(r));
-var K2 = { kernelName: fn, backendName: "cpu", kernelFunc: Zj };
-var Jj = we(dn, (r) => Math.cosh(r));
-var j2 = { kernelName: dn, backendName: "cpu", kernelFunc: Jj };
-function eX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { image: n, boxes: s, boxInd: a } = e, { cropSize: i, method: p, extrapolationValue: u } = o, [c, l, m, f] = n.shape, d = s.shape[0], [h, g] = i, y = ne([d, h, g, f], "float32"), b = t10.data.get(s.dataId).values, C = t10.data.get(a.dataId).values, w = t10.data.get(n.dataId).values, k = x.computeStrides(n.shape), _ = x.computeStrides(y.shape);
- for (let E = 0; E < d; E++) {
- let R = E * 4, A = b[R], D = b[R + 1], O = b[R + 2], M = b[R + 3], L = C[E];
+var S2 = { kernelName: mp, backendName: "cpu", kernelFunc: bj };
+var Cj = Ie(qo, (r) => Math.cos(r));
+var w2 = { kernelName: qo, backendName: "cpu", kernelFunc: Cj };
+var Sj = Ie(Ko, (r) => Math.cosh(r));
+var I2 = { kernelName: Ko, backendName: "cpu", kernelFunc: Sj };
+function wj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { image: n, boxes: s, boxInd: a } = e, { cropSize: i, method: p, extrapolationValue: u } = o, [c, l, m, d] = n.shape, f = s.shape[0], [h, g] = i, x = le([f, h, g, d], "float32"), b = t6.data.get(s.dataId).values, C = t6.data.get(a.dataId).values, w = t6.data.get(n.dataId).values, k = y.computeStrides(n.shape), _ = y.computeStrides(x.shape);
+ for (let $ = 0; $ < f; $++) {
+ let A = $ * 4, R = b[A], D = b[A + 1], P = b[A + 2], M = b[A + 3], L = C[$];
if (L >= c)
continue;
- let W = h > 1 ? (O - A) * (l - 1) / (h - 1) : 0, V = g > 1 ? (M - D) * (m - 1) / (g - 1) : 0;
- for (let G = 0; G < h; G++) {
- let q = h > 1 ? A * (l - 1) + G * W : 0.5 * (A + O) * (l - 1);
+ let W = h > 1 ? (P - R) * (l - 1) / (h - 1) : 0, V = g > 1 ? (M - D) * (m - 1) / (g - 1) : 0;
+ for (let U = 0; U < h; U++) {
+ let q = h > 1 ? R * (l - 1) + U * W : 0.5 * (R + P) * (l - 1);
if (q < 0 || q > l - 1) {
for (let H = 0; H < g; H++)
- for (let j = 0; j < f; j++) {
- let Y = j + H * _[2] + G * _[1] + E * _[0];
- y.values[Y] = u;
+ for (let j = 0; j < d; j++) {
+ let X = j + H * _[2] + U * _[1] + $ * _[0];
+ x.values[X] = u;
}
continue;
}
if (p === "bilinear") {
- let H = Math.floor(q), j = Math.ceil(q), Y = q - H;
+ let H = Math.floor(q), j = Math.ceil(q), X = q - H;
for (let Z = 0; Z < g; Z++) {
let ee = g > 1 ? D * (m - 1) + Z * V : 0.5 * (D + M) * (m - 1);
if (ee < 0 || ee > m - 1) {
- for (let ie = 0; ie < f; ie++) {
- let de = ie + Z * _[2] + G * _[1] + E * _[0];
- y.values[de] = u;
+ for (let pe = 0; pe < d; pe++) {
+ let he = pe + Z * _[2] + U * _[1] + $ * _[0];
+ x.values[he] = u;
}
continue;
}
- let X = Math.floor(ee), Q = Math.ceil(ee), se = ee - X;
- for (let ie = 0; ie < f; ie++) {
- let de = ie + X * k[2] + H * k[1] + L * k[0], Ie = w[de];
- de = ie + Q * k[2] + H * k[1] + L * k[0];
- let Se = w[de];
- de = ie + X * k[2] + j * k[1] + L * k[0];
- let Ee = w[de];
- de = ie + Q * k[2] + j * k[1] + L * k[0];
- let Me = w[de], st = Ie + (Se - Ie) * se, pt = Ee + (Me - Ee) * se;
- de = ie + Z * _[2] + G * _[1] + E * _[0], y.values[de] = st + (pt - st) * Y;
+ let Y = Math.floor(ee), J = Math.ceil(ee), ie = ee - Y;
+ for (let pe = 0; pe < d; pe++) {
+ let he = pe + Y * k[2] + H * k[1] + L * k[0], we = w[he];
+ he = pe + J * k[2] + H * k[1] + L * k[0];
+ let ve = w[he];
+ he = pe + Y * k[2] + j * k[1] + L * k[0];
+ let $e = w[he];
+ he = pe + J * k[2] + j * k[1] + L * k[0];
+ let Le = w[he], nt = we + (ve - we) * ie, pt = $e + (Le - $e) * ie;
+ he = pe + Z * _[2] + U * _[1] + $ * _[0], x.values[he] = nt + (pt - nt) * X;
}
}
} else
for (let H = 0; H < g; ++H) {
let j = g > 1 ? D * (m - 1) + H * V : 0.5 * (D + M) * (m - 1);
if (j < 0 || j > m - 1) {
- for (let ee = 0; ee < f; ee++) {
- let X = ee + H * _[2] + G * _[1] + E * _[0];
- y.values[X] = u;
+ for (let ee = 0; ee < d; ee++) {
+ let Y = ee + H * _[2] + U * _[1] + $ * _[0];
+ x.values[Y] = u;
}
continue;
}
- let Y = Math.round(j), Z = Math.round(q);
- for (let ee = 0; ee < f; ee++) {
- let X = ee + Y * k[2] + Z * k[1] + L * k[0], Q = ee + H * _[2] + G * _[1] + E * _[0];
- y.values[Q] = w[X];
+ let X = Math.round(j), Z = Math.round(q);
+ for (let ee = 0; ee < d; ee++) {
+ let Y = ee + X * k[2] + Z * k[1] + L * k[0], J = ee + H * _[2] + U * _[1] + $ * _[0];
+ x.values[J] = w[Y];
}
}
}
}
- return t10.makeTensorInfo(y.shape, y.dtype, y.values);
+ return t6.makeTensorInfo(x.shape, x.dtype, x.values);
}
-var X2 = { kernelName: xn, backendName: "cpu", kernelFunc: eX };
-function tX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o;
+var v2 = { kernelName: Yo, backendName: "cpu", kernelFunc: wj };
+function Ij(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o;
K(n, "cumprod");
- let p = I.getAxesPermutation([s], n.shape.length), u = n;
- p != null && (u = bt({ inputs: { x: n }, backend: t10, attrs: { perm: p } }));
- let c = I.getInnerMostAxes(1, n.shape.length)[0];
+ let p = S.getAxesPermutation([s], n.shape.length), u = n;
+ p != null && (u = Ct({ inputs: { x: n }, backend: t6, attrs: { perm: p } }));
+ let c = S.getInnerMostAxes(1, n.shape.length)[0];
if (c !== u.shape.length - 1)
throw new Error(`backend.cumprod in CPU expects an inner-most axis=${u.shape.length - 1} but got axis=${c}`);
- let l = ct(u.dtype, "int32"), m = x.makeOnesTypedArray(x.sizeFromShape(u.shape), l), f = t10.data.get(u.dataId).values, d = u.shape[u.shape.length - 1], h = i ? (y, b) => y + d - b - 1 : (y, b) => y + b;
- for (let y = 0; y < f.length; y += d)
- for (let b = 0; b < d; b++) {
- let C = h(y, b);
+ let l = dt(u.dtype, "int32"), m = y.makeOnesTypedArray(y.sizeFromShape(u.shape), l), d = t6.data.get(u.dataId).values, f = u.shape[u.shape.length - 1], h = i ? (x, b) => x + f - b - 1 : (x, b) => x + b;
+ for (let x = 0; x < d.length; x += f)
+ for (let b = 0; b < f; b++) {
+ let C = h(x, b);
if (b === 0)
- m[C] = a ? 1 : f[C];
+ m[C] = a ? 1 : d[C];
else {
- let w = h(y, b - 1);
- m[C] = a ? f[w] * m[w] : f[C] * m[w];
+ let w = h(x, b - 1);
+ m[C] = a ? d[w] * m[w] : d[C] * m[w];
}
}
- let g = t10.makeTensorInfo(u.shape, l, m);
+ let g = t6.makeTensorInfo(u.shape, l, m);
if (p != null) {
- let y = I.getUndoAxesPermutation(p), b = bt({ inputs: { x: g }, backend: t10, attrs: { perm: y } });
- return t10.disposeIntermediateTensorInfo(g), t10.disposeIntermediateTensorInfo(u), b;
+ let x = S.getUndoAxesPermutation(p), b = Ct({ inputs: { x: g }, backend: t6, attrs: { perm: x } });
+ return t6.disposeIntermediateTensorInfo(g), t6.disposeIntermediateTensorInfo(u), b;
}
return g;
}
-var Y2 = { kernelName: hn, backendName: "cpu", kernelFunc: tX };
-function rX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o;
+var k2 = { kernelName: jo, backendName: "cpu", kernelFunc: Ij };
+function vj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o;
K(n, "cumsum");
- let p = I.getAxesPermutation([s], n.shape.length), u = n;
- p != null && (u = bt({ inputs: { x: n }, backend: t10, attrs: { perm: p } }));
- let c = I.getInnerMostAxes(1, n.shape.length)[0];
+ let p = S.getAxesPermutation([s], n.shape.length), u = n;
+ p != null && (u = Ct({ inputs: { x: n }, backend: t6, attrs: { perm: p } }));
+ let c = S.getInnerMostAxes(1, n.shape.length)[0];
if (c !== u.shape.length - 1)
throw new Error(`backend.cumsum in CPU expects an inner-most axis=${u.shape.length - 1} but got axis=${c}`);
- let l = ct(u.dtype, "int32"), m = x.makeZerosTypedArray(x.sizeFromShape(u.shape), l), f = t10.data.get(u.dataId).values, d = u.shape[u.shape.length - 1], h = i ? (y, b) => y + d - b - 1 : (y, b) => y + b;
- for (let y = 0; y < f.length; y += d)
- for (let b = 0; b < d; b++) {
- let C = h(y, b);
+ let l = dt(u.dtype, "int32"), m = y.makeZerosTypedArray(y.sizeFromShape(u.shape), l), d = t6.data.get(u.dataId).values, f = u.shape[u.shape.length - 1], h = i ? (x, b) => x + f - b - 1 : (x, b) => x + b;
+ for (let x = 0; x < d.length; x += f)
+ for (let b = 0; b < f; b++) {
+ let C = h(x, b);
if (b === 0)
- m[C] = a ? 0 : f[C];
+ m[C] = a ? 0 : d[C];
else {
- let w = h(y, b - 1);
- m[C] = a ? f[w] + m[w] : f[C] + m[w];
+ let w = h(x, b - 1);
+ m[C] = a ? d[w] + m[w] : d[C] + m[w];
}
}
- let g = t10.makeTensorInfo(u.shape, l, m);
+ let g = t6.makeTensorInfo(u.shape, l, m);
if (p != null) {
- let y = I.getUndoAxesPermutation(p), b = bt({ inputs: { x: g }, backend: t10, attrs: { perm: y } });
- return t10.disposeIntermediateTensorInfo(g), t10.disposeIntermediateTensorInfo(u), b;
+ let x = S.getUndoAxesPermutation(p), b = Ct({ inputs: { x: g }, backend: t6, attrs: { perm: x } });
+ return t6.disposeIntermediateTensorInfo(g), t6.disposeIntermediateTensorInfo(u), b;
}
return g;
}
-var Q2 = { kernelName: gn, backendName: "cpu", kernelFunc: rX };
-function oX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, weights: s } = e, { size: a, binaryOutput: i } = o;
+var N2 = { kernelName: Xo, backendName: "cpu", kernelFunc: vj };
+function kj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, weights: s } = e, { size: a, binaryOutput: i } = o;
if (n.shape.length === 1) {
- let p = t10.data.get(n.dataId).values, u = t10.data.get(s.dataId).values, c = Zp(p, u, s.dtype, s.shape, a);
- return t10.makeTensorInfo([a], s.dtype, c);
+ let p = t6.data.get(n.dataId).values, u = t6.data.get(s.dataId).values, c = Kp(p, u, s.dtype, s.shape, a);
+ return t6.makeTensorInfo([a], s.dtype, c);
} else if (n.shape.length === 2) {
- let p = t10.bufferSync(n), u = t10.bufferSync(s), c = yd(p, u, a, i);
- return t10.makeTensorInfo(c.shape, s.dtype, c.values);
+ let p = t6.bufferSync(n), u = t6.bufferSync(s), c = uf(p, u, a, i);
+ return t6.makeTensorInfo(c.shape, s.dtype, c.values);
}
throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${n.shape.length}.`);
}
-var Z2 = { kernelName: dp, backendName: "cpu", kernelFunc: oX };
-function nX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { blockSize: s, dataFormat: a } = o;
- x.assert(a === "NHWC", () => `Only NHWC dataFormat supported on CPU for depthToSpace. Got ${a}`);
- let i = n.shape[0], p = n.shape[1], u = n.shape[2], c = n.shape[3], l = p * s, m = u * s, f = c / (s * s), d = t10.data.get(n.dataId).values, h = new Float32Array(i * l * m * f), g = 0;
- for (let y = 0; y < i; ++y)
+var T2 = { kernelName: ti, backendName: "cpu", kernelFunc: kj };
+function Nj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { blockSize: s, dataFormat: a } = o;
+ y.assert(a === "NHWC", () => `Only NHWC dataFormat supported on CPU for depthToSpace. Got ${a}`);
+ let i = n.shape[0], p = n.shape[1], u = n.shape[2], c = n.shape[3], l = p * s, m = u * s, d = c / (s * s), f = t6.data.get(n.dataId).values, h = new Float32Array(i * l * m * d), g = 0;
+ for (let x = 0; x < i; ++x)
for (let b = 0; b < l; ++b) {
let C = Math.floor(b / s), w = b % s;
for (let k = 0; k < m; ++k) {
- let _ = Math.floor(k / s), E = k % s, R = (w * s + E) * f;
- for (let A = 0; A < f; ++A) {
- let O = A + R + c * (_ + u * (C + p * y));
- h[g++] = d[O];
+ let _ = Math.floor(k / s), $ = k % s, A = (w * s + $) * d;
+ for (let R = 0; R < d; ++R) {
+ let P = R + A + c * (_ + u * (C + p * x));
+ h[g++] = f[P];
}
}
}
- return t10.makeTensorInfo([i, l, m, f], n.dtype, h);
+ return t6.makeTensorInfo([i, l, m, d], n.dtype, h);
}
-var J2 = { kernelName: yn, backendName: "cpu", kernelFunc: nX };
-function AI(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p, dimRoundingMode: u } = o;
+var _2 = { kernelName: Qo, backendName: "cpu", kernelFunc: Nj };
+function TS(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p, dimRoundingMode: u } = o;
K([n, s], "depthwiseConv2DNative");
- let c = x.computeStrides(n.shape), l = x.computeStrides(s.shape), m = p;
- m == null && (m = [1, 1]), x.assert(I.eitherStridesOrDilationsAreOne(a, m), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${m}'`);
- let f = I.computeConv2DInfo(n.shape, s.shape, a, m, i, u, true), { filterHeight: d, filterWidth: h, dilationHeight: g, dilationWidth: y, padInfo: b } = f, C = b.left, w = b.top, k = f.outChannels / f.inChannels, _ = new je(f.outShape, n.dtype), E = t10.data.get(n.dataId).values, R = t10.data.get(s.dataId).values, A = _.values;
- for (let D = 0; D < f.batchSize; ++D) {
- let O = D * c[0], M = D * _.strides[0];
- for (let L = 0; L < f.outHeight; ++L) {
- let W = M + L * _.strides[1], V = L * f.strideHeight - w;
- for (let G = 0; G < d; ++G) {
- let q = V + G * g;
- if (q < 0 || q >= f.inHeight)
+ let c = y.computeStrides(n.shape), l = y.computeStrides(s.shape), m = p;
+ m == null && (m = [1, 1]), y.assert(S.eitherStridesOrDilationsAreOne(a, m), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${m}'`);
+ let d = S.computeConv2DInfo(n.shape, s.shape, a, m, i, u, true), { filterHeight: f, filterWidth: h, dilationHeight: g, dilationWidth: x, padInfo: b } = d, C = b.left, w = b.top, k = d.outChannels / d.inChannels, _ = new st(d.outShape, n.dtype), $ = t6.data.get(n.dataId).values, A = t6.data.get(s.dataId).values, R = _.values;
+ for (let D = 0; D < d.batchSize; ++D) {
+ let P = D * c[0], M = D * _.strides[0];
+ for (let L = 0; L < d.outHeight; ++L) {
+ let W = M + L * _.strides[1], V = L * d.strideHeight - w;
+ for (let U = 0; U < f; ++U) {
+ let q = V + U * g;
+ if (q < 0 || q >= d.inHeight)
continue;
- let H = G * l[0], j = O + q * c[1];
- for (let Y = 0; Y < f.outWidth; ++Y) {
- let Z = W + Y * _.strides[2], ee = Y * f.strideWidth - C;
- for (let X = 0; X < h; ++X) {
- let Q = ee + X * y;
- if (Q < 0 || Q >= f.inWidth)
+ let H = U * l[0], j = P + q * c[1];
+ for (let X = 0; X < d.outWidth; ++X) {
+ let Z = W + X * _.strides[2], ee = X * d.strideWidth - C;
+ for (let Y = 0; Y < h; ++Y) {
+ let J = ee + Y * x;
+ if (J < 0 || J >= d.inWidth)
continue;
- let se = H + X * l[1], ie = j + Q * f.inChannels, de = Z, Ie = se;
- for (let Se = 0; Se < f.inChannels; ++Se) {
- let Ee = E[ie + Se];
- for (let Me = 0; Me < k; ++Me)
- A[de + Me] += Ee * R[Ie + Me];
- de += k, Ie += k;
+ let ie = H + Y * l[1], pe = j + J * d.inChannels, he = Z, we = ie;
+ for (let ve = 0; ve < d.inChannels; ++ve) {
+ let $e = $[pe + ve];
+ for (let Le = 0; Le < k; ++Le)
+ R[he + Le] += $e * A[we + Le];
+ he += k, we += k;
}
}
}
}
}
}
- return t10.makeTensorInfo(_.shape, _.dtype, _.values);
+ return t6.makeTensorInfo(_.shape, _.dtype, _.values);
}
-var e_ = { kernelName: bn, backendName: "cpu", kernelFunc: AI };
-function sX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, dy: s } = e, { strides: a, dilations: i, pad: p, dimRoundingMode: u, filterShape: c } = o;
+var E2 = { kernelName: Zo, backendName: "cpu", kernelFunc: TS };
+function Tj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, dy: s } = e, { strides: a, dilations: i, pad: p, dimRoundingMode: u, filterShape: c } = o;
K([n, s], "depthwiseConv2dNativeBackpropFilter");
- let l = I.computeConv2DInfo(n.shape, c, a, i, p, u, true), { strideHeight: m, strideWidth: f, filterHeight: d, filterWidth: h } = l, g = new je(l.filterShape, "float32"), y = l.padInfo.left, b = l.padInfo.top, C = l.outChannels / l.inChannels, w = t10.data.get(n.dataId).values, k = new je(n.shape, n.dtype, w), _ = t10.data.get(s.dataId).values, E = new je(s.shape, s.dtype, _);
- for (let R = 0; R < d; ++R) {
- let A = Math.max(0, Math.ceil((b - R) / m)), D = Math.min(l.outHeight, (l.inHeight + b - R) / m);
- for (let O = 0; O < h; ++O) {
- let M = Math.max(0, Math.ceil((y - O) / f)), L = Math.min(l.outWidth, (l.inWidth + y - O) / f);
+ let l = S.computeConv2DInfo(n.shape, c, a, i, p, u, true), { strideHeight: m, strideWidth: d, filterHeight: f, filterWidth: h } = l, g = new st(l.filterShape, "float32"), x = l.padInfo.left, b = l.padInfo.top, C = l.outChannels / l.inChannels, w = t6.data.get(n.dataId).values, k = new st(n.shape, n.dtype, w), _ = t6.data.get(s.dataId).values, $ = new st(s.shape, s.dtype, _);
+ for (let A = 0; A < f; ++A) {
+ let R = Math.max(0, Math.ceil((b - A) / m)), D = Math.min(l.outHeight, (l.inHeight + b - A) / m);
+ for (let P = 0; P < h; ++P) {
+ let M = Math.max(0, Math.ceil((x - P) / d)), L = Math.min(l.outWidth, (l.inWidth + x - P) / d);
for (let W = 0; W < l.outChannels; ++W) {
- let V = Math.trunc(W / C), G = W % C, q = 0;
+ let V = Math.trunc(W / C), U = W % C, q = 0;
for (let H = 0; H < l.batchSize; ++H)
- for (let j = A; j < D; ++j) {
- let Y = R + j * m - b;
+ for (let j = R; j < D; ++j) {
+ let X = A + j * m - b;
for (let Z = M; Z < L; ++Z) {
- let ee = O + Z * f - y;
- q += k.get(H, Y, ee, V) * E.get(H, j, Z, W);
+ let ee = P + Z * d - x;
+ q += k.get(H, X, ee, V) * $.get(H, j, Z, W);
}
}
- g.set(q, R, O, V, G);
+ g.set(q, A, P, V, U);
}
}
}
- return t10.makeTensorInfo(g.shape, g.dtype, g.values);
+ return t6.makeTensorInfo(g.shape, g.dtype, g.values);
}
-var t_ = { kernelName: hp, backendName: "cpu", kernelFunc: sX };
-function aX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, filter: s } = e, { strides: a, dilations: i, pad: p, dimRoundingMode: u, inputShape: c } = o;
+var $2 = { kernelName: dp, backendName: "cpu", kernelFunc: Tj };
+function _j(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, filter: s } = e, { strides: a, dilations: i, pad: p, dimRoundingMode: u, inputShape: c } = o;
K([n, s], "depthwiseConv2DNativeBackpropInput");
- let l = x.computeStrides(n.shape), m = x.computeStrides(s.shape), f = I.computeConv2DInfo(c, s.shape, a, i, p, u, true), d = new je(f.inShape, "float32"), h = d.values, [g, y, b] = d.strides, C = t10.data.get(n.dataId).values, [w, k, _] = l, E = t10.data.get(s.dataId).values, [R, A, D] = m, { batchSize: O, filterHeight: M, filterWidth: L, inChannels: W, inHeight: V, inWidth: G, outChannels: q, outHeight: H, outWidth: j, strideHeight: Y, strideWidth: Z } = f, ee = M - 1 - f.padInfo.top, X = L - 1 - f.padInfo.left, Q = q / W;
- for (let se = 0; se < O; ++se)
- for (let ie = 0; ie < W; ++ie)
- for (let de = 0; de < V; ++de) {
- let Ie = de - ee, Se = Math.max(0, Math.ceil(Ie / Y)), Ee = Math.min(H, (M + Ie) / Y);
- for (let Me = 0; Me < G; ++Me) {
- let st = Me - X, pt = Math.max(0, Math.ceil(st / Z)), De = Math.min(j, (L + st) / Z), ft = 0;
- for (let at = Se; at < Ee; ++at) {
- let dt = at * Y - Ie;
- for (let It = pt; It < De; ++It) {
- let Fr = It * Z - st, Pt = w * se + k * at + _ * It, jr = R * (M - 1 - dt) + A * (L - 1 - Fr) + D * ie;
- for (let er = 0; er < Q; ++er) {
- let Tt = ie * Q + er, tr = C[Pt + Tt], rr = E[jr + er];
- ft += tr * rr;
+ let l = y.computeStrides(n.shape), m = y.computeStrides(s.shape), d = S.computeConv2DInfo(c, s.shape, a, i, p, u, true), f = new st(d.inShape, "float32"), h = f.values, [g, x, b] = f.strides, C = t6.data.get(n.dataId).values, [w, k, _] = l, $ = t6.data.get(s.dataId).values, [A, R, D] = m, { batchSize: P, filterHeight: M, filterWidth: L, inChannels: W, inHeight: V, inWidth: U, outChannels: q, outHeight: H, outWidth: j, strideHeight: X, strideWidth: Z } = d, ee = M - 1 - d.padInfo.top, Y = L - 1 - d.padInfo.left, J = q / W;
+ for (let ie = 0; ie < P; ++ie)
+ for (let pe = 0; pe < W; ++pe)
+ for (let he = 0; he < V; ++he) {
+ let we = he - ee, ve = Math.max(0, Math.ceil(we / X)), $e = Math.min(H, (M + we) / X);
+ for (let Le = 0; Le < U; ++Le) {
+ let nt = Le - Y, pt = Math.max(0, Math.ceil(nt / Z)), Oe = Math.min(j, (L + nt) / Z), mt = 0;
+ for (let at = ve; at < $e; ++at) {
+ let ft = at * X - we;
+ for (let wt = pt; wt < Oe; ++wt) {
+ let Fr = wt * Z - nt, Ot = w * ie + k * at + _ * wt, Kr = A * (M - 1 - ft) + R * (L - 1 - Fr) + D * pe;
+ for (let er = 0; er < J; ++er) {
+ let Nt = pe * J + er, tr = C[Ot + Nt], rr = $[Kr + er];
+ mt += tr * rr;
}
}
}
- h[g * se + y * de + b * Me + ie] = ft;
+ h[g * ie + x * he + b * Le + pe] = mt;
}
}
- return t10.makeTensorInfo(d.shape, d.dtype, d.values);
+ return t6.makeTensorInfo(f.shape, f.dtype, f.values);
}
-var r_ = { kernelName: gp, backendName: "cpu", kernelFunc: aX };
-function iX(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e, n = x.sizeFromShape(o.shape), s = t10.data.get(o.dataId).values, a = ne([n, n], o.dtype), i = a.values;
+var A2 = { kernelName: fp, backendName: "cpu", kernelFunc: _j };
+function Ej(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e, n = y.sizeFromShape(o.shape), s = t6.data.get(o.dataId).values, a = le([n, n], o.dtype), i = a.values;
for (let u = 0; u < s.length; u++)
i[u * n + u] = s[u];
let p = [...o.shape, ...o.shape];
- return t10.makeTensorInfo(p, a.dtype, a.values);
+ return t6.makeTensorInfo(p, a.dtype, a.values);
}
-var o_ = { kernelName: xp, backendName: "cpu", kernelFunc: iX };
-var n_ = { kernelName: yp, backendName: "cpu", kernelFunc: ({ inputs: r, backend: e, attrs: t10 }) => {
- let { x: o, filter: n } = r, { strides: s, pad: a, dilations: i } = t10, p = e, u = p.data.get(o.dataId).values, c = o.shape.length, l = p.data.get(n.dataId).values, m = n.shape.length, { batchSize: f, inHeight: d, inWidth: h, inChannels: g, outHeight: y, outWidth: b, padInfo: C, strideHeight: w, strideWidth: k, filterHeight: _, filterWidth: E, dilationHeight: R, dilationWidth: A, outShape: D } = I.computeDilation2DInfo(o.shape, n.shape, s, a, "NHWC", i), O = x.sizeFromShape(D), M = D.length, L = x.getArrayFromDType(o.dtype, O);
- for (let V = 0; V < f; ++V)
- for (let G = 0; G < y; ++G) {
- let q = G * w - C.top;
+var R2 = { kernelName: hp, backendName: "cpu", kernelFunc: Ej };
+var F2 = { kernelName: gp, backendName: "cpu", kernelFunc: ({ inputs: r, backend: e, attrs: t6 }) => {
+ let { x: o, filter: n } = r, { strides: s, pad: a, dilations: i } = t6, p = e, u = p.data.get(o.dataId).values, c = o.shape.length, l = p.data.get(n.dataId).values, m = n.shape.length, { batchSize: d, inHeight: f, inWidth: h, inChannels: g, outHeight: x, outWidth: b, padInfo: C, strideHeight: w, strideWidth: k, filterHeight: _, filterWidth: $, dilationHeight: A, dilationWidth: R, outShape: D } = S.computeDilation2DInfo(o.shape, n.shape, s, a, "NHWC", i), P = y.sizeFromShape(D), M = D.length, L = y.getArrayFromDType(o.dtype, P);
+ for (let V = 0; V < d; ++V)
+ for (let U = 0; U < x; ++U) {
+ let q = U * w - C.top;
for (let H = 0; H < b; ++H) {
let j = H * k - C.left;
- for (let Y = 0; Y < g; ++Y) {
+ for (let X = 0; X < g; ++X) {
let Z = Number.MIN_SAFE_INTEGER;
- for (let X = 0; X < _; ++X) {
- let Q = q + X * R;
- if (Q >= 0 && Q < d)
- for (let se = 0; se < E; ++se) {
- let ie = j + se * A;
- if (ie >= 0 && ie < h) {
- let de = x.locToIndex([V, Q, ie, Y], c, x.computeStrides(o.shape)), Ie = x.locToIndex([X, se, Y], m, x.computeStrides(n.shape)), Se = u[de] + l[Ie];
- Se > Z && (Z = Se);
+ for (let Y = 0; Y < _; ++Y) {
+ let J = q + Y * A;
+ if (J >= 0 && J < f)
+ for (let ie = 0; ie < $; ++ie) {
+ let pe = j + ie * R;
+ if (pe >= 0 && pe < h) {
+ let he = y.locToIndex([V, J, pe, X], c, y.computeStrides(o.shape)), we = y.locToIndex([Y, ie, X], m, y.computeStrides(n.shape)), ve = u[he] + l[we];
+ ve > Z && (Z = ve);
}
}
}
- let ee = x.locToIndex([V, G, H, Y], M, x.computeStrides(D));
+ let ee = y.locToIndex([V, U, H, X], M, y.computeStrides(D));
L[ee] = Z;
}
}
}
- return { dataId: p.write(x.toTypedArray(L, o.dtype), D, o.dtype), shape: D, dtype: o.dtype };
+ return { dataId: p.write(y.toTypedArray(L, o.dtype), D, o.dtype), shape: D, dtype: o.dtype };
} };
-var s_ = { kernelName: vb, backendName: "cpu", kernelFunc: ({ inputs: r, backend: e, attrs: t10 }) => {
- let { x: o, filter: n, dy: s } = r, { strides: a, pad: i, dilations: p } = t10, u = e, c = x.toNestedArray(o.shape, u.data.get(o.dataId).values), l = x.toNestedArray(n.shape, u.data.get(n.dataId).values), { batchSize: m, inHeight: f, inWidth: d, inChannels: h, outHeight: g, outWidth: y, padInfo: b, strideHeight: C, strideWidth: w, filterHeight: k, filterWidth: _, dilationHeight: E, dilationWidth: R, outShape: A } = I.computeDilation2DInfo(o.shape, n.shape, a, i, "NHWC", p);
- x.assert(s.rank === A.length, () => `Error in ${vb}, dy must have the same rank as output ${A.length}, but got ${s.rank}`);
- let D = x.toNestedArray(A, u.data.get(s.dataId).values), O = x.makeZerosNestedTypedArray(n.shape, n.dtype);
+var D2 = { kernelName: bb, backendName: "cpu", kernelFunc: ({ inputs: r, backend: e, attrs: t6 }) => {
+ let { x: o, filter: n, dy: s } = r, { strides: a, pad: i, dilations: p } = t6, u = e, c = y.toNestedArray(o.shape, u.data.get(o.dataId).values), l = y.toNestedArray(n.shape, u.data.get(n.dataId).values), { batchSize: m, inHeight: d, inWidth: f, inChannels: h, outHeight: g, outWidth: x, padInfo: b, strideHeight: C, strideWidth: w, filterHeight: k, filterWidth: _, dilationHeight: $, dilationWidth: A, outShape: R } = S.computeDilation2DInfo(o.shape, n.shape, a, i, "NHWC", p);
+ y.assert(s.rank === R.length, () => `Error in ${bb}, dy must have the same rank as output ${R.length}, but got ${s.rank}`);
+ let D = y.toNestedArray(R, u.data.get(s.dataId).values), P = y.makeZerosNestedTypedArray(n.shape, n.dtype);
for (let L = 0; L < m; ++L)
for (let W = 0; W < g; ++W) {
let V = W * C - b.top;
- for (let G = 0; G < y; ++G) {
- let q = G * w - b.left;
+ for (let U = 0; U < x; ++U) {
+ let q = U * w - b.left;
for (let H = 0; H < h; ++H) {
- let j = Number.MIN_SAFE_INTEGER, Y = 0, Z = 0;
+ let j = Number.MIN_SAFE_INTEGER, X = 0, Z = 0;
for (let ee = 0; ee < k; ++ee) {
- let X = V + ee * E;
- if (X >= 0 && X < f)
- for (let Q = 0; Q < _; ++Q) {
- let se = q + Q * R;
- if (se >= 0 && se < d) {
- let ie = c[L][X][se][H] + l[ee][Q][H];
- ie > j && (j = ie, Y = ee, Z = Q);
+ let Y = V + ee * $;
+ if (Y >= 0 && Y < d)
+ for (let J = 0; J < _; ++J) {
+ let ie = q + J * A;
+ if (ie >= 0 && ie < f) {
+ let pe = c[L][Y][ie][H] + l[ee][J][H];
+ pe > j && (j = pe, X = ee, Z = J);
}
}
}
- O[Y][Z][H] += D[L][W][G][H];
+ P[X][Z][H] += D[L][W][U][H];
}
}
}
- return { dataId: u.write(x.toTypedArray(O, o.dtype), n.shape, n.dtype), shape: n.shape, dtype: n.dtype };
+ return { dataId: u.write(y.toTypedArray(P, o.dtype), n.shape, n.dtype), shape: n.shape, dtype: n.dtype };
} };
-var a_ = { kernelName: Sb, backendName: "cpu", kernelFunc: ({ inputs: r, backend: e, attrs: t10 }) => {
- let { x: o, filter: n, dy: s } = r, { strides: a, pad: i, dilations: p } = t10, u = e, c = x.toNestedArray(o.shape, u.data.get(o.dataId).values), l = x.toNestedArray(n.shape, u.data.get(n.dataId).values), { batchSize: m, inHeight: f, inWidth: d, inChannels: h, outHeight: g, outWidth: y, padInfo: b, strideHeight: C, strideWidth: w, filterHeight: k, filterWidth: _, dilationHeight: E, dilationWidth: R, outShape: A } = I.computeDilation2DInfo(o.shape, n.shape, a, i, "NHWC", p);
- x.assert(s.rank === A.length, () => `Error in ${Sb}, dy must have the same rank as output ${A.length}, but got ${s.rank}`);
- let D = x.toNestedArray(A, u.data.get(s.dataId).values), O = x.makeZerosNestedTypedArray(o.shape, o.dtype);
+var O2 = { kernelName: yb, backendName: "cpu", kernelFunc: ({ inputs: r, backend: e, attrs: t6 }) => {
+ let { x: o, filter: n, dy: s } = r, { strides: a, pad: i, dilations: p } = t6, u = e, c = y.toNestedArray(o.shape, u.data.get(o.dataId).values), l = y.toNestedArray(n.shape, u.data.get(n.dataId).values), { batchSize: m, inHeight: d, inWidth: f, inChannels: h, outHeight: g, outWidth: x, padInfo: b, strideHeight: C, strideWidth: w, filterHeight: k, filterWidth: _, dilationHeight: $, dilationWidth: A, outShape: R } = S.computeDilation2DInfo(o.shape, n.shape, a, i, "NHWC", p);
+ y.assert(s.rank === R.length, () => `Error in ${yb}, dy must have the same rank as output ${R.length}, but got ${s.rank}`);
+ let D = y.toNestedArray(R, u.data.get(s.dataId).values), P = y.makeZerosNestedTypedArray(o.shape, o.dtype);
for (let L = 0; L < m; ++L)
for (let W = 0; W < g; ++W) {
let V = W * C - b.top;
- for (let G = 0; G < y; ++G) {
- let q = G * w - b.left;
+ for (let U = 0; U < x; ++U) {
+ let q = U * w - b.left;
for (let H = 0; H < h; ++H) {
- let j = Number.MIN_SAFE_INTEGER, Y = V < 0 ? 0 : V, Z = q < 0 ? 0 : q;
+ let j = Number.MIN_SAFE_INTEGER, X = V < 0 ? 0 : V, Z = q < 0 ? 0 : q;
for (let ee = 0; ee < k; ++ee) {
- let X = V + ee * E;
- if (X >= 0 && X < f)
- for (let Q = 0; Q < _; ++Q) {
- let se = q + Q * R;
- if (se >= 0 && se < d) {
- let ie = c[L][X][se][H] + l[ee][Q][H];
- ie > j && (j = ie, Y = X, Z = se);
+ let Y = V + ee * $;
+ if (Y >= 0 && Y < d)
+ for (let J = 0; J < _; ++J) {
+ let ie = q + J * A;
+ if (ie >= 0 && ie < f) {
+ let pe = c[L][Y][ie][H] + l[ee][J][H];
+ pe > j && (j = pe, X = Y, Z = ie);
}
}
}
- O[L][Y][Z][H] += D[L][W][G][H];
+ P[L][X][Z][H] += D[L][W][U][H];
}
}
}
- return { dataId: u.write(x.toTypedArray(O, o.dtype), o.shape, o.dtype), shape: o.shape, dtype: o.dtype };
+ return { dataId: u.write(y.toTypedArray(P, o.dtype), o.shape, o.dtype), shape: o.shape, dtype: o.dtype };
} };
-function Fa(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
+function La(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
K(n, "sum");
let i;
- n.dtype === "bool" ? i = Uo({ inputs: { x: n }, backend: t10, attrs: { dtype: "int32" } }) : i = ar({ inputs: { x: n }, backend: t10 });
- let p = i.shape.length, u = x.parseAxisParam(s, i.shape), c = I.getAxesPermutation(u, p), l = u, m = i;
- c != null && (m = bt({ inputs: { x: i }, backend: t10, attrs: { perm: c } }), l = I.getInnerMostAxes(l.length, p)), I.assertAxesAreInnerMostDims("sum", l, m.shape.length);
- let [f, d] = I.computeOutAndReduceShapes(m.shape, l), h = I.upcastType(m.dtype, "int32"), g = Yp(t10, f, h), y = x.sizeFromShape(d), b = t10.data.get(g.dataId).values, C = t10.data.get(m.dataId).values;
+ n.dtype === "bool" ? i = Io({ inputs: { x: n }, backend: t6, attrs: { dtype: "int32" } }) : i = ar({ inputs: { x: n }, backend: t6 });
+ let p = i.shape.length, u = y.parseAxisParam(s, i.shape), c = S.getAxesPermutation(u, p), l = u, m = i;
+ c != null && (m = Ct({ inputs: { x: i }, backend: t6, attrs: { perm: c } }), l = S.getInnerMostAxes(l.length, p)), S.assertAxesAreInnerMostDims("sum", l, m.shape.length);
+ let [d, f] = S.computeOutAndReduceShapes(m.shape, l), h = S.upcastType(m.dtype, "int32"), g = Hp(t6, d, h), x = y.sizeFromShape(f), b = t6.data.get(g.dataId).values, C = t6.data.get(m.dataId).values;
for (let w = 0; w < b.length; ++w) {
- let k = w * y, _ = 0;
- for (let E = 0; E < y; ++E)
- _ += C[k + E];
+ let k = w * x, _ = 0;
+ for (let $ = 0; $ < x; ++$)
+ _ += C[k + $];
b[w] = _;
}
if (a) {
- let w = I.expandShapeToKeepDim(g.shape, u), k = g;
- g = Oe({ inputs: { x: g }, backend: t10, attrs: { shape: w } }), t10.disposeIntermediateTensorInfo(k);
+ let w = S.expandShapeToKeepDim(g.shape, u), k = g;
+ g = Me({ inputs: { x: g }, backend: t6, attrs: { shape: w } }), t6.disposeIntermediateTensorInfo(k);
}
- return t10.disposeIntermediateTensorInfo(i), c != null && t10.disposeIntermediateTensorInfo(m), g;
+ return t6.disposeIntermediateTensorInfo(i), c != null && t6.disposeIntermediateTensorInfo(m), g;
}
-var i_ = { kernelName: jn, backendName: "cpu", kernelFunc: Fa };
-function uX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { equation: n } = o, s = e, { allDims: a, summedDims: i, idDims: p } = I.decodeEinsumEquation(n, s.length);
- I.checkEinsumDimSizes(a.length, p, s);
- let { path: u, steps: c } = I.getEinsumComputePath(i, p), l = c.length, m = null, f = a.length, d = [];
+var P2 = { kernelName: Hn, backendName: "cpu", kernelFunc: La };
+function $j(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { equation: n } = o, s = e, { allDims: a, summedDims: i, idDims: p } = S.decodeEinsumEquation(n, s.length);
+ S.checkEinsumDimSizes(a.length, p, s);
+ let { path: u, steps: c } = S.getEinsumComputePath(i, p), l = c.length, m = null, d = a.length, f = [];
for (let h = 0; h < l; ++h) {
for (let g of c[h]) {
- let { permutationIndices: y, expandDims: b } = I.getEinsumPermutation(f, p[g]), C;
- I.isIdentityPermutation(y) ? C = s[g] : (C = bt({ inputs: { x: s[g] }, backend: t10, attrs: { perm: y } }), d.push(C));
+ let { permutationIndices: x, expandDims: b } = S.getEinsumPermutation(d, p[g]), C;
+ S.isIdentityPermutation(x) ? C = s[g] : (C = Ct({ inputs: { x: s[g] }, backend: t6, attrs: { perm: x } }), f.push(C));
let w = C.shape.slice();
for (let k = 0; k < b.length; ++k)
w.splice(b[k], 0, 1);
- x.arraysEqual(C.shape, w) || (C = Oe({ inputs: { x: C }, backend: t10, attrs: { shape: w } }), d.push(C)), m === null ? m = C : (m = wu({ inputs: { a: C, b: m }, backend: t10 }), d.push(m));
+ y.arraysEqual(C.shape, w) || (C = Me({ inputs: { x: C }, backend: t6, attrs: { shape: w } }), f.push(C)), m === null ? m = C : (m = wu({ inputs: { a: C, b: m }, backend: t6 }), f.push(m));
}
- h < l - 1 && (u[h] >= 0 && (m = Fa({ inputs: { x: m }, backend: t10, attrs: { axis: u[h] - (a.length - f), keepDims: false } }), d.push(m)), f--);
+ h < l - 1 && (u[h] >= 0 && (m = La({ inputs: { x: m }, backend: t6, attrs: { axis: u[h] - (a.length - d), keepDims: false } }), f.push(m)), d--);
}
- for (let h of d)
- h !== m && t10.disposeIntermediateTensorInfo(h);
+ for (let h of f)
+ h !== m && t6.disposeIntermediateTensorInfo(h);
return m;
}
-var u_ = { kernelName: Xa, backendName: "cpu", kernelFunc: uX };
-function pX(r) {
- let { inputs: e, backend: t10 } = r, { dy: o, y: n } = e;
+var M2 = { kernelName: ri, backendName: "cpu", kernelFunc: $j };
+function Aj(r) {
+ let { inputs: e, backend: t6 } = r, { dy: o, y: n } = e;
K([o, n], "eluGrad");
- let s = new Float32Array(x.sizeFromShape(n.shape)), a = t10.data.get(n.dataId).values, i = t10.data.get(o.dataId).values;
+ let s = new Float32Array(y.sizeFromShape(n.shape)), a = t6.data.get(n.dataId).values, i = t6.data.get(o.dataId).values;
for (let p = 0; p < a.length; ++p) {
let u = a[p];
u >= 1 ? s[p] = i[p] : s[p] = i[p] * (u + 1);
}
- return t10.makeTensorInfo(n.shape, "float32", s);
+ return t6.makeTensorInfo(n.shape, "float32", s);
}
-var p_ = { kernelName: Pm, backendName: "cpu", kernelFunc: pX };
-var cX = I.ERF_P;
-var lX = I.ERF_A1;
-var mX = I.ERF_A2;
-var fX = I.ERF_A3;
-var dX = I.ERF_A4;
-var hX = I.ERF_A5;
-var gX = we(Gi, (r) => {
- let e = Math.sign(r), t10 = Math.abs(r), o = 1 / (1 + cX * t10);
- return e * (1 - ((((hX * o + dX) * o + fX) * o + mX) * o + lX) * o * Math.exp(-t10 * t10));
+var L2 = { kernelName: km, backendName: "cpu", kernelFunc: Aj };
+var Rj = S.ERF_P;
+var Fj = S.ERF_A1;
+var Dj = S.ERF_A2;
+var Oj = S.ERF_A3;
+var Pj = S.ERF_A4;
+var Mj = S.ERF_A5;
+var Lj = Ie(ma, (r) => {
+ let e = Math.sign(r), t6 = Math.abs(r), o = 1 / (1 + Rj * t6);
+ return e * (1 - ((((Mj * o + Pj) * o + Oj) * o + Dj) * o + Fj) * o * Math.exp(-t6 * t6));
});
-var c_ = { kernelName: Gi, backendName: "cpu", kernelFunc: gX };
-function oc(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { input: n } = e, { dim: s } = o, a = n.shape.length, i = n.shape.slice(), p = s;
- return s < 0 && (x.assert(-(a + 1) <= s, () => `Axis must be in the interval [${-(a + 1)}, ${a}]`), p = a + s + 1), i.splice(p, 0, 1), Oe({ inputs: { x: n }, backend: t10, attrs: { shape: i } });
+var B2 = { kernelName: ma, backendName: "cpu", kernelFunc: Lj };
+function Jp(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { input: n } = e, { dim: s } = o, a = n.shape.length, i = n.shape.slice(), p = s;
+ return s < 0 && (y.assert(-(a + 1) <= s, () => `Axis must be in the interval [${-(a + 1)}, ${a}]`), p = a + s + 1), i.splice(p, 0, 1), Me({ inputs: { x: n }, backend: t6, attrs: { shape: i } });
}
-var l_ = { kernelName: xs, backendName: "cpu", kernelFunc: oc };
-var xX = Le((r, e) => r / e);
-var Sl = Ye(Cn, xX);
-var vl = { kernelName: Cn, backendName: "cpu", kernelFunc: Sl };
-function Pd(r, e, t10) {
- let o = r.shape, n = o[0], s = o[1], a = t10.data.get(r.dataId), i = a.complexTensorInfos.real, p = a.complexTensorInfos.imag, u = [n, s], c = x.sizeFromShape(u), l = x.getTypedArrayFromDType("float32", c), m = x.getTypedArrayFromDType("float32", c);
+var V2 = { kernelName: bs, backendName: "cpu", kernelFunc: Jp };
+var Bj = Be((r, e) => r / e);
+var hl = Qe(Jo, Bj);
+var gl = { kernelName: Jo, backendName: "cpu", kernelFunc: hl };
+function vf(r, e, t6) {
+ let o = r.shape, n = o[0], s = o[1], a = t6.data.get(r.dataId), i = a.complexTensorInfos.real, p = a.complexTensorInfos.imag, u = [n, s], c = y.sizeFromShape(u), l = y.getTypedArrayFromDType("float32", c), m = y.getTypedArrayFromDType("float32", c);
for (let g = 0; g < n; g++) {
- let y = qo({ inputs: { x: i }, backend: t10, attrs: { begin: [g, 0], size: [1, s] } }), b = qo({ inputs: { x: p }, backend: t10, attrs: { begin: [g, 0], size: [1, s] } }), C = qt({ inputs: { real: y, imag: b }, backend: t10 }), { real: w, imag: k } = yX(C, e, t10), _ = I.mergeRealAndImagArrays(w, k);
- for (let E = 0; E < s; E++) {
- let R = I.getComplexWithIndex(_, E);
- l[g * s + E] = R.real, m[g * s + E] = R.imag;
+ let x = No({ inputs: { x: i }, backend: t6, attrs: { begin: [g, 0], size: [1, s] } }), b = No({ inputs: { x: p }, backend: t6, attrs: { begin: [g, 0], size: [1, s] } }), C = Ht({ inputs: { real: x, imag: b }, backend: t6 }), { real: w, imag: k } = Vj(C, e, t6), _ = S.mergeRealAndImagArrays(w, k);
+ for (let $ = 0; $ < s; $++) {
+ let A = S.getComplexWithIndex(_, $);
+ l[g * s + $] = A.real, m[g * s + $] = A.imag;
}
- t10.disposeIntermediateTensorInfo(y), t10.disposeIntermediateTensorInfo(b), t10.disposeIntermediateTensorInfo(C);
+ t6.disposeIntermediateTensorInfo(x), t6.disposeIntermediateTensorInfo(b), t6.disposeIntermediateTensorInfo(C);
}
- let f = t10.makeTensorInfo(u, "float32", l), d = t10.makeTensorInfo(u, "float32", m), h = qt({ inputs: { real: f, imag: d }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(d), h;
+ let d = t6.makeTensorInfo(u, "float32", l), f = t6.makeTensorInfo(u, "float32", m), h = Ht({ inputs: { real: d, imag: f }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(d), t6.disposeIntermediateTensorInfo(f), h;
}
-function yX(r, e, t10) {
- let o = x.sizeFromShape(r.shape), n = t10.data.get(r.dataId), s = t10.data.get(n.complexTensorInfos.real.dataId).values, a = t10.data.get(n.complexTensorInfos.imag.dataId).values;
- if (bX(o)) {
- let i = FI(s, a, o, e, t10), p = [r.shape[0], r.shape[1]];
+function Vj(r, e, t6) {
+ let o = y.sizeFromShape(r.shape), n = t6.data.get(r.dataId), s = t6.data.get(n.complexTensorInfos.real.dataId).values, a = t6.data.get(n.complexTensorInfos.imag.dataId).values;
+ if (zj(o)) {
+ let i = _S(s, a, o, e, t6), p = [r.shape[0], r.shape[1]];
if (e) {
- let u = t10.makeTensorInfo(p, "float32", i.real), c = t10.makeTensorInfo(p, "float32", i.imag), l = t10.makeTensorInfo([], "float32", x.createScalarValue(o, "float32")), m = ar({ inputs: { x: l }, backend: t10 }), f = vl.kernelFunc({ inputs: { a: u, b: l }, backend: t10 }), d = vl.kernelFunc({ inputs: { a: c, b: m }, backend: t10 }), h = t10.data.get(f.dataId).values, g = t10.data.get(d.dataId).values;
- return t10.disposeIntermediateTensorInfo(u), t10.disposeIntermediateTensorInfo(c), t10.disposeIntermediateTensorInfo(l), t10.disposeIntermediateTensorInfo(m), t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(d), { real: h, imag: g };
+ let u = t6.makeTensorInfo(p, "float32", i.real), c = t6.makeTensorInfo(p, "float32", i.imag), l = t6.makeTensorInfo([], "float32", y.createScalarValue(o, "float32")), m = ar({ inputs: { x: l }, backend: t6 }), d = gl.kernelFunc({ inputs: { a: u, b: l }, backend: t6 }), f = gl.kernelFunc({ inputs: { a: c, b: m }, backend: t6 }), h = t6.data.get(d.dataId).values, g = t6.data.get(f.dataId).values;
+ return t6.disposeIntermediateTensorInfo(u), t6.disposeIntermediateTensorInfo(c), t6.disposeIntermediateTensorInfo(l), t6.disposeIntermediateTensorInfo(m), t6.disposeIntermediateTensorInfo(d), t6.disposeIntermediateTensorInfo(f), { real: h, imag: g };
}
return i;
} else {
- let i = I.mergeRealAndImagArrays(s, a), p = CX(i, o, e);
- return I.splitRealAndImagArrays(p);
+ let i = S.mergeRealAndImagArrays(s, a), p = Wj(i, o, e);
+ return S.splitRealAndImagArrays(p);
}
}
-function bX(r) {
+function zj(r) {
return (r & r - 1) === 0;
}
-function FI(r, e, t10, o, n) {
- if (t10 === 1)
+function _S(r, e, t6, o, n) {
+ if (t6 === 1)
return { real: r, imag: e };
- let s = I.mergeRealAndImagArrays(r, e), a = t10 / 2, i = I.complexWithEvenIndex(s), p = i.real, u = i.imag, c = [p.length], l = n.makeTensorInfo(c, "float32", p), m = n.makeTensorInfo(c, "float32", u), f = qt({ inputs: { real: l, imag: m }, backend: n }), d = I.complexWithOddIndex(s), h = d.real, g = d.imag, y = [h.length], b = n.makeTensorInfo(y, "float32", h), C = n.makeTensorInfo(y, "float32", g), w = qt({ inputs: { real: b, imag: C }, backend: n }), k = FI(p, u, a, o, n), _ = k.real, E = k.imag, R = [_.length], A = n.makeTensorInfo(R, "float32", _), D = n.makeTensorInfo(R, "float32", E), O = qt({ inputs: { real: A, imag: D }, backend: n }), M = FI(h, g, a, o, n), L = M.real, W = M.imag, V = [L.length], G = n.makeTensorInfo(V, "float32", L), q = n.makeTensorInfo(V, "float32", W), H = qt({ inputs: { real: G, imag: q }, backend: n }), j = I.exponents(t10, o), Y = [j.real.length], Z = n.makeTensorInfo(Y, "float32", j.real), ee = n.makeTensorInfo(Y, "float32", j.imag), X = qt({ inputs: { real: Z, imag: ee }, backend: n }), Q = wu({ inputs: { a: X, b: H }, backend: n }), se = Hs({ inputs: { a: O, b: Q }, backend: n }), ie = Il({ inputs: { a: O, b: Q }, backend: n }), de = Wo({ inputs: { input: se }, backend: n }), Ie = Wo({ inputs: { input: ie }, backend: n }), Se = qs({ inputs: { input: se }, backend: n }), Ee = qs({ inputs: { input: ie }, backend: n }), Me = vi({ inputs: [de, Ie], backend: n, attrs: { axis: 0 } }), st = vi({ inputs: [Se, Ee], backend: n, attrs: { axis: 0 } }), pt = n.data.get(Me.dataId).values, De = n.data.get(st.dataId).values;
- return n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(m), n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(b), n.disposeIntermediateTensorInfo(C), n.disposeIntermediateTensorInfo(w), n.disposeIntermediateTensorInfo(A), n.disposeIntermediateTensorInfo(D), n.disposeIntermediateTensorInfo(O), n.disposeIntermediateTensorInfo(G), n.disposeIntermediateTensorInfo(q), n.disposeIntermediateTensorInfo(H), n.disposeIntermediateTensorInfo(Z), n.disposeIntermediateTensorInfo(ee), n.disposeIntermediateTensorInfo(X), n.disposeIntermediateTensorInfo(Q), n.disposeIntermediateTensorInfo(se), n.disposeIntermediateTensorInfo(ie), n.disposeIntermediateTensorInfo(de), n.disposeIntermediateTensorInfo(Se), n.disposeIntermediateTensorInfo(Ie), n.disposeIntermediateTensorInfo(Ee), n.disposeIntermediateTensorInfo(Me), n.disposeIntermediateTensorInfo(st), { real: pt, imag: De };
+ let s = S.mergeRealAndImagArrays(r, e), a = t6 / 2, i = S.complexWithEvenIndex(s), p = i.real, u = i.imag, c = [p.length], l = n.makeTensorInfo(c, "float32", p), m = n.makeTensorInfo(c, "float32", u), d = Ht({ inputs: { real: l, imag: m }, backend: n }), f = S.complexWithOddIndex(s), h = f.real, g = f.imag, x = [h.length], b = n.makeTensorInfo(x, "float32", h), C = n.makeTensorInfo(x, "float32", g), w = Ht({ inputs: { real: b, imag: C }, backend: n }), k = _S(p, u, a, o, n), _ = k.real, $ = k.imag, A = [_.length], R = n.makeTensorInfo(A, "float32", _), D = n.makeTensorInfo(A, "float32", $), P = Ht({ inputs: { real: R, imag: D }, backend: n }), M = _S(h, g, a, o, n), L = M.real, W = M.imag, V = [L.length], U = n.makeTensorInfo(V, "float32", L), q = n.makeTensorInfo(V, "float32", W), H = Ht({ inputs: { real: U, imag: q }, backend: n }), j = S.exponents(t6, o), X = [j.real.length], Z = n.makeTensorInfo(X, "float32", j.real), ee = n.makeTensorInfo(X, "float32", j.imag), Y = Ht({ inputs: { real: Z, imag: ee }, backend: n }), J = wu({ inputs: { a: Y, b: H }, backend: n }), ie = js({ inputs: { a: P, b: J }, backend: n }), pe = dl({ inputs: { a: P, b: J }, backend: n }), he = wo({ inputs: { input: ie }, backend: n }), we = wo({ inputs: { input: pe }, backend: n }), ve = Xs({ inputs: { input: ie }, backend: n }), $e = Xs({ inputs: { input: pe }, backend: n }), Le = Pi({ inputs: [he, we], backend: n, attrs: { axis: 0 } }), nt = Pi({ inputs: [ve, $e], backend: n, attrs: { axis: 0 } }), pt = n.data.get(Le.dataId).values, Oe = n.data.get(nt.dataId).values;
+ return n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(m), n.disposeIntermediateTensorInfo(d), n.disposeIntermediateTensorInfo(b), n.disposeIntermediateTensorInfo(C), n.disposeIntermediateTensorInfo(w), n.disposeIntermediateTensorInfo(R), n.disposeIntermediateTensorInfo(D), n.disposeIntermediateTensorInfo(P), n.disposeIntermediateTensorInfo(U), n.disposeIntermediateTensorInfo(q), n.disposeIntermediateTensorInfo(H), n.disposeIntermediateTensorInfo(Z), n.disposeIntermediateTensorInfo(ee), n.disposeIntermediateTensorInfo(Y), n.disposeIntermediateTensorInfo(J), n.disposeIntermediateTensorInfo(ie), n.disposeIntermediateTensorInfo(pe), n.disposeIntermediateTensorInfo(he), n.disposeIntermediateTensorInfo(ve), n.disposeIntermediateTensorInfo(we), n.disposeIntermediateTensorInfo($e), n.disposeIntermediateTensorInfo(Le), n.disposeIntermediateTensorInfo(nt), { real: pt, imag: Oe };
}
-function CX(r, e, t10) {
+function Wj(r, e, t6) {
let o = new Float32Array(e * 2);
for (let n = 0; n < e; n++) {
let s = 0, a = 0;
for (let i = 0; i < e; i++) {
- let p = I.exponent(n * i, e, t10), u = I.getComplexWithIndex(r, i);
+ let p = S.exponent(n * i, e, t6), u = S.getComplexWithIndex(r, i);
s += u.real * p.real - u.imag * p.imag, a += u.real * p.imag + u.imag * p.real;
}
- t10 && (s /= e, a /= e), I.assignToTypedArray(o, s, a, n);
+ t6 && (s /= e, a /= e), S.assignToTypedArray(o, s, a, n);
}
return o;
}
-function IX(r) {
- let { inputs: e, backend: t10 } = r, { input: o } = e, n = x.sizeFromShape(o.shape), s = o.shape[o.shape.length - 1], a = n / s, i = Oe({ inputs: { x: o }, backend: t10, attrs: { shape: [a, s] } }), p = Pd(i, false, t10), u = Oe({ inputs: { x: p }, backend: t10, attrs: { shape: o.shape } });
- return t10.disposeIntermediateTensorInfo(i), t10.disposeIntermediateTensorInfo(p), u;
+function Uj(r) {
+ let { inputs: e, backend: t6 } = r, { input: o } = e, n = y.sizeFromShape(o.shape), s = o.shape[o.shape.length - 1], a = n / s, i = Me({ inputs: { x: o }, backend: t6, attrs: { shape: [a, s] } }), p = vf(i, false, t6), u = Me({ inputs: { x: p }, backend: t6, attrs: { shape: o.shape } });
+ return t6.disposeIntermediateTensorInfo(i), t6.disposeIntermediateTensorInfo(p), u;
}
-var m_ = { kernelName: bp, backendName: "cpu", kernelFunc: IX };
-function kl(r) {
- let { backend: e, attrs: t10 } = r, { shape: o, value: n, dtype: s } = t10, a = s || x.inferDtype(n), i = x.getArrayFromDType(a, x.sizeFromShape(o));
- return wX(i, n, a), e.makeTensorInfo(o, a, i);
+var z2 = { kernelName: oi, backendName: "cpu", kernelFunc: Uj };
+function xl(r) {
+ let { backend: e, attrs: t6 } = r, { shape: o, value: n, dtype: s } = t6, a = s || y.inferDtype(n), i = y.getArrayFromDType(a, y.sizeFromShape(o));
+ return Gj(i, n, a), e.makeTensorInfo(o, a, i);
}
-var f_ = { kernelName: ys, backendName: "cpu", kernelFunc: kl };
-function wX(r, e, t10) {
+var W2 = { kernelName: Cs, backendName: "cpu", kernelFunc: xl };
+function Gj(r, e, t6) {
r.fill(e);
}
-var d_ = { kernelName: Sn, backendName: "cpu", kernelFunc: ({ inputs: r, attrs: e, backend: t10 }) => {
- let { image: o } = r, n = t10, s = x.getTypedArrayFromDType(o.dtype, x.sizeFromShape(o.shape)), [a, i, p, u] = o.shape, c = n.data.get(o.dataId).values;
+var U2 = { kernelName: on, backendName: "cpu", kernelFunc: ({ inputs: r, attrs: e, backend: t6 }) => {
+ let { image: o } = r, n = t6, s = y.getTypedArrayFromDType(o.dtype, y.sizeFromShape(o.shape)), [a, i, p, u] = o.shape, c = n.data.get(o.dataId).values;
for (let m = 0; m < a; m++) {
- let f = m * p * i * u;
- for (let d = 0; d < i; d++) {
- let h = d * (p * u);
+ let d = m * p * i * u;
+ for (let f = 0; f < i; f++) {
+ let h = f * (p * u);
for (let g = 0; g < p; g++) {
- let y = g * u;
+ let x = g * u;
for (let b = 0; b < u; b++) {
- let C = Math.round(p - g - 1), w = f + h + y + b, k = c[w];
+ let C = Math.round(p - g - 1), w = d + h + x + b, k = c[w];
if (C >= 0 && C < p) {
- let _ = C * u, E = f + h + _ + b;
- k = c[E];
+ let _ = C * u, $ = d + h + _ + b;
+ k = c[$];
}
s[w] = k;
}
@@ -13854,645 +13900,645 @@ var d_ = { kernelName: Sn, backendName: "cpu", kernelFunc: ({ inputs: r, attrs:
}
return { dataId: n.write(s, o.shape, o.dtype), shape: o.shape, dtype: o.dtype };
} };
-var SX = Le((r, e) => Math.floor(r / e));
-var vX = Ye(vn, SX, null, "int32");
-var h_ = { kernelName: vn, backendName: "cpu", kernelFunc: vX };
-function kX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m, activation: f, leakyreluAlpha: d } = o, h = RI({ inputs: { x: n, filter: s }, backend: t10, attrs: { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m } });
+var Hj = Be((r, e) => Math.floor(r / e));
+var qj = Qe(sn, Hj, null, "int32");
+var G2 = { kernelName: sn, backendName: "cpu", kernelFunc: qj };
+function Kj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m, activation: d, leakyreluAlpha: f } = o, h = NS({ inputs: { x: n, filter: s }, backend: t6, attrs: { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m } });
if (a) {
let g = h;
if (c === "NCHW" && a.shape.length === 1 && a.shape[0] !== 1) {
- let y = Oe({ inputs: { x: a }, backend: t10, attrs: { shape: [a.shape[0], 1, 1] } });
- h = Hs({ inputs: { a: h, b: y }, backend: t10 }), t10.disposeIntermediateTensorInfo(y);
+ let x = Me({ inputs: { x: a }, backend: t6, attrs: { shape: [a.shape[0], 1, 1] } });
+ h = js({ inputs: { a: h, b: x }, backend: t6 }), t6.disposeIntermediateTensorInfo(x);
} else
- h = Hs({ inputs: { a: h, b: a }, backend: t10 });
- t10.disposeIntermediateTensorInfo(g);
+ h = js({ inputs: { a: h, b: a }, backend: t6 });
+ t6.disposeIntermediateTensorInfo(g);
}
- if (f) {
+ if (d) {
let g = h;
- if (c === "NCHW" && f === "prelu" && i.shape.length === 1 && i.shape[0] !== 1) {
- let y = Oe({ inputs: { x: i }, backend: t10, attrs: { shape: [i.shape[0], 1, 1] } });
- h = _u(t10, h, f, y, d), t10.disposeIntermediateTensorInfo(y);
+ if (c === "NCHW" && d === "prelu" && i.shape.length === 1 && i.shape[0] !== 1) {
+ let x = Me({ inputs: { x: i }, backend: t6, attrs: { shape: [i.shape[0], 1, 1] } });
+ h = _u(t6, h, d, x, f), t6.disposeIntermediateTensorInfo(x);
} else
- h = _u(t10, h, f, i, d);
- t10.disposeIntermediateTensorInfo(g);
+ h = _u(t6, h, d, i, f);
+ t6.disposeIntermediateTensorInfo(g);
}
return h;
}
-var g_ = { kernelName: Do, backendName: "cpu", kernelFunc: kX };
-function TX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m, activation: f, leakyreluAlpha: d } = o, h = AI({ inputs: { x: n, filter: s }, backend: t10, attrs: { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m } });
+var H2 = { kernelName: ho, backendName: "cpu", kernelFunc: Kj };
+function jj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m, activation: d, leakyreluAlpha: f } = o, h = TS({ inputs: { x: n, filter: s }, backend: t6, attrs: { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m } });
if (a) {
let g = h;
- h = Hs({ inputs: { a: h, b: a }, backend: t10 }), t10.disposeIntermediateTensorInfo(g);
+ h = js({ inputs: { a: h, b: a }, backend: t6 }), t6.disposeIntermediateTensorInfo(g);
}
- if (f) {
+ if (d) {
let g = h;
- h = _u(t10, h, f, i, d), t10.disposeIntermediateTensorInfo(g);
+ h = _u(t6, h, d, i, f), t6.disposeIntermediateTensorInfo(g);
}
return h;
}
-var x_ = { kernelName: Po, backendName: "cpu", kernelFunc: TX };
-function NX(r) {
- let { inputs: e, backend: t10 } = r, { params: o, indices: n } = e, s = x.sizeFromShape(o.shape), a = n.shape, i = a[a.length - 1], [p, u, c, l] = I.prepareAndValidate(o, n);
+var q2 = { kernelName: go, backendName: "cpu", kernelFunc: jj };
+function Xj(r) {
+ let { inputs: e, backend: t6 } = r, { params: o, indices: n } = e, s = y.sizeFromShape(o.shape), a = n.shape, i = a[a.length - 1], [p, u, c, l] = S.prepareAndValidate(o, n);
if (u === 0)
- return t10.makeTensorInfo(p, o.dtype, []);
- let m = t10.data.get(n.dataId).values, f = t10.bufferSync(o), d = bd(m, f, o.dtype, u, i, c, l, o.shape, s);
- return t10.makeTensorInfo(p, o.dtype, d.values);
+ return t6.makeTensorInfo(p, o.dtype, []);
+ let m = t6.data.get(n.dataId).values, d = t6.bufferSync(o), f = pf(m, d, o.dtype, u, i, c, l, o.shape, s);
+ return t6.makeTensorInfo(p, o.dtype, f.values);
}
-var y_ = { kernelName: Tn, backendName: "cpu", kernelFunc: NX };
-function _X(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, indices: s } = e, { axis: a, batchDims: i } = o;
+var K2 = { kernelName: un, backendName: "cpu", kernelFunc: Xj };
+function Yj(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, indices: s } = e, { axis: a, batchDims: i } = o;
K([n, s], "gatherV2");
- let p = x.parseAxisParam(a, n.shape)[0], u = t10.data.get(s.dataId).values, c = n.shape[p];
+ let p = y.parseAxisParam(a, n.shape)[0], u = t6.data.get(s.dataId).values, c = n.shape[p];
for (let w = 0; w < u.length; ++w) {
let k = u[w];
- x.assert(k <= c - 1 && k >= 0, () => `GatherV2: the index value ${k} is not in [0, ${c - 1}]`);
+ y.assert(k <= c - 1 && k >= 0, () => `GatherV2: the index value ${k} is not in [0, ${c - 1}]`);
}
let l = i;
i == null && (l = 0);
- let m = x.sizeFromShape(s.shape), f = I.segment_util.collectGatherOpShapeInfo(n, s, p, l), d = Oe({ inputs: { x: n }, backend: t10, attrs: { shape: [f.batchSize, f.outerSize, f.dimSize, f.sliceSize] } }), h = Oe({ inputs: { x: s }, backend: t10, attrs: { shape: [f.batchSize, m / f.batchSize] } }), g = [f.batchSize, f.outerSize, m / f.batchSize, f.sliceSize], y = t10.bufferSync(h), b = t10.bufferSync(d), C = Cd(b, y, g);
- return t10.disposeIntermediateTensorInfo(d), t10.disposeIntermediateTensorInfo(h), t10.makeTensorInfo(f.outputShape, C.dtype, C.values);
+ let m = y.sizeFromShape(s.shape), d = S.segment_util.collectGatherOpShapeInfo(n, s, p, l), f = Me({ inputs: { x: n }, backend: t6, attrs: { shape: [d.batchSize, d.outerSize, d.dimSize, d.sliceSize] } }), h = Me({ inputs: { x: s }, backend: t6, attrs: { shape: [d.batchSize, m / d.batchSize] } }), g = [d.batchSize, d.outerSize, m / d.batchSize, d.sliceSize], x = t6.bufferSync(h), b = t6.bufferSync(f), C = cf(b, x, g);
+ return t6.disposeIntermediateTensorInfo(f), t6.disposeIntermediateTensorInfo(h), t6.makeTensorInfo(d.outputShape, C.dtype, C.values);
}
-var b_ = { kernelName: bs, backendName: "cpu", kernelFunc: _X };
-function EX(r) {
- let { inputs: e, backend: t10 } = r, { input: o } = e, n = x.sizeFromShape(o.shape), s = o.shape[o.shape.length - 1], a = n / s, i = Oe({ inputs: { x: o }, backend: t10, attrs: { shape: [a, s] } }), p = Pd(i, true, t10), u = Oe({ inputs: { x: p }, backend: t10, attrs: { shape: o.shape } });
- return t10.disposeIntermediateTensorInfo(i), t10.disposeIntermediateTensorInfo(p), u;
+var j2 = { kernelName: Ss, backendName: "cpu", kernelFunc: Yj };
+function Qj(r) {
+ let { inputs: e, backend: t6 } = r, { input: o } = e, n = y.sizeFromShape(o.shape), s = o.shape[o.shape.length - 1], a = n / s, i = Me({ inputs: { x: o }, backend: t6, attrs: { shape: [a, s] } }), p = vf(i, true, t6), u = Me({ inputs: { x: p }, backend: t6, attrs: { shape: o.shape } });
+ return t6.disposeIntermediateTensorInfo(i), t6.disposeIntermediateTensorInfo(p), u;
}
-var C_ = { kernelName: Cp, backendName: "cpu", kernelFunc: EX };
-var $X = we(Hi, (r) => Number.isFinite(r) ? 1 : 0, "bool");
-var I_ = { kernelName: Hi, backendName: "cpu", kernelFunc: $X };
-var RX = we(qi, (r) => Math.abs(r) === 1 / 0 ? 1 : 0, "bool");
-var w_ = { kernelName: qi, backendName: "cpu", kernelFunc: RX };
-var AX = we(ia, (r) => Number.isNaN(r) ? 1 : 0, "bool");
-var S_ = { kernelName: ia, backendName: "cpu", kernelFunc: AX };
-function FX(r) {
- let { backend: e, attrs: t10 } = r, { start: o, stop: n, num: s } = t10, a = Id(o, n, s);
+var X2 = { kernelName: ni, backendName: "cpu", kernelFunc: Qj };
+var Zj = Ie(fa, (r) => Number.isFinite(r) ? 1 : 0, "bool");
+var Y2 = { kernelName: fa, backendName: "cpu", kernelFunc: Zj };
+var Jj = Ie(ha, (r) => Math.abs(r) === 1 / 0 ? 1 : 0, "bool");
+var Q2 = { kernelName: ha, backendName: "cpu", kernelFunc: Jj };
+var eX = Ie(ln, (r) => Number.isNaN(r) ? 1 : 0, "bool");
+var Z2 = { kernelName: ln, backendName: "cpu", kernelFunc: eX };
+function tX(r) {
+ let { backend: e, attrs: t6 } = r, { start: o, stop: n, num: s } = t6, a = lf(o, n, s);
return e.makeTensorInfo([a.length], "float32", a);
}
-var v_ = { kernelName: Ip, backendName: "cpu", kernelFunc: FX };
-var DX = we(Ki, (r) => Math.log1p(r));
-var k_ = { kernelName: Ki, backendName: "cpu", kernelFunc: DX };
-var PX = Le((r, e) => r && e);
-var OX = Ye(_n, PX, null, "bool");
-var T_ = { kernelName: _n, backendName: "cpu", kernelFunc: OX };
-var MX = we(En, (r) => r ? 0 : 1, "bool");
-var N_ = { kernelName: En, backendName: "cpu", kernelFunc: MX };
-var LX = Le((r, e) => r || e);
-var BX = Ye(ua, LX, null, "bool");
-var __ = { kernelName: ua, backendName: "cpu", kernelFunc: BX };
-function VX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { depthRadius: s, bias: a, alpha: i, beta: p } = o;
+var J2 = { kernelName: xp, backendName: "cpu", kernelFunc: tX };
+var rX = Ie(ga, (r) => Math.log1p(r));
+var e_ = { kernelName: ga, backendName: "cpu", kernelFunc: rX };
+var oX = Be((r, e) => r && e);
+var nX = Qe(gn, oX, null, "bool");
+var t_ = { kernelName: gn, backendName: "cpu", kernelFunc: nX };
+var sX = Ie(xn, (r) => r ? 0 : 1, "bool");
+var r_ = { kernelName: xn, backendName: "cpu", kernelFunc: sX };
+var aX = Be((r, e) => r || e);
+var iX = Qe(xa, aX, null, "bool");
+var o_ = { kernelName: xa, backendName: "cpu", kernelFunc: iX };
+function uX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { depthRadius: s, bias: a, alpha: i, beta: p } = o;
K(n, "LRN");
- let u = n.shape[3], c = u - 1, l = t10.data.get(n.dataId).values, m = x.sizeFromShape(n.shape), f = new Float32Array(m);
- function d(h) {
- let g = h % u, y = h - g + Math.max(0, g - s), b = h - g + Math.min(g + s, c), C = 0;
- for (; y <= b; y++) {
- let w = l[y];
+ let u = n.shape[3], c = u - 1, l = t6.data.get(n.dataId).values, m = y.sizeFromShape(n.shape), d = new Float32Array(m);
+ function f(h) {
+ let g = h % u, x = h - g + Math.max(0, g - s), b = h - g + Math.min(g + s, c), C = 0;
+ for (; x <= b; x++) {
+ let w = l[x];
C += w * w;
}
return C;
}
for (let h = 0; h < m; h++) {
- let g = d(h), y = l[h] * Math.pow(a + i * g, -p);
- f[h] = y;
+ let g = f(h), x = l[h] * Math.pow(a + i * g, -p);
+ d[h] = x;
}
- return t10.makeTensorInfo(n.shape, n.dtype, f);
+ return t6.makeTensorInfo(n.shape, n.dtype, d);
}
-var E_ = { kernelName: wp, backendName: "cpu", kernelFunc: VX };
-function zX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, y: s, dy: a } = e, { depthRadius: i, bias: p, alpha: u, beta: c } = o;
+var n_ = { kernelName: yp, backendName: "cpu", kernelFunc: uX };
+function pX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, y: s, dy: a } = e, { depthRadius: i, bias: p, alpha: u, beta: c } = o;
K(a, "LRNGrad");
- let l = x.sizeFromShape(a.shape), m = a.shape[3], f = t10.data.get(a.dataId).values, d = t10.data.get(n.dataId).values, h = t10.data.get(s.dataId).values, g = new Float32Array(l), y = l;
- for (let b = 0; b < y; b++) {
+ let l = y.sizeFromShape(a.shape), m = a.shape[3], d = t6.data.get(a.dataId).values, f = t6.data.get(n.dataId).values, h = t6.data.get(s.dataId).values, g = new Float32Array(l), x = l;
+ for (let b = 0; b < x; b++) {
let C = b % m, w = b - C + Math.max(0, C - i), k = b - C + Math.min(m, C + i + 1), _ = 0;
- for (let E = w; E < k; E++)
- _ += Math.pow(d[E], 2);
+ for (let $ = w; $ < k; $++)
+ _ += Math.pow(f[$], 2);
_ = u * _ + p;
- for (let E = w; E < k; E++) {
- let R = -2 * u * c * d[E] * h[b] / _;
- b === E && (R += Math.pow(_, -c)), R *= f[b], g[E] += R;
+ for (let $ = w; $ < k; $++) {
+ let A = -2 * u * c * f[$] * h[b] / _;
+ b === $ && (A += Math.pow(_, -c)), A *= d[b], g[$] += A;
}
}
- return t10.makeTensorInfo(a.shape, n.dtype, g);
+ return t6.makeTensorInfo(a.shape, n.dtype, g);
}
-var $_ = { kernelName: Om, backendName: "cpu", kernelFunc: zX };
-function DI(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { reductionIndices: s, keepDims: a } = o, i = t10, p = n.shape, u = p.length, c = x.parseAxisParam(s, p), l = c, m = I.getAxesPermutation(l, u), f = i.data.get(n.dataId).values;
+var s_ = { kernelName: Nm, backendName: "cpu", kernelFunc: pX };
+function ES(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { reductionIndices: s, keepDims: a } = o, i = t6, p = n.shape, u = p.length, c = y.parseAxisParam(s, p), l = c, m = S.getAxesPermutation(l, u), d = i.data.get(n.dataId).values;
if (m != null) {
let w = new Array(u);
for (let k = 0; k < w.length; k++)
w[k] = p[m[k]];
- f = Jp(f, p, n.dtype, m, w), l = I.getInnerMostAxes(l.length, u), p = w;
+ d = jp(d, p, n.dtype, m, w), l = S.getInnerMostAxes(l.length, u), p = w;
}
- K(n, "max"), I.assertAxesAreInnerMostDims("max", l, u);
- let [d, h] = I.computeOutAndReduceShapes(p, l), g = x.sizeFromShape(h), y = wd(f, g, d, n.dtype), b = i.write(y, d, n.dtype), C = d;
- return a && (C = I.expandShapeToKeepDim(d, c)), { dataId: b, shape: C, dtype: n.dtype };
+ K(n, "max"), S.assertAxesAreInnerMostDims("max", l, u);
+ let [f, h] = S.computeOutAndReduceShapes(p, l), g = y.sizeFromShape(h), x = mf(d, g, f, n.dtype), b = i.write(x, f, n.dtype), C = f;
+ return a && (C = S.expandShapeToKeepDim(f, c)), { dataId: b, shape: C, dtype: n.dtype };
}
-var R_ = { kernelName: $n, backendName: "cpu", kernelFunc: DI };
-function WX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e;
+var a_ = { kernelName: yn, backendName: "cpu", kernelFunc: ES };
+function cX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e;
K(n, "maxPool");
let { filterSize: s, strides: a, pad: i, dimRoundingMode: p } = o, u = 1;
- x.assert(I.eitherStridesOrDilationsAreOne(a, u), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
- let c = I.computePool2DInfo(n.shape, s, a, u, i, p), l;
- if (c.filterWidth === 1 && c.filterHeight === 1 && x.arraysEqual(c.inShape, c.outShape))
- l = ar({ inputs: { x: n }, backend: t10 });
+ y.assert(S.eitherStridesOrDilationsAreOne(a, u), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
+ let c = S.computePool2DInfo(n.shape, s, a, u, i, p), l;
+ if (c.filterWidth === 1 && c.filterHeight === 1 && y.arraysEqual(c.inShape, c.outShape))
+ l = ar({ inputs: { x: n }, backend: t6 });
else {
- let m = t10.data.get(n.dataId).values, f = x.computeStrides(n.shape), d = rc(m, n.shape, n.dtype, f, c, "max");
- l = t10.makeTensorInfo(c.outShape, n.dtype, d.values);
+ let m = t6.data.get(n.dataId).values, d = y.computeStrides(n.shape), f = Zp(m, n.shape, n.dtype, d, c, "max");
+ l = t6.makeTensorInfo(c.outShape, n.dtype, f.values);
}
return l;
}
-var A_ = { kernelName: Rn, backendName: "cpu", kernelFunc: WX };
-function UX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { filterSize: s, strides: a, pad: i, dimRoundingMode: p, dataFormat: u } = o;
+var i_ = { kernelName: Cn, backendName: "cpu", kernelFunc: cX };
+function lX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { filterSize: s, strides: a, pad: i, dimRoundingMode: p, dataFormat: u } = o;
K(n, "maxPool3d");
- let c = I.computePool3DInfo(n.shape, s, a, 1, i, p, u), l = t10.data.get(n.dataId).values, m = Dd(l, n.shape, n.dtype, x.computeStrides(n.shape), c, "max");
- return t10.makeTensorInfo(m.shape, "float32", m.values);
+ let c = S.computePool3DInfo(n.shape, s, a, 1, i, p, u), l = t6.data.get(n.dataId).values, m = If(l, n.shape, n.dtype, y.computeStrides(n.shape), c, "max");
+ return t6.makeTensorInfo(m.shape, "float32", m.values);
}
-var F_ = { kernelName: Sp, backendName: "cpu", kernelFunc: UX };
-function GX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, input: s } = e, { filterSize: a, strides: i, pad: p, dimRoundingMode: u } = o;
+var u_ = { kernelName: bp, backendName: "cpu", kernelFunc: lX };
+function mX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, input: s } = e, { filterSize: a, strides: i, pad: p, dimRoundingMode: u } = o;
K([n, s], "maxPool3DGrad");
- let c = I.computePool3DInfo(s.shape, a, i, 1, p, u), l = t10.bufferSync(s), m = _2(l, c), f = c.strideDepth, d = c.strideHeight, h = c.strideWidth, g = c.dilationDepth, y = c.dilationHeight, b = c.dilationWidth, C = c.effectiveFilterDepth, w = c.effectiveFilterHeight, k = c.effectiveFilterWidth, _ = C - 1 - c.padInfo.front, E = k - 1 - c.padInfo.left, R = w - 1 - c.padInfo.top, A = ne(s.shape, "float32"), D = t10.bufferSync(n);
- for (let O = 0; O < c.batchSize; ++O)
+ let c = S.computePool3DInfo(s.shape, a, i, 1, p, u), l = t6.bufferSync(s), m = o2(l, c), d = c.strideDepth, f = c.strideHeight, h = c.strideWidth, g = c.dilationDepth, x = c.dilationHeight, b = c.dilationWidth, C = c.effectiveFilterDepth, w = c.effectiveFilterHeight, k = c.effectiveFilterWidth, _ = C - 1 - c.padInfo.front, $ = k - 1 - c.padInfo.left, A = w - 1 - c.padInfo.top, R = le(s.shape, "float32"), D = t6.bufferSync(n);
+ for (let P = 0; P < c.batchSize; ++P)
for (let M = 0; M < c.inChannels; ++M)
for (let L = 0; L < c.inDepth; ++L)
for (let W = 0; W < c.inHeight; ++W)
for (let V = 0; V < c.inWidth; ++V) {
- let G = L - _, q = W - R, H = V - E, j = 0;
- for (let Y = 0; Y < C; Y += g) {
- let Z = (G + Y) / f;
+ let U = L - _, q = W - A, H = V - $, j = 0;
+ for (let X = 0; X < C; X += g) {
+ let Z = (U + X) / d;
if (!(Z < 0 || Z >= c.outDepth || Math.floor(Z) !== Z))
- for (let ee = 0; ee < w; ee += y) {
- let X = (q + ee) / d;
- if (!(X < 0 || X >= c.outHeight || Math.floor(X) !== X))
- for (let Q = 0; Q < k; Q += b) {
- let se = (H + Q) / h;
- if (se < 0 || se >= c.outWidth || Math.floor(se) !== se)
+ for (let ee = 0; ee < w; ee += x) {
+ let Y = (q + ee) / f;
+ if (!(Y < 0 || Y >= c.outHeight || Math.floor(Y) !== Y))
+ for (let J = 0; J < k; J += b) {
+ let ie = (H + J) / h;
+ if (ie < 0 || ie >= c.outWidth || Math.floor(ie) !== ie)
continue;
- let ie = C * w * k - 1 - m.get(O, Z, X, se, M), de = Y * w * k + ee * k + Q, Ie = ie === de ? 1 : 0;
- if (Ie === 0)
+ let pe = C * w * k - 1 - m.get(P, Z, Y, ie, M), he = X * w * k + ee * k + J, we = pe === he ? 1 : 0;
+ if (we === 0)
continue;
- let Se = D.get(O, Z, X, se, M);
- j += Se * Ie;
+ let ve = D.get(P, Z, Y, ie, M);
+ j += ve * we;
}
}
}
- A.set(j, O, L, W, V, M);
+ R.set(j, P, L, W, V, M);
}
- return t10.makeTensorInfo(A.shape, A.dtype, A.values);
+ return t6.makeTensorInfo(R.shape, R.dtype, R.values);
}
-var D_ = { kernelName: Lm, backendName: "cpu", kernelFunc: GX };
-function HX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, input: s, output: a } = e, i = s;
+var p_ = { kernelName: _m, backendName: "cpu", kernelFunc: mX };
+function dX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, input: s, output: a } = e, i = s;
K([s, a], "maxPoolGrad");
- let { filterSize: p, strides: u, pad: c, dimRoundingMode: l } = o, m = I.computePool2DInfo(i.shape, p, u, 1, c, l), f = t10.data.get(i.dataId).values, d = ne(m.outShape, i.dtype, Fd(f, i.shape, i.dtype, m).values), h = m.strideHeight, g = m.strideWidth, y = m.dilationHeight, b = m.dilationWidth, C = m.effectiveFilterHeight, w = m.effectiveFilterWidth, k = w - 1 - m.padInfo.left, _ = C - 1 - m.padInfo.top, E = ne(i.shape, "float32"), R = t10.data.get(n.dataId).values, A = ne(n.shape, "float32", R);
+ let { filterSize: p, strides: u, pad: c, dimRoundingMode: l } = o, m = S.computePool2DInfo(i.shape, p, u, 1, c, l), d = t6.data.get(i.dataId).values, f = le(m.outShape, i.dtype, wf(d, i.shape, i.dtype, m).values), h = m.strideHeight, g = m.strideWidth, x = m.dilationHeight, b = m.dilationWidth, C = m.effectiveFilterHeight, w = m.effectiveFilterWidth, k = w - 1 - m.padInfo.left, _ = C - 1 - m.padInfo.top, $ = le(i.shape, "float32"), A = t6.data.get(n.dataId).values, R = le(n.shape, "float32", A);
for (let D = 0; D < m.batchSize; ++D)
- for (let O = 0; O < m.inChannels; ++O)
+ for (let P = 0; P < m.inChannels; ++P)
for (let M = 0; M < m.inHeight; ++M)
for (let L = 0; L < m.inWidth; ++L) {
- let W = M - _, V = L - k, G = 0;
- for (let q = 0; q < C; q += y) {
+ let W = M - _, V = L - k, U = 0;
+ for (let q = 0; q < C; q += x) {
let H = (W + q) / h;
if (!(H < 0 || H >= m.outHeight || Math.floor(H) !== H))
for (let j = 0; j < w; j += b) {
- let Y = (V + j) / g;
- if (Y < 0 || Y >= m.outWidth || Math.floor(Y) !== Y)
+ let X = (V + j) / g;
+ if (X < 0 || X >= m.outWidth || Math.floor(X) !== X)
continue;
- let Z = C * w - 1 - d.get(D, H, Y, O), ee = q * w + j, X = Z === ee ? 1 : 0;
- if (X === 0)
+ let Z = C * w - 1 - f.get(D, H, X, P), ee = q * w + j, Y = Z === ee ? 1 : 0;
+ if (Y === 0)
continue;
- let Q = A.get(D, H, Y, O);
- G += Q * X;
+ let J = R.get(D, H, X, P);
+ U += J * Y;
}
}
- E.set(G, D, M, L, O);
+ $.set(U, D, M, L, P);
}
- return t10.makeTensorInfo(E.shape, E.dtype, E.values);
+ return t6.makeTensorInfo($.shape, $.dtype, $.values);
}
-var P_ = { kernelName: Mm, backendName: "cpu", kernelFunc: HX };
-function O_(r, e, t10, o, n) {
- let s = x.computeStrides(e), a = rc(r, e, t10, s, n, "max"), i = Fd(r, e, t10, n, true, o);
+var c_ = { kernelName: Tm, backendName: "cpu", kernelFunc: dX };
+function l_(r, e, t6, o, n) {
+ let s = y.computeStrides(e), a = Zp(r, e, t6, s, n, "max"), i = wf(r, e, t6, n, true, o);
return [a.values, i.values];
}
-var M_ = { kernelName: vp, backendName: "cpu", kernelFunc: ({ inputs: r, attrs: e, backend: t10 }) => {
- let { x: o } = r, { filterSize: n, strides: s, pad: a, includeBatchInIndex: i } = e, p = t10;
+var m_ = { kernelName: Cp, backendName: "cpu", kernelFunc: ({ inputs: r, attrs: e, backend: t6 }) => {
+ let { x: o } = r, { filterSize: n, strides: s, pad: a, includeBatchInIndex: i } = e, p = t6;
K(o, "MaxPoolWithArgmax");
- let u = p.data.get(o.dataId).values, c = I.computePool2DInfo(o.shape, n, s, [1, 1], a), [l, m] = O_(u, o.shape, o.dtype, i, c), f = p.write(l, c.outShape, o.dtype), d = p.write(m, c.outShape, o.dtype);
- return [{ dataId: f, shape: c.outShape, dtype: o.dtype }, { dataId: d, shape: c.outShape, dtype: "int32" }];
+ let u = p.data.get(o.dataId).values, c = S.computePool2DInfo(o.shape, n, s, [1, 1], a), [l, m] = l_(u, o.shape, o.dtype, i, c), d = p.write(l, c.outShape, o.dtype), f = p.write(m, c.outShape, o.dtype);
+ return [{ dataId: d, shape: c.outShape, dtype: o.dtype }, { dataId: f, shape: c.outShape, dtype: "int32" }];
} };
-function qX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = x.parseAxisParam(s, n.shape), u = I.computeOutAndReduceShapes(n.shape, i)[1], c = x.sizeFromShape(u), l = [], m = t10.makeTensorInfo([], "float32", new Float32Array([c]));
+function fX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = y.parseAxisParam(s, n.shape), u = S.computeOutAndReduceShapes(n.shape, i)[1], c = y.sizeFromShape(u), l = [], m = t6.makeTensorInfo([], "float32", new Float32Array([c]));
l.push(m);
- let f = Uo({ inputs: { x: n }, backend: t10, attrs: { dtype: "float32" } });
- l.push(f);
- let d = Sl({ inputs: { a: f, b: m }, backend: t10 });
+ let d = Io({ inputs: { x: n }, backend: t6, attrs: { dtype: "float32" } });
l.push(d);
- let h = Fa({ inputs: { x: d }, backend: t10, attrs: { axis: s, keepDims: a } });
- return l.forEach((g) => t10.disposeIntermediateTensorInfo(g)), h;
+ let f = hl({ inputs: { a: d, b: m }, backend: t6 });
+ l.push(f);
+ let h = La({ inputs: { x: f }, backend: t6, attrs: { axis: s, keepDims: a } });
+ return l.forEach((g) => t6.disposeIntermediateTensorInfo(g)), h;
}
-var L_ = { kernelName: An, backendName: "cpu", kernelFunc: qX };
-function KX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
+var d_ = { kernelName: Sn, backendName: "cpu", kernelFunc: fX };
+function hX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
K(n, "min");
- let i = x.parseAxisParam(s, n.shape), p = i, u = I.getAxesPermutation(p, n.shape.length), c = n;
- u != null && (c = bt({ inputs: { x: n }, backend: t10, attrs: { perm: u } }), p = I.getInnerMostAxes(p.length, n.shape.length)), I.assertAxesAreInnerMostDims("min", p, c.shape.length);
- let [l, m] = I.computeOutAndReduceShapes(c.shape, p), f = x.sizeFromShape(m), d = x.makeZerosTypedArray(x.sizeFromShape(l), c.dtype), h = t10.data.get(c.dataId).values;
- for (let y = 0; y < d.length; ++y) {
- let b = y * f, C = h[b];
- for (let w = 0; w < f; ++w) {
+ let i = y.parseAxisParam(s, n.shape), p = i, u = S.getAxesPermutation(p, n.shape.length), c = n;
+ u != null && (c = Ct({ inputs: { x: n }, backend: t6, attrs: { perm: u } }), p = S.getInnerMostAxes(p.length, n.shape.length)), S.assertAxesAreInnerMostDims("min", p, c.shape.length);
+ let [l, m] = S.computeOutAndReduceShapes(c.shape, p), d = y.sizeFromShape(m), f = y.makeZerosTypedArray(y.sizeFromShape(l), c.dtype), h = t6.data.get(c.dataId).values;
+ for (let x = 0; x < f.length; ++x) {
+ let b = x * d, C = h[b];
+ for (let w = 0; w < d; ++w) {
let k = h[b + w];
(Number.isNaN(k) || k < C) && (C = k);
}
- d[y] = C;
+ f[x] = C;
}
- u != null && t10.disposeIntermediateTensorInfo(c);
- let g = t10.makeTensorInfo(l, c.dtype, d);
+ u != null && t6.disposeIntermediateTensorInfo(c);
+ let g = t6.makeTensorInfo(l, c.dtype, f);
if (a) {
- let y = I.expandShapeToKeepDim(l, i), b = Oe({ inputs: { x: g }, backend: t10, attrs: { shape: y } });
- return t10.disposeIntermediateTensorInfo(g), b;
+ let x = S.expandShapeToKeepDim(l, i), b = Me({ inputs: { x: g }, backend: t6, attrs: { shape: x } });
+ return t6.disposeIntermediateTensorInfo(g), b;
}
return g;
}
-var B_ = { kernelName: Fn, backendName: "cpu", kernelFunc: KX };
-function jX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { paddings: s, mode: a } = o;
+var f_ = { kernelName: wn, backendName: "cpu", kernelFunc: hX };
+function gX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { paddings: s, mode: a } = o;
K(n, "mirrorPad");
- let i = s.map((C, w) => C[0] + n.shape[w] + C[1]), p = s.map((C) => C[0]), u = s.map((C, w) => C[0] + n.shape[w]), c = a === "reflect" ? 0 : 1, l = t10.data.get(n.dataId).values, m = n.shape.length, f = x.computeStrides(n.shape), d = x.sizeFromShape(i), h = i.length, g = x.computeStrides(i), y = x.getTypedArrayFromDType(n.dtype, d);
- for (let C = 0; C < d; C++) {
- let w = x.indexToLoc(C, h, g);
+ let i = s.map((C, w) => C[0] + n.shape[w] + C[1]), p = s.map((C) => C[0]), u = s.map((C, w) => C[0] + n.shape[w]), c = a === "reflect" ? 0 : 1, l = t6.data.get(n.dataId).values, m = n.shape.length, d = y.computeStrides(n.shape), f = y.sizeFromShape(i), h = i.length, g = y.computeStrides(i), x = y.getTypedArrayFromDType(n.dtype, f);
+ for (let C = 0; C < f; C++) {
+ let w = y.indexToLoc(C, h, g);
for (let _ = 0; _ < h; _++)
w[_] < p[_] ? w[_] = p[_] * 2 - w[_] - c : w[_] >= u[_] && (w[_] = (u[_] - 1) * 2 - w[_] + c);
- w = w.map((_, E) => _ - p[E]);
- let k = x.locToIndex(w, m, f);
- y[C] = l[k];
+ w = w.map((_, $) => _ - p[$]);
+ let k = y.locToIndex(w, m, d);
+ x[C] = l[k];
}
- return { dataId: t10.write(y, i, n.dtype), shape: i, dtype: n.dtype };
+ return { dataId: t6.write(x, i, n.dtype), shape: i, dtype: n.dtype };
}
-var V_ = { kernelName: Dn, backendName: "cpu", kernelFunc: jX };
-var XX = Le((r, e) => {
- let t10 = r % e;
- return r < 0 && e < 0 || r >= 0 && e >= 0 ? t10 : (t10 + e) % e;
+var h_ = { kernelName: vn, backendName: "cpu", kernelFunc: gX };
+var xX = Be((r, e) => {
+ let t6 = r % e;
+ return r < 0 && e < 0 || r >= 0 && e >= 0 ? t6 : (t6 + e) % e;
});
-var YX = Ye(ji, XX);
-var z_ = { kernelName: ji, backendName: "cpu", kernelFunc: YX };
-var U_ = rp(IC());
-function PI(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { logits: n } = e, { dim: s } = o, a = n.shape.length, i = s;
+var yX = Qe(ya, xX);
+var g_ = { kernelName: ya, backendName: "cpu", kernelFunc: yX };
+var y_ = rp(gC());
+function $S(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { logits: n } = e, { dim: s } = o, a = n.shape.length, i = s;
if (i === -1 && (i = a - 1), i !== a - 1)
throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${a} and dim was ${i}`);
- let p = x.parseAxisParam([i], n.shape), u = DI({ inputs: { x: n }, backend: t10, attrs: { reductionIndices: p, keepDims: false } }), c = I.expandShapeToKeepDim(u.shape, p), l = Oe({ inputs: { x: u }, backend: t10, attrs: { shape: c } }), m = Il({ inputs: { a: n, b: l }, backend: t10 }), f = iI({ inputs: { x: m }, backend: t10 }), d = Fa({ inputs: { x: f }, backend: t10, attrs: { axis: p, keepDims: false } }), h = Oe({ inputs: { x: d }, backend: t10, attrs: { shape: c } }), g = Sl({ inputs: { a: f, b: h }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(u), t10.disposeIntermediateTensorInfo(l), t10.disposeIntermediateTensorInfo(m), t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(d), t10.disposeIntermediateTensorInfo(h), g;
+ let p = y.parseAxisParam([i], n.shape), u = ES({ inputs: { x: n }, backend: t6, attrs: { reductionIndices: p, keepDims: false } }), c = S.expandShapeToKeepDim(u.shape, p), l = Me({ inputs: { x: u }, backend: t6, attrs: { shape: c } }), m = dl({ inputs: { a: n, b: l }, backend: t6 }), d = rS({ inputs: { x: m }, backend: t6 }), f = La({ inputs: { x: d }, backend: t6, attrs: { axis: p, keepDims: false } }), h = Me({ inputs: { x: f }, backend: t6, attrs: { shape: c } }), g = hl({ inputs: { a: d, b: h }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(u), t6.disposeIntermediateTensorInfo(l), t6.disposeIntermediateTensorInfo(m), t6.disposeIntermediateTensorInfo(d), t6.disposeIntermediateTensorInfo(f), t6.disposeIntermediateTensorInfo(h), g;
}
-var W_ = { kernelName: Xn, backendName: "cpu", kernelFunc: PI };
-function QX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { logits: n } = e, { numSamples: s, seed: a, normalized: i } = o;
+var x_ = { kernelName: qn, backendName: "cpu", kernelFunc: $S };
+function bX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { logits: n } = e, { numSamples: s, seed: a, normalized: i } = o;
K(n, "multinomial");
- let p = i ? n : PI({ inputs: { logits: n }, backend: t10, attrs: { dim: -1 } }), u = p.shape[0], c = p.shape[1], l = t10.data.get(p.dataId).values, m = [u, s], f = x.makeZerosTypedArray(x.sizeFromShape(m), "int32");
- for (let d = 0; d < u; ++d) {
- let h = d * c, g = new Float32Array(c - 1);
+ let p = i ? n : $S({ inputs: { logits: n }, backend: t6, attrs: { dim: -1 } }), u = p.shape[0], c = p.shape[1], l = t6.data.get(p.dataId).values, m = [u, s], d = y.makeZerosTypedArray(y.sizeFromShape(m), "int32");
+ for (let f = 0; f < u; ++f) {
+ let h = f * c, g = new Float32Array(c - 1);
g[0] = l[h];
for (let C = 1; C < g.length; ++C)
g[C] = g[C - 1] + l[h + C];
- let y = U_.alea(a.toString()), b = d * s;
+ let x = y_.alea(a.toString()), b = f * s;
for (let C = 0; C < s; ++C) {
- let w = y();
- f[b + C] = g.length;
+ let w = x();
+ d[b + C] = g.length;
for (let k = 0; k < g.length; k++)
if (w < g[k]) {
- f[b + C] = k;
+ d[b + C] = k;
break;
}
}
}
- return i || t10.disposeIntermediateTensorInfo(p), t10.makeTensorInfo(m, "int32", f);
+ return i || t6.disposeIntermediateTensorInfo(p), t6.makeTensorInfo(m, "int32", d);
}
-var G_ = { kernelName: kp, backendName: "cpu", kernelFunc: QX };
-var ZX = Bt.nonMaxSuppressionV3Impl;
-function JX(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p } = o;
+var b_ = { kernelName: Sp, backendName: "cpu", kernelFunc: bX };
+var CX = Lt.nonMaxSuppressionV3Impl;
+function SX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p } = o;
K(n, "NonMaxSuppression");
- let u = t10.data.get(n.dataId).values, c = t10.data.get(s.dataId).values, { selectedIndices: l } = ZX(u, c, a, i, p);
- return t10.makeTensorInfo([l.length], "int32", new Int32Array(l));
+ let u = t6.data.get(n.dataId).values, c = t6.data.get(s.dataId).values, { selectedIndices: l } = CX(u, c, a, i, p);
+ return t6.makeTensorInfo([l.length], "int32", new Int32Array(l));
}
-var H_ = { kernelName: On, backendName: "cpu", kernelFunc: JX };
-var e5 = Bt.nonMaxSuppressionV4Impl;
-function t5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p, padToMaxOutputSize: u } = o;
+var C_ = { kernelName: Tn, backendName: "cpu", kernelFunc: SX };
+var wX = Lt.nonMaxSuppressionV4Impl;
+function IX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p, padToMaxOutputSize: u } = o;
K(n, "NonMaxSuppressionPadded");
- let c = t10.data.get(n.dataId).values, l = t10.data.get(s.dataId).values, { selectedIndices: m, validOutputs: f } = e5(c, l, a, i, p, u);
- return [t10.makeTensorInfo([m.length], "int32", new Int32Array(m)), t10.makeTensorInfo([], "int32", new Int32Array([f]))];
+ let c = t6.data.get(n.dataId).values, l = t6.data.get(s.dataId).values, { selectedIndices: m, validOutputs: d } = wX(c, l, a, i, p, u);
+ return [t6.makeTensorInfo([m.length], "int32", new Int32Array(m)), t6.makeTensorInfo([], "int32", new Int32Array([d]))];
}
-var q_ = { kernelName: pa, backendName: "cpu", kernelFunc: t5 };
-var r5 = Bt.nonMaxSuppressionV5Impl;
-function o5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p, softNmsSigma: u } = o;
+var S_ = { kernelName: ba, backendName: "cpu", kernelFunc: IX };
+var vX = Lt.nonMaxSuppressionV5Impl;
+function kX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p, softNmsSigma: u } = o;
K(n, "NonMaxSuppressionWithScore");
- let c = t10.data.get(n.dataId).values, l = t10.data.get(s.dataId).values, m = a, f = i, d = p, h = u, { selectedIndices: g, selectedScores: y } = r5(c, l, m, f, d, h);
- return [t10.makeTensorInfo([g.length], "int32", new Int32Array(g)), t10.makeTensorInfo([y.length], "float32", new Float32Array(y))];
+ let c = t6.data.get(n.dataId).values, l = t6.data.get(s.dataId).values, m = a, d = i, f = p, h = u, { selectedIndices: g, selectedScores: x } = vX(c, l, m, d, f, h);
+ return [t6.makeTensorInfo([g.length], "int32", new Int32Array(g)), t6.makeTensorInfo([x.length], "float32", new Float32Array(x))];
}
-var K_ = { kernelName: Mn, backendName: "cpu", kernelFunc: o5 };
-function n5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { indices: n } = e, { dtype: s, depth: a, onValue: i, offValue: p } = o;
+var w_ = { kernelName: _n, backendName: "cpu", kernelFunc: kX };
+function NX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { indices: n } = e, { dtype: s, depth: a, onValue: i, offValue: p } = o;
K(n, "oneHot");
- let u = x.sizeFromShape(n.shape), c = new Float32Array(u * a);
+ let u = y.sizeFromShape(n.shape), c = new Float32Array(u * a);
c.fill(p);
- let l = t10.data.get(n.dataId).values;
+ let l = t6.data.get(n.dataId).values;
for (let m = 0; m < u; ++m)
l[m] >= 0 && l[m] < a && (c[m * a + l[m]] = i);
- return t10.makeTensorInfo([...n.shape, a], s, c);
+ return t6.makeTensorInfo([...n.shape, a], s, c);
}
-var j_ = { kernelName: ca, backendName: "cpu", kernelFunc: n5 };
-function Tl(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
+var I_ = { kernelName: En, backendName: "cpu", kernelFunc: NX };
+function yl(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e;
if (o.dtype === "string")
throw new Error("zerosLike is not supported for string tensors");
if (o.dtype === "complex64") {
- let n = Wo({ inputs: { input: o }, backend: t10 }), s = Tl({ inputs: { x: n }, backend: t10 }), a = qs({ inputs: { input: o }, backend: t10 }), i = Tl({ inputs: { x: a }, backend: t10 }), p = qt({ inputs: { real: s, imag: i }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(n), t10.disposeIntermediateTensorInfo(s), t10.disposeIntermediateTensorInfo(a), t10.disposeIntermediateTensorInfo(i), p;
+ let n = wo({ inputs: { input: o }, backend: t6 }), s = yl({ inputs: { x: n }, backend: t6 }), a = Xs({ inputs: { input: o }, backend: t6 }), i = yl({ inputs: { x: a }, backend: t6 }), p = Ht({ inputs: { real: s, imag: i }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(n), t6.disposeIntermediateTensorInfo(s), t6.disposeIntermediateTensorInfo(a), t6.disposeIntermediateTensorInfo(i), p;
} else
- return kl({ backend: t10, attrs: { shape: o.shape, value: 0, dtype: o.dtype } });
+ return xl({ backend: t6, attrs: { shape: o.shape, value: 0, dtype: o.dtype } });
}
-var X_ = { kernelName: Es, backendName: "cpu", kernelFunc: Tl };
-function Y_(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
+var v_ = { kernelName: Fs, backendName: "cpu", kernelFunc: yl };
+function k_(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e;
if (o.dtype === "string")
throw new Error("onesLike is not supported for string tensors");
if (o.dtype === "complex64") {
- let n = Wo({ inputs: { input: o }, backend: t10 }), s = Y_({ inputs: { x: n }, backend: t10 }), a = qs({ inputs: { input: o }, backend: t10 }), i = Tl({ inputs: { x: a }, backend: t10 }), p = qt({ inputs: { real: s, imag: i }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(n), t10.disposeIntermediateTensorInfo(s), t10.disposeIntermediateTensorInfo(a), t10.disposeIntermediateTensorInfo(i), p;
+ let n = wo({ inputs: { input: o }, backend: t6 }), s = k_({ inputs: { x: n }, backend: t6 }), a = Xs({ inputs: { input: o }, backend: t6 }), i = yl({ inputs: { x: a }, backend: t6 }), p = Ht({ inputs: { real: s, imag: i }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(n), t6.disposeIntermediateTensorInfo(s), t6.disposeIntermediateTensorInfo(a), t6.disposeIntermediateTensorInfo(i), p;
} else
- return kl({ backend: t10, attrs: { shape: o.shape, value: 1, dtype: o.dtype } });
+ return xl({ backend: t6, attrs: { shape: o.shape, value: 1, dtype: o.dtype } });
}
-var Q_ = { kernelName: Cs, backendName: "cpu", kernelFunc: Y_ };
-function OI(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { axis: n } = o;
+var N_ = { kernelName: Is, backendName: "cpu", kernelFunc: k_ };
+function AS(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { axis: n } = o;
if (e.length === 1)
- return oc({ inputs: { input: e[0] }, backend: t10, attrs: { dim: n } });
+ return Jp({ inputs: { input: e[0] }, backend: t6, attrs: { dim: n } });
let s = e[0].shape, a = e[0].dtype;
e.forEach((c) => {
- x.assertShapesMatch(s, c.shape, "All tensors passed to stack must have matching shapes"), x.assert(a === c.dtype, () => "All tensors passed to stack must have matching dtypes");
+ y.assertShapesMatch(s, c.shape, "All tensors passed to stack must have matching shapes"), y.assert(a === c.dtype, () => "All tensors passed to stack must have matching dtypes");
});
let i = [], p = e.map((c) => {
- let l = oc({ inputs: { input: c }, backend: t10, attrs: { dim: n } });
+ let l = Jp({ inputs: { input: c }, backend: t6, attrs: { dim: n } });
return i.push(l), l;
- }), u = vi({ inputs: p, backend: t10, attrs: { axis: n } });
- return i.forEach((c) => t10.disposeIntermediateTensorInfo(c)), u;
+ }), u = Pi({ inputs: p, backend: t6, attrs: { axis: n } });
+ return i.forEach((c) => t6.disposeIntermediateTensorInfo(c)), u;
}
-var Z_ = { kernelName: Is, backendName: "cpu", kernelFunc: OI };
-function s5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { paddings: s, constantValue: a } = o;
+var T_ = { kernelName: vs, backendName: "cpu", kernelFunc: AS };
+function TX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { paddings: s, constantValue: a } = o;
K(n, "pad");
- let i = s.map((b, C) => b[0] + n.shape[C] + b[1]), p = s.map((b) => b[0]), u = t10.data.get(n.dataId).values, c = x.sizeFromShape(n.shape), l = n.shape.length, m = x.computeStrides(n.shape), f = x.sizeFromShape(i), d = i.length, h = x.computeStrides(i), g = x.getTypedArrayFromDType(n.dtype, f);
+ let i = s.map((b, C) => b[0] + n.shape[C] + b[1]), p = s.map((b) => b[0]), u = t6.data.get(n.dataId).values, c = y.sizeFromShape(n.shape), l = n.shape.length, m = y.computeStrides(n.shape), d = y.sizeFromShape(i), f = i.length, h = y.computeStrides(i), g = y.getTypedArrayFromDType(n.dtype, d);
a !== 0 && g.fill(a);
for (let b = 0; b < c; b++) {
- let w = x.indexToLoc(b, l, m).map((_, E) => _ + p[E]), k = x.locToIndex(w, d, h);
+ let w = y.indexToLoc(b, l, m).map((_, $) => _ + p[$]), k = y.locToIndex(w, f, h);
g[k] = u[b];
}
- return { dataId: t10.write(g, i, n.dtype), shape: i, dtype: n.dtype };
+ return { dataId: t6.write(g, i, n.dtype), shape: i, dtype: n.dtype };
}
-var Od = { kernelName: Ln, backendName: "cpu", kernelFunc: s5 };
-var a5 = Le((r, e) => Math.pow(r, e));
-var i5 = Ye(Bn, a5);
-var J_ = { kernelName: Bn, backendName: "cpu", kernelFunc: i5 };
-function u5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { paramsNestedSplits: n, paramsDenseValues: s, indices: a } = e, { outputRaggedRank: i } = o, p = n.map((y) => t10.data.get(y.dataId).values), u = n.map((y) => y.shape), c = t10.data.get(s.dataId).values, l = t10.data.get(a.dataId).values, [m, f, d] = Sd(p, u, c, s.shape, s.dtype, l, a.shape, i), h = m.map((y) => t10.makeTensorInfo([y.length], "int32", y)), g = t10.makeTensorInfo(d, s.dtype, f);
+var kf = { kernelName: $n, backendName: "cpu", kernelFunc: TX };
+var _X = Be((r, e) => Math.pow(r, e));
+var EX = Qe(An, _X);
+var __ = { kernelName: An, backendName: "cpu", kernelFunc: EX };
+function $X(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { paramsNestedSplits: n, paramsDenseValues: s, indices: a } = e, { outputRaggedRank: i } = o, p = n.map((x) => t6.data.get(x.dataId).values), u = n.map((x) => x.shape), c = t6.data.get(s.dataId).values, l = t6.data.get(a.dataId).values, [m, d, f] = df(p, u, c, s.shape, s.dtype, l, a.shape, i), h = m.map((x) => t6.makeTensorInfo([x.length], "int32", x)), g = t6.makeTensorInfo(f, s.dtype, d);
return h.concat([g]);
}
-var eE = { kernelName: Tp, backendName: "cpu", kernelFunc: u5 };
-function p5(r) {
- let { inputs: e, backend: t10 } = r, { starts: o, limits: n, deltas: s } = e, a = t10.data.get(o.dataId).values, i = t10.data.get(n.dataId).values, p = t10.data.get(s.dataId).values, [u, c] = vd(a, o.shape, o.dtype, i, n.shape, p, s.shape), l = t10.makeTensorInfo([u.length], "int32", u), m = t10.makeTensorInfo([c.length], o.dtype, c);
+var E_ = { kernelName: wp, backendName: "cpu", kernelFunc: $X };
+function AX(r) {
+ let { inputs: e, backend: t6 } = r, { starts: o, limits: n, deltas: s } = e, a = t6.data.get(o.dataId).values, i = t6.data.get(n.dataId).values, p = t6.data.get(s.dataId).values, [u, c] = ff(a, o.shape, o.dtype, i, n.shape, p, s.shape), l = t6.makeTensorInfo([u.length], "int32", u), m = t6.makeTensorInfo([c.length], o.dtype, c);
return [l, m];
}
-var tE = { kernelName: Np, backendName: "cpu", kernelFunc: p5 };
-function c5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { shape: n, values: s, defaultValue: a, rowPartitionTensors: i } = e, { rowPartitionTypes: p } = o, u = t10.data.get(n.dataId).values, c = t10.data.get(s.dataId).values, l = t10.data.get(a.dataId).values, m = i.map((g) => t10.data.get(g.dataId).values), f = i.map((g) => g.shape), [d, h] = kd(u, n.shape, c, s.shape, s.dtype, l, a.shape, m, f, p);
- return t10.makeTensorInfo(d, s.dtype, h);
+var $_ = { kernelName: Ip, backendName: "cpu", kernelFunc: AX };
+function RX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { shape: n, values: s, defaultValue: a, rowPartitionTensors: i } = e, { rowPartitionTypes: p } = o, u = t6.data.get(n.dataId).values, c = t6.data.get(s.dataId).values, l = t6.data.get(a.dataId).values, m = i.map((g) => t6.data.get(g.dataId).values), d = i.map((g) => g.shape), [f, h] = hf(u, n.shape, c, s.shape, s.dtype, l, a.shape, m, d, p);
+ return t6.makeTensorInfo(f, s.dtype, h);
}
-var rE = { kernelName: _p, backendName: "cpu", kernelFunc: c5 };
-function l5(r) {
- let { backend: e, attrs: t10 } = r, { start: o, stop: n, dtype: s, step: a } = t10, i = Su(o, n, a, s);
+var A_ = { kernelName: vp, backendName: "cpu", kernelFunc: RX };
+function FX(r) {
+ let { backend: e, attrs: t6 } = r, { start: o, stop: n, dtype: s, step: a } = t6, i = Iu(o, n, a, s);
return e.makeTensorInfo([i.length], s, i);
}
-var oE = { kernelName: ws, backendName: "cpu", kernelFunc: l5 };
-var m5 = we(ma, (r) => 1 / r);
-var nE = { kernelName: ma, backendName: "cpu", kernelFunc: m5 };
-function f5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { images: n } = e, { alignCorners: s, halfPixelCenters: a, size: i } = o;
+var R_ = { kernelName: ks, backendName: "cpu", kernelFunc: FX };
+var DX = Ie(Dn, (r) => 1 / r);
+var F_ = { kernelName: Dn, backendName: "cpu", kernelFunc: DX };
+function OX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { images: n } = e, { alignCorners: s, halfPixelCenters: a, size: i } = o;
K(n, "resizeBilinear");
- let p = x.computeStrides(n.shape), [u, c] = i, [l, m, f, d] = n.shape, h = t10.data.get(n.dataId).values, g = new Float32Array(x.sizeFromShape([l, u, c, d])), y = [s && u > 1 ? m - 1 : m, s && c > 1 ? f - 1 : f], b = [s && u > 1 ? u - 1 : u, s && c > 1 ? c - 1 : c], C = 0, w = y[0] / b[0], k = y[1] / b[1];
+ let p = y.computeStrides(n.shape), [u, c] = i, [l, m, d, f] = n.shape, h = t6.data.get(n.dataId).values, g = new Float32Array(y.sizeFromShape([l, u, c, f])), x = [s && u > 1 ? m - 1 : m, s && c > 1 ? d - 1 : d], b = [s && u > 1 ? u - 1 : u, s && c > 1 ? c - 1 : c], C = 0, w = x[0] / b[0], k = x[1] / b[1];
for (let _ = 0; _ < l; _++)
- for (let E = 0; E < u; E++) {
- let R;
- a ? R = w * (E + 0.5) - 0.5 : R = w * E;
- let A = Math.max(0, Math.floor(R)), D = R - A, O = Math.min(m - 1, Math.ceil(R)), M = _ * p[0] + A * p[1], L = _ * p[0] + O * p[1];
+ for (let $ = 0; $ < u; $++) {
+ let A;
+ a ? A = w * ($ + 0.5) - 0.5 : A = w * $;
+ let R = Math.max(0, Math.floor(A)), D = A - R, P = Math.min(m - 1, Math.ceil(A)), M = _ * p[0] + R * p[1], L = _ * p[0] + P * p[1];
for (let W = 0; W < c; W++) {
let V;
a ? V = k * (W + 0.5) - 0.5 : V = k * W;
- let G = Math.max(0, Math.floor(V)), q = V - G, H = Math.min(f - 1, Math.ceil(V)), j = M + G * p[2], Y = L + G * p[2], Z = M + H * p[2], ee = L + H * p[2];
- for (let X = 0; X < d; X++) {
- let Q = h[j + X], se = h[Y + X], ie = h[Z + X], de = h[ee + X], Ie = Q + (ie - Q) * q, Se = se + (de - se) * q, Ee = Ie + (Se - Ie) * D;
- g[C++] = Ee;
+ let U = Math.max(0, Math.floor(V)), q = V - U, H = Math.min(d - 1, Math.ceil(V)), j = M + U * p[2], X = L + U * p[2], Z = M + H * p[2], ee = L + H * p[2];
+ for (let Y = 0; Y < f; Y++) {
+ let J = h[j + Y], ie = h[X + Y], pe = h[Z + Y], he = h[ee + Y], we = J + (pe - J) * q, ve = ie + (he - ie) * q, $e = we + (ve - we) * D;
+ g[C++] = $e;
}
}
}
- return t10.makeTensorInfo([l, u, c, d], "float32", g);
+ return t6.makeTensorInfo([l, u, c, f], "float32", g);
}
-var sE = { kernelName: Un, backendName: "cpu", kernelFunc: f5 };
-function d5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { images: n, dy: s } = e, { alignCorners: a } = o;
+var D_ = { kernelName: Mn, backendName: "cpu", kernelFunc: OX };
+function PX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { images: n, dy: s } = e, { alignCorners: a } = o;
K([s, n], "resizeBilinearGrad");
- let i = x.computeStrides(n.shape), [p, u, c, l] = n.shape, [, m, f] = s.shape, d = new Float32Array(p * u * c * l), h = [a && m > 1 ? u - 1 : u, a && f > 1 ? c - 1 : c], g = [a && m > 1 ? m - 1 : m, a && f > 1 ? f - 1 : f], y = h[0] / g[0], b = h[1] / g[1], C = t10.data.get(s.dataId).values, w = 0;
+ let i = y.computeStrides(n.shape), [p, u, c, l] = n.shape, [, m, d] = s.shape, f = new Float32Array(p * u * c * l), h = [a && m > 1 ? u - 1 : u, a && d > 1 ? c - 1 : c], g = [a && m > 1 ? m - 1 : m, a && d > 1 ? d - 1 : d], x = h[0] / g[0], b = h[1] / g[1], C = t6.data.get(s.dataId).values, w = 0;
for (let k = 0; k < p; k++) {
let _ = k * i[0];
- for (let E = 0; E < m; E++) {
- let R = E * y, A = Math.floor(R), D = Math.min(Math.ceil(R), u - 1), O = _ + A * i[1], M = _ + D * i[1], L = R - A, W = 1 - L;
- for (let V = 0; V < f; V++) {
- let G = V * b, q = Math.floor(G), H = Math.min(Math.ceil(G), c - 1), j = G - q, Y = 1 - j, Z = O + q * i[2], ee = O + H * i[2], X = M + q * i[2], Q = M + H * i[2], se = W * Y, ie = W * j, de = L * Y, Ie = L * j;
- for (let Se = 0; Se < l; Se++) {
- let Ee = C[w++];
- d[Z + Se] += Ee * se, d[ee + Se] += Ee * ie, d[X + Se] += Ee * de, d[Q + Se] += Ee * Ie;
+ for (let $ = 0; $ < m; $++) {
+ let A = $ * x, R = Math.floor(A), D = Math.min(Math.ceil(A), u - 1), P = _ + R * i[1], M = _ + D * i[1], L = A - R, W = 1 - L;
+ for (let V = 0; V < d; V++) {
+ let U = V * b, q = Math.floor(U), H = Math.min(Math.ceil(U), c - 1), j = U - q, X = 1 - j, Z = P + q * i[2], ee = P + H * i[2], Y = M + q * i[2], J = M + H * i[2], ie = W * X, pe = W * j, he = L * X, we = L * j;
+ for (let ve = 0; ve < l; ve++) {
+ let $e = C[w++];
+ f[Z + ve] += $e * ie, f[ee + ve] += $e * pe, f[Y + ve] += $e * he, f[J + ve] += $e * we;
}
}
}
}
- return t10.makeTensorInfo([p, c, u, l], "float32", d);
+ return t6.makeTensorInfo([p, c, u, l], "float32", f);
}
-var aE = { kernelName: Vm, backendName: "cpu", kernelFunc: d5 };
-function h5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { images: n } = e, { alignCorners: s, halfPixelCenters: a, size: i } = o;
+var O_ = { kernelName: $m, backendName: "cpu", kernelFunc: PX };
+function MX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { images: n } = e, { alignCorners: s, halfPixelCenters: a, size: i } = o;
K(n, "resizeNearestNeighbor");
- let p = x.computeStrides(n.shape), [u, c] = i, [l, m, f, d] = n.shape, h = t10.data.get(n.dataId).values, g = new Float32Array(l * u * c * d), y = [s && u > 1 ? m - 1 : m, s && c > 1 ? f - 1 : f], b = [s && u > 1 ? u - 1 : u, s && c > 1 ? c - 1 : c], C = y[0] / b[0], w = y[1] / b[1], k = 0;
+ let p = y.computeStrides(n.shape), [u, c] = i, [l, m, d, f] = n.shape, h = t6.data.get(n.dataId).values, g = new Float32Array(l * u * c * f), x = [s && u > 1 ? m - 1 : m, s && c > 1 ? d - 1 : d], b = [s && u > 1 ? u - 1 : u, s && c > 1 ? c - 1 : c], C = x[0] / b[0], w = x[1] / b[1], k = 0;
for (let _ = 0; _ < l; _++) {
- let E = _ * p[0];
- for (let R = 0; R < u; R++) {
- let A = a ? C * (R + 0.5) : C * R, D = Math.min(m - 1, s ? Math.round(A) : Math.floor(A));
+ let $ = _ * p[0];
+ for (let A = 0; A < u; A++) {
+ let R = a ? C * (A + 0.5) : C * A, D = Math.min(m - 1, s ? Math.round(R) : Math.floor(R));
a && (D = Math.max(0, D));
- let O = E + D * p[1];
+ let P = $ + D * p[1];
for (let M = 0; M < c; M++) {
- let L = a ? w * (M + 0.5) : w * M, W = Math.min(f - 1, s ? Math.round(L) : Math.floor(L));
+ let L = a ? w * (M + 0.5) : w * M, W = Math.min(d - 1, s ? Math.round(L) : Math.floor(L));
a && (W = Math.max(0, W));
- let V = O + W * p[2];
- for (let G = 0; G < d; G++) {
- let q = h[V + G];
+ let V = P + W * p[2];
+ for (let U = 0; U < f; U++) {
+ let q = h[V + U];
g[k++] = q;
}
}
}
}
- return t10.makeTensorInfo([l, u, c, d], n.dtype, g);
+ return t6.makeTensorInfo([l, u, c, f], n.dtype, g);
}
-var iE = { kernelName: Wn, backendName: "cpu", kernelFunc: h5 };
-function g5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { images: n, dy: s } = e, { alignCorners: a } = o;
+var P_ = { kernelName: Pn, backendName: "cpu", kernelFunc: MX };
+function LX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { images: n, dy: s } = e, { alignCorners: a } = o;
K([s, n], "resizeNearestNeighborGrad");
- let i = x.computeStrides(n.shape), p = x.computeStrides(s.shape), [u, c, l, m] = n.shape, [, f, d] = s.shape, h = new Float32Array(u * c * l * m), g = t10.data.get(s.dataId).values, y = [a && f > 1 ? c - 1 : c, a && d > 1 ? l - 1 : l], b = [a && f > 1 ? f - 1 : f, a && d > 1 ? d - 1 : d], C = y[0] / b[0], w = y[1] / b[1], k = 1 / C, _ = 1 / w, E = Math.ceil(k) * 2 + 2, R = Math.ceil(_) * 2 + 2;
- for (let A = 0; A < u; A++) {
- let D = A * i[0];
- for (let O = 0; O < c; O++) {
- let M = D + O * i[1], L = Math.floor(O * k), W = Math.floor(L - E / 2);
+ let i = y.computeStrides(n.shape), p = y.computeStrides(s.shape), [u, c, l, m] = n.shape, [, d, f] = s.shape, h = new Float32Array(u * c * l * m), g = t6.data.get(s.dataId).values, x = [a && d > 1 ? c - 1 : c, a && f > 1 ? l - 1 : l], b = [a && d > 1 ? d - 1 : d, a && f > 1 ? f - 1 : f], C = x[0] / b[0], w = x[1] / b[1], k = 1 / C, _ = 1 / w, $ = Math.ceil(k) * 2 + 2, A = Math.ceil(_) * 2 + 2;
+ for (let R = 0; R < u; R++) {
+ let D = R * i[0];
+ for (let P = 0; P < c; P++) {
+ let M = D + P * i[1], L = Math.floor(P * k), W = Math.floor(L - $ / 2);
for (let V = 0; V < l; V++) {
- let G = M + V * i[2], q = Math.floor(V * _), H = Math.floor(q - R / 2);
+ let U = M + V * i[2], q = Math.floor(V * _), H = Math.floor(q - A / 2);
for (let j = 0; j < m; j++) {
- let Y = 0;
- for (let Z = 0; Z < E; Z++) {
+ let X = 0;
+ for (let Z = 0; Z < $; Z++) {
let ee = Z + W;
- if (ee < 0 || ee >= f)
+ if (ee < 0 || ee >= d)
continue;
- let X = D + ee * p[1], Q = ee * C, se = Math.min(c - 1, a ? Math.round(Q) : Math.floor(Q));
- if (O === se)
- for (let ie = 0; ie < R; ie++) {
- let de = ie + H;
- if (de < 0 || de >= d)
+ let Y = D + ee * p[1], J = ee * C, ie = Math.min(c - 1, a ? Math.round(J) : Math.floor(J));
+ if (P === ie)
+ for (let pe = 0; pe < A; pe++) {
+ let he = pe + H;
+ if (he < 0 || he >= f)
continue;
- let Ie = X + de * p[2], Se = de * w, Ee = Math.min(l - 1, a ? Math.round(Se) : Math.floor(Se));
- V === Ee && (Y += g[Ie + j]);
+ let we = Y + he * p[2], ve = he * w, $e = Math.min(l - 1, a ? Math.round(ve) : Math.floor(ve));
+ V === $e && (X += g[we + j]);
}
}
- h[G + j] = Y;
+ h[U + j] = X;
}
}
}
}
- return t10.makeTensorInfo(n.shape, n.dtype, h);
+ return t6.makeTensorInfo(n.shape, n.dtype, h);
}
-var uE = { kernelName: Bm, backendName: "cpu", kernelFunc: g5 };
-function x5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { dims: s } = o;
+var M_ = { kernelName: Em, backendName: "cpu", kernelFunc: LX };
+function BX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { dims: s } = o;
K(n, "reverse");
- let a = n.shape.length, i = x.parseAxisParam(s, n.shape);
+ let a = n.shape.length, i = y.parseAxisParam(s, n.shape);
if (a === 0)
- return ar({ inputs: { x: n }, backend: t10 });
- let p = new je(n.shape, n.dtype), u = t10.bufferSync(n);
+ return ar({ inputs: { x: n }, backend: t6 });
+ let p = new st(n.shape, n.dtype), u = t6.bufferSync(n);
for (let c = 0; c < p.size; c++) {
let l = p.indexToLoc(c), m = l.slice();
- i.forEach((f) => m[f] = n.shape[f] - 1 - m[f]), p.set(u.get(...m), ...l);
+ i.forEach((d) => m[d] = n.shape[d] - 1 - m[d]), p.set(u.get(...m), ...l);
}
- return t10.makeTensorInfo(p.shape, p.dtype, p.values);
+ return t6.makeTensorInfo(p.shape, p.dtype, p.values);
}
-var pE = { kernelName: fa, backendName: "cpu", kernelFunc: x5 };
-var cE = { kernelName: es, backendName: "cpu", kernelFunc: ({ inputs: r, attrs: e, backend: t10 }) => {
- let { image: o } = r, { radians: n, fillValue: s, center: a } = e, i = t10, p = x.getTypedArrayFromDType(o.dtype, x.sizeFromShape(o.shape)), [u, c, l, m] = o.shape, [f, d] = I.getImageCenter(a, c, l), h = 255, g = Math.sin(n), y = Math.cos(n), b = i.data.get(o.dataId).values;
+var L_ = { kernelName: Bn, backendName: "cpu", kernelFunc: BX };
+var B_ = { kernelName: es, backendName: "cpu", kernelFunc: ({ inputs: r, attrs: e, backend: t6 }) => {
+ let { image: o } = r, { radians: n, fillValue: s, center: a } = e, i = t6, p = y.getTypedArrayFromDType(o.dtype, y.sizeFromShape(o.shape)), [u, c, l, m] = o.shape, [d, f] = S.getImageCenter(a, c, l), h = 255, g = Math.sin(n), x = Math.cos(n), b = i.data.get(o.dataId).values;
for (let w = 0; w < u; w++) {
let k = w * l * c * m;
for (let _ = 0; _ < c; _++) {
- let E = _ * (l * m);
- for (let R = 0; R < l; R++) {
- let A = R * m;
+ let $ = _ * (l * m);
+ for (let A = 0; A < l; A++) {
+ let R = A * m;
for (let D = 0; D < m; D++) {
- let O = [u, _, R, D], M = O[2], L = O[1], W = (M - f) * y - (L - d) * g, V = (M - f) * g + (L - d) * y;
- W = Math.round(W + f), V = Math.round(V + d);
- let G = s;
- if (typeof s != "number" && (D === 3 ? G = h : G = s[D]), W >= 0 && W < l && V >= 0 && V < c) {
- let H = V * (l * m), j = W * m, Y = k + H + j + D;
- G = b[Y];
+ let P = [u, _, A, D], M = P[2], L = P[1], W = (M - d) * x - (L - f) * g, V = (M - d) * g + (L - f) * x;
+ W = Math.round(W + d), V = Math.round(V + f);
+ let U = s;
+ if (typeof s != "number" && (D === 3 ? U = h : U = s[D]), W >= 0 && W < l && V >= 0 && V < c) {
+ let H = V * (l * m), j = W * m, X = k + H + j + D;
+ U = b[X];
}
- let q = k + E + A + D;
- p[q] = G;
+ let q = k + $ + R + D;
+ p[q] = U;
}
}
}
}
return { dataId: i.write(p, o.shape, o.dtype), shape: o.shape, dtype: o.dtype };
} };
-var y5 = we(da, (r) => {
+var VX = Ie(Ca, (r) => {
let e = Math.floor(r);
return r - e < 0.5 ? Math.floor(r) : r - e > 0.5 ? Math.ceil(r) : e % 2 === 0 ? e : e + 1;
});
-var lE = { kernelName: da, backendName: "cpu", kernelFunc: y5 };
-function b5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { indices: n, updates: s } = e, { shape: a } = o, { sliceRank: i, numUpdates: p, sliceSize: u, strides: c, outputSize: l } = I.calculateShapes(s, n, a), m = true, f = t10.bufferSync(n), d = t10.bufferSync(s), h = Aa(f, d, a, l, u, p, i, c, 0, m);
- return t10.makeTensorInfo(a, h.dtype, h.values);
+var V_ = { kernelName: Ca, backendName: "cpu", kernelFunc: VX };
+function zX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { indices: n, updates: s } = e, { shape: a } = o, { sliceRank: i, numUpdates: p, sliceSize: u, strides: c, outputSize: l } = S.calculateShapes(s, n, a), m = true, d = t6.bufferSync(n), f = t6.bufferSync(s), h = Ma(d, f, a, l, u, p, i, c, 0, m);
+ return t6.makeTensorInfo(a, h.dtype, h.values);
}
-var mE = { kernelName: Hn, backendName: "cpu", kernelFunc: b5 };
-function C5(r, e) {
- let t10 = 0, o = r.length, n = 0;
- for (; t10 < o; )
- n = Math.floor((t10 + o) / 2), r[n] < e ? t10 = n + 1 : o = n;
+var z_ = { kernelName: zn, backendName: "cpu", kernelFunc: zX };
+function WX(r, e) {
+ let t6 = 0, o = r.length, n = 0;
+ for (; t6 < o; )
+ n = Math.floor((t6 + o) / 2), r[n] < e ? t6 = n + 1 : o = n;
return o;
}
-function I5(r, e) {
- let t10 = 0, o = r.length, n = 0;
- for (; t10 < o; )
- n = Math.floor((t10 + o) / 2), r[n] <= e ? t10 = n + 1 : o = n;
+function UX(r, e) {
+ let t6 = 0, o = r.length, n = 0;
+ for (; t6 < o; )
+ n = Math.floor((t6 + o) / 2), r[n] <= e ? t6 = n + 1 : o = n;
return o;
}
-function fE(r, e, t10, o, n, s) {
- let a = x.getArrayFromDType("int32", t10 * n);
- for (let i = 0; i < t10; ++i) {
+function W_(r, e, t6, o, n, s) {
+ let a = y.getArrayFromDType("int32", t6 * n);
+ for (let i = 0; i < t6; ++i) {
let p = r.slice(i * o, (i + 1) * o), u = i * n;
for (let c = 0; c < n; ++c)
- a[u + c] = s === "left" ? C5(p, e[c + u]) : I5(p, e[c + u]);
+ a[u + c] = s === "left" ? WX(p, e[c + u]) : UX(p, e[c + u]);
}
return a;
}
-function w5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { sortedSequence: n, values: s } = e, { side: a } = o, i = t10.data.get(n.dataId).values, p = t10.data.get(s.dataId).values, u = fE(i, p, n.shape[0], n.shape[1], s.shape[1], a);
- return t10.makeTensorInfo(s.shape, "int32", u);
+function GX(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { sortedSequence: n, values: s } = e, { side: a } = o, i = t6.data.get(n.dataId).values, p = t6.data.get(s.dataId).values, u = W_(i, p, n.shape[0], n.shape[1], s.shape[1], a);
+ return t6.makeTensorInfo(s.shape, "int32", u);
}
-var dE = { kernelName: Ep, backendName: "cpu", kernelFunc: w5 };
-function S5(r) {
- let { inputs: e, backend: t10 } = r, { condition: o, t: n, e: s } = e;
+var U_ = { kernelName: ii, backendName: "cpu", kernelFunc: GX };
+function HX(r) {
+ let { inputs: e, backend: t6 } = r, { condition: o, t: n, e: s } = e;
K([o, n, s], "select");
- let a = o.shape.length, i = t10.data.get(o.dataId).values, p = t10.data.get(n.dataId).values, u = t10.data.get(s.dataId).values, c = ct(n.dtype, s.dtype), l = x.makeZerosTypedArray(x.sizeFromShape(n.shape), c), m = 0, f = a === 0 || a > 1 || n.shape.length === 1 ? 1 : x.sizeFromShape(n.shape.slice(1));
- for (let d = 0; d < i.length; d++)
- for (let h = 0; h < f; h++)
- i[d] === 1 ? l[m++] = p[d] : l[m++] = u[d];
- return t10.makeTensorInfo(n.shape, c, l);
+ let a = o.shape.length, i = t6.data.get(o.dataId).values, p = t6.data.get(n.dataId).values, u = t6.data.get(s.dataId).values, c = dt(n.dtype, s.dtype), l = y.makeZerosTypedArray(y.sizeFromShape(n.shape), c), m = 0, d = a === 0 || a > 1 || n.shape.length === 1 ? 1 : y.sizeFromShape(n.shape.slice(1));
+ for (let f = 0; f < i.length; f++)
+ for (let h = 0; h < d; h++)
+ i[f] === 1 ? l[m++] = p[f] : l[m++] = u[f];
+ return t6.makeTensorInfo(n.shape, c, l);
}
-var hE = { kernelName: vs, backendName: "cpu", kernelFunc: S5 };
-var v5 = I.SELU_SCALEALPHA;
-var k5 = I.SELU_SCALE;
-var T5 = we(Xi, (r) => r >= 0 ? k5 * r : v5 * (Math.exp(r) - 1));
-var gE = { kernelName: Xi, backendName: "cpu", kernelFunc: T5 };
-var N5 = we(Yi, (r) => r < 0 ? -1 : r > 0 ? 1 : 0);
-var xE = { kernelName: Yi, backendName: "cpu", kernelFunc: N5 };
-var _5 = we(Kn, (r) => Math.sin(r));
-var yE = { kernelName: Kn, backendName: "cpu", kernelFunc: _5 };
-var E5 = we(ha, (r) => Math.sinh(r));
-var bE = { kernelName: ha, backendName: "cpu", kernelFunc: E5 };
-var $5 = 11920928955078125e-23;
-var CE = Math.log($5) + 2;
-var R5 = we(Qi, (r) => {
- let e = r > -CE, t10 = r < CE, o = Math.exp(r), n;
- return t10 ? n = o : e ? n = r : n = Math.log(1 + o), n;
+var G_ = { kernelName: Ts, backendName: "cpu", kernelFunc: HX };
+var qX = S.SELU_SCALEALPHA;
+var KX = S.SELU_SCALE;
+var jX = Ie(Xi, (r) => r >= 0 ? KX * r : qX * (Math.exp(r) - 1));
+var H_ = { kernelName: Xi, backendName: "cpu", kernelFunc: jX };
+var XX = Ie(Yi, (r) => r < 0 ? -1 : r > 0 ? 1 : 0);
+var q_ = { kernelName: Yi, backendName: "cpu", kernelFunc: XX };
+var YX = Ie(Wn, (r) => Math.sin(r));
+var K_ = { kernelName: Wn, backendName: "cpu", kernelFunc: YX };
+var QX = Ie(Sa, (r) => Math.sinh(r));
+var j_ = { kernelName: Sa, backendName: "cpu", kernelFunc: QX };
+var ZX = 11920928955078125e-23;
+var X_ = Math.log(ZX) + 2;
+var JX = Ie(Qi, (r) => {
+ let e = r > -X_, t6 = r < X_, o = Math.exp(r), n;
+ return t6 ? n = o : e ? n = r : n = Math.log(1 + o), n;
});
-var IE = { kernelName: Qi, backendName: "cpu", kernelFunc: R5 };
-function A5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { blockShape: s, paddings: a } = o;
+var Y_ = { kernelName: Qi, backendName: "cpu", kernelFunc: JX };
+function e5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { blockShape: s, paddings: a } = o;
K([n], "spaceToBatchND");
- let i = x.sizeFromShape(s), p = [[0, 0]];
+ let i = y.sizeFromShape(s), p = [[0, 0]];
p.push(...a);
for (let _ = 1 + s.length; _ < n.shape.length; ++_)
p.push([0, 0]);
- let u = Od.kernelFunc({ inputs: { x: n }, backend: t10, attrs: { paddings: p, constantValue: 0 } }), c = I.getReshaped(u.shape, s, i, false), l = I.getPermuted(c.length, s.length, false), m = I.getReshapedPermuted(u.shape, s, i, false), h = Oe({ inputs: { x: u }, backend: t10, attrs: { shape: c } }), b = bt({ inputs: { x: h }, backend: t10, attrs: { perm: l } }), k = Oe({ inputs: { x: b }, backend: t10, attrs: { shape: m } });
- return t10.disposeIntermediateTensorInfo(u), t10.disposeIntermediateTensorInfo(h), t10.disposeIntermediateTensorInfo(b), k;
+ let u = kf.kernelFunc({ inputs: { x: n }, backend: t6, attrs: { paddings: p, constantValue: 0 } }), c = S.getReshaped(u.shape, s, i, false), l = S.getPermuted(c.length, s.length, false), m = S.getReshapedPermuted(u.shape, s, i, false), h = Me({ inputs: { x: u }, backend: t6, attrs: { shape: c } }), b = Ct({ inputs: { x: h }, backend: t6, attrs: { perm: l } }), k = Me({ inputs: { x: b }, backend: t6, attrs: { shape: m } });
+ return t6.disposeIntermediateTensorInfo(u), t6.disposeIntermediateTensorInfo(h), t6.disposeIntermediateTensorInfo(b), k;
}
-var wE = { kernelName: ks, backendName: "cpu", kernelFunc: A5 };
-function F5(r) {
- let { inputs: e, backend: t10 } = r, { indices: o, values: n, denseShape: s, defaultValue: a } = e;
+var Q_ = { kernelName: Es, backendName: "cpu", kernelFunc: e5 };
+function t5(r) {
+ let { inputs: e, backend: t6 } = r, { indices: o, values: n, denseShape: s, defaultValue: a } = e;
if (s.shape.length !== 1)
throw new Error(`Dense shape must be a vector, saw:
${s.shape}`);
@@ -14505,12 +14551,12 @@ function F5(r) {
if (a.shape.length !== 0)
throw new Error(`Default value must be a scalar, saw:
${a.shape}`);
- let i = t10.data.get(o.dataId).values, p = t10.data.get(n.dataId).values, u = t10.data.get(s.dataId).values, c = t10.data.get(a.dataId).values[0], [l, m, f, d, h] = Td(i, o.shape, o.dtype, p, n.dtype, u, c);
- return [t10.makeTensorInfo(m, o.dtype, l), t10.makeTensorInfo([m[0]], n.dtype, f), t10.makeTensorInfo([d.length], "bool", new Uint8Array(d.map((g) => Number(g)))), t10.makeTensorInfo([h.length], o.dtype, new Int32Array(h))];
+ let i = t6.data.get(o.dataId).values, p = t6.data.get(n.dataId).values, u = t6.data.get(s.dataId).values, c = t6.data.get(a.dataId).values[0], [l, m, d, f, h] = gf(i, o.shape, o.dtype, p, n.dtype, u, c);
+ return [t6.makeTensorInfo(m, o.dtype, l), t6.makeTensorInfo([m[0]], n.dtype, d), t6.makeTensorInfo([f.length], "bool", new Uint8Array(f.map((g) => Number(g)))), t6.makeTensorInfo([h.length], o.dtype, new Int32Array(h))];
}
-var SE = { kernelName: Qa, backendName: "cpu", kernelFunc: F5 };
-function D5(r) {
- let { inputs: e, backend: t10 } = r, { inputIndices: o, inputShape: n, newShape: s } = e;
+var Z_ = { kernelName: ui, backendName: "cpu", kernelFunc: t5 };
+function r5(r) {
+ let { inputs: e, backend: t6 } = r, { inputIndices: o, inputShape: n, newShape: s } = e;
if (o.shape.length !== 2)
throw new Error(`Input indices should be a matrix but received shape
${o.shape}`);
@@ -14519,12 +14565,12 @@ function D5(r) {
${n.shape}`);
if (s.shape.length !== 1)
throw new Error(`Target shape should be a vector but received shape ${s.shape}`);
- let a = Array.from(t10.data.get(n.dataId).values), i = t10.data.get(o.dataId).values, p = Array.from(t10.data.get(s.dataId).values), [u, c, l] = Nd(i, o.shape, o.dtype, a, p);
- return [t10.makeTensorInfo(c, o.dtype, u), t10.makeTensorInfo([l.length], s.dtype, new Int32Array(l))];
+ let a = Array.from(t6.data.get(n.dataId).values), i = t6.data.get(o.dataId).values, p = Array.from(t6.data.get(s.dataId).values), [u, c, l] = xf(i, o.shape, o.dtype, a, p);
+ return [t6.makeTensorInfo(c, o.dtype, u), t6.makeTensorInfo([l.length], s.dtype, new Int32Array(l))];
}
-var vE = { kernelName: ga, backendName: "cpu", kernelFunc: D5 };
-function P5(r) {
- let { inputs: e, backend: t10 } = r, { data: o, indices: n, segmentIds: s } = e;
+var J_ = { kernelName: wa, backendName: "cpu", kernelFunc: r5 };
+function o5(r) {
+ let { inputs: e, backend: t6 } = r, { data: o, indices: n, segmentIds: s } = e;
if (o.shape.length < 1)
throw new Error("Data should be at least 1 dimensional but received scalar");
if (n.shape.length !== 1)
@@ -14535,12 +14581,12 @@ function P5(r) {
${s.shape}`);
if (n.shape[0] !== s.shape[0])
throw new Error("segmentIds and indices should have same size.");
- let a = t10.data.get(o.dataId).values, i = t10.data.get(n.dataId).values, p = t10.data.get(s.dataId).values, [u, c] = tc(a, o.shape, o.dtype, i, p, true);
- return t10.makeTensorInfo(c, o.dtype, u);
+ let a = t6.data.get(o.dataId).values, i = t6.data.get(n.dataId).values, p = t6.data.get(s.dataId).values, [u, c] = Yp(a, o.shape, o.dtype, i, p, true);
+ return t6.makeTensorInfo(c, o.dtype, u);
}
-var kE = { kernelName: Za, backendName: "cpu", kernelFunc: P5 };
-function O5(r) {
- let { inputs: e, backend: t10 } = r, { data: o, indices: n, segmentIds: s } = e;
+var eE = { kernelName: pi, backendName: "cpu", kernelFunc: o5 };
+function n5(r) {
+ let { inputs: e, backend: t6 } = r, { data: o, indices: n, segmentIds: s } = e;
if (o.shape.length < 1)
throw new Error("Data should be at least 1 dimensional but received scalar");
if (n.shape.length !== 1)
@@ -14551,348 +14597,348 @@ function O5(r) {
${s.shape}`);
if (n.shape[0] !== s.shape[0])
throw new Error("segmentIds and indices should have same size.");
- let a = t10.data.get(o.dataId).values, i = t10.data.get(n.dataId).values, p = t10.data.get(s.dataId).values, [u, c] = tc(a, o.shape, o.dtype, i, p);
- return t10.makeTensorInfo(c, o.dtype, u);
+ let a = t6.data.get(o.dataId).values, i = t6.data.get(n.dataId).values, p = t6.data.get(s.dataId).values, [u, c] = Yp(a, o.shape, o.dtype, i, p);
+ return t6.makeTensorInfo(c, o.dtype, u);
}
-var TE = { kernelName: Ja, backendName: "cpu", kernelFunc: O5 };
-function M5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { sparseIndices: n, sparseValues: s, defaultValue: a } = e, { outputShape: i } = o, { sliceRank: p, numUpdates: u, sliceSize: c, strides: l, outputSize: m } = I.calculateShapes(s, n, i), f = false, d = t10.bufferSync(n), h;
+var tE = { kernelName: ci, backendName: "cpu", kernelFunc: n5 };
+function s5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { sparseIndices: n, sparseValues: s, defaultValue: a } = e, { outputShape: i } = o, { sliceRank: p, numUpdates: u, sliceSize: c, strides: l, outputSize: m } = S.calculateShapes(s, n, i), d = false, f = t6.bufferSync(n), h;
switch (s.dtype) {
case "bool": {
- let g = t10.bufferSync(s), y = Boolean(t10.data.get(a.dataId).values[0]);
- h = Aa(d, g, i, m, c, u, p, l, y, f);
+ let g = t6.bufferSync(s), x = Boolean(t6.data.get(a.dataId).values[0]);
+ h = Ma(f, g, i, m, c, u, p, l, x, d);
break;
}
case "float32": {
- let g = t10.bufferSync(s), y = t10.data.get(a.dataId).values[0];
- h = Aa(d, g, i, m, c, u, p, l, y, f);
+ let g = t6.bufferSync(s), x = t6.data.get(a.dataId).values[0];
+ h = Ma(f, g, i, m, c, u, p, l, x, d);
break;
}
case "int32": {
- let g = t10.bufferSync(s), y = t10.data.get(a.dataId).values[0];
- h = Aa(d, g, i, m, c, u, p, l, y, f);
+ let g = t6.bufferSync(s), x = t6.data.get(a.dataId).values[0];
+ h = Ma(f, g, i, m, c, u, p, l, x, d);
break;
}
case "string": {
- let g = t10.bufferSync(s), y = x.decodeString(t10.data.get(a.dataId).values[0]);
- h = Aa(d, g, i, m, c, u, p, l, y, f);
+ let g = t6.bufferSync(s), x = y.decodeString(t6.data.get(a.dataId).values[0]);
+ h = Ma(f, g, i, m, c, u, p, l, x, d);
break;
}
default:
throw new Error(`Unsupported type ${s.dtype}`);
}
- return t10.makeTensorInfo(i, h.dtype, h.values);
+ return t6.makeTensorInfo(i, h.dtype, h.values);
}
-var NE = { kernelName: ei, backendName: "cpu", kernelFunc: M5 };
-function L5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { numOrSizeSplits: s, axis: a } = o, i = x.parseAxisParam(a, n.shape)[0], p = I.prepareSplitSize(n, s, i), u = new Array(n.shape.length).fill(0), c = n.shape.slice();
+var rE = { kernelName: li, backendName: "cpu", kernelFunc: s5 };
+function a5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { numOrSizeSplits: s, axis: a } = o, i = y.parseAxisParam(a, n.shape)[0], p = S.prepareSplitSize(n, s, i), u = new Array(n.shape.length).fill(0), c = n.shape.slice();
return p.map((l) => {
let m = [...c];
m[i] = l;
- let f = qo({ inputs: { x: n }, backend: t10, attrs: { begin: u, size: m } });
- return u[i] += l, f;
+ let d = No({ inputs: { x: n }, backend: t6, attrs: { begin: u, size: m } });
+ return u[i] += l, d;
});
}
-var _E = { kernelName: Ts, backendName: "cpu", kernelFunc: L5 };
-var EE = { kernelName: ti, backendName: "cpu", kernelFunc: ({ inputs: r, backend: e }) => {
- let { x: t10 } = r, o = e;
- K(t10, "square");
- let n = o.data.get(t10.dataId).values, s = new Float32Array(n.length);
+var oE = { kernelName: $s, backendName: "cpu", kernelFunc: a5 };
+var nE = { kernelName: mi, backendName: "cpu", kernelFunc: ({ inputs: r, backend: e }) => {
+ let { x: t6 } = r, o = e;
+ K(t6, "square");
+ let n = o.data.get(t6.dataId).values, s = new Float32Array(n.length);
for (let i = 0; i < n.length; ++i) {
let p = n[i];
s[i] = p * p;
}
- return { dataId: o.write(s, t10.shape, t10.dtype), shape: t10.shape, dtype: t10.dtype };
+ return { dataId: o.write(s, t6.shape, t6.dtype), shape: t6.shape, dtype: t6.dtype };
} };
-var B5 = we($s, (r, e) => {
- let t10 = e;
- return isNaN(r) ? NaN : r > 0 ? 1 : t10.alpha;
+var i5 = Ie(Ds, (r, e) => {
+ let t6 = e;
+ return isNaN(r) ? NaN : r > 0 ? 1 : t6.alpha;
});
-var $E = { kernelName: $s, backendName: "cpu", kernelFunc: B5 };
-function V5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { begin: s, end: a, strides: i, beginMask: p, endMask: u, ellipsisMask: c, newAxisMask: l, shrinkAxisMask: m } = o;
+var sE = { kernelName: Ds, backendName: "cpu", kernelFunc: i5 };
+function u5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { begin: s, end: a, strides: i, beginMask: p, endMask: u, ellipsisMask: c, newAxisMask: l, shrinkAxisMask: m } = o;
K(n, "stridedSlice");
- let { finalShapeSparse: f, finalShape: d, isIdentity: h, sliceDim0: g, isSimpleSlice: y, begin: b, end: C, strides: w } = et.sliceInfo(n.shape, s, a, i, p, u, c, l, m), k;
+ let { finalShapeSparse: d, finalShape: f, isIdentity: h, sliceDim0: g, isSimpleSlice: x, begin: b, end: C, strides: w } = ut.sliceInfo(n.shape, s, a, i, p, u, c, l, m), k;
if (h)
- k = Oe({ inputs: { x: n }, backend: t10, attrs: { shape: d } });
- else if (g || y) {
- x.assert(n.shape.length >= 1, () => `Input must have rank at least 1, got: ${n.shape.length}`);
- let _ = et.computeOutShape(b, C, w), E = qo({ inputs: { x: n }, backend: t10, attrs: { begin: b, size: _ } });
- k = Oe({ inputs: { x: E }, backend: t10, attrs: { shape: d } }), t10.disposeIntermediateTensorInfo(E);
+ k = Me({ inputs: { x: n }, backend: t6, attrs: { shape: f } });
+ else if (g || x) {
+ y.assert(n.shape.length >= 1, () => `Input must have rank at least 1, got: ${n.shape.length}`);
+ let _ = ut.computeOutShape(b, C, w), $ = No({ inputs: { x: n }, backend: t6, attrs: { begin: b, size: _ } });
+ k = Me({ inputs: { x: $ }, backend: t6, attrs: { shape: f } }), t6.disposeIntermediateTensorInfo($);
} else {
- let _ = t10.bufferSync(n), E = _d(f, _, w, b);
- k = t10.makeTensorInfo(d, E.dtype, E.values);
+ let _ = t6.bufferSync(n), $ = yf(d, _, w, b);
+ k = t6.makeTensorInfo(f, $.dtype, $.values);
}
return k;
}
-var RE = { kernelName: Yn, backendName: "cpu", kernelFunc: V5 };
-function z5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { separator: n, nGramWidths: s, leftPad: a, rightPad: i, padWidth: p, preserveShortSequences: u } = o, { data: c, dataSplits: l } = e, m = t10.data.get(c.dataId).values, f = t10.data.get(l.dataId).values, [d, h] = ku(m, f, n, s, a, i, p, u);
- return [t10.makeTensorInfo([d.length], "string", d), t10.makeTensorInfo(l.shape, "int32", h)];
+var aE = { kernelName: jn, backendName: "cpu", kernelFunc: u5 };
+function p5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { separator: n, nGramWidths: s, leftPad: a, rightPad: i, padWidth: p, preserveShortSequences: u } = o, { data: c, dataSplits: l } = e, m = t6.data.get(c.dataId).values, d = t6.data.get(l.dataId).values, [f, h] = ku(m, d, n, s, a, i, p, u);
+ return [t6.makeTensorInfo([f.length], "string", f), t6.makeTensorInfo(l.shape, "int32", h)];
}
-var AE = { kernelName: Ns, backendName: "cpu", kernelFunc: z5 };
-function W5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { skipEmpty: n } = o, { input: s, delimiter: a } = e;
+var iE = { kernelName: As, backendName: "cpu", kernelFunc: p5 };
+function c5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { skipEmpty: n } = o, { input: s, delimiter: a } = e;
if (s.dtype !== "string")
throw new Error("Input must be of datatype string");
if (s.shape.length !== 1)
throw new Error(`Input must be a vector, got shape: ${s.shape}`);
if (a.shape.length !== 0)
throw new Error(`Delimiter must be a scalar, got shape: ${a.shape}`);
- let i = t10.data.get(s.dataId).values, p = t10.data.get(a.dataId).values[0], [u, c, l] = Tu(i, p, n), m = c.length;
- return [t10.makeTensorInfo([m, 2], "int32", u), t10.makeTensorInfo([m], "string", c), t10.makeTensorInfo([2], "int32", new Int32Array(l))];
+ let i = t6.data.get(s.dataId).values, p = t6.data.get(a.dataId).values[0], [u, c, l] = Nu(i, p, n), m = c.length;
+ return [t6.makeTensorInfo([m, 2], "int32", u), t6.makeTensorInfo([m], "string", c), t6.makeTensorInfo([2], "int32", new Int32Array(l))];
}
-var FE = { kernelName: ri, backendName: "cpu", kernelFunc: W5 };
-function U5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { numBuckets: n } = o, { input: s } = e;
+var uE = { kernelName: di, backendName: "cpu", kernelFunc: c5 };
+function l5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { numBuckets: n } = o, { input: s } = e;
if (s.dtype !== "string")
throw new Error("Input must be of datatype string");
if (n <= 0)
throw new Error("Number of buckets must be at least 1");
- let a = t10.data.get(s.dataId).values, i = Nu(a, n);
- return t10.makeTensorInfo(s.shape, "int32", i);
+ let a = t6.data.get(s.dataId).values, i = Tu(a, n);
+ return t6.makeTensorInfo(s.shape, "int32", i);
}
-var DE = { kernelName: oi, backendName: "cpu", kernelFunc: U5 };
-var G5 = we(xa, (r) => Math.tan(r));
-var PE = { kernelName: xa, backendName: "cpu", kernelFunc: G5 };
-var H5 = we(Qn, (r) => Math.tanh(r));
-var OE = { kernelName: Qn, backendName: "cpu", kernelFunc: H5 };
-function q5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { reps: s } = o;
+var pE = { kernelName: fi, backendName: "cpu", kernelFunc: l5 };
+var m5 = Ie(Yn, (r) => Math.tan(r));
+var cE = { kernelName: Yn, backendName: "cpu", kernelFunc: m5 };
+var d5 = Ie(Qn, (r) => Math.tanh(r));
+var lE = { kernelName: Qn, backendName: "cpu", kernelFunc: d5 };
+function f5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { reps: s } = o;
K(n, "tile");
- let a = Ed(t10.bufferSync(n), s);
- return t10.makeTensorInfo(a.shape, a.dtype, a.values);
+ let a = bf(t6.bufferSync(n), s);
+ return t6.makeTensorInfo(a.shape, a.dtype, a.values);
}
-var ME = { kernelName: wo, backendName: "cpu", kernelFunc: q5 };
-function K5(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { k: s, sorted: a } = o;
+var mE = { kernelName: to, backendName: "cpu", kernelFunc: f5 };
+function h5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { k: s, sorted: a } = o;
K(n, "topk");
- let i = t10.data.get(n.dataId).values, [p, u] = $d(i, n.shape, n.dtype, s, a);
- return [t10.makeTensorInfo(p.shape, p.dtype, p.values), t10.makeTensorInfo(u.shape, u.dtype, u.values)];
+ let i = t6.data.get(n.dataId).values, [p, u] = Cf(i, n.shape, n.dtype, s, a);
+ return [t6.makeTensorInfo(p.shape, p.dtype, p.values), t6.makeTensorInfo(u.shape, u.dtype, u.values)];
}
-var LE = { kernelName: Zn, backendName: "cpu", kernelFunc: K5 };
-function j5(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { image: n, transforms: s } = e, { interpolation: a, fillMode: i, fillValue: p, outputShape: u } = t10, [c, l, m, f] = n.shape, [d, h] = u != null ? u : [l, m], g = [c, d, h, f], y = x.computeStrides(n.shape), b = y[0], C = y[1], w = y[2], k = x.computeStrides(g), _ = k[0], E = k[1], R = k[2], A = x.getTypedArrayFromDType(n.dtype, x.sizeFromShape(g));
- A.fill(p);
- let D = o.data.get(n.dataId).values, O = o.data.get(s.dataId).values;
+var dE = { kernelName: Zn, backendName: "cpu", kernelFunc: h5 };
+function g5(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { image: n, transforms: s } = e, { interpolation: a, fillMode: i, fillValue: p, outputShape: u } = t6, [c, l, m, d] = n.shape, [f, h] = u != null ? u : [l, m], g = [c, f, h, d], x = y.computeStrides(n.shape), b = x[0], C = x[1], w = x[2], k = y.computeStrides(g), _ = k[0], $ = k[1], A = k[2], R = y.getTypedArrayFromDType(n.dtype, y.sizeFromShape(g));
+ R.fill(p);
+ let D = o.data.get(n.dataId).values, P = o.data.get(s.dataId).values;
for (let L = 0; L < c; ++L) {
- let W = s.shape[0] === 1 ? O : O.subarray(L * 8, L * 8 + 8);
- for (let V = 0; V < d; ++V)
- for (let G = 0; G < h; ++G)
- for (let q = 0; q < f; ++q) {
- let H, j = W[6] * G + W[7] * V + 1;
+ let W = s.shape[0] === 1 ? P : P.subarray(L * 8, L * 8 + 8);
+ for (let V = 0; V < f; ++V)
+ for (let U = 0; U < h; ++U)
+ for (let q = 0; q < d; ++q) {
+ let H, j = W[6] * U + W[7] * V + 1;
if (j === 0)
continue;
- let Y = (W[0] * G + W[1] * V + W[2]) / j, Z = (W[3] * G + W[4] * V + W[5]) / j, ee = BE(Y, m, i), X = BE(Z, l, i);
+ let X = (W[0] * U + W[1] * V + W[2]) / j, Z = (W[3] * U + W[4] * V + W[5]) / j, ee = fE(X, m, i), Y = fE(Z, l, i);
switch (a) {
case "nearest":
- H = J5(D, l, m, b, C, w, L, X, ee, q, p);
+ H = S5(D, l, m, b, C, w, L, Y, ee, q, p);
break;
case "bilinear":
- H = e8(D, l, m, b, C, w, L, X, ee, q, p);
+ H = w5(D, l, m, b, C, w, L, Y, ee, q, p);
break;
default:
throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${a}`);
}
- let Q = L * _ + V * E + G * R + q;
- A[Q] = H;
+ let J = L * _ + V * $ + U * A + q;
+ R[J] = H;
}
- return o.makeTensorInfo(g, n.dtype, A);
+ return o.makeTensorInfo(g, n.dtype, R);
}
- return { dataId: o.write(A, g, n.dtype), shape: n.shape, dtype: n.dtype };
+ return { dataId: o.write(R, g, n.dtype), shape: n.shape, dtype: n.dtype };
}
-var VE = { kernelName: Jn, backendName: "cpu", kernelFunc: j5 };
-function BE(r, e, t10) {
- switch (t10) {
+var hE = { kernelName: Jn, backendName: "cpu", kernelFunc: g5 };
+function fE(r, e, t6) {
+ switch (t6) {
case "reflect":
- return X5(r, e);
+ return x5(r, e);
case "wrap":
- return Y5(r, e);
+ return y5(r, e);
case "nearest":
- return Z5(r, e);
+ return C5(r, e);
case "constant":
default:
- return Q5(r, e);
+ return b5(r, e);
}
}
-function X5(r, e) {
- let t10 = r;
- if (t10 < 0)
+function x5(r, e) {
+ let t6 = r;
+ if (t6 < 0)
if (e <= 1)
- t10 = 0;
+ t6 = 0;
else {
let o = 2 * e;
- t10 < o && (t10 = o * Math.trunc(-t10 / o) + t10), t10 = t10 < -e ? t10 + o : -t10 - 1;
+ t6 < o && (t6 = o * Math.trunc(-t6 / o) + t6), t6 = t6 < -e ? t6 + o : -t6 - 1;
}
- else if (t10 > e - 1)
+ else if (t6 > e - 1)
if (e <= 1)
- t10 = 0;
+ t6 = 0;
else {
let o = 2 * e;
- t10 -= o * Math.trunc(t10 / o), t10 >= e && (t10 = o - t10 - 1);
+ t6 -= o * Math.trunc(t6 / o), t6 >= e && (t6 = o - t6 - 1);
}
- return x.clamp(0, t10, e - 1);
+ return y.clamp(0, t6, e - 1);
}
-function Y5(r, e) {
- let t10 = r;
- if (t10 < 0)
+function y5(r, e) {
+ let t6 = r;
+ if (t6 < 0)
if (e <= 1)
- t10 = 0;
+ t6 = 0;
else {
let o = e - 1;
- t10 += e * (Math.trunc(-t10 / o) + 1);
+ t6 += e * (Math.trunc(-t6 / o) + 1);
}
- else if (t10 > e - 1)
+ else if (t6 > e - 1)
if (e <= 1)
- t10 = 0;
+ t6 = 0;
else {
let o = e - 1;
- t10 -= e * Math.trunc(t10 / o);
+ t6 -= e * Math.trunc(t6 / o);
}
- return x.clamp(0, t10, e - 1);
+ return y.clamp(0, t6, e - 1);
}
-function Q5(r, e) {
+function b5(r, e) {
return r;
}
-function Z5(r, e) {
- return x.clamp(0, r, e - 1);
+function C5(r, e) {
+ return y.clamp(0, r, e - 1);
}
-function Nl(r, e, t10, o, n, s, a, i, p, u, c) {
+function bl(r, e, t6, o, n, s, a, i, p, u, c) {
let l = a * o + i * n + p * s + u;
- return 0 <= i && i < e && 0 <= p && p < t10 ? r[l] : c;
+ return 0 <= i && i < e && 0 <= p && p < t6 ? r[l] : c;
}
-function J5(r, e, t10, o, n, s, a, i, p, u, c) {
+function S5(r, e, t6, o, n, s, a, i, p, u, c) {
let l = Math.round(i), m = Math.round(p);
- return Nl(r, e, t10, o, n, s, a, l, m, u, c);
+ return bl(r, e, t6, o, n, s, a, l, m, u, c);
}
-function e8(r, e, t10, o, n, s, a, i, p, u, c) {
- let l = Math.floor(i), m = Math.floor(p), f = l + 1, d = m + 1, h = (d - p) * Nl(r, e, t10, o, n, s, a, l, m, u, c) + (p - m) * Nl(r, e, t10, o, n, s, a, l, d, u, c), g = (d - p) * Nl(r, e, t10, o, n, s, a, f, m, u, c) + (p - m) * Nl(r, e, t10, o, n, s, a, f, d, u, c);
- return (f - i) * h + (i - l) * g;
+function w5(r, e, t6, o, n, s, a, i, p, u, c) {
+ let l = Math.floor(i), m = Math.floor(p), d = l + 1, f = m + 1, h = (f - p) * bl(r, e, t6, o, n, s, a, l, m, u, c) + (p - m) * bl(r, e, t6, o, n, s, a, l, f, u, c), g = (f - p) * bl(r, e, t6, o, n, s, a, d, m, u, c) + (p - m) * bl(r, e, t6, o, n, s, a, d, f, u, c);
+ return (d - i) * h + (i - l) * g;
}
-function t8(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { axis: n } = t10, { x: s } = e;
+function I5(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { axis: n } = t6, { x: s } = e;
K(s, "unique");
- let a = o.data.get(s.dataId).values, { outputValues: i, outputShape: p, indices: u } = Rd(a, n, s.shape, s.dtype);
+ let a = o.data.get(s.dataId).values, { outputValues: i, outputShape: p, indices: u } = Sf(a, n, s.shape, s.dtype);
return [o.makeTensorInfo(p, s.dtype, i), o.makeTensorInfo([u.length], "int32", u)];
}
-var zE = { kernelName: $p, backendName: "cpu", kernelFunc: t8 };
-function r8(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { value: n } = e, { axis: s } = o;
+var gE = { kernelName: kp, backendName: "cpu", kernelFunc: I5 };
+function v5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { value: n } = e, { axis: s } = o;
s < 0 && (s += n.shape.length);
let a = n.shape.length, i = n.shape[s], p = new Array(a - 1), u = 0;
- for (let f = 0; f < a; f++)
- f !== s && (p[u++] = n.shape[f]);
+ for (let d = 0; d < a; d++)
+ d !== s && (p[u++] = n.shape[d]);
let c = new Array(a).fill(0), l = n.shape.slice();
l[s] = 1;
let m = new Array(i);
- for (let f = 0; f < m.length; f++) {
- c[s] = f;
- let d = qo({ inputs: { x: n }, backend: t10, attrs: { begin: c, size: l } });
- m[f] = Oe({ inputs: { x: d }, backend: t10, attrs: { shape: p } }), t10.disposeIntermediateTensorInfo(d);
+ for (let d = 0; d < m.length; d++) {
+ c[s] = d;
+ let f = No({ inputs: { x: n }, backend: t6, attrs: { begin: c, size: l } });
+ m[d] = Me({ inputs: { x: f }, backend: t6, attrs: { shape: p } }), t6.disposeIntermediateTensorInfo(f);
}
return m;
}
-var WE = { kernelName: _s, backendName: "cpu", kernelFunc: r8 };
-function o8(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, segmentIds: s } = e, { numSegments: a } = o;
+var xE = { kernelName: Rs, backendName: "cpu", kernelFunc: v5 };
+function k5(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, segmentIds: s } = e, { numSegments: a } = o;
K(n, "unsortedSegmentSum");
let i = n.shape.length, p = s.shape.length, u = [], c = [], l = i - p, m = s;
- for (let d = 0; d < l; ++d) {
- let h = oc({ inputs: { input: m }, backend: t10, attrs: { dim: d + 1 } });
+ for (let f = 0; f < l; ++f) {
+ let h = Jp({ inputs: { input: m }, backend: t6, attrs: { dim: f + 1 } });
m = h, c.push(h);
}
- for (let d = 0; d < a; ++d) {
- let h = x.createScalarValue(d, "int32"), g = t10.makeTensorInfo([], "int32", h), y = sI({ inputs: { a: g, b: m }, backend: t10 }), b = Uo({ inputs: { x: y }, backend: t10, attrs: { dtype: "float32" } }), C = wu({ inputs: { a: b, b: n }, backend: t10 }), w = Fa({ inputs: { x: C }, backend: t10, attrs: { axis: 0, keepDims: false } });
- u.push(w), c.push(g), c.push(y), c.push(b), c.push(C), c.push(w);
+ for (let f = 0; f < a; ++f) {
+ let h = y.createScalarValue(f, "int32"), g = t6.makeTensorInfo([], "int32", h), x = eS({ inputs: { a: g, b: m }, backend: t6 }), b = Io({ inputs: { x }, backend: t6, attrs: { dtype: "float32" } }), C = wu({ inputs: { a: b, b: n }, backend: t6 }), w = La({ inputs: { x: C }, backend: t6, attrs: { axis: 0, keepDims: false } });
+ u.push(w), c.push(g), c.push(x), c.push(b), c.push(C), c.push(w);
}
- let f = OI({ inputs: u, backend: t10, attrs: { axis: 0 } });
- return c.forEach((d) => t10.disposeIntermediateTensorInfo(d)), f;
+ let d = AS({ inputs: u, backend: t6, attrs: { axis: 0 } });
+ return c.forEach((f) => t6.disposeIntermediateTensorInfo(f)), d;
}
-var UE = { kernelName: Rp, backendName: "cpu", kernelFunc: o8 };
-var n8 = [h2, TN, g2, x2, RN, y2, b2, C2, I2, w2, S2, v2, k2, T2, N2, E2, $2, R2, A2, d2, F2, D2, P2, O2, $N, AN, M2, NN, L2, V2, z2, W2, U2, G2, H2, q2, K2, j2, X2, Y2, Q2, Z2, J2, e_, t_, r_, o_, n_, s_, a_, u_, u2, p_, FN, c_, DN, l_, PN, m_, f_, d_, ON, h_, g_, x_, y_, b_, MN, LN, _N, C_, B2, I_, w_, S_, p2, BN, VN, v_, zN, k_, T_, N_, __, E_, $_, R_, WN, A_, F_, D_, P_, M_, L_, B_, UN, V_, z_, G_, GN, HN, H_, q_, K_, qN, j_, Q_, Z_, Od, J_, c2, jN, eE, tE, rE, oE, EN, vl, nE, l2, m2, f2, sE, aE, iE, uE, pE, cE, lE, JN, mE, dE, hE, gE, t2, xE, yE, bE, r2, W_, IE, wE, SE, vE, kE, TE, NE, _E, n2, EE, s2, $E, RE, AE, FE, DE, a2, i_, PE, OE, ME, LE, VE, KN, zE, WE, UE, X_];
-for (let r of n8)
- ya(r);
-var ic = {};
-Be(ic, { assertNotComplex: () => as, bindCanvasToFramebuffer: () => f8, bindColorTextureToFramebuffer: () => Rl, bindTextureToProgramUniformSampler: () => ZI, bindTextureUnit: () => KE, bindVertexBufferToProgramAttribute: () => Wd, callAndCheck: () => me, canBeRepresented: () => VI, createFragmentShader: () => WI, createFramebuffer: () => XI, createProgram: () => UI, createStaticIndexBuffer: () => qI, createStaticVertexBuffer: () => HI, createTexture: () => KI, createVertexShader: () => zI, getBatchDim: () => Pa, getExtensionOrThrow: () => nc, getFramebufferErrorMessage: () => jE, getMaxTexturesInShader: () => tw, getNumChannels: () => l8, getProgramUniformLocation: () => QI, getProgramUniformLocationOrThrow: () => YI, getRowsCols: () => Oa, getShapeAs3D: () => ac, getTextureShapeFromLogicalShape: () => JI, getWebGLDisjointQueryTimerVersion: () => rw, getWebGLErrorMessage: () => qE, getWebGLMaxTextureSize: () => ew, hasExtension: () => Hr, isCapableOfRenderingToFloatTexture: () => ow, isDownloadFloatTextureEnabled: () => nw, isReshapeFree: () => Ti, isWebGLFenceEnabled: () => sw, isWebGLVersionEnabled: () => Gd, linkProgram: () => GI, logShaderSourceAndInfoLog: () => zd, resetMaxTextureSize: () => d8, resetMaxTexturesInShader: () => h8, unbindColorTextureFromFramebuffer: () => Ud, unbindTextureUnit: () => m8, validateFramebuffer: () => sc, validateProgram: () => $l, validateTextureSize: () => jI });
+var yE = { kernelName: Np, backendName: "cpu", kernelFunc: k5 };
+var N5 = [GT, tT, HT, qT, aT, KT, jT, XT, YT, QT, ZT, JT, e2, t2, r2, n2, s2, a2, i2, UT, u2, p2, c2, l2, sT, iT, m2, rT, d2, h2, g2, x2, y2, b2, C2, S2, w2, I2, v2, k2, N2, T2, _2, E2, $2, A2, R2, F2, D2, O2, M2, MT, L2, uT, B2, pT, V2, cT, z2, W2, U2, lT, G2, H2, q2, K2, j2, mT, dT, oT, X2, f2, Y2, Q2, Z2, LT, fT, hT, J2, gT, e_, t_, r_, o_, n_, s_, a_, xT, i_, u_, p_, c_, m_, d_, f_, yT, h_, g_, b_, bT, CT, C_, S_, w_, ST, I_, N_, T_, kf, __, BT, IT, E_, $_, A_, R_, nT, gl, F_, VT, zT, WT, D_, O_, P_, M_, L_, B_, V_, _T, z_, U_, G_, H_, $T, q_, K_, j_, AT, x_, Y_, Q_, Z_, J_, eE, tE, rE, oE, FT, nE, DT, sE, aE, iE, uE, pE, OT, P2, cE, lE, mE, dE, hE, wT, gE, xE, yE, v_];
+for (let r of N5)
+ Ia(r);
+var oc = {};
+Ue(oc, { assertNotComplex: () => is, bindCanvasToFramebuffer: () => O5, bindColorTextureToFramebuffer: () => Il, bindTextureToProgramUniformSampler: () => KS, bindTextureUnit: () => wE, bindVertexBufferToProgramAttribute: () => Af, callAndCheck: () => ce, canBeRepresented: () => OS, createFragmentShader: () => MS, createFramebuffer: () => GS, createProgram: () => LS, createStaticIndexBuffer: () => zS, createStaticVertexBuffer: () => VS, createTexture: () => WS, createVertexShader: () => PS, getBatchDim: () => Va, getExtensionOrThrow: () => ec, getFramebufferErrorMessage: () => IE, getMaxTexturesInShader: () => YS, getNumChannels: () => F5, getProgramUniformLocation: () => qS, getProgramUniformLocationOrThrow: () => HS, getRowsCols: () => za, getShapeAs3D: () => rc, getTextureShapeFromLogicalShape: () => jS, getWebGLDisjointQueryTimerVersion: () => QS, getWebGLErrorMessage: () => SE, getWebGLMaxTextureSize: () => XS, hasExtension: () => Ur, isCapableOfRenderingToFloatTexture: () => ZS, isDownloadFloatTextureEnabled: () => JS, isReshapeFree: () => Li, isWebGLFenceEnabled: () => ew, isWebGLVersionEnabled: () => Ff, linkProgram: () => BS, logShaderSourceAndInfoLog: () => $f, resetMaxTextureSize: () => P5, resetMaxTexturesInShader: () => M5, unbindColorTextureFromFramebuffer: () => Rf, unbindTextureUnit: () => D5, validateFramebuffer: () => tc, validateProgram: () => wl, validateTextureSize: () => US });
var Eu = {};
-var Md = { alpha: false, antialias: false, premultipliedAlpha: false, preserveDrawingBuffer: false, depth: false, stencil: false, failIfMajorPerformanceCaveat: true };
-function MI(r, e) {
+var Nf = { alpha: false, antialias: false, premultipliedAlpha: false, preserveDrawingBuffer: false, depth: false, stencil: false, failIfMajorPerformanceCaveat: true };
+function RS(r, e) {
Eu[r] = e;
}
-function Gr(r, e) {
+function Wr(r, e) {
if (!(r in Eu) || e != null) {
- let o = a8(r, e);
+ let o = _5(r, e);
if (o !== null)
Eu[r] = o;
else
return console.log("Could not get context for WebGL version", r), null;
}
- let t10 = Eu[r];
- return t10 == null || t10.isContextLost() ? (delete Eu[r], Gr(r)) : (t10.disable(t10.DEPTH_TEST), t10.disable(t10.STENCIL_TEST), t10.disable(t10.BLEND), t10.disable(t10.DITHER), t10.disable(t10.POLYGON_OFFSET_FILL), t10.disable(t10.SAMPLE_COVERAGE), t10.enable(t10.SCISSOR_TEST), t10.enable(t10.CULL_FACE), t10.cullFace(t10.BACK), Eu[r]);
+ let t6 = Eu[r];
+ return t6 == null || t6.isContextLost() ? (delete Eu[r], Wr(r)) : (t6.disable(t6.DEPTH_TEST), t6.disable(t6.STENCIL_TEST), t6.disable(t6.BLEND), t6.disable(t6.DITHER), t6.disable(t6.POLYGON_OFFSET_FILL), t6.disable(t6.SAMPLE_COVERAGE), t6.enable(t6.SCISSOR_TEST), t6.enable(t6.CULL_FACE), t6.cullFace(t6.BACK), Eu[r]);
}
-function s8(r) {
+function T5(r) {
if (typeof OffscreenCanvas != "undefined" && r === 2)
return new OffscreenCanvas(300, 150);
if (typeof document != "undefined")
return document.createElement("canvas");
throw new Error("Cannot create a canvas in this context");
}
-function a8(r, e) {
+function _5(r, e) {
if (r !== 1 && r !== 2)
throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");
- let t10 = e == null ? s8(r) : e;
- return t10.addEventListener("webglcontextlost", (o) => {
+ let t6 = e == null ? T5(r) : e;
+ return t6.addEventListener("webglcontextlost", (o) => {
o.preventDefault(), delete Eu[r];
- }, false), P().getBool("SOFTWARE_WEBGL_ENABLED") && (Md.failIfMajorPerformanceCaveat = false), r === 1 ? t10.getContext("webgl", Md) || t10.getContext("experimental-webgl", Md) : t10.getContext("webgl2", Md);
+ }, false), O().getBool("SOFTWARE_WEBGL_ENABLED") && (Nf.failIfMajorPerformanceCaveat = false), r === 1 ? t6.getContext("webgl", Nf) || t6.getContext("experimental-webgl", Nf) : t6.getContext("webgl2", Nf);
}
-var ki;
+var Mi;
(function(r) {
r[r.DENSE = 0] = "DENSE", r[r.SHARED_BATCH = 1] = "SHARED_BATCH";
-})(ki || (ki = {}));
+})(Mi || (Mi = {}));
var ir;
(function(r) {
r[r.RENDER = 0] = "RENDER", r[r.UPLOAD = 1] = "UPLOAD", r[r.PIXELS = 2] = "PIXELS", r[r.DOWNLOAD = 3] = "DOWNLOAD";
})(ir || (ir = {}));
-var Jt;
+var Zt;
(function(r) {
r[r.UNPACKED_FLOAT16 = 0] = "UNPACKED_FLOAT16", r[r.UNPACKED_FLOAT32 = 1] = "UNPACKED_FLOAT32", r[r.PACKED_4X1_UNSIGNED_BYTE = 2] = "PACKED_4X1_UNSIGNED_BYTE", r[r.PACKED_2X2_FLOAT32 = 3] = "PACKED_2X2_FLOAT32", r[r.PACKED_2X2_FLOAT16 = 4] = "PACKED_2X2_FLOAT16";
-})(Jt || (Jt = {}));
+})(Zt || (Zt = {}));
function $u(r, e) {
return [e, r];
}
-function GE(r, e) {
+function bE(r, e) {
return r * e;
}
-function _l(r) {
- let e = x.sizeFromShape(r), t10 = Math.ceil(e / 4);
- return x.sizeToSquarishShape(t10);
+function Cl(r) {
+ let e = y.sizeFromShape(r), t6 = Math.ceil(e / 4);
+ return y.sizeToSquarishShape(t6);
}
-function Ks(r, e) {
+function Ys(r, e) {
return [Math.max(1, Math.ceil(e / 2)), Math.max(1, Math.ceil(r / 2))];
}
-function HE(r, e) {
- let [t10, o] = Ks(r, e);
- return t10 * o * 4;
+function CE(r, e) {
+ let [t6, o] = Ys(r, e);
+ return t6 * o * 4;
}
-function El(r, e) {
- let t10 = r, o, n, s, a, i, p, u, c, l, m;
- return P().getNumber("WEBGL_VERSION") === 2 ? (o = t10.R32F, n = t10.R16F, s = t10.RGBA16F, a = t10.RGBA32F, i = t10.RED, u = 4, c = 1, l = t10.HALF_FLOAT, m = t10.FLOAT, p = t10.RGBA8) : (o = r.RGBA, n = r.RGBA, s = r.RGBA, a = t10.RGBA, i = r.RGBA, u = 4, c = 4, l = e != null ? e.HALF_FLOAT_OES : null, m = r.FLOAT, p = r.RGBA), { internalFormatFloat: o, internalFormatHalfFloat: n, internalFormatPackedHalfFloat: s, internalFormatPackedFloat: a, textureFormatFloat: i, downloadTextureFormat: p, downloadUnpackNumChannels: u, defaultNumChannels: c, textureTypeHalfFloat: l, textureTypeFloat: m };
+function Sl(r, e) {
+ let t6 = r, o, n, s, a, i, p, u, c, l, m;
+ return O().getNumber("WEBGL_VERSION") === 2 ? (o = t6.R32F, n = t6.R16F, s = t6.RGBA16F, a = t6.RGBA32F, i = t6.RED, u = 4, c = 1, l = t6.HALF_FLOAT, m = t6.FLOAT, p = t6.RGBA8) : (o = r.RGBA, n = r.RGBA, s = r.RGBA, a = t6.RGBA, i = r.RGBA, u = 4, c = 4, l = e != null ? e.HALF_FLOAT_OES : null, m = r.FLOAT, p = r.RGBA), { internalFormatFloat: o, internalFormatHalfFloat: n, internalFormatPackedHalfFloat: s, internalFormatPackedFloat: a, textureFormatFloat: i, downloadTextureFormat: p, downloadUnpackNumChannels: u, defaultNumChannels: c, textureTypeHalfFloat: l, textureTypeFloat: m };
}
-function me(r, e) {
- let t10 = e();
- return P().getBool("DEBUG") && i8(r), t10;
+function ce(r, e) {
+ let t6 = e();
+ return O().getBool("DEBUG") && E5(r), t6;
}
-function i8(r) {
+function E5(r) {
let e = r.getError();
if (e !== r.NO_ERROR)
- throw new Error("WebGL Error: " + qE(r, e));
+ throw new Error("WebGL Error: " + SE(r, e));
}
-var u8 = 596e-10;
-var p8 = 65504;
-function VI(r) {
- return !!(P().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || r === 0 || u8 < Math.abs(r) && Math.abs(r) < p8);
+var $5 = 596e-10;
+var A5 = 65504;
+function OS(r) {
+ return !!(O().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || r === 0 || $5 < Math.abs(r) && Math.abs(r) < A5);
}
-function qE(r, e) {
+function SE(r, e) {
switch (e) {
case r.NO_ERROR:
return "NO_ERROR";
@@ -14912,113 +14958,113 @@ function qE(r, e) {
return `Unknown error code ${e}`;
}
}
-function nc(r, e) {
- return Da(r, () => r.getExtension(e), 'Extension "' + e + '" not supported on this browser.');
+function ec(r, e) {
+ return Ba(r, () => r.getExtension(e), 'Extension "' + e + '" not supported on this browser.');
}
-function zI(r, e) {
- let t10 = Da(r, () => r.createShader(r.VERTEX_SHADER), "Unable to create vertex WebGLShader.");
- if (me(r, () => r.shaderSource(t10, e)), me(r, () => r.compileShader(t10)), r.getShaderParameter(t10, r.COMPILE_STATUS) === false)
- throw console.log(r.getShaderInfoLog(t10)), new Error("Failed to compile vertex shader.");
- return t10;
+function PS(r, e) {
+ let t6 = Ba(r, () => r.createShader(r.VERTEX_SHADER), "Unable to create vertex WebGLShader.");
+ if (ce(r, () => r.shaderSource(t6, e)), ce(r, () => r.compileShader(t6)), r.getShaderParameter(t6, r.COMPILE_STATUS) === false)
+ throw console.log(r.getShaderInfoLog(t6)), new Error("Failed to compile vertex shader.");
+ return t6;
}
-function WI(r, e) {
- let t10 = Da(r, () => r.createShader(r.FRAGMENT_SHADER), "Unable to create fragment WebGLShader.");
- if (me(r, () => r.shaderSource(t10, e)), me(r, () => r.compileShader(t10)), P().get("ENGINE_COMPILE_ONLY"))
- return t10;
- if (r.getShaderParameter(t10, r.COMPILE_STATUS) === false)
- throw zd(e, r.getShaderInfoLog(t10)), new Error("Failed to compile fragment shader.");
- return t10;
+function MS(r, e) {
+ let t6 = Ba(r, () => r.createShader(r.FRAGMENT_SHADER), "Unable to create fragment WebGLShader.");
+ if (ce(r, () => r.shaderSource(t6, e)), ce(r, () => r.compileShader(t6)), O().get("ENGINE_COMPILE_ONLY"))
+ return t6;
+ if (r.getShaderParameter(t6, r.COMPILE_STATUS) === false)
+ throw $f(e, r.getShaderInfoLog(t6)), new Error("Failed to compile fragment shader.");
+ return t6;
}
-var c8 = /ERROR: [0-9]+:([0-9]+):/g;
-function zd(r, e) {
- let t10 = c8.exec(e);
- if (t10 == null) {
+var R5 = /ERROR: [0-9]+:([0-9]+):/g;
+function $f(r, e) {
+ let t6 = R5.exec(e);
+ if (t6 == null) {
console.log(`Couldn't parse line number in error: ${e}`), console.log(r);
return;
}
- let o = +t10[1], n = r.split(`
-`), s = n.length.toString().length + 2, a = n.map((l, m) => x.rightPad((m + 1).toString(), s) + l), i = 0;
+ let o = +t6[1], n = r.split(`
+`), s = n.length.toString().length + 2, a = n.map((l, m) => y.rightPad((m + 1).toString(), s) + l), i = 0;
for (let l = 0; l < a.length; l++)
i = Math.max(a[l].length, i);
let p = a.slice(0, o - 1), u = a.slice(o - 1, o), c = a.slice(o);
console.log(p.join(`
`)), console.log(e.split(`
-`)[0]), console.log(`%c ${x.rightPad(u[0], i)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(c.join(`
+`)[0]), console.log(`%c ${y.rightPad(u[0], i)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(c.join(`
`));
}
-function UI(r) {
- return Da(r, () => r.createProgram(), "Unable to create WebGLProgram.");
+function LS(r) {
+ return Ba(r, () => r.createProgram(), "Unable to create WebGLProgram.");
}
-function GI(r, e) {
- if (me(r, () => r.linkProgram(e)), !P().get("ENGINE_COMPILE_ONLY") && r.getProgramParameter(e, r.LINK_STATUS) === false)
+function BS(r, e) {
+ if (ce(r, () => r.linkProgram(e)), !O().get("ENGINE_COMPILE_ONLY") && r.getProgramParameter(e, r.LINK_STATUS) === false)
throw console.log(r.getProgramInfoLog(e)), new Error("Failed to link vertex and fragment shaders.");
}
-function $l(r, e) {
- if (me(r, () => r.validateProgram(e)), r.getProgramParameter(e, r.VALIDATE_STATUS) === false)
+function wl(r, e) {
+ if (ce(r, () => r.validateProgram(e)), r.getProgramParameter(e, r.VALIDATE_STATUS) === false)
throw console.log(r.getProgramInfoLog(e)), new Error("Shader program validation failed.");
}
-function HI(r, e) {
- let t10 = Da(r, () => r.createBuffer(), "Unable to create WebGLBuffer");
- return me(r, () => r.bindBuffer(r.ARRAY_BUFFER, t10)), me(r, () => r.bufferData(r.ARRAY_BUFFER, e, r.STATIC_DRAW)), t10;
+function VS(r, e) {
+ let t6 = Ba(r, () => r.createBuffer(), "Unable to create WebGLBuffer");
+ return ce(r, () => r.bindBuffer(r.ARRAY_BUFFER, t6)), ce(r, () => r.bufferData(r.ARRAY_BUFFER, e, r.STATIC_DRAW)), t6;
}
-function qI(r, e) {
- let t10 = Da(r, () => r.createBuffer(), "Unable to create WebGLBuffer");
- return me(r, () => r.bindBuffer(r.ELEMENT_ARRAY_BUFFER, t10)), me(r, () => r.bufferData(r.ELEMENT_ARRAY_BUFFER, e, r.STATIC_DRAW)), t10;
+function zS(r, e) {
+ let t6 = Ba(r, () => r.createBuffer(), "Unable to create WebGLBuffer");
+ return ce(r, () => r.bindBuffer(r.ELEMENT_ARRAY_BUFFER, t6)), ce(r, () => r.bufferData(r.ELEMENT_ARRAY_BUFFER, e, r.STATIC_DRAW)), t6;
}
-function l8() {
- return P().getNumber("WEBGL_VERSION") === 2 ? 1 : 4;
+function F5() {
+ return O().getNumber("WEBGL_VERSION") === 2 ? 1 : 4;
}
-function KI(r) {
- return Da(r, () => r.createTexture(), "Unable to create WebGLTexture.");
+function WS(r) {
+ return Ba(r, () => r.createTexture(), "Unable to create WebGLTexture.");
}
-function jI(r, e) {
- let t10 = P().getNumber("WEBGL_MAX_TEXTURE_SIZE");
+function US(r, e) {
+ let t6 = O().getNumber("WEBGL_MAX_TEXTURE_SIZE");
if (r <= 0 || e <= 0) {
let o = `[${r}x${e}]`;
throw new Error("Requested texture size " + o + " is invalid.");
}
- if (r > t10 || e > t10) {
- let o = `[${r}x${e}]`, n = `[${t10}x${t10}]`;
+ if (r > t6 || e > t6) {
+ let o = `[${r}x${e}]`, n = `[${t6}x${t6}]`;
throw new Error("Requested texture size " + o + " greater than WebGL maximum on this browser / GPU " + n + ".");
}
}
-function XI(r) {
- return Da(r, () => r.createFramebuffer(), "Unable to create WebGLFramebuffer.");
+function GS(r) {
+ return Ba(r, () => r.createFramebuffer(), "Unable to create WebGLFramebuffer.");
}
-function Wd(r, e, t10, o, n, s, a) {
- let i = r.getAttribLocation(e, t10);
- return i === -1 ? false : (me(r, () => r.bindBuffer(r.ARRAY_BUFFER, o)), me(r, () => r.vertexAttribPointer(i, n, r.FLOAT, false, s, a)), me(r, () => r.enableVertexAttribArray(i)), true);
+function Af(r, e, t6, o, n, s, a) {
+ let i = r.getAttribLocation(e, t6);
+ return i === -1 ? false : (ce(r, () => r.bindBuffer(r.ARRAY_BUFFER, o)), ce(r, () => r.vertexAttribPointer(i, n, r.FLOAT, false, s, a)), ce(r, () => r.enableVertexAttribArray(i)), true);
}
-function KE(r, e, t10) {
- XE(r, t10), me(r, () => r.activeTexture(r.TEXTURE0 + t10)), me(r, () => r.bindTexture(r.TEXTURE_2D, e));
+function wE(r, e, t6) {
+ vE(r, t6), ce(r, () => r.activeTexture(r.TEXTURE0 + t6)), ce(r, () => r.bindTexture(r.TEXTURE_2D, e));
}
-function m8(r, e) {
- XE(r, e), me(r, () => r.activeTexture(r.TEXTURE0 + e)), me(r, () => r.bindTexture(r.TEXTURE_2D, null));
+function D5(r, e) {
+ vE(r, e), ce(r, () => r.activeTexture(r.TEXTURE0 + e)), ce(r, () => r.bindTexture(r.TEXTURE_2D, null));
}
-function YI(r, e, t10) {
- return Da(r, () => r.getUniformLocation(e, t10), 'uniform "' + t10 + '" not present in program.');
+function HS(r, e, t6) {
+ return Ba(r, () => r.getUniformLocation(e, t6), 'uniform "' + t6 + '" not present in program.');
}
-function QI(r, e, t10) {
- return r.getUniformLocation(e, t10);
+function qS(r, e, t6) {
+ return r.getUniformLocation(e, t6);
}
-function ZI(r, e, t10, o) {
- me(r, () => KE(r, e, o)), me(r, () => r.uniform1i(t10, o));
+function KS(r, e, t6, o) {
+ ce(r, () => wE(r, e, o)), ce(r, () => r.uniform1i(t6, o));
}
-function f8(r) {
- me(r, () => r.bindFramebuffer(r.FRAMEBUFFER, null)), me(r, () => r.viewport(0, 0, r.canvas.width, r.canvas.height)), me(r, () => r.scissor(0, 0, r.canvas.width, r.canvas.height));
+function O5(r) {
+ ce(r, () => r.bindFramebuffer(r.FRAMEBUFFER, null)), ce(r, () => r.viewport(0, 0, r.canvas.width, r.canvas.height)), ce(r, () => r.scissor(0, 0, r.canvas.width, r.canvas.height));
}
-function Rl(r, e, t10) {
- me(r, () => r.bindFramebuffer(r.FRAMEBUFFER, t10)), me(r, () => r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, e, 0));
+function Il(r, e, t6) {
+ ce(r, () => r.bindFramebuffer(r.FRAMEBUFFER, t6)), ce(r, () => r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, e, 0));
}
-function Ud(r, e) {
- me(r, () => r.bindFramebuffer(r.FRAMEBUFFER, e)), me(r, () => r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, null, 0));
+function Rf(r, e) {
+ ce(r, () => r.bindFramebuffer(r.FRAMEBUFFER, e)), ce(r, () => r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, null, 0));
}
-function sc(r) {
+function tc(r) {
let e = r.checkFramebufferStatus(r.FRAMEBUFFER);
if (e !== r.FRAMEBUFFER_COMPLETE)
- throw new Error("Error binding framebuffer: " + jE(r, e));
+ throw new Error("Error binding framebuffer: " + IE(r, e));
}
-function jE(r, e) {
+function IE(r, e) {
switch (e) {
case r.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
@@ -15032,159 +15078,159 @@ function jE(r, e) {
return `unknown error ${e}`;
}
}
-function Da(r, e, t10) {
- let o = me(r, () => e());
+function Ba(r, e, t6) {
+ let o = ce(r, () => e());
if (o == null)
- throw new Error(t10);
+ throw new Error(t6);
return o;
}
-function XE(r, e) {
- let t10 = r.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, o = e + r.TEXTURE0;
- if (o < r.TEXTURE0 || o > t10) {
- let n = `[gl.TEXTURE0, gl.TEXTURE${t10}]`;
+function vE(r, e) {
+ let t6 = r.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, o = e + r.TEXTURE0;
+ if (o < r.TEXTURE0 || o > t6) {
+ let n = `[gl.TEXTURE0, gl.TEXTURE${t6}]`;
throw new Error(`textureUnit must be in ${n}.`);
}
}
-function Pa(r, e = 2) {
- return x.sizeFromShape(r.slice(0, r.length - e));
+function Va(r, e = 2) {
+ return y.sizeFromShape(r.slice(0, r.length - e));
}
-function Oa(r) {
+function za(r) {
if (r.length === 0)
throw Error("Cannot get rows and columns of an empty shape array.");
return [r.length > 1 ? r[r.length - 2] : 1, r[r.length - 1]];
}
-function ac(r) {
+function rc(r) {
let e = [1, 1, 1];
- return r.length === 0 || r.length === 1 && r[0] === 1 || (e = [Pa(r), ...Oa(r)]), e;
+ return r.length === 0 || r.length === 1 && r[0] === 1 || (e = [Va(r), ...za(r)]), e;
}
-function JI(r, e = false) {
- let t10 = P().getNumber("WEBGL_MAX_TEXTURE_SIZE"), o = P().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");
- o === 1 / 0 && P().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (o = t10 / 2), e && (t10 = t10 * 2, o = o * 2, r = r.map((i, p) => p >= r.length - 2 ? x.nearestLargerEven(r[p]) : r[p]), r.length === 1 && (r = [2, r[0]])), r.length !== 2 && (r = x.squeezeShape(r).newShape);
- let n = x.sizeFromShape(r), s = null;
- r.length <= 1 && n <= t10 ? s = [1, n] : r.length === 2 && r[0] <= t10 && r[1] <= t10 ? s = r : r.length === 3 && r[0] * r[1] <= t10 && r[2] <= t10 ? s = [r[0] * r[1], r[2]] : r.length === 3 && r[0] <= t10 && r[1] * r[2] <= t10 ? s = [r[0], r[1] * r[2]] : r.length === 4 && r[0] * r[1] * r[2] <= t10 && r[3] <= t10 ? s = [r[0] * r[1] * r[2], r[3]] : r.length === 4 && r[0] <= t10 && r[1] * r[2] * r[3] <= t10 && (s = [r[0], r[1] * r[2] * r[3]]);
+function jS(r, e = false) {
+ let t6 = O().getNumber("WEBGL_MAX_TEXTURE_SIZE"), o = O().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");
+ o === 1 / 0 && O().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (o = t6 / 2), e && (t6 = t6 * 2, o = o * 2, r = r.map((i, p) => p >= r.length - 2 ? y.nearestLargerEven(r[p]) : r[p]), r.length === 1 && (r = [2, r[0]])), r.length !== 2 && (r = y.squeezeShape(r).newShape);
+ let n = y.sizeFromShape(r), s = null;
+ r.length <= 1 && n <= t6 ? s = [1, n] : r.length === 2 && r[0] <= t6 && r[1] <= t6 ? s = r : r.length === 3 && r[0] * r[1] <= t6 && r[2] <= t6 ? s = [r[0] * r[1], r[2]] : r.length === 3 && r[0] <= t6 && r[1] * r[2] <= t6 ? s = [r[0], r[1] * r[2]] : r.length === 4 && r[0] * r[1] * r[2] <= t6 && r[3] <= t6 ? s = [r[0] * r[1] * r[2], r[3]] : r.length === 4 && r[0] <= t6 && r[1] * r[2] * r[3] <= t6 && (s = [r[0], r[1] * r[2] * r[3]]);
let a = s != null && Math.max(...s) > o && Math.min(...s) <= (e ? 2 : 1) && Math.min(...s) > 0;
if (s == null || a)
if (e) {
- let i = Pa(r), p = 2, u = 2;
- r.length && ([p, u] = Oa(r)), n = i * (p / 2) * (u / 2), s = x.sizeToSquarishShape(n).map((c) => c * 2);
+ let i = Va(r), p = 2, u = 2;
+ r.length && ([p, u] = za(r)), n = i * (p / 2) * (u / 2), s = y.sizeToSquarishShape(n).map((c) => c * 2);
} else
- s = x.sizeToSquarishShape(n);
+ s = y.sizeToSquarishShape(n);
return s;
}
-function Ld(r) {
+function Tf(r) {
return r % 2 === 0;
}
-function Ti(r, e) {
- if (r = r.slice(-2), e = e.slice(-2), x.arraysEqual(r, e) || !r.length || !e.length || r[0] === 0 || r[1] === 0 || e[0] === 0 || e[1] === 0)
+function Li(r, e) {
+ if (r = r.slice(-2), e = e.slice(-2), y.arraysEqual(r, e) || !r.length || !e.length || r[0] === 0 || r[1] === 0 || e[0] === 0 || e[1] === 0)
return true;
if (r.length !== e.length) {
- let t10 = r.slice(-1)[0], o = e.slice(-1)[0];
- if (t10 === o || Ld(t10) && Ld(o) && (r[0] === 1 || e[0] === 1))
+ let t6 = r.slice(-1)[0], o = e.slice(-1)[0];
+ if (t6 === o || Tf(t6) && Tf(o) && (r[0] === 1 || e[0] === 1))
return true;
}
- return r[1] === e[1] && Ld(r[0]) && Ld(e[0]);
+ return r[1] === e[1] && Tf(r[0]) && Tf(e[0]);
}
-var Bd;
-var Vd;
-function ew(r) {
- if (Bd == null) {
- let e = Gr(r);
- Bd = e.getParameter(e.MAX_TEXTURE_SIZE);
+var _f;
+var Ef;
+function XS(r) {
+ if (_f == null) {
+ let e = Wr(r);
+ _f = e.getParameter(e.MAX_TEXTURE_SIZE);
}
- return Bd;
+ return _f;
}
-function d8() {
- Bd = null;
+function P5() {
+ _f = null;
}
-function h8() {
- Vd = null;
+function M5() {
+ Ef = null;
}
-function tw(r) {
- if (Vd == null) {
- let e = Gr(r);
- Vd = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);
+function YS(r) {
+ if (Ef == null) {
+ let e = Wr(r);
+ Ef = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);
}
- return Math.min(16, Vd);
+ return Math.min(16, Ef);
}
-function rw(r) {
+function QS(r) {
if (r === 0)
return 0;
- let e, t10 = Gr(r);
- return Hr(t10, "EXT_disjoint_timer_query_webgl2") && r === 2 ? e = 2 : Hr(t10, "EXT_disjoint_timer_query") ? e = 1 : e = 0, e;
+ let e, t6 = Wr(r);
+ return Ur(t6, "EXT_disjoint_timer_query_webgl2") && r === 2 ? e = 2 : Ur(t6, "EXT_disjoint_timer_query") ? e = 1 : e = 0, e;
}
-function Hr(r, e) {
+function Ur(r, e) {
return r.getExtension(e) != null;
}
-function Gd(r) {
+function Ff(r) {
try {
- if (Gr(r) != null)
+ if (Wr(r) != null)
return true;
} catch (e) {
return console.log("Error when getting WebGL context: ", e), false;
}
return false;
}
-function ow(r) {
+function ZS(r) {
if (r === 0)
return false;
- let e = Gr(r);
+ let e = Wr(r);
if (r === 1) {
- if (!Hr(e, "OES_texture_float"))
+ if (!Ur(e, "OES_texture_float"))
return false;
- } else if (!Hr(e, "EXT_color_buffer_float"))
+ } else if (!Ur(e, "EXT_color_buffer_float"))
return false;
- return BI(e);
+ return DS(e);
}
-function nw(r) {
+function JS(r) {
if (r === 0)
return false;
- let e = Gr(r);
+ let e = Wr(r);
if (r === 1) {
- if (!Hr(e, "OES_texture_float") || !Hr(e, "WEBGL_color_buffer_float"))
+ if (!Ur(e, "OES_texture_float") || !Ur(e, "WEBGL_color_buffer_float"))
return false;
} else {
- if (Hr(e, "EXT_color_buffer_float"))
- return BI(e);
+ if (Ur(e, "EXT_color_buffer_float"))
+ return DS(e);
let o = "EXT_color_buffer_half_float";
- if (Hr(e, o)) {
+ if (Ur(e, o)) {
let n = e.getExtension(o);
- return g8(e, n);
+ return L5(e, n);
}
return false;
}
- return BI(e);
+ return DS(e);
}
-function BI(r) {
- let e = El(r), t10 = r.createTexture();
- r.bindTexture(r.TEXTURE_2D, t10);
+function DS(r) {
+ let e = Sl(r), t6 = r.createTexture();
+ r.bindTexture(r.TEXTURE_2D, t6);
let o = 1, n = 1;
r.texImage2D(r.TEXTURE_2D, 0, e.internalFormatFloat, o, n, 0, e.textureFormatFloat, e.textureTypeFloat, null);
let s = r.createFramebuffer();
- r.bindFramebuffer(r.FRAMEBUFFER, s), r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, t10, 0);
+ r.bindFramebuffer(r.FRAMEBUFFER, s), r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, t6, 0);
let a = r.checkFramebufferStatus(r.FRAMEBUFFER) === r.FRAMEBUFFER_COMPLETE;
- return r.bindTexture(r.TEXTURE_2D, null), r.bindFramebuffer(r.FRAMEBUFFER, null), r.deleteTexture(t10), r.deleteFramebuffer(s), a;
+ return r.bindTexture(r.TEXTURE_2D, null), r.bindFramebuffer(r.FRAMEBUFFER, null), r.deleteTexture(t6), r.deleteFramebuffer(s), a;
}
-function g8(r, e) {
- let t10 = El(r, e), o = r.createTexture();
+function L5(r, e) {
+ let t6 = Sl(r, e), o = r.createTexture();
r.bindTexture(r.TEXTURE_2D, o);
let n = 1, s = 1;
- r.texImage2D(r.TEXTURE_2D, 0, t10.internalFormatHalfFloat, n, s, 0, t10.textureFormatFloat, t10.textureTypeHalfFloat, null);
+ r.texImage2D(r.TEXTURE_2D, 0, t6.internalFormatHalfFloat, n, s, 0, t6.textureFormatFloat, t6.textureTypeHalfFloat, null);
let a = r.createFramebuffer();
r.bindFramebuffer(r.FRAMEBUFFER, a), r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, o, 0);
let i = r.checkFramebufferStatus(r.FRAMEBUFFER) === r.FRAMEBUFFER_COMPLETE;
return r.bindTexture(r.TEXTURE_2D, null), r.bindFramebuffer(r.FRAMEBUFFER, null), r.deleteTexture(o), r.deleteFramebuffer(a), i;
}
-function sw(r) {
- return r !== 2 ? false : Gr(r).fenceSync != null;
+function ew(r) {
+ return r !== 2 ? false : Wr(r).fenceSync != null;
}
-function as(r, e) {
- Array.isArray(r) || (r = [r]), r.forEach((t10) => {
- t10 != null && x.assert(t10.dtype !== "complex64", () => `${e} does not support complex64 tensors in the WebGL backend.`);
+function is(r, e) {
+ Array.isArray(r) || (r = [r]), r.forEach((t6) => {
+ t6 != null && y.assert(t6.dtype !== "complex64", () => `${e} does not support complex64 tensors in the WebGL backend.`);
});
}
-var Ce = P();
+var Ce = O();
Ce.registerFlag("HAS_WEBGL", () => Ce.getNumber("WEBGL_VERSION") > 0);
-Ce.registerFlag("WEBGL_VERSION", () => Gd(2) ? 2 : Gd(1) ? 1 : 0);
+Ce.registerFlag("WEBGL_VERSION", () => Ff(2) ? 2 : Ff(1) ? 1 : 0);
Ce.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS", () => false);
Ce.registerFlag("WEBGL_BUFFER_SUPPORTED", () => Ce.get("WEBGL_VERSION") === 2);
Ce.registerFlag("WEBGL_CPU_FORWARD", () => true);
@@ -15200,23 +15246,23 @@ Ce.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS", () => Ce.getBool("WEBGL_PACK"));
Ce.registerFlag("WEBGL_PACK_REDUCE", () => Ce.getBool("WEBGL_PACK"));
Ce.registerFlag("WEBGL_LAZILY_UNPACK", () => Ce.getBool("WEBGL_PACK"));
Ce.registerFlag("WEBGL_CONV_IM2COL", () => Ce.getBool("WEBGL_PACK"));
-Ce.registerFlag("WEBGL_MAX_TEXTURE_SIZE", () => ew(Ce.getNumber("WEBGL_VERSION")));
-Ce.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER", () => tw(Ce.getNumber("WEBGL_VERSION")));
+Ce.registerFlag("WEBGL_MAX_TEXTURE_SIZE", () => XS(Ce.getNumber("WEBGL_VERSION")));
+Ce.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER", () => YS(Ce.getNumber("WEBGL_VERSION")));
Ce.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION", () => {
let r = Ce.getNumber("WEBGL_VERSION");
- return r === 0 ? 0 : rw(r);
+ return r === 0 ? 0 : QS(r);
});
-Ce.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE", () => Ce.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 && !ii.isMobile());
-Ce.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE", () => ow(Ce.getNumber("WEBGL_VERSION")));
+Ce.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE", () => Ce.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 && !yi.isMobile());
+Ce.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE", () => ZS(Ce.getNumber("WEBGL_VERSION")));
Ce.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED", () => Ce.getBool("WEBGL_FORCE_F16_TEXTURES") ? false : Ce.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));
-Ce.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED", () => nw(Ce.getNumber("WEBGL_VERSION")));
-Ce.registerFlag("WEBGL_FENCE_API_ENABLED", () => sw(Ce.getNumber("WEBGL_VERSION")));
+Ce.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED", () => JS(Ce.getNumber("WEBGL_VERSION")));
+Ce.registerFlag("WEBGL_FENCE_API_ENABLED", () => ew(Ce.getNumber("WEBGL_VERSION")));
Ce.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM", () => Ce.getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? 4 : 0);
Ce.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD", () => -1, (r) => {
if (r < 0 && r !== -1)
throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${r}.`);
});
-Ce.registerFlag("WEBGL_FLUSH_THRESHOLD", () => ii.isMobile() ? 1 : -1, (r) => {
+Ce.registerFlag("WEBGL_FLUSH_THRESHOLD", () => yi.isMobile() ? 1 : -1, (r) => {
if (r < 0 && r !== -1)
throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${r}.`);
});
@@ -15229,9 +15275,10 @@ Ce.registerFlag("SOFTWARE_WEBGL_ENABLED", () => Ce.getBool("IS_TEST"));
Ce.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE", () => 1 / 0);
Ce.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE", () => false);
Ce.registerFlag("WEBGL2_ISNAN_CUSTOM", () => false);
-function Ct() {
- let r, e, t10, o, n, s, a, i, p, u;
- return P().getNumber("WEBGL_VERSION") === 2 ? (r = "#version 300 es", e = "in", t10 = "out", o = "in", n = "texture", s = "outputColor", a = "out vec4 outputColor;", i = P().getBool("WEBGL2_ISNAN_CUSTOM") ? `
+Ce.registerFlag("ENGINE_COMPILE_ONLY", () => false);
+function St() {
+ let r, e, t6, o, n, s, a, i, p, u;
+ return O().getNumber("WEBGL_VERSION") === 2 ? (r = "#version 300 es", e = "in", t6 = "out", o = "in", n = "texture", s = "outputColor", a = "out vec4 outputColor;", i = O().getBool("WEBGL2_ISNAN_CUSTOM") ? `
bool isnan_custom(float val) {
uint floatToUint = floatBitsToUint(val);
return (floatToUint & 0x7fffffffu) > 0x7f800000u;
@@ -15252,7 +15299,7 @@ function Ct() {
ivec4 newRound(vec4 value) {
return ivec4(floor(value + vec4(0.5)));
}
- `) : (r = "", e = "attribute", t10 = "varying", o = "varying", n = "texture2D", s = "gl_FragColor", a = "", i = `
+ `) : (r = "", e = "attribute", t6 = "varying", o = "varying", n = "texture2D", s = "gl_FragColor", a = "", i = `
#define isnan(value) isnan_custom(value)
bool isnan_custom(float val) {
return (val > 0. || val < 1. || val == 0.) ? false : true;
@@ -15277,52 +15324,52 @@ function Ct() {
ivec4 round(vec4 value) {
return ivec4(floor(value + vec4(0.5)));
}
- `), { version: r, attribute: e, varyingVs: t10, varyingFs: o, texture2D: n, output: s, defineOutput: a, defineSpecialNaN: i, defineSpecialInf: p, defineRound: u };
+ `), { version: r, attribute: e, varyingVs: t6, varyingFs: o, texture2D: n, output: s, defineOutput: a, defineSpecialNaN: i, defineSpecialInf: p, defineRound: u };
}
-function is(r, e, t10 = "index") {
- let o = x.computeStrides(e);
+function us(r, e, t6 = "index") {
+ let o = y.computeStrides(e);
return o.map((n, s) => {
- let a = `int ${r[s]} = ${t10} / ${n}`, i = s === o.length - 1 ? `int ${r[s + 1]} = ${t10} - ${r[s]} * ${n}` : `index -= ${r[s]} * ${n}`;
+ let a = `int ${r[s]} = ${t6} / ${n}`, i = s === o.length - 1 ? `int ${r[s + 1]} = ${t6} - ${r[s]} * ${n}` : `index -= ${r[s]} * ${n}`;
return `${a}; ${i};`;
}).join("");
}
-function Ru(r, e, t10 = "index") {
- let o = x.computeStrides(e);
+function Au(r, e, t6 = "index") {
+ let o = y.computeStrides(e);
return o.map((n, s) => {
- let a = `int ${r[s]} = ${t10} / outShapeStrides[${s}]`, i = s === o.length - 1 ? `int ${r[s + 1]} = ${t10} - ${r[s]} * outShapeStrides[${s}]` : `index -= ${r[s]} * outShapeStrides[${s}]`;
+ let a = `int ${r[s]} = ${t6} / outShapeStrides[${s}]`, i = s === o.length - 1 ? `int ${r[s + 1]} = ${t6} - ${r[s]} * outShapeStrides[${s}]` : `index -= ${r[s]} * outShapeStrides[${s}]`;
return `${a}; ${i};`;
}).join("");
}
-function x8(r, e) {
- let t10 = r.length, o = r.map((s) => `${e}[${s}]`), n = new Array(t10 - 1);
- n[t10 - 2] = o[t10 - 1];
- for (let s = t10 - 3; s >= 0; --s)
+function B5(r, e) {
+ let t6 = r.length, o = r.map((s) => `${e}[${s}]`), n = new Array(t6 - 1);
+ n[t6 - 2] = o[t6 - 1];
+ for (let s = t6 - 3; s >= 0; --s)
n[s] = `(${n[s + 1]} * ${o[s + 1]})`;
return n;
}
-function YE(r, e, t10 = "index") {
- let o = r.map((s, a) => a), n = x8(o, e);
+function kE(r, e, t6 = "index") {
+ let o = r.map((s, a) => a), n = B5(o, e);
return n.map((s, a) => {
- let i = `int ${r[a]} = ${t10} / ${n[a]}`, p = a === n.length - 1 ? `int ${r[a + 1]} = ${t10} - ${r[a]} * ${n[a]}` : `index -= ${r[a]} * ${n[a]}`;
+ let i = `int ${r[a]} = ${t6} / ${n[a]}`, p = a === n.length - 1 ? `int ${r[a + 1]} = ${t6} - ${r[a]} * ${n[a]}` : `index -= ${r[a]} * ${n[a]}`;
return `${i}; ${p};`;
}).join("");
}
-function uc(r) {
- let e = x.computeStrides(r).map((t10) => t10.toString());
+function nc(r) {
+ let e = y.computeStrides(r).map((t6) => t6.toString());
return `
int getFlatIndex(ivec3 coords) {
return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z;
}
`;
}
-function pc() {
+function sc() {
return `
int getFlatIndex(ivec3 coords) {
return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
}
`;
}
-var Hd = `
+var Df = `
const float FLOAT_MAX = 1.70141184e38;
const float FLOAT_MIN = 1.17549435e-38;
@@ -15362,32 +15409,32 @@ var Hd = `
return c / 255.0;
}
`;
-var { getBroadcastDims: QE } = I;
-function ZE(r, e, t10) {
+var { getBroadcastDims: NE } = S;
+function TE(r, e, t6) {
let o = [];
- if (r.forEach((f) => {
- let d = x.sizeFromShape(f.shapeInfo.logicalShape);
- if (f.shapeInfo.isUniform ? o.push(`uniform float ${f.name}${d > 1 ? `[${d}]` : ""};`) : (o.push(`uniform sampler2D ${f.name};`), o.push(`uniform int offset${f.name};`)), t10.enableShapeUniforms) {
- let { uniformShape: h } = qd(t10.packedInputs, f.shapeInfo.logicalShape, f.shapeInfo.texShape);
+ if (r.forEach((d) => {
+ let f = y.sizeFromShape(d.shapeInfo.logicalShape);
+ if (d.shapeInfo.isUniform ? o.push(`uniform float ${d.name}${f > 1 ? `[${f}]` : ""};`) : (o.push(`uniform sampler2D ${d.name};`), o.push(`uniform int offset${d.name};`)), t6.enableShapeUniforms) {
+ let { uniformShape: h } = Of(t6.packedInputs, d.shapeInfo.logicalShape, d.shapeInfo.texShape);
switch (h.length) {
case 1:
- o.push(`uniform int ${f.name}Shape;`);
+ o.push(`uniform int ${d.name}Shape;`);
break;
case 2:
- o.push(`uniform ivec2 ${f.name}Shape;`);
+ o.push(`uniform ivec2 ${d.name}Shape;`);
break;
case 3:
- o.push(`uniform ivec3 ${f.name}Shape;`);
+ o.push(`uniform ivec3 ${d.name}Shape;`);
break;
case 4:
- o.push(`uniform ivec4 ${f.name}Shape;`);
+ o.push(`uniform ivec4 ${d.name}Shape;`);
break;
default:
break;
}
- o.push(`uniform ivec2 ${f.name}TexShape;`);
+ o.push(`uniform ivec2 ${d.name}TexShape;`);
}
- }), t10.enableShapeUniforms) {
+ }), t6.enableShapeUniforms) {
switch (e.logicalShape.length) {
case 1:
o.push("uniform int outShape;");
@@ -15406,112 +15453,112 @@ function ZE(r, e, t10) {
}
o.push("uniform ivec2 outTexShape;");
}
- t10.customUniforms && t10.customUniforms.forEach((f) => {
- o.push(`uniform ${f.type} ${f.name}${f.arrayIndex ? `[${f.arrayIndex}]` : ""};`);
+ t6.customUniforms && t6.customUniforms.forEach((d) => {
+ o.push(`uniform ${d.type} ${d.name}${d.arrayIndex ? `[${d.arrayIndex}]` : ""};`);
});
let n = o.join(`
-`), s = r.map((f) => y8(f, e, t10.packedInputs, t10.enableShapeUniforms)).join(`
-`), a = e.texShape, i = Ct(), p = I8(i), u, c, l = v8(i);
- return e.isPacked ? (u = b8(e.logicalShape, a, t10.enableShapeUniforms), c = S8(i)) : (u = C8(e.logicalShape, a, t10.enableShapeUniforms), c = w8(i)), t10.packedInputs && (l += _8), [l, p, c, n, u, s, t10.userCode].join(`
+`), s = r.map((d) => V5(d, e, t6.packedInputs, t6.enableShapeUniforms)).join(`
+`), a = e.texShape, i = St(), p = U5(i), u, c, l = q5(i);
+ return e.isPacked ? (u = z5(e.logicalShape, a, t6.enableShapeUniforms), c = H5(i)) : (u = W5(e.logicalShape, a, t6.enableShapeUniforms), c = G5(i)), t6.packedInputs && (l += Y5), [l, p, c, n, u, s, t6.userCode].join(`
`);
}
-function lc(r, e = false) {
- let t10 = r.shapeInfo.logicalShape;
- switch (t10.length) {
+function ic(r, e = false) {
+ let t6 = r.shapeInfo.logicalShape;
+ switch (t6.length) {
case 0:
- return V8(r, e);
+ return u8(r, e);
case 1:
- return W8(r, e);
+ return c8(r, e);
case 2:
- return G8(r, e);
+ return m8(r, e);
case 3:
- return q8(r, e);
+ return f8(r, e);
case 4:
- return j8(r, e);
+ return g8(r, e);
case 5:
- return X8(r);
+ return x8(r);
case 6:
- return Y8(r);
+ return y8(r);
default:
- throw new Error(`${t10.length}-D input sampling is not yet supported`);
+ throw new Error(`${t6.length}-D input sampling is not yet supported`);
}
}
-function JE(r, e) {
+function _E(r, e) {
switch (r.shapeInfo.logicalShape.length) {
case 0:
- return B8(r);
+ return i8(r);
case 1:
- return z8(r, e);
+ return p8(r, e);
case 2:
- return U8(r, e);
+ return l8(r, e);
case 3:
- return H8(r, e);
+ return d8(r, e);
default:
- return K8(r, e);
+ return h8(r, e);
}
}
-function y8(r, e, t10 = false, o) {
+function V5(r, e, t6 = false, o) {
let n = "";
- t10 ? n += JE(r, o) : n += lc(r, o);
+ t6 ? n += _E(r, o) : n += ic(r, o);
let s = r.shapeInfo.logicalShape, a = e.logicalShape;
- return s.length <= a.length && (t10 ? n += Q8(r, e) : n += Z8(r, e)), n;
+ return s.length <= a.length && (t6 ? n += b8(r, e) : n += C8(r, e)), n;
}
-function b8(r, e, t10) {
+function z5(r, e, t6) {
switch (r.length) {
case 0:
- return e$();
+ return EE();
case 1:
- return E8(r, e, t10);
+ return Q5(r, e, t6);
case 2:
- return M8(r, e, t10);
+ return s8(r, e, t6);
case 3:
- return R8(r, e, t10);
+ return J5(r, e, t6);
default:
- return F8(r, e, t10);
+ return t8(r, e, t6);
}
}
-function C8(r, e, t10) {
+function W5(r, e, t6) {
switch (r.length) {
case 0:
- return e$();
+ return EE();
case 1:
- return $8(r, e, t10);
+ return Z5(r, e, t6);
case 2:
- return L8(r, e, t10);
+ return a8(r, e, t6);
case 3:
- return A8(r, e, t10);
+ return e8(r, e, t6);
case 4:
- return D8(r, e, t10);
+ return r8(r, e, t6);
case 5:
- return P8(r, e);
+ return o8(r, e);
case 6:
- return O8(r, e);
+ return n8(r, e);
default:
throw new Error(`${r.length}-D output sampling is not yet supported`);
}
}
-function I8(r) {
+function U5(r) {
return `
float sampleTexture(sampler2D textureSampler, vec2 uv) {
return ${r.texture2D}(textureSampler, uv).r;
}
`;
}
-function w8(r) {
+function G5(r) {
return `
void setOutput(float val) {
${r.output} = vec4(val, 0, 0, 0);
}
`;
}
-function S8(r) {
+function H5(r) {
return `
void setOutput(vec4 val) {
${r.output} = val;
}
`;
}
-function v8(r) {
+function q5(r) {
return `${r.version}
precision highp float;
precision highp int;
@@ -15567,12 +15614,12 @@ function v8(r) {
return fract((p3.x + p3.y) * p3.z);
}
- ${k8}
- ${T8}
- ${N8}
+ ${K5}
+ ${j5}
+ ${X5}
`;
}
-var k8 = `
+var K5 = `
vec2 uvFromFlat(int texNumR, int texNumC, int index) {
int texR = index / texNumC;
int texC = index - texR * texNumC;
@@ -15585,7 +15632,7 @@ vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
`;
-var T8 = `
+var j5 = `
vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
int texNumC, int row, int col) {
int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
@@ -15594,7 +15641,7 @@ vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
`;
-var N8 = `
+var X5 = `
vec2 packedUVfrom3D(int texNumR, int texNumC,
int texelsInBatch, int texelsInLogicalRow, int b,
int row, int col) {
@@ -15604,7 +15651,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC,
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
`;
-var _8 = `
+var Y5 = `
float getChannel(vec4 frag, vec2 innerDims) {
vec2 modCoord = mod(innerDims, 2.);
return modCoord.x == 0. ?
@@ -15616,16 +15663,16 @@ var _8 = `
return modCoord == 0. ? frag.r : frag.g;
}
`;
-function e$() {
+function EE() {
return `
int getOutputCoords() {
return 0;
}
`;
}
-function E8(r, e, t10) {
+function Q5(r, e, t6) {
let o = [Math.ceil(e[0] / 2), Math.ceil(e[1] / 2)];
- return o[0] === 1 ? t10 ? `
+ return o[0] === 1 ? t6 ? `
int getOutputCoords() {
return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));
}
@@ -15633,7 +15680,7 @@ function E8(r, e, t10) {
int getOutputCoords() {
return 2 * int(resultUV.x * ${o[1]}.0);
}
- ` : o[1] === 1 ? t10 ? `
+ ` : o[1] === 1 ? t6 ? `
int getOutputCoords() {
return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));
}
@@ -15641,7 +15688,7 @@ function E8(r, e, t10) {
int getOutputCoords() {
return 2 * int(resultUV.y * ${o[0]}.0);
}
- ` : t10 ? `
+ ` : t6 ? `
int getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
ivec2 resTexRC = ivec2(resultUV.yx *
@@ -15656,8 +15703,8 @@ function E8(r, e, t10) {
}
`;
}
-function $8(r, e, t10) {
- return e[0] === 1 ? t10 ? `
+function Z5(r, e, t6) {
+ return e[0] === 1 ? t6 ? `
int getOutputCoords() {
return int(resultUV.x * float(outTexShape[1]));
}
@@ -15665,7 +15712,7 @@ function $8(r, e, t10) {
int getOutputCoords() {
return int(resultUV.x * ${e[1]}.0);
}
- ` : e[1] === 1 ? t10 ? `
+ ` : e[1] === 1 ? t6 ? `
int getOutputCoords() {
return int(resultUV.y * float(outTexShape[0]));
}
@@ -15673,7 +15720,7 @@ function $8(r, e, t10) {
int getOutputCoords() {
return int(resultUV.y * ${e[0]}.0);
}
- ` : t10 ? `
+ ` : t6 ? `
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
@@ -15687,8 +15734,8 @@ function $8(r, e, t10) {
}
`;
}
-function R8(r, e, t10) {
- if (t10)
+function J5(r, e, t6) {
+ if (t6)
return `
ivec3 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
@@ -15724,18 +15771,18 @@ function R8(r, e, t10) {
}
`;
}
-function A8(r, e, t10) {
- if (t10)
+function e8(r, e, t6) {
+ if (t6)
return `
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
- ${Ru(["r", "c", "d"], r)}
+ ${Au(["r", "c", "d"], r)}
return ivec3(r, c, d);
}
`;
- let o = is(["r", "c", "d"], r);
+ let o = us(["r", "c", "d"], r);
return `
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
@@ -15746,8 +15793,8 @@ function A8(r, e, t10) {
}
`;
}
-function F8(r, e, t10) {
- if (t10)
+function t8(r, e, t6) {
+ if (t6)
return `
ivec4 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
@@ -15795,18 +15842,18 @@ function F8(r, e, t10) {
}
`;
}
-function D8(r, e, t10) {
- if (t10)
+function r8(r, e, t6) {
+ if (t6)
return `
ivec4 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
- ${Ru(["r", "c", "d", "d2"], r)}
+ ${Au(["r", "c", "d", "d2"], r)}
return ivec4(r, c, d, d2);
}
`;
- let o = is(["r", "c", "d", "d2"], r);
+ let o = us(["r", "c", "d", "d2"], r);
return `
ivec4 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
@@ -15817,8 +15864,8 @@ function D8(r, e, t10) {
}
`;
}
-function P8(r, e) {
- let t10 = is(["r", "c", "d", "d2", "d3"], r);
+function o8(r, e) {
+ let t6 = us(["r", "c", "d", "d2", "d3"], r);
return `
ivec5 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]},
@@ -15826,32 +15873,32 @@ function P8(r, e) {
int index = resTexRC.x * ${e[1]} + resTexRC.y;
- ${t10}
+ ${t6}
ivec5 outShape = ivec5(r, c, d, d2, d3);
return outShape;
}
`;
}
-function O8(r, e) {
- let t10 = is(["r", "c", "d", "d2", "d3", "d4"], r);
+function n8(r, e) {
+ let t6 = us(["r", "c", "d", "d2", "d3", "d4"], r);
return `
ivec6 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
- ${t10}
+ ${t6}
ivec6 result = ivec6(r, c, d, d2, d3, d4);
return result;
}
`;
}
-function M8(r, e, t10) {
+function s8(r, e, t6) {
let o = [Math.ceil(e[0] / 2), Math.ceil(e[1] / 2)];
- if (x.arraysEqual(r, e))
- return t10 ? `
+ if (y.arraysEqual(r, e))
+ return t6 ? `
ivec2 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));
@@ -15862,7 +15909,7 @@ function M8(r, e, t10) {
}
`;
let n = Math.ceil(r[1] / 2);
- return t10 ? `
+ return t6 ? `
ivec2 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));
@@ -15888,8 +15935,8 @@ function M8(r, e, t10) {
}
`;
}
-function L8(r, e, t10) {
- return x.arraysEqual(r, e) ? t10 ? `
+function a8(r, e, t6) {
+ return y.arraysEqual(r, e) ? t6 ? `
ivec2 getOutputCoords() {
return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));
}
@@ -15897,7 +15944,7 @@ function L8(r, e, t10) {
ivec2 getOutputCoords() {
return ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]}));
}
- ` : r[1] === 1 ? t10 ? `
+ ` : r[1] === 1 ? t6 ? `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
@@ -15911,7 +15958,7 @@ function L8(r, e, t10) {
int index = resTexRC.x * ${e[1]} + resTexRC.y;
return ivec2(index, 0);
}
- ` : r[0] === 1 ? t10 ? `
+ ` : r[0] === 1 ? t6 ? `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
@@ -15925,7 +15972,7 @@ function L8(r, e, t10) {
int index = resTexRC.x * ${e[1]} + resTexRC.y;
return ivec2(0, index);
}
- ` : t10 ? `
+ ` : t6 ? `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
@@ -15945,53 +15992,53 @@ function L8(r, e, t10) {
}
`;
}
-function Au(r) {
+function Ru(r) {
return `offset${r}`;
}
-function B8(r) {
- let e = r.name, t10 = "get" + e.charAt(0).toUpperCase() + e.slice(1), o = Ct();
+function i8(r) {
+ let e = r.name, t6 = "get" + e.charAt(0).toUpperCase() + e.slice(1), o = St();
return `
- vec4 ${t10}() {
+ vec4 ${t6}() {
return ${o.texture2D}(${e}, halfCR);
}
`;
}
-function V8(r, e) {
- let t10 = r.name, o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1);
+function u8(r, e) {
+ let t6 = r.name, o = "get" + t6.charAt(0).toUpperCase() + t6.slice(1);
if (r.shapeInfo.isUniform)
- return `float ${o}() {return ${t10};}`;
+ return `float ${o}() {return ${t6};}`;
let [n, s] = r.shapeInfo.texShape;
if (n === 1 && s === 1)
return `
float ${o}() {
- return sampleTexture(${t10}, halfCR);
+ return sampleTexture(${t6}, halfCR);
}
`;
- let a = Au(t10);
+ let a = Ru(t6);
if (e)
return `
float ${o}() {
- vec2 uv = uvFromFlat(${t10}TexShape[0], ${t10}TexShape[1], ${a});
- return sampleTexture(${t10}, uv);
+ vec2 uv = uvFromFlat(${t6}TexShape[0], ${t6}TexShape[1], ${a});
+ return sampleTexture(${t6}, uv);
}
`;
let [i, p] = r.shapeInfo.texShape;
return `
float ${o}() {
vec2 uv = uvFromFlat(${i}, ${p}, ${a});
- return sampleTexture(${t10}, uv);
+ return sampleTexture(${t6}, uv);
}
`;
}
-function z8(r, e) {
- let t10 = r.name, o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1), n = r.shapeInfo.texShape, s = Ct();
+function p8(r, e) {
+ let t6 = r.name, o = "get" + t6.charAt(0).toUpperCase() + t6.slice(1), n = r.shapeInfo.texShape, s = St();
if (e)
return `
vec4 ${o}(int index) {
- ivec2 packedTexShape = ivec2(ceil(float(${t10}TexShape[0]) / 2.0), ceil(float(${t10}TexShape[1]) / 2.0));
+ ivec2 packedTexShape = ivec2(ceil(float(${t6}TexShape[0]) / 2.0), ceil(float(${t6}TexShape[1]) / 2.0));
vec2 uv = packedUVfrom1D(
packedTexShape[0], packedTexShape[1], index);
- return ${s.texture2D}(${t10}, uv);
+ return ${s.texture2D}(${t6}, uv);
}
`;
let a = [Math.ceil(n[0] / 2), Math.ceil(n[1] / 2)];
@@ -15999,61 +16046,61 @@ function z8(r, e) {
vec4 ${o}(int index) {
vec2 uv = packedUVfrom1D(
${a[0]}, ${a[1]}, index);
- return ${s.texture2D}(${t10}, uv);
+ return ${s.texture2D}(${t6}, uv);
}
`;
}
-function W8(r, e) {
- let t10 = r.name, o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1);
+function c8(r, e) {
+ let t6 = r.name, o = "get" + t6.charAt(0).toUpperCase() + t6.slice(1);
if (r.shapeInfo.isUniform)
return `
float ${o}(int index) {
- ${mc(r)}
+ ${uc(r)}
}
`;
let n = r.shapeInfo.texShape, s = n[0], a = n[1];
if (a === 1 && s === 1)
return `
float ${o}(int index) {
- return sampleTexture(${t10}, halfCR);
+ return sampleTexture(${t6}, halfCR);
}
`;
- let i = Au(t10);
+ let i = Ru(t6);
return a === 1 ? e ? `
float ${o}(int index) {
- vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / float(${t10}TexShape[0]));
- return sampleTexture(${t10}, uv);
+ vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / float(${t6}TexShape[0]));
+ return sampleTexture(${t6}, uv);
}
` : `
float ${o}(int index) {
vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / ${s}.0);
- return sampleTexture(${t10}, uv);
+ return sampleTexture(${t6}, uv);
}
` : s === 1 ? e ? `
float ${o}(int index) {
- vec2 uv = vec2((float(index + ${i}) + 0.5) / float(${t10}TexShape[1]), 0.5);
- return sampleTexture(${t10}, uv);
+ vec2 uv = vec2((float(index + ${i}) + 0.5) / float(${t6}TexShape[1]), 0.5);
+ return sampleTexture(${t6}, uv);
}
` : `
float ${o}(int index) {
vec2 uv = vec2((float(index + ${i}) + 0.5) / ${a}.0, 0.5);
- return sampleTexture(${t10}, uv);
+ return sampleTexture(${t6}, uv);
}
` : e ? `
float ${o}(int index) {
- vec2 uv = uvFromFlat(${t10}TexShape[0], ${t10}TexShape[1], index + ${i});
- return sampleTexture(${t10}, uv);
+ vec2 uv = uvFromFlat(${t6}TexShape[0], ${t6}TexShape[1], index + ${i});
+ return sampleTexture(${t6}, uv);
}
` : `
float ${o}(int index) {
vec2 uv = uvFromFlat(${s}, ${a}, index + ${i});
- return sampleTexture(${t10}, uv);
+ return sampleTexture(${t6}, uv);
}
`;
}
-function U8(r, e) {
- let t10 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = r.shapeInfo.texShape, a = s[0], i = s[1], p = Ct();
- if (s != null && x.arraysEqual(t10, s))
+function l8(r, e) {
+ let t6 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = r.shapeInfo.texShape, a = s[0], i = s[1], p = St();
+ if (s != null && y.arraysEqual(t6, s))
return e ? `
vec4 ${n}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}TexShape[1], ${o}TexShape[0]);
@@ -16076,7 +16123,7 @@ function U8(r, e) {
return ${p.texture2D}(${o}, uv);
}
`;
- let u = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)], c = Math.ceil(t10[1] / 2);
+ let u = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)], c = Math.ceil(t6[1] / 2);
return `
vec4 ${n}(int row, int col) {
vec2 uv = packedUVfrom2D(${c}, ${u[0]}, ${u[1]}, row, col);
@@ -16084,9 +16131,9 @@ function U8(r, e) {
}
`;
}
-function G8(r, e) {
- let t10 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = r.shapeInfo.texShape;
- if (s != null && x.arraysEqual(t10, s)) {
+function m8(r, e) {
+ let t6 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = r.shapeInfo.texShape;
+ if (s != null && y.arraysEqual(t6, s)) {
if (e)
return `
float ${n}(int row, int col) {
@@ -16094,32 +16141,32 @@ function G8(r, e) {
return sampleTexture(${o}, uv);
}
`;
- let m = s[0], f = s[1];
+ let m = s[0], d = s[1];
return `
float ${n}(int row, int col) {
- vec2 uv = (vec2(col, row) + halfCR) / vec2(${f}.0, ${m}.0);
+ vec2 uv = (vec2(col, row) + halfCR) / vec2(${d}.0, ${m}.0);
return sampleTexture(${o}, uv);
}
`;
}
- let { newShape: a, keptDims: i } = x.squeezeShape(t10), p = a;
- if (p.length < t10.length) {
- let m = fc(r, p), f = ["row", "col"];
+ let { newShape: a, keptDims: i } = y.squeezeShape(t6), p = a;
+ if (p.length < t6.length) {
+ let m = pc(r, p), d = ["row", "col"];
return `
- ${lc(m, e)}
+ ${ic(m, e)}
float ${n}(int row, int col) {
- return ${n}(${dc(f, i)});
+ return ${n}(${cc(d, i)});
}
`;
}
if (r.shapeInfo.isUniform)
return `
float ${n}(int row, int col) {
- int index = round(dot(vec2(row, col), vec2(${t10[1]}, 1)));
- ${mc(r)}
+ int index = round(dot(vec2(row, col), vec2(${t6[1]}, 1)));
+ ${uc(r)}
}
`;
- let u = s[0], c = s[1], l = Au(o);
+ let u = s[0], c = s[1], l = Ru(o);
return c === 1 ? e ? `
float ${n}(int row, int col) {
float index = dot(vec3(row, col, ${l}), vec3(${o}Shape[1], 1, 1));
@@ -16128,7 +16175,7 @@ function G8(r, e) {
}
` : `
float ${n}(int row, int col) {
- float index = dot(vec3(row, col, ${l}), vec3(${t10[1]}, 1, 1));
+ float index = dot(vec3(row, col, ${l}), vec3(${t6[1]}, 1, 1));
vec2 uv = vec2(0.5, (index + 0.5) / ${u}.0);
return sampleTexture(${o}, uv);
}
@@ -16140,7 +16187,7 @@ function G8(r, e) {
}
` : `
float ${n}(int row, int col) {
- float index = dot(vec3(row, col, ${l}), vec3(${t10[1]}, 1, 1));
+ float index = dot(vec3(row, col, ${l}), vec3(${t6[1]}, 1, 1));
vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);
return sampleTexture(${o}, uv);
}
@@ -16154,24 +16201,24 @@ function G8(r, e) {
` : `
float ${n}(int row, int col) {
// Explicitly use integer operations as dot() only works on floats.
- int index = row * ${t10[1]} + col + ${l};
+ int index = row * ${t6[1]} + col + ${l};
vec2 uv = uvFromFlat(${u}, ${c}, index);
return sampleTexture(${o}, uv);
}
`;
}
-function H8(r, e) {
- let t10 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = r.shapeInfo.texShape, a = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)];
- if (t10[0] === 1) {
- let m = t10.slice(1), f = [1, 2], d = fc(r, m), h = ["b", "row", "col"];
+function d8(r, e) {
+ let t6 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = r.shapeInfo.texShape, a = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)];
+ if (t6[0] === 1) {
+ let m = t6.slice(1), d = [1, 2], f = pc(r, m), h = ["b", "row", "col"];
return `
- ${JE(d, e)}
+ ${_E(f, e)}
vec4 ${n}(int b, int row, int col) {
- return ${n}(${dc(h, f)});
+ return ${n}(${cc(h, d)});
}
`;
}
- let i = Ct();
+ let i = St();
if (e)
return `
vec4 ${n}(int b, int row, int col) {
@@ -16183,7 +16230,7 @@ function H8(r, e) {
return ${i.texture2D}(${o}, uv);
}
`;
- let p = a[0], u = a[1], c = Math.ceil(t10[2] / 2), l = c * Math.ceil(t10[1] / 2);
+ let p = a[0], u = a[1], c = Math.ceil(t6[2] / 2), l = c * Math.ceil(t6[1] / 2);
return `
vec4 ${n}(int b, int row, int col) {
vec2 uv = packedUVfrom3D(
@@ -16192,14 +16239,14 @@ function H8(r, e) {
}
`;
}
-function q8(r, e) {
- let t10 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = t10[1] * t10[2], a = t10[2], { newShape: i, keptDims: p } = x.squeezeShape(t10), u = i;
- if (u.length < t10.length) {
- let h = fc(r, u), g = ["row", "col", "depth"];
+function f8(r, e) {
+ let t6 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = t6[1] * t6[2], a = t6[2], { newShape: i, keptDims: p } = y.squeezeShape(t6), u = i;
+ if (u.length < t6.length) {
+ let h = pc(r, u), g = ["row", "col", "depth"];
return `
- ${lc(h, e)}
+ ${ic(h, e)}
float ${n}(int row, int col, int depth) {
- return ${n}(${dc(g, p)});
+ return ${n}(${cc(g, p)});
}
`;
}
@@ -16208,11 +16255,11 @@ function q8(r, e) {
float ${n}(int row, int col, int depth) {
int index = round(dot(vec3(row, col, depth),
vec3(${s}, ${a}, 1)));
- ${mc(r)}
+ ${uc(r)}
}
`;
- let c = r.shapeInfo.texShape, l = c[0], m = c[1], f = r.shapeInfo.flatOffset;
- if (m === s && f == null)
+ let c = r.shapeInfo.texShape, l = c[0], m = c[1], d = r.shapeInfo.flatOffset;
+ if (m === s && d == null)
return e ? `
float ${n}(int row, int col, int depth) {
int stride1 = ${o}Shape[2];
@@ -16231,7 +16278,7 @@ function q8(r, e) {
return sampleTexture(${o}, uv);
}
`;
- if (m === a && f == null)
+ if (m === a && d == null)
return e ? `
float ${n}(int row, int col, int depth) {
float texR = dot(vec2(row, col), vec2(${o}Shape[1], 1));
@@ -16241,68 +16288,68 @@ function q8(r, e) {
}
` : `
float ${n}(int row, int col, int depth) {
- float texR = dot(vec2(row, col), vec2(${t10[1]}, 1));
+ float texR = dot(vec2(row, col), vec2(${t6[1]}, 1));
float texC = float(depth);
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${m}.0, ${l}.0);
return sampleTexture(${o}, uv);
}
`;
- let d = Au(o);
+ let f = Ru(o);
return e ? `
float ${n}(int row, int col, int depth) {
// Explicitly use integer operations as dot() only works on floats.
int stride0 = ${o}Shape[1] * ${o}Shape[2];
int stride1 = ${o}Shape[2];
- int index = row * stride0 + col * stride1 + depth + ${d};
+ int index = row * stride0 + col * stride1 + depth + ${f};
vec2 uv = uvFromFlat(${o}TexShape[0], ${o}TexShape[1], index);
return sampleTexture(${o}, uv);
}
` : `
float ${n}(int row, int col, int depth) {
// Explicitly use integer operations as dot() only works on floats.
- int index = row * ${s} + col * ${a} + depth + ${d};
+ int index = row * ${s} + col * ${a} + depth + ${f};
vec2 uv = uvFromFlat(${l}, ${m}, index);
return sampleTexture(${o}, uv);
}
`;
}
-function K8(r, e) {
- let t10 = r.name, o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1), n = Ct();
+function h8(r, e) {
+ let t6 = r.name, o = "get" + t6.charAt(0).toUpperCase() + t6.slice(1), n = St();
if (e)
return `
vec4 ${o}(int b2, int b, int row, int col) {
- int valuesPerRow = int(ceil(float(${t10}Shape[3]) / 2.0));
- int texelsInBatch = valuesPerRow * int(ceil(float(${t10}Shape[2]) / 2.0));
+ int valuesPerRow = int(ceil(float(${t6}Shape[3]) / 2.0));
+ int texelsInBatch = valuesPerRow * int(ceil(float(${t6}Shape[2]) / 2.0));
int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);
- texelsInBatch *= ${t10}Shape[1];
+ texelsInBatch *= ${t6}Shape[1];
index = b2 * texelsInBatch + index;
- ivec2 packedTexShape = ivec2(ceil(float(${t10}TexShape[0]) / 2.0), ceil(float(${t10}TexShape[1]) / 2.0));
+ ivec2 packedTexShape = ivec2(ceil(float(${t6}TexShape[0]) / 2.0), ceil(float(${t6}TexShape[1]) / 2.0));
int texR = index / packedTexShape[1];
int texC = index - texR * packedTexShape[1];
- vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${n.texture2D}(${t10}, uv);
+ vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${n.texture2D}(${t6}, uv);
}
`;
- let s = r.shapeInfo.logicalShape, a = s.length, i = r.shapeInfo.texShape, p = [Math.ceil(i[0] / 2), Math.ceil(i[1] / 2)], u = p[0], c = p[1], l = Math.ceil(s[a - 1] / 2), m = l * Math.ceil(s[a - 2] / 2), f = "int b, int row, int col", d = `b * ${m} + (row / 2) * ${l} + (col / 2)`;
+ let s = r.shapeInfo.logicalShape, a = s.length, i = r.shapeInfo.texShape, p = [Math.ceil(i[0] / 2), Math.ceil(i[1] / 2)], u = p[0], c = p[1], l = Math.ceil(s[a - 1] / 2), m = l * Math.ceil(s[a - 2] / 2), d = "int b, int row, int col", f = `b * ${m} + (row / 2) * ${l} + (col / 2)`;
for (let h = 2; h < a - 1; h++)
- f = `int b${h}, ` + f, m *= s[a - h - 1], d = `b${h} * ${m} + ` + d;
+ d = `int b${h}, ` + d, m *= s[a - h - 1], f = `b${h} * ${m} + ` + f;
return `
- vec4 ${o}(${f}) {
- int index = ${d};
+ vec4 ${o}(${d}) {
+ int index = ${f};
int texR = index / ${c};
int texC = index - texR * ${c};
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${u});
- return ${n.texture2D}(${t10}, uv);
+ return ${n.texture2D}(${t6}, uv);
}
`;
}
-function j8(r, e) {
- let t10 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = t10[3], a = t10[2] * s, i = t10[1] * a, { newShape: p, keptDims: u } = x.squeezeShape(t10);
- if (p.length < t10.length) {
- let b = fc(r, p), C = ["row", "col", "depth", "depth2"];
+function g8(r, e) {
+ let t6 = r.shapeInfo.logicalShape, o = r.name, n = "get" + o.charAt(0).toUpperCase() + o.slice(1), s = t6[3], a = t6[2] * s, i = t6[1] * a, { newShape: p, keptDims: u } = y.squeezeShape(t6);
+ if (p.length < t6.length) {
+ let b = pc(r, p), C = ["row", "col", "depth", "depth2"];
return `
- ${lc(b, e)}
+ ${ic(b, e)}
float ${n}(int row, int col, int depth, int depth2) {
- return ${n}(${dc(C, u)});
+ return ${n}(${cc(C, u)});
}
`;
}
@@ -16311,14 +16358,14 @@ function j8(r, e) {
float ${n}(int row, int col, int depth, int depth2) {
int index = round(dot(vec4(row, col, depth, depth2),
vec4(${i}, ${a}, ${s}, 1)));
- ${mc(r)}
+ ${uc(r)}
}
`;
- let c = r.shapeInfo.flatOffset, l = r.shapeInfo.texShape, m = l[0], f = l[1], d = `int stride2 = ${o}Shape[3];`, h = `int stride1 = ${o}Shape[2] * stride2;`, g = `int stride0 = ${o}Shape[1] * stride1;`;
- if (f === i && c == null)
+ let c = r.shapeInfo.flatOffset, l = r.shapeInfo.texShape, m = l[0], d = l[1], f = `int stride2 = ${o}Shape[3];`, h = `int stride1 = ${o}Shape[2] * stride2;`, g = `int stride0 = ${o}Shape[1] * stride1;`;
+ if (d === i && c == null)
return e ? `
float ${n}(int row, int col, int depth, int depth2) {
- ${d}
+ ${f}
${h}
float texR = float(row);
float texC =
@@ -16335,11 +16382,11 @@ function j8(r, e) {
dot(vec3(col, depth, depth2),
vec3(${a}, ${s}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
- vec2(${f}.0, ${m}.0);
+ vec2(${d}.0, ${m}.0);
return sampleTexture(${o}, uv);
}
`;
- if (f === s && c == null)
+ if (d === s && c == null)
return e ? `
float ${n}(int row, int col, int depth, int depth2) {
float texR = dot(vec3(row, col, depth),
@@ -16352,23 +16399,23 @@ function j8(r, e) {
` : `
float ${n}(int row, int col, int depth, int depth2) {
float texR = dot(vec3(row, col, depth),
- vec3(${t10[1] * t10[2]}, ${t10[2]}, 1));
+ vec3(${t6[1] * t6[2]}, ${t6[2]}, 1));
float texC = float(depth2);
vec2 uv = (vec2(texC, texR) + halfCR) /
- vec2(${f}.0, ${m}.0);
+ vec2(${d}.0, ${m}.0);
return sampleTexture(${o}, uv);
}
`;
- let y = Au(o);
+ let x = Ru(o);
return e ? `
float ${n}(int row, int col, int depth, int depth2) {
// Explicitly use integer operations as dot() only works on floats.
- ${d}
+ ${f}
${h}
${g}
int index = row * stride0 + col * stride1 +
depth * stride2 + depth2;
- vec2 uv = uvFromFlat(${o}TexShape[0], ${o}TexShape[1], index + ${y});
+ vec2 uv = uvFromFlat(${o}TexShape[0], ${o}TexShape[1], index + ${x});
return sampleTexture(${o}, uv);
}
` : `
@@ -16376,19 +16423,19 @@ function j8(r, e) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${i} + col * ${a} +
depth * ${s} + depth2;
- vec2 uv = uvFromFlat(${m}, ${f}, index + ${y});
+ vec2 uv = uvFromFlat(${m}, ${d}, index + ${x});
return sampleTexture(${o}, uv);
}
`;
}
-function X8(r) {
- let e = r.shapeInfo.logicalShape, t10 = r.name, o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1), n = e[4], s = e[3] * n, a = e[2] * s, i = e[1] * a, { newShape: p, keptDims: u } = x.squeezeShape(e);
+function x8(r) {
+ let e = r.shapeInfo.logicalShape, t6 = r.name, o = "get" + t6.charAt(0).toUpperCase() + t6.slice(1), n = e[4], s = e[3] * n, a = e[2] * s, i = e[1] * a, { newShape: p, keptDims: u } = y.squeezeShape(e);
if (p.length < e.length) {
- let h = fc(r, p), g = ["row", "col", "depth", "depth2", "depth3"];
+ let h = pc(r, p), g = ["row", "col", "depth", "depth2", "depth3"];
return `
- ${lc(h)}
+ ${ic(h)}
float ${o}(int row, int col, int depth, int depth2, int depth3) {
- return ${o}(${dc(g, u)});
+ return ${o}(${cc(g, u)});
}
`;
}
@@ -16399,22 +16446,22 @@ function X8(r) {
vec4(row, col, depth, depth2),
vec4(${i}, ${a}, ${s}, ${n})) +
depth3;
- ${mc(r)}
+ ${uc(r)}
}
`;
- let c = r.shapeInfo.flatOffset, l = r.shapeInfo.texShape, m = l[0], f = l[1];
- if (f === i && c == null)
+ let c = r.shapeInfo.flatOffset, l = r.shapeInfo.texShape, m = l[0], d = l[1];
+ if (d === i && c == null)
return `
float ${o}(int row, int col, int depth, int depth2, int depth3) {
int texR = row;
float texC = dot(vec4(col, depth, depth2, depth3),
vec4(${a}, ${s}, ${n}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
- vec2(${f}.0, ${m}.0);
- return sampleTexture(${t10}, uv);
+ vec2(${d}.0, ${m}.0);
+ return sampleTexture(${t6}, uv);
}
`;
- if (f === n && c == null)
+ if (d === n && c == null)
return `
float ${o}(int row, int col, int depth, int depth2, int depth3) {
float texR = dot(
@@ -16423,30 +16470,30 @@ function X8(r) {
${e[2] * e[3]}, ${e[3]}, 1));
int texC = depth3;
vec2 uv = (vec2(texC, texR) + halfCR) /
- vec2(${f}.0, ${m}.0);
- return sampleTexture(${t10}, uv);
+ vec2(${d}.0, ${m}.0);
+ return sampleTexture(${t6}, uv);
}
`;
- let d = Au(t10);
+ let f = Ru(t6);
return `
float ${o}(int row, int col, int depth, int depth2, int depth3) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${i} + col * ${a} + depth * ${s} +
- depth2 * ${n} + depth3 + ${d};
- vec2 uv = uvFromFlat(${m}, ${f}, index);
- return sampleTexture(${t10}, uv);
+ depth2 * ${n} + depth3 + ${f};
+ vec2 uv = uvFromFlat(${m}, ${d}, index);
+ return sampleTexture(${t6}, uv);
}
`;
}
-function Y8(r) {
- let e = r.shapeInfo.logicalShape, t10 = r.name, o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1), { newShape: n, keptDims: s } = x.squeezeShape(e);
+function y8(r) {
+ let e = r.shapeInfo.logicalShape, t6 = r.name, o = "get" + t6.charAt(0).toUpperCase() + t6.slice(1), { newShape: n, keptDims: s } = y.squeezeShape(e);
if (n.length < e.length) {
- let g = fc(r, n), y = ["row", "col", "depth", "depth2", "depth3", "depth4"];
+ let g = pc(r, n), x = ["row", "col", "depth", "depth2", "depth3", "depth4"];
return `
- ${lc(g)}
+ ${ic(g)}
float ${o}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
- return ${o}(${dc(y, s)});
+ return ${o}(${cc(x, s)});
}
`;
}
@@ -16461,11 +16508,11 @@ function Y8(r) {
dot(
vec2(depth3, depth4),
vec2(${a}, 1)));
- ${mc(r)}
+ ${uc(r)}
}
`;
- let l = r.shapeInfo.flatOffset, m = r.shapeInfo.texShape, f = m[0], d = m[1];
- if (d === c && l == null)
+ let l = r.shapeInfo.flatOffset, m = r.shapeInfo.texShape, d = m[0], f = m[1];
+ if (f === c && l == null)
return `
float ${o}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
@@ -16474,11 +16521,11 @@ function Y8(r) {
vec4(${u}, ${p}, ${i}, ${a})) +
float(depth4);
vec2 uv = (vec2(texC, texR) + halfCR) /
- vec2(${d}.0, ${f}.0);
- return sampleTexture(${t10}, uv);
+ vec2(${f}.0, ${d}.0);
+ return sampleTexture(${t6}, uv);
}
`;
- if (d === a && l == null)
+ if (f === a && l == null)
return `
float ${o}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
@@ -16489,79 +16536,79 @@ function Y8(r) {
${e[4]})) + float(depth3);
int texC = depth4;
vec2 uv = (vec2(texC, texR) + halfCR) /
- vec2(${d}.0, ${f}.0);
- return sampleTexture(${t10}, uv);
+ vec2(${f}.0, ${d}.0);
+ return sampleTexture(${t6}, uv);
}
`;
- let h = Au(t10);
+ let h = Ru(t6);
return `
float ${o}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${c} + col * ${u} + depth * ${p} +
depth2 * ${i} + depth3 * ${a} + depth4 + ${h};
- vec2 uv = uvFromFlat(${f}, ${d}, index);
- return sampleTexture(${t10}, uv);
+ vec2 uv = uvFromFlat(${d}, ${f}, index);
+ return sampleTexture(${t6}, uv);
}
`;
}
-function mc(r) {
- let e = r.name, t10 = x.sizeFromShape(r.shapeInfo.logicalShape);
- return t10 < 2 ? `return ${e};` : `
- for (int i = 0; i < ${t10}; i++) {
+function uc(r) {
+ let e = r.name, t6 = y.sizeFromShape(r.shapeInfo.logicalShape);
+ return t6 < 2 ? `return ${e};` : `
+ for (int i = 0; i < ${t6}; i++) {
if (i == index) {
return ${e}[i];
}
}
`;
}
-function Q8(r, e) {
- let t10 = r.name, o = t10.charAt(0).toUpperCase() + t10.slice(1), n = "get" + o + "AtOutCoords", s = r.shapeInfo.logicalShape.length, a = e.logicalShape.length, i = QE(r.shapeInfo.logicalShape, e.logicalShape), p = _e(a), u = a - s, c, l = ["x", "y", "z", "w", "u", "v"];
+function b8(r, e) {
+ let t6 = r.name, o = t6.charAt(0).toUpperCase() + t6.slice(1), n = "get" + o + "AtOutCoords", s = r.shapeInfo.logicalShape.length, a = e.logicalShape.length, i = NE(r.shapeInfo.logicalShape, e.logicalShape), p = _e(a), u = a - s, c, l = ["x", "y", "z", "w", "u", "v"];
s === 0 ? c = "" : a < 2 && i.length >= 1 ? c = "coords = 0;" : c = i.map((b) => `coords.${l[b + u]} = 0;`).join(`
`);
let m = "";
a < 2 && s > 0 ? m = "coords" : m = r.shapeInfo.logicalShape.map((b, C) => `coords.${l[C + u]}`).join(", ");
- let f = "return outputValue;", h = x.sizeFromShape(r.shapeInfo.logicalShape) === 1, y = x.sizeFromShape(e.logicalShape) === 1;
- if (s === 1 && !h && !y)
- f = `
+ let d = "return outputValue;", h = y.sizeFromShape(r.shapeInfo.logicalShape) === 1, x = y.sizeFromShape(e.logicalShape) === 1;
+ if (s === 1 && !h && !x)
+ d = `
return vec4(outputValue.xy, outputValue.xy);
`;
- else if (h && !y)
- a === 1 ? f = `
+ else if (h && !x)
+ a === 1 ? d = `
return vec4(outputValue.x, outputValue.x, 0., 0.);
- ` : f = `
+ ` : d = `
return vec4(outputValue.x);
`;
else if (i.length) {
let b = s - 2, C = s - 1;
- i.indexOf(b) > -1 && i.indexOf(C) > -1 ? f = "return vec4(outputValue.x);" : i.indexOf(b) > -1 ? f = "return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);" : i.indexOf(C) > -1 && (f = "return vec4(outputValue.xx, outputValue.zz);");
+ i.indexOf(b) > -1 && i.indexOf(C) > -1 ? d = "return vec4(outputValue.x);" : i.indexOf(b) > -1 ? d = "return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);" : i.indexOf(C) > -1 && (d = "return vec4(outputValue.xx, outputValue.zz);");
}
return `
vec4 ${n}() {
${p} coords = getOutputCoords();
${c}
vec4 outputValue = get${o}(${m});
- ${f}
+ ${d}
}
`;
}
-function Z8(r, e) {
- let t10 = r.name, o = t10.charAt(0).toUpperCase() + t10.slice(1), n = "get" + o + "AtOutCoords", s = e.texShape, a = r.shapeInfo.texShape, i = r.shapeInfo.logicalShape.length, p = e.logicalShape.length;
- if (!r.shapeInfo.isUniform && i === p && r.shapeInfo.flatOffset == null && x.arraysEqual(a, s))
+function C8(r, e) {
+ let t6 = r.name, o = t6.charAt(0).toUpperCase() + t6.slice(1), n = "get" + o + "AtOutCoords", s = e.texShape, a = r.shapeInfo.texShape, i = r.shapeInfo.logicalShape.length, p = e.logicalShape.length;
+ if (!r.shapeInfo.isUniform && i === p && r.shapeInfo.flatOffset == null && y.arraysEqual(a, s))
return `
float ${n}() {
- return sampleTexture(${t10}, resultUV);
+ return sampleTexture(${t6}, resultUV);
}
`;
- let u = _e(p), c = QE(r.shapeInfo.logicalShape, e.logicalShape), l = p - i, m, f = ["x", "y", "z", "w", "u", "v"];
- i === 0 ? m = "" : p < 2 && c.length >= 1 ? m = "coords = 0;" : m = c.map((h) => `coords.${f[h + l]} = 0;`).join(`
+ let u = _e(p), c = NE(r.shapeInfo.logicalShape, e.logicalShape), l = p - i, m, d = ["x", "y", "z", "w", "u", "v"];
+ i === 0 ? m = "" : p < 2 && c.length >= 1 ? m = "coords = 0;" : m = c.map((h) => `coords.${d[h + l]} = 0;`).join(`
`);
- let d = "";
- return p < 2 && i > 0 ? d = "coords" : d = r.shapeInfo.logicalShape.map((h, g) => `coords.${f[g + l]}`).join(", "), `
+ let f = "";
+ return p < 2 && i > 0 ? f = "coords" : f = r.shapeInfo.logicalShape.map((h, g) => `coords.${d[g + l]}`).join(", "), `
float ${n}() {
${u} coords = getOutputCoords();
${m}
- return get${o}(${d});
+ return get${o}(${f});
}
`;
}
@@ -16580,77 +16627,77 @@ function _e(r) {
return "ivec6";
throw Error(`GPU for rank ${r} is not yet supported`);
}
-function qd(r, e, t10) {
- let { newShape: o, keptDims: n } = x.squeezeShape(e), s = e.length, a = r && s === 3 && e[0] === 1, i = a ? e.slice(1) : o, p = !r && s > 1 && !x.arraysEqual(e, t10) && o.length < s || a;
+function Of(r, e, t6) {
+ let { newShape: o, keptDims: n } = y.squeezeShape(e), s = e.length, a = r && s === 3 && e[0] === 1, i = a ? e.slice(1) : o, p = !r && s > 1 && !y.arraysEqual(e, t6) && o.length < s || a;
return { useSqueezeShape: p, uniformShape: p ? i : e, keptDims: n };
}
-function fc(r, e) {
- let t10 = JSON.parse(JSON.stringify(r));
- return t10.shapeInfo.logicalShape = e, t10;
+function pc(r, e) {
+ let t6 = JSON.parse(JSON.stringify(r));
+ return t6.shapeInfo.logicalShape = e, t6;
}
-function dc(r, e) {
- return e.map((t10) => r[t10]).join(", ");
+function cc(r, e) {
+ return e.map((t6) => r[t6]).join(", ");
}
-function r$(r, e, t10, o) {
- let n = t10.map((c, l) => {
+function AE(r, e, t6, o) {
+ let n = t6.map((c, l) => {
let m = { logicalShape: c.shape, texShape: c.isUniform ? null : c.texData.texShape, isUniform: c.isUniform, isPacked: c.isUniform ? false : c.texData.isPacked, flatOffset: null };
return c.texData != null && c.texData.slice != null && c.texData.slice.flatOffset > 0 && (m.flatOffset = c.texData.slice.flatOffset), { name: e.variableNames[l], shapeInfo: m };
- }), s = n.map((c) => c.shapeInfo), a = { logicalShape: o.shape, texShape: o.texData.texShape, isUniform: false, isPacked: o.texData.isPacked, flatOffset: null }, i = ZE(n, a, e), p = WI(r.gl, i), u = r.createProgram(p);
- return P().get("ENGINE_COMPILE_ONLY") ? { program: e, fragmentShader: p, source: i, webGLProgram: u, inShapeInfos: s, outShapeInfo: a, uniformLocations: null, customUniformLocations: null, infLoc: null, nanLoc: null, inShapesLocations: null, inTexShapesLocations: null, outShapeLocation: null, outShapeStridesLocation: null, outTexShapeLocation: null } : Object.assign({ program: e, fragmentShader: p, source: i, webGLProgram: u, inShapeInfos: s, outShapeInfo: a }, aw(r, e, u));
+ }), s = n.map((c) => c.shapeInfo), a = { logicalShape: o.shape, texShape: o.texData.texShape, isUniform: false, isPacked: o.texData.isPacked, flatOffset: null }, i = TE(n, a, e), p = MS(r.gl, i), u = r.createProgram(p);
+ return O().get("ENGINE_COMPILE_ONLY") ? { program: e, fragmentShader: p, source: i, webGLProgram: u, inShapeInfos: s, outShapeInfo: a, uniformLocations: null, customUniformLocations: null, infLoc: null, nanLoc: null, inShapesLocations: null, inTexShapesLocations: null, outShapeLocation: null, outShapeStridesLocation: null, outTexShapeLocation: null } : Object.assign({ program: e, fragmentShader: p, source: i, webGLProgram: u, inShapeInfos: s, outShapeInfo: a }, tw(r, e, u));
}
-function aw(r, e, t10) {
+function tw(r, e, t6) {
let o = {}, n = {}, s = {}, a = [], i, p, u, c = null, l = null;
- l = r.getUniformLocation(t10, "NAN", false), P().getNumber("WEBGL_VERSION") === 1 && (c = r.getUniformLocation(t10, "INFINITY", false));
+ l = r.getUniformLocation(t6, "NAN", false), O().getNumber("WEBGL_VERSION") === 1 && (c = r.getUniformLocation(t6, "INFINITY", false));
let m = false;
- for (let f = 0; f < e.variableNames.length; f++) {
- let d = e.variableNames[f];
- o[d] = r.getUniformLocation(t10, d, m), o[`offset${d}`] = r.getUniformLocation(t10, `offset${d}`, m), e.enableShapeUniforms && (n[`${d}Shape`] = r.getUniformLocation(t10, `${d}Shape`, m), s[`${d}TexShape`] = r.getUniformLocation(t10, `${d}TexShape`, m));
+ for (let d = 0; d < e.variableNames.length; d++) {
+ let f = e.variableNames[d];
+ o[f] = r.getUniformLocation(t6, f, m), o[`offset${f}`] = r.getUniformLocation(t6, `offset${f}`, m), e.enableShapeUniforms && (n[`${f}Shape`] = r.getUniformLocation(t6, `${f}Shape`, m), s[`${f}TexShape`] = r.getUniformLocation(t6, `${f}TexShape`, m));
}
- return e.enableShapeUniforms && (i = r.getUniformLocation(t10, "outShape", m), u = r.getUniformLocation(t10, "outShapeStrides", m), p = r.getUniformLocation(t10, "outTexShape", m)), e.customUniforms && e.customUniforms.forEach((f, d) => {
- a[d] = r.getUniformLocation(t10, f.name, m);
+ return e.enableShapeUniforms && (i = r.getUniformLocation(t6, "outShape", m), u = r.getUniformLocation(t6, "outShapeStrides", m), p = r.getUniformLocation(t6, "outTexShape", m)), e.customUniforms && e.customUniforms.forEach((d, f) => {
+ a[f] = r.getUniformLocation(t6, d.name, m);
}), { uniformLocations: o, customUniformLocations: a, infLoc: c, nanLoc: l, inShapesLocations: n, inTexShapesLocations: s, outShapeLocation: i, outShapeStridesLocation: u, outTexShapeLocation: p };
}
-function t$(r, e) {
+function $E(r, e) {
if (r.length !== e.length)
throw Error(`Binary was compiled with ${r.length} inputs, but was executed with ${e.length} inputs`);
- r.forEach((t10, o) => {
- let n = t10.logicalShape, s = e[o], a = s.shape;
- if (!x.arraysEqual(n, a))
+ r.forEach((t6, o) => {
+ let n = t6.logicalShape, s = e[o], a = s.shape;
+ if (!y.arraysEqual(n, a))
throw Error(`Binary was compiled with different shapes than the current args. Shapes ${n} and ${a} must match`);
- if (t10.isUniform && s.isUniform)
+ if (t6.isUniform && s.isUniform)
return;
- let i = t10.texShape, p = s.isUniform ? null : s.texData.texShape;
- if (!x.arraysEqual(i, p))
+ let i = t6.texShape, p = s.isUniform ? null : s.texData.texShape;
+ if (!y.arraysEqual(i, p))
throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${i} and ${p} must match`);
});
}
-function o$(r, e, t10, o, n) {
- e.program.enableShapeUniforms || (t$(e.inShapeInfos, t10), t$([e.outShapeInfo], [o]));
+function RE(r, e, t6, o, n) {
+ e.program.enableShapeUniforms || ($E(e.inShapeInfos, t6), $E([e.outShapeInfo], [o]));
let s = o.texData.texture, a = o.texData.texShape;
- o.texData.isPacked ? r.setOutputPackedMatrixTexture(s.texture, a[0], a[1]) : r.setOutputMatrixTexture(s.texture, a[0], a[1]), r.setProgram(e.webGLProgram), P().getNumber("WEBGL_VERSION") === 1 && e.infLoc !== null && r.gl.uniform1f(e.infLoc, 1 / 0), e.nanLoc !== null && r.gl.uniform1f(e.nanLoc, NaN), t10.forEach((p, u) => {
- let c = e.program.variableNames[u], l = e.uniformLocations[c], m = e.uniformLocations[`offset${c}`], f = e.inShapesLocations[`${c}Shape`], d = e.inTexShapesLocations[`${c}TexShape`];
- if (f) {
- let { uniformShape: h } = qd(e.program.packedInputs, p.shape, p.texData.texShape);
+ o.texData.isPacked ? r.setOutputPackedMatrixTexture(s.texture, a[0], a[1]) : r.setOutputMatrixTexture(s.texture, a[0], a[1]), r.setProgram(e.webGLProgram), O().getNumber("WEBGL_VERSION") === 1 && e.infLoc !== null && r.gl.uniform1f(e.infLoc, 1 / 0), e.nanLoc !== null && r.gl.uniform1f(e.nanLoc, NaN), t6.forEach((p, u) => {
+ let c = e.program.variableNames[u], l = e.uniformLocations[c], m = e.uniformLocations[`offset${c}`], d = e.inShapesLocations[`${c}Shape`], f = e.inTexShapesLocations[`${c}TexShape`];
+ if (d) {
+ let { uniformShape: h } = Of(e.program.packedInputs, p.shape, p.texData.texShape);
switch (h.length) {
case 1:
- r.gl.uniform1iv(f, new Int32Array(h));
+ r.gl.uniform1iv(d, new Int32Array(h));
break;
case 2:
- r.gl.uniform2iv(f, new Int32Array(h));
+ r.gl.uniform2iv(d, new Int32Array(h));
break;
case 3:
- r.gl.uniform3iv(f, new Int32Array(h));
+ r.gl.uniform3iv(d, new Int32Array(h));
break;
case 4:
- r.gl.uniform4iv(f, new Int32Array(h));
+ r.gl.uniform4iv(d, new Int32Array(h));
break;
default:
break;
}
}
- if (d && r.gl.uniform2i(d, p.texData.texShape[0], p.texData.texShape[1]), l != null) {
+ if (f && r.gl.uniform2i(f, p.texData.texShape[0], p.texData.texShape[1]), l != null) {
if (p.isUniform) {
- if (x.sizeFromShape(p.shape) < 2)
+ if (y.sizeFromShape(p.shape) < 2)
r.gl.uniform1f(l, p.uniformValues[0]);
else {
let h = p.uniformValues;
@@ -16680,7 +16727,7 @@ function o$(r, e, t10, o, n) {
break;
}
if (e.outShapeStridesLocation) {
- let p = x.computeStrides(o.shape);
+ let p = y.computeStrides(o.shape);
switch (o.shape.length) {
case 2:
r.gl.uniform1iv(e.outShapeStridesLocation, new Int32Array(p));
@@ -16717,41 +16764,41 @@ function o$(r, e, t10, o, n) {
throw Error(`uniform type ${p.type} is not supported yet.`);
}), r.executeProgram();
}
-function n$(r, e, t10) {
+function FE(r, e, t6) {
let o = "";
- e.concat(t10).forEach((a) => {
+ e.concat(t6).forEach((a) => {
let i = a.texData != null && a.texData.slice != null && a.texData.slice.flatOffset > 0;
if (r.enableShapeUniforms && !a.isUniform) {
- let p = a.texData.texShape, { useSqueezeShape: u, uniformShape: c, keptDims: l } = qd(r.packedInputs, a.shape, p), m = "", f = "", d = "";
+ let p = a.texData.texShape, { useSqueezeShape: u, uniformShape: c, keptDims: l } = Of(r.packedInputs, a.shape, p), m = "", d = "", f = "";
if (c.length === 1 && r.packedInputs) {
let k = [Math.ceil(p[0] / 2), Math.ceil(p[1] / 2)];
m = `${k[0] > 1}_${k[1] > 1}`;
} else if (c.length === 2 && !r.packedInputs)
- f = `${c[0] > 1}_${c[1] > 1}`;
+ d = `${c[0] > 1}_${c[1] > 1}`;
else if (c.length > 2 && !r.packedInputs) {
- let k = x.computeStrides(c);
- d = `${k[0] === p[1]}_${k[k.length - 1] === p[1]}`;
+ let k = y.computeStrides(c);
+ f = `${k[0] === p[1]}_${k[k.length - 1] === p[1]}`;
}
- let h = a.shape.length, g = c.length === 2 && x.arraysEqual(a.shape, p), y = x.sizeFromShape(a.shape) === 1, b = I.getBroadcastDims(a.shape, t10.shape), C = !r.packedInputs && h === t10.shape.length && x.arraysEqual(p, t10.texData.texShape), w = r.packedInputs || c.length > 2 ? "" : `${p[0] > 1}_${p[1] > 1}`;
- o += `${h}_${C}_${u ? l : ""}_${c.length}_${y}_${b}_${g}_${m}_${f}_${d}_${w}_${i}`;
+ let h = a.shape.length, g = c.length === 2 && y.arraysEqual(a.shape, p), x = y.sizeFromShape(a.shape) === 1, b = S.getBroadcastDims(a.shape, t6.shape), C = !r.packedInputs && h === t6.shape.length && y.arraysEqual(p, t6.texData.texShape), w = r.packedInputs || c.length > 2 ? "" : `${p[0] > 1}_${p[1] > 1}`;
+ o += `${h}_${C}_${u ? l : ""}_${c.length}_${x}_${b}_${g}_${m}_${d}_${f}_${w}_${i}`;
} else {
let p = a.isUniform ? "uniform" : a.texData.texShape;
o += `${a.shape}_${p}_${i}`;
}
});
let n = r.userCode, s = r.constructor.name;
- return s += "_" + o + "_" + n + `${P().getNumber("WEBGL_VERSION")}`, s;
+ return s += "_" + o + "_" + n + `${O().getNumber("WEBGL_VERSION")}`, s;
}
-function lt(r) {
- return P().getBool("WEBGL_USE_SHAPES_UNIFORMS") && r <= 4;
+function ct(r) {
+ return O().getBool("WEBGL_USE_SHAPES_UNIFORMS") && r <= 4;
}
-var Kd = class {
+var Pf = class {
constructor(e) {
- this.variableNames = ["A"], this.packedInputs = false, this.packedOutput = true, this.outPackingScheme = ki.DENSE, this.customUniforms = [{ name: "texShape", type: "ivec2" }];
- let t10 = Ct();
- this.outputShape = e, this.enableShapeUniforms = lt(this.outputShape.length), this.userCode = `
+ this.variableNames = ["A"], this.packedInputs = false, this.packedOutput = true, this.outPackingScheme = Mi.DENSE, this.customUniforms = [{ name: "texShape", type: "ivec2" }];
+ let t6 = St();
+ this.outputShape = e, this.enableShapeUniforms = ct(this.outputShape.length), this.userCode = `
ivec3 outCoordsFromFlatIndex(int index) {
- ${this.enableShapeUniforms ? Ru(["r", "c", "d"], e) : is(["r", "c", "d"], e)}
+ ${this.enableShapeUniforms ? Au(["r", "c", "d"], e) : us(["r", "c", "d"], e)}
return ivec3(r, c, d);
}
@@ -16767,18 +16814,18 @@ var Kd = class {
result[i] = getA(rc.x, rc.y, rc.z);
}
- ${t10.output} = result;
+ ${t6.output} = result;
}
`;
}
};
-var jd = class {
+var Mf = class {
constructor(e) {
- this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.outPackingScheme = ki.DENSE, this.customUniforms = [{ name: "texShape", type: "ivec2" }];
- let t10 = Ct();
- this.outputShape = e, this.enableShapeUniforms = lt(this.outputShape.length), this.userCode = `
+ this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.outPackingScheme = Mi.DENSE, this.customUniforms = [{ name: "texShape", type: "ivec2" }];
+ let t6 = St();
+ this.outputShape = e, this.enableShapeUniforms = ct(this.outputShape.length), this.userCode = `
ivec3 outCoordsFromFlatIndex(int index) {
- ${this.enableShapeUniforms ? Ru(["r", "c", "d"], e) : is(["r", "c", "d"], e)}
+ ${this.enableShapeUniforms ? Au(["r", "c", "d"], e) : us(["r", "c", "d"], e)}
return ivec3(r, c, d);
}
@@ -16794,58 +16841,58 @@ var jd = class {
result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));
}
- ${t10.output} = result;
+ ${t6.output} = result;
}
`;
}
};
-var Xd = class {
+var Lf = class {
constructor(e) {
this.variableNames = ["A"], this.outTexUsage = ir.DOWNLOAD;
- let t10 = Ct();
+ let t6 = St();
this.outputShape = e, this.userCode = `
- ${Hd}
+ ${Df}
void main() {
float x = getAAtOutCoords();
- ${t10.output} = encode_float(x);
+ ${t6.output} = encode_float(x);
}
`;
}
};
-var Yd = class {
+var Bf = class {
constructor(e) {
this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = false, this.outTexUsage = ir.DOWNLOAD;
- let t10 = Ct();
+ let t6 = St();
this.outputShape = e, this.userCode = `
- ${Hd}
+ ${Df}
void main() {
ivec3 coords = getOutputCoords();
float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
- ${t10.output} = encode_float(x);
+ ${t6.output} = encode_float(x);
}
`;
}
};
-var tY = { R: 0, G: 1, B: 2, A: 3 };
-var Al = class {
- constructor(e, t10 = false, o = "RGBA") {
+var I8 = { R: 0, G: 1, B: 2, A: 3 };
+var vl = class {
+ constructor(e, t6 = false, o = "RGBA") {
this.variableNames = ["A"], this.customUniforms = [{ name: "texShape", type: "ivec2" }];
- let n = Ct();
- this.outputShape = e, this.enableShapeUniforms = lt(this.outputShape.length);
+ let n = St();
+ this.outputShape = e, this.enableShapeUniforms = ct(this.outputShape.length);
let s = "result";
- t10 && (s = "floor(result * 255. + 0.5)");
+ t6 && (s = "floor(result * 255. + 0.5)");
let a = "";
for (let i = 0; i < o.length; i++) {
let p = o[i];
a += `
if(offset == ${i}) {
- result = values[${tY[p]}];
+ result = values[${I8[p]}];
}`;
}
this.userCode = `
- ${this.enableShapeUniforms ? pc() : uc(e)}
+ ${this.enableShapeUniforms ? sc() : nc(e)}
void main() {
ivec3 coords = getOutputCoords();
@@ -16867,13 +16914,13 @@ var Al = class {
`;
}
};
-var Qd = class {
- constructor(e, t10 = false) {
+var Vf = class {
+ constructor(e, t6 = false) {
this.variableNames = ["A"], this.packedInputs = false, this.packedOutput = true, this.customUniforms = [{ name: "texShape", type: "ivec2" }];
- let o = Ct();
- this.outputShape = e, this.enableShapeUniforms = lt(this.outputShape.length);
+ let o = St();
+ this.outputShape = e, this.enableShapeUniforms = ct(this.outputShape.length);
let n = "", s = "result";
- t10 && (s = "floor(result * 255. + 0.5)");
+ t6 && (s = "floor(result * 255. + 0.5)");
for (let a = 0; a <= 1; a++)
for (let i = 0; i <= 1; i++) {
let p = a * 2 + i;
@@ -16908,7 +16955,7 @@ var Qd = class {
`;
}
this.userCode = `
- ${this.enableShapeUniforms ? pc() : uc(e)}
+ ${this.enableShapeUniforms ? sc() : nc(e)}
void main() {
ivec3 coords = getOutputCoords();
@@ -16926,10 +16973,10 @@ var Qd = class {
`;
}
};
-var Sw = {};
-Be(Sw, { bindVertexProgramAttributeStreams: () => hw, createBufferFromOutputTexture: () => yw, createFloat16MatrixTexture: () => lw, createFloat16PackedMatrixTexture: () => dw, createFloat32MatrixTexture: () => cw, createIndexBuffer: () => pw, createPackedMatrixTexture: () => fw, createUnsignedBytesMatrixTexture: () => mw, createVertexBuffer: () => uw, createVertexShader: () => iw, downloadByteEncodedFloatMatrixFromOutputTexture: () => Cw, downloadFloat32MatrixFromBuffer: () => bw, downloadMatrixFromPackedOutputTexture: () => ww, downloadPackedMatrixFromBuffer: () => Iw, getInternalFormatForFloat16MatrixTexture: () => Jd, getInternalFormatForFloat16PackedMatrixTexture: () => rh, getInternalFormatForFloat32MatrixTexture: () => Zd, getInternalFormatForPackedMatrixTexture: () => th, getInternalFormatForUnsignedBytesMatrixTexture: () => eh, uploadDenseMatrixToTexture: () => gw, uploadPixelDataToTexture: () => xw });
-function iw(r) {
- let e = Ct(), t10 = `${e.version}
+var yw = {};
+Ue(yw, { bindVertexProgramAttributeStreams: () => cw, createBufferFromOutputTexture: () => dw, createFloat16MatrixTexture: () => aw, createFloat16PackedMatrixTexture: () => pw, createFloat32MatrixTexture: () => sw, createIndexBuffer: () => nw, createPackedMatrixTexture: () => uw, createUnsignedBytesMatrixTexture: () => iw, createVertexBuffer: () => ow, createVertexShader: () => rw, downloadByteEncodedFloatMatrixFromOutputTexture: () => hw, downloadFloat32MatrixFromBuffer: () => fw, downloadMatrixFromPackedOutputTexture: () => xw, downloadPackedMatrixFromBuffer: () => gw, getInternalFormatForFloat16MatrixTexture: () => Wf, getInternalFormatForFloat16PackedMatrixTexture: () => Hf, getInternalFormatForFloat32MatrixTexture: () => zf, getInternalFormatForPackedMatrixTexture: () => Gf, getInternalFormatForUnsignedBytesMatrixTexture: () => Uf, uploadDenseMatrixToTexture: () => lw, uploadPixelDataToTexture: () => mw });
+function rw(r) {
+ let e = St(), t6 = `${e.version}
precision highp float;
${e.attribute} vec3 clipSpacePos;
${e.attribute} vec2 uv;
@@ -16939,159 +16986,167 @@ function iw(r) {
gl_Position = vec4(clipSpacePos, 1);
resultUV = uv;
}`;
- return zI(r, t10);
+ return PS(r, t6);
}
-function uw(r) {
+function ow(r) {
let e = new Float32Array([-1, 1, 0, 0, 1, -1, -1, 0, 0, 0, 1, 1, 0, 1, 1, 1, -1, 0, 1, 0]);
- return HI(r, e);
+ return VS(r, e);
}
-function pw(r) {
+function nw(r) {
let e = new Uint16Array([0, 1, 2, 2, 1, 3]);
- return qI(r, e);
+ return zS(r, e);
}
-function Fl(r, e, t10, o, n, s) {
- jI(e, t10);
- let a = KI(r), i = r.TEXTURE_2D;
- return me(r, () => r.bindTexture(i, a)), me(r, () => r.texParameteri(i, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE)), me(r, () => r.texParameteri(i, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE)), me(r, () => r.texParameteri(i, r.TEXTURE_MIN_FILTER, r.NEAREST)), me(r, () => r.texParameteri(i, r.TEXTURE_MAG_FILTER, r.NEAREST)), P().getNumber("WEBGL_VERSION") === 1 ? me(r, () => r.texImage2D(i, 0, o, e, t10, 0, n, s, null)) : me(r, () => r.texStorage2D(i, 1, o, e, t10)), me(r, () => r.bindTexture(r.TEXTURE_2D, null)), { texture: a, texShape: [t10, e] };
+function kl(r, e, t6, o, n, s) {
+ US(e, t6);
+ let a = WS(r), i = r.TEXTURE_2D;
+ return ce(r, () => r.bindTexture(i, a)), ce(r, () => r.texParameteri(i, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE)), ce(r, () => r.texParameteri(i, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE)), ce(r, () => r.texParameteri(i, r.TEXTURE_MIN_FILTER, r.NEAREST)), ce(r, () => r.texParameteri(i, r.TEXTURE_MAG_FILTER, r.NEAREST)), O().getNumber("WEBGL_VERSION") === 1 ? ce(r, () => r.texImage2D(i, 0, o, e, t6, 0, n, s, null)) : ce(r, () => r.texStorage2D(i, 1, o, e, t6)), ce(r, () => r.bindTexture(r.TEXTURE_2D, null)), { texture: a, texShape: [t6, e] };
}
-function Zd(r) {
+function zf(r) {
return r.internalFormatFloat;
}
-function cw(r, e, t10, o) {
- let [n, s] = $u(e, t10);
- return Fl(r, n, s, Zd(o), o.textureFormatFloat, r.FLOAT);
+function sw(r, e, t6, o) {
+ let [n, s] = $u(e, t6);
+ return kl(r, n, s, zf(o), o.textureFormatFloat, r.FLOAT);
}
-function Jd(r) {
+function Wf(r) {
return r.internalFormatHalfFloat;
}
-function lw(r, e, t10, o) {
- let [n, s] = $u(e, t10);
- return Fl(r, n, s, Jd(o), o.textureFormatFloat, o.textureTypeHalfFloat);
+function aw(r, e, t6, o) {
+ let [n, s] = $u(e, t6);
+ return kl(r, n, s, Wf(o), o.textureFormatFloat, o.textureTypeHalfFloat);
}
-function eh(r) {
+function Uf(r) {
return r.downloadTextureFormat;
}
-function mw(r, e, t10, o) {
- let [n, s] = $u(e, t10);
- return Fl(r, n, s, eh(o), r.RGBA, r.UNSIGNED_BYTE);
+function iw(r, e, t6, o) {
+ let [n, s] = $u(e, t6);
+ return kl(r, n, s, Uf(o), r.RGBA, r.UNSIGNED_BYTE);
}
-function th(r) {
+function Gf(r) {
return r.internalFormatPackedFloat;
}
-function fw(r, e, t10, o) {
- let [n, s] = Ks(e, t10);
- return Fl(r, n, s, th(o), r.RGBA, r.FLOAT);
+function uw(r, e, t6, o) {
+ let [n, s] = Ys(e, t6);
+ return kl(r, n, s, Gf(o), r.RGBA, r.FLOAT);
}
-function rh(r) {
+function Hf(r) {
return r.internalFormatPackedHalfFloat;
}
-function dw(r, e, t10, o) {
- let [n, s] = Ks(e, t10);
- return Fl(r, n, s, rh(o), r.RGBA, o.textureTypeHalfFloat);
+function pw(r, e, t6, o) {
+ let [n, s] = Ys(e, t6);
+ return kl(r, n, s, Hf(o), r.RGBA, o.textureTypeHalfFloat);
}
-function hw(r, e, t10) {
- return me(r, () => r.bindBuffer(r.ARRAY_BUFFER, t10)), Wd(r, e, "clipSpacePos", t10, 3, 20, 0) && Wd(r, e, "uv", t10, 2, 20, 12);
+function cw(r, e, t6) {
+ return ce(r, () => r.bindBuffer(r.ARRAY_BUFFER, t6)), Af(r, e, "clipSpacePos", t6, 3, 20, 0) && Af(r, e, "uv", t6, 2, 20, 12);
}
-function gw(r, e, t10, o, n, s) {
- me(r, () => r.bindTexture(r.TEXTURE_2D, e));
+function lw(r, e, t6, o, n, s) {
+ ce(r, () => r.bindTexture(r.TEXTURE_2D, e));
let a, i, p;
- n instanceof Uint8Array ? (a = new Uint8Array(t10 * o * 4), i = r.UNSIGNED_BYTE, p = r.RGBA) : (a = new Float32Array(t10 * o * 4), i = r.FLOAT, p = s.internalFormatPackedFloat), a.set(n), P().getNumber("WEBGL_VERSION") === 2 ? me(r, () => r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, t10, o, r.RGBA, i, a)) : me(r, () => r.texImage2D(r.TEXTURE_2D, 0, p, t10, o, 0, r.RGBA, i, a)), me(r, () => r.bindTexture(r.TEXTURE_2D, null));
+ n instanceof Uint8Array ? (a = new Uint8Array(t6 * o * 4), i = r.UNSIGNED_BYTE, p = r.RGBA) : (a = new Float32Array(t6 * o * 4), i = r.FLOAT, p = s.internalFormatPackedFloat), a.set(n), O().getNumber("WEBGL_VERSION") === 2 ? ce(r, () => r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, t6, o, r.RGBA, i, a)) : ce(r, () => r.texImage2D(r.TEXTURE_2D, 0, p, t6, o, 0, r.RGBA, i, a)), ce(r, () => r.bindTexture(r.TEXTURE_2D, null));
}
-function xw(r, e, t10) {
- me(r, () => r.bindTexture(r.TEXTURE_2D, e)), t10.data instanceof Uint8Array ? P().getNumber("WEBGL_VERSION") === 2 ? me(r, () => r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, t10.width, t10.height, r.RGBA, r.UNSIGNED_BYTE, t10.data)) : me(r, () => r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, t10.width, t10.height, 0, r.RGBA, r.UNSIGNED_BYTE, t10.data)) : P().getNumber("WEBGL_VERSION") === 2 ? me(r, () => r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, r.RGBA, r.UNSIGNED_BYTE, t10)) : me(r, () => r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, r.RGBA, r.UNSIGNED_BYTE, t10)), me(r, () => r.bindTexture(r.TEXTURE_2D, null));
+function mw(r, e, t6) {
+ ce(r, () => r.bindTexture(r.TEXTURE_2D, e)), t6.data instanceof Uint8Array ? O().getNumber("WEBGL_VERSION") === 2 ? ce(r, () => r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, t6.width, t6.height, r.RGBA, r.UNSIGNED_BYTE, t6.data)) : ce(r, () => r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, t6.width, t6.height, 0, r.RGBA, r.UNSIGNED_BYTE, t6.data)) : O().getNumber("WEBGL_VERSION") === 2 ? ce(r, () => r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, r.RGBA, r.UNSIGNED_BYTE, t6)) : ce(r, () => r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, r.RGBA, r.UNSIGNED_BYTE, t6)), ce(r, () => r.bindTexture(r.TEXTURE_2D, null));
}
-function yw(r, e, t10, o) {
+function dw(r, e, t6, o) {
let n = r.createBuffer();
- me(r, () => r.bindBuffer(r.PIXEL_PACK_BUFFER, n));
- let i = 4 * 4 * e * t10;
- return me(r, () => r.bufferData(r.PIXEL_PACK_BUFFER, i, r.STREAM_READ)), me(r, () => r.readPixels(0, 0, t10, e, r.RGBA, r.FLOAT, 0)), me(r, () => r.bindBuffer(r.PIXEL_PACK_BUFFER, null)), n;
+ ce(r, () => r.bindBuffer(r.PIXEL_PACK_BUFFER, n));
+ let i = 4 * 4 * e * t6;
+ return ce(r, () => r.bufferData(r.PIXEL_PACK_BUFFER, i, r.STREAM_READ)), ce(r, () => r.readPixels(0, 0, t6, e, r.RGBA, r.FLOAT, 0)), ce(r, () => r.bindBuffer(r.PIXEL_PACK_BUFFER, null)), n;
}
-function bw(r, e, t10) {
- let o = r, n = new Float32Array(t10);
+function fw(r, e, t6) {
+ let o = r, n = new Float32Array(t6);
return o.bindBuffer(o.PIXEL_PACK_BUFFER, e), o.getBufferSubData(o.PIXEL_PACK_BUFFER, 0, n), o.bindBuffer(o.PIXEL_PACK_BUFFER, null), n;
}
-function Cw(r, e, t10, o) {
- let [n, s] = $u(e, t10), a = 4, i = new Uint8Array(GE(e * t10, a));
- return me(r, () => r.readPixels(0, 0, n, s, o.downloadTextureFormat, r.UNSIGNED_BYTE, i)), new Float32Array(i.buffer);
+function hw(r, e, t6, o) {
+ let [n, s] = $u(e, t6), a = 4, i = new Uint8Array(bE(e * t6, a));
+ return ce(r, () => r.readPixels(0, 0, n, s, o.downloadTextureFormat, r.UNSIGNED_BYTE, i)), new Float32Array(i.buffer);
}
-function Iw(r, e, t10, o, n, s, a, i) {
- let p = r, u = new Float32Array(HE(s, a));
+function gw(r, e, t6, o, n, s, a, i) {
+ let p = r, u = new Float32Array(CE(s, a));
return p.bindBuffer(p.PIXEL_PACK_BUFFER, e), p.getBufferSubData(p.PIXEL_PACK_BUFFER, 0, u), p.bindBuffer(p.PIXEL_PACK_BUFFER, null), u;
}
-function ww(r, e, t10) {
- let o = new Float32Array(e * t10 * 4);
- return me(r, () => r.readPixels(0, 0, t10, e, r.RGBA, r.FLOAT, o)), o;
+function xw(r, e, t6) {
+ let o = new Float32Array(e * t6 * 4);
+ return ce(r, () => r.readPixels(0, 0, t6, e, r.RGBA, r.FLOAT, o)), o;
}
var Fu = class {
constructor(e) {
- this.outputTexture = null, this.program = null, this.disposed = false, this.vertexAttrsAreBound = false, this.itemsToPoll = [];
- let t10 = P().getNumber("WEBGL_VERSION");
- e != null ? (this.gl = e, MI(t10, e)) : this.gl = Gr(t10);
+ this.outputTexture = null, this.program = null, this.disposed = false, this.itemsToPoll = [];
+ let t6 = O().getNumber("WEBGL_VERSION");
+ if (e != null ? (this.gl = e, RS(t6, e)) : this.gl = Wr(t6), e = this.gl, O().getNumber("WEBGL_VERSION") === 2) {
+ let s = e;
+ this.createVertexArray = () => ce(s, () => s.createVertexArray()), this.bindVertexArray = (a) => ce(s, () => s.bindVertexArray(a)), this.deleteVertexArray = (a) => ce(s, () => s.deleteVertexArray(a)), this.getVertexArray = () => ce(s, () => s.getParameter(s.VERTEX_ARRAY_BINDING));
+ } else if (e != null) {
+ let s = e.getExtension("OES_vertex_array_object");
+ if (s == null)
+ throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");
+ this.createVertexArray = () => ce(e, () => s.createVertexArrayOES()), this.bindVertexArray = (a) => ce(e, () => s.bindVertexArrayOES(a)), this.deleteVertexArray = (a) => ce(e, () => s.deleteVertexArrayOES(a)), this.getVertexArray = () => ce(e, () => e.getParameter(s.VERTEX_ARRAY_BINDING_OES));
+ }
let o = "WEBGL_color_buffer_float", n = "EXT_color_buffer_half_float";
- if (this.parallelCompilationExtension = this.gl.getExtension("KHR_parallel_shader_compile"), P().getNumber("WEBGL_VERSION") === 1) {
+ if (this.parallelCompilationExtension = this.gl.getExtension("KHR_parallel_shader_compile"), O().getNumber("WEBGL_VERSION") === 1) {
let s = "OES_texture_float", a = "OES_texture_half_float";
- if (this.textureFloatExtension = nc(this.gl, s), Hr(this.gl, a))
- this.textureHalfFloatExtension = nc(this.gl, a);
- else if (P().get("WEBGL_FORCE_F16_TEXTURES"))
+ if (this.textureFloatExtension = ec(this.gl, s), Ur(this.gl, a))
+ this.textureHalfFloatExtension = ec(this.gl, a);
+ else if (O().get("WEBGL_FORCE_F16_TEXTURES"))
throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");
- if (this.colorBufferFloatExtension = this.gl.getExtension(o), Hr(this.gl, n))
- this.colorBufferHalfFloatExtension = nc(this.gl, n);
- else if (P().get("WEBGL_FORCE_F16_TEXTURES"))
+ if (this.colorBufferFloatExtension = this.gl.getExtension(o), Ur(this.gl, n))
+ this.colorBufferHalfFloatExtension = ec(this.gl, n);
+ else if (O().get("WEBGL_FORCE_F16_TEXTURES"))
throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");
- } else if (o = "EXT_color_buffer_float", Hr(this.gl, o))
+ } else if (o = "EXT_color_buffer_float", Ur(this.gl, o))
this.colorBufferFloatExtension = this.gl.getExtension(o);
- else if (Hr(this.gl, n))
+ else if (Ur(this.gl, n))
this.colorBufferHalfFloatExtension = this.gl.getExtension(n);
else
throw new Error("GL context does not support color renderable floats");
- this.vertexBuffer = uw(this.gl), this.indexBuffer = pw(this.gl), this.framebuffer = XI(this.gl), this.textureConfig = El(this.gl, this.textureHalfFloatExtension);
+ this.vertexBuffer = ow(this.gl), this.indexBuffer = nw(this.gl), this.framebuffer = GS(this.gl), this.textureConfig = Sl(this.gl, this.textureHalfFloatExtension);
}
get debug() {
- return P().getBool("DEBUG");
+ return O().getBool("DEBUG");
}
dispose() {
if (this.disposed)
return;
this.program != null && console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."), this.outputTexture != null && console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");
let e = this.gl;
- me(e, () => e.finish()), me(e, () => e.bindFramebuffer(e.FRAMEBUFFER, null)), me(e, () => e.deleteFramebuffer(this.framebuffer)), me(e, () => e.bindBuffer(e.ARRAY_BUFFER, null)), me(e, () => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null)), me(e, () => e.deleteBuffer(this.indexBuffer)), this.disposed = true;
+ ce(e, () => e.finish()), ce(e, () => e.bindFramebuffer(e.FRAMEBUFFER, null)), ce(e, () => e.deleteFramebuffer(this.framebuffer)), ce(e, () => e.bindBuffer(e.ARRAY_BUFFER, null)), ce(e, () => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null)), ce(e, () => e.deleteBuffer(this.indexBuffer)), this.disposed = true;
}
- createFloat32MatrixTexture(e, t10) {
- return this.throwIfDisposed(), cw(this.gl, e, t10, this.textureConfig);
+ createFloat32MatrixTexture(e, t6) {
+ return this.throwIfDisposed(), sw(this.gl, e, t6, this.textureConfig);
}
- createFloat16MatrixTexture(e, t10) {
- return this.throwIfDisposed(), lw(this.gl, e, t10, this.textureConfig);
+ createFloat16MatrixTexture(e, t6) {
+ return this.throwIfDisposed(), aw(this.gl, e, t6, this.textureConfig);
}
- createUnsignedBytesMatrixTexture(e, t10) {
- return this.throwIfDisposed(), mw(this.gl, e, t10, this.textureConfig);
+ createUnsignedBytesMatrixTexture(e, t6) {
+ return this.throwIfDisposed(), iw(this.gl, e, t6, this.textureConfig);
}
- uploadPixelDataToTexture(e, t10) {
- this.throwIfDisposed(), xw(this.gl, e, t10);
+ uploadPixelDataToTexture(e, t6) {
+ this.throwIfDisposed(), mw(this.gl, e, t6);
}
- uploadDenseMatrixToTexture(e, t10, o, n) {
- this.throwIfDisposed(), gw(this.gl, e, t10, o, n, this.textureConfig);
+ uploadDenseMatrixToTexture(e, t6, o, n) {
+ this.throwIfDisposed(), lw(this.gl, e, t6, o, n, this.textureConfig);
}
- createFloat16PackedMatrixTexture(e, t10) {
- return this.throwIfDisposed(), dw(this.gl, e, t10, this.textureConfig);
+ createFloat16PackedMatrixTexture(e, t6) {
+ return this.throwIfDisposed(), pw(this.gl, e, t6, this.textureConfig);
}
- createPackedMatrixTexture(e, t10) {
- return this.throwIfDisposed(), fw(this.gl, e, t10, this.textureConfig);
+ createPackedMatrixTexture(e, t6) {
+ return this.throwIfDisposed(), uw(this.gl, e, t6, this.textureConfig);
}
deleteMatrixTexture(e) {
- this.throwIfDisposed(), this.outputTexture === e && (Ud(this.gl, this.framebuffer), this.outputTexture = null), me(this.gl, () => this.gl.deleteTexture(e));
+ this.throwIfDisposed(), this.outputTexture === e && (Rf(this.gl, this.framebuffer), this.outputTexture = null), ce(this.gl, () => this.gl.deleteTexture(e));
}
- downloadByteEncodedFloatMatrixFromOutputTexture(e, t10, o) {
- return this.downloadMatrixDriver(e, () => Cw(this.gl, t10, o, this.textureConfig));
+ downloadByteEncodedFloatMatrixFromOutputTexture(e, t6, o) {
+ return this.downloadMatrixDriver(e, () => hw(this.gl, t6, o, this.textureConfig));
}
- downloadPackedMatrixFromBuffer(e, t10, o, n, s, a) {
- return Iw(this.gl, e, t10, o, n, s, a, this.textureConfig);
+ downloadPackedMatrixFromBuffer(e, t6, o, n, s, a) {
+ return gw(this.gl, e, t6, o, n, s, a, this.textureConfig);
}
- downloadFloat32MatrixFromBuffer(e, t10) {
- return bw(this.gl, e, t10);
+ downloadFloat32MatrixFromBuffer(e, t6) {
+ return fw(this.gl, e, t6);
}
- createBufferFromTexture(e, t10, o) {
+ createBufferFromTexture(e, t6, o) {
this.bindTextureToFrameBuffer(e);
- let n = yw(this.gl, t10, o, this.textureConfig);
+ let n = dw(this.gl, t6, o, this.textureConfig);
return this.unbindTextureToFrameBuffer(), n;
}
createAndWaitForFence() {
@@ -17099,72 +17154,78 @@ var Fu = class {
return this.pollFence(e);
}
createFence(e) {
- let t10, o;
- if (P().getBool("WEBGL_FENCE_API_ENABLED")) {
+ let t6, o;
+ if (O().getBool("WEBGL_FENCE_API_ENABLED")) {
let n = e, s = n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE, 0);
e.flush(), o = () => {
let a = n.clientWaitSync(s, 0, 0);
return a === n.ALREADY_SIGNALED || a === n.CONDITION_SATISFIED;
- }, t10 = s;
+ }, t6 = s;
} else
- P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 ? (t10 = this.beginQuery(), this.endQuery(), o = () => this.isQueryAvailable(t10, P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))) : o = () => true;
- return { query: t10, isFencePassed: o };
+ O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 ? (t6 = this.beginQuery(), this.endQuery(), o = () => this.isQueryAvailable(t6, O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))) : o = () => true;
+ return { query: t6, isFencePassed: o };
}
- downloadMatrixFromPackedTexture(e, t10, o) {
- return this.downloadMatrixDriver(e, () => ww(this.gl, t10, o));
+ downloadMatrixFromPackedTexture(e, t6, o) {
+ return this.downloadMatrixDriver(e, () => xw(this.gl, t6, o));
}
createProgram(e) {
this.throwIfDisposed();
- let t10 = this.gl;
- this.vertexShader == null && (this.vertexShader = iw(t10));
- let o = UI(t10);
- return me(t10, () => t10.attachShader(o, this.vertexShader)), me(t10, () => t10.attachShader(o, e)), GI(t10, o), this.debug && $l(t10, o), this.vertexAttrsAreBound || (this.setProgram(o), this.vertexAttrsAreBound = hw(t10, this.program, this.vertexBuffer)), o;
+ let t6 = this.gl;
+ this.vertexShader == null && (this.vertexShader = rw(t6));
+ let o = LS(t6);
+ ce(t6, () => t6.attachShader(o, this.vertexShader)), ce(t6, () => t6.attachShader(o, e)), BS(t6, o);
+ let n;
+ return n = Object.assign(o, { vao: this.createVertexArray() }), this.bindVertexArray(n.vao), ce(t6, () => t6.bindBuffer(t6.ELEMENT_ARRAY_BUFFER, this.indexBuffer)), console.assert(cw(t6, n, this.vertexBuffer), "gpgpu_util.bindVertexProgramAttributeStreams not fully successful."), this.debug && wl(t6, n), this.setProgram(n), n;
}
deleteProgram(e) {
- this.throwIfDisposed(), e === this.program && (this.program = null), e != null && me(this.gl, () => this.gl.deleteProgram(e));
+ this.throwIfDisposed(), e === this.program && (this.program = null), e != null && (ce(this.gl, () => this.gl.deleteProgram(e)), this.deleteVertexArray(e.vao));
}
setProgram(e) {
- this.throwIfDisposed(), this.program = e, this.program != null && this.debug && $l(this.gl, this.program), me(this.gl, () => this.gl.useProgram(e));
+ this.throwIfDisposed(), this.program = e, this.program != null && (this.bindVertexArray(this.program.vao), this.debug && wl(this.gl, this.program)), ce(this.gl, () => this.gl.useProgram(e));
}
- getUniformLocation(e, t10, o = true) {
- return this.throwIfDisposed(), o ? YI(this.gl, e, t10) : QI(this.gl, e, t10);
+ getUniformLocation(e, t6, o = true) {
+ return this.throwIfDisposed(), o ? HS(this.gl, e, t6) : qS(this.gl, e, t6);
}
- getAttributeLocation(e, t10) {
- return this.throwIfDisposed(), me(this.gl, () => this.gl.getAttribLocation(e, t10));
+ getAttributeLocation(e, t6) {
+ return this.throwIfDisposed(), ce(this.gl, () => this.gl.getAttribLocation(e, t6));
}
- getUniformLocationNoThrow(e, t10) {
- return this.throwIfDisposed(), this.gl.getUniformLocation(e, t10);
+ getUniformLocationNoThrow(e, t6) {
+ return this.throwIfDisposed(), this.gl.getUniformLocation(e, t6);
}
- setInputMatrixTexture(e, t10, o) {
- this.throwIfDisposed(), this.throwIfNoProgram(), ZI(this.gl, e, t10, o);
+ setInputMatrixTexture(e, t6, o) {
+ this.throwIfDisposed(), this.throwIfNoProgram(), KS(this.gl, e, t6, o);
}
- setOutputMatrixTexture(e, t10, o) {
- this.setOutputMatrixTextureDriver(e, o, t10);
+ setOutputMatrixTexture(e, t6, o) {
+ this.setOutputMatrixTextureDriver(e, o, t6);
}
- setOutputPackedMatrixTexture(e, t10, o) {
+ setOutputPackedMatrixTexture(e, t6, o) {
this.throwIfDisposed();
- let [n, s] = Ks(t10, o);
+ let [n, s] = Ys(t6, o);
this.setOutputMatrixTextureDriver(e, n, s);
}
- setOutputMatrixWriteRegion(e, t10, o, n) {
- this.setOutputMatrixWriteRegionDriver(o, e, n, t10);
+ setOutputMatrixWriteRegion(e, t6, o, n) {
+ this.setOutputMatrixWriteRegionDriver(o, e, n, t6);
}
- setOutputPackedMatrixWriteRegion(e, t10, o, n) {
+ setOutputPackedMatrixWriteRegion(e, t6, o, n) {
throw new Error("setOutputPackedMatrixWriteRegion not implemented.");
}
debugValidate() {
- this.program != null && $l(this.gl, this.program), sc(this.gl);
+ this.program != null && wl(this.gl, this.program), tc(this.gl);
}
executeProgram() {
this.throwIfDisposed(), this.throwIfNoProgram();
let e = this.gl;
- this.debug && this.debugValidate(), me(e, () => e.drawElements(e.TRIANGLES, 6, e.UNSIGNED_SHORT, 0));
+ if (this.debug) {
+ let t6 = this.getVertexArray();
+ console.assert(t6 === this.program.vao, "VAO changed between setProgram and executeProgram!"), this.debugValidate();
+ }
+ ce(e, () => e.drawElements(e.TRIANGLES, 6, e.UNSIGNED_SHORT, 0));
}
blockUntilAllProgramsCompleted() {
- this.throwIfDisposed(), me(this.gl, () => this.gl.finish());
+ this.throwIfDisposed(), ce(this.gl, () => this.gl.finish());
}
getQueryTimerExtension() {
- return this.disjointQueryTimerExtension == null && (this.disjointQueryTimerExtension = nc(this.gl, P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2 ? "EXT_disjoint_timer_query_webgl2" : "EXT_disjoint_timer_query")), this.disjointQueryTimerExtension;
+ return this.disjointQueryTimerExtension == null && (this.disjointQueryTimerExtension = ec(this.gl, O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2 ? "EXT_disjoint_timer_query_webgl2" : "EXT_disjoint_timer_query")), this.disjointQueryTimerExtension;
}
getQueryTimerExtensionWebGL2() {
return this.getQueryTimerExtension();
@@ -17173,29 +17234,29 @@ var Fu = class {
return this.getQueryTimerExtension();
}
beginQuery() {
- if (P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2) {
+ if (O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2) {
let o = this.gl, n = this.getQueryTimerExtensionWebGL2(), s = o.createQuery();
return o.beginQuery(n.TIME_ELAPSED_EXT, s), s;
}
- let e = this.getQueryTimerExtensionWebGL1(), t10 = e.createQueryEXT();
- return e.beginQueryEXT(e.TIME_ELAPSED_EXT, t10), t10;
+ let e = this.getQueryTimerExtensionWebGL1(), t6 = e.createQueryEXT();
+ return e.beginQueryEXT(e.TIME_ELAPSED_EXT, t6), t6;
}
endQuery() {
- if (P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2) {
- let t10 = this.gl, o = this.getQueryTimerExtensionWebGL2();
- t10.endQuery(o.TIME_ELAPSED_EXT);
+ if (O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2) {
+ let t6 = this.gl, o = this.getQueryTimerExtensionWebGL2();
+ t6.endQuery(o.TIME_ELAPSED_EXT);
return;
}
let e = this.getQueryTimerExtensionWebGL1();
e.endQueryEXT(e.TIME_ELAPSED_EXT);
}
async waitForQueryAndGetTime(e) {
- return await x.repeatedTry(() => this.disposed || this.isQueryAvailable(e, P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))), this.getQueryTime(e, P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"));
+ return await y.repeatedTry(() => this.disposed || this.isQueryAvailable(e, O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))), this.getQueryTime(e, O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"));
}
- getQueryTime(e, t10) {
- if (t10 === 0)
+ getQueryTime(e, t6) {
+ if (t6 === 0)
return null;
- if (t10 === 2) {
+ if (t6 === 2) {
let o = this.gl;
return o.getQueryParameter(e, o.QUERY_RESULT) / 1e6;
} else {
@@ -17203,10 +17264,10 @@ var Fu = class {
return o.getQueryObjectEXT(e, o.QUERY_RESULT_EXT) / 1e6;
}
}
- isQueryAvailable(e, t10) {
- if (t10 === 0)
+ isQueryAvailable(e, t6) {
+ if (t6 === 0)
return true;
- if (t10 === 2) {
+ if (t6 === 2) {
let o = this.gl, n = this.getQueryTimerExtensionWebGL2(), s = o.getQueryParameter(e, o.QUERY_RESULT_AVAILABLE);
return this.disjoint == null && (this.disjoint = this.gl.getParameter(n.GPU_DISJOINT_EXT)), s && !this.disjoint;
} else {
@@ -17215,42 +17276,42 @@ var Fu = class {
}
}
pollFence(e) {
- return new Promise((t10) => {
- this.addItemToPoll(() => e.isFencePassed(), () => t10());
+ return new Promise((t6) => {
+ this.addItemToPoll(() => e.isFencePassed(), () => t6());
});
}
pollItems() {
- let e = rY(this.itemsToPoll.map((t10) => t10.isDoneFn));
- for (let t10 = 0; t10 <= e; ++t10) {
- let { resolveFn: o } = this.itemsToPoll[t10];
+ let e = v8(this.itemsToPoll.map((t6) => t6.isDoneFn));
+ for (let t6 = 0; t6 <= e; ++t6) {
+ let { resolveFn: o } = this.itemsToPoll[t6];
o();
}
this.itemsToPoll = this.itemsToPoll.slice(e + 1);
}
- addItemToPoll(e, t10) {
- if (this.itemsToPoll.push({ isDoneFn: e, resolveFn: t10 }), this.itemsToPoll.length > 1)
+ addItemToPoll(e, t6) {
+ if (this.itemsToPoll.push({ isDoneFn: e, resolveFn: t6 }), this.itemsToPoll.length > 1)
return;
let o;
- "setTimeoutCustom" in P().platform && (o = P().platform.setTimeoutCustom.bind(P().platform)), x.repeatedTry(() => (this.pollItems(), this.itemsToPoll.length === 0), () => 0, null, o);
+ "setTimeoutCustom" in O().platform && (o = O().platform.setTimeoutCustom.bind(O().platform)), y.repeatedTry(() => (this.pollItems(), this.itemsToPoll.length === 0), () => 0, null, o);
}
bindTextureToFrameBuffer(e) {
- this.throwIfDisposed(), Rl(this.gl, e, this.framebuffer), this.debug && sc(this.gl);
+ this.throwIfDisposed(), Il(this.gl, e, this.framebuffer), this.debug && tc(this.gl);
}
unbindTextureToFrameBuffer() {
- this.outputTexture != null ? (Rl(this.gl, this.outputTexture, this.framebuffer), this.debug && sc(this.gl)) : Ud(this.gl, this.framebuffer);
+ this.outputTexture != null ? (Il(this.gl, this.outputTexture, this.framebuffer), this.debug && tc(this.gl)) : Rf(this.gl, this.framebuffer);
}
- downloadMatrixDriver(e, t10) {
+ downloadMatrixDriver(e, t6) {
this.bindTextureToFrameBuffer(e);
- let o = t10();
+ let o = t6();
return this.unbindTextureToFrameBuffer(), o;
}
- setOutputMatrixTextureDriver(e, t10, o) {
+ setOutputMatrixTextureDriver(e, t6, o) {
this.throwIfDisposed();
let n = this.gl;
- Rl(n, e, this.framebuffer), this.debug && sc(n), this.outputTexture = e, me(n, () => n.viewport(0, 0, t10, o)), me(n, () => n.scissor(0, 0, t10, o));
+ Il(n, e, this.framebuffer), this.debug && tc(n), this.outputTexture = e, ce(n, () => n.viewport(0, 0, t6, o)), ce(n, () => n.scissor(0, 0, t6, o));
}
- setOutputMatrixWriteRegionDriver(e, t10, o, n) {
- this.throwIfDisposed(), me(this.gl, () => this.gl.scissor(e, t10, o, n));
+ setOutputMatrixWriteRegionDriver(e, t6, o, n) {
+ this.throwIfDisposed(), ce(this.gl, () => this.gl.scissor(e, t6, o, n));
}
throwIfDisposed() {
if (this.disposed)
@@ -17261,37 +17322,37 @@ var Fu = class {
throw new Error("No GPU program is currently set.");
}
};
-function rY(r) {
+function v8(r) {
let e = 0;
for (; e < r.length && r[e](); ++e)
;
return e - 1;
}
-var { addImpl: s$, bincountImpl: oh, bincountReduceImpl: a$, castImpl: i$, ceilImpl: u$, concatImpl: p$, equalImpl: c$, expImpl: l$, expm1Impl: m$, floorImpl: f$, gatherNdImpl: d$, gatherV2Impl: h$, greaterImpl: g$, greaterEqualImpl: x$, lessImpl: y$, lessEqualImpl: b$, linSpaceImpl: C$, logImpl: I$, maxImpl: w$, maximumImpl: S$, minimumImpl: v$, multiplyImpl: k$, negImpl: T$, notEqualImpl: N$, prodImpl: _$, raggedGatherImpl: E$, raggedRangeImpl: $$, raggedTensorToTensorImpl: R$, rangeImpl: A$, rsqrtImpl: F$, scatterImpl: D$, sigmoidImpl: P$, simpleAbsImpl: nh, sliceImpl: O$, sparseFillEmptyRowsImpl: M$, sparseReshapeImpl: L$, sparseSegmentReductionImpl: sh, sqrtImpl: B$, stridedSliceImpl: V$, stringNGramsImpl: z$, stringSplitImpl: W$, stringToHashBucketFastImpl: U$, subImpl: G$, tileImpl: H$, topKImpl: q$, transposeImpl: Du, uniqueImpl: K$ } = Ad;
-function vw(r, e) {
- return ["x", "y", "z", "w", "u", "v"].slice(0, e).map((t10) => `${r}.${t10}`);
+var { addImpl: DE, bincountImpl: qf, bincountReduceImpl: OE, castImpl: PE, ceilImpl: ME, concatImpl: LE, equalImpl: BE, expImpl: VE, expm1Impl: zE, floorImpl: WE, gatherNdImpl: UE, gatherV2Impl: GE, greaterImpl: HE, greaterEqualImpl: qE, lessImpl: KE, lessEqualImpl: jE, linSpaceImpl: XE, logImpl: YE, maxImpl: QE, maximumImpl: ZE, minimumImpl: JE, multiplyImpl: e$, negImpl: t$, notEqualImpl: r$, prodImpl: o$, raggedGatherImpl: n$, raggedRangeImpl: s$, raggedTensorToTensorImpl: a$, rangeImpl: i$, rsqrtImpl: u$, scatterImpl: p$, sigmoidImpl: c$, simpleAbsImpl: Kf, sliceImpl: l$, sparseFillEmptyRowsImpl: m$, sparseReshapeImpl: d$, sparseSegmentReductionImpl: jf, sqrtImpl: f$, stridedSliceImpl: h$, stringNGramsImpl: g$, stringSplitImpl: x$, stringToHashBucketFastImpl: y$, subImpl: b$, tileImpl: C$, topKImpl: S$, transposeImpl: Du, uniqueImpl: w$ } = Qp;
+function bw(r, e) {
+ return ["x", "y", "z", "w", "u", "v"].slice(0, e).map((t6) => `${r}.${t6}`);
}
function $t(r, e) {
- return e === 1 ? [r] : vw(r, e);
+ return e === 1 ? [r] : bw(r, e);
}
-function j$(r, e) {
+function I$(r, e) {
if (r === 1)
return "rc";
- let t10 = "";
+ let t6 = "";
for (let o = 0; o < r; o++)
- t10 += e[o], o < r - 1 && (t10 += ",");
- return t10;
+ t6 += e[o], o < r - 1 && (t6 += ",");
+ return t6;
}
-var ah = class {
+var Xf = class {
constructor(e) {
- if (this.variableNames = ["A"], this.packedInputs = false, this.packedOutput = true, this.outputShape = e, this.rank = e.length, this.enableShapeUniforms = lt(this.outputShape.length), this.rank === 0)
+ if (this.variableNames = ["A"], this.packedInputs = false, this.packedOutput = true, this.outputShape = e, this.rank = e.length, this.enableShapeUniforms = ct(this.outputShape.length), this.rank === 0)
this.userCode = `
void main() {
setOutput(vec4(getA(), 0., 0., 0.));
}
`;
else {
- let t10 = $t("rc", this.rank), o = _e(this.rank), n = this.getOutOfBoundsCondition(t10), s = this.getSetup(t10), a = this.getOutput(t10);
+ let t6 = $t("rc", this.rank), o = _e(this.rank), n = this.getOutOfBoundsCondition(t6), s = this.getSetup(t6), a = this.getOutput(t6);
this.userCode = `
void main() {
${o} rc = getOutputCoords();
@@ -17308,31 +17369,31 @@ var ah = class {
}
}
getSourceCoordsArr(e) {
- let t10 = [];
+ let t6 = [];
for (let o = 0; o <= 1; o++)
for (let n = 0; n <= 1; n++) {
let s = `${o === 0 ? "r" : "rp1"}, ${n === 0 ? "c" : "cp1"}`;
for (let a = 2; a < this.rank; a++)
s = `${e[e.length - 1 - a]},` + s;
- t10.push(s);
+ t6.push(s);
}
- return t10;
+ return t6;
}
getOutOfBoundsCondition(e) {
if (this.rank === 1)
return `rc > ${this.enableShapeUniforms ? "outShape" : this.outputShape[0]}`;
- let t10 = "";
+ let t6 = "";
for (let o = this.rank - 2; o < this.rank; o++)
- t10 += `${e[o]} >= ${this.enableShapeUniforms ? `outShape[${o}]` : this.outputShape[o]}`, o < this.rank - 1 && (t10 += "||");
- return t10;
+ t6 += `${e[o]} >= ${this.enableShapeUniforms ? `outShape[${o}]` : this.outputShape[o]}`, o < this.rank - 1 && (t6 += "||");
+ return t6;
}
getSetup(e) {
if (this.rank === 1)
return "";
- let t10 = e.slice(-2), o = this.enableShapeUniforms ? `outShape[${this.rank} - 1]` : this.outputShape[this.rank - 1], n = this.enableShapeUniforms ? `outShape[${this.rank} - 2]` : this.outputShape[this.rank - 2];
+ let t6 = e.slice(-2), o = this.enableShapeUniforms ? `outShape[${this.rank} - 1]` : this.outputShape[this.rank - 1], n = this.enableShapeUniforms ? `outShape[${this.rank} - 2]` : this.outputShape[this.rank - 2];
return `
- int r = ${t10[0]};
- int c = ${t10[1]};
+ int r = ${t6[0]};
+ int c = ${t6[1]};
int rp1 = r + 1;
int cp1 = c + 1;
@@ -17341,16 +17402,16 @@ var ah = class {
`;
}
getOutput(e) {
- let t10 = this.getSourceCoordsArr(e);
- return this.rank === 1 ? `getA(rc), (rc + 1 >= ${this.enableShapeUniforms ? "outShape" : this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0` : `getA(${t10[0]}),
- cEdge ? 0. : getA(${t10[1]}),
- rEdge ? 0. : getA(${t10[2]}),
- rEdge || cEdge ? 0. : getA(${t10[3]})`;
+ let t6 = this.getSourceCoordsArr(e);
+ return this.rank === 1 ? `getA(rc), (rc + 1 >= ${this.enableShapeUniforms ? "outShape" : this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0` : `getA(${t6[0]}),
+ cEdge ? 0. : getA(${t6[1]}),
+ rEdge ? 0. : getA(${t6[2]}),
+ rEdge || cEdge ? 0. : getA(${t6[3]})`;
}
};
-var hc = class {
- constructor(e, t10) {
- this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = e, this.enableShapeUniforms = lt(this.outputShape.length);
+var lc = class {
+ constructor(e, t6) {
+ this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = e, this.enableShapeUniforms = ct(this.outputShape.length);
let o = "";
for (let n = 0; n < 4; n++) {
let s = "thisRC = rc;";
@@ -17368,8 +17429,8 @@ var hc = class {
`;
}
this.userCode = `
- ${oY(t10, this.enableShapeUniforms)}
- ${this.enableShapeUniforms ? pc() : uc(e)}
+ ${k8(t6, this.enableShapeUniforms)}
+ ${this.enableShapeUniforms ? sc() : nc(e)}
void main() {
ivec3 rc = getOutputCoords();
@@ -17387,36 +17448,36 @@ var hc = class {
`;
}
};
-function oY(r, e) {
+function k8(r, e) {
return `
ivec3 inputCoordsFromReshapedOutCoords(int index) {
- ${e ? YE(["r", "c", "d"], "inputShape") : is(["r", "c", "d"], r)}
+ ${e ? kE(["r", "c", "d"], "inputShape") : us(["r", "c", "d"], r)}
return ivec3(r, c, d);
}
`;
}
-var ih = class {
+var Yf = class {
constructor(e) {
this.gpgpu = e, this.numUsedTextures = 0, this.numFreeTextures = 0, this._numBytesAllocated = 0, this._numBytesFree = 0, this.freeTextures = {}, this.logEnabled = false, this.usedTextures = {};
}
- acquireTexture(e, t10, o) {
- let n = Y$(t10, o), s = Q$(e, n, o);
+ acquireTexture(e, t6, o) {
+ let n = k$(t6, o), s = N$(e, n, o);
s in this.freeTextures || (this.freeTextures[s] = []), s in this.usedTextures || (this.usedTextures[s] = []);
- let a = X$(e, n, this.gpgpu.gl, this.gpgpu.textureConfig, o);
+ let a = v$(e, n, this.gpgpu.gl, this.gpgpu.textureConfig, o);
if (this.freeTextures[s].length > 0) {
this.numFreeTextures--, this.numUsedTextures++, this._numBytesFree -= a, this.log();
let p = this.freeTextures[s].shift();
return this.usedTextures[s].push(p), p;
}
let i;
- return n === Jt.PACKED_2X2_FLOAT32 ? i = this.gpgpu.createPackedMatrixTexture(e[0], e[1]) : n === Jt.PACKED_2X2_FLOAT16 ? i = this.gpgpu.createFloat16PackedMatrixTexture(e[0], e[1]) : n === Jt.UNPACKED_FLOAT32 ? i = this.gpgpu.createFloat32MatrixTexture(e[0], e[1]) : n === Jt.UNPACKED_FLOAT16 ? i = this.gpgpu.createFloat16MatrixTexture(e[0], e[1]) : n === Jt.PACKED_4X1_UNSIGNED_BYTE && (i = this.gpgpu.createUnsignedBytesMatrixTexture(e[0], e[1])), this.usedTextures[s].push(i), this.numUsedTextures++, this._numBytesAllocated += a, this.log(), i;
+ return n === Zt.PACKED_2X2_FLOAT32 ? i = this.gpgpu.createPackedMatrixTexture(e[0], e[1]) : n === Zt.PACKED_2X2_FLOAT16 ? i = this.gpgpu.createFloat16PackedMatrixTexture(e[0], e[1]) : n === Zt.UNPACKED_FLOAT32 ? i = this.gpgpu.createFloat32MatrixTexture(e[0], e[1]) : n === Zt.UNPACKED_FLOAT16 ? i = this.gpgpu.createFloat16MatrixTexture(e[0], e[1]) : n === Zt.PACKED_4X1_UNSIGNED_BYTE && (i = this.gpgpu.createUnsignedBytesMatrixTexture(e[0], e[1])), this.usedTextures[s].push(i), this.numUsedTextures++, this._numBytesAllocated += a, this.log(), i;
}
- releaseTexture(e, t10, o, n) {
+ releaseTexture(e, t6, o, n) {
if (this.freeTextures == null)
return;
- let s = Y$(o, n), a = Q$(t10, s, n);
+ let s = k$(o, n), a = N$(t6, s, n);
a in this.freeTextures || (this.freeTextures[a] = []);
- let i = X$(t10, s, this.gpgpu.gl, this.gpgpu.textureConfig, n), p = P().get("WEBGL_DELETE_TEXTURE_THRESHOLD");
+ let i = v$(t6, s, this.gpgpu.gl, this.gpgpu.textureConfig, n), p = O().get("WEBGL_DELETE_TEXTURE_THRESHOLD");
p !== -1 && this._numBytesAllocated > p ? (this.gpgpu.deleteMatrixTexture(e.texture), this._numBytesAllocated -= i) : (this.freeTextures[a].push(e), this.numFreeTextures++, this._numBytesFree += i), this.numUsedTextures--;
let u = this.usedTextures[a], c = u.indexOf(e);
if (c < 0)
@@ -17428,8 +17489,8 @@ var ih = class {
return;
let e = this.numFreeTextures + this.numUsedTextures;
console.log("Free/Used", `${this.numFreeTextures} / ${this.numUsedTextures}`, `(${e})`);
- let t10 = this._numBytesFree / this._numBytesAllocated;
- console.log(`Bytes allocated: ${this._numBytesAllocated}`), console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100 * t10)}%)`);
+ let t6 = this._numBytesFree / this._numBytesAllocated;
+ console.log(`Bytes allocated: ${this._numBytesAllocated}`), console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100 * t6)}%)`);
}
get numBytesAllocated() {
return this._numBytesAllocated;
@@ -17446,81 +17507,81 @@ var ih = class {
dispose() {
if (this.freeTextures != null) {
for (let e in this.freeTextures)
- this.freeTextures[e].forEach((t10) => {
- this.gpgpu.deleteMatrixTexture(t10.texture);
+ this.freeTextures[e].forEach((t6) => {
+ this.gpgpu.deleteMatrixTexture(t6.texture);
});
for (let e in this.usedTextures)
- this.usedTextures[e].forEach((t10) => {
- this.gpgpu.deleteMatrixTexture(t10.texture);
+ this.usedTextures[e].forEach((t6) => {
+ this.gpgpu.deleteMatrixTexture(t6.texture);
});
this.freeTextures = null, this.usedTextures = null, this.numUsedTextures = 0, this.numFreeTextures = 0, this._numBytesAllocated = 0, this._numBytesFree = 0;
}
}
};
-function nY(r, e) {
- let t10 = r;
- if (e === t10.R32F)
+function N8(r, e) {
+ let t6 = r;
+ if (e === t6.R32F)
return 4;
- if (e === t10.R16F)
+ if (e === t6.R16F)
return 2;
- if (e === t10.RGBA32F)
+ if (e === t6.RGBA32F)
return 16;
if (e === r.RGBA)
return 16;
- if (e === t10.RGBA16F)
+ if (e === t6.RGBA16F)
return 8;
- if (e === t10.RGBA8)
+ if (e === t6.RGBA8)
return 4;
throw new Error(`Unknown internal format ${e}`);
}
-function X$(r, e, t10, o, n) {
- let s = sY(e, o), a;
+function v$(r, e, t6, o, n) {
+ let s = T8(e, o), a;
if (n) {
- let [p, u] = Ks(r[0], r[1]);
+ let [p, u] = Ys(r[0], r[1]);
a = p * u;
} else {
let [p, u] = $u(r[0], r[1]);
a = p * u;
}
- let i = nY(t10, s);
+ let i = N8(t6, s);
return a * i;
}
-function sY(r, e) {
+function T8(r, e) {
switch (r) {
- case Jt.PACKED_2X2_FLOAT32:
- return th(e);
- case Jt.PACKED_2X2_FLOAT16:
- return rh(e);
- case Jt.UNPACKED_FLOAT32:
- return Zd(e);
- case Jt.UNPACKED_FLOAT16:
- return Jd(e);
- case Jt.PACKED_4X1_UNSIGNED_BYTE:
- return eh(e);
+ case Zt.PACKED_2X2_FLOAT32:
+ return Gf(e);
+ case Zt.PACKED_2X2_FLOAT16:
+ return Hf(e);
+ case Zt.UNPACKED_FLOAT32:
+ return zf(e);
+ case Zt.UNPACKED_FLOAT16:
+ return Wf(e);
+ case Zt.PACKED_4X1_UNSIGNED_BYTE:
+ return Uf(e);
default:
throw new Error(`Unknown physical texture type ${r}`);
}
}
-function aY(r) {
- return P().getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? r ? Jt.PACKED_2X2_FLOAT32 : Jt.UNPACKED_FLOAT32 : r ? Jt.PACKED_2X2_FLOAT16 : Jt.UNPACKED_FLOAT16;
+function _8(r) {
+ return O().getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? r ? Zt.PACKED_2X2_FLOAT32 : Zt.UNPACKED_FLOAT32 : r ? Zt.PACKED_2X2_FLOAT16 : Zt.UNPACKED_FLOAT16;
}
-function Y$(r, e) {
+function k$(r, e) {
if (r === ir.UPLOAD)
- return Jt.PACKED_2X2_FLOAT32;
+ return Zt.PACKED_2X2_FLOAT32;
if (r === ir.RENDER || r == null)
- return aY(e);
+ return _8(e);
if (r === ir.DOWNLOAD || r === ir.PIXELS)
- return Jt.PACKED_4X1_UNSIGNED_BYTE;
+ return Zt.PACKED_4X1_UNSIGNED_BYTE;
throw new Error(`Unknown logical texture type ${r}`);
}
-function Q$(r, e, t10) {
- return `${r[0]}_${r[1]}_${e}_${t10}`;
+function N$(r, e, t6) {
+ return `${r[0]}_${r[1]}_${e}_${t6}`;
}
-var fr = class {
- constructor(e, t10) {
- this.variableNames = ["A"], this.outputShape = e, this.enableShapeUniforms = lt(this.outputShape.length), this.userCode = `
+var Jt = class {
+ constructor(e, t6) {
+ this.variableNames = ["A"], this.outputShape = e, this.enableShapeUniforms = ct(this.outputShape.length), this.userCode = `
float unaryOperation(float x) {
- ${t10}
+ ${t6}
}
void main() {
@@ -17532,20 +17593,20 @@ var fr = class {
`;
}
};
-var Vt = "if (isnan(x)) return x;";
-var Z$ = "return x;";
-var kw = "return abs(x);";
-var J$ = "return (x >= 0.0) ? x : (exp(x) - 1.0);";
-var eR = Vt + `
+var Bt = "if (isnan(x)) return x;";
+var T$ = "return x;";
+var Cw = "return abs(x);";
+var _$ = "return (x >= 0.0) ? x : (exp(x) - 1.0);";
+var E$ = Bt + `
return (x < 0.0) ? 0.0 : x;
`;
-var tR = Vt + `
+var $$ = Bt + `
return (x < 0.0) ? 0.0 : min(6.0, x);
`;
-var Pu = "return x;";
-var rR = "return 1.0 / (1.0 + exp(-1.0 * x));";
-var nR = "return x;";
-var sR = `
+var Qs = "return x;";
+var A$ = "return 1.0 / (1.0 + exp(-1.0 * x));";
+var F$ = "return x;";
+var D$ = `
vec4 result;
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
@@ -17555,7 +17616,7 @@ var sR = `
return result;
`;
-var aR = `
+var O$ = `
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
@@ -17566,7 +17627,7 @@ var aR = `
return result;
`;
-var iR = `
+var P$ = `
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
@@ -17577,12 +17638,12 @@ var iR = `
return result;
`;
-var uR = "return 1.0 / (1.0 + exp(-1.0 * x));";
-var No = class {
- constructor(e, t10) {
- this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.outputShape = e, this.enableShapeUniforms = lt(this.outputShape.length), this.userCode = `
+var M$ = "return 1.0 / (1.0 + exp(-1.0 * x));";
+var Ar = class {
+ constructor(e, t6) {
+ this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.outputShape = e, this.enableShapeUniforms = ct(this.outputShape.length), this.userCode = `
vec4 unaryOperation(vec4 x) {
- ${t10}
+ ${t6}
}
void main() {
@@ -17594,10 +17655,10 @@ var No = class {
`;
}
};
-var uh = class {
+var Qf = class {
constructor(e) {
- this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = false, this.outputShape = e, this.enableShapeUniforms = lt(this.outputShape.length);
- let t10 = e.length, o = $t("rc", t10), n = _e(t10), s = j$(t10, o), a = o.slice(-2), i = t10 <= 1 ? "rc" : `vec2(${a.join(",")})`;
+ this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = false, this.outputShape = e, this.enableShapeUniforms = ct(this.outputShape.length);
+ let t6 = e.length, o = $t("rc", t6), n = _e(t6), s = I$(t6, o), a = o.slice(-2), i = t6 <= 1 ? "rc" : `vec2(${a.join(",")})`;
this.userCode = `
void main() {
${n} rc = getOutputCoords();
@@ -17608,194 +17669,194 @@ var uh = class {
`;
}
};
-var uY = Bt.whereImpl;
-var pY = 1e-7;
-var cY = 1e-4;
-var ph = {};
-function lY(r) {
- return r in ph || (ph[r] = {}), ph[r];
+var $8 = Lt.whereImpl;
+var A8 = 1e-7;
+var R8 = 1e-4;
+var Zf = {};
+function F8(r) {
+ return r in Zf || (Zf[r] = {}), Zf[r];
}
-var mY = P().getNumber("CPU_HANDOFF_SIZE_THRESHOLD");
-var fY = 600;
-function dY() {
- return P().global.screen == null ? 1024 : P().global.screen.height * P().global.screen.width * window.devicePixelRatio * fY / 1024 / 1024;
+var D8 = O().getNumber("CPU_HANDOFF_SIZE_THRESHOLD");
+var O8 = 600;
+function P8() {
+ return O().global.screen == null ? 1024 : O().global.screen.height * O().global.screen.width * window.devicePixelRatio * O8 / 1024 / 1024;
}
-var Ni = class extends Jr {
+var Bi = class extends Zr {
constructor(e) {
- if (super(), this.pendingRead = /* @__PURE__ */ new WeakMap(), this.pendingDisposal = /* @__PURE__ */ new WeakSet(), this.dataRefCount = /* @__PURE__ */ new WeakMap(), this.numBytesInGPU = 0, this.uploadWaitMs = 0, this.downloadWaitMs = 0, this.lastGlFlushTime = 0, this.warnedAboutMemory = false, this.pendingDeletes = 0, this.disposed = false, !P().getBool("HAS_WEBGL"))
+ if (super(), this.pendingRead = /* @__PURE__ */ new WeakMap(), this.pendingDisposal = /* @__PURE__ */ new WeakSet(), this.dataRefCount = /* @__PURE__ */ new WeakMap(), this.numBytesInGPU = 0, this.uploadWaitMs = 0, this.downloadWaitMs = 0, this.lastGlFlushTime = 0, this.warnedAboutMemory = false, this.pendingDeletes = 0, this.disposed = false, !O().getBool("HAS_WEBGL"))
throw new Error("WebGL is not supported on this device");
- let t10;
+ let t6;
if (e != null) {
if (e instanceof Fu)
- t10 = e;
+ t6 = e;
else {
- let o = Gr(P().getNumber("WEBGL_VERSION"), e);
- t10 = new Fu(o);
+ let o = Wr(O().getNumber("WEBGL_VERSION"), e);
+ t6 = new Fu(o);
}
this.binaryCache = {}, this.gpgpuCreatedLocally = false;
} else {
- let o = Gr(P().getNumber("WEBGL_VERSION"));
- t10 = new Fu(o), this.binaryCache = lY(P().getNumber("WEBGL_VERSION")), this.gpgpuCreatedLocally = true;
+ let o = Wr(O().getNumber("WEBGL_VERSION"));
+ t6 = new Fu(o), this.binaryCache = F8(O().getNumber("WEBGL_VERSION")), this.gpgpuCreatedLocally = true;
}
- this.gpgpu = t10, this.canvas = this.gpgpu.gl.canvas, this.textureManager = new ih(this.gpgpu), this.numMBBeforeWarning = dY(), this.texData = new rn(this, cr());
+ this.gpgpu = t6, this.canvas = this.gpgpu.gl.canvas, this.textureManager = new Yf(this.gpgpu), this.numMBBeforeWarning = P8(), this.texData = new Do(this, cr());
}
nextDataId() {
- return Ni.nextDataId++;
+ return Bi.nextDataId++;
}
numDataIds() {
return this.texData.numDataIds() - this.pendingDeletes;
}
- writeTexture(e, t10, o, n, s, a) {
- let i = this.makeTensorInfo(t10, o), p = this.texData.get(i.dataId);
+ writeTexture(e, t6, o, n, s, a) {
+ let i = this.makeTensorInfo(t6, o), p = this.texData.get(i.dataId);
p.isPacked = false, p.texture = { texture: e, texShape: [n, s] }, p.texShape = [n, s];
- let u = ac(t10), c = new Al(u, false, a), l = this.runWebGLProgram(c, [i], o, [[n, s]]);
- return l.shape = t10, p.texture = null, this.disposeIntermediateTensorInfo(i), l.dataId;
+ let u = rc(t6), c = new vl(u, false, a), l = this.runWebGLProgram(c, [i], o, [[n, s]]);
+ return l.shape = t6, p.texture = null, this.disposeIntermediateTensorInfo(i), l.dataId;
}
- write(e, t10, o) {
- if ((P().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS") || P().getBool("DEBUG")) && this.checkNumericalProblems(e), o === "complex64" && e != null)
+ write(e, t6, o) {
+ if ((O().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS") || O().getBool("DEBUG")) && this.checkNumericalProblems(e), o === "complex64" && e != null)
throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");
let n = { id: this.nextDataId() };
- return this.texData.set(n, { shape: t10, dtype: o, values: e, usage: ir.UPLOAD, refCount: 1 }), n;
+ return this.texData.set(n, { shape: t6, dtype: o, values: e, usage: ir.UPLOAD, refCount: 1 }), n;
}
refCount(e) {
return this.texData.has(e) ? this.texData.get(e).refCount : 0;
}
incRef(e) {
- let t10 = this.texData.get(e);
- t10.refCount++;
+ let t6 = this.texData.get(e);
+ t6.refCount++;
}
decRef(e) {
if (this.texData.has(e)) {
- let t10 = this.texData.get(e);
- t10.refCount--;
+ let t6 = this.texData.get(e);
+ t6.refCount--;
}
}
- move(e, t10, o, n, s) {
- if (P().getBool("DEBUG") && this.checkNumericalProblems(t10), n === "complex64")
+ move(e, t6, o, n, s) {
+ if (O().getBool("DEBUG") && this.checkNumericalProblems(t6), n === "complex64")
throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");
- this.texData.set(e, { shape: o, dtype: n, values: t10, usage: ir.UPLOAD, refCount: s });
+ this.texData.set(e, { shape: o, dtype: n, values: t6, usage: ir.UPLOAD, refCount: s });
}
disposeIntermediateTensorInfo(e) {
this.disposeData(e.dataId);
}
readSync(e) {
- let t10 = this.texData.get(e), { values: o, dtype: n, complexTensorInfos: s, slice: a, shape: i, isPacked: p } = t10;
+ let t6 = this.texData.get(e), { values: o, dtype: n, complexTensorInfos: s, slice: a, shape: i, isPacked: p } = t6;
if (a != null) {
let m;
- p ? m = new No(i, Pu) : m = new fr(i, Pu);
- let f = this.runWebGLProgram(m, [{ dataId: e, shape: i, dtype: n }], n), d = this.readSync(f.dataId);
- return this.disposeIntermediateTensorInfo(f), d;
+ p ? m = new Ar(i, Qs) : m = new Jt(i, Qs);
+ let d = this.runWebGLProgram(m, [{ dataId: e, shape: i, dtype: n }], n), f = this.readSync(d.dataId);
+ return this.disposeIntermediateTensorInfo(d), f;
}
if (o != null)
return this.convertAndCacheOnCPU(e);
if (n === "string")
return o;
let u = this.activeTimers != null, c;
- u && (c = x.now());
+ u && (c = y.now());
let l;
if (n === "complex64") {
- let m = this.readSync(s.real.dataId), f = this.readSync(s.imag.dataId);
- l = I.mergeRealAndImagArrays(m, f);
+ let m = this.readSync(s.real.dataId), d = this.readSync(s.imag.dataId);
+ l = S.mergeRealAndImagArrays(m, d);
} else
l = this.getValuesFromTexture(e);
- return u && (this.downloadWaitMs += x.now() - c), this.convertAndCacheOnCPU(e, l);
+ return u && (this.downloadWaitMs += y.now() - c), this.convertAndCacheOnCPU(e, l);
}
async read(e) {
if (this.pendingRead.has(e)) {
- let d = this.pendingRead.get(e);
- return new Promise((h) => d.push(h));
+ let f = this.pendingRead.get(e);
+ return new Promise((h) => f.push(h));
}
- let t10 = this.texData.get(e), { values: o, shape: n, slice: s, dtype: a, complexTensorInfos: i, isPacked: p } = t10;
+ let t6 = this.texData.get(e), { values: o, shape: n, slice: s, dtype: a, complexTensorInfos: i, isPacked: p } = t6;
if (s != null) {
- let d;
- p ? d = new No(n, Pu) : d = new fr(n, Pu);
- let h = this.runWebGLProgram(d, [{ dataId: e, shape: n, dtype: a }], a), g = this.read(h.dataId);
+ let f;
+ p ? f = new Ar(n, Qs) : f = new Jt(n, Qs);
+ let h = this.runWebGLProgram(f, [{ dataId: e, shape: n, dtype: a }], a), g = this.read(h.dataId);
return this.disposeIntermediateTensorInfo(h), g;
}
if (o != null)
return this.convertAndCacheOnCPU(e);
- if (P().getBool("DEBUG") && !P().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED") && P().getNumber("WEBGL_VERSION") === 2)
+ if (O().getBool("DEBUG") && !O().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED") && O().getNumber("WEBGL_VERSION") === 2)
throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");
let u = null, c;
- if (a !== "complex64" && P().get("WEBGL_BUFFER_SUPPORTED")) {
+ if (a !== "complex64" && O().get("WEBGL_BUFFER_SUPPORTED")) {
c = this.decode(e);
- let d = this.texData.get(c.dataId);
- u = this.gpgpu.createBufferFromTexture(d.texture.texture, ..._l(n));
+ let f = this.texData.get(c.dataId);
+ u = this.gpgpu.createBufferFromTexture(f.texture.texture, ...Cl(n));
}
this.pendingRead.set(e, []), a !== "complex64" && await this.gpgpu.createAndWaitForFence();
let l;
if (a === "complex64") {
- let d = await Promise.all([this.read(i.real.dataId), this.read(i.imag.dataId)]), h = d[0], g = d[1];
- l = I.mergeRealAndImagArrays(h, g);
+ let f = await Promise.all([this.read(i.real.dataId), this.read(i.imag.dataId)]), h = f[0], g = f[1];
+ l = S.mergeRealAndImagArrays(h, g);
} else if (u == null)
l = this.getValuesFromTexture(e);
else {
- let d = x.sizeFromShape(n);
- l = this.gpgpu.downloadFloat32MatrixFromBuffer(u, d);
+ let f = y.sizeFromShape(n);
+ l = this.gpgpu.downloadFloat32MatrixFromBuffer(u, f);
}
if (c != null && this.disposeIntermediateTensorInfo(c), u != null) {
- let d = this.gpgpu.gl;
- me(d, () => d.deleteBuffer(u));
+ let f = this.gpgpu.gl;
+ ce(f, () => f.deleteBuffer(u));
}
- let m = this.convertAndCacheOnCPU(e, l), f = this.pendingRead.get(e);
- return this.pendingRead.delete(e), f.forEach((d) => d(m)), this.pendingDisposal.has(e) && (this.pendingDisposal.delete(e), this.disposeData(e) && cr().removeDataId(e, this), this.pendingDeletes--), m;
+ let m = this.convertAndCacheOnCPU(e, l), d = this.pendingRead.get(e);
+ return this.pendingRead.delete(e), d.forEach((f) => f(m)), this.pendingDisposal.has(e) && (this.pendingDisposal.delete(e), this.disposeData(e) && cr().removeDataId(e, this), this.pendingDeletes--), m;
}
- readToGPU(e, t10 = {}) {
+ readToGPU(e, t6 = {}) {
let o = this.texData.get(e), { values: n, shape: s, slice: a, dtype: i, isPacked: p, texture: u } = o;
if (i === "complex64")
throw new Error("Does not support reading texture for complex64 dtype.");
if (a != null) {
- let f;
- p ? f = new No(s, Pu) : f = new fr(s, Pu);
- let d = this.runWebGLProgram(f, [{ dataId: e, shape: s, dtype: i }], i), h = this.readToGPU(d, t10);
- return this.disposeIntermediateTensorInfo(d), h;
+ let d;
+ p ? d = new Ar(s, Qs) : d = new Jt(s, Qs);
+ let f = this.runWebGLProgram(d, [{ dataId: e, shape: s, dtype: i }], i), h = this.readToGPU(f, t6);
+ return this.disposeIntermediateTensorInfo(f), h;
}
if (u == null)
throw n != null ? new Error("Data is not on GPU but on CPU.") : new Error("There is no data on GPU or CPU.");
- let c = this.decode(e, t10.customTexShape), l = cr().makeTensorFromTensorInfo(c), m = this.texData.get(c.dataId);
+ let c = this.decode(e, t6.customTexShape), l = cr().makeTensorFromTensorInfo(c), m = this.texData.get(c.dataId);
return Object.assign({ tensorRef: l }, m.texture);
}
bufferSync(e) {
- let t10 = this.readSync(e.dataId);
+ let t6 = this.readSync(e.dataId);
if (e.dtype === "string")
try {
- let o = t10.map((n) => x.decodeString(n));
- return ne(e.shape, e.dtype, o);
+ let o = t6.map((n) => y.decodeString(n));
+ return le(e.shape, e.dtype, o);
} catch (o) {
throw new Error("Failed to decode encoded string bytes into utf-8");
}
- return ne(e.shape, e.dtype, t10);
+ return le(e.shape, e.dtype, t6);
}
checkNumericalProblems(e) {
if (e != null)
- for (let t10 = 0; t10 < e.length; t10++) {
- let o = e[t10];
- if (!VI(o))
- throw P().getBool("WEBGL_RENDER_FLOAT32_CAPABLE") ? Error(`The value ${o} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`) : Error(`The value ${o} cannot be represented on this device.`);
+ for (let t6 = 0; t6 < e.length; t6++) {
+ let o = e[t6];
+ if (!OS(o))
+ throw O().getBool("WEBGL_RENDER_FLOAT32_CAPABLE") ? Error(`The value ${o} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`) : Error(`The value ${o} cannot be represented on this device.`);
}
}
getValuesFromTexture(e) {
- let { shape: t10, dtype: o, isPacked: n } = this.texData.get(e), s = x.sizeFromShape(t10);
- if (P().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")) {
- let m = this.decode(e), f = this.texData.get(m.dataId), d = this.gpgpu.downloadMatrixFromPackedTexture(f.texture.texture, ..._l(t10)).subarray(0, s);
- return this.disposeIntermediateTensorInfo(m), d;
+ let { shape: t6, dtype: o, isPacked: n } = this.texData.get(e), s = y.sizeFromShape(t6);
+ if (O().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")) {
+ let m = this.decode(e), d = this.texData.get(m.dataId), f = this.gpgpu.downloadMatrixFromPackedTexture(d.texture.texture, ...Cl(t6)).subarray(0, s);
+ return this.disposeIntermediateTensorInfo(m), f;
}
- let a = P().getBool("WEBGL_PACK") && n === true, i = a ? ac(t10) : t10, p = a ? new Yd(i) : new Xd(i), u = this.runWebGLProgram(p, [{ shape: i, dtype: o, dataId: e }], "float32"), c = this.texData.get(u.dataId), l = this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(c.texture.texture, c.texShape[0], c.texShape[1]).subarray(0, s);
+ let a = O().getBool("WEBGL_PACK") && n === true, i = a ? rc(t6) : t6, p = a ? new Bf(i) : new Lf(i), u = this.runWebGLProgram(p, [{ shape: i, dtype: o, dataId: e }], "float32"), c = this.texData.get(u.dataId), l = this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(c.texture.texture, c.texShape[0], c.texShape[1]).subarray(0, s);
return this.disposeIntermediateTensorInfo(u), l;
}
timerAvailable() {
- return P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0;
+ return O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0;
}
time(e) {
- let t10 = this.activeTimers, o = [], n = false;
+ let t6 = this.activeTimers, o = [], n = false;
this.programTimersStack == null ? (this.programTimersStack = o, n = true) : this.activeTimers.push(o), this.activeTimers = o, e();
- let s = x.flatten(this.activeTimers.map((p) => p.query)).filter((p) => p != null), a = x.flatten(this.activeTimers.map((p) => p.name)).filter((p) => p != null);
- this.activeTimers = t10, n && (this.programTimersStack = null);
+ let s = y.flatten(this.activeTimers.map((p) => p.query)).filter((p) => p != null), a = y.flatten(this.activeTimers.map((p) => p.name)).filter((p) => p != null);
+ this.activeTimers = t6, n && (this.programTimersStack = null);
let i = { uploadWaitMs: this.uploadWaitMs, downloadWaitMs: this.downloadWaitMs, kernelMs: null, wallMs: null };
return (async () => {
- if (P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0) {
+ if (O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0) {
let p = await Promise.all(s);
- i.kernelMs = x.sum(p), i.getExtraProfileInfo = () => p.map((u, c) => ({ name: a[c], ms: u })).map((u) => `${u.name}: ${u.ms}`).join(", ");
+ i.kernelMs = y.sum(p), i.getExtraProfileInfo = () => p.map((u, c) => ({ name: a[c], ms: u })).map((u) => `${u.name}: ${u.ms}`).join(", ");
} else
i.kernelMs = { error: "WebGL query timers are not supported in this environment." };
return this.uploadWaitMs = 0, this.downloadWaitMs = 0, i;
@@ -17805,33 +17866,33 @@ var Ni = class extends Jr {
return { unreliable: false, numBytesInGPU: this.numBytesInGPU, numBytesInGPUAllocated: this.textureManager.numBytesAllocated, numBytesInGPUFree: this.textureManager.numBytesFree };
}
startTimer() {
- return P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? this.gpgpu.beginQuery() : { startMs: x.now(), endMs: null };
+ return O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? this.gpgpu.beginQuery() : { startMs: y.now(), endMs: null };
}
endTimer(e) {
- return P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? (this.gpgpu.endQuery(), e) : (e.endMs = x.now(), e);
+ return O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? (this.gpgpu.endQuery(), e) : (e.endMs = y.now(), e);
}
async getQueryTime(e) {
- if (P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0)
+ if (O().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0)
return this.gpgpu.waitForQueryAndGetTime(e);
- let t10 = e;
- return t10.endMs - t10.startMs;
+ let t6 = e;
+ return t6.endMs - t6.startMs;
}
- disposeData(e, t10 = false) {
+ disposeData(e, t6 = false) {
if (this.pendingDisposal.has(e))
return false;
if (!this.texData.has(e))
return true;
- if (t10 ? this.texData.get(e).refCount = 0 : this.texData.get(e).refCount--, !t10 && this.texData.get(e).refCount > 0)
+ if (t6 ? this.texData.get(e).refCount = 0 : this.texData.get(e).refCount--, !t6 && this.texData.get(e).refCount > 0)
return false;
if (this.pendingRead.has(e))
return this.pendingDisposal.add(e), this.pendingDeletes++, false;
this.releaseGPUData(e);
let { complexTensorInfos: o } = this.texData.get(e);
- return o != null && (this.disposeData(o.real.dataId, t10), this.disposeData(o.imag.dataId, t10)), this.texData.delete(e), true;
+ return o != null && (this.disposeData(o.real.dataId, t6), this.disposeData(o.imag.dataId, t6)), this.texData.delete(e), true;
}
releaseGPUData(e) {
- let { texture: t10, dtype: o, texShape: n, usage: s, isPacked: a, slice: i } = this.texData.get(e), p = i && i.origDataId || e, u = this.dataRefCount.get(p);
- u > 1 ? this.dataRefCount.set(p, u - 1) : (this.dataRefCount.delete(p), t10 != null && (this.numBytesInGPU -= this.computeBytes(n, o), this.textureManager.releaseTexture(t10, n, s, a)));
+ let { texture: t6, dtype: o, texShape: n, usage: s, isPacked: a, slice: i } = this.texData.get(e), p = i && i.origDataId || e, u = this.dataRefCount.get(p);
+ u > 1 ? this.dataRefCount.set(p, u - 1) : (this.dataRefCount.delete(p), t6 != null && (this.numBytesInGPU -= this.computeBytes(n, o), this.textureManager.releaseTexture(t6, n, s, a)));
let c = this.texData.get(e);
c.texture = null, c.texShape = null, c.isPacked = false, c.slice = null;
}
@@ -17841,166 +17902,166 @@ var Ni = class extends Jr {
getDataInfo(e) {
return this.texData.get(e);
}
- shouldExecuteOnCPU(e, t10 = mY) {
- return P().getBool("WEBGL_CPU_FORWARD") && e.every((o) => this.texData.get(o.dataId).texture == null && x.sizeFromShape(o.shape) < t10);
+ shouldExecuteOnCPU(e, t6 = D8) {
+ return O().getBool("WEBGL_CPU_FORWARD") && e.every((o) => this.texData.get(o.dataId).texture == null && y.sizeFromShape(o.shape) < t6);
}
getGPGPUContext() {
return this.gpgpu;
}
where(e) {
- I.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");
- let t10 = e.dataSync();
- return uY(e.shape, t10);
+ S.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");
+ let t6 = e.dataSync();
+ return $8(e.shape, t6);
}
- packedUnaryOp(e, t10, o) {
- let n = new No(e.shape, t10), s = this.compileAndRun(n, [e], o);
+ packedUnaryOp(e, t6, o) {
+ let n = new Ar(e.shape, t6), s = this.compileAndRun(n, [e], o);
return cr().makeTensorFromTensorInfo(s);
}
abs(e) {
if (this.shouldExecuteOnCPU([e]) && e.dtype !== "complex64") {
- let n = nh(this.texData.get(e.dataId).values);
+ let n = Kf(this.texData.get(e.dataId).values);
return this.makeOutput(e.shape, e.dtype, n);
}
- if (P().getBool("WEBGL_PACK_UNARY_OPERATIONS"))
- return this.packedUnaryOp(e, kw, e.dtype);
- let t10 = new fr(e.shape, kw), o = this.compileAndRun(t10, [e]);
+ if (O().getBool("WEBGL_PACK_UNARY_OPERATIONS"))
+ return this.packedUnaryOp(e, Cw, e.dtype);
+ let t6 = new Jt(e.shape, Cw), o = this.compileAndRun(t6, [e]);
return cr().makeTensorFromTensorInfo(o);
}
- makeTensorInfo(e, t10, o) {
+ makeTensorInfo(e, t6, o) {
let n;
- if (t10 === "string" && o != null && o.length > 0 && x.isString(o[0])) {
- let s = o.map((a) => x.encodeString(a));
- n = this.write(s, e, t10);
+ if (t6 === "string" && o != null && o.length > 0 && y.isString(o[0])) {
+ let s = o.map((a) => y.encodeString(a));
+ n = this.write(s, e, t6);
} else
- n = this.write(o, e, t10);
- return this.texData.get(n).usage = null, { dataId: n, shape: e, dtype: t10 };
+ n = this.write(o, e, t6);
+ return this.texData.get(n).usage = null, { dataId: n, shape: e, dtype: t6 };
}
- makeOutput(e, t10, o) {
- return cr().makeTensorFromTensorInfo(this.makeTensorInfo(e, t10, o), this);
+ makeOutput(e, t6, o) {
+ return cr().makeTensorFromTensorInfo(this.makeTensorInfo(e, t6, o), this);
}
unpackTensor(e) {
- let t10 = new uh(e.shape);
- return this.runWebGLProgram(t10, [e], e.dtype);
+ let t6 = new Qf(e.shape);
+ return this.runWebGLProgram(t6, [e], e.dtype);
}
packTensor(e) {
- let t10 = new ah(e.shape), o = true;
- return this.runWebGLProgram(t10, [e], e.dtype, null, o);
+ let t6 = new Xf(e.shape), o = true;
+ return this.runWebGLProgram(t6, [e], e.dtype, null, o);
}
- packedReshape(e, t10) {
- let o = [Pa(e.shape), ...Oa(e.shape)], n = { dtype: e.dtype, shape: o, dataId: e.dataId }, s = [Pa(t10), ...Oa(t10)], a = new hc(s, o), i = true, p = [o], u = this.runWebGLProgram(a, [n], e.dtype, p, i);
- return { dataId: u.dataId, shape: t10, dtype: u.dtype };
+ packedReshape(e, t6) {
+ let o = [Va(e.shape), ...za(e.shape)], n = { dtype: e.dtype, shape: o, dataId: e.dataId }, s = [Va(t6), ...za(t6)], a = new lc(s, o), i = true, p = [o], u = this.runWebGLProgram(a, [n], e.dtype, p, i);
+ return { dataId: u.dataId, shape: t6, dtype: u.dtype };
}
- decode(e, t10) {
+ decode(e, t6) {
let o = this.texData.get(e), { isPacked: n, shape: s, dtype: a } = o;
- if (t10 != null) {
- let m = x.sizeFromShape(s), f = t10[0] * t10[1] * 4;
- x.assert(m <= f, () => "customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.");
+ if (t6 != null) {
+ let m = y.sizeFromShape(s), d = t6[0] * t6[1] * 4;
+ y.assert(m <= d, () => "customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.");
}
- let i = ac(s), p;
- n ? p = new jd(i) : p = new Kd(i);
- let u = true, c = [t10 != null ? t10 : _l(i)], l = this.runWebGLProgram(p, [{ shape: i, dtype: a, dataId: e }], a, c, u, t10);
+ let i = rc(s), p;
+ n ? p = new Mf(i) : p = new Pf(i);
+ let u = true, c = [t6 != null ? t6 : Cl(i)], l = this.runWebGLProgram(p, [{ shape: i, dtype: a, dataId: e }], a, c, u, t6);
return { dtype: a, shape: s, dataId: l.dataId };
}
- runWebGLProgram(e, t10, o, n, s = false, a) {
+ runWebGLProgram(e, t6, o, n, s = false, a) {
let i = this.makeTensorInfo(e.outputShape, o), p = this.texData.get(i.dataId);
- if (e.packedOutput && (p.isPacked = true), e.outPackingScheme === ki.DENSE) {
- let y = a != null ? a : _l(e.outputShape);
- p.texShape = y.map((b) => b * 2);
+ if (e.packedOutput && (p.isPacked = true), e.outPackingScheme === Mi.DENSE) {
+ let x = a != null ? a : Cl(e.outputShape);
+ p.texShape = x.map((b) => b * 2);
}
- if (e.outTexUsage != null && (p.usage = e.outTexUsage), x.sizeFromShape(i.shape) === 0)
- return p.values = x.getTypedArrayFromDType(i.dtype, 0), i;
- let u = [], c = t10.map((y) => {
- if (y.dtype === "complex64")
+ if (e.outTexUsage != null && (p.usage = e.outTexUsage), y.sizeFromShape(i.shape) === 0)
+ return p.values = y.getTypedArrayFromDType(i.dtype, 0), i;
+ let u = [], c = t6.map((x) => {
+ if (x.dtype === "complex64")
throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");
- let b = this.texData.get(y.dataId);
+ let b = this.texData.get(x.dataId);
if (b.texture == null) {
- if (!e.packedInputs && x.sizeFromShape(y.shape) <= P().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))
- return { shape: y.shape, texData: null, isUniform: true, uniformValues: b.values };
- e.packedInputs && (b.isPacked = true, b.shape = y.shape);
+ if (!e.packedInputs && y.sizeFromShape(x.shape) <= O().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))
+ return { shape: x.shape, texData: null, isUniform: true, uniformValues: b.values };
+ e.packedInputs && (b.isPacked = true, b.shape = x.shape);
}
- if (this.uploadToGPU(y.dataId), !!b.isPacked != !!e.packedInputs)
- y = b.isPacked ? this.unpackTensor(y) : this.packTensor(y), u.push(y), b = this.texData.get(y.dataId);
- else if (b.isPacked && !Ti(b.shape, y.shape)) {
- let C = y, w = y.shape;
- y.shape = b.shape, y = this.packedReshape(y, w), u.push(y), b = this.texData.get(y.dataId), C.shape = w;
+ if (this.uploadToGPU(x.dataId), !!b.isPacked != !!e.packedInputs)
+ x = b.isPacked ? this.unpackTensor(x) : this.packTensor(x), u.push(x), b = this.texData.get(x.dataId);
+ else if (b.isPacked && !Li(b.shape, x.shape)) {
+ let C = x, w = x.shape;
+ x.shape = b.shape, x = this.packedReshape(x, w), u.push(x), b = this.texData.get(x.dataId), C.shape = w;
}
- return { shape: y.shape, texData: b, isUniform: false };
+ return { shape: x.shape, texData: b, isUniform: false };
});
this.uploadToGPU(i.dataId);
- let l = { shape: i.shape, texData: p, isUniform: false }, m = n$(e, c, l), f = this.getAndSaveBinary(m, () => r$(this.gpgpu, e, c, l)), d = this.activeTimers != null, h;
- d && (h = this.startTimer()), P().get("ENGINE_COMPILE_ONLY") || o$(this.gpgpu, f, c, l, n), u.forEach((y) => this.disposeIntermediateTensorInfo(y)), d && (h = this.endTimer(h), this.activeTimers.push({ name: e.constructor.name, query: this.getQueryTime(h) }));
- let g = P().get("WEBGL_FLUSH_THRESHOLD");
+ let l = { shape: i.shape, texData: p, isUniform: false }, m = FE(e, c, l), d = this.getAndSaveBinary(m, () => AE(this.gpgpu, e, c, l)), f = this.activeTimers != null, h;
+ f && (h = this.startTimer()), O().get("ENGINE_COMPILE_ONLY") || RE(this.gpgpu, d, c, l, n), u.forEach((x) => this.disposeIntermediateTensorInfo(x)), f && (h = this.endTimer(h), this.activeTimers.push({ name: e.constructor.name, query: this.getQueryTime(h) }));
+ let g = O().get("WEBGL_FLUSH_THRESHOLD");
if (g > 0) {
- let y = x.now();
- y - this.lastGlFlushTime > g && (this.gpgpu.gl.flush(), this.lastGlFlushTime = y);
+ let x = y.now();
+ x - this.lastGlFlushTime > g && (this.gpgpu.gl.flush(), this.lastGlFlushTime = x);
}
- if (!P().getBool("WEBGL_LAZILY_UNPACK") && p.isPacked && s === false) {
- let y = this.unpackTensor(i);
- return this.disposeIntermediateTensorInfo(i), y;
+ if (!O().getBool("WEBGL_LAZILY_UNPACK") && p.isPacked && s === false) {
+ let x = this.unpackTensor(i);
+ return this.disposeIntermediateTensorInfo(i), x;
}
return i;
}
- compileAndRun(e, t10, o, n, s = false) {
- return o = o || t10[0].dtype, this.runWebGLProgram(e, t10, o, n, s);
+ compileAndRun(e, t6, o, n, s = false) {
+ return o = o || t6[0].dtype, this.runWebGLProgram(e, t6, o, n, s);
}
- getAndSaveBinary(e, t10) {
- return e in this.binaryCache || (this.binaryCache[e] = t10()), this.binaryCache[e];
+ getAndSaveBinary(e, t6) {
+ return e in this.binaryCache || (this.binaryCache[e] = t6()), this.binaryCache[e];
}
getTextureManager() {
return this.textureManager;
}
dispose() {
- this.disposed || (P().getBool("IS_TEST") || Object.keys(this.binaryCache).forEach((t10) => {
- this.gpgpu.deleteProgram(this.binaryCache[t10].webGLProgram), delete this.binaryCache[t10];
+ this.disposed || (O().getBool("IS_TEST") || Object.keys(this.binaryCache).forEach((t6) => {
+ this.gpgpu.deleteProgram(this.binaryCache[t6].webGLProgram), delete this.binaryCache[t6];
}), this.textureManager.dispose(), this.canvas != null && typeof HTMLCanvasElement != "undefined" && this.canvas instanceof HTMLCanvasElement ? this.canvas.remove() : this.canvas = null, this.gpgpuCreatedLocally && (this.gpgpu.program = null, this.gpgpu.dispose()), this.disposed = true);
}
floatPrecision() {
- return this.floatPrecisionValue == null && (this.floatPrecisionValue = Ne(() => {
- if (!P().get("WEBGL_RENDER_FLOAT32_ENABLED")) {
- let e = P().getBool("DEBUG");
- P().set("DEBUG", false);
- let t10 = this.abs(be(1e-8)).dataSync()[0];
- if (P().set("DEBUG", e), t10 > 0)
+ return this.floatPrecisionValue == null && (this.floatPrecisionValue = Ee(() => {
+ if (!O().get("WEBGL_RENDER_FLOAT32_ENABLED")) {
+ let e = O().getBool("DEBUG");
+ O().set("DEBUG", false);
+ let t6 = this.abs(be(1e-8)).dataSync()[0];
+ if (O().set("DEBUG", e), t6 > 0)
return 32;
}
return 16;
})), this.floatPrecisionValue;
}
epsilon() {
- return this.floatPrecision() === 32 ? pY : cY;
+ return this.floatPrecision() === 32 ? A8 : R8;
}
uploadToGPU(e) {
- let t10 = this.texData.get(e), { shape: o, dtype: n, values: s, texture: a, usage: i, isPacked: p } = t10;
+ let t6 = this.texData.get(e), { shape: o, dtype: n, values: s, texture: a, usage: i, isPacked: p } = t6;
if (a != null)
return;
let u = this.activeTimers != null, c;
- u && (c = x.now());
- let l = t10.texShape;
- if (l == null && (l = JI(o, p), t10.texShape = l), s != null) {
- let m = ac(o), f, d = l[1], h = l[0], g = s instanceof Uint8Array || s instanceof Uint8ClampedArray;
- (p || !g) && ([d, h] = Ks(l[0], l[1])), p ? f = new Qd(m, g) : f = new Al(m, g);
- let y = g ? [h, d] : l, b = this.makeTensorInfo(y, n), C = this.texData.get(b.dataId);
- g ? C.usage = ir.PIXELS : C.usage = ir.UPLOAD, C.texShape = y, this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(b.dataId), d, h, s);
- let w = [[h, d]], k = true, _ = this.runWebGLProgram(f, [b], n, w, k), E = this.texData.get(_.dataId);
- t10.texShape = E.texShape, t10.isPacked = E.isPacked, t10.usage = E.usage, P().get("ENGINE_COMPILE_ONLY") ? this.disposeData(_.dataId) : (t10.texture = E.texture, t10.values = null, this.texData.delete(_.dataId)), this.disposeIntermediateTensorInfo(b), u && (this.uploadWaitMs += x.now() - c);
+ u && (c = y.now());
+ let l = t6.texShape;
+ if (l == null && (l = jS(o, p), t6.texShape = l), s != null) {
+ let m = rc(o), d, f = l[1], h = l[0], g = s instanceof Uint8Array || s instanceof Uint8ClampedArray;
+ (p || !g) && ([f, h] = Ys(l[0], l[1])), p ? d = new Vf(m, g) : d = new vl(m, g);
+ let x = g ? [h, f] : l, b = this.makeTensorInfo(x, n), C = this.texData.get(b.dataId);
+ g ? C.usage = ir.PIXELS : C.usage = ir.UPLOAD, C.texShape = x, this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(b.dataId), f, h, s);
+ let w = [[h, f]], k = true, _ = this.runWebGLProgram(d, [b], n, w, k), $ = this.texData.get(_.dataId);
+ t6.texShape = $.texShape, t6.isPacked = $.isPacked, t6.usage = $.usage, O().get("ENGINE_COMPILE_ONLY") ? this.disposeData(_.dataId) : (t6.texture = $.texture, t6.values = null, this.texData.delete(_.dataId)), this.disposeIntermediateTensorInfo(b), u && (this.uploadWaitMs += y.now() - c);
} else {
let m = this.acquireTexture(l, i, n, p);
- t10.texture = m;
+ t6.texture = m;
}
}
- convertAndCacheOnCPU(e, t10) {
+ convertAndCacheOnCPU(e, t6) {
let o = this.texData.get(e), { dtype: n } = o;
- return this.releaseGPUData(e), t10 != null && (o.values = hY(t10, n)), o.values;
+ return t6 != null && (o.values = M8(t6, n)), o.values;
}
- acquireTexture(e, t10, o, n) {
+ acquireTexture(e, t6, o, n) {
if (this.numBytesInGPU += this.computeBytes(e, o), !this.warnedAboutMemory && this.numBytesInGPU > this.numMBBeforeWarning * 1024 * 1024) {
let s = (this.numBytesInGPU / 1024 / 1024).toFixed(2);
this.warnedAboutMemory = true, console.warn(`High memory usage in GPU: ${s} MB, most likely due to a memory leak`);
}
- return this.textureManager.acquireTexture(e, t10, n);
+ return this.textureManager.acquireTexture(e, t6, n);
}
- computeBytes(e, t10) {
- return e[0] * e[1] * x.bytesPerElement(t10);
+ computeBytes(e, t6) {
+ return e[0] * e[1] * y.bytesPerElement(t6);
}
checkCompileCompletion() {
for (let [, e] of Object.entries(this.binaryCache))
@@ -18009,14 +18070,14 @@ var Ni = class extends Jr {
async checkCompileCompletionAsync() {
let e = [];
if (this.gpgpu.parallelCompilationExtension) {
- for (let [, t10] of Object.entries(this.binaryCache))
- e.push(this.checkCompletionAsync_(t10));
+ for (let [, t6] of Object.entries(this.binaryCache))
+ e.push(this.checkCompletionAsync_(t6));
return Promise.all(e);
} else {
- for (let [, t10] of Object.entries(this.binaryCache)) {
+ for (let [, t6] of Object.entries(this.binaryCache)) {
let o = new Promise((n) => {
try {
- this.checkCompletion_(t10), n(true);
+ this.checkCompletion_(t6), n(true);
} catch (s) {
throw s;
}
@@ -18027,52 +18088,52 @@ var Ni = class extends Jr {
}
}
async checkCompletionAsync_(e) {
- return this.gpgpu.gl.getProgramParameter(e.webGLProgram, this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR) ? this.checkCompletion_(e) : (await kC(), this.checkCompletionAsync_(e));
+ return this.gpgpu.gl.getProgramParameter(e.webGLProgram, this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR) ? this.checkCompletion_(e) : (await CC(), this.checkCompletionAsync_(e));
}
checkCompletion_(e) {
if (this.gpgpu.gl.getProgramParameter(e.webGLProgram, this.gpgpu.gl.LINK_STATUS) === false)
- throw console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)), this.gpgpu.gl.getShaderParameter(e.fragmentShader, this.gpgpu.gl.COMPILE_STATUS) === false ? (zd(e.source, this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)), new Error("Failed to compile fragment shader.")) : new Error("Failed to link vertex and fragment shaders.");
+ throw console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)), this.gpgpu.gl.getShaderParameter(e.fragmentShader, this.gpgpu.gl.COMPILE_STATUS) === false ? ($f(e.source, this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)), new Error("Failed to compile fragment shader.")) : new Error("Failed to link vertex and fragment shaders.");
return true;
}
getUniformLocations() {
for (let [, e] of Object.entries(this.binaryCache)) {
- let { uniformLocations: t10, customUniformLocations: o, infLoc: n, nanLoc: s, inShapesLocations: a, inTexShapesLocations: i, outShapeLocation: p, outShapeStridesLocation: u, outTexShapeLocation: c } = aw(this.gpgpu, e.program, e.webGLProgram);
- e.uniformLocations = t10, e.customUniformLocations = o, e.infLoc = n, e.nanLoc = s, e.inShapesLocations = a, e.inTexShapesLocations = i, e.outShapeLocation = p, e.outShapeStridesLocation = u, e.outTexShapeLocation = c;
+ let { uniformLocations: t6, customUniformLocations: o, infLoc: n, nanLoc: s, inShapesLocations: a, inTexShapesLocations: i, outShapeLocation: p, outShapeStridesLocation: u, outTexShapeLocation: c } = tw(this.gpgpu, e.program, e.webGLProgram);
+ e.uniformLocations = t6, e.customUniformLocations = o, e.infLoc = n, e.nanLoc = s, e.inShapesLocations = a, e.inTexShapesLocations = i, e.outShapeLocation = p, e.outShapeStridesLocation = u, e.outTexShapeLocation = c;
}
}
- createTensorFromTexture(e, t10, o) {
+ createTensorFromTexture(e, t6, o) {
let { texture: n, height: s, width: a, channels: i } = e, p = cr().backend;
if (!p.gpgpu.gl.isTexture(n))
throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");
- let u = p.writeTexture(n, t10, o, s, a, i);
- return cr().makeTensorFromDataId(u, t10, o, p);
+ let u = p.writeTexture(n, t6, o, s, a, i);
+ return cr().makeTensorFromDataId(u, t6, o, p);
}
};
-Ni.nextDataId = 0;
-function hY(r, e) {
+Bi.nextDataId = 0;
+function M8(r, e) {
if (e === "float32" || e === "complex64")
return r;
if (e === "int32" || e === "bool") {
- let t10 = e === "int32" ? new Int32Array(r.length) : new Uint8Array(r.length);
- for (let o = 0; o < t10.length; ++o)
- t10[o] = Math.round(r[o]);
- return t10;
+ let t6 = e === "int32" ? new Int32Array(r.length) : new Uint8Array(r.length);
+ for (let o = 0; o < t6.length; ++o)
+ t6[o] = Math.round(r[o]);
+ return t6;
} else
throw new Error(`Unknown dtype ${e}`);
}
-var gY = "4.0.0";
-function pR() {
- P().set("WEBGL_FORCE_F16_TEXTURES", true);
+var L8 = "4.1.0";
+function L$() {
+ O().set("WEBGL_FORCE_F16_TEXTURES", true);
}
-ii.isBrowser() && pi("webgl", () => new Ni(), 2);
-var R9e = { forceHalfFloat: pR };
-var gc = `
+yi.isBrowser() && Ci("webgl", () => new Bi(), 2);
+var L9e = { forceHalfFloat: L$ };
+var mc = `
if (isnan(a)) return a;
if (isnan(b)) return b;
`;
-var _o = class {
- constructor(e, t10, o) {
- this.variableNames = ["A", "B"], this.outputShape = I.assertAndGetBroadcastShape(t10, o), this.enableShapeUniforms = lt(this.outputShape.length), this.userCode = `
+var io = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["A", "B"], this.outputShape = S.assertAndGetBroadcastShape(t6, o), this.enableShapeUniforms = ct(this.outputShape.length), this.userCode = `
float binaryOperation(float a, float b) {
${e}
}
@@ -18085,20 +18146,20 @@ var _o = class {
`;
}
};
-var js = `
+var Zs = `
result.r = isNaN.r ? NAN : result.r;
result.g = isNaN.g ? NAN : result.g;
result.b = isNaN.b ? NAN : result.b;
result.a = isNaN.a ? NAN : result.a;
`;
-var Ko = class {
- constructor(e, t10, o, n = false) {
- this.variableNames = ["A", "B"], this.supportsBroadcasting = true, this.packedInputs = true, this.packedOutput = true, this.outputShape = I.assertAndGetBroadcastShape(t10, o);
+var To = class {
+ constructor(e, t6, o, n = false) {
+ this.variableNames = ["A", "B"], this.supportsBroadcasting = true, this.packedInputs = true, this.packedOutput = true, this.outputShape = S.assertAndGetBroadcastShape(t6, o);
let s = this.outputShape.length;
- this.enableShapeUniforms = lt(s);
+ this.enableShapeUniforms = ct(s);
let a = "";
if (n)
- if (s === 0 || x.sizeFromShape(this.outputShape) === 1)
+ if (s === 0 || y.sizeFromShape(this.outputShape) === 1)
a = `
result.y = 0.;
result.z = 0.;
@@ -18153,88 +18214,88 @@ var Ko = class {
`;
}
};
-function Rt(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
- return t10.incRef(o.dataId), { dataId: o.dataId, shape: o.shape, dtype: o.dtype };
+function At(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e;
+ return t6.incRef(o.dataId), { dataId: o.dataId, shape: o.shape, dtype: o.dtype };
}
-var cR = { kernelName: uo, backendName: "webgl", kernelFunc: Rt };
-function Ar(r) {
- let { inputs: e, backend: t10 } = r, { real: o, imag: n } = e, s = t10.makeTensorInfo(o.shape, "complex64"), a = t10.texData.get(s.dataId), i = Rt({ inputs: { x: o }, backend: t10 }), p = Rt({ inputs: { x: n }, backend: t10 });
+var B$ = { kernelName: mo, backendName: "webgl", kernelFunc: At };
+function Rr(r) {
+ let { inputs: e, backend: t6 } = r, { real: o, imag: n } = e, s = t6.makeTensorInfo(o.shape, "complex64"), a = t6.texData.get(s.dataId), i = At({ inputs: { x: o }, backend: t6 }), p = At({ inputs: { x: n }, backend: t6 });
return a.complexTensorInfos = { real: i, imag: p }, s;
}
-var lR = { kernelName: aa, backendName: "webgl", kernelFunc: Ar };
-var Tw = "return (a < 0.) ? b * a : a;";
-var Nw = `
+var V$ = { kernelName: ei, backendName: "webgl", kernelFunc: Rr };
+var Sw = "return (a < 0.) ? b * a : a;";
+var ww = `
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
`;
-function xY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { alpha: s } = o, a = t10.makeTensorInfo([], "float32", x.createScalarValue(s, "float32")), i = P().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ko(Nw, n.shape, a.shape) : new _o(Tw, n.shape, a.shape), p = t10.runWebGLProgram(i, [n, a], "float32");
- return t10.disposeIntermediateTensorInfo(a), p;
+function B8(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { alpha: s } = o, a = t6.makeTensorInfo([], "float32", y.createScalarValue(s, "float32")), i = O().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new To(ww, n.shape, a.shape) : new io(Sw, n.shape, a.shape), p = t6.runWebGLProgram(i, [n, a], "float32");
+ return t6.disposeIntermediateTensorInfo(a), p;
}
-var mR = { kernelName: Nn, backendName: "webgl", kernelFunc: xY };
-var _w = "return (a < 0.) ? b * a : a;";
-var Ew = `
+var z$ = { kernelName: mn, backendName: "webgl", kernelFunc: B8 };
+var Iw = "return (a < 0.) ? b * a : a;";
+var vw = `
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
`;
-function yY(r) {
- let { inputs: e, backend: t10 } = r, { x: o, alpha: n } = e, s = P().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ko(Ew, o.shape, n.shape) : new _o(_w, o.shape, n.shape);
- return t10.runWebGLProgram(s, [o, n], "float32");
+function V8(r) {
+ let { inputs: e, backend: t6 } = r, { x: o, alpha: n } = e, s = O().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new To(vw, o.shape, n.shape) : new io(Iw, o.shape, n.shape);
+ return t6.runWebGLProgram(s, [o, n], "float32");
}
-var fR = { kernelName: Vn, backendName: "webgl", kernelFunc: yY };
-var jo = "if (isnan(x)) return x;";
-function he({ opSnippet: r, packedOpSnippet: e, cpuKernelImpl: t10, dtype: o }) {
+var W$ = { kernelName: Rn, backendName: "webgl", kernelFunc: V8 };
+var _o = "if (isnan(x)) return x;";
+function ge({ opSnippet: r, packedOpSnippet: e, cpuKernelImpl: t6, dtype: o }) {
return ({ inputs: n, backend: s }) => {
let { x: a } = n, i = s, p = o || a.dtype;
- if (i.shouldExecuteOnCPU([a]) && t10 != null) {
- let l = i.texData.get(a.dataId), m = t10(l.values, p);
+ if (i.shouldExecuteOnCPU([a]) && t6 != null) {
+ let l = i.texData.get(a.dataId), m = t6(l.values, p);
return i.makeTensorInfo(a.shape, p, m);
}
- let u = P().getBool("WEBGL_PACK_UNARY_OPERATIONS") && e != null, c;
- return u ? c = new No(a.shape, e) : c = new fr(a.shape, r), i.runWebGLProgram(c, [a], p);
+ let u = O().getBool("WEBGL_PACK_UNARY_OPERATIONS") && e != null, c;
+ return u ? c = new Ar(a.shape, e) : c = new Jt(a.shape, r), i.runWebGLProgram(c, [a], p);
};
}
-function ot({ opSnippet: r, packedOpSnippet: e, checkOutOfBounds: t10 = false, supportsComplex: o = false, cpuKernelImpl: n, dtype: s }) {
+function tt({ opSnippet: r, packedOpSnippet: e, checkOutOfBounds: t6 = false, supportsComplex: o = false, cpuKernelImpl: n, dtype: s }) {
return ({ inputs: a, backend: i }) => {
let { a: p, b: u } = a, c = i;
if (o && p.dtype === "complex64") {
- let d = c.texData.get(p.dataId), h = c.texData.get(u.dataId), [g, y] = [[d.complexTensorInfos.real, h.complexTensorInfos.real], [d.complexTensorInfos.imag, h.complexTensorInfos.imag]].map((C) => {
- let [w, k] = C, _ = { dataId: w.dataId, dtype: w.dtype, shape: p.shape }, E = { dataId: k.dataId, dtype: k.dtype, shape: u.shape }, R = new _o(r, p.shape, u.shape);
- return c.runWebGLProgram(R, [_, E], ct(w.dtype, k.dtype));
- }), b = Ar({ inputs: { real: g, imag: y }, backend: c });
- return c.disposeIntermediateTensorInfo(g), c.disposeIntermediateTensorInfo(y), b;
+ let f = c.texData.get(p.dataId), h = c.texData.get(u.dataId), [g, x] = [[f.complexTensorInfos.real, h.complexTensorInfos.real], [f.complexTensorInfos.imag, h.complexTensorInfos.imag]].map((C) => {
+ let [w, k] = C, _ = { dataId: w.dataId, dtype: w.dtype, shape: p.shape }, $ = { dataId: k.dataId, dtype: k.dtype, shape: u.shape }, A = new io(r, p.shape, u.shape);
+ return c.runWebGLProgram(A, [_, $], dt(w.dtype, k.dtype));
+ }), b = Rr({ inputs: { real: g, imag: x }, backend: c });
+ return c.disposeIntermediateTensorInfo(g), c.disposeIntermediateTensorInfo(x), b;
}
- let l = s || ct(p.dtype, u.dtype);
+ let l = s || dt(p.dtype, u.dtype);
if ((p.dtype === "string" || u.dtype === "string" || c.shouldExecuteOnCPU([p, u])) && n != null) {
- let d = c.texData.get(p.dataId).values, h = c.texData.get(u.dataId).values, g = p.dtype === "string" ? I.fromUint8ToStringArray(d) : d, y = p.dtype === "string" ? I.fromUint8ToStringArray(h) : h, [b, C] = n(p.shape, u.shape, g, y, l), w = c.makeTensorInfo(C, l), k = c.texData.get(w.dataId);
+ let f = c.texData.get(p.dataId).values, h = c.texData.get(u.dataId).values, g = p.dtype === "string" ? S.fromUint8ToStringArray(f) : f, x = p.dtype === "string" ? S.fromUint8ToStringArray(h) : h, [b, C] = n(p.shape, u.shape, g, x, l), w = c.makeTensorInfo(C, l), k = c.texData.get(w.dataId);
return k.values = b, w;
}
- let m = P().getBool("WEBGL_PACK_BINARY_OPERATIONS") && e != null, f;
- return m ? f = new Ko(e, p.shape, u.shape, t10) : f = new _o(r, p.shape, u.shape), c.runWebGLProgram(f, [p, u], l);
+ let m = O().getBool("WEBGL_PACK_BINARY_OPERATIONS") && e != null, d;
+ return m ? d = new To(e, p.shape, u.shape, t6) : d = new io(r, p.shape, u.shape), c.runWebGLProgram(d, [p, u], l);
};
}
-function Ma(r, e = false) {
+function Wa(r, e = false) {
if (r === "linear")
- return e ? nR : Z$;
+ return e ? F$ : T$;
if (r === "relu")
- return e ? aR : eR;
+ return e ? O$ : E$;
if (r === "elu")
- return e ? sR : J$;
+ return e ? D$ : _$;
if (r === "relu6")
- return e ? iR : tR;
+ return e ? P$ : $$;
if (r === "prelu")
- return e ? Ew : _w;
+ return e ? vw : Iw;
if (r === "leakyrelu")
- return e ? Nw : Tw;
+ return e ? ww : Sw;
if (r === "sigmoid")
- return e ? uR : rR;
+ return e ? M$ : A$;
throw new Error(`Activation ${r} has not been implemented for the WebGL backend.`);
}
-var xc = class {
- constructor(e, t10, o, n = false, s = false, a = false, i = null, p = false, u = false) {
- this.variableNames = ["matrixA", "matrixB"], this.packedInputs = true, this.packedOutput = true, this.outputShape = o, this.enableShapeUniforms = lt(this.outputShape.length);
- let c = n ? e[1] : e[2], l = Math.ceil(c / 2), m = n ? "i * 2, rc.y" : "rc.y, i * 2", f = s ? "rc.z, i * 2" : "i * 2, rc.z", d = n ? ["a.xxyy", "a.zzww"] : ["a.xxzz", "a.yyww"], h = s ? ["b.xzxz", "b.ywyw"] : ["b.xyxy", "b.zwzw"], g = "", y = "";
+var dc = class {
+ constructor(e, t6, o, n = false, s = false, a = false, i = null, p = false, u = false) {
+ this.variableNames = ["matrixA", "matrixB"], this.packedInputs = true, this.packedOutput = true, this.outputShape = o, this.enableShapeUniforms = ct(this.outputShape.length);
+ let c = n ? e[1] : e[2], l = Math.ceil(c / 2), m = n ? "i * 2, rc.y" : "rc.y, i * 2", d = s ? "rc.z, i * 2" : "i * 2, rc.z", f = n ? ["a.xxyy", "a.zzww"] : ["a.xxzz", "a.yyww"], h = s ? ["b.xzxz", "b.ywyw"] : ["b.xyxy", "b.zwzw"], g = "", x = "";
i && (p ? g = `vec4 activation(vec4 a) {
vec4 b = getPreluActivationWeightsAtOutCoords();
${i}
@@ -18243,11 +18304,11 @@ var xc = class {
${i}
}` : g = `vec4 activation(vec4 x) {
${i}
- }`, y = "result = activation(result);");
+ }`, x = "result = activation(result);");
let b = a ? "result += getBiasAtOutCoords();" : "";
a && this.variableNames.push("bias"), p && this.variableNames.push("preluActivationWeights"), u && this.variableNames.push("leakyreluAlpha");
let C = "rc.x", w = "rc.x";
- e[0] < t10[0] ? C = `int(min(float(rc.x), ${e[0] - 1}.))` : t10[0] < e[0] && (w = `int(min(float(rc.x), ${t10[0] - 1}.))`), this.userCode = `
+ e[0] < t6[0] ? C = `int(min(float(rc.x), ${e[0] - 1}.))` : t6[0] < e[0] && (w = `int(min(float(rc.x), ${t6[0] - 1}.))`), this.userCode = `
${g}
// Don't use uniform for sharedDimensionPacked for performance.
const float sharedDimension = ${l}.0;
@@ -18258,12 +18319,12 @@ var xc = class {
int batchA = ${C};
int batchB = ${w};
vec4 a = getMatrixA(batchA, ${m});
- vec4 b = getMatrixB(batchB, ${f});
+ vec4 b = getMatrixB(batchB, ${d});
// These swizzled products need to be separately added.
// See: https://github.com/tensorflow/tfjs/issues/1735
- result += (${d[0]} * ${h[0]});
- result += (${d[1]} * ${h[1]});
+ result += (${f[0]} * ${h[0]});
+ result += (${f[1]} * ${h[1]});
}
return result;
}
@@ -18274,17 +18335,17 @@ var xc = class {
${b}
- ${y}
+ ${x}
setOutput(result);
}
`;
}
};
-var $w = { REAL: "return areal * breal - aimag * bimag;", IMAG: "return areal * bimag + aimag * breal;" };
-var Dl = class {
- constructor(e, t10, o) {
- this.variableNames = ["AReal", "AImag", "BReal", "BImag"], this.outputShape = I.assertAndGetBroadcastShape(t10, o), this.userCode = `
+var kw = { REAL: "return areal * breal - aimag * bimag;", IMAG: "return areal * bimag + aimag * breal;" };
+var Nl = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["AReal", "AImag", "BReal", "BImag"], this.outputShape = S.assertAndGetBroadcastShape(t6, o), this.userCode = `
float binaryOpComplex(
float areal, float aimag, float breal, float bimag) {
${e}
@@ -18300,41 +18361,41 @@ var Dl = class {
`;
}
};
-var dR = "return a * b;";
-function Pl(r) {
- let { inputs: e, backend: t10 } = r, { a: o, b: n } = e, s = I.upcastType(o.dtype, n.dtype);
+var U$ = "return a * b;";
+function Tl(r) {
+ let { inputs: e, backend: t6 } = r, { a: o, b: n } = e, s = S.upcastType(o.dtype, n.dtype);
if (o.dtype === "complex64") {
- let i = t10.texData.get(o.dataId), p = t10.texData.get(n.dataId), u = new Dl($w.REAL, o.shape, n.shape), c = new Dl($w.IMAG, o.shape, n.shape), l = [{ dataId: i.complexTensorInfos.real.dataId, dtype: i.complexTensorInfos.real.dtype, shape: o.shape }, { dataId: i.complexTensorInfos.imag.dataId, dtype: i.complexTensorInfos.imag.dtype, shape: o.shape }, { dataId: p.complexTensorInfos.real.dataId, dtype: p.complexTensorInfos.real.dtype, shape: n.shape }, { dataId: p.complexTensorInfos.imag.dataId, dtype: p.complexTensorInfos.imag.dtype, shape: n.shape }], m = t10.runWebGLProgram(u, l, "float32"), f = t10.runWebGLProgram(c, l, "float32"), d = Ar({ inputs: { real: m, imag: f }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(m), t10.disposeIntermediateTensorInfo(f), d;
+ let i = t6.texData.get(o.dataId), p = t6.texData.get(n.dataId), u = new Nl(kw.REAL, o.shape, n.shape), c = new Nl(kw.IMAG, o.shape, n.shape), l = [{ dataId: i.complexTensorInfos.real.dataId, dtype: i.complexTensorInfos.real.dtype, shape: o.shape }, { dataId: i.complexTensorInfos.imag.dataId, dtype: i.complexTensorInfos.imag.dtype, shape: o.shape }, { dataId: p.complexTensorInfos.real.dataId, dtype: p.complexTensorInfos.real.dtype, shape: n.shape }, { dataId: p.complexTensorInfos.imag.dataId, dtype: p.complexTensorInfos.imag.dtype, shape: n.shape }], m = t6.runWebGLProgram(u, l, "float32"), d = t6.runWebGLProgram(c, l, "float32"), f = Rr({ inputs: { real: m, imag: d }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(m), t6.disposeIntermediateTensorInfo(d), f;
}
- if (t10.shouldExecuteOnCPU([o, n])) {
- let i = t10.texData.get(o.dataId), p = t10.texData.get(n.dataId), [u, c] = k$(o.shape, n.shape, i.values, p.values, s), l = t10.makeTensorInfo(c, s), m = t10.texData.get(l.dataId);
+ if (t6.shouldExecuteOnCPU([o, n])) {
+ let i = t6.texData.get(o.dataId), p = t6.texData.get(n.dataId), [u, c] = e$(o.shape, n.shape, i.values, p.values, s), l = t6.makeTensorInfo(c, s), m = t6.texData.get(l.dataId);
return m.values = u, l;
}
let a;
- return P().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? a = new Ko(dR, o.shape, n.shape) : a = new _o(dR, o.shape, n.shape), t10.runWebGLProgram(a, [o, n], s);
+ return O().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? a = new To(U$, o.shape, n.shape) : a = new io(U$, o.shape, n.shape), t6.runWebGLProgram(a, [o, n], s);
}
-var hR = { kernelName: ho, backendName: "webgl", kernelFunc: Pl };
-function gR(r, e, t10) {
- let o = [Pa(r.shape), ...Oa(r.shape)], n = { dtype: r.dtype, shape: o, dataId: r.dataId }, s = [Pa(e), ...Oa(e)], a = new hc(s, o), i = true, p = [o], u = t10.runWebGLProgram(a, [n], r.dtype, p, i);
+var G$ = { kernelName: kn, backendName: "webgl", kernelFunc: Tl };
+function H$(r, e, t6) {
+ let o = [Va(r.shape), ...za(r.shape)], n = { dtype: r.dtype, shape: o, dataId: r.dataId }, s = [Va(e), ...za(e)], a = new lc(s, o), i = true, p = [o], u = t6.runWebGLProgram(a, [n], r.dtype, p, i);
return { dataId: u.dataId, shape: e, dtype: u.dtype };
}
-function J(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { shape: s } = o, a = t10, i = x.sizeFromShape(n.shape), p = x.inferFromImplicitShape(s, i), u = x.sizeFromShape(p);
- x.assert(i === u, () => `The new shape (${p}) has ${u} elements and the old shape (${n.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`);
+function te(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { shape: s } = o, a = t6, i = y.sizeFromShape(n.shape), p = y.inferFromImplicitShape(s, i), u = y.sizeFromShape(p);
+ y.assert(i === u, () => `The new shape (${p}) has ${u} elements and the old shape (${n.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`);
let c = a.texData.get(n.dataId);
- return c.isPacked && !Ti(n.shape, p) && !(c.texture !== null && Ti(c.shape, p)) ? gR(n, p, a) : (a.incRef(n.dataId), { dataId: n.dataId, shape: p, dtype: n.dtype });
+ return c.isPacked && !Li(n.shape, p) && !(c.texture !== null && Li(c.shape, p)) ? H$(n, p, a) : (a.incRef(n.dataId), { dataId: n.dataId, shape: p, dtype: n.dtype });
}
-var xR = { kernelName: Ss, backendName: "webgl", kernelFunc: J };
-var Ol = class {
- constructor(e, t10) {
+var q$ = { kernelName: Ns, backendName: "webgl", kernelFunc: te };
+var _l = class {
+ constructor(e, t6) {
this.variableNames = ["x"];
let { windowSize: o, batchSize: n, inSize: s, outSize: a } = e;
this.outputShape = [n, a];
let i = Math.floor(o / 4) * 4, p = o % 4, u = "sumValue += dot(values, ones);";
- if (t10 != null) {
- let l = 1 / t10;
- u = `sumValue += dot(values * ${x.isInt(l) ? l.toPrecision(2) : l}, ones);`;
+ if (t6 != null) {
+ let l = 1 / t6;
+ u = `sumValue += dot(values * ${y.isInt(l) ? l.toPrecision(2) : l}, ones);`;
}
let c = "";
s % o > 0 && (c = `
@@ -18393,24 +18454,24 @@ var Ol = class {
`;
}
};
-var ch = class {
- constructor(e, t10) {
+var Jf = class {
+ constructor(e, t6) {
this.variableNames = ["x"];
let { windowSize: o, batchSize: n, inSize: s, outSize: a } = e;
this.outputShape = [n, a];
let i = "0.0", p = "";
- t10 === "prod" ? i = "1.0" : t10 === "min" ? (i = "1.0 / 1e-20", p = "min") : t10 === "max" && (i = "-1.0 / 1e-20", p = "max");
- let u = `${t10}(${t10}(${t10}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;
- t10 === "sum" ? u = "sumValue" : t10 === "prod" ? u = "prodValue" : t10 === "all" ? u = "allValue" : t10 === "any" && (u = "anyValue");
+ t6 === "prod" ? i = "1.0" : t6 === "min" ? (i = "1.0 / 1e-20", p = "min") : t6 === "max" && (i = "-1.0 / 1e-20", p = "max");
+ let u = `${t6}(${t6}(${t6}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;
+ t6 === "sum" ? u = "sumValue" : t6 === "prod" ? u = "prodValue" : t6 === "all" ? u = "allValue" : t6 === "any" && (u = "anyValue");
let c = Math.floor(o / 4) * 4, l = o % 4, m = `
- if (${t10 === "sum"}) {
+ if (${t6 === "sum"}) {
sumValue += dot(values, ones);
- } else if (${t10 === "prod"}) {
+ } else if (${t6 === "prod"}) {
vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);
prodValue *= tmp[0] * tmp[1];
} else {
minMaxValue = ${p}(values, minMaxValue);
- if (${t10 === "min"} || ${t10 === "max"}) {
+ if (${t6 === "min"} || ${t6 === "max"}) {
minMaxValue = ${p}(values, minMaxValue);
bvec4 isNaN = isnan(values);
if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {
@@ -18418,18 +18479,18 @@ var ch = class {
}
}
}
- `, f = "vec4";
- t10 === "all" ? (i = "1.0", m = `
+ `, d = "vec4";
+ t6 === "all" ? (i = "1.0", m = `
bool reducedAllValue = all(values);
float floatedReducedAllValue = float(reducedAllValue);
allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);
- `, f = "bvec4") : t10 === "any" && (i = "0.0", m = `
+ `, d = "bvec4") : t6 === "any" && (i = "0.0", m = `
bool reducedAnyValue = any(values);
float floatedReducedAnyValue = float(reducedAnyValue);
anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);
- `, f = "bvec4");
- let d = "";
- s % o > 0 && (d = `
+ `, d = "bvec4");
+ let f = "";
+ s % o > 0 && (f = `
if (inIdx < 0 || inIdx >= ${s}) {
return initializationValue;
}
@@ -18438,7 +18499,7 @@ var ch = class {
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float getValue(int batch, int inIdx) {
- ${d}
+ ${f}
return getX(batch, inIdx);
}
@@ -18456,7 +18517,7 @@ var ch = class {
for (int i = 0; i < ${c}; i += 4) {
int inIdx = inOffset + i;
- ${f} values = ${f}(
+ ${d} values = ${d}(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
@@ -18468,7 +18529,7 @@ var ch = class {
int inIdx = inOffset + ${c};
if (${l === 1}) {
- ${f} values = ${f}(
+ ${d} values = ${d}(
getValue(batch, inIdx),
initializationValue,
initializationValue,
@@ -18477,7 +18538,7 @@ var ch = class {
${m}
} else if (${l === 2}) {
- ${f} values = ${f}(
+ ${d} values = ${d}(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
initializationValue,
@@ -18486,7 +18547,7 @@ var ch = class {
${m}
} else if (${l === 3}) {
- ${f} values = ${f}(
+ ${d} values = ${d}(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
@@ -18500,30 +18561,30 @@ var ch = class {
`;
}
};
-function CY(r) {
+function W8(r) {
let e = [];
for (; e.length === 0 || e[e.length - 1].outSize !== 1; ) {
- let t10 = e.length ? e[e.length - 1].outSize : r[1], o = I.computeOptimalWindowSize(t10);
- e.push({ inSize: t10, windowSize: o, outSize: Math.ceil(t10 / o) });
+ let t6 = e.length ? e[e.length - 1].outSize : r[1], o = S.computeOptimalWindowSize(t6);
+ e.push({ inSize: t6, windowSize: o, outSize: Math.ceil(t6 / o) });
}
return e;
}
-function qr(r, e, t10, o) {
- let n = CY(r.shape), s = r;
+function Gr(r, e, t6, o) {
+ let n = W8(r.shape), s = r;
for (let a = 0; a < n.length; a++) {
let { inSize: i, windowSize: p, outSize: u } = n[a], c, l;
- t10 === "mean" ? c = a === 0 ? new Ol({ windowSize: p, inSize: i, batchSize: r.shape[0], outSize: u }, i) : new Ol({ windowSize: p, inSize: i, batchSize: r.shape[0], outSize: u }) : c = new ch({ windowSize: p, inSize: i, batchSize: r.shape[0], outSize: u }, t10), l = s, s = o.runWebGLProgram(c, [s], e), l.dataId !== r.dataId && o.disposeIntermediateTensorInfo(l);
+ t6 === "mean" ? c = a === 0 ? new _l({ windowSize: p, inSize: i, batchSize: r.shape[0], outSize: u }, i) : new _l({ windowSize: p, inSize: i, batchSize: r.shape[0], outSize: u }) : c = new Jf({ windowSize: p, inSize: i, batchSize: r.shape[0], outSize: u }, t6), l = s, s = o.runWebGLProgram(c, [s], e), l.dataId !== r.dataId && o.disposeIntermediateTensorInfo(l);
}
return s;
}
-var lh = class {
- constructor(e, t10) {
+var eh = class {
+ constructor(e, t6) {
this.variableNames = ["A"];
let o = new Array(e.length);
for (let a = 0; a < o.length; a++)
- o[a] = e[t10[a]];
+ o[a] = e[t6[a]];
this.outputShape = o, this.rank = o.length;
- let n = _e(this.rank), s = IY(t10);
+ let n = _e(this.rank), s = U8(t6);
this.userCode = `
void main() {
${n} resRC = getOutputCoords();
@@ -18532,26 +18593,26 @@ var lh = class {
`;
}
};
-function IY(r) {
+function U8(r) {
let e = r.length;
if (e > 6)
throw Error(`Transpose for rank ${e} is not yet supported`);
- let t10 = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u", "resRC.v"], o = new Array(e);
+ let t6 = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u", "resRC.v"], o = new Array(e);
for (let n = 0; n < r.length; n++)
- o[r[n]] = t10[n];
+ o[r[n]] = t6[n];
return o.join();
}
-var mh = class {
- constructor(e, t10) {
+var th = class {
+ constructor(e, t6) {
this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true;
let o = new Array(e.length);
for (let c = 0; c < o.length; c++)
- o[c] = e[t10[c]];
+ o[c] = e[t6[c]];
if (this.outputShape = o, this.rank = o.length, this.rank > 6)
throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);
- let n = _e(this.rank), s = vw("rc", this.rank), a = new Array(this.rank);
- for (let c = 0; c < t10.length; c++)
- a[t10[c]] = s[c];
+ let n = _e(this.rank), s = bw("rc", this.rank), a = new Array(this.rank);
+ for (let c = 0; c < t6.length; c++)
+ a[t6[c]] = s[c];
let i = `vec2(${a.slice(-2).join()})`, p = `++${s[this.rank - 1]} < ${o[this.rank - 1]}`, u = `getChannel(getA(${a.join()}), ${i})`;
this.userCode = `
void main() {
@@ -18573,101 +18634,101 @@ var mh = class {
`;
}
};
-function _i(r, e, t10) {
- let o = P().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new mh(r.shape, e) : new lh(r.shape, e);
- return t10.runWebGLProgram(o, [r], r.dtype);
+function Vi(r, e, t6) {
+ let o = O().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new th(r.shape, e) : new eh(r.shape, e);
+ return t6.runWebGLProgram(o, [r], r.dtype);
}
-function yR(r, e, t10, o) {
- let n = e, s = r.shape.length, a = x.parseAxisParam(n, r.shape), i = a, p = I.getAxesPermutation(i, s), u = p != null, c = r;
- u && (c = _i(r, p, o), i = I.getInnerMostAxes(i.length, s)), I.assertAxesAreInnerMostDims("sum", i, s);
- let [l, m] = I.computeOutAndReduceShapes(c.shape, i), f = l;
- t10 && (f = I.expandShapeToKeepDim(l, a));
- let d = x.sizeFromShape(m), g = x.sizeFromShape(r.shape) / d, y = J({ inputs: { x: c }, attrs: { shape: [g, d] }, backend: o }), b = Ca(r.dtype), C = qr(y, b, "sum", o), w = J({ inputs: { x: C }, attrs: { shape: f }, backend: o });
- return o.disposeIntermediateTensorInfo(y), o.disposeIntermediateTensorInfo(C), u && o.disposeIntermediateTensorInfo(c), w;
+function K$(r, e, t6, o) {
+ let n = e, s = r.shape.length, a = y.parseAxisParam(n, r.shape), i = a, p = S.getAxesPermutation(i, s), u = p != null, c = r;
+ u && (c = Vi(r, p, o), i = S.getInnerMostAxes(i.length, s)), S.assertAxesAreInnerMostDims("sum", i, s);
+ let [l, m] = S.computeOutAndReduceShapes(c.shape, i), d = l;
+ t6 && (d = S.expandShapeToKeepDim(l, a));
+ let f = y.sizeFromShape(m), g = y.sizeFromShape(r.shape) / f, x = te({ inputs: { x: c }, attrs: { shape: [g, f] }, backend: o }), b = ka(r.dtype), C = Gr(x, b, "sum", o), w = te({ inputs: { x: C }, attrs: { shape: d }, backend: o });
+ return o.disposeIntermediateTensorInfo(x), o.disposeIntermediateTensorInfo(C), u && o.disposeIntermediateTensorInfo(c), w;
}
function Ou(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
- return yR(n, s, a, t10);
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o;
+ return K$(n, s, a, t6);
}
-var bR = { kernelName: jn, backendName: "webgl", kernelFunc: Ou };
+var j$ = { kernelName: Hn, backendName: "webgl", kernelFunc: Ou };
function xt(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { perm: s } = o, a = t10, i = n.shape.length, p = new Array(i);
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { perm: s } = o, a = t6, i = n.shape.length, p = new Array(i);
for (let c = 0; c < p.length; c++)
p[c] = n.shape[s[c]];
let u;
if (a.shouldExecuteOnCPU([n])) {
let l = a.texData.get(n.dataId).values, m = Du(l, n.shape, n.dtype, s, p);
u = a.makeTensorInfo(p, n.dtype);
- let f = a.texData.get(u.dataId);
- f.values = m;
+ let d = a.texData.get(u.dataId);
+ d.values = m;
} else
- u = _i(n, s, a);
+ u = Vi(n, s, a);
return u;
}
-var CR = { kernelName: Mr, backendName: "webgl", kernelFunc: xt };
-var Rw = 1e3;
-function Mu({ a: r, b: e, transposeA: t10, transposeB: o, backend: n, bias: s = null, preluActivationWeights: a = null, leakyreluAlpha: i = 0, activation: p = null }) {
- let u = r.shape.length, c = e.shape.length, l = t10 ? r.shape[u - 2] : r.shape[u - 1], m = o ? e.shape[c - 1] : e.shape[c - 2], f = t10 ? r.shape[u - 1] : r.shape[u - 2], d = o ? e.shape[c - 2] : e.shape[c - 1], h = r.shape.slice(0, -2), g = e.shape.slice(0, -2), y = x.sizeFromShape(h), b = x.sizeFromShape(g), w = br.assertAndGetBroadcastShape(r.shape.slice(0, -2), e.shape.slice(0, -2)).concat([f, d]);
- x.assert(l === m, () => `Error in matMul: inner shapes (${l}) and (${m}) of Tensors with shapes ${r.shape} and ${e.shape} and transposeA=${t10} and transposeB=${o} must match.`);
- let k = t10 ? [y, l, f] : [y, f, l], _ = o ? [b, d, m] : [b, m, d], E = J({ inputs: { x: r }, backend: n, attrs: { shape: k } }), R = J({ inputs: { x: e }, backend: n, attrs: { shape: _ } }), A = [E, R], D = Math.max(y, b), O = t10 ? E.shape[1] : E.shape[2], M = s != null, L = a != null, W = p === "leakyrelu", V = p != null ? Ma(p, true) : null, G = M || L || W || V != null, q;
- if ((f === 1 || d === 1) && O > Rw && G === false) {
- let j = E, Y = R;
- t10 && (j = xt({ inputs: { x: E }, backend: n, attrs: { perm: [0, 2, 1] } }), A.push(j)), o && (Y = xt({ inputs: { x: R }, backend: n, attrs: { perm: [0, 2, 1] } }), A.push(Y));
- let Z = d !== 1, ee = d === 1, X = j;
- Z && (X = J({ inputs: { x: j }, backend: n, attrs: { shape: [D, O, 1] } }), A.push(X));
- let Q = d === 1 ? 2 : 1, se = Y;
- ee && (se = J({ inputs: { x: Y }, backend: n, attrs: { shape: [D, 1, O] } }), A.push(se));
- let ie = Pl({ inputs: { a: X, b: se }, backend: n });
- q = Ou({ inputs: { x: ie }, backend: n, attrs: { axis: Q, keepDims: true } }), A.push(ie);
+var X$ = { kernelName: ro, backendName: "webgl", kernelFunc: xt };
+var Nw = 1e3;
+function Pu({ a: r, b: e, transposeA: t6, transposeB: o, backend: n, bias: s = null, preluActivationWeights: a = null, leakyreluAlpha: i = 0, activation: p = null }) {
+ let u = r.shape.length, c = e.shape.length, l = t6 ? r.shape[u - 2] : r.shape[u - 1], m = o ? e.shape[c - 1] : e.shape[c - 2], d = t6 ? r.shape[u - 1] : r.shape[u - 2], f = o ? e.shape[c - 2] : e.shape[c - 1], h = r.shape.slice(0, -2), g = e.shape.slice(0, -2), x = y.sizeFromShape(h), b = y.sizeFromShape(g), w = br.assertAndGetBroadcastShape(r.shape.slice(0, -2), e.shape.slice(0, -2)).concat([d, f]);
+ y.assert(l === m, () => `Error in matMul: inner shapes (${l}) and (${m}) of Tensors with shapes ${r.shape} and ${e.shape} and transposeA=${t6} and transposeB=${o} must match.`);
+ let k = t6 ? [x, l, d] : [x, d, l], _ = o ? [b, f, m] : [b, m, f], $ = te({ inputs: { x: r }, backend: n, attrs: { shape: k } }), A = te({ inputs: { x: e }, backend: n, attrs: { shape: _ } }), R = [$, A], D = Math.max(x, b), P = t6 ? $.shape[1] : $.shape[2], M = s != null, L = a != null, W = p === "leakyrelu", V = p != null ? Wa(p, true) : null, U = M || L || W || V != null, q;
+ if ((d === 1 || f === 1) && P > Nw && U === false) {
+ let j = $, X = A;
+ t6 && (j = xt({ inputs: { x: $ }, backend: n, attrs: { perm: [0, 2, 1] } }), R.push(j)), o && (X = xt({ inputs: { x: A }, backend: n, attrs: { perm: [0, 2, 1] } }), R.push(X));
+ let Z = f !== 1, ee = f === 1, Y = j;
+ Z && (Y = te({ inputs: { x: j }, backend: n, attrs: { shape: [D, P, 1] } }), R.push(Y));
+ let J = f === 1 ? 2 : 1, ie = X;
+ ee && (ie = te({ inputs: { x: X }, backend: n, attrs: { shape: [D, 1, P] } }), R.push(ie));
+ let pe = Tl({ inputs: { a: Y, b: ie }, backend: n });
+ q = Ou({ inputs: { x: pe }, backend: n, attrs: { axis: J, keepDims: true } }), R.push(pe);
} else {
- let j = ct(r.dtype, e.dtype), Y = new xc(k, _, [D, f, d], t10, o, M, V, L, W), Z = [E, R];
+ let j = dt(r.dtype, e.dtype), X = new dc(k, _, [D, d, f], t6, o, M, V, L, W), Z = [$, A];
if (s != null && Z.push(s), L && Z.push(a), W) {
- let ee = n.makeTensorInfo([], "float32", x.createScalarValue(i, "float32"));
- Z.push(ee), A.push(ee);
+ let ee = n.makeTensorInfo([], "float32", y.createScalarValue(i, "float32"));
+ Z.push(ee), R.push(ee);
}
- q = n.runWebGLProgram(Y, Z, j);
+ q = n.runWebGLProgram(X, Z, j);
}
- let H = J({ inputs: { x: q }, backend: n, attrs: { shape: w } });
- A.push(q);
- for (let j of A)
+ let H = te({ inputs: { x: q }, backend: n, attrs: { shape: w } });
+ R.push(q);
+ for (let j of R)
n.disposeIntermediateTensorInfo(j);
return H;
}
-function wY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { a: n, b: s, bias: a, preluActivationWeights: i } = e, { transposeA: p, transposeB: u, activation: c, leakyreluAlpha: l } = o;
- return Mu({ a: n, b: s, transposeA: p, transposeB: u, backend: t10, bias: a, preluActivationWeights: i, leakyreluAlpha: l, activation: c });
+function G8(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { a: n, b: s, bias: a, preluActivationWeights: i } = e, { transposeA: p, transposeB: u, activation: c, leakyreluAlpha: l } = o;
+ return Pu({ a: n, b: s, transposeA: p, transposeB: u, backend: t6, bias: a, preluActivationWeights: i, leakyreluAlpha: l, activation: c });
}
-var IR = { kernelName: Fo, backendName: "webgl", kernelFunc: wY };
-var wR = "return abs(x);";
-function SY(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
- if (t10.shouldExecuteOnCPU([o]) && o.dtype !== "complex64") {
- let s = t10.texData.get(o.dataId), a = nh(s.values);
- return t10.makeTensorInfo(o.shape, o.dtype, a);
+var Y$ = { kernelName: fo, backendName: "webgl", kernelFunc: G8 };
+var Q$ = "return abs(x);";
+function H8(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e;
+ if (t6.shouldExecuteOnCPU([o]) && o.dtype !== "complex64") {
+ let s = t6.texData.get(o.dataId), a = Kf(s.values);
+ return t6.makeTensorInfo(o.shape, o.dtype, a);
}
let n;
- return P().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? n = new No(o.shape, wR) : n = new fr(o.shape, wR), t10.runWebGLProgram(n, [o], o.dtype);
+ return O().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? n = new Ar(o.shape, Q$) : n = new Jt(o.shape, Q$), t6.runWebGLProgram(n, [o], o.dtype);
}
-var SR = { kernelName: sn, backendName: "webgl", kernelFunc: SY };
-var vY = Vt + `
+var Z$ = { kernelName: gs, backendName: "webgl", kernelFunc: H8 };
+var q8 = Bt + `
if (abs(x) > 1.) {
return NAN;
}
return acos(x);
`;
-var kY = he({ opSnippet: vY });
-var vR = { kernelName: Li, backendName: "webgl", kernelFunc: kY };
-var TY = Vt + `
+var K8 = ge({ opSnippet: q8 });
+var J$ = { kernelName: sa, backendName: "webgl", kernelFunc: K8 };
+var j8 = Bt + `
if (x < 1.0) return NAN;
return log(x + sqrt(x * x - 1.0));`;
-var NY = he({ opSnippet: TY });
-var kR = { kernelName: Bi, backendName: "webgl", kernelFunc: NY };
-var TR = "return a + b;";
-var _Y = ot({ opSnippet: TR, packedOpSnippet: TR, supportsComplex: true, cpuKernelImpl: s$ });
-var NR = { kernelName: _r, backendName: "webgl", kernelFunc: _Y };
-var fh = class {
- constructor(e, t10) {
- this.outputShape = [], this.outputShape = e, this.variableNames = t10.map((s, a) => `T${a}`);
+var X8 = ge({ opSnippet: j8 });
+var eA = { kernelName: aa, backendName: "webgl", kernelFunc: X8 };
+var tA = "return a + b;";
+var Y8 = tt({ opSnippet: tA, packedOpSnippet: tA, supportsComplex: true, cpuKernelImpl: DE });
+var rA = { kernelName: eo, backendName: "webgl", kernelFunc: Y8 };
+var rh = class {
+ constructor(e, t6) {
+ this.outputShape = [], this.outputShape = e, this.variableNames = t6.map((s, a) => `T${a}`);
let o = [];
this.variableNames.forEach((s) => {
o.push(`float v${s} = get${s}AtOutCoords();`);
@@ -18684,9 +18745,9 @@ var fh = class {
`;
}
};
-var dh = class {
- constructor(e, t10) {
- this.outputShape = [], this.packedInputs = true, this.packedOutput = true, this.outputShape = e, this.variableNames = t10.map((s, a) => `T${a}`);
+var oh = class {
+ constructor(e, t6) {
+ this.outputShape = [], this.packedInputs = true, this.packedOutput = true, this.outputShape = e, this.variableNames = t6.map((s, a) => `T${a}`);
let o = [];
this.variableNames.forEach((s) => {
o.push(`vec4 v${s} = get${s}AtOutCoords();`);
@@ -18703,48 +18764,48 @@ var dh = class {
`;
}
};
-function hh(r) {
- let { inputs: e, backend: t10 } = r, o = e;
+function nh(r) {
+ let { inputs: e, backend: t6 } = r, o = e;
if (o.length === 1)
- return Rt({ inputs: { x: o[0] }, backend: t10 });
- if (o.length > P().get("WEBGL_MAX_TEXTURES_IN_SHADER")) {
- let p = Math.floor(o.length / 2), u = hh({ inputs: o.slice(0, p), backend: t10 }), c = hh({ inputs: o.slice(p), backend: t10 });
- return hh({ inputs: [u, c], backend: t10 });
+ return At({ inputs: { x: o[0] }, backend: t6 });
+ if (o.length > O().get("WEBGL_MAX_TEXTURES_IN_SHADER")) {
+ let p = Math.floor(o.length / 2), u = nh({ inputs: o.slice(0, p), backend: t6 }), c = nh({ inputs: o.slice(p), backend: t6 });
+ return nh({ inputs: [u, c], backend: t6 });
}
- let n = o.map((p) => p.dtype).reduce((p, u) => ct(p, u)), s = o.map((p) => p.shape), i = P().getBool("WEBGL_PACK") ? new dh(o[0].shape, s) : new fh(o[0].shape, s);
- return t10.runWebGLProgram(i, o, n);
+ let n = o.map((p) => p.dtype).reduce((p, u) => dt(p, u)), s = o.map((p) => p.shape), i = O().getBool("WEBGL_PACK") ? new oh(o[0].shape, s) : new rh(o[0].shape, s);
+ return t6.runWebGLProgram(i, o, n);
}
-var _R = { kernelName: an, backendName: "webgl", kernelFunc: hh };
-function EY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = n.shape.length, p = x.parseAxisParam(s, n.shape), u = p, c = I.getAxesPermutation(u, i), l = n;
- c != null && (l = xt({ inputs: { x: n }, backend: t10, attrs: { perm: c } }), u = I.getInnerMostAxes(u.length, i)), I.assertAxesAreInnerMostDims("all", u, i);
- let [m, f] = I.computeOutAndReduceShapes(l.shape, u), d = x.sizeFromShape(f), h = J({ inputs: { x: l }, backend: t10, attrs: { shape: [-1, d] } }), g = qr(h, h.dtype, "all", t10), y;
+var oA = { kernelName: Mo, backendName: "webgl", kernelFunc: nh };
+function Q8(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = n.shape.length, p = y.parseAxisParam(s, n.shape), u = p, c = S.getAxesPermutation(u, i), l = n;
+ c != null && (l = xt({ inputs: { x: n }, backend: t6, attrs: { perm: c } }), u = S.getInnerMostAxes(u.length, i)), S.assertAxesAreInnerMostDims("all", u, i);
+ let [m, d] = S.computeOutAndReduceShapes(l.shape, u), f = y.sizeFromShape(d), h = te({ inputs: { x: l }, backend: t6, attrs: { shape: [-1, f] } }), g = Gr(h, h.dtype, "all", t6), x;
if (a) {
- let b = I.expandShapeToKeepDim(m, p);
- y = J({ inputs: { x: g }, backend: t10, attrs: { shape: b } });
+ let b = S.expandShapeToKeepDim(m, p);
+ x = te({ inputs: { x: g }, backend: t6, attrs: { shape: b } });
} else
- y = J({ inputs: { x: g }, backend: t10, attrs: { shape: m } });
- return t10.disposeIntermediateTensorInfo(h), t10.disposeIntermediateTensorInfo(g), c != null && t10.disposeIntermediateTensorInfo(l), y;
+ x = te({ inputs: { x: g }, backend: t6, attrs: { shape: m } });
+ return t6.disposeIntermediateTensorInfo(h), t6.disposeIntermediateTensorInfo(g), c != null && t6.disposeIntermediateTensorInfo(l), x;
}
-var ER = { kernelName: oa, backendName: "webgl", kernelFunc: EY };
-function $Y(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = n.shape.length, p = x.parseAxisParam(s, n.shape), u = p, c = I.getAxesPermutation(u, i), l = n;
- c != null && (l = xt({ inputs: { x: n }, backend: t10, attrs: { perm: c } }), u = I.getInnerMostAxes(u.length, i)), I.assertAxesAreInnerMostDims("any", u, i);
- let [m, f] = I.computeOutAndReduceShapes(l.shape, u), d = x.sizeFromShape(f), h = J({ inputs: { x: l }, backend: t10, attrs: { shape: [-1, d] } }), g = qr(h, h.dtype, "any", t10), y;
+var nA = { kernelName: Lo, backendName: "webgl", kernelFunc: Q8 };
+function Z8(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = n.shape.length, p = y.parseAxisParam(s, n.shape), u = p, c = S.getAxesPermutation(u, i), l = n;
+ c != null && (l = xt({ inputs: { x: n }, backend: t6, attrs: { perm: c } }), u = S.getInnerMostAxes(u.length, i)), S.assertAxesAreInnerMostDims("any", u, i);
+ let [m, d] = S.computeOutAndReduceShapes(l.shape, u), f = y.sizeFromShape(d), h = te({ inputs: { x: l }, backend: t6, attrs: { shape: [-1, f] } }), g = Gr(h, h.dtype, "any", t6), x;
if (a) {
- let b = I.expandShapeToKeepDim(m, p);
- y = J({ inputs: { x: g }, backend: t10, attrs: { shape: b } });
+ let b = S.expandShapeToKeepDim(m, p);
+ x = te({ inputs: { x: g }, backend: t6, attrs: { shape: b } });
} else
- y = J({ inputs: { x: g }, backend: t10, attrs: { shape: m } });
- return t10.disposeIntermediateTensorInfo(h), t10.disposeIntermediateTensorInfo(g), c != null && t10.disposeIntermediateTensorInfo(l), y;
+ x = te({ inputs: { x: g }, backend: t6, attrs: { shape: m } });
+ return t6.disposeIntermediateTensorInfo(h), t6.disposeIntermediateTensorInfo(g), c != null && t6.disposeIntermediateTensorInfo(l), x;
}
-var $R = { kernelName: na, backendName: "webgl", kernelFunc: $Y };
-var gh = class {
- constructor(e, t10, o) {
+var sA = { kernelName: Bo, backendName: "webgl", kernelFunc: Z8 };
+var sh = class {
+ constructor(e, t6, o) {
this.variableNames = ["A"];
let { windowSize: n, batchSize: s, outSize: a } = e;
o || this.variableNames.push("bestIndicesA"), this.outputShape = [s, a];
- let i = t10 === "max" ? ">" : "<", p = o ? "inOffset + i;" : "round(getBestIndicesA(batch, inOffset + i));";
+ let i = t6 === "max" ? ">" : "<", p = o ? "inOffset + i;" : "round(getBestIndicesA(batch, inOffset + i));";
this.userCode = `
void main() {
ivec2 coords = getOutputCoords();
@@ -18768,23 +18829,23 @@ var gh = class {
`;
}
};
-var xh = class {
- constructor(e, t10, o, n) {
- this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, x.assert(e.length > 2, () => `Packed arg${o.charAt(0).toUpperCase() + o.slice(1)} supports only inputs with rank above 2.`);
- let s = e[e.length - 1], a = Math.ceil(s / t10);
+var ah = class {
+ constructor(e, t6, o, n) {
+ this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, y.assert(e.length > 2, () => `Packed arg${o.charAt(0).toUpperCase() + o.slice(1)} supports only inputs with rank above 2.`);
+ let s = e[e.length - 1], a = Math.ceil(s / t6);
this.outputShape = e.slice(0, -1), a > 1 && this.outputShape.push(a), n || this.variableNames.push("bestIndicesA");
let i = this.outputShape, p = i.length, u = _e(p), c = $t("coords", p), l, m;
if (a === 1) {
m = p + 1;
- let R = _e(m);
+ let A = _e(m);
l = `
- ${R} sourceLocR = ${R}(${c.join()}, 0);
+ ${A} sourceLocR = ${A}(${c.join()}, 0);
++${c[p - 1]};
- ${R} sourceLocG = ${R}(${c.join()}, 0);
+ ${A} sourceLocG = ${A}(${c.join()}, 0);
++${c[p - 2]};
- ${R} sourceLocA = ${R}(${c.join()}, 0);
+ ${A} sourceLocA = ${A}(${c.join()}, 0);
--${c[p - 1]};
- ${R} sourceLocB = ${R}(${c.join()}, 0);
+ ${A} sourceLocB = ${A}(${c.join()}, 0);
--${c[p - 2]};`;
} else
m = p, l = `
@@ -18796,37 +18857,37 @@ var xh = class {
--${c[p - 1]};
${u} sourceLocB = coords;
--${c[p - 2]};`;
- let f = ["x", "y", "z", "w", "u", "v"].slice(0, m), d = "." + f[m - 1], h = f.map((R) => "int " + R), g = $t("sourceLocR", m - 1).concat("inIdx.r"), y = $t("sourceLocG", m - 1).concat("inIdx.g"), b = $t("sourceLocB", m - 1).concat("inIdx.b"), C = $t("sourceLocA", m - 1).concat("inIdx.a"), w = o === "max" ? "greaterThan" : "lessThan", k = n ? "" : `
+ let d = ["x", "y", "z", "w", "u", "v"].slice(0, m), f = "." + d[m - 1], h = d.map((A) => "int " + A), g = $t("sourceLocR", m - 1).concat("inIdx.r"), x = $t("sourceLocG", m - 1).concat("inIdx.g"), b = $t("sourceLocB", m - 1).concat("inIdx.b"), C = $t("sourceLocA", m - 1).concat("inIdx.a"), w = o === "max" ? "greaterThan" : "lessThan", k = n ? "" : `
inIdx = round(vec4(getBestIndicesAChannel(${g.join()}),
- getBestIndicesAChannel(${y.join()}),
+ getBestIndicesAChannel(${x.join()}),
getBestIndicesAChannel(${b.join()}),
getBestIndicesAChannel(${C.join()})));`, _ = `vec4(
getAChannel(${g.join()}),
- hasNextCol ? getAChannel(${y.join()}) : 0.,
+ hasNextCol ? getAChannel(${x.join()}) : 0.,
hasNextRow ? getAChannel(${b.join()}) : 0.,
- hasNextRow && hasNextCol ? getAChannel(${C.join()}) : 0.)`, E = n ? "" : `
+ hasNextRow && hasNextCol ? getAChannel(${C.join()}) : 0.)`, $ = n ? "" : `
float getBestIndicesAChannel(${h.join()}) {
- return getChannel(getBestIndicesA(${f.join()}),
- vec2(${f.slice(-2).join()}));
+ return getChannel(getBestIndicesA(${d.join()}),
+ vec2(${d.slice(-2).join()}));
}`;
this.userCode = `
float getAChannel(${h.join()}) {
- return getChannel(getA(${f.join()}),
- vec2(${f.slice(-2).join()}));
+ return getChannel(getA(${d.join()}),
+ vec2(${d.slice(-2).join()}));
}
- ${E}
+ ${$}
void main() {
${u} coords = getOutputCoords();
bool hasNextCol = ${c[p - 1]} < ${i[p - 1] - 1};
bool hasNextRow = ${c[p - 2]} < ${i[p - 2] - 1};
${l}
- ivec4 srcIdx = ivec4(sourceLocR${d}, sourceLocG${d},
- sourceLocB${d}, sourceLocA${d}) * ${t10};
+ ivec4 srcIdx = ivec4(sourceLocR${f}, sourceLocG${f},
+ sourceLocB${f}, sourceLocA${f}) * ${t6};
ivec4 inIdx = srcIdx;
vec4 bestIndex = vec4(inIdx);
vec4 bestValue = ${_};
- for (int i = 0; i < ${t10}; i++) {
+ for (int i = 0; i < ${t6}; i++) {
inIdx = srcIdx;
${k}
vec4 candidate = ${_};
@@ -18846,99 +18907,99 @@ var xh = class {
`;
}
};
-function RR(r, e, t10, o = null) {
+function aA(r, e, t6, o = null) {
let n = e.shape[0], s = e.shape[1];
o != null && (n = o.shape[0], s = o.shape[1]);
- let a = I.computeOptimalWindowSize(s), i = { windowSize: a, inSize: s, batchSize: n, outSize: Math.ceil(s / a) }, p = new gh(i, t10, o == null), u = [e];
+ let a = S.computeOptimalWindowSize(s), i = { windowSize: a, inSize: s, batchSize: n, outSize: Math.ceil(s / a) }, p = new sh(i, t6, o == null), u = [e];
o != null && u.push(o);
let c = r.runWebGLProgram(p, u, "int32");
if (c.shape[1] === 1)
return c;
- let l = RR(r, e, t10, c);
+ let l = aA(r, e, t6, c);
return r.disposeIntermediateTensorInfo(c), l;
}
-function AR(r, e, t10, o = null) {
- let n = o != null ? o.shape : e.shape, s = n[n.length - 1], a = I.computeOptimalWindowSize(s), i = new xh(n, a, t10, o == null), p = o == null ? [e] : [e, o], u = r.runWebGLProgram(i, p, "int32");
+function iA(r, e, t6, o = null) {
+ let n = o != null ? o.shape : e.shape, s = n[n.length - 1], a = S.computeOptimalWindowSize(s), i = new ah(n, a, t6, o == null), p = o == null ? [e] : [e, o], u = r.runWebGLProgram(i, p, "int32");
if (u.shape.length === e.shape.length) {
- let c = AR(r, e, t10, u);
+ let c = iA(r, e, t6, u);
return r.disposeIntermediateTensorInfo(u), c;
}
return u;
}
-function yh(r, e, t10, o) {
- let n = [t10];
- if (I.assertAxesAreInnerMostDims("arg" + o.charAt(0).toUpperCase() + o.slice(1), n, e.shape.length), !P().getBool("WEBGL_PACK_REDUCE") || e.shape.length <= 2) {
+function ih(r, e, t6, o) {
+ let n = [t6];
+ if (S.assertAxesAreInnerMostDims("arg" + o.charAt(0).toUpperCase() + o.slice(1), n, e.shape.length), !O().getBool("WEBGL_PACK_REDUCE") || e.shape.length <= 2) {
let s = [], a = r.texData.get(e.dataId), i = a !== null && a.isPacked, p = e;
i && (p = r.unpackTensor(e), s.push(p));
- let [u, c] = I.computeOutAndReduceShapes(p.shape, n), l = x.sizeFromShape(c), m = J({ inputs: { x: p }, backend: r, attrs: { shape: [-1, l] } });
+ let [u, c] = S.computeOutAndReduceShapes(p.shape, n), l = y.sizeFromShape(c), m = te({ inputs: { x: p }, backend: r, attrs: { shape: [-1, l] } });
s.push(m);
- let f = RR(r, m, o);
- s.push(f);
- let d = J({ inputs: { x: f }, backend: r, attrs: { shape: u } });
- return s.forEach((h) => r.disposeIntermediateTensorInfo(h)), d;
+ let d = aA(r, m, o);
+ s.push(d);
+ let f = te({ inputs: { x: d }, backend: r, attrs: { shape: u } });
+ return s.forEach((h) => r.disposeIntermediateTensorInfo(h)), f;
}
- return AR(r, e, o);
+ return iA(r, e, o);
}
-function RY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s } = o, a = x.parseAxisParam(s, n.shape), i = I.getAxesPermutation(a, n.shape.length), p = n, u = [];
- i != null && (p = xt({ inputs: { x: n }, backend: t10, attrs: { perm: i } }), u.push(p), a = I.getInnerMostAxes(a.length, p.shape.length)), I.assertAxesAreInnerMostDims("argMax", [a[0]], p.shape.length);
- let c = yh(t10, p, a[0], "max");
- return u.forEach((l) => t10.disposeIntermediateTensorInfo(l)), c;
+function J8(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s } = o, a = y.parseAxisParam(s, n.shape), i = S.getAxesPermutation(a, n.shape.length), p = n, u = [];
+ i != null && (p = xt({ inputs: { x: n }, backend: t6, attrs: { perm: i } }), u.push(p), a = S.getInnerMostAxes(a.length, p.shape.length)), S.assertAxesAreInnerMostDims("argMax", [a[0]], p.shape.length);
+ let c = ih(t6, p, a[0], "max");
+ return u.forEach((l) => t6.disposeIntermediateTensorInfo(l)), c;
}
-var FR = { kernelName: un, backendName: "webgl", kernelFunc: RY };
-function AY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s } = o, a = x.parseAxisParam(s, n.shape), i = I.getAxesPermutation(a, n.shape.length), p = n, u = [];
- i != null && (p = xt({ inputs: { x: n }, backend: t10, attrs: { perm: i } }), u.push(p), a = I.getInnerMostAxes(a.length, p.shape.length)), I.assertAxesAreInnerMostDims("argMin", [a[0]], p.shape.length);
- let c = yh(t10, p, a[0], "min");
- return u.forEach((l) => t10.disposeIntermediateTensorInfo(l)), c;
+var uA = { kernelName: Vo, backendName: "webgl", kernelFunc: J8 };
+function eY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s } = o, a = y.parseAxisParam(s, n.shape), i = S.getAxesPermutation(a, n.shape.length), p = n, u = [];
+ i != null && (p = xt({ inputs: { x: n }, backend: t6, attrs: { perm: i } }), u.push(p), a = S.getInnerMostAxes(a.length, p.shape.length)), S.assertAxesAreInnerMostDims("argMin", [a[0]], p.shape.length);
+ let c = ih(t6, p, a[0], "min");
+ return u.forEach((l) => t6.disposeIntermediateTensorInfo(l)), c;
}
-var DR = { kernelName: ja, backendName: "webgl", kernelFunc: AY };
-var FY = Vt + `
+var pA = { kernelName: Za, backendName: "webgl", kernelFunc: eY };
+var tY = Bt + `
if (abs(x) > 1.) {
return NAN;
}
return asin(x);
`;
-var DY = he({ opSnippet: FY });
-var PR = { kernelName: Vi, backendName: "webgl", kernelFunc: DY };
-var PY = Vt + "return log(x + sqrt(x * x + 1.0));";
-var OY = he({ opSnippet: PY });
-var OR = { kernelName: zi, backendName: "webgl", kernelFunc: OY };
-var MY = Vt + `
+var rY = ge({ opSnippet: tY });
+var cA = { kernelName: ia, backendName: "webgl", kernelFunc: rY };
+var oY = Bt + "return log(x + sqrt(x * x + 1.0));";
+var nY = ge({ opSnippet: oY });
+var lA = { kernelName: ua, backendName: "webgl", kernelFunc: nY };
+var sY = Bt + `
return atan(x);
`;
-var LY = he({ opSnippet: MY });
-var MR = { kernelName: Wi, backendName: "webgl", kernelFunc: LY };
-var BY = gc + `
+var aY = ge({ opSnippet: sY });
+var mA = { kernelName: pa, backendName: "webgl", kernelFunc: aY };
+var iY = mc + `
return atan(a, b);
`;
-var VY = `
+var uY = `
vec4 result = atan(a, b);
bvec4 isNaNA = isnan(a);
bvec4 isNaNB = isnan(b);
bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);
- ` + js + `
+ ` + Zs + `
return result;
`;
-var zY = ot({ opSnippet: BY, packedOpSnippet: VY });
-var LR = { kernelName: sa, backendName: "webgl", kernelFunc: zY };
-var WY = Vt + `
+var pY = tt({ opSnippet: iY, packedOpSnippet: uY });
+var dA = { kernelName: la, backendName: "webgl", kernelFunc: pY };
+var cY = Bt + `
if ((x < -1.0) || (x > 1.0)) return NAN;
return (log(1.0 + x) - log(1.0 - x)) / 2.0;`;
-var UY = he({ opSnippet: WY });
-var BR = { kernelName: Ui, backendName: "webgl", kernelFunc: UY };
-var us = class {
- constructor(e, t10, o, n = false, s = false) {
- if (this.variableNames = ["x"], t10 === "avg" && o)
+var lY = ge({ opSnippet: cY });
+var fA = { kernelName: ca, backendName: "webgl", kernelFunc: lY };
+var ps = class {
+ constructor(e, t6, o, n = false, s = false) {
+ if (this.variableNames = ["x"], t6 === "avg" && o)
throw new Error("Cannot compute positions for average pool.");
- let a = e.filterWidth, i = e.strideHeight, p = e.strideWidth, u = e.dilationHeight, c = e.dilationWidth, l = e.effectiveFilterHeight, m = e.effectiveFilterWidth, f = e.padInfo.top, d = e.padInfo.left;
+ let a = e.filterWidth, i = e.strideHeight, p = e.strideWidth, u = e.dilationHeight, c = e.dilationWidth, l = e.effectiveFilterHeight, m = e.effectiveFilterWidth, d = e.padInfo.top, f = e.padInfo.left;
this.outputShape = e.outShape;
- let h = t10 === "avg", g = `((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`, y = `(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`, b = "0.0";
+ let h = t6 === "avg", g = `((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`, x = `(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`, b = "0.0";
if (h || (b = "-1.0 / 1e-20"), o) {
- let R = ">=";
+ let A = ">=";
this.userCode = `
const ivec2 strides = ivec2(${i}, ${p});
- const ivec2 pads = ivec2(${f}, ${d});
+ const ivec2 pads = ivec2(${d}, ${f});
void main() {
ivec4 coords = getOutputCoords();
@@ -18978,10 +19039,10 @@ var us = class {
// use the current value.
float currMinMaxValue = mix(
value, minMaxValue, minMaxValueFound);
- if (value ${R} currMinMaxValue) {
+ if (value ${A} currMinMaxValue) {
minMaxValue = value;
minMaxValueFound = 1.0;
- minMaxPosition = ${n ? s ? g : y : `wR * ${m} + wC`};
+ minMaxPosition = ${n ? s ? g : x : `wR * ${m} + wC`};
}
}
}
@@ -18990,9 +19051,9 @@ var us = class {
`;
return;
}
- let C = "max", w = `${t10}(${t10}(${t10}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;
- t10 === "avg" && (w = "avgValue / count");
- let k = Math.floor(a / 4) * 4, _ = a % 4, E = `
+ let C = "max", w = `${t6}(${t6}(${t6}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;
+ t6 === "avg" && (w = "avgValue / count");
+ let k = Math.floor(a / 4) * 4, _ = a % 4, $ = `
if (${h}) {
avgValue += dot(values, ones);
} else {
@@ -19001,7 +19062,7 @@ var us = class {
`;
this.userCode = `
const ivec2 strides = ivec2(${i}, ${p});
- const ivec2 pads = ivec2(${f}, ${d});
+ const ivec2 pads = ivec2(${d}, ${f});
const float initializationValue = ${b};
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
@@ -19048,7 +19109,7 @@ var us = class {
getValue(batch, xR, xC + 3 * ${c}, d)
);
- ${E}
+ ${$}
}
int xC = xCCorner + ${k};
@@ -19060,7 +19121,7 @@ var us = class {
initializationValue
);
- ${E}
+ ${$}
} else if (${_ === 2}) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
@@ -19069,7 +19130,7 @@ var us = class {
initializationValue
);
- ${E}
+ ${$}
} else if (${_ === 3}) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
@@ -19078,7 +19139,7 @@ var us = class {
initializationValue
);
- ${E}
+ ${$}
}
}
setOutput(${w});
@@ -19086,19 +19147,19 @@ var us = class {
`;
}
};
-var Ei = class {
- constructor(e, t10, o, n = false, s = false) {
- if (this.variableNames = ["x"], t10 === "avg" && o)
+var zi = class {
+ constructor(e, t6, o, n = false, s = false) {
+ if (this.variableNames = ["x"], t6 === "avg" && o)
throw new Error("Cannot compute positions for average pool.");
- let a = e.filterWidth, i = e.strideDepth, p = e.strideHeight, u = e.strideWidth, c = e.dilationDepth, l = e.dilationHeight, m = e.dilationWidth, f = e.effectiveFilterDepth, d = e.effectiveFilterHeight, h = e.effectiveFilterWidth, g = e.padInfo.front, y = e.padInfo.top, b = e.padInfo.left;
+ let a = e.filterWidth, i = e.strideDepth, p = e.strideHeight, u = e.strideWidth, c = e.dilationDepth, l = e.dilationHeight, m = e.dilationWidth, d = e.effectiveFilterDepth, f = e.effectiveFilterHeight, h = e.effectiveFilterWidth, g = e.padInfo.front, x = e.padInfo.top, b = e.padInfo.left;
this.outputShape = e.outShape;
- let C = t10 === "avg", w = "0.0";
+ let C = t6 === "avg", w = "0.0";
if (C || (w = "-1.0 / 1e-20"), o) {
let D = ">=";
this.userCode = `
const ivec3 strides =
ivec3(${i}, ${p}, ${u});
- const ivec3 pads = ivec3(${g}, ${y}, ${b});
+ const ivec3 pads = ivec3(${g}, ${x}, ${b});
void main() {
ivec5 coords = getOutputCoords();
@@ -19116,7 +19177,7 @@ var Ei = class {
float minMaxValueFound = 0.0;
int minMaxPosition = 0;
- for (int wD = 0; wD < ${f};
+ for (int wD = 0; wD < ${d};
wD += ${c}) {
int xD = xDCorner + wD;
@@ -19124,7 +19185,7 @@ var Ei = class {
continue;
}
- for (int wR = 0; wR < ${d};
+ for (int wR = 0; wR < ${f};
wR += ${l}) {
int xR = xRCorner + wR;
@@ -19149,7 +19210,7 @@ var Ei = class {
if (value ${D} currMinMaxValue) {
minMaxValue = value;
minMaxValueFound = 1.0;
- minMaxPosition = ${n ? s ? `(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch` : `((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch` : `wD * ${d} * ${h} +
+ minMaxPosition = ${n ? s ? `(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch` : `((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch` : `wD * ${f} * ${h} +
wR * ${h} + wC`};
}
}
@@ -19160,9 +19221,9 @@ var Ei = class {
`;
return;
}
- let k = "max", _ = `${t10}(${t10}(${t10}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;
- t10 === "avg" && (_ = "avgValue / count");
- let E = Math.floor(a / 4) * 4, R = a % 4, A = `
+ let k = "max", _ = `${t6}(${t6}(${t6}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;
+ t6 === "avg" && (_ = "avgValue / count");
+ let $ = Math.floor(a / 4) * 4, A = a % 4, R = `
if (${C}) {
avgValue += dot(values, ones);
} else {
@@ -19172,7 +19233,7 @@ var Ei = class {
this.userCode = `
const ivec3 strides =
ivec3(${i}, ${p}, ${u});
- const ivec3 pads = ivec3(${g}, ${y}, ${b});
+ const ivec3 pads = ivec3(${g}, ${x}, ${b});
const float initializationValue = ${w};
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
@@ -19202,7 +19263,7 @@ var Ei = class {
float avgValue = 0.0;
count = 0.0;
- for (int wD = 0; wD < ${f};
+ for (int wD = 0; wD < ${d};
wD += ${c}) {
int xD = xDCorner + wD;
@@ -19210,7 +19271,7 @@ var Ei = class {
continue;
}
- for (int wR = 0; wR < ${d};
+ for (int wR = 0; wR < ${f};
wR += ${l}) {
int xR = xRCorner + wR;
@@ -19218,7 +19279,7 @@ var Ei = class {
continue;
}
- for (int wC = 0; wC < ${E}; wC += 4) {
+ for (int wC = 0; wC < ${$}; wC += 4) {
int xC = xCCorner + wC * ${m};
vec4 values = vec4(
@@ -19228,11 +19289,11 @@ var Ei = class {
getValue(batch, xD, xR, xC + 3 * ${m}, ch)
);
- ${A}
+ ${R}
}
- int xC = xCCorner + ${E};
- if (${R === 1}) {
+ int xC = xCCorner + ${$};
+ if (${A === 1}) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
initializationValue,
@@ -19240,8 +19301,8 @@ var Ei = class {
initializationValue
);
- ${A}
- } else if (${R === 2}) {
+ ${R}
+ } else if (${A === 2}) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + ${m}, ch),
@@ -19249,8 +19310,8 @@ var Ei = class {
initializationValue
);
- ${A}
- } else if (${R === 3}) {
+ ${R}
+ } else if (${A === 3}) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + ${m}, ch),
@@ -19258,7 +19319,7 @@ var Ei = class {
initializationValue
);
- ${A}
+ ${R}
}
}
setOutput(${_});
@@ -19267,27 +19328,27 @@ var Ei = class {
`;
}
};
-function GY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e;
- as(n, "avgPool");
+function mY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e;
+ is(n, "avgPool");
let { filterSize: s, strides: a, pad: i, dimRoundingMode: p } = o, u = 1;
- x.assert(I.eitherStridesOrDilationsAreOne(a, u), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
- let c = I.computePool2DInfo(n.shape, s, a, u, i, p);
- if (c.filterWidth === 1 && c.filterHeight === 1 && x.arraysEqual(c.inShape, c.outShape))
- return Rt({ inputs: { x: n }, backend: t10 });
- let l = new us(c, "avg", false);
- return t10.runWebGLProgram(l, [n], "float32");
+ y.assert(S.eitherStridesOrDilationsAreOne(a, u), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
+ let c = S.computePool2DInfo(n.shape, s, a, u, i, p);
+ if (c.filterWidth === 1 && c.filterHeight === 1 && y.arraysEqual(c.inShape, c.outShape))
+ return At({ inputs: { x: n }, backend: t6 });
+ let l = new ps(c, "avg", false);
+ return t6.runWebGLProgram(l, [n], "float32");
}
-var VR = { kernelName: pn, backendName: "webgl", kernelFunc: GY };
-function HY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { filterSize: s, strides: a, pad: i, dimRoundingMode: p, dataFormat: u } = o, c = [1, 1, 1], l = I.computePool3DInfo(n.shape, s, a, c, i, p, u), m = new Ei(l, "avg", false);
- return t10.runWebGLProgram(m, [n], "float32");
+var hA = { kernelName: zo, backendName: "webgl", kernelFunc: mY };
+function dY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { filterSize: s, strides: a, pad: i, dimRoundingMode: p, dataFormat: u } = o, c = [1, 1, 1], l = S.computePool3DInfo(n.shape, s, a, c, i, p, u), m = new zi(l, "avg", false);
+ return t6.runWebGLProgram(m, [n], "float32");
}
-var zR = { kernelName: ip, backendName: "webgl", kernelFunc: HY };
-var bh = class {
+var gA = { kernelName: ip, backendName: "webgl", kernelFunc: dY };
+var uh = class {
constructor(e) {
this.variableNames = ["dy"], this.outputShape = e.inShape;
- let t10 = e.filterHeight, o = e.filterWidth, n = e.strideHeight, s = e.strideWidth, a = e.dilationHeight, i = e.dilationWidth, p = e.effectiveFilterHeight, u = e.effectiveFilterWidth, c = p - 1 - e.padInfo.top, l = u - 1 - e.padInfo.left, m = 1 / (t10 * o);
+ let t6 = e.filterHeight, o = e.filterWidth, n = e.strideHeight, s = e.strideWidth, a = e.dilationHeight, i = e.dilationWidth, p = e.effectiveFilterHeight, u = e.effectiveFilterWidth, c = p - 1 - e.padInfo.top, l = u - 1 - e.padInfo.left, m = 1 / (t6 * o);
this.userCode = `
const ivec2 pads = ivec2(${c}, ${l});
const float avgMultiplier = float(${m});
@@ -19333,13 +19394,13 @@ var bh = class {
`;
}
};
-var Ch = class {
+var ph = class {
constructor(e) {
this.variableNames = ["dy"], this.outputShape = e.inShape;
- let t10 = e.filterDepth, o = e.filterHeight, n = e.filterWidth, s = e.strideDepth, a = e.strideHeight, i = e.strideWidth, p = e.dilationDepth, u = e.dilationHeight, c = e.dilationWidth, l = e.effectiveFilterDepth, m = e.effectiveFilterHeight, f = e.effectiveFilterWidth, d = l - 1 - e.padInfo.front, h = m - 1 - e.padInfo.top, g = f - 1 - e.padInfo.left, y = 1 / (t10 * o * n);
+ let t6 = e.filterDepth, o = e.filterHeight, n = e.filterWidth, s = e.strideDepth, a = e.strideHeight, i = e.strideWidth, p = e.dilationDepth, u = e.dilationHeight, c = e.dilationWidth, l = e.effectiveFilterDepth, m = e.effectiveFilterHeight, d = e.effectiveFilterWidth, f = l - 1 - e.padInfo.front, h = m - 1 - e.padInfo.top, g = d - 1 - e.padInfo.left, x = 1 / (t6 * o * n);
this.userCode = `
- const ivec3 pads = ivec3(${d}, ${h}, ${g});
- const float avgMultiplier = float(${y});
+ const ivec3 pads = ivec3(${f}, ${h}, ${g});
+ const float avgMultiplier = float(${x});
void main() {
ivec5 coords = getOutputCoords();
@@ -19375,7 +19436,7 @@ var Ch = class {
}
int idyR = int(dyR);
- for (int wC = 0; wC < ${f};
+ for (int wC = 0; wC < ${d};
wC += ${c}) {
float dyC = float(dyCCorner + wC) / ${i}.0;
@@ -19396,30 +19457,30 @@ var Ch = class {
`;
}
};
-function qY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, input: s } = e, a = s, { filterSize: i, strides: p, pad: u, dimRoundingMode: c } = o, l = [1, 1, 1], m = I.computePool3DInfo(a.shape, i, p, l, u, c), f = new Ch(m);
- return t10.runWebGLProgram(f, [n], a.dtype);
+function fY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, input: s } = e, a = s, { filterSize: i, strides: p, pad: u, dimRoundingMode: c } = o, l = [1, 1, 1], m = S.computePool3DInfo(a.shape, i, p, l, u, c), d = new ph(m);
+ return t6.runWebGLProgram(d, [n], a.dtype);
}
-var WR = { kernelName: Fm, backendName: "webgl", kernelFunc: qY };
-function KY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, input: s } = e, a = s;
- as([n, s], "avgPoolGrad");
- let { filterSize: i, strides: p, pad: u } = o, c = I.computePool2DInfo(a.shape, i, p, 1, u), l = new bh(c);
- return t10.runWebGLProgram(l, [n], a.dtype);
+var xA = { kernelName: Im, backendName: "webgl", kernelFunc: fY };
+function hY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, input: s } = e, a = s;
+ is([n, s], "avgPoolGrad");
+ let { filterSize: i, strides: p, pad: u } = o, c = S.computePool2DInfo(a.shape, i, p, 1, u), l = new uh(c);
+ return t6.runWebGLProgram(l, [n], a.dtype);
}
-var UR = { kernelName: Am, backendName: "webgl", kernelFunc: KY };
-function jY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { a: n, b: s } = e, { transposeA: a, transposeB: i } = o;
- return Mu({ a: n, b: s, transposeA: a, transposeB: i, backend: t10 });
+var yA = { kernelName: wm, backendName: "webgl", kernelFunc: hY };
+function gY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { a: n, b: s } = e, { transposeA: a, transposeB: i } = o;
+ return Pu({ a: n, b: s, transposeA: a, transposeB: i, backend: t6 });
}
-var GR = { kernelName: cn, backendName: "webgl", kernelFunc: jY };
-var Ih = class {
- constructor(e, t10, o, n, s, a) {
- this.outputShape = [], this.variableNames = ["x", "mean", "variance"], I.assertAndGetBroadcastShape(e, t10), I.assertAndGetBroadcastShape(e, o);
+var bA = { kernelName: Wo, backendName: "webgl", kernelFunc: gY };
+var ch = class {
+ constructor(e, t6, o, n, s, a) {
+ this.outputShape = [], this.variableNames = ["x", "mean", "variance"], S.assertAndGetBroadcastShape(e, t6), S.assertAndGetBroadcastShape(e, o);
let i = "0.0";
- n != null && (I.assertAndGetBroadcastShape(e, n), this.variableNames.push("offset"), i = "getOffsetAtOutCoords()");
+ n != null && (S.assertAndGetBroadcastShape(e, n), this.variableNames.push("offset"), i = "getOffsetAtOutCoords()");
let p = "1.0";
- s != null && (I.assertAndGetBroadcastShape(e, s), this.variableNames.push("scale"), p = "getScaleAtOutCoords()"), this.outputShape = e, this.userCode = `
+ s != null && (S.assertAndGetBroadcastShape(e, s), this.variableNames.push("scale"), p = "getScaleAtOutCoords()"), this.outputShape = e, this.userCode = `
void main() {
float x = getXAtOutCoords();
float mean = getMeanAtOutCoords();
@@ -19432,13 +19493,13 @@ var Ih = class {
`;
}
};
-var wh = class {
- constructor(e, t10, o, n, s, a) {
- this.packedInputs = true, this.packedOutput = true, this.variableNames = ["x", "mean", "variance"], I.assertAndGetBroadcastShape(e, t10), I.assertAndGetBroadcastShape(e, o);
+var lh = class {
+ constructor(e, t6, o, n, s, a) {
+ this.packedInputs = true, this.packedOutput = true, this.variableNames = ["x", "mean", "variance"], S.assertAndGetBroadcastShape(e, t6), S.assertAndGetBroadcastShape(e, o);
let i = "vec4(0.0)";
- n != null && (I.assertAndGetBroadcastShape(e, n), this.variableNames.push("offset"), i = "getOffsetAtOutCoords()");
+ n != null && (S.assertAndGetBroadcastShape(e, n), this.variableNames.push("offset"), i = "getOffsetAtOutCoords()");
let p = "vec4(1.0)";
- s != null && (I.assertAndGetBroadcastShape(e, s), this.variableNames.push("scale"), p = "getScaleAtOutCoords()"), this.outputShape = e, this.userCode = `
+ s != null && (S.assertAndGetBroadcastShape(e, s), this.variableNames.push("scale"), p = "getScaleAtOutCoords()"), this.outputShape = e, this.userCode = `
void main() {
vec4 offset = ${i};
vec4 scale = ${p};
@@ -19454,28 +19515,28 @@ var wh = class {
`;
}
};
-var XY = ({ inputs: r, backend: e, attrs: t10 }) => {
+var xY = ({ inputs: r, backend: e, attrs: t6 }) => {
let { x: o, mean: n, variance: s, offset: a, scale: i } = r;
- x.assert(n.shape.length === s.shape.length, () => "Batch normalization gradient requires mean and variance to have equal ranks."), x.assert(a == null || n.shape.length === a.shape.length, () => "Batch normalization gradient requires mean and offset to have equal ranks."), x.assert(i == null || n.shape.length === i.shape.length, () => "Batch normalization gradient requires mean and scale to have equal ranks.");
- let { varianceEpsilon: p } = t10;
+ y.assert(n.shape.length === s.shape.length, () => "Batch normalization gradient requires mean and variance to have equal ranks."), y.assert(a == null || n.shape.length === a.shape.length, () => "Batch normalization gradient requires mean and offset to have equal ranks."), y.assert(i == null || n.shape.length === i.shape.length, () => "Batch normalization gradient requires mean and scale to have equal ranks.");
+ let { varianceEpsilon: p } = t6;
p == null && (p = 1e-3);
let u = [o, n, s], c = null;
a != null && (c = a.shape, u.push(a));
let l = null;
i != null && (l = i.shape, u.push(i));
- let m = P().getBool("WEBGL_PACK_NORMALIZATION") ? new wh(o.shape, n.shape, s.shape, c, l, p) : new Ih(o.shape, n.shape, s.shape, c, l, p);
+ let m = O().getBool("WEBGL_PACK_NORMALIZATION") ? new lh(o.shape, n.shape, s.shape, c, l, p) : new ch(o.shape, n.shape, s.shape, c, l, p);
return e.runWebGLProgram(m, u, u[0].dtype);
};
-var HR = { kernelName: kn, backendName: "webgl", kernelFunc: XY };
-var Sh = class {
+var CA = { kernelName: an, backendName: "webgl", kernelFunc: xY };
+var mh = class {
constructor(e) {
this.variableNames = ["source"], this.outputShape = e, this.rank = e.length;
- let t10 = _e(this.rank);
+ let t6 = _e(this.rank);
this.customUniforms = [{ name: "start", arrayIndex: this.rank, type: "int" }];
- let o = YY(this.rank), n, s = e.map((a, i) => `sourceLoc.${Aw[i]} = start[${i}] + coords.${Aw[i]};`);
+ let o = yY(this.rank), n, s = e.map((a, i) => `sourceLoc.${Tw[i]} = start[${i}] + coords.${Tw[i]};`);
n = `
- ${t10} sourceLoc;
- ${t10} coords = getOutputCoords();
+ ${t6} sourceLoc;
+ ${t6} coords = getOutputCoords();
${s.join(`
`)}
`, this.userCode = `
@@ -19486,18 +19547,18 @@ var Sh = class {
`;
}
};
-var Aw = ["x", "y", "z", "w", "u", "v"];
-function YY(r) {
+var Tw = ["x", "y", "z", "w", "u", "v"];
+function yY(r) {
if (r === 1)
return "sourceLoc";
if (r <= 6)
- return Aw.slice(0, r).map((e) => "sourceLoc." + e).join(",");
+ return Tw.slice(0, r).map((e) => "sourceLoc." + e).join(",");
throw Error(`Slicing for rank ${r} is not yet supported`);
}
-var vh = class {
+var dh = class {
constructor(e) {
this.variableNames = ["source"], this.packedInputs = true, this.packedOutput = true, this.outputShape = e, this.rank = e.length, this.customUniforms = [{ name: "start", arrayIndex: this.rank, type: "int" }];
- let t10 = _e(this.rank), o = $t("coords", this.rank), n = $t("sourceLoc", this.rank), s = this.rank === 1 ? "sourceLoc" : `vec2(${n.slice(-2).join()})`, a = `getChannel(getSource(${n.join()}), ${s})`, i = `
+ let t6 = _e(this.rank), o = $t("coords", this.rank), n = $t("sourceLoc", this.rank), s = this.rank === 1 ? "sourceLoc" : `vec2(${n.slice(-2).join()})`, a = `getChannel(getSource(${n.join()}), ${s})`, i = `
result.x = ${a};
if (++${o[this.rank - 1]} < ${e[this.rank - 1]}) {
++${n[this.rank - 1]};
@@ -19515,12 +19576,12 @@ var vh = class {
}
}
`, u = this.rank <= 4 ? `sourceLoc = coords +
- ${t10}(${e.map((c, l) => `start[${l}]`).join()});` : e.map((c, l) => `${n[l]} = ${o[l]} + start[${l}];`).join(`
+ ${t6}(${e.map((c, l) => `start[${l}]`).join()});` : e.map((c, l) => `${n[l]} = ${o[l]} + start[${l}];`).join(`
`);
this.userCode = `
void main() {
- ${t10} coords = getOutputCoords();
- ${t10} sourceLoc;
+ ${t6} coords = getOutputCoords();
+ ${t6} sourceLoc;
${u}
vec4 result = vec4(0.);
${i}
@@ -19530,93 +19591,93 @@ var vh = class {
`;
}
};
-function QY(r, e, t10, o) {
- let n = o.texData.get(r.dataId), s = o.makeTensorInfo(t10, r.dtype), a = o.texData.get(s.dataId);
- Object.assign(a, n), a.refCount = 1, a.shape = t10, a.dtype = r.dtype;
- let i = et.computeFlatOffset(e, x.computeStrides(r.shape));
+function bY(r, e, t6, o) {
+ let n = o.texData.get(r.dataId), s = o.makeTensorInfo(t6, r.dtype), a = o.texData.get(s.dataId);
+ Object.assign(a, n), a.refCount = 1, a.shape = t6, a.dtype = r.dtype;
+ let i = ut.computeFlatOffset(e, y.computeStrides(r.shape));
n.slice && (i += n.slice.flatOffset), a.slice = { flatOffset: i, origDataId: n.slice && n.slice.origDataId || r.dataId };
let p = o.dataRefCount.get(a.slice.origDataId) || 1;
return o.dataRefCount.set(a.slice.origDataId, p + 1), s;
}
-function ps(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { begin: s, size: a } = o, [i, p] = et.parseSliceParams(n, s, a);
- if (et.assertParamsValid(n, i, p), x.sizeFromShape(p) === 0)
- return t10.makeTensorInfo(p, n.dtype, []);
- if (t10.shouldExecuteOnCPU([n]) || n.dtype === "string") {
- let l = t10.texData.get(n.dataId), m = O$(l.values, i, p, n.shape, n.dtype);
- return t10.makeTensorInfo(p, n.dtype, m);
+function cs(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { begin: s, size: a } = o, [i, p] = ut.parseSliceParams(n, s, a);
+ if (ut.assertParamsValid(n, i, p), y.sizeFromShape(p) === 0)
+ return t6.makeTensorInfo(p, n.dtype, []);
+ if (t6.shouldExecuteOnCPU([n]) || n.dtype === "string") {
+ let l = t6.texData.get(n.dataId), m = l$(l.values, i, p, n.shape, n.dtype);
+ return t6.makeTensorInfo(p, n.dtype, m);
}
- let { isPacked: u } = t10.texData.get(n.dataId), c = et.isSliceContinous(n.shape, i, p);
+ let { isPacked: u } = t6.texData.get(n.dataId), c = ut.isSliceContinous(n.shape, i, p);
if (u || !c) {
- let l = P().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new vh(p) : new Sh(p), m = [i];
- return t10.runWebGLProgram(l, [n], n.dtype, m);
+ let l = O().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new dh(p) : new mh(p), m = [i];
+ return t6.runWebGLProgram(l, [n], n.dtype, m);
}
- return t10.uploadToGPU(n.dataId), QY(n, i, p, t10);
+ return t6.uploadToGPU(n.dataId), bY(n, i, p, t6);
}
-var qR = { kernelName: qn, backendName: "webgl", kernelFunc: ps };
-var ZY = (r) => {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { blockShape: s, crops: a } = o;
- x.assert(n.shape.length <= 4, () => "batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");
- let i = s.reduce((b, C) => b * C), p = I.getReshaped(n.shape, s, i), u = I.getPermuted(p.length, s.length), c = I.getReshapedPermuted(n.shape, s, i), l = I.getSliceBeginCoords(a, s.length), m = I.getSliceSize(c, a, s.length), f = [], d = J({ inputs: { x: n }, backend: t10, attrs: { shape: p } }), h = xt({ inputs: { x: d }, backend: t10, attrs: { perm: u } }), g = J({ inputs: { x: h }, backend: t10, attrs: { shape: c } }), y = ps({ inputs: { x: g }, backend: t10, attrs: { begin: l, size: m } });
- return f.push(d), f.push(h), f.push(g), f.forEach((b) => t10.disposeIntermediateTensorInfo(b)), y;
+var SA = { kernelName: _s, backendName: "webgl", kernelFunc: cs };
+var CY = (r) => {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { blockShape: s, crops: a } = o;
+ y.assert(n.shape.length <= 4, () => "batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");
+ let i = s.reduce((b, C) => b * C), p = S.getReshaped(n.shape, s, i), u = S.getPermuted(p.length, s.length), c = S.getReshapedPermuted(n.shape, s, i), l = S.getSliceBeginCoords(a, s.length), m = S.getSliceSize(c, a, s.length), d = [], f = te({ inputs: { x: n }, backend: t6, attrs: { shape: p } }), h = xt({ inputs: { x: f }, backend: t6, attrs: { perm: u } }), g = te({ inputs: { x: h }, backend: t6, attrs: { shape: c } }), x = cs({ inputs: { x: g }, backend: t6, attrs: { begin: l, size: m } });
+ return d.push(f), d.push(h), d.push(g), d.forEach((b) => t6.disposeIntermediateTensorInfo(b)), x;
};
-var KR = { kernelName: hs, backendName: "webgl", kernelFunc: ZY };
-function JY(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, weights: s } = e, { size: a } = o, i = t10.readSync(n.dataId), p = t10.readSync(s.dataId), u = oh(i, p, s.dtype, s.shape, a);
- return t10.makeTensorInfo([a], s.dtype, u);
+var wA = { kernelName: xs, backendName: "webgl", kernelFunc: CY };
+function SY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, weights: s } = e, { size: a } = o, i = t6.readSync(n.dataId), p = t6.readSync(s.dataId), u = qf(i, p, s.dtype, s.shape, a);
+ return t6.makeTensorInfo([a], s.dtype, u);
}
-var jR = { kernelName: up, backendName: "webgl", kernelFunc: JY };
-function eQ(r) {
- let { inputs: e, backend: t10 } = r, { s0: o, s1: n } = e, s = t10.readSync(o.dataId), a = t10.readSync(n.dataId), i = I.assertAndGetBroadcastShape(Array.from(s), Array.from(a));
- return t10.makeTensorInfo([i.length], "int32", Int32Array.from(i));
+var IA = { kernelName: Ja, backendName: "webgl", kernelFunc: SY };
+function wY(r) {
+ let { inputs: e, backend: t6 } = r, { s0: o, s1: n } = e, s = t6.readSync(o.dataId), a = t6.readSync(n.dataId), i = S.assertAndGetBroadcastShape(Array.from(s), Array.from(a));
+ return t6.makeTensorInfo([i.length], "int32", Int32Array.from(i));
}
-var XR = { kernelName: pp, backendName: "webgl", kernelFunc: eQ };
-var tQ = "return float(a != b);";
-var Fw = ot({ opSnippet: tQ, cpuKernelImpl: N$, dtype: "bool" });
-var YR = { kernelName: go, backendName: "webgl", kernelFunc: Fw };
-function La(r) {
- let { inputs: e, backend: t10 } = r, { input: o } = e, n = t10.texData.get(o.dataId);
- return Rt({ inputs: { x: n.complexTensorInfos.real }, backend: t10 });
+var vA = { kernelName: up, backendName: "webgl", kernelFunc: wY };
+var IY = "return float(a != b);";
+var _w = tt({ opSnippet: IY, cpuKernelImpl: r$, dtype: "bool" });
+var kA = { kernelName: Nn, backendName: "webgl", kernelFunc: _w };
+function Ua(r) {
+ let { inputs: e, backend: t6 } = r, { input: o } = e, n = t6.texData.get(o.dataId);
+ return At({ inputs: { x: n.complexTensorInfos.real }, backend: t6 });
}
-var QR = { kernelName: la, backendName: "webgl", kernelFunc: La };
-var rQ = "return float(int(x));";
-function ZR(r, e) {
- let t10 = new fr(r.shape, rQ), o = e.runWebGLProgram(t10, [r], "int32");
+var NA = { kernelName: ai, backendName: "webgl", kernelFunc: Ua };
+var vY = "return float(int(x));";
+function TA(r, e) {
+ let t6 = new Jt(r.shape, vY), o = e.runWebGLProgram(t6, [r], "int32");
return { dataId: o.dataId, shape: o.shape, dtype: o.dtype };
}
-function Dw(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { dtype: s } = o;
+function Ew(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { dtype: s } = o;
if (s === "complex64") {
if (n.dtype === "complex64")
- return Rt({ inputs: { x: n }, backend: t10 });
- let a = Wr(n.shape), i = Dw({ inputs: { x: n }, backend: t10, attrs: { dtype: "float32" } }), p = Ar({ inputs: { real: i, imag: a }, backend: t10 });
- return a.dispose(), t10.disposeIntermediateTensorInfo(i), p;
+ return At({ inputs: { x: n }, backend: t6 });
+ let a = Vr(n.shape), i = Ew({ inputs: { x: n }, backend: t6, attrs: { dtype: "float32" } }), p = Rr({ inputs: { real: i, imag: a }, backend: t6 });
+ return a.dispose(), t6.disposeIntermediateTensorInfo(i), p;
}
if (n.dtype === "complex64") {
- let a = La({ inputs: { input: n }, backend: t10 }), i = Dw({ inputs: { x: a }, backend: t10, attrs: { dtype: s } });
- return t10.disposeIntermediateTensorInfo(a), i;
+ let a = Ua({ inputs: { input: n }, backend: t6 }), i = Ew({ inputs: { x: a }, backend: t6, attrs: { dtype: s } });
+ return t6.disposeIntermediateTensorInfo(a), i;
}
- if (!x.hasEncodingLoss(n.dtype, s)) {
- let a = Rt({ inputs: { x: n }, backend: t10 });
+ if (!y.hasEncodingLoss(n.dtype, s)) {
+ let a = At({ inputs: { x: n }, backend: t6 });
return { dataId: a.dataId, shape: a.shape, dtype: s };
}
- if (t10.shouldExecuteOnCPU([n])) {
- let a = t10.texData.get(n.dataId).values, [i, p, u] = i$(a, n.shape, n.dtype, s);
- return t10.makeTensorInfo(i, p, u);
+ if (t6.shouldExecuteOnCPU([n])) {
+ let a = t6.texData.get(n.dataId).values, [i, p, u] = PE(a, n.shape, n.dtype, s);
+ return t6.makeTensorInfo(i, p, u);
}
if (s === "int32")
- return ZR(n, t10);
+ return TA(n, t6);
if (s === "bool") {
- let a = t10.makeTensorInfo([], "bool", x.getTypedArrayFromDType("bool", 1)), p = Fw({ inputs: { a: n, b: a }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(a), p;
+ let a = t6.makeTensorInfo([], "bool", y.getTypedArrayFromDType("bool", 1)), p = _w({ inputs: { a: n, b: a }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(a), p;
}
throw new Error(`Error in Cast: failed to cast ${n.dtype} to ${s}`);
}
-var JR = { kernelName: to, backendName: "webgl", kernelFunc: Dw };
-var eA = "return ceil(x);";
-var oQ = he({ opSnippet: eA, packedOpSnippet: eA, cpuKernelImpl: u$ });
-var tA = { kernelName: ro, backendName: "webgl", kernelFunc: oQ };
-var kh = class {
+var _A = { kernelName: co, backendName: "webgl", kernelFunc: Ew };
+var EA = "return ceil(x);";
+var kY = ge({ opSnippet: EA, packedOpSnippet: EA, cpuKernelImpl: ME });
+var $A = { kernelName: Uo, backendName: "webgl", kernelFunc: kY };
+var fh = class {
constructor(e) {
this.variableNames = ["A"], this.customUniforms = [{ name: "minVal", type: "float" }, { name: "maxVal", type: "float" }], this.outputShape = e, this.userCode = `
@@ -19632,7 +19693,7 @@ var kh = class {
`;
}
};
-var Th = class {
+var hh = class {
constructor(e) {
this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "minVal", type: "float" }, { name: "maxVal", type: "float" }], this.outputShape = e, this.userCode = `
void main() {
@@ -19648,14 +19709,14 @@ var Th = class {
`;
}
};
-function nQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { clipValueMin: s, clipValueMax: a } = o, i;
- P().getBool("WEBGL_PACK_CLIP") ? i = new Th(n.shape) : i = new kh(n.shape);
+function NY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { clipValueMin: s, clipValueMax: a } = o, i;
+ O().getBool("WEBGL_PACK_CLIP") ? i = new hh(n.shape) : i = new fh(n.shape);
let p = [[s], [a]];
- return t10.runWebGLProgram(i, [n], n.dtype, p);
+ return t6.runWebGLProgram(i, [n], n.dtype, p);
}
-var rA = { kernelName: Ro, backendName: "webgl", kernelFunc: nQ };
-var Nh = class {
+var AA = { kernelName: lo, backendName: "webgl", kernelFunc: NY };
+var gh = class {
constructor(e) {
this.variableNames = ["real", "imag"], this.outputShape = e, this.userCode = `
void main() {
@@ -19673,27 +19734,27 @@ var Nh = class {
`;
}
};
-function oA(r, e) {
+function RA(r, e) {
return { dataId: e.dataId, dtype: e.dtype, shape: r.shape };
}
-function sQ(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e, n = t10.texData.get(o.dataId), s = new Nh(o.shape), a = [oA(o, n.complexTensorInfos.real), oA(o, n.complexTensorInfos.imag)];
- return t10.runWebGLProgram(s, a, a[0].dtype);
+function TY(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e, n = t6.texData.get(o.dataId), s = new gh(o.shape), a = [RA(o, n.complexTensorInfos.real), RA(o, n.complexTensorInfos.imag)];
+ return t6.runWebGLProgram(s, a, a[0].dtype);
}
-var nA = { kernelName: cp, backendName: "webgl", kernelFunc: sQ };
-var _h = class {
+var FA = { kernelName: pp, backendName: "webgl", kernelFunc: TY };
+var xh = class {
constructor(e) {
- this.outputShape = [], this.outputShape = I.computeOutShape(e, 1), this.variableNames = e.map((a, i) => `T${i}`);
- let t10 = new Array(e.length - 1);
- t10[0] = e[0][1];
- for (let a = 1; a < t10.length; a++)
- t10[a] = t10[a - 1] + e[a][1];
- let o = [`if (yC < ${t10[0]}) setOutput(getT0(yR, yC));`];
- for (let a = 1; a < t10.length; a++) {
- let i = t10[a - 1];
- o.push(`else if (yC < ${t10[a]}) setOutput(getT${a}(yR, yC-${i}));`);
+ this.outputShape = [], this.outputShape = S.computeOutShape(e, 1), this.variableNames = e.map((a, i) => `T${i}`);
+ let t6 = new Array(e.length - 1);
+ t6[0] = e[0][1];
+ for (let a = 1; a < t6.length; a++)
+ t6[a] = t6[a - 1] + e[a][1];
+ let o = [`if (yC < ${t6[0]}) setOutput(getT0(yR, yC));`];
+ for (let a = 1; a < t6.length; a++) {
+ let i = t6[a - 1];
+ o.push(`else if (yC < ${t6[a]}) setOutput(getT${a}(yR, yC-${i}));`);
}
- let n = t10.length, s = t10[t10.length - 1];
+ let n = t6.length, s = t6[t6.length - 1];
o.push(`else setOutput(getT${n}(yR, yC-${s}));`), this.userCode = `
void main() {
ivec2 coords = getOutputCoords();
@@ -19706,16 +19767,16 @@ var _h = class {
`;
}
};
-var $h = class {
- constructor(e, t10) {
- this.packedInputs = true, this.packedOutput = true, this.outputShape = [], this.outputShape = I.computeOutShape(e, t10);
+var bh = class {
+ constructor(e, t6) {
+ this.packedInputs = true, this.packedOutput = true, this.outputShape = [], this.outputShape = S.computeOutShape(e, t6);
let o = this.outputShape, n = o.length, s = _e(n), a = $t("coords", n), i = ["x", "y", "z", "w", "u", "v"].slice(0, n);
this.variableNames = e.map((h, g) => `T${g}`);
let p = new Array(e.length - 1);
- p[0] = e[0][t10];
+ p[0] = e[0][t6];
for (let h = 1; h < p.length; h++)
- p[h] = p[h - 1] + e[h][t10];
- let u = i[t10], c = i.slice(-2), l = i.join(), m = `if (${u} < ${p[0]}) {
+ p[h] = p[h - 1] + e[h][t6];
+ let u = i[t6], c = i.slice(-2), l = i.join(), m = `if (${u} < ${p[0]}) {
return getChannel(
getT0(${l}), vec2(${c.join()}));
}`;
@@ -19724,15 +19785,15 @@ var $h = class {
m += `
if (${u} < ${p[h]} && ${u} >= ${p[h - 1]}) {
return getChannel(
- getT${h}(${Eh(i, u, g)}),
- vec2(${Eh(c, u, g)}));
+ getT${h}(${yh(i, u, g)}),
+ vec2(${yh(c, u, g)}));
}`;
}
- let f = p.length, d = p[p.length - 1];
+ let d = p.length, f = p[p.length - 1];
m += `
return getChannel(
- getT${f}(${Eh(i, u, d)}),
- vec2(${Eh(c, u, d)}));`, this.userCode = `
+ getT${d}(${yh(i, u, f)}),
+ vec2(${yh(c, u, f)}));`, this.userCode = `
float getValue(${i.map((h) => "int " + h)}) {
${m}
}
@@ -19761,68 +19822,73 @@ var $h = class {
`;
}
};
-function Eh(r, e, t10) {
+function yh(r, e, t6) {
let o = r.indexOf(e);
- return r.map((s, a) => a === o ? `${s} - ${t10}` : s).join();
+ return r.map((s, a) => a === o ? `${s} - ${t6}` : s).join();
}
-function Lu(r) {
- let { inputs: e, backend: t10 } = r, { input: o } = e, n = t10.texData.get(o.dataId);
- return Rt({ inputs: { x: n.complexTensorInfos.imag }, backend: t10 });
+function Mu(r) {
+ let { inputs: e, backend: t6 } = r, { input: o } = e, n = t6.texData.get(o.dataId);
+ return At({ inputs: { x: n.complexTensorInfos.imag }, backend: t6 });
}
-var sA = { kernelName: Ya, backendName: "webgl", kernelFunc: Lu };
-function yc(r, e, t10) {
+var DA = { kernelName: si, backendName: "webgl", kernelFunc: Mu };
+function fc(r, e, t6) {
let o = r[0].dtype;
if (o === "complex64") {
- let l = r.map((g) => La({ inputs: { input: g }, backend: t10 })), m = r.map((g) => Lu({ inputs: { input: g }, backend: t10 })), f = yc(l, e, t10), d = yc(m, e, t10), h = Ar({ inputs: { real: f, imag: d }, backend: t10 });
- return l.forEach((g) => t10.disposeIntermediateTensorInfo(g)), m.forEach((g) => t10.disposeIntermediateTensorInfo(g)), t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(d), h;
+ let d = r.map((b) => Ua({ inputs: { input: b }, backend: t6 })), f = r.map((b) => Mu({ inputs: { input: b }, backend: t6 })), h = fc(d, e, t6), g = fc(f, e, t6), x = Rr({ inputs: { real: h, imag: g }, backend: t6 });
+ return d.forEach((b) => t6.disposeIntermediateTensorInfo(b)), f.forEach((b) => t6.disposeIntermediateTensorInfo(b)), t6.disposeIntermediateTensorInfo(h), t6.disposeIntermediateTensorInfo(g), x;
}
- let n = t10.shouldExecuteOnCPU(r);
+ let n = t6.shouldExecuteOnCPU(r);
if (o === "string" && (n = true), n) {
- let l = r.map((b) => {
- let w = [-1, x.sizeFromShape(b.shape.slice(e))];
- return J({ inputs: { x: b }, backend: t10, attrs: { shape: w } });
- }), m = l.map((b) => ({ vals: t10.readSync(b.dataId), shape: b.shape })), f = I.computeOutShape(l.map((b) => b.shape), 1), d = l[0].shape[0] === 1, h = p$(m, f, o, d), g = I.computeOutShape(r.map((b) => b.shape), e), y = t10.makeTensorInfo(g, o, h);
- return l.forEach((b) => t10.disposeIntermediateTensorInfo(b)), y;
+ let d = r.map((w) => {
+ let _ = [-1, y.sizeFromShape(w.shape.slice(e))];
+ return te({ inputs: { x: w }, backend: t6, attrs: { shape: _ } });
+ }), f = d.map((w) => ({ vals: t6.readSync(w.dataId), shape: w.shape })), h = S.computeOutShape(d.map((w) => w.shape), 1), g = d[0].shape[0] === 1, x = LE(f, h, o, g), b = S.computeOutShape(r.map((w) => w.shape), e), C = t6.makeTensorInfo(b, o, x);
+ return d.forEach((w) => t6.disposeIntermediateTensorInfo(w)), C;
}
- let s = P().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");
- if (r.length > s) {
- let l = [];
- for (let f = 0; f < r.length; f += s) {
- let d = r.slice(f, f + s);
- l.push(yc(d, e, t10));
+ let s = r.filter((d) => y.sizeFromShape(d.shape) > 0), a = O().getBool("WEBGL_PACK_ARRAY_OPERATIONS") && s[0].shape.length > 1;
+ if (s.length === 1) {
+ let d = a ? new Jt(r[0].shape, Qs) : new Ar(r[0].shape, Qs);
+ return t6.runWebGLProgram(d, r, o);
+ }
+ let i = O().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");
+ if (s.length > i) {
+ let d = [];
+ for (let h = 0; h < s.length; h += i) {
+ let g = s.slice(h, h + i);
+ d.push(fc(g, e, t6));
}
- let m = yc(l, e, t10);
- for (let f of l)
- t10.disposeIntermediateTensorInfo(f);
- return m;
+ let f = fc(d, e, t6);
+ for (let h of d)
+ t6.disposeIntermediateTensorInfo(h);
+ return f;
}
- if (P().getBool("WEBGL_PACK_ARRAY_OPERATIONS") && r[0].shape.length > 1) {
- let l = new $h(r.map((m) => m.shape), e);
- return t10.runWebGLProgram(l, r, o);
+ if (a) {
+ let d = new bh(s.map((f) => f.shape), e);
+ return t6.runWebGLProgram(d, s, o);
}
- let { tensors2D: a, outShape: i } = aQ(r, e, t10), p = new _h(a.map((l) => l.shape)), u = t10.runWebGLProgram(p, a, o);
- a.forEach((l) => t10.disposeIntermediateTensorInfo(l));
- let c = J({ inputs: { x: u }, attrs: { shape: i }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(u), c;
+ let { tensors2D: p, outShape: u } = _Y(s, e, t6), c = new xh(p.map((d) => d.shape)), l = t6.runWebGLProgram(c, p, o);
+ p.forEach((d) => t6.disposeIntermediateTensorInfo(d));
+ let m = te({ inputs: { x: l }, attrs: { shape: u }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(l), m;
}
-function aQ(r, e, t10) {
- let o = I.computeOutShape(r.map((s) => s.shape), e);
- return { tensors2D: r.map((s) => J({ inputs: { x: s }, attrs: { shape: [-1, x.sizeFromShape(s.shape.slice(e))] }, backend: t10 })), outShape: o };
+function _Y(r, e, t6) {
+ let o = S.computeOutShape(r.map((s) => s.shape), e);
+ return { tensors2D: r.map((s) => te({ inputs: { x: s }, attrs: { shape: [-1, y.sizeFromShape(s.shape.slice(e))] }, backend: t6 })), outShape: o };
}
-function Pw(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { axis: n } = o, s = x.parseAxisParam(n, e[0].shape)[0], a = e.map((u) => u.shape);
- I.assertParamsConsistent(a, s);
- let i = I.computeOutShape(e.map((u) => u.shape), s);
- if (x.sizeFromShape(i) === 0)
- return t10.makeTensorInfo(i, e[0].dtype, []);
- let p = e.filter((u) => x.sizeFromShape(u.shape) > 0);
- return p.length === 1 ? Rt({ inputs: { x: p[0] }, backend: t10 }) : yc(p, s, t10);
+function $w(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { axis: n } = o, s = y.parseAxisParam(n, e[0].shape)[0], a = e.map((u) => u.shape);
+ S.assertParamsConsistent(a, s);
+ let i = S.computeOutShape(e.map((u) => u.shape), s);
+ if (y.sizeFromShape(i) === 0)
+ return t6.makeTensorInfo(i, e[0].dtype, []);
+ let p = e.filter((u) => y.sizeFromShape(u.shape) > 0);
+ return p.length === 1 ? At({ inputs: { x: p[0] }, backend: t6 }) : fc(p, s, t6);
}
-var aA = { kernelName: gs, backendName: "webgl", kernelFunc: Pw };
-var bc = class {
- constructor(e, t10 = false, o = null, n = false, s = false) {
+var OA = { kernelName: ys, backendName: "webgl", kernelFunc: $w };
+var hc = class {
+ constructor(e, t6 = false, o = null, n = false, s = false) {
this.variableNames = ["x", "W"], this.outputShape = e.outShape;
- let a = e.padInfo.top, i = e.padInfo.left, p = e.strideHeight, u = e.strideWidth, c = e.dilationHeight, l = e.dilationWidth, m = e.filterHeight, f = e.filterWidth, d = Math.floor(e.inChannels / 4) * 4, h = e.inChannels % 4, g = e.dataFormat === "channelsLast", y = g ? 1 : 2, b = g ? 2 : 3, C = g ? 3 : 1, w = "", k = "";
+ let a = e.padInfo.top, i = e.padInfo.left, p = e.strideHeight, u = e.strideWidth, c = e.dilationHeight, l = e.dilationWidth, m = e.filterHeight, d = e.filterWidth, f = Math.floor(e.inChannels / 4) * 4, h = e.inChannels % 4, g = e.dataFormat === "channelsLast", x = g ? 1 : 2, b = g ? 2 : 3, C = g ? 3 : 1, w = "", k = "";
o && (n ? w = `float activation(float a) {
float b = getPreluActivationWeightsAtOutCoords();
${o}
@@ -19834,8 +19900,8 @@ var bc = class {
${o}
}
`, k = "result = activation(result);");
- let _ = t10 ? "result += getBiasAtOutCoords();" : "";
- t10 && this.variableNames.push("bias"), n && this.variableNames.push("preluActivationWeights"), s && this.variableNames.push("leakyreluAlpha"), this.userCode = `
+ let _ = t6 ? "result += getBiasAtOutCoords();" : "";
+ t6 && this.variableNames.push("bias"), n && this.variableNames.push("preluActivationWeights"), s && this.variableNames.push("leakyreluAlpha"), this.userCode = `
${w}
const ivec2 strides = ivec2(${p}, ${u});
@@ -19847,7 +19913,7 @@ var bc = class {
int d2 = coords[${C}];
ivec2 xRCCorner =
- ivec2(coords[${y}], coords[${b}]) * strides - pads;
+ ivec2(coords[${x}], coords[${b}]) * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
@@ -19861,14 +19927,14 @@ var bc = class {
continue;
}
- for (int wC = 0; wC < ${f}; wC++) {
+ for (int wC = 0; wC < ${d}; wC++) {
int xC = xCCorner + wC * ${l};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
- for (int d1 = 0; d1 < ${d}; d1 += 4) {
+ for (int d1 = 0; d1 < ${f}; d1 += 4) {
vec4 wValues = vec4(
getW(wR, wC, d1, d2),
getW(wR, wC, d1 + 1, d2),
@@ -19899,53 +19965,53 @@ var bc = class {
if (${g}) {
dotProd +=
- getX(batch, xR, xC, ${d}) *
- getW(wR, wC, ${d}, d2);
+ getX(batch, xR, xC, ${f}) *
+ getW(wR, wC, ${f}, d2);
} else {
dotProd +=
- getX(batch, ${d}, xR, xC) *
- getW(wR, wC, ${d}, d2);
+ getX(batch, ${f}, xR, xC) *
+ getW(wR, wC, ${f}, d2);
}
} else if (${h === 2}) {
vec2 wValues = vec2(
- getW(wR, wC, ${d}, d2),
- getW(wR, wC, ${d} + 1, d2)
+ getW(wR, wC, ${f}, d2),
+ getW(wR, wC, ${f} + 1, d2)
);
if (${g}) {
vec2 xValues = vec2(
- getX(batch, xR, xC, ${d}),
- getX(batch, xR, xC, ${d} + 1)
+ getX(batch, xR, xC, ${f}),
+ getX(batch, xR, xC, ${f} + 1)
);
dotProd += dot(xValues, wValues);
} else {
vec2 xValues = vec2(
- getX(batch, ${d}, xR, xC),
- getX(batch, ${d} + 1, xR, xC)
+ getX(batch, ${f}, xR, xC),
+ getX(batch, ${f} + 1, xR, xC)
);
dotProd += dot(xValues, wValues);
}
} else if (${h === 3}) {
vec3 wValues = vec3(
- getW(wR, wC, ${d}, d2),
- getW(wR, wC, ${d} + 1, d2),
- getW(wR, wC, ${d} + 2, d2)
+ getW(wR, wC, ${f}, d2),
+ getW(wR, wC, ${f} + 1, d2),
+ getW(wR, wC, ${f} + 2, d2)
);
if (${g}) {
vec3 xValues = vec3(
- getX(batch, xR, xC, ${d}),
- getX(batch, xR, xC, ${d} + 1),
- getX(batch, xR, xC, ${d} + 2)
+ getX(batch, xR, xC, ${f}),
+ getX(batch, xR, xC, ${f} + 1),
+ getX(batch, xR, xC, ${f} + 2)
);
dotProd += dot(xValues, wValues);
} else {
vec3 xValues = vec3(
- getX(batch, ${d}, xR, xC),
- getX(batch, ${d} + 1, xR, xC),
- getX(batch, ${d} + 2, xR, xC)
+ getX(batch, ${f}, xR, xC),
+ getX(batch, ${f} + 1, xR, xC),
+ getX(batch, ${f} + 2, xR, xC)
);
dotProd += dot(xValues, wValues);
}
@@ -19962,13 +20028,13 @@ var bc = class {
`;
}
};
-var Rh = class {
+var Ch = class {
constructor(e) {
this.variableNames = ["x", "W"], this.outputShape = e.outShape;
- let t10 = e.padInfo.front, o = e.padInfo.top, n = e.padInfo.left, s = e.strideDepth, a = e.strideHeight, i = e.strideWidth, p = e.dilationDepth, u = e.dilationHeight, c = e.dilationWidth, l = e.filterDepth, m = e.filterHeight, f = e.filterWidth, d = Math.floor(e.inChannels / 4) * 4, h = e.inChannels % 4;
+ let t6 = e.padInfo.front, o = e.padInfo.top, n = e.padInfo.left, s = e.strideDepth, a = e.strideHeight, i = e.strideWidth, p = e.dilationDepth, u = e.dilationHeight, c = e.dilationWidth, l = e.filterDepth, m = e.filterHeight, d = e.filterWidth, f = Math.floor(e.inChannels / 4) * 4, h = e.inChannels % 4;
this.userCode = `
const ivec3 strides = ivec3(${s}, ${a}, ${i});
- const ivec3 pads = ivec3(${t10}, ${o}, ${n});
+ const ivec3 pads = ivec3(${t6}, ${o}, ${n});
void main() {
ivec5 coords = getOutputCoords();
@@ -19998,14 +20064,14 @@ var Rh = class {
continue;
}
- for (int wC = 0; wC < ${f}; wC++) {
+ for (int wC = 0; wC < ${d}; wC++) {
int xC = xCCorner + wC * ${c};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
- for (int d1 = 0; d1 < ${d}; d1 += 4) {
+ for (int d1 = 0; d1 < ${f}; d1 += 4) {
vec4 xValues = vec4(
getX(batch, xF, xR, xC, d1),
getX(batch, xF, xR, xC, d1 + 1),
@@ -20024,28 +20090,28 @@ var Rh = class {
if (${h === 1}) {
dotProd +=
- getX(batch, xF, xR, xC, ${d}) *
- getW(wF, wR, wC, ${d}, d2);
+ getX(batch, xF, xR, xC, ${f}) *
+ getW(wF, wR, wC, ${f}, d2);
} else if (${h === 2}) {
vec2 xValues = vec2(
- getX(batch, xF, xR, xC, ${d}),
- getX(batch, xF, xR, xC, ${d} + 1)
+ getX(batch, xF, xR, xC, ${f}),
+ getX(batch, xF, xR, xC, ${f} + 1)
);
vec2 wValues = vec2(
- getW(wF, wR, wC, ${d}, d2),
- getW(wF, wR, wC, ${d} + 1, d2)
+ getW(wF, wR, wC, ${f}, d2),
+ getW(wF, wR, wC, ${f} + 1, d2)
);
dotProd += dot(xValues, wValues);
} else if (${h === 3}) {
vec3 xValues = vec3(
- getX(batch, xF, xR, xC, ${d}),
- getX(batch, xF, xR, xC, ${d} + 1),
- getX(batch, xF, xR, xC, ${d} + 2)
+ getX(batch, xF, xR, xC, ${f}),
+ getX(batch, xF, xR, xC, ${f} + 1),
+ getX(batch, xF, xR, xC, ${f} + 2)
);
vec3 wValues = vec3(
- getW(wF, wR, wC, ${d}, d2),
- getW(wF, wR, wC, ${d} + 1, d2),
- getW(wF, wR, wC, ${d} + 2, d2)
+ getW(wF, wR, wC, ${f}, d2),
+ getW(wF, wR, wC, ${f} + 1, d2),
+ getW(wF, wR, wC, ${f} + 2, d2)
);
dotProd += dot(xValues, wValues);
}
@@ -20057,9 +20123,9 @@ var Rh = class {
`;
}
};
-var Cc = class {
- constructor(e, t10 = false, o = null, n = false, s = false) {
- this.variableNames = ["x", "W"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = lt(this.outputShape.length);
+var gc = class {
+ constructor(e, t6 = false, o = null, n = false, s = false) {
+ this.variableNames = ["x", "W"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = ct(this.outputShape.length);
let a = e.padInfo.left, i = e.strideWidth, p = e.dilationWidth, u = e.filterHeight, c = e.filterWidth, l = c, m = `
int xR; int xC; int xCOffset;
vec4 wTexel; vec4 previous; vec4 final;`;
@@ -20086,24 +20152,24 @@ var Cc = class {
if (xR >=0 && xR < inDims[0]) {
`;
for (let g = 0; g < (l + 1) / 2; g++) {
- let y = g * 2;
+ let x = g * 2;
if (m += `
- xC = xCCorner + ${y * p};
+ xC = xCCorner + ${x * p};
`, i === 1) {
- if (y < c && (a % 2 === 1 ? (m += `
+ if (x < c && (a % 2 === 1 ? (m += `
xCOffset = xC + 1;
- if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
- xTexelC${y} = getX(batch, xR, xCOffset, d1);
+ if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x}Ready == 0) {
+ xTexelC${x} = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
- xTexelC${y}.zw = vec2(0.0);
+ xTexelC${x}.zw = vec2(0.0);
}
- xTexelC${y}Ready = 1;
+ xTexelC${x}Ready = 1;
}
- `, p === 1 && y > 0 ? m += `
- xC${y} = vec4(xTexelC${y - 2}.zw, xTexelC${y}.xy);
+ `, p === 1 && x > 0 ? m += `
+ xC${x} = vec4(xTexelC${x - 2}.zw, xTexelC${x}.xy);
` : m += `
xCOffset = xC + 1 - 2;
@@ -20116,126 +20182,126 @@ var Cc = class {
previous.zw = vec2(0.0);
}
- xC${y} = vec4(previous.zw, xTexelC${y}.xy);
+ xC${x} = vec4(previous.zw, xTexelC${x}.xy);
} else {
- xC${y} = vec4(0.0, 0.0, xTexelC${y}.xy);
+ xC${x} = vec4(0.0, 0.0, xTexelC${x}.xy);
}
`) : m += `
- if (xC >= 0 && xC < inDims[1] && xTexelC${y}Ready == 0) {
- xTexelC${y} = getX(batch, xR, xC, d1);
+ if (xC >= 0 && xC < inDims[1] && xTexelC${x}Ready == 0) {
+ xTexelC${x} = getX(batch, xR, xC, d1);
if (xC + 1 >= inDims[1]) {
- xTexelC${y}.zw = vec2(0.0);
+ xTexelC${x}.zw = vec2(0.0);
}
- xTexelC${y}Ready = 1;
+ xTexelC${x}Ready = 1;
}
- xC${y} = xTexelC${y};
- `, y + 1 < c)) {
- let b = a % 2 === 0 ? x.nearestLargerEven(p) : p;
+ xC${x} = xTexelC${x};
+ `, x + 1 < c)) {
+ let b = a % 2 === 0 ? y.nearestLargerEven(p) : p;
p % 2 === 0 && a % 2 === 1 || p % 2 !== 0 && a % 2 !== 1 ? (m += `
xCOffset = xC + imod(pads[1], 2) + ${b};
- if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y + 1}Ready == 0) {
- xTexelC${y + 1} = getX(batch, xR, xCOffset, d1);
+ if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x + 1}Ready == 0) {
+ xTexelC${x + 1} = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
- xTexelC${y + 1}.zw = vec2(0.0);
+ xTexelC${x + 1}.zw = vec2(0.0);
}
- xTexelC${y + 1}Ready = 1;
+ xTexelC${x + 1}Ready = 1;
}
`, p > 1 ? m += `
xCOffset -= 2;
if (xCOffset >= 0 && xCOffset < inDims[1]) {
previous = getX(batch, xR, xCOffset, d1);
- xC${y + 1} = vec4(previous.zw, xTexelC${y + 1}.xy);
+ xC${x + 1} = vec4(previous.zw, xTexelC${x + 1}.xy);
} else {
- xC${y + 1} = vec4(0.0, 0.0, xTexelC${y + 1}.xy);
+ xC${x + 1} = vec4(0.0, 0.0, xTexelC${x + 1}.xy);
}
` : m += `
- xC${y + 1} = vec4(xTexelC${y}.zw, xTexelC${y + 1}.xy);
+ xC${x + 1} = vec4(xTexelC${x}.zw, xTexelC${x + 1}.xy);
`) : b === 1 ? m += `
- xC${y + 1} = xTexelC${y};
+ xC${x + 1} = xTexelC${x};
` : m += `
xCOffset = xC + ${b};
- if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y + 1}Ready == 0) {
- xTexelC${y + 1} = getX(batch, xR, xCOffset, d1);
+ if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x + 1}Ready == 0) {
+ xTexelC${x + 1} = getX(batch, xR, xCOffset, d1);
if (xCOffset + 1 >= inDims[1]) {
- xTexelC${y + 1}.zw = vec2(0.0);
+ xTexelC${x + 1}.zw = vec2(0.0);
}
- xTexelC${y + 1}Ready = 1;
+ xTexelC${x + 1}Ready = 1;
}
- xC${y + 1} = xTexelC${y + 1};
+ xC${x + 1} = xTexelC${x + 1};
`;
}
} else
- y < c && (a % 2 === 1 ? (m += `
+ x < c && (a % 2 === 1 ? (m += `
xCOffset = xC + 1 - strides[1];
- if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
- xTexelC${y} = getX(batch, xR, xCOffset, d1);
+ if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x}Ready == 0) {
+ xTexelC${x} = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
- xTexelC${y}.zw = vec2(0.0);
+ xTexelC${x}.zw = vec2(0.0);
}
- xTexelC${y}Ready = 1;
+ xTexelC${x}Ready = 1;
}
- if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${y + 1}Ready == 0) {
- xTexelC${y + 1} = getX(batch, xR, xC + 1, d1);
+ if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${x + 1}Ready == 0) {
+ xTexelC${x + 1} = getX(batch, xR, xC + 1, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xC + 2 >= inDims[1]) {
- xTexelC${y + 1}.zw = vec2(0.0);
+ xTexelC${x + 1}.zw = vec2(0.0);
}
- xTexelC${y + 1}Ready = 1;
+ xTexelC${x + 1}Ready = 1;
}
- xC${y} = vec4(xTexelC${y}.zw, xTexelC${y + 1}.zw);
- `, y + 1 < c && (m += `
+ xC${x} = vec4(xTexelC${x}.zw, xTexelC${x + 1}.zw);
+ `, x + 1 < c && (m += `
final = vec4(0.0);
xCOffset = xC + 1 + strides[1];
if(xCOffset >= 0 && xCOffset < inDims[1]) {
final = getX(batch, xR, xCOffset, d1);
}
- xC${y + 1} = vec4(xTexelC${y + 1}.xy, final.xy);
+ xC${x + 1} = vec4(xTexelC${x + 1}.xy, final.xy);
`)) : (m += `
- if(xC >= 0 && xC < inDims[1] && xTexelC${y}Ready == 0) {
- xTexelC${y} = getX(batch, xR, xC, d1);
+ if(xC >= 0 && xC < inDims[1] && xTexelC${x}Ready == 0) {
+ xTexelC${x} = getX(batch, xR, xC, d1);
if (xC + 1 >= inDims[1]) {
- xTexelC${y}.zw = vec2(0.0);
+ xTexelC${x}.zw = vec2(0.0);
}
- xTexelC${y}Ready = 1;
+ xTexelC${x}Ready = 1;
}
xCOffset = xC + strides[1];
- if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y + 1}Ready == 0) {
- xTexelC${y + 1} = getX(batch, xR, xCOffset, d1);
+ if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x + 1}Ready == 0) {
+ xTexelC${x + 1} = getX(batch, xR, xCOffset, d1);
if (xCOffset + 1 >= inDims[1]) {
- xTexelC${y + 1}.zw = vec2(0.);
+ xTexelC${x + 1}.zw = vec2(0.);
}
- xTexelC${y + 1}Ready = 1;
+ xTexelC${x + 1}Ready = 1;
}
- xC${y} = vec4(
- xTexelC${y}.xy, xTexelC${y + 1}.xy);
- `, y + 1 < c && (m += `
- xC${y + 1} = vec4(xTexelC${y}.zw, xTexelC${y + 1}.zw);
+ xC${x} = vec4(
+ xTexelC${x}.xy, xTexelC${x + 1}.xy);
+ `, x + 1 < c && (m += `
+ xC${x + 1} = vec4(xTexelC${x}.zw, xTexelC${x + 1}.zw);
`)));
- y < c && (m += `
- wTexel = getW(r, ${y}, d1, d2);
- dotProd += xC${y}.xxzz * vec4(wTexel.xy, wTexel.xy);
+ x < c && (m += `
+ wTexel = getW(r, ${x}, d1, d2);
+ dotProd += xC${x}.xxzz * vec4(wTexel.xy, wTexel.xy);
if(d1 + 1 < ${e.inChannels}) {
- dotProd += xC${y}.yyww * vec4(wTexel.zw, wTexel.zw);
+ dotProd += xC${x}.yyww * vec4(wTexel.zw, wTexel.zw);
}
- `, y + 1 < c && (m += `
- wTexel = getW(r, ${y + 1}, d1, d2);
- dotProd += xC${y + 1}.xxzz * vec4(wTexel.xy, wTexel.xy);
+ `, x + 1 < c && (m += `
+ wTexel = getW(r, ${x + 1}, d1, d2);
+ dotProd += xC${x + 1}.xxzz * vec4(wTexel.xy, wTexel.xy);
if(d1 + 1 < ${e.inChannels}) {
- dotProd += xC${y + 1}.yyww * vec4(wTexel.zw, wTexel.zw);
+ dotProd += xC${x + 1}.yyww * vec4(wTexel.zw, wTexel.zw);
}
`));
}
@@ -20246,19 +20312,19 @@ var Cc = class {
`, m += `
}
`;
- let f = "", d = "";
- o && (n ? f = `vec4 activation(vec4 a) {
+ let d = "", f = "";
+ o && (n ? d = `vec4 activation(vec4 a) {
vec4 b = getPreluActivationWeightsAtOutCoords();
${o}
- }` : s ? f = `vec4 activation(vec4 a) {
+ }` : s ? d = `vec4 activation(vec4 a) {
vec4 b = getLeakyreluAlphaAtOutCoords();
${o}
- }` : f = `vec4 activation(vec4 x) {
+ }` : d = `vec4 activation(vec4 x) {
${o}
- }`, d = "result = activation(result);");
- let h = t10 ? "result += getBiasAtOutCoords();" : "";
- t10 && this.variableNames.push("bias"), n && this.variableNames.push("preluActivationWeights"), s && this.variableNames.push("leakyreluAlpha"), this.userCode = `
- ${f}
+ }`, f = "result = activation(result);");
+ let h = t6 ? "result += getBiasAtOutCoords();" : "";
+ t6 && this.variableNames.push("bias"), n && this.variableNames.push("preluActivationWeights"), s && this.variableNames.push("leakyreluAlpha"), this.userCode = `
+ ${d}
void main() {
ivec4 coords = getOutputCoords();
@@ -20275,16 +20341,16 @@ var Cc = class {
vec4 result = dotProd - vec4(0.000000000000001);
${h}
- ${d}
+ ${f}
setOutput(result);
}
`;
}
};
-var Ah = class {
- constructor(e, t10) {
- this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "inputShape", type: "ivec4" }, { name: "pad", type: "ivec2" }, { name: "stride", type: "ivec2" }, { name: "dilation", type: "ivec2" }, { name: "inChannels", type: "int" }, { name: "itemsPerBlockRow", type: "int" }, { name: "outWidth", type: "int" }], this.outputShape = e, this.enableShapeUniforms = lt(this.outputShape.length);
- let { dataFormat: o } = t10, n = Ct(), s = o === "channelsLast", a = s ? 1 : 2, i = s ? 2 : 3, p = this.enableShapeUniforms ? "if(blockIndex < outShape[2] && pos < outShape[1]) {" : `if(blockIndex < ${e[2]} && pos < ${e[1]}) {`, u = "";
+var Sh = class {
+ constructor(e, t6) {
+ this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "inputShape", type: "ivec4" }, { name: "pad", type: "ivec2" }, { name: "stride", type: "ivec2" }, { name: "dilation", type: "ivec2" }, { name: "inChannels", type: "int" }, { name: "itemsPerBlockRow", type: "int" }, { name: "outWidth", type: "int" }], this.outputShape = e, this.enableShapeUniforms = ct(this.outputShape.length);
+ let { dataFormat: o } = t6, n = St(), s = o === "channelsLast", a = s ? 1 : 2, i = s ? 2 : 3, p = this.enableShapeUniforms ? "if(blockIndex < outShape[2] && pos < outShape[1]) {" : `if(blockIndex < ${e[2]} && pos < ${e[1]}) {`, u = "";
for (let c = 0; c <= 1; c++)
for (let l = 0; l <= 1; l++)
u += `
@@ -20338,81 +20404,81 @@ var Ah = class {
`;
}
};
-function Fh(r, e) {
- let t10 = r.length;
- return t10 >= 3 ? e ? [...r.slice(0, -3), r[t10 - 3] * r[t10 - 2], r[t10 - 1]] : [...r.slice(0, -3), r[t10 - 3], r[t10 - 2] * r[t10 - 1]] : !e && t10 === 1 && r[0] > 1 ? [r[0], 1] : null;
+function wh(r, e) {
+ let t6 = r.length;
+ return t6 >= 3 ? e ? [...r.slice(0, -3), r[t6 - 3] * r[t6 - 2], r[t6 - 1]] : [...r.slice(0, -3), r[t6 - 3], r[t6 - 2] * r[t6 - 1]] : !e && t6 === 1 && r[0] > 1 ? [r[0], 1] : null;
}
-function Dh({ x: r, filter: e, convInfo: t10, backend: o, bias: n = null, preluActivationWeights: s = null, leakyreluAlpha: a = 0, activation: i = null }) {
- let p = r.shape, u = o.texData.get(r.dataId), c = t10.inChannels, l = p[0] * p[1] * p[2], m = t10.outChannels, f = t10.dataFormat === "channelsLast", d = false, h = false, g, y = [];
+function Ih({ x: r, filter: e, convInfo: t6, backend: o, bias: n = null, preluActivationWeights: s = null, leakyreluAlpha: a = 0, activation: i = null }) {
+ let p = r.shape, u = o.texData.get(r.dataId), c = t6.inChannels, l = p[0] * p[1] * p[2], m = t6.outChannels, d = t6.dataFormat === "channelsLast", f = false, h = false, g, x = [];
if (s != null) {
- let w = Fh(s.shape, f);
- w != null && (s = J({ inputs: { x: s }, backend: o, attrs: { shape: w } }), y.push(s));
+ let w = wh(s.shape, d);
+ w != null && (s = te({ inputs: { x: s }, backend: o, attrs: { shape: w } }), x.push(s));
}
if (n != null) {
- let w = Fh(n.shape, f);
- w != null && (n = J({ inputs: { x: n }, backend: o, attrs: { shape: w } }), y.push(n));
+ let w = wh(n.shape, d);
+ w != null && (n = te({ inputs: { x: n }, backend: o, attrs: { shape: w } }), x.push(n));
}
- if (!((l === 1 || m === 1) && c > Rw) && u.isPacked && f && u.texture != null && p[2] % 2 !== 0 && x.arraysEqual(u.shape.slice(-3), p.slice(-3))) {
- let w = p[0] * p[1] * (p[2] + 1), k = { dataId: r.dataId, shape: [1, w, t10.inChannels], dtype: r.dtype }, _ = u.shape;
- u.shape = u.shape.slice(), u.shape[u.shape.length - 2]++, x.assert(Ti(u.shape, k.shape), () => `packed reshape ${u.shape} to ${k.shape} isn't free`);
- let E = J({ inputs: { x: e }, backend: o, attrs: { shape: [1, t10.inChannels, t10.outChannels] } });
- y.push(E);
- let R = Mu({ a: k, b: E, backend: o, transposeA: d, transposeB: h, bias: n, activation: i, preluActivationWeights: s, leakyreluAlpha: a }), A = o.texData.get(R.dataId);
- x.assert(A.isPacked, () => "batchMatMul result is expected to be packed"), u.shape = _, A.shape = t10.outShape, g = Rt({ inputs: { x: R }, backend: o }), g.shape = t10.outShape, y.push(R);
+ if (!((l === 1 || m === 1) && c > Nw) && u.isPacked && d && u.texture != null && p[2] % 2 !== 0 && y.arraysEqual(u.shape.slice(-3), p.slice(-3))) {
+ let w = p[0] * p[1] * (p[2] + 1), k = { dataId: r.dataId, shape: [1, w, t6.inChannels], dtype: r.dtype }, _ = u.shape;
+ u.shape = u.shape.slice(), u.shape[u.shape.length - 2]++, y.assert(Li(u.shape, k.shape), () => `packed reshape ${u.shape} to ${k.shape} isn't free`);
+ let $ = te({ inputs: { x: e }, backend: o, attrs: { shape: [1, t6.inChannels, t6.outChannels] } });
+ x.push($);
+ let A = Pu({ a: k, b: $, backend: o, transposeA: f, transposeB: h, bias: n, activation: i, preluActivationWeights: s, leakyreluAlpha: a }), R = o.texData.get(A.dataId);
+ y.assert(R.isPacked, () => "batchMatMul result is expected to be packed"), u.shape = _, R.shape = t6.outShape, g = At({ inputs: { x: A }, backend: o }), g.shape = t6.outShape, x.push(A);
} else {
- let w = t10.outHeight * t10.outWidth, k = J({ inputs: { x: r }, backend: o, attrs: { shape: f ? [t10.batchSize, w, t10.inChannels] : [t10.batchSize, t10.inChannels, w] } }), _ = J({ inputs: { x: e }, backend: o, attrs: { shape: [1, t10.inChannels, t10.outChannels] } }), E = Mu({ a: f ? k : _, b: f ? _ : k, transposeA: !f, transposeB: h, backend: o, bias: n, activation: i, preluActivationWeights: s, leakyreluAlpha: a });
- g = J({ inputs: { x: E }, backend: o, attrs: { shape: t10.outShape } }), y.push(k), y.push(_), y.push(E);
+ let w = t6.outHeight * t6.outWidth, k = te({ inputs: { x: r }, backend: o, attrs: { shape: d ? [t6.batchSize, w, t6.inChannels] : [t6.batchSize, t6.inChannels, w] } }), _ = te({ inputs: { x: e }, backend: o, attrs: { shape: [1, t6.inChannels, t6.outChannels] } }), $ = Pu({ a: d ? k : _, b: d ? _ : k, transposeA: !d, transposeB: h, backend: o, bias: n, activation: i, preluActivationWeights: s, leakyreluAlpha: a });
+ g = te({ inputs: { x: $ }, backend: o, attrs: { shape: t6.outShape } }), x.push(k), x.push(_), x.push($);
}
- for (let w of y)
+ for (let w of x)
o.disposeIntermediateTensorInfo(w);
return g;
}
-function Ph({ x: r, filter: e, convInfo: t10, backend: o, bias: n = null, preluActivationWeights: s = null, leakyreluAlpha: a = 0, activation: i = null }) {
- let { filterWidth: p, filterHeight: u, inChannels: c, outWidth: l, outHeight: m, dataFormat: f } = t10, d = f === "channelsLast", h = p * u * c, g = m * l, y = [t10.batchSize, h, g], b = true, C = false, w = [];
+function vh({ x: r, filter: e, convInfo: t6, backend: o, bias: n = null, preluActivationWeights: s = null, leakyreluAlpha: a = 0, activation: i = null }) {
+ let { filterWidth: p, filterHeight: u, inChannels: c, outWidth: l, outHeight: m, dataFormat: d } = t6, f = d === "channelsLast", h = p * u * c, g = m * l, x = [t6.batchSize, h, g], b = true, C = false, w = [];
if (s != null) {
- let H = Fh(s.shape, d);
- H != null && (s = J({ inputs: { x: s }, backend: o, attrs: { shape: H } }), w.push(s));
+ let H = wh(s.shape, f);
+ H != null && (s = te({ inputs: { x: s }, backend: o, attrs: { shape: H } }), w.push(s));
}
if (n != null) {
- let H = Fh(n.shape, d);
- H != null && (n = J({ inputs: { x: n }, backend: o, attrs: { shape: H } }), w.push(n));
+ let H = wh(n.shape, f);
+ H != null && (n = te({ inputs: { x: n }, backend: o, attrs: { shape: H } }), w.push(n));
}
- let k = J({ inputs: { x: e }, backend: o, attrs: { shape: [1, h, x.sizeFromShape(e.shape) / h] } });
+ let k = te({ inputs: { x: e }, backend: o, attrs: { shape: [1, h, y.sizeFromShape(e.shape) / h] } });
w.push(k);
- let _ = new Ah(y, t10), E = [r.shape, [t10.padInfo.top, t10.padInfo.left], [t10.strideHeight, t10.strideWidth], [t10.dilationHeight, t10.dilationWidth], [t10.inChannels], [t10.filterWidth * t10.inChannels], [t10.outWidth]], R = o.runWebGLProgram(_, [r], "float32", E), A = J({ inputs: { x: R }, backend: o, attrs: { shape: y } });
- w.push(R), w.push(A);
- let D = n != null, O = s != null, M = i === "leakyrelu", L = i ? Ma(i, true) : null, W = new xc(d ? A.shape : k.shape, d ? k.shape : A.shape, d ? [t10.batchSize, g, t10.outChannels] : [t10.batchSize, t10.outChannels, g], b, C, D, L, O, M), V = d ? [A, k] : [k, A];
- if (n && V.push(n), O && V.push(s), M) {
- let H = o.makeTensorInfo([], "float32", x.createScalarValue(a, "float32"));
+ let _ = new Sh(x, t6), $ = [r.shape, [t6.padInfo.top, t6.padInfo.left], [t6.strideHeight, t6.strideWidth], [t6.dilationHeight, t6.dilationWidth], [t6.inChannels], [t6.filterWidth * t6.inChannels], [t6.outWidth]], A = o.runWebGLProgram(_, [r], "float32", $), R = te({ inputs: { x: A }, backend: o, attrs: { shape: x } });
+ w.push(A), w.push(R);
+ let D = n != null, P = s != null, M = i === "leakyrelu", L = i ? Wa(i, true) : null, W = new dc(f ? R.shape : k.shape, f ? k.shape : R.shape, f ? [t6.batchSize, g, t6.outChannels] : [t6.batchSize, t6.outChannels, g], b, C, D, L, P, M), V = f ? [R, k] : [k, R];
+ if (n && V.push(n), P && V.push(s), M) {
+ let H = o.makeTensorInfo([], "float32", y.createScalarValue(a, "float32"));
V.push(H), w.push(H);
}
- let G = o.runWebGLProgram(W, V, "float32"), q = J({ inputs: { x: G }, backend: o, attrs: { shape: t10.outShape } });
- w.push(G);
+ let U = o.runWebGLProgram(W, V, "float32"), q = te({ inputs: { x: U }, backend: o, attrs: { shape: t6.outShape } });
+ w.push(U);
for (let H of w)
o.disposeIntermediateTensorInfo(H);
return q;
}
-function iQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dataFormat: p, dilations: u, dimRoundingMode: c } = o, l = I.convertConv2DDataFormat(p), m = I.computeConv2DInfo(n.shape, s.shape, a, u, i, c, false, l), f;
+function EY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dataFormat: p, dilations: u, dimRoundingMode: c } = o, l = S.convertConv2DDataFormat(p), m = S.computeConv2DInfo(n.shape, s.shape, a, u, i, c, false, l), d;
if (m.filterHeight === 1 && m.filterWidth === 1 && m.dilationHeight === 1 && m.dilationWidth === 1 && m.strideHeight === 1 && m.strideWidth === 1 && (m.padInfo.type === "SAME" || m.padInfo.type === "VALID"))
- f = Dh({ x: n, filter: s, convInfo: m, backend: t10 });
- else if (m.strideWidth <= 2 && l === "channelsLast" && P().getBool("WEBGL_EXP_CONV")) {
- let h = new Cc(m), g = [[m.padInfo.top, m.padInfo.left], [m.strideHeight, m.strideWidth], [m.dilationHeight, m.dilationWidth], [m.inHeight, m.inWidth]];
- f = t10.runWebGLProgram(h, [n, s], "float32", g);
- } else if (P().getBool("WEBGL_CONV_IM2COL"))
- f = Ph({ x: n, filter: s, convInfo: m, backend: t10 });
+ d = Ih({ x: n, filter: s, convInfo: m, backend: t6 });
+ else if (m.strideWidth <= 2 && l === "channelsLast" && O().getBool("WEBGL_EXP_CONV")) {
+ let h = new gc(m), g = [[m.padInfo.top, m.padInfo.left], [m.strideHeight, m.strideWidth], [m.dilationHeight, m.dilationWidth], [m.inHeight, m.inWidth]];
+ d = t6.runWebGLProgram(h, [n, s], "float32", g);
+ } else if (O().getBool("WEBGL_CONV_IM2COL"))
+ d = vh({ x: n, filter: s, convInfo: m, backend: t6 });
else {
- let h = new bc(m);
- f = t10.runWebGLProgram(h, [n, s], "float32");
+ let h = new hc(m);
+ d = t6.runWebGLProgram(h, [n, s], "float32");
}
- let d = J({ inputs: { x: f }, backend: t10, attrs: { shape: m.outShape } });
- return t10.disposeIntermediateTensorInfo(f), d;
+ let f = te({ inputs: { x: d }, backend: t6, attrs: { shape: m.outShape } });
+ return t6.disposeIntermediateTensorInfo(d), f;
}
-var iA = { kernelName: ln, backendName: "webgl", kernelFunc: iQ };
-var Oh = class {
+var PA = { kernelName: Go, backendName: "webgl", kernelFunc: EY };
+var kh = class {
constructor(e) {
this.variableNames = ["x", "dy"], this.outputShape = e.filterShape;
- let t10 = e.strideHeight, o = e.strideWidth, n = e.padInfo.top, s = e.padInfo.left, a = e.dataFormat === "channelsLast";
+ let t6 = e.strideHeight, o = e.strideWidth, n = e.padInfo.top, s = e.padInfo.left, a = e.dataFormat === "channelsLast";
this.userCode = `
void main() {
ivec4 coords = getOutputCoords();
@@ -20427,7 +20493,7 @@ var Oh = class {
for (int b = 0; b < ${e.batchSize}; b++) {
for (int yR = 0; yR < ${e.outHeight}; yR++) {
- int xR = wR + yR * ${t10} - ${n};
+ int xR = wR + yR * ${t6} - ${n};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
@@ -20458,10 +20524,10 @@ var Oh = class {
`;
}
};
-var Mh = class {
+var Nh = class {
constructor(e) {
this.variableNames = ["dy", "W"], this.outputShape = e.inShape;
- let t10 = e.filterHeight, o = e.filterWidth, n = e.strideHeight, s = e.strideWidth, a = e.dataFormat === "channelsLast", i = t10 - 1 - e.padInfo.top, p = o - 1 - e.padInfo.left, u = a ? 1 : 2, c = a ? 2 : 3, l = a ? 3 : 1;
+ let t6 = e.filterHeight, o = e.filterWidth, n = e.strideHeight, s = e.strideWidth, a = e.dataFormat === "channelsLast", i = t6 - 1 - e.padInfo.top, p = o - 1 - e.padInfo.left, u = a ? 1 : 2, c = a ? 2 : 3, l = a ? 3 : 1;
this.userCode = `
const ivec2 pads = ivec2(${i}, ${p});
@@ -20477,7 +20543,7 @@ var Mh = class {
// Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
- for (int wR = 0; wR < ${t10}; wR++) {
+ for (int wR = 0; wR < ${t6}; wR++) {
float dyR = float(dyRCorner + wR) / ${n}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
@@ -20485,7 +20551,7 @@ var Mh = class {
}
int idyR = int(dyR);
- int wRPerm = ${t10} - 1 - wR;
+ int wRPerm = ${t6} - 1 - wR;
for (int wC = 0; wC < ${o}; wC++) {
float dyC = float(dyCCorner + wC) / ${s}.0;
@@ -20518,10 +20584,10 @@ var Mh = class {
`;
}
};
-var Lh = class {
+var Th = class {
constructor(e) {
this.variableNames = ["x", "dy"], this.outputShape = e.filterShape;
- let t10 = e.strideDepth, o = e.strideHeight, n = e.strideWidth, s = e.padInfo.front, a = e.padInfo.top, i = e.padInfo.left;
+ let t6 = e.strideDepth, o = e.strideHeight, n = e.strideWidth, s = e.padInfo.front, a = e.padInfo.top, i = e.padInfo.left;
this.userCode = `
void main() {
ivec5 coords = getOutputCoords();
@@ -20535,7 +20601,7 @@ var Lh = class {
for (int b = 0; b < ${e.batchSize}; b++) {
for (int yF = 0; yF < ${e.outDepth}; yF++) {
- int xF = wF + yF * ${t10} - ${s};
+ int xF = wF + yF * ${t6} - ${s};
if (xF < 0 || xF >= ${e.inDepth}) {
continue;
@@ -20567,10 +20633,10 @@ var Lh = class {
`;
}
};
-var Bh = class {
+var _h = class {
constructor(e) {
this.variableNames = ["dy", "W"], this.outputShape = e.inShape;
- let t10 = e.filterDepth, o = e.filterHeight, n = e.filterWidth, s = e.strideDepth, a = e.strideHeight, i = e.strideWidth, p = t10 - 1 - e.padInfo.front, u = o - 1 - e.padInfo.top, c = n - 1 - e.padInfo.left;
+ let t6 = e.filterDepth, o = e.filterHeight, n = e.filterWidth, s = e.strideDepth, a = e.strideHeight, i = e.strideWidth, p = t6 - 1 - e.padInfo.front, u = o - 1 - e.padInfo.top, c = n - 1 - e.padInfo.left;
this.userCode = `
const ivec3 pads = ivec3(${p}, ${u}, ${c});
@@ -20586,7 +20652,7 @@ var Bh = class {
int dyCCorner = dyCorner.z;
float dotProd = 0.0;
- for (int wF = 0; wF < ${t10}; wF++) {
+ for (int wF = 0; wF < ${t6}; wF++) {
float dyF = float(dyFCorner + wF) / ${s}.0;
if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {
@@ -20594,7 +20660,7 @@ var Bh = class {
}
int idyF = int(dyF);
- int wFPerm = ${t10} - 1 - wF;
+ int wFPerm = ${t6} - 1 - wF;
for (int wR = 0; wR < ${o}; wR++) {
float dyR = float(dyRCorner + wR) / ${a}.0;
@@ -20631,48 +20697,48 @@ var Bh = class {
`;
}
};
-function uQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, dy: s } = e, { strides: a, pad: i, dataFormat: p, dimRoundingMode: u, filterShape: c } = o, l = I.convertConv2DDataFormat(p), m = I.computeConv2DInfo(n.shape, c, a, 1, i, u, false, l), f = new Oh(m);
- return t10.runWebGLProgram(f, [n, s], "float32");
+function $Y(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, dy: s } = e, { strides: a, pad: i, dataFormat: p, dimRoundingMode: u, filterShape: c } = o, l = S.convertConv2DDataFormat(p), m = S.computeConv2DInfo(n.shape, c, a, 1, i, u, false, l), d = new kh(m);
+ return t6.runWebGLProgram(d, [n, s], "float32");
}
-var uA = { kernelName: lp, backendName: "webgl", kernelFunc: uQ };
-function pQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, filter: s } = e, { inputShape: a, strides: i, pad: p, dataFormat: u, dimRoundingMode: c } = o, l = I.convertConv2DDataFormat(u), m = I.computeConv2DInfo(a, s.shape, i, 1, p, c, false, l), f = new Mh(m);
- return t10.runWebGLProgram(f, [n, s], "float32");
+var MA = { kernelName: cp, backendName: "webgl", kernelFunc: $Y };
+function AY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, filter: s } = e, { inputShape: a, strides: i, pad: p, dataFormat: u, dimRoundingMode: c } = o, l = S.convertConv2DDataFormat(u), m = S.computeConv2DInfo(a, s.shape, i, 1, p, c, false, l), d = new Nh(m);
+ return t6.runWebGLProgram(d, [n, s], "float32");
}
-var pA = { kernelName: mn, backendName: "webgl", kernelFunc: pQ };
-function cQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p } = o, u = I.computeConv3DInfo(n.shape, s.shape, a, p, i), c = new Rh(u);
- return t10.runWebGLProgram(c, [n, s], "float32");
+var LA = { kernelName: Ho, backendName: "webgl", kernelFunc: AY };
+function RY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p } = o, u = S.computeConv3DInfo(n.shape, s.shape, a, p, i), c = new Ch(u);
+ return t6.runWebGLProgram(c, [n, s], "float32");
}
-var cA = { kernelName: mp, backendName: "webgl", kernelFunc: cQ };
-function lQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, dy: s } = e, { strides: a, pad: i, filterShape: p } = o, u = I.computeConv3DInfo(n.shape, p, a, 1, i), c = new Lh(u);
- return t10.runWebGLProgram(c, [n, s], "float32");
+var BA = { kernelName: lp, backendName: "webgl", kernelFunc: RY };
+function FY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, dy: s } = e, { strides: a, pad: i, filterShape: p } = o, u = S.computeConv3DInfo(n.shape, p, a, 1, i), c = new Th(u);
+ return t6.runWebGLProgram(c, [n, s], "float32");
}
-var lA = { kernelName: Dm, backendName: "webgl", kernelFunc: lQ };
-function mQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, filter: s } = e, { pad: a, strides: i, inputShape: p } = o, u = I.computeConv3DInfo(p, s.shape, i, 1, a), c = new Bh(u);
- return t10.runWebGLProgram(c, [n, s], "float32");
+var VA = { kernelName: vm, backendName: "webgl", kernelFunc: FY };
+function DY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, filter: s } = e, { pad: a, strides: i, inputShape: p } = o, u = S.computeConv3DInfo(p, s.shape, i, 1, a), c = new _h(u);
+ return t6.runWebGLProgram(c, [n, s], "float32");
}
-var mA = { kernelName: fp, backendName: "webgl", kernelFunc: mQ };
-var fQ = jo + `
+var zA = { kernelName: mp, backendName: "webgl", kernelFunc: DY };
+var OY = _o + `
return cos(x);
`;
-var dQ = he({ opSnippet: fQ });
-var fA = { kernelName: fn, backendName: "webgl", kernelFunc: dQ };
-var hQ = `
+var PY = ge({ opSnippet: OY });
+var WA = { kernelName: qo, backendName: "webgl", kernelFunc: PY };
+var MY = `
float e2x = exp(-x);
return (e2x + 1.0 / e2x) / 2.0;
`;
-var gQ = he({ opSnippet: hQ });
-var dA = { kernelName: dn, backendName: "webgl", kernelFunc: gQ };
-var Vh = class {
- constructor(e, t10, o, n, s) {
+var LY = ge({ opSnippet: MY });
+var UA = { kernelName: Ko, backendName: "webgl", kernelFunc: LY };
+var Eh = class {
+ constructor(e, t6, o, n, s) {
this.variableNames = ["Image", "Boxes", "BoxInd"], this.outputShape = [];
- let [a, i, p, u] = e, [c] = t10, [l, m] = o;
+ let [a, i, p, u] = e, [c] = t6, [l, m] = o;
this.outputShape = [c, l, m, u];
- let f = n === "bilinear" ? 1 : 0, [d, h] = [`${i - 1}.0`, `${p - 1}.0`], [g, y, b] = l > 1 ? [`${(i - 1) / (l - 1)}`, "(y2-y1) * height_ratio", `y1*${d} + float(y)*(height_scale)`] : ["0.0", "0.0", `0.5 * (y1+y2) * ${d}`], [C, w, k] = m > 1 ? [`${(p - 1) / (m - 1)}`, "(x2-x1) * width_ratio", `x1*${h} + float(x)*(width_scale)`] : ["0.0", "0.0", `0.5 * (x1+x2) * ${h}`];
+ let d = n === "bilinear" ? 1 : 0, [f, h] = [`${i - 1}.0`, `${p - 1}.0`], [g, x, b] = l > 1 ? [`${(i - 1) / (l - 1)}`, "(y2-y1) * height_ratio", `y1*${f} + float(y)*(height_scale)`] : ["0.0", "0.0", `0.5 * (y1+y2) * ${f}`], [C, w, k] = m > 1 ? [`${(p - 1) / (m - 1)}`, "(x2-x1) * width_ratio", `x1*${h} + float(x)*(width_scale)`] : ["0.0", "0.0", `0.5 * (x1+x2) * ${h}`];
this.userCode = `
const float height_ratio = float(${g});
const float width_ratio = float(${C});
@@ -20695,11 +20761,11 @@ var Vh = class {
return;
}
- float height_scale = ${y};
+ float height_scale = ${x};
float width_scale = ${w};
float in_y = ${b};
- if( in_y < 0.0 || in_y > ${d} ) {
+ if( in_y < 0.0 || in_y > ${f} ) {
setOutput(float(${s}));
return;
}
@@ -20710,7 +20776,7 @@ var Vh = class {
}
vec2 sourceFracIndexCR = vec2(in_x,in_y);
- if(${f} == 1) {
+ if(${d} == 1) {
// Compute the four integer indices.
ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);
ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));
@@ -20737,36 +20803,36 @@ var Vh = class {
`;
}
};
-var xQ = (r) => {
- let { inputs: e, backend: t10, attrs: o } = r, { image: n, boxes: s, boxInd: a } = e, { cropSize: i, method: p, extrapolationValue: u } = o, c = new Vh(n.shape, s.shape, i, p, u);
- return t10.runWebGLProgram(c, [n, s, a], "float32");
+var BY = (r) => {
+ let { inputs: e, backend: t6, attrs: o } = r, { image: n, boxes: s, boxInd: a } = e, { cropSize: i, method: p, extrapolationValue: u } = o, c = new Eh(n.shape, s.shape, i, p, u);
+ return t6.runWebGLProgram(c, [n, s, a], "float32");
};
-var hA = { kernelName: xn, backendName: "webgl", kernelFunc: xQ };
-var Bu;
+var GA = { kernelName: Yo, backendName: "webgl", kernelFunc: BY };
+var Lu;
(function(r) {
r.Prod = "*", r.Sum = "+";
-})(Bu || (Bu = {}));
-var Ml = class {
- constructor(e, t10, o, n) {
- this.op = e, this.outputShape = t10, this.variableNames = ["x"], this.customUniforms = [{ name: "index", type: "float" }];
- let s = this.outputShape.length, a = this.op === Bu.Prod ? "1.0" : "0.0", i = o ? a : `getX(${gA(s, "coords", this.op)})`, p = this.outputShape[this.outputShape.length - 1], u = "", c = "";
+})(Lu || (Lu = {}));
+var El = class {
+ constructor(e, t6, o, n) {
+ this.op = e, this.outputShape = t6, this.variableNames = ["x"], this.customUniforms = [{ name: "index", type: "float" }];
+ let s = this.outputShape.length, a = this.op === Lu.Prod ? "1.0" : "0.0", i = o ? a : `getX(${HA(s, "coords", this.op)})`, p = this.outputShape[this.outputShape.length - 1], u = "", c = "";
o ? (u = n ? `end != ${p - 1}` : "end != 0", c = n ? "end + 1" : "end - 1") : (u = n ? `end + pow2 < ${p}` : "end >= pow2", c = n ? "end + pow2" : "end - pow2"), this.userCode = `
void main() {
${_e(s)} coords = getOutputCoords();
- int end = ${xA(s, "coords", this.op)};
+ int end = ${qA(s, "coords", this.op)};
float val = ${i};
int pow2 = int(pow(2.0, index));
if (${u}) {
int idx = ${c};
- ${xA(s, "coords", this.op)} = idx;
- val ${this.op}= getX(${gA(s, "coords", this.op)});
+ ${qA(s, "coords", this.op)} = idx;
+ val ${this.op}= getX(${HA(s, "coords", this.op)});
}
setOutput(val);
}
`;
}
};
-function gA(r, e, t10) {
+function HA(r, e, t6) {
if (r === 1)
return `${e}`;
if (r === 2)
@@ -20775,9 +20841,9 @@ function gA(r, e, t10) {
return `${e}.x, ${e}.y, ${e}.z`;
if (r === 4)
return `${e}.x, ${e}.y, ${e}.z, ${e}.w`;
- throw new Error(`Cumulative ${t10} for rank ${r} is not yet supported`);
+ throw new Error(`Cumulative ${t6} for rank ${r} is not yet supported`);
}
-function xA(r, e, t10) {
+function qA(r, e, t6) {
if (r === 1)
return `${e}`;
if (r === 2)
@@ -20786,54 +20852,54 @@ function xA(r, e, t10) {
return `${e}.z`;
if (r === 4)
return `${e}.w`;
- throw new Error(`Cumulative ${t10} for rank ${r} is not yet supported`);
+ throw new Error(`Cumulative ${t6} for rank ${r} is not yet supported`);
}
-function zh(r, e, t10, o, n, s) {
- let a = e.shape.length, i = I.getAxesPermutation([o], a), p = e;
- i != null && (p = xt({ inputs: { x: e }, backend: t10, attrs: { perm: i } }));
- let u = I.getInnerMostAxes(1, a)[0];
+function $h(r, e, t6, o, n, s) {
+ let a = e.shape.length, i = S.getAxesPermutation([o], a), p = e;
+ i != null && (p = xt({ inputs: { x: e }, backend: t6, attrs: { perm: i } }));
+ let u = S.getInnerMostAxes(1, a)[0];
if (u !== a - 1)
throw new Error(`WebGL cumprod shader expects an inner-most axis=${e.shape.length - 1} but got axis=${o}`);
- let c = p.shape[u], l = Rt({ inputs: { x: p }, backend: t10 });
+ let c = p.shape[u], l = At({ inputs: { x: p }, backend: t6 });
for (let m = 0; m <= Math.ceil(Math.log2(c)) - 1; m++) {
- let f = new Ml(r, p.shape, false, s), d = [[m]], h = l;
- l = t10.runWebGLProgram(f, [l], l.dtype, d), t10.disposeIntermediateTensorInfo(h);
+ let d = new El(r, p.shape, false, s), f = [[m]], h = l;
+ l = t6.runWebGLProgram(d, [l], l.dtype, f), t6.disposeIntermediateTensorInfo(h);
}
if (n) {
- let m = new Ml(r, p.shape, n, s), f = l;
- l = t10.runWebGLProgram(m, [l], l.dtype), t10.disposeIntermediateTensorInfo(f);
+ let m = new El(r, p.shape, n, s), d = l;
+ l = t6.runWebGLProgram(m, [l], l.dtype), t6.disposeIntermediateTensorInfo(d);
}
if (i != null) {
- let m = I.getUndoAxesPermutation(i), f = xt({ inputs: { x: l }, backend: t10, attrs: { perm: m } });
- return t10.disposeIntermediateTensorInfo(l), t10.disposeIntermediateTensorInfo(p), f;
+ let m = S.getUndoAxesPermutation(i), d = xt({ inputs: { x: l }, backend: t6, attrs: { perm: m } });
+ return t6.disposeIntermediateTensorInfo(l), t6.disposeIntermediateTensorInfo(p), d;
}
return l;
}
-function yQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o;
- return zh(Bu.Prod, n, t10, s, a, i);
+function VY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o;
+ return $h(Lu.Prod, n, t6, s, a, i);
}
-var yA = { kernelName: hn, backendName: "webgl", kernelFunc: yQ };
-function bQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o;
- return zh(Bu.Sum, n, t10, s, a, i);
+var KA = { kernelName: jo, backendName: "webgl", kernelFunc: VY };
+function zY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o;
+ return $h(Lu.Sum, n, t6, s, a, i);
}
-var bA = { kernelName: gn, backendName: "webgl", kernelFunc: bQ };
-function CQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, weights: s } = e, { size: a, binaryOutput: i } = o;
+var jA = { kernelName: Xo, backendName: "webgl", kernelFunc: zY };
+function WY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, weights: s } = e, { size: a, binaryOutput: i } = o;
if (n.shape.length === 1) {
- let p = t10.readSync(n.dataId), u = t10.readSync(s.dataId), c = oh(p, u, s.dtype, s.shape, a);
- return t10.makeTensorInfo([a], s.dtype, c);
+ let p = t6.readSync(n.dataId), u = t6.readSync(s.dataId), c = qf(p, u, s.dtype, s.shape, a);
+ return t6.makeTensorInfo([a], s.dtype, c);
} else if (n.shape.length === 2) {
- let p = t10.bufferSync(n), u = t10.bufferSync(s), c = a$(p, u, a, i);
- return t10.makeTensorInfo(c.shape, s.dtype, c.values);
+ let p = t6.bufferSync(n), u = t6.bufferSync(s), c = OE(p, u, a, i);
+ return t6.makeTensorInfo(c.shape, s.dtype, c.values);
}
throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${n.shape.length}.`);
}
-var CA = { kernelName: dp, backendName: "webgl", kernelFunc: CQ };
-var Wh = class {
- constructor(e, t10, o) {
- this.variableNames = ["x"], this.outputShape = [], this.outputShape = e, this.blockSize = t10, this.dataFormat = o, this.userCode = `
+var XA = { kernelName: ti, backendName: "webgl", kernelFunc: WY };
+var Ah = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["x"], this.outputShape = [], this.outputShape = e, this.blockSize = t6, this.dataFormat = o, this.userCode = `
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
@@ -20841,11 +20907,11 @@ var Wh = class {
int w = ${this.getWidthCoordString()};
int d = ${this.getDepthCoordString()};
- int in_h = h / ${t10};
- int offset_h = imod(h, ${t10});
- int in_w = w / ${t10};
- int offset_w = imod(w, ${t10});
- int offset_d = (offset_h * ${t10} + offset_w) *
+ int in_h = h / ${t6};
+ int offset_h = imod(h, ${t6});
+ int in_w = w / ${t6};
+ int offset_w = imod(w, ${t6});
+ int offset_d = (offset_h * ${t6} + offset_w) *
${this.getOutputDepthSize()};
int in_d = d + offset_d;
@@ -20870,14 +20936,14 @@ var Wh = class {
return this.dataFormat === "NHWC" ? "getX(b, in_h, in_w, in_d)" : "getX(b, in_d, in_h, in_w)";
}
};
-function IQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { blockSize: s, dataFormat: a } = o, i = n.shape[0], p = a === "NHWC" ? n.shape[1] : n.shape[2], u = a === "NHWC" ? n.shape[2] : n.shape[3], c = a === "NHWC" ? n.shape[3] : n.shape[1], l = p * s, m = u * s, f = c / (s * s), d = a === "NHWC" ? [i, l, m, f] : [i, f, l, m], h = new Wh(d, s, a);
- return t10.runWebGLProgram(h, [n], n.dtype);
+function UY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { blockSize: s, dataFormat: a } = o, i = n.shape[0], p = a === "NHWC" ? n.shape[1] : n.shape[2], u = a === "NHWC" ? n.shape[2] : n.shape[3], c = a === "NHWC" ? n.shape[3] : n.shape[1], l = p * s, m = u * s, d = c / (s * s), f = a === "NHWC" ? [i, l, m, d] : [i, d, l, m], h = new Ah(f, s, a);
+ return t6.runWebGLProgram(h, [n], n.dtype);
}
-var IA = { kernelName: yn, backendName: "webgl", kernelFunc: IQ };
-var Ic = class {
- constructor(e, t10 = false, o = null, n = false, s = false) {
- this.variableNames = ["x", "W"], this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = lt(this.outputShape.length);
+var YA = { kernelName: Qo, backendName: "webgl", kernelFunc: UY };
+var xc = class {
+ constructor(e, t6 = false, o = null, n = false, s = false) {
+ this.variableNames = ["x", "W"], this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = ct(this.outputShape.length);
let a = e.filterHeight, i = e.filterWidth, p = e.outChannels / e.inChannels, u = "", c = "";
o && (n ? u = `float activation(float a) {
float b = getPreluActivationWeightsAtOutCoords();
@@ -20890,8 +20956,8 @@ var Ic = class {
${o}
}
`, c = "result = activation(result);");
- let l = t10 ? "result += getBiasAtOutCoords();" : "";
- t10 && this.variableNames.push("bias"), n && this.variableNames.push("preluActivationWeights"), s && this.variableNames.push("leakyreluAlpha"), this.userCode = `
+ let l = t6 ? "result += getBiasAtOutCoords();" : "";
+ t6 && this.variableNames.push("bias"), n && this.variableNames.push("preluActivationWeights"), s && this.variableNames.push("leakyreluAlpha"), this.userCode = `
${u}
void main() {
@@ -20937,39 +21003,39 @@ var Ic = class {
`;
}
};
-var wc = class {
- constructor(e, t10 = false, o = null, n = false, s = false) {
- this.variableNames = ["x", "W"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = lt(this.outputShape.length);
- let a = e.outChannels / e.inChannels, i = e.padInfo.left, p = e.strideWidth, u = e.dilationWidth, c = e.filterHeight, l = e.filterWidth, m = l, f = `
+var yc = class {
+ constructor(e, t6 = false, o = null, n = false, s = false) {
+ this.variableNames = ["x", "W"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = ct(this.outputShape.length);
+ let a = e.outChannels / e.inChannels, i = e.padInfo.left, p = e.strideWidth, u = e.dilationWidth, c = e.filterHeight, l = e.filterWidth, m = l, d = `
int xR; int xC; int xCOffset;
vec4 wTexel; vec4 previous; vec4 final;`;
- for (let y = 0; y < l; y++)
- f += `
- vec4 xTexelC${y * 2};
- int xTexelC${y * 2}Ready;
- vec4 xTexelC${y * 2 + 1};
- int xTexelC${y * 2 + 1}Ready;
- vec4 xC${y};`;
- f += `
+ for (let x = 0; x < l; x++)
+ d += `
+ vec4 xTexelC${x * 2};
+ int xTexelC${x * 2}Ready;
+ vec4 xTexelC${x * 2 + 1};
+ int xTexelC${x * 2 + 1}Ready;
+ vec4 xC${x};`;
+ d += `
for (int r = 0; r < ${c}; r++) {
`;
- for (let y = 0; y < l; y++)
- f += `
- xTexelC${y * 2} = vec4(0.0);
- xTexelC${y * 2}Ready = 0;
- xTexelC${y * 2 + 1} = vec4(0.0);
- xTexelC${y * 2 + 1}Ready = 0;
- xC${y} = vec4(0.0);`;
- f += `
+ for (let x = 0; x < l; x++)
+ d += `
+ xTexelC${x * 2} = vec4(0.0);
+ xTexelC${x * 2}Ready = 0;
+ xTexelC${x * 2 + 1} = vec4(0.0);
+ xTexelC${x * 2 + 1}Ready = 0;
+ xC${x} = vec4(0.0);`;
+ d += `
xR = xRCorner + r * dilations[0];
if (xR >=0 && xR < inDims[0]) {
`;
- for (let y = 0; y < (m + 1) / 2; y++) {
- let b = y * 2;
- if (f += `
+ for (let x = 0; x < (m + 1) / 2; x++) {
+ let b = x * 2;
+ if (d += `
xC = xCCorner + ${b * u};
`, p === 1) {
- if (b < l && (i % 2 === 1 ? (f += `
+ if (b < l && (i % 2 === 1 ? (d += `
xCOffset = xC + 1;
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${b}Ready == 0) {
xTexelC${b} = getX(batch, xR, xCOffset, d1);
@@ -20981,9 +21047,9 @@ var wc = class {
}
xTexelC${b}Ready = 1;
}
- `, u === 1 && b > 0 ? f += `
+ `, u === 1 && b > 0 ? d += `
xC${b} = vec4(xTexelC${b - 2}.zw, xTexelC${b}.xy);
- ` : f += `
+ ` : d += `
xCOffset = xC + 1 - 2;
if (xCOffset >= 0 && xCOffset < inDims[1]) {
@@ -20999,7 +21065,7 @@ var wc = class {
} else {
xC${b} = vec4(0.0, 0.0, xTexelC${b}.xy);
}
- `) : f += `
+ `) : d += `
if (xC >= 0 && xC < inDims[1] && xTexelC${b}Ready == 0) {
xTexelC${b} = getX(batch, xR, xC, d1);
if (xC + 1 >= inDims[1]) {
@@ -21010,8 +21076,8 @@ var wc = class {
xC${b} = xTexelC${b};
`, b + 1 < l)) {
- let C = i % 2 === 0 ? x.nearestLargerEven(u) : u;
- u % 2 === 0 && i % 2 === 1 || u % 2 !== 0 && i % 2 !== 1 ? (f += `
+ let C = i % 2 === 0 ? y.nearestLargerEven(u) : u;
+ u % 2 === 0 && i % 2 === 1 || u % 2 !== 0 && i % 2 !== 1 ? (d += `
xCOffset = xC + imod(pads[1], 2) + ${C};
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${b + 1}Ready == 0) {
@@ -21024,7 +21090,7 @@ var wc = class {
}
xTexelC${b + 1}Ready = 1;
}
- `, u > 1 ? f += `
+ `, u > 1 ? d += `
xCOffset -= 2;
if (xCOffset >= 0 && xCOffset < inDims[1]) {
previous = getX(batch, xR, xCOffset, d1);
@@ -21032,11 +21098,11 @@ var wc = class {
} else {
xC${b + 1} = vec4(0.0, 0.0, xTexelC${b + 1}.xy);
}
- ` : f += `
+ ` : d += `
xC${b + 1} = vec4(xTexelC${b}.zw, xTexelC${b + 1}.xy);
- `) : C === 1 ? f += `
+ `) : C === 1 ? d += `
xC${b + 1} = xTexelC${b};
- ` : f += `
+ ` : d += `
xCOffset = xC + ${C};
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${b + 1}Ready == 0) {
@@ -21051,7 +21117,7 @@ var wc = class {
`;
}
} else
- b < l && (i % 2 === 1 ? (f += `
+ b < l && (i % 2 === 1 ? (d += `
xCOffset = xC + 1 - strides[1];
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${b}Ready == 0) {
xTexelC${b} = getX(batch, xR, xCOffset, d1);
@@ -21074,14 +21140,14 @@ var wc = class {
}
xC${b} = vec4(xTexelC${b}.zw, xTexelC${b + 1}.zw);
- `, b + 1 < l && (f += `
+ `, b + 1 < l && (d += `
final = vec4(0.0);
xCOffset = xC + 1 + strides[1];
if(xCOffset >= 0 && xCOffset < inDims[1]) {
final = getX(batch, xR, xCOffset, d1);
}
xC${b + 1} = vec4(xTexelC${b + 1}.xy, final.xy);
- `)) : (f += `
+ `)) : (d += `
if(xC >= 0 && xC < inDims[1] && xTexelC${b}Ready == 0) {
xTexelC${b} = getX(batch, xR, xC, d1);
if (xC + 1 >= inDims[1]) {
@@ -21101,35 +21167,35 @@ var wc = class {
xC${b} = vec4(
xTexelC${b}.xy, xTexelC${b + 1}.xy);
- `, b + 1 < l && (f += `
+ `, b + 1 < l && (d += `
xC${b + 1} = vec4(xTexelC${b}.zw, xTexelC${b + 1}.zw);
`)));
- b < l && (f += `
+ b < l && (d += `
wTexel = getW(r, ${b}, d1, q);
dotProd += xC${b} * vec4(wTexel.xz, wTexel.xz);
- `, b + 1 < l && (f += `
+ `, b + 1 < l && (d += `
wTexel = getW(r, ${b + 1}, d1, q);
dotProd += xC${b + 1} * vec4(wTexel.xz, wTexel.xz);
`));
}
- f += `
+ d += `
}
- `, f += `
+ `, d += `
}
`;
- let d = "", h = "";
- o && (n ? d = `vec4 activation(vec4 a) {
+ let f = "", h = "";
+ o && (n ? f = `vec4 activation(vec4 a) {
vec4 b = getPreluActivationWeightsAtOutCoords();
${o}
- }` : s ? d = `vec4 activation(vec4 a) {
+ }` : s ? f = `vec4 activation(vec4 a) {
vec4 b = getLeakyreluAlphaAtOutCoords();
${o}
- }` : d = `vec4 activation(vec4 x) {
+ }` : f = `vec4 activation(vec4 x) {
${o}
}`, h = "result = activation(result);");
- let g = t10 ? "result += getBiasAtOutCoords();" : "";
- t10 && this.variableNames.push("bias"), n && this.variableNames.push("preluActivationWeights"), s && this.variableNames.push("leakyreluAlpha"), this.userCode = `
- ${d}
+ let g = t6 ? "result += getBiasAtOutCoords();" : "";
+ t6 && this.variableNames.push("bias"), n && this.variableNames.push("preluActivationWeights"), s && this.variableNames.push("leakyreluAlpha"), this.userCode = `
+ ${f}
void main() {
ivec4 coords = getOutputCoords();
@@ -21144,7 +21210,7 @@ var wc = class {
//intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.
vec4 dotProd = vec4(0.000000000000001);
- ${f}
+ ${d}
vec4 result = dotProd - vec4(0.000000000000001);
${g}
@@ -21154,19 +21220,19 @@ var wc = class {
`;
}
};
-function wQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p, dimRoundingMode: u } = o, c = p;
- c == null && (c = [1, 1]), x.assert(I.eitherStridesOrDilationsAreOne(a, c), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${c}'`);
- let l = I.computeConv2DInfo(n.shape, s.shape, a, c, i, u, true), m;
- P().getBool("WEBGL_PACK_DEPTHWISECONV") && l.strideWidth <= 2 && l.outChannels / l.inChannels === 1 ? m = new wc(l) : m = new Ic(l);
- let f = [[l.padInfo.top, l.padInfo.left], [l.strideHeight, l.strideWidth], [l.dilationHeight, l.dilationWidth], [l.inHeight, l.inWidth]];
- return t10.runWebGLProgram(m, [n, s], "float32", f);
+function GY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p, dimRoundingMode: u } = o, c = p;
+ c == null && (c = [1, 1]), y.assert(S.eitherStridesOrDilationsAreOne(a, c), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${c}'`);
+ let l = S.computeConv2DInfo(n.shape, s.shape, a, c, i, u, true), m;
+ O().getBool("WEBGL_PACK_DEPTHWISECONV") && l.strideWidth <= 2 && l.outChannels / l.inChannels === 1 ? m = new yc(l) : m = new xc(l);
+ let d = [[l.padInfo.top, l.padInfo.left], [l.strideHeight, l.strideWidth], [l.dilationHeight, l.dilationWidth], [l.inHeight, l.inWidth]];
+ return t6.runWebGLProgram(m, [n, s], "float32", d);
}
-var wA = { kernelName: bn, backendName: "webgl", kernelFunc: wQ };
-var Uh = class {
+var QA = { kernelName: Zo, backendName: "webgl", kernelFunc: GY };
+var Rh = class {
constructor(e) {
this.variableNames = ["x", "dy"], this.outputShape = e.filterShape;
- let t10 = e.strideHeight, o = e.strideWidth, n = e.padInfo.top, s = e.padInfo.left, a = e.outChannels / e.inChannels;
+ let t6 = e.strideHeight, o = e.strideWidth, n = e.padInfo.top, s = e.padInfo.left, a = e.outChannels / e.inChannels;
this.userCode = `
void main() {
ivec4 coords = getOutputCoords();
@@ -21181,7 +21247,7 @@ var Uh = class {
// TO DO: Vec4 over the batch size
for (int b = 0; b < ${e.batchSize}; b++) {
for (int yR = 0; yR < ${e.outHeight}; yR++) {
- int xR = wR + yR * ${t10} - ${n};
+ int xR = wR + yR * ${t6} - ${n};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
@@ -21205,10 +21271,10 @@ var Uh = class {
`;
}
};
-var Gh = class {
+var Fh = class {
constructor(e) {
this.variableNames = ["dy", "W"], this.outputShape = e.inShape;
- let t10 = e.filterHeight, o = e.filterWidth, n = e.strideHeight, s = e.strideWidth, a = t10 - 1 - e.padInfo.top, i = o - 1 - e.padInfo.left, p = e.outChannels / e.inChannels;
+ let t6 = e.filterHeight, o = e.filterWidth, n = e.strideHeight, s = e.strideWidth, a = t6 - 1 - e.padInfo.top, i = o - 1 - e.padInfo.left, p = e.outChannels / e.inChannels;
this.userCode = `
const ivec2 pads = ivec2(${a}, ${i});
@@ -21222,7 +21288,7 @@ var Gh = class {
float dotProd = 0.0;
- for (int wR = 0; wR < ${t10}; wR++) {
+ for (int wR = 0; wR < ${t6}; wR++) {
float dyR = float(dyRCorner + wR) / ${n}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
@@ -21230,7 +21296,7 @@ var Gh = class {
}
int idyR = int(dyR);
- int wRPerm = ${t10} - 1 - wR;
+ int wRPerm = ${t6} - 1 - wR;
for (int wC = 0; wC < ${o}; wC++) {
float dyC = float(dyCCorner + wC) / ${s}.0;
@@ -21257,17 +21323,17 @@ var Gh = class {
`;
}
};
-function SQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, dy: s } = e, { strides: a, dilations: i, pad: p, dimRoundingMode: u, filterShape: c } = o, l = I.computeConv2DInfo(n.shape, c, a, i, p, u, true), m = new Uh(l);
- return t10.runWebGLProgram(m, [n, s], "float32");
+function HY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, dy: s } = e, { strides: a, dilations: i, pad: p, dimRoundingMode: u, filterShape: c } = o, l = S.computeConv2DInfo(n.shape, c, a, i, p, u, true), m = new Rh(l);
+ return t6.runWebGLProgram(m, [n, s], "float32");
}
-var SA = { kernelName: hp, backendName: "webgl", kernelFunc: SQ };
-function vQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, filter: s } = e, { strides: a, dilations: i, pad: p, dimRoundingMode: u, inputShape: c } = o, l = I.computeConv2DInfo(c, s.shape, a, i, p, u, true), m = new Gh(l);
- return t10.runWebGLProgram(m, [n, s], "float32");
+var ZA = { kernelName: dp, backendName: "webgl", kernelFunc: HY };
+function qY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, filter: s } = e, { strides: a, dilations: i, pad: p, dimRoundingMode: u, inputShape: c } = o, l = S.computeConv2DInfo(c, s.shape, a, i, p, u, true), m = new Fh(l);
+ return t6.runWebGLProgram(m, [n, s], "float32");
}
-var vA = { kernelName: gp, backendName: "webgl", kernelFunc: vQ };
-var Hh = class {
+var JA = { kernelName: fp, backendName: "webgl", kernelFunc: qY };
+var Dh = class {
constructor(e) {
this.variableNames = ["X"], this.outputShape = [e, e], this.userCode = `
void main() {
@@ -21278,15 +21344,15 @@ var Hh = class {
`;
}
};
-function kQ(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e, n = [...o.shape, ...o.shape], s = x.sizeFromShape(o.shape), a = J({ inputs: { x: o }, backend: t10, attrs: { shape: [s] } }), i = new Hh(s), p = t10.runWebGLProgram(i, [a], a.dtype), u = J({ inputs: { x: p }, backend: t10, attrs: { shape: n } });
- return t10.disposeIntermediateTensorInfo(a), t10.disposeIntermediateTensorInfo(p), u;
+function KY(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e, n = [...o.shape, ...o.shape], s = y.sizeFromShape(o.shape), a = te({ inputs: { x: o }, backend: t6, attrs: { shape: [s] } }), i = new Dh(s), p = t6.runWebGLProgram(i, [a], a.dtype), u = te({ inputs: { x: p }, backend: t6, attrs: { shape: n } });
+ return t6.disposeIntermediateTensorInfo(a), t6.disposeIntermediateTensorInfo(p), u;
}
-var kA = { kernelName: xp, backendName: "webgl", kernelFunc: kQ };
-var qh = class {
+var eR = { kernelName: hp, backendName: "webgl", kernelFunc: KY };
+var Oh = class {
constructor(e) {
this.variableNames = ["x", "W"], this.outputShape = e.outShape;
- let { inHeight: t10, inWidth: o, padInfo: n, strideHeight: s, strideWidth: a, filterHeight: i, filterWidth: p, dilationHeight: u, dilationWidth: c } = e, { top: l, left: m } = n;
+ let { inHeight: t6, inWidth: o, padInfo: n, strideHeight: s, strideWidth: a, filterHeight: i, filterWidth: p, dilationHeight: u, dilationWidth: c } = e, { top: l, left: m } = n;
this.userCode = `
const ivec2 strides = ivec2(${s}, ${a});
const ivec2 pads = ivec2(${l}, ${m});
@@ -21305,7 +21371,7 @@ var qh = class {
for (int h = 0; h < ${i}; h++) {
int hIn = hBeg + h * ${u};
- if (hIn >= 0 && hIn < ${t10}) {
+ if (hIn >= 0 && hIn < ${t6}) {
for (int w = 0; w < ${p}; w++) {
int wIn = wBeg + w * ${c};
@@ -21328,35 +21394,35 @@ var qh = class {
`;
}
};
-function TQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p } = o, u = I.computeDilation2DInfo(n.shape, s.shape, a, i, "NHWC", p), c, l = new qh(u);
- c = t10.runWebGLProgram(l, [n, s], "float32");
- let m = J({ inputs: { x: c }, backend: t10, attrs: { shape: u.outShape } });
- return t10.disposeIntermediateTensorInfo(c), m;
+function jY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s } = e, { strides: a, pad: i, dilations: p } = o, u = S.computeDilation2DInfo(n.shape, s.shape, a, i, "NHWC", p), c, l = new Oh(u);
+ c = t6.runWebGLProgram(l, [n, s], "float32");
+ let m = te({ inputs: { x: c }, backend: t6, attrs: { shape: u.outShape } });
+ return t6.disposeIntermediateTensorInfo(c), m;
}
-var TA = { kernelName: yp, backendName: "webgl", kernelFunc: TQ };
-function NQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { equation: n } = o, s = e, { allDims: a, summedDims: i, idDims: p } = I.decodeEinsumEquation(n, s.length);
- I.checkEinsumDimSizes(a.length, p, s);
- let { path: u, steps: c } = I.getEinsumComputePath(i, p), l = c.length, m = null, f = a.length, d = [];
+var tR = { kernelName: gp, backendName: "webgl", kernelFunc: jY };
+function XY(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { equation: n } = o, s = e, { allDims: a, summedDims: i, idDims: p } = S.decodeEinsumEquation(n, s.length);
+ S.checkEinsumDimSizes(a.length, p, s);
+ let { path: u, steps: c } = S.getEinsumComputePath(i, p), l = c.length, m = null, d = a.length, f = [];
for (let h = 0; h < l; ++h) {
for (let g of c[h]) {
- let { permutationIndices: y, expandDims: b } = I.getEinsumPermutation(f, p[g]), C;
- I.isIdentityPermutation(y) ? C = s[g] : (C = xt({ inputs: { x: s[g] }, backend: t10, attrs: { perm: y } }), d.push(C));
+ let { permutationIndices: x, expandDims: b } = S.getEinsumPermutation(d, p[g]), C;
+ S.isIdentityPermutation(x) ? C = s[g] : (C = xt({ inputs: { x: s[g] }, backend: t6, attrs: { perm: x } }), f.push(C));
let w = C.shape.slice();
for (let k = 0; k < b.length; ++k)
w.splice(b[k], 0, 1);
- x.arraysEqual(C.shape, w) || (C = J({ inputs: { x: C }, backend: t10, attrs: { shape: w } }), d.push(C)), m === null ? m = C : (m = Pl({ inputs: { a: C, b: m }, backend: t10 }), d.push(m));
+ y.arraysEqual(C.shape, w) || (C = te({ inputs: { x: C }, backend: t6, attrs: { shape: w } }), f.push(C)), m === null ? m = C : (m = Tl({ inputs: { a: C, b: m }, backend: t6 }), f.push(m));
}
- h < l - 1 && (u[h] >= 0 && (m = Ou({ inputs: { x: m }, backend: t10, attrs: { axis: u[h] - (a.length - f), keepDims: false } }), d.push(m)), f--);
+ h < l - 1 && (u[h] >= 0 && (m = Ou({ inputs: { x: m }, backend: t6, attrs: { axis: u[h] - (a.length - d), keepDims: false } }), f.push(m)), d--);
}
- for (let h of d)
- h !== m && t10.disposeIntermediateTensorInfo(h);
+ for (let h of f)
+ h !== m && t6.disposeIntermediateTensorInfo(h);
return m;
}
-var NA = { kernelName: Xa, backendName: "webgl", kernelFunc: NQ };
-var _Q = "return (x >= 0.0) ? x : (exp(x) - 1.0);";
-var EQ = `
+var rR = { kernelName: ri, backendName: "webgl", kernelFunc: XY };
+var YY = "return (x >= 0.0) ? x : (exp(x) - 1.0);";
+var QY = `
vec4 result;
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
@@ -21366,46 +21432,46 @@ var EQ = `
return result;
`;
-var $Q = he({ opSnippet: _Q, packedOpSnippet: EQ });
-var _A = { kernelName: In, backendName: "webgl", kernelFunc: $Q };
-var RQ = "return (b >= 1.0) ? a : a * (b + 1.0);";
-var AQ = `
+var ZY = ge({ opSnippet: YY, packedOpSnippet: QY });
+var oR = { kernelName: en, backendName: "webgl", kernelFunc: ZY };
+var JY = "return (b >= 1.0) ? a : a * (b + 1.0);";
+var eQ = `
vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));
`;
-var FQ = (r) => {
- let { inputs: e, backend: t10 } = r, { dy: o, y: n } = e, s = P().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ko(AQ, o.shape, n.shape) : new _o(RQ, o.shape, n.shape);
- return t10.runWebGLProgram(s, [o, n], o.dtype);
+var tQ = (r) => {
+ let { inputs: e, backend: t6 } = r, { dy: o, y: n } = e, s = O().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new To(eQ, o.shape, n.shape) : new io(JY, o.shape, n.shape);
+ return t6.runWebGLProgram(s, [o, n], o.dtype);
};
-var EA = { kernelName: Pm, backendName: "webgl", kernelFunc: FQ };
-var DQ = `
+var nR = { kernelName: km, backendName: "webgl", kernelFunc: tQ };
+var rQ = `
return vec4(equal(a, b));
`;
-var PQ = "return float(a == b);";
-var OQ = ot({ opSnippet: PQ, packedOpSnippet: DQ, dtype: "bool", cpuKernelImpl: c$ });
-var $A = { kernelName: oo, backendName: "webgl", kernelFunc: OQ };
-var MQ = `
+var oQ = "return float(a == b);";
+var nQ = tt({ opSnippet: oQ, packedOpSnippet: rQ, dtype: "bool", cpuKernelImpl: BE });
+var sR = { kernelName: tn, backendName: "webgl", kernelFunc: nQ };
+var sQ = `
// Error function is calculated approximately with elementary function.
// See "Handbook of Mathematical Functions with Formulas,
// Graphs, and Mathematical Tables", Abramowitz and Stegun.
- float p = ${I.ERF_P};
- float a1 = ${I.ERF_A1};
- float a2 = ${I.ERF_A2};
- float a3 = ${I.ERF_A3};
- float a4 = ${I.ERF_A4};
- float a5 = ${I.ERF_A5};
+ float p = ${S.ERF_P};
+ float a1 = ${S.ERF_A1};
+ float a2 = ${S.ERF_A2};
+ float a3 = ${S.ERF_A3};
+ float a4 = ${S.ERF_A4};
+ float a5 = ${S.ERF_A5};
float sign = sign(x);
x = abs(x);
float t = 1.0 / (1.0 + p * x);
return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));
`;
-var LQ = he({ opSnippet: MQ });
-var RA = { kernelName: Gi, backendName: "webgl", kernelFunc: LQ };
-var BQ = jo + `
+var aQ = ge({ opSnippet: sQ });
+var aR = { kernelName: ma, backendName: "webgl", kernelFunc: aQ };
+var iQ = _o + `
return exp(x);
`;
-var VQ = `
+var uQ = `
vec4 result = exp(x);
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
@@ -21415,21 +21481,21 @@ var VQ = `
return result;
`;
-var Ow = he({ opSnippet: BQ, packedOpSnippet: VQ, cpuKernelImpl: l$, dtype: "float32" });
-var AA = { kernelName: no, backendName: "webgl", kernelFunc: Ow };
-function Kh(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { dim: n } = t10, { input: s } = e, a = s.shape.length, i = s.shape.slice(), p = n;
- return n < 0 && (x.assert(-(a + 1) <= n, () => `Axis must be in the interval [${-(a + 1)}, ${a}]`), p = a + n + 1), i.splice(p, 0, 1), J({ inputs: { x: s }, backend: o, attrs: { shape: i } });
+var Aw = ge({ opSnippet: iQ, packedOpSnippet: uQ, cpuKernelImpl: VE, dtype: "float32" });
+var iR = { kernelName: rn, backendName: "webgl", kernelFunc: Aw };
+function Ph(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { dim: n } = t6, { input: s } = e, a = s.shape.length, i = s.shape.slice(), p = n;
+ return n < 0 && (y.assert(-(a + 1) <= n, () => `Axis must be in the interval [${-(a + 1)}, ${a}]`), p = a + n + 1), i.splice(p, 0, 1), te({ inputs: { x: s }, backend: o, attrs: { shape: i } });
}
-var FA = { kernelName: xs, backendName: "webgl", kernelFunc: Kh };
-var DA = "return exp(x) - 1.0;";
-var zQ = he({ opSnippet: DA, packedOpSnippet: DA, cpuKernelImpl: m$ });
-var PA = { kernelName: wn, backendName: "webgl", kernelFunc: zQ };
-var Ll = class {
- constructor(e, t10, o) {
+var uR = { kernelName: bs, backendName: "webgl", kernelFunc: Ph };
+var pR = "return exp(x) - 1.0;";
+var pQ = ge({ opSnippet: pR, packedOpSnippet: pR, cpuKernelImpl: zE });
+var cR = { kernelName: da, backendName: "webgl", kernelFunc: pQ };
+var $l = class {
+ constructor(e, t6, o) {
this.variableNames = ["real", "imag"];
- let n = t10[1];
- this.outputShape = t10;
+ let n = t6[1];
+ this.outputShape = t6;
let s = o ? `2.0 * ${Math.PI}` : `-2.0 * ${Math.PI}`, a = o ? `${n}.0` : "1.0", i;
if (e === "real")
i = "return real * expR - imag * expI;";
@@ -21473,19 +21539,19 @@ var Ll = class {
`;
}
};
-function jh(r, e, t10) {
- let o = t10.texData.get(r.dataId), n = x.sizeFromShape(r.shape), s = r.shape[r.shape.length - 1], a = n / s, i = J({ inputs: { x: r }, backend: t10, attrs: { shape: [a, s] } }), p = i.shape, u = new Ll("real", p, e), c = new Ll("imag", p, e), l = [{ dataId: o.complexTensorInfos.real.dataId, dtype: o.complexTensorInfos.real.dtype, shape: p }, { dataId: o.complexTensorInfos.imag.dataId, dtype: o.complexTensorInfos.imag.dtype, shape: p }], m = t10.runWebGLProgram(u, l, "float32"), f = t10.runWebGLProgram(c, l, "float32"), d = Ar({ inputs: { real: m, imag: f }, backend: t10 });
- t10.disposeIntermediateTensorInfo(m), t10.disposeIntermediateTensorInfo(f);
- let h = J({ inputs: { x: d }, backend: t10, attrs: { shape: r.shape } });
- return t10.disposeIntermediateTensorInfo(i), t10.disposeIntermediateTensorInfo(d), h;
+function Mh(r, e, t6) {
+ let o = t6.texData.get(r.dataId), n = y.sizeFromShape(r.shape), s = r.shape[r.shape.length - 1], a = n / s, i = te({ inputs: { x: r }, backend: t6, attrs: { shape: [a, s] } }), p = i.shape, u = new $l("real", p, e), c = new $l("imag", p, e), l = [{ dataId: o.complexTensorInfos.real.dataId, dtype: o.complexTensorInfos.real.dtype, shape: p }, { dataId: o.complexTensorInfos.imag.dataId, dtype: o.complexTensorInfos.imag.dtype, shape: p }], m = t6.runWebGLProgram(u, l, "float32"), d = t6.runWebGLProgram(c, l, "float32"), f = Rr({ inputs: { real: m, imag: d }, backend: t6 });
+ t6.disposeIntermediateTensorInfo(m), t6.disposeIntermediateTensorInfo(d);
+ let h = te({ inputs: { x: f }, backend: t6, attrs: { shape: r.shape } });
+ return t6.disposeIntermediateTensorInfo(i), t6.disposeIntermediateTensorInfo(f), h;
}
-function WQ(r) {
- let { inputs: e, backend: t10 } = r, { input: o } = e;
- return jh(o, false, t10);
+function cQ(r) {
+ let { inputs: e, backend: t6 } = r, { input: o } = e;
+ return Mh(o, false, t6);
}
-var OA = { kernelName: bp, backendName: "webgl", kernelFunc: WQ };
-var Xh = class {
- constructor(e, t10) {
+var lR = { kernelName: oi, backendName: "webgl", kernelFunc: cQ };
+var Lh = class {
+ constructor(e, t6) {
this.outputShape = [], this.customUniforms = [{ name: "value", type: "float" }], this.variableNames = ["x"], this.outputShape = e, this.userCode = `
void main() {
// Input can be obtained from uniform value.
@@ -21494,29 +21560,29 @@ var Xh = class {
`;
}
};
-function Ba(r) {
- let { backend: e, attrs: t10 } = r, { shape: o, value: n } = t10, { dtype: s } = t10;
- if (s = s || x.inferDtype(n), s === "string") {
- let a = x.getArrayFromDType(s, x.sizeFromShape(o));
+function Ga(r) {
+ let { backend: e, attrs: t6 } = r, { shape: o, value: n } = t6, { dtype: s } = t6;
+ if (s = s || y.inferDtype(n), s === "string") {
+ let a = y.getArrayFromDType(s, y.sizeFromShape(o));
return a.fill(n), e.makeTensorInfo(o, s, a);
} else {
- let a = new Xh(o, n), i = [[n]];
+ let a = new Lh(o, n), i = [[n]];
return e.runWebGLProgram(a, [], s, i);
}
}
-var MA = { kernelName: ys, backendName: "webgl", kernelFunc: Ba };
-var Yh = class {
+var mR = { kernelName: Cs, backendName: "webgl", kernelFunc: Ga };
+var Bh = class {
constructor(e) {
this.variableNames = ["Image"], this.outputShape = [];
- let t10 = e[2];
+ let t6 = e[2];
this.outputShape = e, this.userCode = `
void main() {
ivec4 coords = getOutputCoords();
int x = coords[2];
- int coordX = ${t10} - x - 1;
+ int coordX = ${t6} - x - 1;
float outputValue;
- if(coordX >= 0 && coordX < ${t10}) {
+ if(coordX >= 0 && coordX < ${t6}) {
outputValue = getImage(coords[0], coords[1], coordX, coords[3]);
} else {
outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);
@@ -21526,14 +21592,14 @@ var Yh = class {
`;
}
};
-var LA = { kernelName: Sn, backendName: "webgl", kernelFunc: ({ inputs: r, backend: e }) => {
- let { image: t10 } = r, o = e, n = new Yh(t10.shape);
- return o.runWebGLProgram(n, [t10], t10.dtype);
+var dR = { kernelName: on, backendName: "webgl", kernelFunc: ({ inputs: r, backend: e }) => {
+ let { image: t6 } = r, o = e, n = new Bh(t6.shape);
+ return o.runWebGLProgram(n, [t6], t6.dtype);
} };
-var BA = "return floor(x);";
-var UQ = he({ opSnippet: BA, packedOpSnippet: BA, cpuKernelImpl: f$ });
-var VA = { kernelName: so, backendName: "webgl", kernelFunc: UQ };
-var GQ = `
+var fR = "return floor(x);";
+var lQ = ge({ opSnippet: fR, packedOpSnippet: fR, cpuKernelImpl: WE });
+var hR = { kernelName: nn, backendName: "webgl", kernelFunc: lQ };
+var mQ = `
float s = sign(a) * sign(b);
int ia = round(a);
int ib = round(b);
@@ -21544,7 +21610,7 @@ var GQ = `
return NAN;
}
`;
-var HQ = `
+var dQ = `
ivec4 ia = round(a);
ivec4 ib = round(b);
bvec4 cond = notEqual(ib, ivec4(0));
@@ -21566,12 +21632,12 @@ var HQ = `
}
return vec4(result);
`;
-var qQ = ot({ opSnippet: GQ, packedOpSnippet: HQ, dtype: "int32" });
-var zA = { kernelName: vn, backendName: "webgl", kernelFunc: qQ };
-var Qh = class {
+var fQ = tt({ opSnippet: mQ, packedOpSnippet: dQ, dtype: "int32" });
+var gR = { kernelName: sn, backendName: "webgl", kernelFunc: fQ };
+var Vh = class {
constructor(e) {
this.variableNames = ["A"];
- let t10 = Ct(), [o, n] = e;
+ let t6 = St(), [o, n] = e;
this.outputShape = e, this.userCode = `
void main() {
ivec3 coords = getOutputCoords();
@@ -21580,7 +21646,7 @@ var Qh = class {
int depth = coords[2];
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${n}.0, ${o}.0);
- vec4 values = ${t10.texture2D}(A, uv);
+ vec4 values = ${t6.texture2D}(A, uv);
float value;
if (depth == 0) {
value = values.r;
@@ -21597,10 +21663,10 @@ var Qh = class {
`;
}
};
-var Zh = class {
+var zh = class {
constructor(e) {
this.variableNames = ["A"], this.packedInputs = false, this.packedOutput = true;
- let t10 = Ct(), [o, n] = e;
+ let t6 = St(), [o, n] = e;
this.outputShape = e, this.userCode = `
void main() {
ivec3 coords = getOutputCoords();
@@ -21617,7 +21683,7 @@ var Zh = class {
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${n}.0, ${o}.0);
- vec4 values = ${t10.texture2D}(A, uv);
+ vec4 values = ${t6.texture2D}(A, uv);
float value;
if (depth == 0) {
value = values.r;
@@ -21633,72 +21699,72 @@ var Zh = class {
}
}
- ${t10.output} = result;
+ ${t6.output} = result;
}
`;
}
};
-var WA = { kernelName: Zi, backendName: "webgl", kernelFunc: KQ };
-var Sc;
-var Mw = P().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");
-function KQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { pixels: n } = e, { numChannels: s } = o, a = typeof HTMLVideoElement != "undefined" && n instanceof HTMLVideoElement, i = typeof HTMLImageElement != "undefined" && n instanceof HTMLImageElement, [p, u] = a ? [n.videoWidth, n.videoHeight] : [n.width, n.height], c = [u, p], l = [u, p, s];
+var xR = { kernelName: Zi, backendName: "webgl", kernelFunc: hQ };
+var bc;
+var Rw = O().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");
+function hQ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { pixels: n } = e, { numChannels: s } = o, a = typeof HTMLVideoElement != "undefined" && n instanceof HTMLVideoElement, i = typeof HTMLImageElement != "undefined" && n instanceof HTMLImageElement, [p, u] = a ? [n.videoWidth, n.videoHeight] : [n.width, n.height], c = [u, p], l = [u, p, s];
if (i || a) {
- let h = P().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");
- (Sc == null || h !== Mw) && (Mw = h, Sc = document.createElement("canvas").getContext("2d", { willReadFrequently: Mw })), Sc.canvas.width = p, Sc.canvas.height = u, Sc.drawImage(n, 0, 0, p, u), n = Sc.canvas;
+ let h = O().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");
+ (bc == null || h !== Rw) && (Rw = h, bc = document.createElement("canvas").getContext("2d", { willReadFrequently: Rw })), bc.canvas.width = p, bc.canvas.height = u, bc.drawImage(n, 0, 0, p, u), n = bc.canvas;
}
- let m = t10.makeTensorInfo(c, "int32");
- t10.texData.get(m.dataId).usage = ir.PIXELS, t10.gpgpu.uploadPixelDataToTexture(t10.getTexture(m.dataId), n);
- let f = P().getBool("WEBGL_PACK") ? new Zh(l) : new Qh(l), d = t10.runWebGLProgram(f, [m], "int32");
- return t10.disposeData(m.dataId), d;
+ let m = t6.makeTensorInfo(c, "int32");
+ t6.texData.get(m.dataId).usage = ir.PIXELS, t6.gpgpu.uploadPixelDataToTexture(t6.getTexture(m.dataId), n);
+ let d = O().getBool("WEBGL_PACK") ? new zh(l) : new Vh(l), f = t6.runWebGLProgram(d, [m], "int32");
+ return t6.disposeData(m.dataId), f;
}
-function jQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m, activation: f, leakyreluAlpha: d } = o, h = I.convertConv2DDataFormat(c), g = I.computeConv2DInfo(n.shape, s.shape, p, l, u, m, false, h), y, b = [], C = a != null, w = i != null, k = f === "leakyrelu", _ = () => {
- let R = [n, s], A = (D, O) => {
- if (O === "NCHW" && D.shape.length === 1 && D.shape[0] !== 1) {
- let M = J({ inputs: { x: D }, backend: t10, attrs: { shape: [D.shape[0], 1, 1] } });
+function gQ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dataFormat: c, dilations: l, dimRoundingMode: m, activation: d, leakyreluAlpha: f } = o, h = S.convertConv2DDataFormat(c), g = S.computeConv2DInfo(n.shape, s.shape, p, l, u, m, false, h), x, b = [], C = a != null, w = i != null, k = d === "leakyrelu", _ = () => {
+ let A = [n, s], R = (D, P) => {
+ if (P === "NCHW" && D.shape.length === 1 && D.shape[0] !== 1) {
+ let M = te({ inputs: { x: D }, backend: t6, attrs: { shape: [D.shape[0], 1, 1] } });
return b.push(M), M;
}
return D;
};
- if (C && R.push(A(a, c)), w && R.push(A(i, c)), k) {
- let D = t10.makeTensorInfo([], "float32", x.createScalarValue(d, "float32"));
- R.push(D), b.push(D);
+ if (C && A.push(R(a, c)), w && A.push(R(i, c)), k) {
+ let D = t6.makeTensorInfo([], "float32", y.createScalarValue(f, "float32"));
+ A.push(D), b.push(D);
}
- return R;
+ return A;
};
if (g.filterHeight === 1 && g.filterWidth === 1 && g.dilationHeight === 1 && g.dilationWidth === 1 && g.strideHeight === 1 && g.strideWidth === 1 && (g.padInfo.type === "SAME" || g.padInfo.type === "VALID"))
- y = Dh({ x: n, filter: s, convInfo: g, backend: t10, bias: a, activation: f, preluActivationWeights: i, leakyreluAlpha: d });
- else if (g.strideWidth <= 2 && h === "channelsLast" && P().getBool("WEBGL_EXP_CONV")) {
- let R = f ? Ma(f, true) : null, A = new Cc(g, C, R, w, k), D = [[g.padInfo.top, g.padInfo.left], [g.strideHeight, g.strideWidth], [g.dilationHeight, g.dilationWidth], [g.inHeight, g.inWidth]], O = _();
- y = t10.runWebGLProgram(A, O, "float32", D);
- } else if (P().getBool("WEBGL_CONV_IM2COL"))
- y = Ph({ x: n, filter: s, convInfo: g, backend: t10, bias: a, activation: f, preluActivationWeights: i, leakyreluAlpha: d });
+ x = Ih({ x: n, filter: s, convInfo: g, backend: t6, bias: a, activation: d, preluActivationWeights: i, leakyreluAlpha: f });
+ else if (g.strideWidth <= 2 && h === "channelsLast" && O().getBool("WEBGL_EXP_CONV")) {
+ let A = d ? Wa(d, true) : null, R = new gc(g, C, A, w, k), D = [[g.padInfo.top, g.padInfo.left], [g.strideHeight, g.strideWidth], [g.dilationHeight, g.dilationWidth], [g.inHeight, g.inWidth]], P = _();
+ x = t6.runWebGLProgram(R, P, "float32", D);
+ } else if (O().getBool("WEBGL_CONV_IM2COL"))
+ x = vh({ x: n, filter: s, convInfo: g, backend: t6, bias: a, activation: d, preluActivationWeights: i, leakyreluAlpha: f });
else {
- let R = f ? Ma(f, false) : null, A = new bc(g, C, R, w, k), D = _();
- y = t10.runWebGLProgram(A, D, "float32");
+ let A = d ? Wa(d, false) : null, R = new hc(g, C, A, w, k), D = _();
+ x = t6.runWebGLProgram(R, D, "float32");
}
- let E = J({ inputs: { x: y }, backend: t10, attrs: { shape: g.outShape } });
- return b.push(y), b.forEach((R) => t10.disposeIntermediateTensorInfo(R)), E;
+ let $ = te({ inputs: { x }, backend: t6, attrs: { shape: g.outShape } });
+ return b.push(x), b.forEach((A) => t6.disposeIntermediateTensorInfo(A)), $;
}
-var UA = { kernelName: Do, backendName: "webgl", kernelFunc: jQ };
-function XQ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dilations: c, dimRoundingMode: l, activation: m, leakyreluAlpha: f } = o, d = [], h = c;
- h == null && (h = [1, 1]), x.assert(I.eitherStridesOrDilationsAreOne(p, h), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${p} and dilations '${h}'`);
- let g = I.computeConv2DInfo(n.shape, s.shape, p, h, u, l, true), y = P().getBool("WEBGL_PACK_DEPTHWISECONV") && g.strideWidth <= 2 && g.outChannels / g.inChannels === 1, b = m ? Ma(m, y) : null, C = [n, s], w = a != null, k = i != null, _ = m === "leakyrelu";
+var yR = { kernelName: ho, backendName: "webgl", kernelFunc: gQ };
+function xQ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dilations: c, dimRoundingMode: l, activation: m, leakyreluAlpha: d } = o, f = [], h = c;
+ h == null && (h = [1, 1]), y.assert(S.eitherStridesOrDilationsAreOne(p, h), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${p} and dilations '${h}'`);
+ let g = S.computeConv2DInfo(n.shape, s.shape, p, h, u, l, true), x = O().getBool("WEBGL_PACK_DEPTHWISECONV") && g.strideWidth <= 2 && g.outChannels / g.inChannels === 1, b = m ? Wa(m, x) : null, C = [n, s], w = a != null, k = i != null, _ = m === "leakyrelu";
if (w && C.push(a), k && C.push(i), _) {
- let D = t10.makeTensorInfo([], "float32", x.createScalarValue(f, "float32"));
- C.push(D), d.push(D);
+ let D = t6.makeTensorInfo([], "float32", y.createScalarValue(d, "float32"));
+ C.push(D), f.push(D);
}
- let E;
- y ? E = new wc(g, w, b, k, _) : E = new Ic(g, w, b, k, _);
- let R = [[g.padInfo.top, g.padInfo.left], [g.strideHeight, g.strideWidth], [g.dilationHeight, g.dilationWidth], [g.inHeight, g.inWidth]], A = t10.runWebGLProgram(E, C, "float32", R);
- return d.forEach((D) => t10.disposeIntermediateTensorInfo(D)), A;
+ let $;
+ x ? $ = new yc(g, w, b, k, _) : $ = new xc(g, w, b, k, _);
+ let A = [[g.padInfo.top, g.padInfo.left], [g.strideHeight, g.strideWidth], [g.dilationHeight, g.dilationWidth], [g.inHeight, g.inWidth]], R = t6.runWebGLProgram($, C, "float32", A);
+ return f.forEach((D) => t6.disposeIntermediateTensorInfo(D)), R;
}
-var GA = { kernelName: Po, backendName: "webgl", kernelFunc: XQ };
-var Jh = class {
- constructor(e, t10, o, n) {
- this.sliceDim = e, this.strides = t10, this.paramsShape = n, this.variableNames = ["x", "indices"], this.outputShape = o;
+var bR = { kernelName: go, backendName: "webgl", kernelFunc: xQ };
+var Wh = class {
+ constructor(e, t6, o, n) {
+ this.sliceDim = e, this.strides = t6, this.paramsShape = n, this.variableNames = ["x", "indices"], this.outputShape = o;
let s = _e(o.length), a = `
int index;`;
for (let i = 0; i < this.sliceDim; i++)
@@ -21720,20 +21786,20 @@ var Jh = class {
`;
}
};
-function YQ(r) {
- let { inputs: e, backend: t10 } = r, { params: o, indices: n } = e, s = n.shape, a = s[s.length - 1], i = x.sizeFromShape(o.shape), [p, u, c, l] = I.prepareAndValidate(o, n), m = J({ inputs: { x: n }, backend: t10, attrs: { shape: [u, a] } }), f = J({ inputs: { x: o }, backend: t10, attrs: { shape: [x.sizeFromShape(o.shape) / c, c] } });
- if (t10.shouldExecuteOnCPU([o, n]) || o.dtype === "string") {
- let y = t10.readSync(n.dataId), b = t10.bufferSync(o), C = d$(y, b, o.dtype, u, a, c, l, o.shape, i);
- return t10.makeTensorInfo(p, o.dtype, C.values);
+function yQ(r) {
+ let { inputs: e, backend: t6 } = r, { params: o, indices: n } = e, s = n.shape, a = s[s.length - 1], i = y.sizeFromShape(o.shape), [p, u, c, l] = S.prepareAndValidate(o, n), m = te({ inputs: { x: n }, backend: t6, attrs: { shape: [u, a] } }), d = te({ inputs: { x: o }, backend: t6, attrs: { shape: [y.sizeFromShape(o.shape) / c, c] } });
+ if (t6.shouldExecuteOnCPU([o, n]) || o.dtype === "string") {
+ let x = t6.readSync(n.dataId), b = t6.bufferSync(o), C = UE(x, b, o.dtype, u, a, c, l, o.shape, i);
+ return t6.makeTensorInfo(p, o.dtype, C.values);
}
- let d = new Jh(a, l, [u, c], o.shape), h = t10.runWebGLProgram(d, [f, m], f.dtype), g = J({ inputs: { x: h }, backend: t10, attrs: { shape: p } });
- return t10.disposeIntermediateTensorInfo(m), t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(h), g;
+ let f = new Wh(a, l, [u, c], o.shape), h = t6.runWebGLProgram(f, [d, m], d.dtype), g = te({ inputs: { x: h }, backend: t6, attrs: { shape: p } });
+ return t6.disposeIntermediateTensorInfo(m), t6.disposeIntermediateTensorInfo(d), t6.disposeIntermediateTensorInfo(h), g;
}
-var HA = { kernelName: Tn, backendName: "webgl", kernelFunc: YQ };
-var eg = class {
- constructor(e, t10) {
- this.variableNames = ["A", "indices"], this.outputShape = t10, this.rank = t10.length;
- let o = _e(this.rank), n = QQ(e, 2);
+var CR = { kernelName: un, backendName: "webgl", kernelFunc: yQ };
+var Uh = class {
+ constructor(e, t6) {
+ this.variableNames = ["A", "indices"], this.outputShape = t6, this.rank = t6.length;
+ let o = _e(this.rank), n = bQ(e, 2);
this.userCode = `
void main() {
${o} resRC = getOutputCoords();
@@ -21744,81 +21810,81 @@ var eg = class {
`;
}
};
-function QQ(r, e) {
- let t10 = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], o = [];
+function bQ(r, e) {
+ let t6 = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], o = [];
for (let n = 0; n < r.length; n++)
- n === 2 ? o.push("index") : o.push(`${t10[n]}`);
+ n === 2 ? o.push("index") : o.push(`${t6[n]}`);
return o.join();
}
-function Lw(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, indices: s } = e, { axis: a, batchDims: i } = o, p = x.parseAxisParam(a, n.shape)[0];
- if (P().get("DEBUG")) {
- let b = t10.readSync(s.dataId), C = n.shape[p];
+function Fw(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, indices: s } = e, { axis: a, batchDims: i } = o, p = y.parseAxisParam(a, n.shape)[0];
+ if (O().get("DEBUG")) {
+ let b = t6.readSync(s.dataId), C = n.shape[p];
for (let w = 0; w < b.length; ++w) {
let k = b[w];
- x.assert(k <= C - 1 && k >= 0, () => `GatherV2: the index value ${k} is not in [0, ${C - 1}]`);
+ y.assert(k <= C - 1 && k >= 0, () => `GatherV2: the index value ${k} is not in [0, ${C - 1}]`);
}
}
- let u = I.segment_util.collectGatherOpShapeInfo(n, s, p, i), c = x.sizeFromShape(s.shape), l = [], m = J({ inputs: { x: n }, backend: t10, attrs: { shape: [u.batchSize, u.outerSize, u.dimSize, u.sliceSize] } }), f = J({ inputs: { x: s }, backend: t10, attrs: { shape: [u.batchSize, c / u.batchSize] } });
- l.push(m), l.push(f);
- let d = [u.batchSize, u.outerSize, c / u.batchSize, u.sliceSize];
- if (t10.shouldExecuteOnCPU([n, s]) || n.dtype === "string") {
- let b = t10.bufferSync(f), C = t10.bufferSync(m), w = h$(C, b, d);
- return l.forEach((k) => t10.disposeIntermediateTensorInfo(k)), t10.makeTensorInfo(u.outputShape, w.dtype, w.values);
+ let u = S.segment_util.collectGatherOpShapeInfo(n, s, p, i), c = y.sizeFromShape(s.shape), l = [], m = te({ inputs: { x: n }, backend: t6, attrs: { shape: [u.batchSize, u.outerSize, u.dimSize, u.sliceSize] } }), d = te({ inputs: { x: s }, backend: t6, attrs: { shape: [u.batchSize, c / u.batchSize] } });
+ l.push(m), l.push(d);
+ let f = [u.batchSize, u.outerSize, c / u.batchSize, u.sliceSize];
+ if (t6.shouldExecuteOnCPU([n, s]) || n.dtype === "string") {
+ let b = t6.bufferSync(d), C = t6.bufferSync(m), w = GE(C, b, f);
+ return l.forEach((k) => t6.disposeIntermediateTensorInfo(k)), t6.makeTensorInfo(u.outputShape, w.dtype, w.values);
}
- let h = new eg(m.shape, d), g = t10.runWebGLProgram(h, [m, f], m.dtype);
+ let h = new Uh(m.shape, f), g = t6.runWebGLProgram(h, [m, d], m.dtype);
l.push(g);
- let y = J({ inputs: { x: g }, backend: t10, attrs: { shape: u.outputShape } });
- return l.forEach((b) => t10.disposeIntermediateTensorInfo(b)), y;
+ let x = te({ inputs: { x: g }, backend: t6, attrs: { shape: u.outputShape } });
+ return l.forEach((b) => t6.disposeIntermediateTensorInfo(b)), x;
}
-var qA = { kernelName: bs, backendName: "webgl", kernelFunc: Lw };
-var ZQ = "return float(a > b);";
-var JQ = `
+var SR = { kernelName: Ss, backendName: "webgl", kernelFunc: Fw };
+var CQ = "return float(a > b);";
+var SQ = `
return vec4(greaterThan(a, b));
`;
-var e7 = ot({ opSnippet: ZQ, packedOpSnippet: JQ, cpuKernelImpl: g$, dtype: "bool" });
-var KA = { kernelName: ao, backendName: "webgl", kernelFunc: e7 };
-var t7 = "return float(a >= b);";
-var r7 = `
+var wQ = tt({ opSnippet: CQ, packedOpSnippet: SQ, cpuKernelImpl: HE, dtype: "bool" });
+var wR = { kernelName: pn, backendName: "webgl", kernelFunc: wQ };
+var IQ = "return float(a >= b);";
+var vQ = `
return vec4(greaterThanEqual(a, b));
`;
-var o7 = ot({ opSnippet: t7, packedOpSnippet: r7, dtype: "bool", cpuKernelImpl: x$ });
-var jA = { kernelName: io, backendName: "webgl", kernelFunc: o7 };
-function n7(r) {
- let { inputs: e, backend: t10 } = r, { input: o } = e;
- return jh(o, true, t10);
+var kQ = tt({ opSnippet: IQ, packedOpSnippet: vQ, dtype: "bool", cpuKernelImpl: qE });
+var IR = { kernelName: cn, backendName: "webgl", kernelFunc: kQ };
+function NQ(r) {
+ let { inputs: e, backend: t6 } = r, { input: o } = e;
+ return Mh(o, true, t6);
}
-var XA = { kernelName: Cp, backendName: "webgl", kernelFunc: n7 };
-var s7 = "return float(!isnan(x) && !isinf(x));";
-var a7 = he({ opSnippet: s7, dtype: "bool" });
-var YA = { kernelName: Hi, backendName: "webgl", kernelFunc: a7 };
-var i7 = "return float(isinf(x));";
-var u7 = he({ opSnippet: i7, dtype: "bool" });
-var QA = { kernelName: qi, backendName: "webgl", kernelFunc: u7 };
-var p7 = "return float(isnan(x));";
-var c7 = he({ opSnippet: p7, dtype: "bool" });
-var ZA = { kernelName: ia, backendName: "webgl", kernelFunc: c7 };
-var l7 = "return float(a < b);";
-var m7 = `
+var vR = { kernelName: ni, backendName: "webgl", kernelFunc: NQ };
+var TQ = "return float(!isnan(x) && !isinf(x));";
+var _Q = ge({ opSnippet: TQ, dtype: "bool" });
+var kR = { kernelName: fa, backendName: "webgl", kernelFunc: _Q };
+var EQ = "return float(isinf(x));";
+var $Q = ge({ opSnippet: EQ, dtype: "bool" });
+var NR = { kernelName: ha, backendName: "webgl", kernelFunc: $Q };
+var AQ = "return float(isnan(x));";
+var RQ = ge({ opSnippet: AQ, dtype: "bool" });
+var TR = { kernelName: ln, backendName: "webgl", kernelFunc: RQ };
+var FQ = "return float(a < b);";
+var DQ = `
return vec4(lessThan(a, b));
`;
-var f7 = ot({ opSnippet: l7, packedOpSnippet: m7, cpuKernelImpl: y$, dtype: "bool" });
-var JA = { kernelName: po, backendName: "webgl", kernelFunc: f7 };
-var d7 = "return float(a <= b);";
-var h7 = `
+var OQ = tt({ opSnippet: FQ, packedOpSnippet: DQ, cpuKernelImpl: KE, dtype: "bool" });
+var _R = { kernelName: dn, backendName: "webgl", kernelFunc: OQ };
+var PQ = "return float(a <= b);";
+var MQ = `
return vec4(lessThanEqual(a, b));
`;
-var g7 = ot({ opSnippet: d7, packedOpSnippet: h7, cpuKernelImpl: b$, dtype: "bool" });
-var eF = { kernelName: co, backendName: "webgl", kernelFunc: g7 };
-function x7(r) {
- let { backend: e, attrs: t10 } = r, { start: o, stop: n, num: s } = t10, a = C$(o, n, s);
+var LQ = tt({ opSnippet: PQ, packedOpSnippet: MQ, cpuKernelImpl: jE, dtype: "bool" });
+var ER = { kernelName: fn, backendName: "webgl", kernelFunc: LQ };
+function BQ(r) {
+ let { backend: e, attrs: t6 } = r, { start: o, stop: n, num: s } = t6, a = XE(o, n, s);
return e.makeTensorInfo([a.length], "float32", a);
}
-var tF = { kernelName: Ip, backendName: "webgl", kernelFunc: x7 };
-var y7 = jo + `
+var $R = { kernelName: xp, backendName: "webgl", kernelFunc: BQ };
+var VQ = _o + `
return x < 0.0 ? 0./0. : log(x);
`;
-var b7 = `
+var zQ = `
vec4 result = log(x);
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);
@@ -21827,37 +21893,37 @@ var b7 = `
result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);
return result;
`;
-var C7 = he({ opSnippet: y7, packedOpSnippet: b7, cpuKernelImpl: I$ });
-var rF = { kernelName: lo, backendName: "webgl", kernelFunc: C7 };
-var I7 = jo + `
+var WQ = ge({ opSnippet: VQ, packedOpSnippet: zQ, cpuKernelImpl: YE });
+var AR = { kernelName: hn, backendName: "webgl", kernelFunc: WQ };
+var UQ = _o + `
return log(1.0 + x);
`;
-var w7 = he({ opSnippet: I7 });
-var oF = { kernelName: Ki, backendName: "webgl", kernelFunc: w7 };
-var S7 = "return float(a >= 1.0 && b >= 1.0);";
-var v7 = `
+var GQ = ge({ opSnippet: UQ });
+var RR = { kernelName: ga, backendName: "webgl", kernelFunc: GQ };
+var HQ = "return float(a >= 1.0 && b >= 1.0);";
+var qQ = `
return vec4(
vec4(greaterThanEqual(a, vec4(1.0))) *
vec4(greaterThanEqual(b, vec4(1.0))));
`;
-var k7 = ot({ opSnippet: S7, packedOpSnippet: v7, dtype: "bool" });
-var nF = { kernelName: _n, backendName: "webgl", kernelFunc: k7 };
-var T7 = "return float(!(x >= 1.0));";
-var N7 = he({ opSnippet: T7 });
-var sF = { kernelName: En, backendName: "webgl", kernelFunc: N7 };
-var _7 = "return float(a >= 1.0 || b >= 1.0);";
-var E7 = `
+var KQ = tt({ opSnippet: HQ, packedOpSnippet: qQ, dtype: "bool" });
+var FR = { kernelName: gn, backendName: "webgl", kernelFunc: KQ };
+var jQ = "return float(!(x >= 1.0));";
+var XQ = ge({ opSnippet: jQ });
+var DR = { kernelName: xn, backendName: "webgl", kernelFunc: XQ };
+var YQ = "return float(a >= 1.0 || b >= 1.0);";
+var QQ = `
return min(
vec4(greaterThanEqual(a, vec4(1.0))) +
vec4(greaterThanEqual(b, vec4(1.0))),
vec4(1.0));
`;
-var $7 = ot({ opSnippet: _7, packedOpSnippet: E7, dtype: "bool" });
-var aF = { kernelName: ua, backendName: "webgl", kernelFunc: $7 };
-var tg = class {
- constructor(e, t10, o, n, s) {
+var ZQ = tt({ opSnippet: YQ, packedOpSnippet: QQ, dtype: "bool" });
+var OR = { kernelName: xa, backendName: "webgl", kernelFunc: ZQ };
+var Gh = class {
+ constructor(e, t6, o, n, s) {
this.variableNames = ["x"], this.outputShape = [];
- let a = t10, i = e[3] - 1;
+ let a = t6, i = e[3] - 1;
this.outputShape = e;
let p, u = `float(${o}) + float(${n}) * sum`;
s === 0.5 ? p = `inversesqrt(${u})` : s === 1 ? p = `1.0/(${u})` : p = `exp(log(${u}) * float(-${s}));`, this.userCode = `
@@ -21882,10 +21948,10 @@ var tg = class {
`;
}
};
-var rg = class {
- constructor(e, t10, o, n, s) {
+var Hh = class {
+ constructor(e, t6, o, n, s) {
this.variableNames = ["x"], this.outputShape = [], this.packedInputs = true, this.packedOutput = true;
- let a = t10, i = e[3] - 1;
+ let a = t6, i = e[3] - 1;
this.outputShape = e;
let p, u = `float(${o}) + float(${n}) * sum`;
s === 0.5 ? p = `inversesqrt(${u})` : s === 1 ? p = `1.0/(${u})` : p = `exp(log(${u}) * float(-${s}));`, this.userCode = `
@@ -21953,14 +22019,14 @@ var rg = class {
`;
}
};
-var R7 = (r) => {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { depthRadius: s, bias: a, alpha: i, beta: p } = o, u = P().getBool("WEBGL_PACK_NORMALIZATION") ? new rg(n.shape, s, a, i, p) : new tg(n.shape, s, a, i, p);
- return t10.runWebGLProgram(u, [n], n.dtype);
+var JQ = (r) => {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { depthRadius: s, bias: a, alpha: i, beta: p } = o, u = O().getBool("WEBGL_PACK_NORMALIZATION") ? new Hh(n.shape, s, a, i, p) : new Gh(n.shape, s, a, i, p);
+ return t6.runWebGLProgram(u, [n], n.dtype);
};
-var iF = { kernelName: wp, backendName: "webgl", kernelFunc: R7 };
-var og = class {
- constructor(e, t10, o, n, s) {
- this.variableNames = ["inputImage", "outputImage", "dy"], this.outputShape = [], this.outputShape = e, this.depth = e[3], this.depthRadius = t10, this.bias = o, this.alpha = n, this.beta = s, this.userCode = `
+var PR = { kernelName: yp, backendName: "webgl", kernelFunc: JQ };
+var qh = class {
+ constructor(e, t6, o, n, s) {
+ this.variableNames = ["inputImage", "outputImage", "dy"], this.outputShape = [], this.outputShape = e, this.depth = e[3], this.depthRadius = t6, this.bias = o, this.alpha = n, this.beta = s, this.userCode = `
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
@@ -21969,9 +22035,9 @@ var og = class {
float result = 0.0;
for (int d = 0; d < ${this.depth}; ++d) {
- int depthBegin = int(max(0.0, float(d - ${t10})));
+ int depthBegin = int(max(0.0, float(d - ${t6})));
int depthEnd = int(min(float(${this.depth}),
- float(d + ${t10} + 1)));
+ float(d + ${t6} + 1)));
const int MIN_DEPTH_BEGIN = 0;
const int MAX_DEPTH_END = ${this.depth};
@@ -22018,78 +22084,78 @@ var og = class {
`;
}
};
-var A7 = (r) => {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, y: s, dy: a } = e, { depthRadius: i, bias: p, alpha: u, beta: c } = o, l = new og(n.shape, i, p, u, c);
- return t10.runWebGLProgram(l, [n, s, a], n.dtype);
+var e7 = (r) => {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, y: s, dy: a } = e, { depthRadius: i, bias: p, alpha: u, beta: c } = o, l = new qh(n.shape, i, p, u, c);
+ return t6.runWebGLProgram(l, [n, s, a], n.dtype);
};
-var uF = { kernelName: Om, backendName: "webgl", kernelFunc: A7 };
-function pF(r, e, t10, o) {
- let n = x.sizeFromShape(e), a = x.sizeFromShape(r.shape) / n, i = J({ inputs: { x: r }, attrs: { shape: [a, n] }, backend: o }), p = qr(i, r.dtype, "max", o), u = J({ inputs: { x: p }, attrs: { shape: t10 }, backend: o });
+var MR = { kernelName: Nm, backendName: "webgl", kernelFunc: e7 };
+function LR(r, e, t6, o) {
+ let n = y.sizeFromShape(e), a = y.sizeFromShape(r.shape) / n, i = te({ inputs: { x: r }, attrs: { shape: [a, n] }, backend: o }), p = Gr(i, r.dtype, "max", o), u = te({ inputs: { x: p }, attrs: { shape: t6 }, backend: o });
return o.disposeIntermediateTensorInfo(i), o.disposeIntermediateTensorInfo(p), u;
}
-function Bw(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { reductionIndices: s, keepDims: a } = o, i = n.shape.length, p = x.parseAxisParam(s, n.shape), u = p, c = I.getAxesPermutation(u, i), l = c != null, m = t10.shouldExecuteOnCPU([n]), f = n;
+function Dw(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { reductionIndices: s, keepDims: a } = o, i = n.shape.length, p = y.parseAxisParam(s, n.shape), u = p, c = S.getAxesPermutation(u, i), l = c != null, m = t6.shouldExecuteOnCPU([n]), d = n;
if (l) {
if (m) {
- let C = t10.texData.get(f.dataId).values, w = new Array(i);
- for (let E = 0; E < w.length; E++)
- w[E] = n.shape[c[E]];
+ let C = t6.texData.get(d.dataId).values, w = new Array(i);
+ for (let $ = 0; $ < w.length; $++)
+ w[$] = n.shape[c[$]];
let k = Du(C, n.shape, n.dtype, c, w);
- f = t10.makeTensorInfo(w, n.dtype);
- let _ = t10.texData.get(f.dataId);
+ d = t6.makeTensorInfo(w, n.dtype);
+ let _ = t6.texData.get(d.dataId);
_.values = k;
} else
- f = _i(n, c, t10);
- u = I.getInnerMostAxes(u.length, i);
+ d = Vi(n, c, t6);
+ u = S.getInnerMostAxes(u.length, i);
}
- I.assertAxesAreInnerMostDims("max", u, i);
- let [d, h] = I.computeOutAndReduceShapes(f.shape, u), g = d;
- a && (g = I.expandShapeToKeepDim(d, p));
- let y;
+ S.assertAxesAreInnerMostDims("max", u, i);
+ let [f, h] = S.computeOutAndReduceShapes(d.shape, u), g = f;
+ a && (g = S.expandShapeToKeepDim(f, p));
+ let x;
if (m) {
- let C = t10.texData.get(f.dataId).values, w = w$(C, x.sizeFromShape(h), g, n.dtype);
- y = t10.makeTensorInfo(g, n.dtype);
- let k = t10.texData.get(y.dataId);
+ let C = t6.texData.get(d.dataId).values, w = QE(C, y.sizeFromShape(h), g, n.dtype);
+ x = t6.makeTensorInfo(g, n.dtype);
+ let k = t6.texData.get(x.dataId);
k.values = w;
} else
- y = pF(f, h, g, t10);
- return l && t10.disposeIntermediateTensorInfo(f), y;
+ x = LR(d, h, g, t6);
+ return l && t6.disposeIntermediateTensorInfo(d), x;
}
-var cF = { kernelName: $n, backendName: "webgl", kernelFunc: Bw };
-var F7 = gc + `
+var BR = { kernelName: yn, backendName: "webgl", kernelFunc: Dw };
+var t7 = mc + `
return max(a, b);
`;
-var D7 = `
+var r7 = `
vec4 result = vec4(max(a, b));
bvec4 isNaNA = isnan(a);
bvec4 isNaNB = isnan(b);
bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);
- ` + js + `
+ ` + Zs + `
return result;
`;
-var P7 = ot({ opSnippet: F7, packedOpSnippet: D7, cpuKernelImpl: S$ });
-var lF = { kernelName: mo, backendName: "webgl", kernelFunc: P7 };
-function O7(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e;
- as(n, "maxPool");
+var o7 = tt({ opSnippet: t7, packedOpSnippet: r7, cpuKernelImpl: ZE });
+var VR = { kernelName: bn, backendName: "webgl", kernelFunc: o7 };
+function n7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e;
+ is(n, "maxPool");
let { filterSize: s, strides: a, pad: i, dimRoundingMode: p } = o, u = 1;
- x.assert(I.eitherStridesOrDilationsAreOne(a, u), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
- let c = I.computePool2DInfo(n.shape, s, a, u, i, p);
- if (c.filterWidth === 1 && c.filterHeight === 1 && x.arraysEqual(c.inShape, c.outShape))
- return Rt({ inputs: { x: n }, backend: t10 });
- let l = new us(c, "max", false);
- return t10.runWebGLProgram(l, [n], n.dtype);
+ y.assert(S.eitherStridesOrDilationsAreOne(a, u), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
+ let c = S.computePool2DInfo(n.shape, s, a, u, i, p);
+ if (c.filterWidth === 1 && c.filterHeight === 1 && y.arraysEqual(c.inShape, c.outShape))
+ return At({ inputs: { x: n }, backend: t6 });
+ let l = new ps(c, "max", false);
+ return t6.runWebGLProgram(l, [n], n.dtype);
}
-var mF = { kernelName: Rn, backendName: "webgl", kernelFunc: O7 };
-function M7(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { filterSize: s, strides: a, pad: i, dataFormat: p, dimRoundingMode: u } = o, c = [1, 1, 1], l = I.computePool3DInfo(n.shape, s, a, c, i, u, p), m = new Ei(l, "max", false);
- return t10.runWebGLProgram(m, [n], n.dtype);
+var zR = { kernelName: Cn, backendName: "webgl", kernelFunc: n7 };
+function s7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { filterSize: s, strides: a, pad: i, dataFormat: p, dimRoundingMode: u } = o, c = [1, 1, 1], l = S.computePool3DInfo(n.shape, s, a, c, i, u, p), m = new zi(l, "max", false);
+ return t6.runWebGLProgram(m, [n], n.dtype);
}
-var fF = { kernelName: Sp, backendName: "webgl", kernelFunc: M7 };
-var ng = class {
+var WR = { kernelName: bp, backendName: "webgl", kernelFunc: s7 };
+var Kh = class {
constructor(e) {
this.variableNames = ["dy", "maxPos"], this.outputShape = e.inShape;
- let t10 = e.strideHeight, o = e.strideWidth, n = e.dilationHeight, s = e.effectiveFilterHeight, a = e.effectiveFilterWidth, i = s - 1 - e.padInfo.top, p = a - 1 - e.padInfo.left, u = s * a - 1;
+ let t6 = e.strideHeight, o = e.strideWidth, n = e.dilationHeight, s = e.effectiveFilterHeight, a = e.effectiveFilterWidth, i = s - 1 - e.padInfo.top, p = a - 1 - e.padInfo.left, u = s * a - 1;
this.userCode = `
const ivec2 pads = ivec2(${i}, ${p});
@@ -22107,7 +22173,7 @@ var ng = class {
float dotProd = 0.0;
for (int wR = 0; wR < ${s};
wR += ${n}) {
- float dyR = float(dyRCorner + wR) / ${t10}.0;
+ float dyR = float(dyRCorner + wR) / ${t6}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
@@ -22139,12 +22205,12 @@ var ng = class {
`;
}
};
-var sg = class {
+var jh = class {
constructor(e) {
this.variableNames = ["dy", "maxPos"], this.outputShape = e.inShape;
- let t10 = e.strideDepth, o = e.strideHeight, n = e.strideWidth, s = e.dilationDepth, a = e.dilationHeight, i = e.dilationWidth, p = e.effectiveFilterDepth, u = e.effectiveFilterHeight, c = e.effectiveFilterWidth, l = p - 1 - e.padInfo.front, m = u - 1 - e.padInfo.top, f = c - 1 - e.padInfo.left, d = p * u * c - 1;
+ let t6 = e.strideDepth, o = e.strideHeight, n = e.strideWidth, s = e.dilationDepth, a = e.dilationHeight, i = e.dilationWidth, p = e.effectiveFilterDepth, u = e.effectiveFilterHeight, c = e.effectiveFilterWidth, l = p - 1 - e.padInfo.front, m = u - 1 - e.padInfo.top, d = c - 1 - e.padInfo.left, f = p * u * c - 1;
this.userCode = `
- const ivec3 pads = ivec3(${l}, ${m}, ${f});
+ const ivec3 pads = ivec3(${l}, ${m}, ${d});
void main() {
ivec5 coords = getOutputCoords();
@@ -22163,7 +22229,7 @@ var sg = class {
for (int wD = 0; wD < ${p};
wD += ${s}) {
- float dyD = float(dyDCorner + wD) / ${t10}.0;
+ float dyD = float(dyDCorner + wD) / ${t6}.0;
if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
continue;
@@ -22191,7 +22257,7 @@ var sg = class {
int idyC = int(dyC);
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
- int maxPosValue = ${d} -
+ int maxPosValue = ${f} -
int(getMaxPos(batch, idyD, idyR, idyC, ch));
// Get the current value, check it against the value from the
@@ -22210,88 +22276,88 @@ var sg = class {
`;
}
};
-function L7(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, input: s } = e, a = s, { filterSize: i, strides: p, pad: u, dimRoundingMode: c } = o, l = [1, 1, 1], m = I.computePool3DInfo(a.shape, i, p, l, u, c), f = new Ei(m, "max", true), d = t10.runWebGLProgram(f, [a], a.dtype), h = new sg(m), g = t10.runWebGLProgram(h, [n, d], a.dtype);
- return t10.disposeIntermediateTensorInfo(d), g;
+function a7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, input: s } = e, a = s, { filterSize: i, strides: p, pad: u, dimRoundingMode: c } = o, l = [1, 1, 1], m = S.computePool3DInfo(a.shape, i, p, l, u, c), d = new zi(m, "max", true), f = t6.runWebGLProgram(d, [a], a.dtype), h = new jh(m), g = t6.runWebGLProgram(h, [n, f], a.dtype);
+ return t6.disposeIntermediateTensorInfo(f), g;
}
-var dF = { kernelName: Lm, backendName: "webgl", kernelFunc: L7 };
-function B7(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { dy: n, input: s, output: a } = e, i = s;
- as([s, a], "maxPoolGrad");
- let { filterSize: p, strides: u, pad: c, dimRoundingMode: l } = o, m = I.computePool2DInfo(i.shape, p, u, 1, c, l), f = true, d = new us(m, "max", f), h = t10.runWebGLProgram(d, [i], i.dtype), g = new ng(m), y = t10.runWebGLProgram(g, [n, h], i.dtype);
- return t10.disposeIntermediateTensorInfo(h), y;
+var UR = { kernelName: _m, backendName: "webgl", kernelFunc: a7 };
+function i7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { dy: n, input: s, output: a } = e, i = s;
+ is([s, a], "maxPoolGrad");
+ let { filterSize: p, strides: u, pad: c, dimRoundingMode: l } = o, m = S.computePool2DInfo(i.shape, p, u, 1, c, l), d = true, f = new ps(m, "max", d), h = t6.runWebGLProgram(f, [i], i.dtype), g = new Kh(m), x = t6.runWebGLProgram(g, [n, h], i.dtype);
+ return t6.disposeIntermediateTensorInfo(h), x;
}
-var hF = { kernelName: Mm, backendName: "webgl", kernelFunc: B7 };
-function gF(r, e, t10, o) {
- let n = new us(t10, "max", false), s = o.runWebGLProgram(n, [r], "float32");
- n = new us(t10, "max", true, true, e);
+var GR = { kernelName: Tm, backendName: "webgl", kernelFunc: i7 };
+function HR(r, e, t6, o) {
+ let n = new ps(t6, "max", false), s = o.runWebGLProgram(n, [r], "float32");
+ n = new ps(t6, "max", true, true, e);
let a = o.runWebGLProgram(n, [r], "float32");
return [s, a];
}
-var xF = { kernelName: vp, backendName: "webgl", kernelFunc: ({ inputs: r, attrs: e, backend: t10 }) => {
- let { x: o } = r, { filterSize: n, strides: s, pad: a, includeBatchInIndex: i } = e, p = t10;
- x.assert(o.shape.length === 4, () => `Error in maxPool: input must be rank 4 but got rank ${o.shape.length}.`);
+var qR = { kernelName: Cp, backendName: "webgl", kernelFunc: ({ inputs: r, attrs: e, backend: t6 }) => {
+ let { x: o } = r, { filterSize: n, strides: s, pad: a, includeBatchInIndex: i } = e, p = t6;
+ y.assert(o.shape.length === 4, () => `Error in maxPool: input must be rank 4 but got rank ${o.shape.length}.`);
let u = [1, 1];
- x.assert(I.eitherStridesOrDilationsAreOne(s, u), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '${u}'`);
- let c = I.computePool2DInfo(o.shape, n, s, u, a), [l, m] = gF(o, i, c, p);
+ y.assert(S.eitherStridesOrDilationsAreOne(s, u), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '${u}'`);
+ let c = S.computePool2DInfo(o.shape, n, s, u, a), [l, m] = HR(o, i, c, p);
return [l, m];
} };
-function yF(r, e, t10, o) {
- let n = x.sizeFromShape(e), a = x.sizeFromShape(r.shape) / n, i = J({ inputs: { x: r }, attrs: { shape: [a, n] }, backend: o }), p = qr(i, "float32", "mean", o), u = J({ inputs: { x: p }, attrs: { shape: t10 }, backend: o });
+function KR(r, e, t6, o) {
+ let n = y.sizeFromShape(e), a = y.sizeFromShape(r.shape) / n, i = te({ inputs: { x: r }, attrs: { shape: [a, n] }, backend: o }), p = Gr(i, "float32", "mean", o), u = te({ inputs: { x: p }, attrs: { shape: t6 }, backend: o });
return o.disposeIntermediateTensorInfo(i), o.disposeIntermediateTensorInfo(p), u;
}
-var bF = { kernelName: An, backendName: "webgl", kernelFunc: ({ inputs: r, attrs: e, backend: t10 }) => {
- let { x: o } = r, { keepDims: n, axis: s } = e, a = t10, i = o.shape.length, p = x.parseAxisParam(s, o.shape), u = p, c = I.getAxesPermutation(u, i), l = c != null, m = a.shouldExecuteOnCPU([o]), f = [], d = o;
+var jR = { kernelName: Sn, backendName: "webgl", kernelFunc: ({ inputs: r, attrs: e, backend: t6 }) => {
+ let { x: o } = r, { keepDims: n, axis: s } = e, a = t6, i = o.shape.length, p = y.parseAxisParam(s, o.shape), u = p, c = S.getAxesPermutation(u, i), l = c != null, m = a.shouldExecuteOnCPU([o]), d = [], f = o;
if (l) {
if (m) {
- let w = a.texData.get(d.dataId).values, k = new Array(i);
- for (let R = 0; R < k.length; R++)
- k[R] = o.shape[c[R]];
+ let w = a.texData.get(f.dataId).values, k = new Array(i);
+ for (let A = 0; A < k.length; A++)
+ k[A] = o.shape[c[A]];
let _ = Du(w, o.shape, o.dtype, c, k);
- d = a.makeTensorInfo(k, o.dtype);
- let E = a.texData.get(d.dataId);
- E.values = _;
+ f = a.makeTensorInfo(k, o.dtype);
+ let $ = a.texData.get(f.dataId);
+ $.values = _;
} else
- d = _i(o, c, a);
- f.push(d), u = I.getInnerMostAxes(u.length, i);
+ f = Vi(o, c, a);
+ d.push(f), u = S.getInnerMostAxes(u.length, i);
}
- I.assertAxesAreInnerMostDims("sum", u, i);
- let [h, g] = I.computeOutAndReduceShapes(d.shape, u), y = h;
- n && (y = I.expandShapeToKeepDim(h, p));
- let b = yF(d, g, y, a);
- for (let C of f)
+ S.assertAxesAreInnerMostDims("sum", u, i);
+ let [h, g] = S.computeOutAndReduceShapes(f.shape, u), x = h;
+ n && (x = S.expandShapeToKeepDim(h, p));
+ let b = KR(f, g, x, a);
+ for (let C of d)
a.disposeIntermediateTensorInfo(C);
return b;
} };
-function V7(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = n.shape.length, p = x.parseAxisParam(s, n.shape), u = p, c = I.getAxesPermutation(u, i), l = n;
- c != null && (l = xt({ inputs: { x: n }, backend: t10, attrs: { perm: c } }), u = I.getInnerMostAxes(u.length, n.shape.length)), I.assertAxesAreInnerMostDims("min", u, i);
- let [m, f] = I.computeOutAndReduceShapes(l.shape, u), d = x.sizeFromShape(f), h = J({ inputs: { x: l }, backend: t10, attrs: { shape: [-1, d] } }), g = qr(h, h.dtype, "min", t10), y;
+function u7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = n.shape.length, p = y.parseAxisParam(s, n.shape), u = p, c = S.getAxesPermutation(u, i), l = n;
+ c != null && (l = xt({ inputs: { x: n }, backend: t6, attrs: { perm: c } }), u = S.getInnerMostAxes(u.length, n.shape.length)), S.assertAxesAreInnerMostDims("min", u, i);
+ let [m, d] = S.computeOutAndReduceShapes(l.shape, u), f = y.sizeFromShape(d), h = te({ inputs: { x: l }, backend: t6, attrs: { shape: [-1, f] } }), g = Gr(h, h.dtype, "min", t6), x;
if (a) {
- let b = I.expandShapeToKeepDim(m, p);
- y = J({ inputs: { x: g }, backend: t10, attrs: { shape: b } });
+ let b = S.expandShapeToKeepDim(m, p);
+ x = te({ inputs: { x: g }, backend: t6, attrs: { shape: b } });
} else
- y = J({ inputs: { x: g }, backend: t10, attrs: { shape: m } });
- return t10.disposeIntermediateTensorInfo(h), t10.disposeIntermediateTensorInfo(g), c != null && t10.disposeIntermediateTensorInfo(l), y;
+ x = te({ inputs: { x: g }, backend: t6, attrs: { shape: m } });
+ return t6.disposeIntermediateTensorInfo(h), t6.disposeIntermediateTensorInfo(g), c != null && t6.disposeIntermediateTensorInfo(l), x;
}
-var CF = { kernelName: Fn, backendName: "webgl", kernelFunc: V7 };
-var z7 = gc + `
+var XR = { kernelName: wn, backendName: "webgl", kernelFunc: u7 };
+var p7 = mc + `
return min(a, b);
`;
-var W7 = `
+var c7 = `
vec4 result = vec4(min(a, b));
bvec4 isNaNA = isnan(a);
bvec4 isNaNB = isnan(b);
bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);
- ` + js + `
+ ` + Zs + `
return result;
`;
-var U7 = ot({ opSnippet: z7, packedOpSnippet: W7, cpuKernelImpl: v$ });
-var IF = { kernelName: fo, backendName: "webgl", kernelFunc: U7 };
-var ag = class {
- constructor(e, t10, o) {
- this.variableNames = ["x"], this.outputShape = t10.map((c, l) => c[0] + e[l] + c[1]);
- let n = e.length, s = _e(n), a = t10.map((c) => c[0]).join(","), i = t10.map((c, l) => c[0] + e[l]).join(","), p = ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, n), u = o === "reflect" ? 0 : 1;
+var l7 = tt({ opSnippet: p7, packedOpSnippet: c7, cpuKernelImpl: JE });
+var YR = { kernelName: In, backendName: "webgl", kernelFunc: l7 };
+var Xh = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["x"], this.outputShape = t6.map((c, l) => c[0] + e[l] + c[1]);
+ let n = e.length, s = _e(n), a = t6.map((c) => c[0]).join(","), i = t6.map((c, l) => c[0] + e[l]).join(","), p = ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, n), u = o === "reflect" ? 0 : 1;
if (n === 1) {
this.userCode = `
int start = ${a};
@@ -22328,12 +22394,12 @@ var ag = class {
`;
}
};
-var ig = class {
- constructor(e, t10, o) {
- this.variableNames = ["x"], this.packedInputs = true, this.packedOutput = true, this.outputShape = t10.map((d, h) => d[0] + e[h] + d[1]);
- let n = e.length, s = _e(n), a = t10.map((d) => d[0]).join(","), i = t10.map((d, h) => d[0] + e[h]).join(","), p = $t("rc", n), u = $t("source", n), c = `${p[n - 1]} < ${this.outputShape[n - 1]}`, l = n === 1 ? "source" : `vec2(${u.slice(-2).join()})`, m = o === "reflect" ? 0 : 1, f = "";
+var Yh = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["x"], this.packedInputs = true, this.packedOutput = true, this.outputShape = t6.map((f, h) => f[0] + e[h] + f[1]);
+ let n = e.length, s = _e(n), a = t6.map((f) => f[0]).join(","), i = t6.map((f, h) => f[0] + e[h]).join(","), p = $t("rc", n), u = $t("source", n), c = `${p[n - 1]} < ${this.outputShape[n - 1]}`, l = n === 1 ? "source" : `vec2(${u.slice(-2).join()})`, m = o === "reflect" ? 0 : 1, d = "";
if (n === 1) {
- let d = `
+ let f = `
${s} source = rc;
if (source < start) {
source = start * 2 - source - ${m};
@@ -22342,18 +22408,18 @@ var ig = class {
}
source -= start;
`;
- f = `
+ d = `
${s} rc = outputLoc;
- ${d}
+ ${f}
result[0] = getChannel(getX(${u.join()}), ${l});
${p[n - 1]} += 1;
if(${c}) {
- ${d}
+ ${f}
result[1] = getChannel(getX(${u.join()}), ${l});
}
`;
} else {
- let d = `
+ let f = `
${s} source = rc;
${s} lt = ${s}(lessThan(source, start));
${s} gte = ${s}(greaterThanEqual(source, end));
@@ -22363,23 +22429,23 @@ var ig = class {
gte * ((end - 1) * 2 - source + ${m});
source -= start;
`;
- f = `
+ d = `
${s} rc = outputLoc;
- ${d}
+ ${f}
result[0] = getChannel(getX(${u.join()}), ${l});
${p[n - 1]} += 1;
if(${c}) {
- ${d}
+ ${f}
result[1] = getChannel(getX(${u.join()}), ${l});
}
rc = outputLoc;
${p[n - 2]} += 1;
if(${p[n - 2]} < ${this.outputShape[n - 2]}) {
- ${d}
+ ${f}
result[2] = getChannel(getX(${u.join()}), ${l});
${p[n - 1]} += 1;
if(${c}) {
- ${d}
+ ${f}
result[3] = getChannel(getX(${u.join()}), ${l});
}
}
@@ -22392,29 +22458,29 @@ var ig = class {
void main() {
${s} outputLoc = getOutputCoords();
vec4 result = vec4(0.);
- ${f}
+ ${d}
setOutput(result);
}
`;
}
};
-var G7 = ({ inputs: r, backend: e, attrs: t10 }) => {
- let { x: o } = r, { paddings: n, mode: s } = t10, a = P().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new ig(o.shape, n, s) : new ag(o.shape, n, s);
+var m7 = ({ inputs: r, backend: e, attrs: t6 }) => {
+ let { x: o } = r, { paddings: n, mode: s } = t6, a = O().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new Yh(o.shape, n, s) : new Xh(o.shape, n, s);
return e.runWebGLProgram(a, [o], o.dtype);
};
-var wF = { kernelName: Dn, backendName: "webgl", kernelFunc: G7 };
-var H7 = `if (b == 0.0) return NAN;
+var QR = { kernelName: vn, backendName: "webgl", kernelFunc: m7 };
+var d7 = `if (b == 0.0) return NAN;
return mod(a, b);`;
-var q7 = `
+var f7 = `
vec4 result = mod(a, b);
bvec4 isNaN = equal(b, vec4(0.0));
- ` + js + `
+ ` + Zs + `
return result;
`;
-var K7 = ot({ opSnippet: H7, packedOpSnippet: q7 });
-var SF = { kernelName: ji, backendName: "webgl", kernelFunc: K7 };
-var ug = class {
- constructor(e, t10, o) {
+var h7 = tt({ opSnippet: d7, packedOpSnippet: f7 });
+var ZR = { kernelName: ya, backendName: "webgl", kernelFunc: h7 };
+var Qh = class {
+ constructor(e, t6, o) {
this.variableNames = ["probs"], this.customUniforms = [{ name: "seed", type: "float" }], this.outputShape = [e, o], this.userCode = `
void main() {
ivec2 coords = getOutputCoords();
@@ -22423,7 +22489,7 @@ var ug = class {
float r = random(seed);
float cdf = 0.0;
- for (int i = 0; i < ${t10 - 1}; i++) {
+ for (int i = 0; i < ${t6 - 1}; i++) {
cdf += getProbs(batch, i);
if (r < cdf) {
@@ -22433,17 +22499,17 @@ var ug = class {
}
// If no other event happened, last event happened.
- setOutput(float(${t10 - 1}));
+ setOutput(float(${t6 - 1}));
}
`;
}
};
-var j7 = `
+var g7 = `
if (a == b) {
return 1.0;
};
return a / b;`;
-var X7 = `
+var x7 = `
// vec4 one = vec4(equal(a, b));
// return one + (vec4(1.0) - one) * a / b;
vec4 result = a / b;
@@ -22462,25 +22528,25 @@ var X7 = `
return result;
`;
-var Vw = ot({ opSnippet: j7, packedOpSnippet: X7, checkOutOfBounds: true });
-var vF = { kernelName: Cn, backendName: "webgl", kernelFunc: Vw };
-var kF = "return a - b;";
-var zw = ot({ opSnippet: kF, packedOpSnippet: kF, supportsComplex: true, cpuKernelImpl: G$ });
-var TF = { kernelName: Io, backendName: "webgl", kernelFunc: zw };
-function Ww(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { logits: n } = e, { dim: s } = o, a = x.parseAxisParam([s], n.shape), i = Bw({ inputs: { x: n }, backend: t10, attrs: { reductionIndices: a, keepDims: false } }), p = I.expandShapeToKeepDim(i.shape, a), u = J({ inputs: { x: i }, backend: t10, attrs: { shape: p } }), c = zw({ inputs: { a: n, b: u }, backend: t10 }), l = Ow({ inputs: { x: c }, backend: t10 }), m = Ou({ inputs: { x: l }, backend: t10, attrs: { axis: a, keepDims: false } }), f = J({ inputs: { x: m }, backend: t10, attrs: { shape: p } }), d = Vw({ inputs: { a: l, b: f }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(i), t10.disposeIntermediateTensorInfo(u), t10.disposeIntermediateTensorInfo(c), t10.disposeIntermediateTensorInfo(l), t10.disposeIntermediateTensorInfo(m), t10.disposeIntermediateTensorInfo(f), d;
+var Ow = tt({ opSnippet: g7, packedOpSnippet: x7, checkOutOfBounds: true });
+var JR = { kernelName: Jo, backendName: "webgl", kernelFunc: Ow };
+var eF = "return a - b;";
+var Pw = tt({ opSnippet: eF, packedOpSnippet: eF, supportsComplex: true, cpuKernelImpl: b$ });
+var tF = { kernelName: Xn, backendName: "webgl", kernelFunc: Pw };
+function Mw(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { logits: n } = e, { dim: s } = o, a = y.parseAxisParam([s], n.shape), i = Dw({ inputs: { x: n }, backend: t6, attrs: { reductionIndices: a, keepDims: false } }), p = S.expandShapeToKeepDim(i.shape, a), u = te({ inputs: { x: i }, backend: t6, attrs: { shape: p } }), c = Pw({ inputs: { a: n, b: u }, backend: t6 }), l = Aw({ inputs: { x: c }, backend: t6 }), m = Ou({ inputs: { x: l }, backend: t6, attrs: { axis: a, keepDims: false } }), d = te({ inputs: { x: m }, backend: t6, attrs: { shape: p } }), f = Ow({ inputs: { a: l, b: d }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(i), t6.disposeIntermediateTensorInfo(u), t6.disposeIntermediateTensorInfo(c), t6.disposeIntermediateTensorInfo(l), t6.disposeIntermediateTensorInfo(m), t6.disposeIntermediateTensorInfo(d), f;
}
-var NF = { kernelName: Xn, backendName: "webgl", kernelFunc: Ww };
-function Y7(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { logits: n } = e, { numSamples: s, seed: a, normalized: i } = o, p = i ? n : Ww({ inputs: { logits: n }, backend: t10, attrs: { dim: n.shape.length - 1 } }), u = p.shape[0], c = p.shape[1], l = new ug(u, c, s), m = [[a]], f = t10.runWebGLProgram(l, [p], "int32", m);
- return i || t10.disposeIntermediateTensorInfo(p), f;
+var rF = { kernelName: qn, backendName: "webgl", kernelFunc: Mw };
+function y7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { logits: n } = e, { numSamples: s, seed: a, normalized: i } = o, p = i ? n : Mw({ inputs: { logits: n }, backend: t6, attrs: { dim: n.shape.length - 1 } }), u = p.shape[0], c = p.shape[1], l = new Qh(u, c, s), m = [[a]], d = t6.runWebGLProgram(l, [p], "int32", m);
+ return i || t6.disposeIntermediateTensorInfo(p), d;
}
-var _F = { kernelName: kp, backendName: "webgl", kernelFunc: Y7 };
-var Q7 = Vt + `
+var oF = { kernelName: Sp, backendName: "webgl", kernelFunc: y7 };
+var b7 = Bt + `
return -x;
`;
-var Z7 = `
+var C7 = `
vec4 result = -x;
bvec4 isNaN = isnan(x);
@@ -22491,40 +22557,40 @@ var Z7 = `
return result;
`;
-function J7(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
- if (t10.shouldExecuteOnCPU([o])) {
- let s = t10.texData.get(o.dataId), [a, i] = T$(s.values, o.shape, o.dtype);
- return t10.makeTensorInfo(i, o.dtype, a);
+function S7(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e;
+ if (t6.shouldExecuteOnCPU([o])) {
+ let s = t6.texData.get(o.dataId), [a, i] = t$(s.values, o.shape, o.dtype);
+ return t6.makeTensorInfo(i, o.dtype, a);
}
let n;
- return P().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? n = new No(o.shape, Z7) : n = new fr(o.shape, Q7), t10.runWebGLProgram(n, [o], o.dtype);
+ return O().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? n = new Ar(o.shape, C7) : n = new Jt(o.shape, b7), t6.runWebGLProgram(n, [o], o.dtype);
}
-var EF = { kernelName: Pn, backendName: "webgl", kernelFunc: J7 };
-var eZ = Bt.nonMaxSuppressionV3Impl;
-function tZ(r) {
- I.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");
- let { inputs: e, backend: t10, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p } = o, u = t10.readSync(n.dataId), c = t10.readSync(s.dataId), { selectedIndices: l } = eZ(u, c, a, i, p);
- return t10.makeTensorInfo([l.length], "int32", new Int32Array(l));
+var nF = { kernelName: ws, backendName: "webgl", kernelFunc: S7 };
+var w7 = Lt.nonMaxSuppressionV3Impl;
+function I7(r) {
+ S.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");
+ let { inputs: e, backend: t6, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p } = o, u = t6.readSync(n.dataId), c = t6.readSync(s.dataId), { selectedIndices: l } = w7(u, c, a, i, p);
+ return t6.makeTensorInfo([l.length], "int32", new Int32Array(l));
}
-var $F = { kernelName: On, backendName: "webgl", kernelFunc: tZ };
-var rZ = Bt.nonMaxSuppressionV4Impl;
-function oZ(r) {
- I.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");
- let { inputs: e, backend: t10, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p, padToMaxOutputSize: u } = o, c = t10.readSync(n.dataId), l = t10.readSync(s.dataId), { selectedIndices: m, validOutputs: f } = rZ(c, l, a, i, p, u);
- return [t10.makeTensorInfo([m.length], "int32", new Int32Array(m)), t10.makeTensorInfo([], "int32", new Int32Array([f]))];
+var sF = { kernelName: Tn, backendName: "webgl", kernelFunc: I7 };
+var v7 = Lt.nonMaxSuppressionV4Impl;
+function k7(r) {
+ S.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");
+ let { inputs: e, backend: t6, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p, padToMaxOutputSize: u } = o, c = t6.readSync(n.dataId), l = t6.readSync(s.dataId), { selectedIndices: m, validOutputs: d } = v7(c, l, a, i, p, u);
+ return [t6.makeTensorInfo([m.length], "int32", new Int32Array(m)), t6.makeTensorInfo([], "int32", new Int32Array([d]))];
}
-var RF = { kernelName: pa, backendName: "webgl", kernelFunc: oZ };
-var nZ = Bt.nonMaxSuppressionV5Impl;
-function sZ(r) {
- I.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");
- let { inputs: e, backend: t10, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p, softNmsSigma: u } = o, c = t10.readSync(n.dataId), l = t10.readSync(s.dataId), m = a, f = i, d = p, h = u, { selectedIndices: g, selectedScores: y } = nZ(c, l, m, f, d, h);
- return [t10.makeTensorInfo([g.length], "int32", new Int32Array(g)), t10.makeTensorInfo([y.length], "float32", new Float32Array(y))];
+var aF = { kernelName: ba, backendName: "webgl", kernelFunc: k7 };
+var N7 = Lt.nonMaxSuppressionV5Impl;
+function T7(r) {
+ S.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");
+ let { inputs: e, backend: t6, attrs: o } = r, { boxes: n, scores: s } = e, { maxOutputSize: a, iouThreshold: i, scoreThreshold: p, softNmsSigma: u } = o, c = t6.readSync(n.dataId), l = t6.readSync(s.dataId), m = a, d = i, f = p, h = u, { selectedIndices: g, selectedScores: x } = N7(c, l, m, d, f, h);
+ return [t6.makeTensorInfo([g.length], "int32", new Int32Array(g)), t6.makeTensorInfo([x.length], "float32", new Float32Array(x))];
}
-var AF = { kernelName: Mn, backendName: "webgl", kernelFunc: sZ };
-var pg = class {
- constructor(e, t10, o, n) {
- this.variableNames = ["indices"], this.outputShape = [e, t10], this.userCode = `
+var iF = { kernelName: _n, backendName: "webgl", kernelFunc: T7 };
+var Zh = class {
+ constructor(e, t6, o, n) {
+ this.variableNames = ["indices"], this.outputShape = [e, t6], this.userCode = `
void main() {
ivec2 coords = getOutputCoords();
int index = round(getIndices(coords.x));
@@ -22534,52 +22600,52 @@ var pg = class {
`;
}
};
-var aZ = (r) => {
- let { inputs: e, backend: t10, attrs: o } = r, { indices: n } = e, { dtype: s, depth: a, onValue: i, offValue: p } = o, u = x.sizeFromShape(n.shape), c = new pg(u, a, i, p), l = J({ inputs: { x: n }, backend: t10, attrs: { shape: [u] } }), m = t10.runWebGLProgram(c, [l], s);
- t10.disposeIntermediateTensorInfo(l);
- let f = [...n.shape, a], d = J({ inputs: { x: m }, backend: t10, attrs: { shape: f } });
- return t10.disposeIntermediateTensorInfo(m), d;
+var _7 = (r) => {
+ let { inputs: e, backend: t6, attrs: o } = r, { indices: n } = e, { dtype: s, depth: a, onValue: i, offValue: p } = o, u = y.sizeFromShape(n.shape), c = new Zh(u, a, i, p), l = te({ inputs: { x: n }, backend: t6, attrs: { shape: [u] } }), m = t6.runWebGLProgram(c, [l], s);
+ t6.disposeIntermediateTensorInfo(l);
+ let d = [...n.shape, a], f = te({ inputs: { x: m }, backend: t6, attrs: { shape: d } });
+ return t6.disposeIntermediateTensorInfo(m), f;
};
-var FF = { kernelName: ca, backendName: "webgl", kernelFunc: aZ };
-function Bl(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
+var uF = { kernelName: En, backendName: "webgl", kernelFunc: _7 };
+function Al(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e;
if (o.dtype === "complex64") {
- let n = La({ inputs: { input: o }, backend: t10 }), s = Bl({ inputs: { x: n }, backend: t10 }), a = Lu({ inputs: { input: o }, backend: t10 }), i = Bl({ inputs: { x: a }, backend: t10 }), p = Ar({ inputs: { real: s, imag: i }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(n), t10.disposeIntermediateTensorInfo(s), t10.disposeIntermediateTensorInfo(a), t10.disposeIntermediateTensorInfo(i), p;
+ let n = Ua({ inputs: { input: o }, backend: t6 }), s = Al({ inputs: { x: n }, backend: t6 }), a = Mu({ inputs: { input: o }, backend: t6 }), i = Al({ inputs: { x: a }, backend: t6 }), p = Rr({ inputs: { real: s, imag: i }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(n), t6.disposeIntermediateTensorInfo(s), t6.disposeIntermediateTensorInfo(a), t6.disposeIntermediateTensorInfo(i), p;
} else
- return Ba({ attrs: { shape: o.shape, dtype: o.dtype, value: o.dtype === "string" ? "" : 0 }, backend: t10 });
+ return Ga({ attrs: { shape: o.shape, dtype: o.dtype, value: o.dtype === "string" ? "" : 0 }, backend: t6 });
}
-var DF = { kernelName: Es, backendName: "webgl", kernelFunc: Bl };
-function PF(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
+var pF = { kernelName: Fs, backendName: "webgl", kernelFunc: Al };
+function cF(r) {
+ let { inputs: e, backend: t6 } = r, { x: o } = e;
if (o.dtype === "string")
throw new Error("onesLike is not supported under string dtype");
if (o.dtype === "complex64") {
- let n = La({ inputs: { input: o }, backend: t10 }), s = PF({ inputs: { x: n }, backend: t10 }), a = Lu({ inputs: { input: o }, backend: t10 }), i = Bl({ inputs: { x: a }, backend: t10 }), p = Ar({ inputs: { real: s, imag: i }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(n), t10.disposeIntermediateTensorInfo(s), t10.disposeIntermediateTensorInfo(a), t10.disposeIntermediateTensorInfo(i), p;
+ let n = Ua({ inputs: { input: o }, backend: t6 }), s = cF({ inputs: { x: n }, backend: t6 }), a = Mu({ inputs: { input: o }, backend: t6 }), i = Al({ inputs: { x: a }, backend: t6 }), p = Rr({ inputs: { real: s, imag: i }, backend: t6 });
+ return t6.disposeIntermediateTensorInfo(n), t6.disposeIntermediateTensorInfo(s), t6.disposeIntermediateTensorInfo(a), t6.disposeIntermediateTensorInfo(i), p;
} else
- return Ba({ attrs: { shape: o.shape, dtype: o.dtype, value: 1 }, backend: t10 });
+ return Ga({ attrs: { shape: o.shape, dtype: o.dtype, value: 1 }, backend: t6 });
}
-var OF = { kernelName: Cs, backendName: "webgl", kernelFunc: PF };
-function iZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { axis: n } = o;
+var lF = { kernelName: Is, backendName: "webgl", kernelFunc: cF };
+function E7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { axis: n } = o;
if (e.length === 1)
- return Kh({ inputs: { input: e[0] }, backend: t10, attrs: { dim: n } });
+ return Ph({ inputs: { input: e[0] }, backend: t6, attrs: { dim: n } });
let s = e[0].shape, a = e[0].dtype;
e.forEach((c) => {
- x.assertShapesMatch(s, c.shape, "All tensors passed to stack must have matching shapes"), x.assert(a === c.dtype, () => "All tensors passed to stack must have matching dtypes");
+ y.assertShapesMatch(s, c.shape, "All tensors passed to stack must have matching shapes"), y.assert(a === c.dtype, () => "All tensors passed to stack must have matching dtypes");
});
let i = [], p = e.map((c) => {
- let l = Kh({ inputs: { input: c }, backend: t10, attrs: { dim: n } });
+ let l = Ph({ inputs: { input: c }, backend: t6, attrs: { dim: n } });
return i.push(l), l;
- }), u = Pw({ inputs: p, backend: t10, attrs: { axis: n } });
- return i.forEach((c) => t10.disposeIntermediateTensorInfo(c)), u;
+ }), u = $w({ inputs: p, backend: t6, attrs: { axis: n } });
+ return i.forEach((c) => t6.disposeIntermediateTensorInfo(c)), u;
}
-var MF = { kernelName: Is, backendName: "webgl", kernelFunc: iZ };
-var cg = class {
- constructor(e, t10, o) {
- this.variableNames = ["x"], this.customUniforms = [{ name: "value", type: "float" }], this.outputShape = t10.map((u, c) => u[0] + e[c] + u[1]);
- let n = e.length, s = _e(n), a = t10.map((u) => u[0]).join(","), i = t10.map((u, c) => u[0] + e[c]).join(","), p = ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, n);
+var mF = { kernelName: vs, backendName: "webgl", kernelFunc: E7 };
+var Jh = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["x"], this.customUniforms = [{ name: "value", type: "float" }], this.outputShape = t6.map((u, c) => u[0] + e[c] + u[1]);
+ let n = e.length, s = _e(n), a = t6.map((u) => u[0]).join(","), i = t6.map((u, c) => u[0] + e[c]).join(","), p = ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, n);
if (n === 1) {
this.userCode = `
int start = ${a};
@@ -22612,50 +22678,50 @@ var cg = class {
`;
}
};
-var lg = class {
- constructor(e, t10, o) {
- this.variableNames = ["x"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "value", type: "float" }], this.outputShape = t10.map((h, g) => h[0] + e[g] + h[1]);
- let n = e.length, s = _e(n), a = t10.map((h) => h[0]).join(","), i = t10.map((h, g) => h[0] + e[g]).join(","), p = $t("rc", n), u = $t("source", n), c = `${p[n - 1]} < ${this.outputShape[n - 1]}`, l = n === 1 ? "source" : `vec2(${u.slice(-2).join()})`, m = [`${s} rc = outputLoc;`, `${p[n - 1]} += 1;
+var eg = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["x"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{ name: "value", type: "float" }], this.outputShape = t6.map((h, g) => h[0] + e[g] + h[1]);
+ let n = e.length, s = _e(n), a = t6.map((h) => h[0]).join(","), i = t6.map((h, g) => h[0] + e[g]).join(","), p = $t("rc", n), u = $t("source", n), c = `${p[n - 1]} < ${this.outputShape[n - 1]}`, l = n === 1 ? "source" : `vec2(${u.slice(-2).join()})`, m = [`${s} rc = outputLoc;`, `${p[n - 1]} += 1;
if(${c}) {
`, n === 1 ? "" : `}
rc = outputLoc;
${p[n - 2]} += 1;
if(${p[n - 2]} < ${this.outputShape[n - 2]}) {`, n === 1 ? "" : ` ${p[n - 1]} += 1;
- if(${c}) {`], f = n === 1 ? "rc < start || rc >= end" : "any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))", d = "";
+ if(${c}) {`], d = n === 1 ? "rc < start || rc >= end" : "any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))", f = "";
for (let h = 0, g = n === 1 ? 2 : 4; h < g; h++)
- d += `
+ f += `
${m[h]}
- if (${f}) {
+ if (${d}) {
result[${h}] = float(value);
} else {
${s} source = rc - start;
result[${h}] = getChannel(getX(${u.join()}), ${l});
}
`;
- d += n === 1 ? "} " : "}}", this.userCode = `
+ f += n === 1 ? "} " : "}}", this.userCode = `
const ${s} start = ${s}(${a});
const ${s} end = ${s}(${i});
void main() {
${s} outputLoc = getOutputCoords();
vec4 result = vec4(0.);
- ${d}
+ ${f}
setOutput(result);
}
`;
}
};
-var Uw = (r) => {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { paddings: s, constantValue: a } = o;
- if (x.sizeFromShape(n.shape) === 0) {
+var Lw = (r) => {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { paddings: s, constantValue: a } = o;
+ if (y.sizeFromShape(n.shape) === 0) {
let u = s.map((c, l) => c[0] + n.shape[l] + c[1]);
- return Ba({ backend: t10, attrs: { shape: u, value: a, dtype: n.dtype } });
+ return Ga({ backend: t6, attrs: { shape: u, value: a, dtype: n.dtype } });
}
- let i = P().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new lg(n.shape, s, a) : new cg(n.shape, s, a), p = [[a]];
- return t10.runWebGLProgram(i, [n], n.dtype, p);
+ let i = O().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new eg(n.shape, s, a) : new Jh(n.shape, s, a), p = [[a]];
+ return t6.runWebGLProgram(i, [n], n.dtype, p);
};
-var LF = { kernelName: Ln, backendName: "webgl", kernelFunc: Uw };
-var uZ = `
+var dF = { kernelName: $n, backendName: "webgl", kernelFunc: Lw };
+var $7 = `
if(a < 0.0 && floor(b) < b){
return NAN;
}
@@ -22665,7 +22731,7 @@ var uZ = `
return (round(mod(b, 2.0)) != 1) ?
pow(abs(a), b) : sign(a) * pow(abs(a), b);
`;
-var pZ = `
+var A7 = `
// isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.
vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));
vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);
@@ -22681,57 +22747,57 @@ var pZ = `
bvec4 isNaN1 = lessThan(a, vec4(0.0));
bvec4 isNaN2 = lessThan(floor(b), b);
bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w);
- ` + js + `
+ ` + Zs + `
return result;
`;
-var cZ = ot({ opSnippet: uZ, packedOpSnippet: pZ });
-var BF = { kernelName: Bn, backendName: "webgl", kernelFunc: cZ };
-function lZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = n.shape.length, p = [], u = x.parseAxisParam(s, n.shape), c = u, l = I.getAxesPermutation(c, i), m = n;
- l != null && (m = xt({ inputs: { x: n }, backend: t10, attrs: { perm: l } }), c = I.getInnerMostAxes(c.length, i), p.push(m)), I.assertAxesAreInnerMostDims("prod", c, i);
- let f;
- if (t10.shouldExecuteOnCPU([m])) {
- let d = t10.texData.get(m.dataId).values, { outVals: h, outShape: g, outDtype: y } = _$(m.shape, m.dtype, d, c);
- f = t10.makeTensorInfo(g, y, h);
+var R7 = tt({ opSnippet: $7, packedOpSnippet: A7 });
+var fF = { kernelName: An, backendName: "webgl", kernelFunc: R7 };
+function F7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, keepDims: a } = o, i = n.shape.length, p = [], u = y.parseAxisParam(s, n.shape), c = u, l = S.getAxesPermutation(c, i), m = n;
+ l != null && (m = xt({ inputs: { x: n }, backend: t6, attrs: { perm: l } }), c = S.getInnerMostAxes(c.length, i), p.push(m)), S.assertAxesAreInnerMostDims("prod", c, i);
+ let d;
+ if (t6.shouldExecuteOnCPU([m])) {
+ let f = t6.texData.get(m.dataId).values, { outVals: h, outShape: g, outDtype: x } = o$(m.shape, m.dtype, f, c);
+ d = t6.makeTensorInfo(g, x, h);
} else {
- let [d, h] = I.computeOutAndReduceShapes(m.shape, c), g = x.sizeFromShape(h), y = J({ inputs: { x: m }, backend: t10, attrs: { shape: [-1, g] } }), b = Ca(n.dtype), C = qr(y, b, "prod", t10);
- f = J({ inputs: { x: C }, backend: t10, attrs: { shape: d } }), p.push(y), p.push(C);
+ let [f, h] = S.computeOutAndReduceShapes(m.shape, c), g = y.sizeFromShape(h), x = te({ inputs: { x: m }, backend: t6, attrs: { shape: [-1, g] } }), b = ka(n.dtype), C = Gr(x, b, "prod", t6);
+ d = te({ inputs: { x: C }, backend: t6, attrs: { shape: f } }), p.push(x), p.push(C);
}
if (a) {
- p.push(f);
- let d = I.expandShapeToKeepDim(f.shape, u);
- f = J({ inputs: { x: f }, backend: t10, attrs: { shape: d } });
+ p.push(d);
+ let f = S.expandShapeToKeepDim(d.shape, u);
+ d = te({ inputs: { x: d }, backend: t6, attrs: { shape: f } });
}
- return p.forEach((d) => t10.disposeIntermediateTensorInfo(d)), f;
+ return p.forEach((f) => t6.disposeIntermediateTensorInfo(f)), d;
}
-var VF = { kernelName: Ao, backendName: "webgl", kernelFunc: lZ };
-function mZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { paramsNestedSplits: n, paramsDenseValues: s, indices: a } = e, { outputRaggedRank: i } = o, p = n.map((y) => t10.readSync(y.dataId)), u = n.map((y) => y.shape), c = t10.readSync(s.dataId), l = t10.readSync(a.dataId), [m, f, d] = E$(p, u, c, s.shape, s.dtype, l, a.shape, i), h = m.map((y) => t10.makeTensorInfo([y.length], "int32", y)), g = t10.makeTensorInfo(d, s.dtype, f);
+var hF = { kernelName: Fn, backendName: "webgl", kernelFunc: F7 };
+function D7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { paramsNestedSplits: n, paramsDenseValues: s, indices: a } = e, { outputRaggedRank: i } = o, p = n.map((x) => t6.readSync(x.dataId)), u = n.map((x) => x.shape), c = t6.readSync(s.dataId), l = t6.readSync(a.dataId), [m, d, f] = n$(p, u, c, s.shape, s.dtype, l, a.shape, i), h = m.map((x) => t6.makeTensorInfo([x.length], "int32", x)), g = t6.makeTensorInfo(f, s.dtype, d);
return h.concat([g]);
}
-var zF = { kernelName: Tp, backendName: "webgl", kernelFunc: mZ };
-function fZ(r) {
- let { inputs: e, backend: t10 } = r, { starts: o, limits: n, deltas: s } = e, a = t10.readSync(o.dataId), i = t10.readSync(n.dataId), p = t10.readSync(s.dataId), [u, c] = $$(a, o.shape, o.dtype, i, n.shape, p, s.shape), l = t10.makeTensorInfo([u.length], "int32", u), m = t10.makeTensorInfo([c.length], o.dtype, c);
+var gF = { kernelName: wp, backendName: "webgl", kernelFunc: D7 };
+function O7(r) {
+ let { inputs: e, backend: t6 } = r, { starts: o, limits: n, deltas: s } = e, a = t6.readSync(o.dataId), i = t6.readSync(n.dataId), p = t6.readSync(s.dataId), [u, c] = s$(a, o.shape, o.dtype, i, n.shape, p, s.shape), l = t6.makeTensorInfo([u.length], "int32", u), m = t6.makeTensorInfo([c.length], o.dtype, c);
return [l, m];
}
-var WF = { kernelName: Np, backendName: "webgl", kernelFunc: fZ };
-function dZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { shape: n, values: s, defaultValue: a, rowPartitionTensors: i } = e, { rowPartitionTypes: p } = o, u = t10.readSync(n.dataId), c = t10.readSync(s.dataId), l = t10.readSync(a.dataId), m = i.map((g) => t10.readSync(g.dataId)), f = i.map((g) => g.shape), [d, h] = R$(u, n.shape, c, s.shape, s.dtype, l, a.shape, m, f, p);
- return t10.makeTensorInfo(d, s.dtype, h);
+var xF = { kernelName: Ip, backendName: "webgl", kernelFunc: O7 };
+function P7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { shape: n, values: s, defaultValue: a, rowPartitionTensors: i } = e, { rowPartitionTypes: p } = o, u = t6.readSync(n.dataId), c = t6.readSync(s.dataId), l = t6.readSync(a.dataId), m = i.map((g) => t6.readSync(g.dataId)), d = i.map((g) => g.shape), [f, h] = a$(u, n.shape, c, s.shape, s.dtype, l, a.shape, m, d, p);
+ return t6.makeTensorInfo(f, s.dtype, h);
}
-var UF = { kernelName: _p, backendName: "webgl", kernelFunc: dZ };
-var Gw = (r) => {
- let { backend: e, attrs: t10 } = r, { start: o, stop: n, step: s, dtype: a } = t10, i = A$(o, n, s, a);
+var yF = { kernelName: vp, backendName: "webgl", kernelFunc: P7 };
+var Bw = (r) => {
+ let { backend: e, attrs: t6 } = r, { start: o, stop: n, step: s, dtype: a } = t6, i = i$(o, n, s, a);
return e.makeTensorInfo([i.length], a, i);
};
-var GF = { kernelName: ws, backendName: "webgl", kernelFunc: Gw };
-var hZ = "return 1.0 / x;";
-var gZ = he({ opSnippet: hZ });
-var HF = { kernelName: ma, backendName: "webgl", kernelFunc: gZ };
-var xZ = Vt + `
+var bF = { kernelName: ks, backendName: "webgl", kernelFunc: Bw };
+var M7 = "return 1.0 / x;";
+var L7 = ge({ opSnippet: M7 });
+var CF = { kernelName: Dn, backendName: "webgl", kernelFunc: L7 };
+var B7 = Bt + `
return (x < 0.0) ? 0.0 : x;
`;
-var yZ = `
+var V7 = `
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
@@ -22742,12 +22808,12 @@ var yZ = `
return result;
`;
-var bZ = he({ opSnippet: xZ, packedOpSnippet: yZ });
-var qF = { kernelName: zn, backendName: "webgl", kernelFunc: bZ };
-var CZ = Vt + `
+var z7 = ge({ opSnippet: B7, packedOpSnippet: V7 });
+var SF = { kernelName: On, backendName: "webgl", kernelFunc: z7 };
+var W7 = Bt + `
return (x < 0.0) ? 0.0 : min(6.0, x);
`;
-var IZ = `
+var U7 = `
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
@@ -22758,14 +22824,14 @@ var IZ = `
return result;
`;
-var wZ = he({ opSnippet: CZ, packedOpSnippet: IZ });
-var KF = { kernelName: Gn, backendName: "webgl", kernelFunc: wZ };
-var mg = class {
- constructor(e, t10, o, n, s) {
+var G7 = ge({ opSnippet: W7, packedOpSnippet: U7 });
+var wF = { kernelName: Ln, backendName: "webgl", kernelFunc: G7 };
+var tg = class {
+ constructor(e, t6, o, n, s) {
this.variableNames = ["A"], this.outputShape = [];
let [a, i, p, u] = e;
- this.outputShape = [a, t10, o, u];
- let c = [n && t10 > 1 ? i - 1 : i, n && o > 1 ? p - 1 : p], l = [n && t10 > 1 ? t10 - 1 : t10, n && o > 1 ? o - 1 : o], m;
+ this.outputShape = [a, t6, o, u];
+ let c = [n && t6 > 1 ? i - 1 : i, n && o > 1 ? p - 1 : p], l = [n && t6 > 1 ? t6 - 1 : t6, n && o > 1 ? o - 1 : o], m;
s ? m = "(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)" : m = "vec2(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `
const vec2 effectiveInputOverOutputRatioRC = vec2(
${c[0] / l[0]},
@@ -22802,12 +22868,12 @@ var mg = class {
`;
}
};
-var fg = class {
- constructor(e, t10, o, n, s) {
+var rg = class {
+ constructor(e, t6, o, n, s) {
this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.outputShape = [];
let [a, i, p, u] = e;
- this.outputShape = [a, t10, o, u];
- let c = [n && t10 > 1 ? i - 1 : i, n && o > 1 ? p - 1 : p], l = [n && t10 > 1 ? t10 - 1 : t10, n && o > 1 ? o - 1 : o], m;
+ this.outputShape = [a, t6, o, u];
+ let c = [n && t6 > 1 ? i - 1 : i, n && o > 1 ? p - 1 : p], l = [n && t6 > 1 ? t6 - 1 : t6, n && o > 1 ? o - 1 : o], m;
s ? m = "(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)" : m = "vec3(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `
const vec3 effectiveInputOverOutputRatioRC = vec3(
${c[0] / l[0]},
@@ -22888,15 +22954,15 @@ var fg = class {
`;
}
};
-function SZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { images: n } = e, { alignCorners: s, halfPixelCenters: a, size: i } = o, [p, u] = i, c = P().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new fg(n.shape, p, u, s, a) : new mg(n.shape, p, u, s, a);
- return t10.runWebGLProgram(c, [n], "float32");
+function H7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { images: n } = e, { alignCorners: s, halfPixelCenters: a, size: i } = o, [p, u] = i, c = O().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new rg(n.shape, p, u, s, a) : new tg(n.shape, p, u, s, a);
+ return t6.runWebGLProgram(c, [n], "float32");
}
-var jF = { kernelName: Un, backendName: "webgl", kernelFunc: SZ };
-var dg = class {
- constructor(e, t10, o) {
- this.variableNames = ["dy"], this.outputShape = [], this.outputShape = t10;
- let [, n, s] = t10, [, a, i] = e, p = [o && a > 1 ? n - 1 : n, o && i > 1 ? s - 1 : s], u = [o && a > 1 ? a - 1 : a, o && i > 1 ? i - 1 : i], c = p[0] / u[0], l = p[1] / u[1], m = 1 / c, f = 1 / l, d = Math.ceil(m) * 2 + 2, h = Math.ceil(f) * 2 + 2;
+var IF = { kernelName: Mn, backendName: "webgl", kernelFunc: H7 };
+var og = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["dy"], this.outputShape = [], this.outputShape = t6;
+ let [, n, s] = t6, [, a, i] = e, p = [o && a > 1 ? n - 1 : n, o && i > 1 ? s - 1 : s], u = [o && a > 1 ? a - 1 : a, o && i > 1 ? i - 1 : i], c = p[0] / u[0], l = p[1] / u[1], m = 1 / c, d = 1 / l, f = Math.ceil(m) * 2 + 2, h = Math.ceil(d) * 2 + 2;
this.userCode = `
void main() {
ivec4 coords = getOutputCoords();
@@ -22911,9 +22977,9 @@ var dg = class {
const float widthScale = float(${l});
const float invHeightScale = float(${m});
- const float invWidthScale = float(${f});
+ const float invWidthScale = float(${d});
- const int winHeight = int(${d});
+ const int winHeight = int(${f});
const int winWidth = int(${h});
// Compute bounds for where in dy we will look
@@ -22981,18 +23047,18 @@ var dg = class {
`;
}
};
-function vZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { images: n, dy: s } = e, { alignCorners: a } = o, i = new dg(s.shape, n.shape, a);
- return t10.runWebGLProgram(i, [s], s.dtype);
+function q7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { images: n, dy: s } = e, { alignCorners: a } = o, i = new og(s.shape, n.shape, a);
+ return t6.runWebGLProgram(i, [s], s.dtype);
}
-var XF = { kernelName: Vm, backendName: "webgl", kernelFunc: vZ };
-var hg = class {
- constructor(e, t10, o, n, s) {
+var vF = { kernelName: $m, backendName: "webgl", kernelFunc: q7 };
+var ng = class {
+ constructor(e, t6, o, n, s) {
this.variableNames = ["A"], this.outputShape = [];
let [a, i, p, u] = e;
- this.outputShape = [a, t10, o, u];
- let c = [n && t10 > 1 ? i - 1 : i, n && o > 1 ? p - 1 : p], l = [n && t10 > 1 ? t10 - 1 : t10, n && o > 1 ? o - 1 : o], m = n ? "0.5" : "0.0", f;
- s ? f = "max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))" : f = "vec2(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `
+ this.outputShape = [a, t6, o, u];
+ let c = [n && t6 > 1 ? i - 1 : i, n && o > 1 ? p - 1 : p], l = [n && t6 > 1 ? t6 - 1 : t6, n && o > 1 ? o - 1 : o], m = n ? "0.5" : "0.0", d;
+ s ? d = "max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))" : d = "vec2(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `
const vec2 effectiveInputOverOutputRatioRC = vec2(
${c[0] / l[0]},
${c[1] / l[1]});
@@ -23005,7 +23071,7 @@ var hg = class {
ivec2 yRC = coords.yz;
// Fractional source index.
- vec2 sourceFracIndexRC = ${f};
+ vec2 sourceFracIndexRC = ${d};
// Compute the coordinators of nearest neighbor point.
ivec2 sourceNearestRC = ivec2(
@@ -23017,13 +23083,13 @@ var hg = class {
`;
}
};
-var gg = class {
- constructor(e, t10, o, n, s) {
+var sg = class {
+ constructor(e, t6, o, n, s) {
this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.outputShape = [];
let [a, i, p, u] = e;
- this.outputShape = [a, t10, o, u];
- let c = [n && t10 > 1 ? i - 1 : i, n && o > 1 ? p - 1 : p], l = [n && t10 > 1 ? t10 - 1 : t10, n && o > 1 ? o - 1 : o], m = n ? "0.5" : "0.0", f;
- s ? f = "max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))" : f = "vec3(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `
+ this.outputShape = [a, t6, o, u];
+ let c = [n && t6 > 1 ? i - 1 : i, n && o > 1 ? p - 1 : p], l = [n && t6 > 1 ? t6 - 1 : t6, n && o > 1 ? o - 1 : o], m = n ? "0.5" : "0.0", d;
+ s ? d = "max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))" : d = "vec3(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `
const vec3 effectiveInputOverOutputRatioRC = vec3(
${c[0] / l[0]},
${c[1] / l[1]},
@@ -23043,7 +23109,7 @@ var gg = class {
ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
// Fractional source index.
- vec3 sourceFracIndexRC = ${f};
+ vec3 sourceFracIndexRC = ${d};
// Compute the coordinators of nearest neighbor point.
ivec3 sourceNearestRC = ivec3(
@@ -23067,15 +23133,15 @@ var gg = class {
`;
}
};
-function kZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { images: n } = e, { alignCorners: s, halfPixelCenters: a, size: i } = o, [p, u] = i, c = P().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new gg(n.shape, p, u, s, a) : new hg(n.shape, p, u, s, a);
- return t10.runWebGLProgram(c, [n], n.dtype);
+function K7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { images: n } = e, { alignCorners: s, halfPixelCenters: a, size: i } = o, [p, u] = i, c = O().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new sg(n.shape, p, u, s, a) : new ng(n.shape, p, u, s, a);
+ return t6.runWebGLProgram(c, [n], n.dtype);
}
-var YF = { kernelName: Wn, backendName: "webgl", kernelFunc: kZ };
-var xg = class {
- constructor(e, t10, o) {
- this.variableNames = ["dy"], this.outputShape = [], this.outputShape = t10;
- let [, n, s] = t10, [, a, i] = e, p = [o && a > 1 ? n - 1 : n, o && i > 1 ? s - 1 : s], u = [o && a > 1 ? a - 1 : a, o && i > 1 ? i - 1 : i], c = p[0] / u[0], l = p[1] / u[1], m = 1 / c, f = 1 / l, d = Math.ceil(m) * 2 + 2, h = Math.ceil(f) * 2 + 2;
+var kF = { kernelName: Pn, backendName: "webgl", kernelFunc: K7 };
+var ag = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["dy"], this.outputShape = [], this.outputShape = t6;
+ let [, n, s] = t6, [, a, i] = e, p = [o && a > 1 ? n - 1 : n, o && i > 1 ? s - 1 : s], u = [o && a > 1 ? a - 1 : a, o && i > 1 ? i - 1 : i], c = p[0] / u[0], l = p[1] / u[1], m = 1 / c, d = 1 / l, f = Math.ceil(m) * 2 + 2, h = Math.ceil(d) * 2 + 2;
this.userCode = `
void main() {
ivec4 coords = getOutputCoords();
@@ -23090,9 +23156,9 @@ var xg = class {
const float widthScale = float(${l});
const float invHeightScale = float(${m});
- const float invWidthScale = float(${f});
+ const float invWidthScale = float(${d});
- const int winHeight = int(${d});
+ const int winHeight = int(${f});
const int winWidth = int(${h});
// Compute bounds for where in dy we will look
@@ -23149,13 +23215,13 @@ var xg = class {
`;
}
};
-function TZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { images: n, dy: s } = e, { alignCorners: a } = o, i = new xg(s.shape, n.shape, a);
- return t10.runWebGLProgram(i, [s], s.dtype);
+function j7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { images: n, dy: s } = e, { alignCorners: a } = o, i = new ag(s.shape, n.shape, a);
+ return t6.runWebGLProgram(i, [s], s.dtype);
}
-var QF = { kernelName: Bm, backendName: "webgl", kernelFunc: TZ };
-var yg = class {
- constructor(e, t10) {
+var NF = { kernelName: Em, backendName: "webgl", kernelFunc: j7 };
+var ig = class {
+ constructor(e, t6) {
this.variableNames = ["x"];
let o = e.length;
if (o > 4)
@@ -23169,7 +23235,7 @@ var yg = class {
`;
return;
}
- let n = (i) => t10.indexOf(i) !== -1 && e[i] !== 1 ? `${e[i]} - coords[${i}] - 1` : `coords[${i}]`, s = e.map((i, p) => n(p)).join(","), a = _e(o);
+ let n = (i) => t6.indexOf(i) !== -1 && e[i] !== 1 ? `${e[i]} - coords[${i}] - 1` : `coords[${i}]`, s = e.map((i, p) => n(p)).join(","), a = _e(o);
this.userCode = `
void main() {
${a} coords = getOutputCoords();
@@ -23178,8 +23244,8 @@ var yg = class {
`;
}
};
-var bg = class {
- constructor(e, t10) {
+var ug = class {
+ constructor(e, t6) {
this.variableNames = ["x"], this.packedInputs = true, this.packedOutput = true;
let o = e.length;
if (o > 4)
@@ -23215,43 +23281,43 @@ var bg = class {
setOutput(result);
}
`;
- function p(d) {
- return m(d);
+ function p(f) {
+ return m(f);
}
- function u(d) {
- return d[o - 1] = "(" + d[o - 1] + " + 1)", m(d);
+ function u(f) {
+ return f[o - 1] = "(" + f[o - 1] + " + 1)", m(f);
}
- function c(d) {
- return d[o - 2] = "(" + d[o - 2] + " + 1)", m(d);
+ function c(f) {
+ return f[o - 2] = "(" + f[o - 2] + " + 1)", m(f);
}
- function l(d) {
- return d[o - 1] = "(" + d[o - 1] + " + 1)", d[o - 2] = "(" + d[o - 2] + " + 1)", m(d);
+ function l(f) {
+ return f[o - 1] = "(" + f[o - 1] + " + 1)", f[o - 2] = "(" + f[o - 2] + " + 1)", m(f);
}
- function m(d) {
- let h = e.map((b, C) => f(C, d)), g = h.join(","), y = h.slice(-2).join(",");
- return `getChannel(getX(${g}), vec2(${y}))`;
+ function m(f) {
+ let h = e.map((b, C) => d(C, f)), g = h.join(","), x = h.slice(-2).join(",");
+ return `getChannel(getX(${g}), vec2(${x}))`;
}
- function f(d, h) {
- return t10.indexOf(d) !== -1 && e[d] !== 1 ? `${e[d]} - ${h[d]} - 1` : `${h[d]}`;
+ function d(f, h) {
+ return t6.indexOf(f) !== -1 && e[f] !== 1 ? `${e[f]} - ${h[f]} - 1` : `${h[f]}`;
}
}
};
-function NZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { dims: s } = o, a = n.shape.length, i = x.parseAxisParam(s, n.shape);
+function X7(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { dims: s } = o, a = n.shape.length, i = y.parseAxisParam(s, n.shape);
if (a === 0)
- return Rt({ inputs: { x: n }, backend: t10 });
- let p = P().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new bg(n.shape, i) : new yg(n.shape, i);
- return t10.runWebGLProgram(p, [n], n.dtype);
+ return At({ inputs: { x: n }, backend: t6 });
+ let p = O().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new ug(n.shape, i) : new ig(n.shape, i);
+ return t6.runWebGLProgram(p, [n], n.dtype);
}
-var ZF = { kernelName: fa, backendName: "webgl", kernelFunc: NZ };
-var Cg = class {
- constructor(e, t10) {
+var TF = { kernelName: Bn, backendName: "webgl", kernelFunc: X7 };
+var pg = class {
+ constructor(e, t6) {
this.variableNames = ["Image"], this.outputShape = [], this.customUniforms = [{ name: "params", type: "vec4" }];
let o = e[1], n = e[2];
this.outputShape = e;
let s = "";
- typeof t10 == "number" ? s = `float outputValue = ${t10.toFixed(2)};` : s = `
- vec3 fill = vec3(${t10.join(",")});
+ typeof t6 == "number" ? s = `float outputValue = ${t6.toFixed(2)};` : s = `
+ vec3 fill = vec3(${t6.join(",")});
float outputValue = fill[coords[3]];`, this.userCode = `
void main() {
ivec4 coords = getOutputCoords();
@@ -23272,11 +23338,11 @@ var Cg = class {
`;
}
};
-var JF = { kernelName: es, backendName: "webgl", kernelFunc: ({ inputs: r, attrs: e, backend: t10 }) => {
- let { image: o } = r, { radians: n, fillValue: s, center: a } = e, i = t10, p = new Cg(o.shape, s), [u, c] = I.getImageCenter(a, o.shape[1], o.shape[2]), l = [[u, c, Math.sin(n), Math.cos(n)]];
+var _F = { kernelName: es, backendName: "webgl", kernelFunc: ({ inputs: r, attrs: e, backend: t6 }) => {
+ let { image: o } = r, { radians: n, fillValue: s, center: a } = e, i = t6, p = new pg(o.shape, s), [u, c] = S.getImageCenter(a, o.shape[1], o.shape[2]), l = [[u, c, Math.sin(n), Math.cos(n)]];
return i.runWebGLProgram(p, [o], o.dtype, l);
} };
-var _Z = `
+var Y7 = `
// OpenGL ES does not support round function.
// The algorithm is based on banker's rounding.
float base = floor(x);
@@ -23292,19 +23358,19 @@ var _Z = `
}
}
`;
-var EZ = he({ opSnippet: _Z });
-var eD = { kernelName: da, backendName: "webgl", kernelFunc: EZ };
-var $Z = "return inversesqrt(x);";
-var RZ = he({ opSnippet: $Z, cpuKernelImpl: F$ });
-var tD = { kernelName: xo, backendName: "webgl", kernelFunc: RZ };
-var vc = class {
- constructor(e, t10, o, n, s, a, i = true) {
+var Q7 = ge({ opSnippet: Y7 });
+var EF = { kernelName: Ca, backendName: "webgl", kernelFunc: Q7 };
+var Z7 = "return inversesqrt(x);";
+var J7 = ge({ opSnippet: Z7, cpuKernelImpl: u$ });
+var $F = { kernelName: Vn, backendName: "webgl", kernelFunc: J7 };
+var Cc = class {
+ constructor(e, t6, o, n, s, a, i = true) {
this.variableNames = ["updates", "indices", "defaultValue"], this.outputShape = a;
let p = _e(s.length), u = _e(a.length), c = "";
o === 1 ? c = "i" : o === 2 && (c = "i, j");
let l = `getIndices(${c})`, m = "";
n === 1 ? m = "i" : n === 2 && (m = "i, coords[1]");
- let f = `getUpdates(${m})`, d = t10 > 1 ? "strides[j]" : "strides";
+ let d = `getUpdates(${m})`, f = t6 > 1 ? "strides[j]" : "strides";
this.userCode = `
${p} strides = ${p}(${s});
@@ -23314,12 +23380,12 @@ var vc = class {
bool found = false;
for (int i = 0; i < ${e}; i++) {
int flattenedIndex = 0;
- for (int j = 0; j < ${t10}; j++) {
+ for (int j = 0; j < ${t6}; j++) {
int index = round(${l});
- flattenedIndex += index * ${d};
+ flattenedIndex += index * ${f};
}
if (flattenedIndex == coords[0]) {
- sum += ${f};
+ sum += ${d};
found = true;
}
}
@@ -23328,18 +23394,18 @@ var vc = class {
`;
}
};
-function AZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { indices: n, updates: s } = e, { shape: a } = o, { sliceRank: i, numUpdates: p, sliceSize: u, strides: c, outputSize: l } = I.calculateShapes(s, n, a), m = [l / u, u];
+function eZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { indices: n, updates: s } = e, { shape: a } = o, { sliceRank: i, numUpdates: p, sliceSize: u, strides: c, outputSize: l } = S.calculateShapes(s, n, a), m = [l / u, u];
if (l === 0)
- return t10.makeTensorInfo(a, n.dtype);
- let f = J({ inputs: { x: n }, backend: t10, attrs: { shape: [p, i] } }), d = J({ inputs: { x: s }, backend: t10, attrs: { shape: [p, u] } }), h = t10.makeTensorInfo([], "float32", new Float32Array([0])), g = new vc(p, i, f.shape.length, d.shape.length, c, m), y = t10.runWebGLProgram(g, [d, f, h], d.dtype), b = J({ inputs: { x: y }, backend: t10, attrs: { shape: a } });
- return t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(d), t10.disposeIntermediateTensorInfo(y), t10.disposeIntermediateTensorInfo(h), b;
+ return t6.makeTensorInfo(a, n.dtype);
+ let d = te({ inputs: { x: n }, backend: t6, attrs: { shape: [p, i] } }), f = te({ inputs: { x: s }, backend: t6, attrs: { shape: [p, u] } }), h = t6.makeTensorInfo([], "float32", new Float32Array([0])), g = new Cc(p, i, d.shape.length, f.shape.length, c, m), x = t6.runWebGLProgram(g, [f, d, h], f.dtype), b = te({ inputs: { x }, backend: t6, attrs: { shape: a } });
+ return t6.disposeIntermediateTensorInfo(d), t6.disposeIntermediateTensorInfo(f), t6.disposeIntermediateTensorInfo(x), t6.disposeIntermediateTensorInfo(h), b;
}
-var rD = { kernelName: Hn, backendName: "webgl", kernelFunc: AZ };
-var Ig = class {
- constructor(e, t10, o, n) {
+var AF = { kernelName: zn, backendName: "webgl", kernelFunc: eZ };
+var cg = class {
+ constructor(e, t6, o, n) {
this.variableNames = ["sortedSequence", "values"], this.customUniforms = [{ name: "numInputs", type: "int" }], this.outputShape = [e, o];
- let s = "while (left < right) {", a = `for (int i = 0; i < ${Math.ceil(Math.log2(t10 + 1))}; ++i) { if (left >= right) break;`, i = P().getNumber("WEBGL_VERSION") === 2 ? s : a, p = n === "left" ? "<" : "<=";
+ let s = "while (left < right) {", a = `for (int i = 0; i < ${Math.ceil(Math.log2(t6 + 1))}; ++i) { if (left >= right) break;`, i = O().getNumber("WEBGL_VERSION") === 2 ? s : a, p = n === "left" ? "<" : "<=";
this.userCode = `
int findBound(int batch, float value) {
int left = 0;
@@ -23368,14 +23434,14 @@ var Ig = class {
`;
}
};
-function FZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { sortedSequence: n, values: s } = e, { side: a } = o, i = new Ig(n.shape[0], n.shape[1], s.shape[1], a), p = [[n.shape[1]]];
- return t10.runWebGLProgram(i, [n, s], "int32", p);
+function tZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { sortedSequence: n, values: s } = e, { side: a } = o, i = new cg(n.shape[0], n.shape[1], s.shape[1], a), p = [[n.shape[1]]];
+ return t6.runWebGLProgram(i, [n, s], "int32", p);
}
-var oD = { kernelName: Ep, backendName: "webgl", kernelFunc: FZ };
-var wg = class {
- constructor(e, t10, o) {
- this.variableNames = ["c", "a", "b"], this.outputShape = t10;
+var RF = { kernelName: ii, backendName: "webgl", kernelFunc: tZ };
+var lg = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["c", "a", "b"], this.outputShape = t6;
let n, s;
if (o > 4)
throw Error(`Where for rank ${o} is not yet supported`);
@@ -23383,7 +23449,7 @@ var wg = class {
s = "resRC", n = "resRC";
else {
let i = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], p = [], u = [];
- for (let c = 0; c < t10.length; c++)
+ for (let c = 0; c < t6.length; c++)
u.push(`${i[c]}`), c < e && p.push(`${i[c]}`);
n = p.join(), s = u.join();
}
@@ -23401,24 +23467,24 @@ var wg = class {
`;
}
};
-function DZ(r) {
- let { inputs: e, backend: t10 } = r, { condition: o, t: n, e: s } = e, a = new wg(o.shape.length, n.shape, n.shape.length);
- return t10.runWebGLProgram(a, [o, n, s], ct(n.dtype, s.dtype));
+function rZ(r) {
+ let { inputs: e, backend: t6 } = r, { condition: o, t: n, e: s } = e, a = new lg(o.shape.length, n.shape, n.shape.length);
+ return t6.runWebGLProgram(a, [o, n, s], dt(n.dtype, s.dtype));
}
-var nD = { kernelName: vs, backendName: "webgl", kernelFunc: DZ };
-var PZ = `
+var FF = { kernelName: Ts, backendName: "webgl", kernelFunc: rZ };
+var oZ = `
// Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
// see: https://arxiv.org/abs/1706.02515
- float scaleAlpha = ${I.SELU_SCALEALPHA};
- float scale = ${I.SELU_SCALE};
+ float scaleAlpha = ${S.SELU_SCALEALPHA};
+ float scale = ${S.SELU_SCALE};
return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
`;
-var OZ = he({ opSnippet: PZ });
-var sD = { kernelName: Xi, backendName: "webgl", kernelFunc: OZ };
-var MZ = jo + `
+var nZ = ge({ opSnippet: oZ });
+var DF = { kernelName: Xi, backendName: "webgl", kernelFunc: nZ };
+var sZ = _o + `
return 1.0 / (1.0 + exp(-1.0 * x));
`;
-var LZ = `
+var aZ = `
vec4 result = 1.0 / (1.0 + exp(-1.0 * x));
bvec4 isNaN = isnan(x);
@@ -23429,26 +23495,26 @@ var LZ = `
return result;
`;
-var BZ = he({ opSnippet: MZ, packedOpSnippet: LZ, cpuKernelImpl: P$ });
-var aD = { kernelName: yo, backendName: "webgl", kernelFunc: BZ };
-var VZ = `
+var iZ = ge({ opSnippet: sZ, packedOpSnippet: aZ, cpuKernelImpl: c$ });
+var OF = { kernelName: Un, backendName: "webgl", kernelFunc: iZ };
+var uZ = `
if (isnan(x)) { return 0.0; }
return sign(x);
`;
-var zZ = he({ opSnippet: VZ });
-var iD = { kernelName: Yi, backendName: "webgl", kernelFunc: zZ };
-var WZ = jo + `
+var pZ = ge({ opSnippet: uZ });
+var PF = { kernelName: Yi, backendName: "webgl", kernelFunc: pZ };
+var cZ = _o + `
return sin(x);
`;
-var UZ = he({ opSnippet: WZ });
-var uD = { kernelName: Kn, backendName: "webgl", kernelFunc: UZ };
-var GZ = `
+var lZ = ge({ opSnippet: cZ });
+var MF = { kernelName: Wn, backendName: "webgl", kernelFunc: lZ };
+var mZ = `
float e2x = exp(x);
return (e2x - 1.0 / e2x) / 2.0;
`;
-var HZ = he({ opSnippet: GZ });
-var pD = { kernelName: ha, backendName: "webgl", kernelFunc: HZ };
-var qZ = `
+var dZ = ge({ opSnippet: mZ });
+var LF = { kernelName: Sa, backendName: "webgl", kernelFunc: dZ };
+var fZ = `
float epsilon = 1.1920928955078125e-7;
float threshold = log(epsilon) + 2.0;
@@ -23469,21 +23535,21 @@ var qZ = `
}
return result;
`;
-var KZ = he({ opSnippet: qZ });
-var cD = { kernelName: Qi, backendName: "webgl", kernelFunc: KZ };
-var jZ = (r) => {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { blockShape: s, paddings: a } = o;
- x.assert(n.shape.length <= 4, () => "spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");
- let i = s.reduce((y, b) => y * b), p = [[0, 0]];
+var hZ = ge({ opSnippet: fZ });
+var BF = { kernelName: Qi, backendName: "webgl", kernelFunc: hZ };
+var gZ = (r) => {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { blockShape: s, paddings: a } = o;
+ y.assert(n.shape.length <= 4, () => "spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");
+ let i = s.reduce((x, b) => x * b), p = [[0, 0]];
p.push(...a);
- for (let y = 1 + s.length; y < n.shape.length; ++y)
+ for (let x = 1 + s.length; x < n.shape.length; ++x)
p.push([0, 0]);
- let u = [], c = Uw({ inputs: { x: n }, backend: t10, attrs: { paddings: p, constantValue: 0 } }), l = I.getReshaped(c.shape, s, i, false), m = I.getPermuted(l.length, s.length, false), f = I.getReshapedPermuted(c.shape, s, i, false), d = J({ inputs: { x: c }, backend: t10, attrs: { shape: l } }), h = xt({ inputs: { x: d }, backend: t10, attrs: { perm: m } }), g = J({ inputs: { x: h }, backend: t10, attrs: { shape: f } });
- return u.push(c), u.push(d), u.push(h), u.forEach((y) => t10.disposeIntermediateTensorInfo(y)), g;
+ let u = [], c = Lw({ inputs: { x: n }, backend: t6, attrs: { paddings: p, constantValue: 0 } }), l = S.getReshaped(c.shape, s, i, false), m = S.getPermuted(l.length, s.length, false), d = S.getReshapedPermuted(c.shape, s, i, false), f = te({ inputs: { x: c }, backend: t6, attrs: { shape: l } }), h = xt({ inputs: { x: f }, backend: t6, attrs: { perm: m } }), g = te({ inputs: { x: h }, backend: t6, attrs: { shape: d } });
+ return u.push(c), u.push(f), u.push(h), u.forEach((x) => t6.disposeIntermediateTensorInfo(x)), g;
};
-var lD = { kernelName: ks, backendName: "webgl", kernelFunc: jZ };
-function XZ(r) {
- let { inputs: e, backend: t10 } = r, { indices: o, values: n, denseShape: s, defaultValue: a } = e;
+var VF = { kernelName: Es, backendName: "webgl", kernelFunc: gZ };
+function xZ(r) {
+ let { inputs: e, backend: t6 } = r, { indices: o, values: n, denseShape: s, defaultValue: a } = e;
if (s.shape.length !== 1)
throw new Error(`Dense shape must be a vector, saw:
${s.shape}`);
@@ -23496,24 +23562,24 @@ function XZ(r) {
if (a.shape.length !== 0)
throw new Error(`Default value must be a scalar, saw:
${a.shape}`);
- let i = t10.readSync(o.dataId), p = t10.readSync(n.dataId), u = t10.readSync(s.dataId), c = t10.readSync(a.dataId)[0], [l, m, f, d, h] = M$(i, o.shape, o.dtype, p, n.dtype, u, c);
- return [t10.makeTensorInfo(m, o.dtype, l), t10.makeTensorInfo([m[0]], n.dtype, f), t10.makeTensorInfo([d.length], "bool", new Uint8Array(d.map((g) => Number(g)))), t10.makeTensorInfo([h.length], o.dtype, new Int32Array(h))];
+ let i = t6.readSync(o.dataId), p = t6.readSync(n.dataId), u = t6.readSync(s.dataId), c = t6.readSync(a.dataId)[0], [l, m, d, f, h] = m$(i, o.shape, o.dtype, p, n.dtype, u, c);
+ return [t6.makeTensorInfo(m, o.dtype, l), t6.makeTensorInfo([m[0]], n.dtype, d), t6.makeTensorInfo([f.length], "bool", new Uint8Array(f.map((g) => Number(g)))), t6.makeTensorInfo([h.length], o.dtype, new Int32Array(h))];
}
-var mD = { kernelName: Qa, backendName: "webgl", kernelFunc: XZ };
-function YZ(r) {
- let { inputs: e, backend: t10 } = r, { inputIndices: o, inputShape: n, newShape: s } = e;
+var zF = { kernelName: ui, backendName: "webgl", kernelFunc: xZ };
+function yZ(r) {
+ let { inputs: e, backend: t6 } = r, { inputIndices: o, inputShape: n, newShape: s } = e;
if (o.shape.length !== 2)
throw new Error(`Input indices should be a matrix but received shape ${o.shape}`);
if (n.shape.length !== 1)
throw new Error(`Input shape should be a vector but received shape ${n.shape}`);
if (s.shape.length !== 1)
throw new Error(`Target shape should be a vector but received shape ${s.shape}`);
- let a = Array.from(t10.readSync(n.dataId)), i = t10.readSync(o.dataId), p = Array.from(t10.readSync(s.dataId)), [u, c, l] = L$(i, o.shape, o.dtype, a, p);
- return [t10.makeTensorInfo(c, o.dtype, u), t10.makeTensorInfo([l.length], s.dtype, new Int32Array(l))];
+ let a = Array.from(t6.readSync(n.dataId)), i = t6.readSync(o.dataId), p = Array.from(t6.readSync(s.dataId)), [u, c, l] = d$(i, o.shape, o.dtype, a, p);
+ return [t6.makeTensorInfo(c, o.dtype, u), t6.makeTensorInfo([l.length], s.dtype, new Int32Array(l))];
}
-var fD = { kernelName: ga, backendName: "webgl", kernelFunc: YZ };
-function QZ(r) {
- let { inputs: e, backend: t10 } = r, { data: o, indices: n, segmentIds: s } = e;
+var WF = { kernelName: wa, backendName: "webgl", kernelFunc: yZ };
+function bZ(r) {
+ let { inputs: e, backend: t6 } = r, { data: o, indices: n, segmentIds: s } = e;
if (o.shape.length < 1)
throw new Error("Data should be at least 1 dimensional but received scalar");
if (n.shape.length !== 1)
@@ -23522,12 +23588,12 @@ function QZ(r) {
if (s.shape.length !== 1)
throw new Error(`Segment ids should be a vector but received shape
${s.shape}`);
- let a = t10.readSync(o.dataId), i = t10.readSync(n.dataId), p = t10.readSync(s.dataId), [u, c] = sh(a, o.shape, o.dtype, i, p, true);
- return t10.makeTensorInfo(c, o.dtype, u);
+ let a = t6.readSync(o.dataId), i = t6.readSync(n.dataId), p = t6.readSync(s.dataId), [u, c] = jf(a, o.shape, o.dtype, i, p, true);
+ return t6.makeTensorInfo(c, o.dtype, u);
}
-var dD = { kernelName: Za, backendName: "webgl", kernelFunc: QZ };
-function ZZ(r) {
- let { inputs: e, backend: t10 } = r, { data: o, indices: n, segmentIds: s } = e;
+var UF = { kernelName: pi, backendName: "webgl", kernelFunc: bZ };
+function CZ(r) {
+ let { inputs: e, backend: t6 } = r, { data: o, indices: n, segmentIds: s } = e;
if (o.shape.length < 1)
throw new Error("Data should be at least 1 dimensional but received scalar");
if (n.shape.length !== 1)
@@ -23536,48 +23602,48 @@ function ZZ(r) {
if (s.shape.length !== 1)
throw new Error(`Segment ids should be a vector but received shape
${s.shape}`);
- let a = t10.readSync(o.dataId), i = t10.readSync(n.dataId), p = t10.readSync(s.dataId), [u, c] = sh(a, o.shape, o.dtype, i, p);
- return t10.makeTensorInfo(c, o.dtype, u);
+ let a = t6.readSync(o.dataId), i = t6.readSync(n.dataId), p = t6.readSync(s.dataId), [u, c] = jf(a, o.shape, o.dtype, i, p);
+ return t6.makeTensorInfo(c, o.dtype, u);
}
-var hD = { kernelName: Ja, backendName: "webgl", kernelFunc: ZZ };
-function JZ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { sparseIndices: n, sparseValues: s, defaultValue: a } = e, { outputShape: i } = o, { sliceRank: p, numUpdates: u, sliceSize: c, strides: l, outputSize: m } = I.calculateShapes(s, n, i), f = false;
+var GF = { kernelName: ci, backendName: "webgl", kernelFunc: CZ };
+function SZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { sparseIndices: n, sparseValues: s, defaultValue: a } = e, { outputShape: i } = o, { sliceRank: p, numUpdates: u, sliceSize: c, strides: l, outputSize: m } = S.calculateShapes(s, n, i), d = false;
if (s.dtype === "string") {
- let y = t10.bufferSync(n), b = t10.bufferSync(s), C = x.decodeString(t10.readSync(a.dataId)[0]), w = D$(y, b, i, m, c, u, p, l, C, f);
- return t10.makeTensorInfo(i, w.dtype, w.values);
+ let x = t6.bufferSync(n), b = t6.bufferSync(s), C = y.decodeString(t6.readSync(a.dataId)[0]), w = p$(x, b, i, m, c, u, p, l, C, d);
+ return t6.makeTensorInfo(i, w.dtype, w.values);
}
- let d = new vc(u, p, n.shape.length, s.shape.length, l, [m, 1], f), h = t10.runWebGLProgram(d, [s, n, a], s.dtype), g = J({ inputs: { x: h }, backend: t10, attrs: { shape: i } });
- return t10.disposeIntermediateTensorInfo(h), g;
+ let f = new Cc(u, p, n.shape.length, s.shape.length, l, [m, 1], d), h = t6.runWebGLProgram(f, [s, n, a], s.dtype), g = te({ inputs: { x: h }, backend: t6, attrs: { shape: i } });
+ return t6.disposeIntermediateTensorInfo(h), g;
}
-var gD = { kernelName: ei, backendName: "webgl", kernelFunc: JZ };
-function e9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { numOrSizeSplits: s, axis: a } = o, i = x.parseAxisParam(a, n.shape)[0], p = I.prepareSplitSize(n, s, i), u = n.shape.length, c = new Array(u).fill(0), l = n.shape.slice();
+var HF = { kernelName: li, backendName: "webgl", kernelFunc: SZ };
+function wZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { numOrSizeSplits: s, axis: a } = o, i = y.parseAxisParam(a, n.shape)[0], p = S.prepareSplitSize(n, s, i), u = n.shape.length, c = new Array(u).fill(0), l = n.shape.slice();
return p.map((m) => {
- let f = [...l];
- f[i] = m;
- let d = ps({ inputs: { x: n }, backend: t10, attrs: { begin: c, size: f } });
- return c[i] += m, d;
+ let d = [...l];
+ d[i] = m;
+ let f = cs({ inputs: { x: n }, backend: t6, attrs: { begin: c, size: d } });
+ return c[i] += m, f;
});
}
-var xD = { kernelName: Ts, backendName: "webgl", kernelFunc: e9 };
-var yD = "return sqrt(x);";
-var t9 = he({ opSnippet: yD, packedOpSnippet: yD, cpuKernelImpl: B$ });
-var bD = { kernelName: bo, backendName: "webgl", kernelFunc: t9 };
-var r9 = "return x * x;";
-var o9 = he({ opSnippet: r9 });
-var CD = { kernelName: ti, backendName: "webgl", kernelFunc: o9 };
-var ID = "return (a - b) * (a - b);";
-var n9 = ot({ opSnippet: ID, packedOpSnippet: ID });
-var wD = { kernelName: Co, backendName: "webgl", kernelFunc: n9 };
-function s9({ inputs: r, attrs: e, backend: t10 }) {
- let { x: o } = r, n = Vt + `
+var qF = { kernelName: $s, backendName: "webgl", kernelFunc: wZ };
+var KF = "return sqrt(x);";
+var IZ = ge({ opSnippet: KF, packedOpSnippet: KF, cpuKernelImpl: f$ });
+var jF = { kernelName: Gn, backendName: "webgl", kernelFunc: IZ };
+var vZ = "return x * x;";
+var kZ = ge({ opSnippet: vZ });
+var XF = { kernelName: mi, backendName: "webgl", kernelFunc: kZ };
+var YF = "return (a - b) * (a - b);";
+var NZ = tt({ opSnippet: YF, packedOpSnippet: YF });
+var QF = { kernelName: Kn, backendName: "webgl", kernelFunc: NZ };
+function TZ({ inputs: r, attrs: e, backend: t6 }) {
+ let { x: o } = r, n = Bt + `
return x > 0.0 ? 1.0 : float(${e.alpha});
- `, s = new fr(o.shape, n);
- return t10.runWebGLProgram(s, [o], o.dtype);
+ `, s = new Jt(o.shape, n);
+ return t6.runWebGLProgram(s, [o], o.dtype);
}
-var SD = { kernelName: $s, backendName: "webgl", kernelFunc: s9 };
-var Sg = class {
- constructor(e, t10, o) {
+var ZF = { kernelName: Ds, backendName: "webgl", kernelFunc: TZ };
+var mg = class {
+ constructor(e, t6, o) {
this.variableNames = ["x"], this.outputShape = o;
let n = o.length, s = _e(o.length), a = _e(o.length), i = "";
if (n === 1)
@@ -23588,7 +23654,7 @@ var Sg = class {
}
this.userCode = `
${s} begin = ${s}(${e});
- ${s} strides = ${s}(${t10});
+ ${s} strides = ${s}(${t6});
void main() {
${a} coords = getOutputCoords();
@@ -23597,69 +23663,69 @@ var Sg = class {
`;
}
};
-function a9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { begin: s, end: a, strides: i, beginMask: p, endMask: u, ellipsisMask: c, newAxisMask: l, shrinkAxisMask: m } = o, { finalShapeSparse: f, finalShape: d, isIdentity: h, sliceDim0: g, isSimpleSlice: y, begin: b, end: C, strides: w } = et.sliceInfo(n.shape, s, a, i, p, u, c, l, m), k;
+function _Z(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { begin: s, end: a, strides: i, beginMask: p, endMask: u, ellipsisMask: c, newAxisMask: l, shrinkAxisMask: m } = o, { finalShapeSparse: d, finalShape: f, isIdentity: h, sliceDim0: g, isSimpleSlice: x, begin: b, end: C, strides: w } = ut.sliceInfo(n.shape, s, a, i, p, u, c, l, m), k;
if (h)
- k = J({ inputs: { x: n }, backend: t10, attrs: { shape: d } });
- else if (g || y) {
- x.assert(n.shape.length >= 1, () => `Input must have rank at least 1, got: ${n.shape.length}`);
- let E = et.computeOutShape(b, C, w), R = ps({ inputs: { x: n }, backend: t10, attrs: { begin: b, size: E } });
- k = J({ inputs: { x: R }, backend: t10, attrs: { shape: d } }), t10.disposeIntermediateTensorInfo(R);
- } else if (t10.shouldExecuteOnCPU([n])) {
- let R = t10.readSync(n.dataId), A = ne(n.shape, n.dtype, R), D = V$(f, A, w, b);
- k = t10.makeTensorInfo(d, n.dtype, D.values);
+ k = te({ inputs: { x: n }, backend: t6, attrs: { shape: f } });
+ else if (g || x) {
+ y.assert(n.shape.length >= 1, () => `Input must have rank at least 1, got: ${n.shape.length}`);
+ let $ = ut.computeOutShape(b, C, w), A = cs({ inputs: { x: n }, backend: t6, attrs: { begin: b, size: $ } });
+ k = te({ inputs: { x: A }, backend: t6, attrs: { shape: f } }), t6.disposeIntermediateTensorInfo(A);
+ } else if (t6.shouldExecuteOnCPU([n])) {
+ let A = t6.readSync(n.dataId), R = le(n.shape, n.dtype, A), D = h$(d, R, w, b);
+ k = t6.makeTensorInfo(f, n.dtype, D.values);
} else {
- let R = new Sg(b, w, f);
- k = t10.runWebGLProgram(R, [n], n.dtype);
+ let A = new mg(b, w, d);
+ k = t6.runWebGLProgram(A, [n], n.dtype);
}
- let _ = J({ inputs: { x: k }, backend: t10, attrs: { shape: d } });
- return t10.disposeIntermediateTensorInfo(k), _;
+ let _ = te({ inputs: { x: k }, backend: t6, attrs: { shape: f } });
+ return t6.disposeIntermediateTensorInfo(k), _;
}
-var vD = { kernelName: Yn, backendName: "webgl", kernelFunc: a9 };
-function i9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { separator: n, nGramWidths: s, leftPad: a, rightPad: i, padWidth: p, preserveShortSequences: u } = o, { data: c, dataSplits: l } = e, m = t10.readSync(c.dataId), f = t10.readSync(l.dataId), [d, h] = z$(m, f, n, s, a, i, p, u);
- return [t10.makeTensorInfo([d.length], "string", d), t10.makeTensorInfo(l.shape, "int32", h)];
+var JF = { kernelName: jn, backendName: "webgl", kernelFunc: _Z };
+function EZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { separator: n, nGramWidths: s, leftPad: a, rightPad: i, padWidth: p, preserveShortSequences: u } = o, { data: c, dataSplits: l } = e, m = t6.readSync(c.dataId), d = t6.readSync(l.dataId), [f, h] = g$(m, d, n, s, a, i, p, u);
+ return [t6.makeTensorInfo([f.length], "string", f), t6.makeTensorInfo(l.shape, "int32", h)];
}
-var kD = { kernelName: Ns, backendName: "webgl", kernelFunc: i9 };
-function u9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { skipEmpty: n } = o, { input: s, delimiter: a } = e;
+var eD = { kernelName: As, backendName: "webgl", kernelFunc: EZ };
+function $Z(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { skipEmpty: n } = o, { input: s, delimiter: a } = e;
if (s.dtype !== "string")
throw new Error("Input must be of datatype string");
if (s.shape.length !== 1)
throw new Error(`Input must be a vector, got shape: ${s.shape}`);
if (a.shape.length !== 0)
throw new Error(`Delimiter must be a scalar, got shape: ${a.shape}`);
- let i = t10.readSync(s.dataId), p = t10.readSync(a.dataId)[0], [u, c, l] = W$(i, p, n), m = c.length;
- return [t10.makeTensorInfo([m, 2], "int32", u), t10.makeTensorInfo([m], "string", c), t10.makeTensorInfo([2], "int32", new Int32Array(l))];
+ let i = t6.readSync(s.dataId), p = t6.readSync(a.dataId)[0], [u, c, l] = x$(i, p, n), m = c.length;
+ return [t6.makeTensorInfo([m, 2], "int32", u), t6.makeTensorInfo([m], "string", c), t6.makeTensorInfo([2], "int32", new Int32Array(l))];
}
-var TD = { kernelName: ri, backendName: "webgl", kernelFunc: u9 };
-function p9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { numBuckets: n } = o, { input: s } = e;
+var tD = { kernelName: di, backendName: "webgl", kernelFunc: $Z };
+function AZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { numBuckets: n } = o, { input: s } = e;
if (s.dtype !== "string")
throw new Error("Input must be of datatype string");
if (n <= 0)
throw new Error("Number of buckets must be at least 1");
- let a = t10.readSync(s.dataId), i = U$(a, n);
- return t10.makeTensorInfo(s.shape, "int32", i);
+ let a = t6.readSync(s.dataId), i = y$(a, n);
+ return t6.makeTensorInfo(s.shape, "int32", i);
}
-var ND = { kernelName: oi, backendName: "webgl", kernelFunc: p9 };
-var c9 = "return tan(x);";
-var l9 = he({ opSnippet: c9 });
-var _D = { kernelName: xa, backendName: "webgl", kernelFunc: l9 };
-var m9 = `
+var rD = { kernelName: fi, backendName: "webgl", kernelFunc: AZ };
+var RZ = "return tan(x);";
+var FZ = ge({ opSnippet: RZ });
+var oD = { kernelName: Yn, backendName: "webgl", kernelFunc: FZ };
+var DZ = `
float e2x = exp(-2.0 * abs(x));
return sign(x) * (1.0 - e2x) / (1.0 + e2x);
`;
-var f9 = he({ opSnippet: m9 });
-var ED = { kernelName: Qn, backendName: "webgl", kernelFunc: f9 };
-var vg = class {
- constructor(e, t10) {
+var OZ = ge({ opSnippet: DZ });
+var nD = { kernelName: Qn, backendName: "webgl", kernelFunc: OZ };
+var dg = class {
+ constructor(e, t6) {
this.variableNames = ["A"];
let o = new Array(e.length);
for (let a = 0; a < o.length; a++)
- o[a] = e[a] * t10[a];
+ o[a] = e[a] * t6[a];
this.outputShape = o, this.rank = o.length;
- let n = _e(this.rank), s = d9(e);
+ let n = _e(this.rank), s = PZ(e);
this.userCode = `
void main() {
${n} resRC = getOutputCoords();
@@ -23668,28 +23734,28 @@ var vg = class {
`;
}
};
-function d9(r) {
+function PZ(r) {
let e = r.length;
if (e > 5)
throw Error(`Tile for rank ${e} is not yet supported`);
if (e === 1)
return `imod(resRC, ${r[0]})`;
- let t10 = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u"], o = [];
+ let t6 = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u"], o = [];
for (let n = 0; n < r.length; n++)
- o.push(`imod(${t10[n]}, ${r[n]})`);
+ o.push(`imod(${t6[n]}, ${r[n]})`);
return o.join();
}
-function Hw(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { reps: s } = o;
+function Vw(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { reps: s } = o;
if (n.dtype === "string" || n.shape.length > 5) {
- let p = t10.readSync(n.dataId), u = n.dtype === "string" ? p.map((m) => x.decodeString(m)) : p, c = ne(n.shape, n.dtype, u), l = H$(c, s);
- return t10.makeTensorInfo(l.shape, l.dtype, l.values);
+ let p = t6.readSync(n.dataId), u = n.dtype === "string" ? p.map((m) => y.decodeString(m)) : p, c = le(n.shape, n.dtype, u), l = C$(c, s);
+ return t6.makeTensorInfo(l.shape, l.dtype, l.values);
}
- let a = new vg(n.shape, s);
- return t10.runWebGLProgram(a, [n], n.dtype);
+ let a = new dg(n.shape, s);
+ return t6.runWebGLProgram(a, [n], n.dtype);
}
-var $D = { kernelName: wo, backendName: "webgl", kernelFunc: Hw };
-var kg = class {
+var sD = { kernelName: to, backendName: "webgl", kernelFunc: Vw };
+var fg = class {
constructor(e) {
this.variableNames = ["x", "indices"], this.customUniforms = [{ name: "n", type: "int" }, { name: "firstPass", type: "int" }, { name: "negativeInf", type: "float" }, { name: "dir", type: "int" }, { name: "inc", type: "int" }], this.outputShape = e, this.userCode = `
void main() {
@@ -23734,7 +23800,7 @@ var kg = class {
`;
}
};
-var Tg = class {
+var hg = class {
constructor(e) {
this.variableNames = ["x", "indices"], this.customUniforms = [{ name: "n", type: "int" }, { name: "firstPass", type: "int" }, { name: "k", type: "int" }], this.outputShape = e, this.userCode = `
void main() {
@@ -23773,55 +23839,55 @@ var Tg = class {
`;
}
};
-function Vu(r, e) {
+function Bu(r, e) {
e !== null && r.disposeIntermediateTensorInfo(e);
}
-function RD(r) {
+function aD(r) {
let e = 1;
for (; e < r; )
e *= 2;
return e;
}
-function h9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { k: s, sorted: a } = o, i = P().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"), p = P().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"), u = n.shape, c = u[u.length - 1];
- if (t10.shouldExecuteOnCPU([n]) || c < i || s > p) {
- let D = t10.readSync(n.dataId), [O, M] = q$(D, u, n.dtype, s, a);
- return [t10.makeTensorInfo(O.shape, O.dtype, O.values), t10.makeTensorInfo(M.shape, M.dtype, M.values)];
+function MZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { k: s, sorted: a } = o, i = O().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"), p = O().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"), u = n.shape, c = u[u.length - 1];
+ if (t6.shouldExecuteOnCPU([n]) || c < i || s > p) {
+ let D = t6.readSync(n.dataId), [P, M] = S$(D, u, n.dtype, s, a);
+ return [t6.makeTensorInfo(P.shape, P.dtype, P.values), t6.makeTensorInfo(M.shape, M.dtype, M.values)];
}
if (s === 0)
- return u[u.length - 1] = 0, [t10.makeTensorInfo(u, n.dtype, []), t10.makeTensorInfo(u, "int32", [])];
+ return u[u.length - 1] = 0, [t6.makeTensorInfo(u, n.dtype, []), t6.makeTensorInfo(u, "int32", [])];
if (c === 1)
- return [n, Ba({ attrs: { shape: u, dtype: "int32", value: 0 }, backend: t10 })];
- let l = t10.texData.get(n.dataId), m = l !== null && l.isPacked, f = m ? t10.unpackTensor(n) : n, h = x.sizeFromShape(u) / c, g = J({ inputs: { x: f }, attrs: { shape: [h, c] }, backend: t10 });
- m && Vu(t10, f);
- let y = RD(s), b = RD(c), C = null, w = () => C === null ? [g, g] : [g, C], k = (D, O, M) => {
- let L = w(), W = new kg(M), G = [[c], [C === null ? 1 : 0], [Number.NEGATIVE_INFINITY], [D], [O]], q = C;
- C = t10.runWebGLProgram(W, L, "int32", G), Vu(t10, q);
+ return [n, Ga({ attrs: { shape: u, dtype: "int32", value: 0 }, backend: t6 })];
+ let l = t6.texData.get(n.dataId), m = l !== null && l.isPacked, d = m ? t6.unpackTensor(n) : n, h = y.sizeFromShape(u) / c, g = te({ inputs: { x: d }, attrs: { shape: [h, c] }, backend: t6 });
+ m && Bu(t6, d);
+ let x = aD(s), b = aD(c), C = null, w = () => C === null ? [g, g] : [g, C], k = (D, P, M) => {
+ let L = w(), W = new fg(M), U = [[c], [C === null ? 1 : 0], [Number.NEGATIVE_INFINITY], [D], [P]], q = C;
+ C = t6.runWebGLProgram(W, L, "int32", U), Bu(t6, q);
};
- for (let D = 1; D < y; D *= 2) {
- let O = D * 2;
+ for (let D = 1; D < x; D *= 2) {
+ let P = D * 2;
for (let M = D; M >= 1; M /= 2)
- k(O, M, [h, b]);
+ k(P, M, [h, b]);
}
- for (let D = b; D > y; D /= 2) {
- let O = w(), M = new Tg([h, D / 2]), W = [[c], [C === null ? 1 : 0], [y]], V = C;
- C = t10.runWebGLProgram(M, O, "int32", W), Vu(t10, V);
- let G = y / 2, q = G * 2;
- for (let H = G; H >= 1; H /= 2)
+ for (let D = b; D > x; D /= 2) {
+ let P = w(), M = new hg([h, D / 2]), W = [[c], [C === null ? 1 : 0], [x]], V = C;
+ C = t6.runWebGLProgram(M, P, "int32", W), Bu(t6, V);
+ let U = x / 2, q = U * 2;
+ for (let H = U; H >= 1; H /= 2)
k(q, H, C.shape);
}
let _ = C;
- C = ps({ inputs: { x: C }, backend: t10, attrs: { begin: 0, size: [h, s] } }), Vu(t10, _);
- let E = Lw({ inputs: { x: g, indices: C }, backend: t10, attrs: { axis: 1, batchDims: 1 } });
- Vu(t10, g);
- let R = u.slice(0, -1);
- R.push(s), _ = C, C = J({ inputs: { x: C }, attrs: { shape: R }, backend: t10 }), Vu(t10, _);
- let A = E;
- return E = J({ inputs: { x: E }, attrs: { shape: R }, backend: t10 }), Vu(t10, A), [E, C];
+ C = cs({ inputs: { x: C }, backend: t6, attrs: { begin: 0, size: [h, s] } }), Bu(t6, _);
+ let $ = Fw({ inputs: { x: g, indices: C }, backend: t6, attrs: { axis: 1, batchDims: 1 } });
+ Bu(t6, g);
+ let A = u.slice(0, -1);
+ A.push(s), _ = C, C = te({ inputs: { x: C }, attrs: { shape: A }, backend: t6 }), Bu(t6, _);
+ let R = $;
+ return $ = te({ inputs: { x: $ }, attrs: { shape: A }, backend: t6 }), Bu(t6, R), [$, C];
}
-var AD = { kernelName: Zn, backendName: "webgl", kernelFunc: h9 };
-var Ng = class {
- constructor(e, t10, o, n, s, a) {
+var iD = { kernelName: Zn, backendName: "webgl", kernelFunc: MZ };
+var gg = class {
+ constructor(e, t6, o, n, s, a) {
this.variableNames = ["Image", "Transforms"], this.outputShape = a;
let i = o === "nearest" ? 1 : 2, p;
switch (n) {
@@ -23895,7 +23961,7 @@ var Ng = class {
float readWithFillValue(int batch, int coordY, int coordX,
int channel) {
float outputValue;
- if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t10}) {
+ if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t6}) {
outputValue = getImage(batch, coordY, coordX, channel);
} else {
outputValue = float(${s});
@@ -23926,7 +23992,7 @@ var Ng = class {
} else {
float inX = (a1 * xf + a2 * yf + a3) / projection;
float inY = (b1 * xf + b2 * yf + b3) / projection;
- float mapX = mapCoord(inX, float(${t10}));
+ float mapX = mapCoord(inX, float(${t6}));
float mapY = mapCoord(inY, float(${e}));
if (${i} == 1) {
@@ -23956,50 +24022,50 @@ var Ng = class {
`;
}
};
-function g9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { image: n, transforms: s } = e, { interpolation: a, fillMode: i, fillValue: p, outputShape: u } = o, [c, l, m, f] = n.shape, [d, h] = u != null ? u : [l, m], g = [c, d, h, f], y = new Ng(l, m, a, i, p, g);
- return t10.runWebGLProgram(y, [n, s], "float32");
+function LZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { image: n, transforms: s } = e, { interpolation: a, fillMode: i, fillValue: p, outputShape: u } = o, [c, l, m, d] = n.shape, [f, h] = u != null ? u : [l, m], g = [c, f, h, d], x = new gg(l, m, a, i, p, g);
+ return t6.runWebGLProgram(x, [n, s], "float32");
}
-var FD = { kernelName: Jn, backendName: "webgl", kernelFunc: g9 };
-function x9(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { axis: n } = t10, { x: s } = e;
- as(s, "unique"), console.warn("WARNING: ", "UI might be locked temporarily as data is being downloaded");
- let a = o.readSync(s.dataId), { outputValues: i, outputShape: p, indices: u } = K$(a, n, s.shape, s.dtype);
+var uD = { kernelName: Jn, backendName: "webgl", kernelFunc: LZ };
+function BZ(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { axis: n } = t6, { x: s } = e;
+ is(s, "unique"), console.warn("WARNING: ", "UI might be locked temporarily as data is being downloaded");
+ let a = o.readSync(s.dataId), { outputValues: i, outputShape: p, indices: u } = w$(a, n, s.shape, s.dtype);
return [o.makeTensorInfo(p, s.dtype, i), o.makeTensorInfo([u.length], "int32", u)];
}
-var DD = { kernelName: $p, backendName: "webgl", kernelFunc: x9 };
-function y9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { value: n } = e, { axis: s } = o;
+var pD = { kernelName: kp, backendName: "webgl", kernelFunc: BZ };
+function VZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { value: n } = e, { axis: s } = o;
s < 0 && (s += n.shape.length);
let a = n, i = a.shape.length, p = n.shape[s], u = new Array(i - 1), c = 0;
for (let h = 0; h < i; h++)
h !== s && (u[c++] = a.shape[h]);
- let l = [], m = new Array(i).fill(0), f = a.shape.slice();
- f[s] = 1;
- let d = new Array(p);
- for (let h = 0; h < d.length; h++) {
+ let l = [], m = new Array(i).fill(0), d = a.shape.slice();
+ d[s] = 1;
+ let f = new Array(p);
+ for (let h = 0; h < f.length; h++) {
m[s] = h;
- let g = ps({ inputs: { x: a }, backend: t10, attrs: { begin: m, size: f } }), y = J({ inputs: { x: g }, backend: t10, attrs: { shape: u } });
- d[h] = y, l.push(g);
+ let g = cs({ inputs: { x: a }, backend: t6, attrs: { begin: m, size: d } }), x = te({ inputs: { x: g }, backend: t6, attrs: { shape: u } });
+ f[h] = x, l.push(g);
}
- return l.forEach((h) => t10.disposeIntermediateTensorInfo(h)), d;
+ return l.forEach((h) => t6.disposeIntermediateTensorInfo(h)), f;
}
-var PD = { kernelName: _s, backendName: "webgl", kernelFunc: y9 };
-var _g = class {
- constructor(e, t10) {
+var cD = { kernelName: Rs, backendName: "webgl", kernelFunc: VZ };
+var xg = class {
+ constructor(e, t6) {
this.variableNames = ["x", "segmentIds"];
let o = e.windowSize, n = e.batchSize, s = e.inSize, a = e.numSegments, i = a * Math.ceil(s / o);
this.outputShape = [n, i];
let p = "0.0", u = "sumValue", c = Math.floor(o / 4) * 4, l = o % 4, m = `
sumValue += dot(values, segFilter);
- `, f = "";
- s % o > 0 && (f = `
+ `, d = "";
+ s % o > 0 && (d = `
if (inIdx < 0 || inIdx >= ${s}) {
return initializationValue;
}
`);
- let d = "";
- s % o > 0 && (d = `
+ let f = "";
+ s % o > 0 && (f = `
if (inIdx < 0 || inIdx >= ${s}) {
return -1.0;
}
@@ -24007,12 +24073,12 @@ var _g = class {
const float initializationValue = ${p};
float getValue(int batch, int inIdx) {
- ${f}
+ ${d}
return getX(batch, inIdx);
}
float getSegmentIdAtIndex(int inIdx) {
- ${d}
+ ${f}
return getSegmentIds(inIdx);
}
@@ -24102,961 +24168,963 @@ var _g = class {
`;
}
};
-function b9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n, segmentIds: s } = e, { numSegments: a } = o, i = n.shape.length, p = [], u = 0, c = I.getAxesPermutation([u], i), l = n;
- c != null && (l = xt({ inputs: { x: n }, backend: t10, attrs: { perm: c } }), p.push(l), u = I.getInnerMostAxes(1, i)[0]);
- let m = I.segment_util.computeOutShape(l.shape, u, a), f = x.sizeFromShape([l.shape[u]]), d = J({ inputs: { x: l }, backend: t10, attrs: { shape: [-1, f] } });
- p.push(d);
- let h = Ca(n.dtype), g = (w, k, _, E, R) => {
- let A = w.shape[0], D = w.shape[1], O = I.segment_util.segOpComputeOptimalWindowSize(D, R), M = { windowSize: O, inSize: D, batchSize: A, numSegments: R }, L = new _g(M, k), W = t10.compileAndRun(L, [w, _], E);
- if (p.push(W), W.shape[1] === R)
+function zZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n, segmentIds: s } = e, { numSegments: a } = o, i = n.shape.length, p = [], u = 0, c = S.getAxesPermutation([u], i), l = n;
+ c != null && (l = xt({ inputs: { x: n }, backend: t6, attrs: { perm: c } }), p.push(l), u = S.getInnerMostAxes(1, i)[0]);
+ let m = S.segment_util.computeOutShape(l.shape, u, a), d = y.sizeFromShape([l.shape[u]]), f = te({ inputs: { x: l }, backend: t6, attrs: { shape: [-1, d] } });
+ p.push(f);
+ let h = ka(n.dtype), g = (w, k, _, $, A) => {
+ let R = w.shape[0], D = w.shape[1], P = S.segment_util.segOpComputeOptimalWindowSize(D, A), M = { windowSize: P, inSize: D, batchSize: R, numSegments: A }, L = new xg(M, k), W = t6.compileAndRun(L, [w, _], $);
+ if (p.push(W), W.shape[1] === A)
return W;
- let V = Gw({ backend: t10, attrs: { start: 0, stop: R, step: 1, dtype: "float32" } }), G = Hw({ inputs: { x: V }, backend: t10, attrs: { reps: [D / O] } });
- return p.push(V), p.push(G), g(W, k, G, E, R);
- }, y = g(d, "unsortedSegmentSum", s, h, a), b = J({ inputs: { x: y }, backend: t10, attrs: { shape: m } }), C = b;
+ let V = Bw({ backend: t6, attrs: { start: 0, stop: A, step: 1, dtype: "float32" } }), U = Vw({ inputs: { x: V }, backend: t6, attrs: { reps: [D / P] } });
+ return p.push(V), p.push(U), g(W, k, U, $, A);
+ }, x = g(f, "unsortedSegmentSum", s, h, a), b = te({ inputs: { x }, backend: t6, attrs: { shape: m } }), C = b;
if (c != null) {
p.push(b);
- let w = I.getUndoAxesPermutation(c);
- C = xt({ inputs: { x: C }, backend: t10, attrs: { perm: w } });
+ let w = S.getUndoAxesPermutation(c);
+ C = xt({ inputs: { x: C }, backend: t6, attrs: { perm: w } });
}
- return p.forEach((w) => t10.disposeIntermediateTensorInfo(w)), C;
+ return p.forEach((w) => t6.disposeIntermediateTensorInfo(w)), C;
}
-var OD = { kernelName: Rp, backendName: "webgl", kernelFunc: b9 };
-var C9 = [IR, SR, vR, kR, NR, _R, ER, $R, FR, DR, PR, OR, MR, LR, BR, VR, zR, WR, UR, GR, HR, KR, jR, XR, JR, tA, rA, lR, nA, aA, iA, uA, pA, cA, lA, mA, fA, dA, hA, yA, bA, CA, IA, wA, SA, vA, kA, TA, NA, _A, EA, $A, RA, AA, FA, PA, OA, MA, LA, VA, zA, WA, UA, GA, HA, qA, KA, jA, cR, XA, sA, YA, QA, ZA, mR, JA, eF, tF, rF, oF, nF, sF, aF, iF, uF, cF, lF, mF, fF, dF, hF, xF, bF, CF, IF, wF, SF, _F, hR, EF, $F, RF, AF, YR, FF, OF, MF, LF, BF, fR, VF, zF, WF, UF, GF, QR, vF, HF, qF, KF, xR, jF, XF, YF, QF, ZF, JF, eD, tD, rD, oD, nD, sD, aD, iD, uD, pD, qR, NF, cD, lD, mD, fD, dD, hD, gD, xD, bD, CD, wD, SD, vD, kD, TD, ND, TF, bR, _D, ED, $D, AD, FD, CR, DD, PD, OD, DF];
-for (let r of C9)
- ya(r);
-var Ae;
+var lD = { kernelName: Np, backendName: "webgl", kernelFunc: zZ };
+var WZ = [Y$, Z$, J$, eA, rA, oA, nA, sA, uA, pA, cA, lA, mA, dA, fA, hA, gA, xA, yA, bA, CA, wA, IA, vA, _A, $A, AA, V$, FA, OA, PA, MA, LA, BA, VA, zA, WA, UA, GA, KA, jA, XA, YA, QA, ZA, JA, eR, tR, rR, oR, nR, sR, aR, iR, uR, cR, lR, mR, dR, hR, gR, xR, yR, bR, CR, SR, wR, IR, B$, vR, DA, kR, NR, TR, z$, _R, ER, $R, AR, RR, FR, DR, OR, PR, MR, BR, VR, zR, WR, UR, GR, qR, jR, XR, YR, QR, ZR, oF, G$, nF, sF, aF, iF, kA, uF, lF, mF, dF, fF, W$, hF, gF, xF, yF, bF, NA, JR, CF, SF, wF, q$, IF, vF, kF, NF, TF, _F, EF, $F, AF, RF, FF, DF, OF, PF, MF, LF, SA, rF, BF, VF, zF, WF, UF, GF, HF, qF, jF, XF, QF, ZF, JF, eD, tD, rD, tF, j$, oD, nD, sD, iD, uD, X$, pD, cD, lD, pF];
+for (let r of WZ)
+ Ia(r);
+var Fe;
(function(r) {
r[r.float32 = 0] = "float32", r[r.int32 = 1] = "int32", r[r.bool = 2] = "bool", r[r.string = 3] = "string", r[r.complex64 = 4] = "complex64";
-})(Ae || (Ae = {}));
-var $i;
+})(Fe || (Fe = {}));
+var Wi;
(function(r) {
r[r.linear = 0] = "linear", r[r.relu = 1] = "relu", r[r.relu6 = 2] = "relu6", r[r.prelu = 3] = "prelu", r[r.leakyrelu = 4] = "leakyrelu", r[r.sigmoid = 5] = "sigmoid", r[r.elu = 6] = "elu";
-})($i || ($i = {}));
-var MD;
-function I9(r) {
- MD = r.wasm.cwrap(Fo, null, ["number", "array", "number", "number", "array", "number", "number", "number", "number", "number", "number", "number", "number"]);
+})(Wi || (Wi = {}));
+var mD;
+function UZ(r) {
+ mD = r.wasm.cwrap(fo, null, ["number", "array", "number", "number", "array", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function w9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { a: n, b: s, bias: a, preluActivationWeights: i } = e;
+function GZ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { a: n, b: s, bias: a, preluActivationWeights: i } = e;
if (n.dtype !== "float32" || s.dtype !== "float32")
throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");
- let { transposeA: p, transposeB: u, activation: c, leakyreluAlpha: l } = o, m = t10.dataIdMap.get(n.dataId).id, f = t10.dataIdMap.get(s.dataId).id, d = 0;
+ let { transposeA: p, transposeB: u, activation: c, leakyreluAlpha: l } = o, m = t6.dataIdMap.get(n.dataId).id, d = t6.dataIdMap.get(s.dataId).id, f = 0;
if (a != null) {
- let R = t10.dataIdMap.get(a.dataId);
- if (R.shape.length !== 1)
- throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${R.shape.length}.`);
- d = R.id;
+ let A = t6.dataIdMap.get(a.dataId);
+ if (A.shape.length !== 1)
+ throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${A.shape.length}.`);
+ f = A.id;
}
- let h = i == null ? 0 : t10.dataIdMap.get(i.dataId).id, g = $i[c];
+ let h = i == null ? 0 : t6.dataIdMap.get(i.dataId).id, g = Wi[c];
if (g == null)
throw new Error(`${c} activation not yet supported for FusedConv2D in the wasm backend.`);
- let y = p ? n.shape[2] : n.shape[1], b = u ? s.shape[1] : s.shape[2], C = br.assertAndGetBroadcastShape(n.shape.slice(0, -2), s.shape.slice(0, -2)), w = t10.makeOutput([...C, y, b], n.dtype), k = t10.dataIdMap.get(w.dataId).id, _ = new Uint8Array(new Int32Array(n.shape).buffer), E = new Uint8Array(new Int32Array(s.shape).buffer);
- return MD(m, _, n.shape.length, f, E, s.shape.length, p, u, g, d, h, l || 0, k), w;
+ let x = p ? n.shape[2] : n.shape[1], b = u ? s.shape[1] : s.shape[2], C = br.assertAndGetBroadcastShape(n.shape.slice(0, -2), s.shape.slice(0, -2)), w = t6.makeOutput([...C, x, b], n.dtype), k = t6.dataIdMap.get(w.dataId).id, _ = new Uint8Array(new Int32Array(n.shape).buffer), $ = new Uint8Array(new Int32Array(s.shape).buffer);
+ return mD(m, _, n.shape.length, d, $, s.shape.length, p, u, g, f, h, l || 0, k), w;
}
-var LD = { kernelName: Fo, backendName: "wasm", setupFunc: I9, kernelFunc: w9 };
-function Qe(r, e) {
- let t10;
+var dD = { kernelName: fo, backendName: "wasm", setupFunc: UZ, kernelFunc: GZ };
+function Ve(r, e) {
+ let t6;
function o(s) {
- t10 = s.wasm.cwrap(r, null, ["number", "number", "number"]);
+ t6 = s.wasm.cwrap(r, null, ["number", "number", "number"]);
}
function n(s) {
let { backend: a, inputs: { x: i } } = s, p = a.dataIdMap.get(i.dataId).id, u = a.makeOutput(i.shape, e || i.dtype), c = a.dataIdMap.get(u.dataId).id;
- return x.sizeFromShape(u.shape) === 0 || t10(p, Ae[i.dtype], c), u;
+ return y.sizeFromShape(u.shape) === 0 || t6(p, Fe[i.dtype], c), u;
}
return { kernelName: r, backendName: "wasm", setupFunc: o, kernelFunc: n };
}
-var BD = Qe(sn);
-function nt(r, e, t10) {
+var fD = Ve(gs);
+function rt(r, e, t6) {
let o;
function n(a) {
o = a.wasm.cwrap(r, null, ["number", "array", "number", "number", "array", "number", "number", "number"]);
}
function s(a) {
- let { backend: i, inputs: p } = a, { a: u, b: c } = p, l = i.dataIdMap.get(u.dataId).id, m = i.dataIdMap.get(c.dataId).id, f = t10 != null ? t10 : u.dtype, d = I.assertAndGetBroadcastShape(u.shape, c.shape), h = i.makeOutput(d, f);
- if (x.sizeFromShape(d) === 0)
+ let { backend: i, inputs: p } = a, { a: u, b: c } = p, l = i.dataIdMap.get(u.dataId).id, m = i.dataIdMap.get(c.dataId).id, d = t6 != null ? t6 : u.dtype, f = S.assertAndGetBroadcastShape(u.shape, c.shape), h = i.makeOutput(f, d);
+ if (y.sizeFromShape(f) === 0)
return h;
- let g = new Uint8Array(new Int32Array(u.shape).buffer), y = new Uint8Array(new Int32Array(c.shape).buffer), b = i.dataIdMap.get(h.dataId).id;
- return (() => o(l, g, u.shape.length, m, y, c.shape.length, Ae[u.dtype], b))(), h;
+ let g = new Uint8Array(new Int32Array(u.shape).buffer), x = new Uint8Array(new Int32Array(c.shape).buffer), b = i.dataIdMap.get(h.dataId).id;
+ return (() => o(l, g, u.shape.length, m, x, c.shape.length, Fe[u.dtype], b))(), h;
}
return { kernelName: r, backendName: "wasm", setupFunc: n, kernelFunc: s };
}
-var S9 = true;
-var VD = nt(_r, S9);
-var zD;
-function v9(r) {
- zD = r.wasm.cwrap(an, null, ["array", "number", "number", "number"]);
+var HZ = true;
+var hD = rt(eo, HZ);
+var gD;
+function qZ(r) {
+ gD = r.wasm.cwrap(Mo, null, ["array", "number", "number", "number"]);
}
-function k9(r) {
- let { inputs: e, backend: t10 } = r, o = t10.makeOutput(e[0].shape, e[0].dtype);
- if (x.sizeFromShape(o.shape) === 0)
+function KZ(r) {
+ let { inputs: e, backend: t6 } = r, o = t6.makeOutput(e[0].shape, e[0].dtype);
+ if (y.sizeFromShape(o.shape) === 0)
return o;
- let n = e.map((i) => t10.dataIdMap.get(i.dataId).id), s = new Uint8Array(new Int32Array(n).buffer), a = t10.dataIdMap.get(o.dataId).id;
- return zD(s, n.length, Ae[o.dtype], a), o;
+ let n = e.map((i) => t6.dataIdMap.get(i.dataId).id), s = new Uint8Array(new Int32Array(n).buffer), a = t6.dataIdMap.get(o.dataId).id;
+ return gD(s, n.length, Fe[o.dtype], a), o;
}
-var WD = { kernelName: an, backendName: "wasm", setupFunc: v9, kernelFunc: k9 };
-function zu(r) {
- let { inputs: { x: e }, backend: t10 } = r;
+var xD = { kernelName: Mo, backendName: "wasm", setupFunc: qZ, kernelFunc: KZ };
+function Vu(r) {
+ let { inputs: { x: e }, backend: t6 } = r;
if (e.dtype === "string")
- return nr(t10.readSync(e.dataId), e.shape, e.dtype);
- let o = t10.makeOutput(e.shape, e.dtype), n = t10.typedArrayFromHeap(e);
- return t10.typedArrayFromHeap(o).set(n), o;
+ return nr(t6.readSync(e.dataId), e.shape, e.dtype);
+ let o = t6.makeOutput(e.shape, e.dtype), n = t6.typedArrayFromHeap(e);
+ return t6.typedArrayFromHeap(o).set(n), o;
}
-var UD = { kernelName: uo, backendName: "wasm", kernelFunc: zu };
-var GD;
-function T9(r) {
- GD = r.wasm.cwrap(Mr, null, ["number", "array", "number", "number", "number", "array", "number"]);
+var yD = { kernelName: mo, backendName: "wasm", kernelFunc: Vu };
+var bD;
+function jZ(r) {
+ bD = r.wasm.cwrap(ro, null, ["number", "array", "number", "number", "number", "array", "number"]);
}
-function Eo(r) {
- let { inputs: e, backend: t10, attrs: o } = r, [n, s] = _9(e.x.shape, o.perm), a = true;
- for (let d = 0; d < s.length; d++)
- s[d] !== d && (a = false);
- let i = N9(e.x.shape, o.perm), p = { dataId: e.x.dataId, shape: n, dtype: e.x.dtype };
+function uo(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, [n, s] = YZ(e.x.shape, o.perm), a = true;
+ for (let f = 0; f < s.length; f++)
+ s[f] !== f && (a = false);
+ let i = XZ(e.x.shape, o.perm), p = { dataId: e.x.dataId, shape: n, dtype: e.x.dtype };
if (a) {
- let d = zu({ inputs: e, backend: t10 });
- return d.shape = i, d;
+ let f = Vu({ inputs: e, backend: t6 });
+ return f.shape = i, f;
}
- let u = t10.makeOutput(i, p.dtype), c = t10.dataIdMap.get(p.dataId).id, l = t10.dataIdMap.get(u.dataId).id, m = new Uint8Array(new Int32Array(s).buffer), f = new Uint8Array(new Int32Array(p.shape).buffer);
- return GD(c, f, p.shape.length, Ae[p.dtype], l, m, s.length), u;
+ let u = t6.makeOutput(i, p.dtype), c = t6.dataIdMap.get(p.dataId).id, l = t6.dataIdMap.get(u.dataId).id, m = new Uint8Array(new Int32Array(s).buffer), d = new Uint8Array(new Int32Array(p.shape).buffer);
+ return bD(c, d, p.shape.length, Fe[p.dtype], l, m, s.length), u;
}
-function N9(r, e) {
- let t10 = new Array(r.length);
- for (let o = 0; o < t10.length; o++)
- t10[o] = r[e[o]];
- return t10;
+function XZ(r, e) {
+ let t6 = new Array(r.length);
+ for (let o = 0; o < t6.length; o++)
+ t6[o] = r[e[o]];
+ return t6;
}
-function _9(r, e) {
- let t10 = [], o = [];
+function YZ(r, e) {
+ let t6 = [], o = [];
for (let n = 0; n < r.length; ++n)
- r[n] !== 1 && t10.push(r[n]), r[e[n]] !== 1 && o.push(e[n]);
+ r[n] !== 1 && t6.push(r[n]), r[e[n]] !== 1 && o.push(e[n]);
for (let n = 0; n < o.length; ++n) {
let s = -1;
for (let a = 0; a < o.length; ++a)
o[a] >= n && (s === -1 || o[s] > o[a]) && (s = a);
o[s] = n;
}
- return [t10, o];
+ return [t6, o];
}
-var HD = { kernelName: Mr, backendName: "wasm", kernelFunc: Eo, setupFunc: T9 };
-function kr(r, e, t10) {
- let o = r.shape, n = r.shape.length, s = x.parseAxisParam(e, o), a = s, i = I.getAxesPermutation(a, n), p = null, u = false;
+var CD = { kernelName: ro, backendName: "wasm", kernelFunc: uo, setupFunc: jZ };
+function kr(r, e, t6) {
+ let o = r.shape, n = r.shape.length, s = y.parseAxisParam(e, o), a = s, i = S.getAxesPermutation(a, n), p = null, u = false;
if (i != null) {
let c = new Array(n);
- for (let f = 0; f < c.length; f++)
- c[f] = o[i[f]];
- a = I.getInnerMostAxes(a.length, n), p = Eo({ inputs: { x: r }, attrs: { perm: i }, backend: t10 });
- let l = t10.dataIdMap.get(r.dataId).id;
- t10.dataIdMap.get(p.dataId).id !== l && (u = true);
+ for (let d = 0; d < c.length; d++)
+ c[d] = o[i[d]];
+ a = S.getInnerMostAxes(a.length, n), p = uo({ inputs: { x: r }, attrs: { perm: i }, backend: t6 });
+ let l = t6.dataIdMap.get(r.dataId).id;
+ t6.dataIdMap.get(p.dataId).id !== l && (u = true);
}
return { transposed: p, originalAxes: s, axes: a, inputWasTransposed: u };
}
-var qD;
-function E9(r) {
- qD = r.wasm.cwrap(oa, null, ["number, number, number"]);
+var SD;
+function QZ(r) {
+ SD = r.wasm.cwrap(Lo, null, ["number, number, number"]);
}
-function $9(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t10, p = e.dataIdMap.get(a.dataId).id, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: f } = kr(a, n, e);
- if (f) {
+function ZZ(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t6, p = e.dataIdMap.get(a.dataId).id, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: d } = kr(a, n, e);
+ if (d) {
let C = e.dataIdMap.get(c.dataId).id;
u = c, p = C;
}
- let d = u.shape.length;
- I.assertAxesAreInnerMostDims("all", l, d);
- let [h, g] = I.computeOutAndReduceShapes(u.shape, l), y = x.sizeFromShape(g), b = e.makeOutput(h, a.dtype);
- if (x.sizeFromShape(u.shape) !== 0) {
+ let f = u.shape.length;
+ S.assertAxesAreInnerMostDims("all", l, f);
+ let [h, g] = S.computeOutAndReduceShapes(u.shape, l), x = y.sizeFromShape(g), b = e.makeOutput(h, a.dtype);
+ if (y.sizeFromShape(u.shape) !== 0) {
let C = e.dataIdMap.get(b.dataId).id;
- qD(p, y, C);
+ SD(p, x, C);
}
- if (f && e.disposeData(c.dataId), s) {
- let C = I.expandShapeToKeepDim(b.shape, m);
+ if (d && e.disposeData(c.dataId), s) {
+ let C = S.expandShapeToKeepDim(b.shape, m);
b.shape = C;
}
return b;
}
-var KD = { kernelName: oa, backendName: "wasm", setupFunc: E9, kernelFunc: $9 };
-var jD;
-function R9(r) {
- jD = r.wasm.cwrap(na, null, ["number, number, number"]);
+var wD = { kernelName: Lo, backendName: "wasm", setupFunc: QZ, kernelFunc: ZZ };
+var ID;
+function JZ(r) {
+ ID = r.wasm.cwrap(Bo, null, ["number, number, number"]);
}
-function A9(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t10, p = e.dataIdMap.get(a.dataId).id, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: f } = kr(a, n, e);
- if (f) {
+function e9(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t6, p = e.dataIdMap.get(a.dataId).id, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: d } = kr(a, n, e);
+ if (d) {
let C = e.dataIdMap.get(c.dataId).id;
u = c, p = C;
}
- let d = u.shape.length;
- I.assertAxesAreInnerMostDims("any", l, d);
- let [h, g] = I.computeOutAndReduceShapes(u.shape, l), y = x.sizeFromShape(g), b = e.makeOutput(h, a.dtype);
- if (x.sizeFromShape(u.shape) !== 0) {
+ let f = u.shape.length;
+ S.assertAxesAreInnerMostDims("any", l, f);
+ let [h, g] = S.computeOutAndReduceShapes(u.shape, l), x = y.sizeFromShape(g), b = e.makeOutput(h, a.dtype);
+ if (y.sizeFromShape(u.shape) !== 0) {
let C = e.dataIdMap.get(b.dataId).id;
- jD(p, y, C);
+ ID(p, x, C);
}
- if (f && e.disposeData(c.dataId), s) {
- let C = I.expandShapeToKeepDim(b.shape, m);
+ if (d && e.disposeData(c.dataId), s) {
+ let C = S.expandShapeToKeepDim(b.shape, m);
b.shape = C;
}
return b;
}
-var XD = { kernelName: na, backendName: "wasm", setupFunc: R9, kernelFunc: A9 };
-var YD;
-function F9(r) {
- YD = r.wasm.cwrap(un, null, ["number", "number", "number", "number", "number"]);
+var vD = { kernelName: Bo, backendName: "wasm", setupFunc: JZ, kernelFunc: e9 };
+var kD;
+function t9(r) {
+ kD = r.wasm.cwrap(Vo, null, ["number", "number", "number", "number", "number"]);
}
-function D9(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { axis: n } = o, { x: s } = t10, a = e.dataIdMap.get(s.dataId).id, i = a, p = s, { transposed: u, axes: c, inputWasTransposed: l } = kr(s, n, e);
+function r9(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { axis: n } = o, { x: s } = t6, a = e.dataIdMap.get(s.dataId).id, i = a, p = s, { transposed: u, axes: c, inputWasTransposed: l } = kr(s, n, e);
if (l) {
- let y = e.dataIdMap.get(u.dataId).id;
- y !== a && (p = u, i = y);
+ let x = e.dataIdMap.get(u.dataId).id;
+ x !== a && (p = u, i = x);
}
- let m = p.shape.slice(0, -1), f = e.makeOutput(m, "int32"), d = e.dataIdMap.get(f.dataId).id, h = x.sizeFromShape(f.shape), g = p.shape[c[0]];
- return YD(i, Ae[p.dtype], h, g, d), l && e.disposeData(u.dataId), f;
+ let m = p.shape.slice(0, -1), d = e.makeOutput(m, "int32"), f = e.dataIdMap.get(d.dataId).id, h = y.sizeFromShape(d.shape), g = p.shape[c[0]];
+ return kD(i, Fe[p.dtype], h, g, f), l && e.disposeData(u.dataId), d;
}
-var QD = { kernelName: un, backendName: "wasm", kernelFunc: D9, setupFunc: F9 };
-var ZD;
-function P9(r) {
- ZD = r.wasm.cwrap(pn, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var ND = { kernelName: Vo, backendName: "wasm", kernelFunc: r9, setupFunc: t9 };
+var TD;
+function o9(r) {
+ TD = r.wasm.cwrap(zo, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function O9(r) {
- let { inputs: e, attrs: t10, backend: o } = r, n = e.x, s = o.dataIdMap.get(n.dataId).id, { filterSize: a, strides: i, pad: p, dimRoundingMode: u } = t10, c = I.computePool2DInfo(n.shape, a, i, 1, p, u), l = c.filterHeight, m = c.filterWidth, f = c.padInfo.top, d = c.padInfo.right, h = c.padInfo.bottom, g = c.padInfo.left, y = c.strideHeight, b = c.strideWidth, C = c.inChannels;
+function n9(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, n = e.x, s = o.dataIdMap.get(n.dataId).id, { filterSize: a, strides: i, pad: p, dimRoundingMode: u } = t6, c = S.computePool2DInfo(n.shape, a, i, 1, p, u), l = c.filterHeight, m = c.filterWidth, d = c.padInfo.top, f = c.padInfo.right, h = c.padInfo.bottom, g = c.padInfo.left, x = c.strideHeight, b = c.strideWidth, C = c.inChannels;
if (c.dataFormat !== "channelsLast")
throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);
if (c.dilationWidth !== 1 || c.dilationHeight !== 1)
throw new Error(`was backend only supports average pooling with dilation = [1, 1], got [${c.dilationHeight}, ${c.dilationWidth}].`);
let w = o.makeOutput(c.outShape, "float32"), k = o.dataIdMap.get(w.dataId).id;
- return ZD(s, n.shape[0], n.shape[1], n.shape[2], l, m, f, d, h, g, y, b, C, k), w;
+ return TD(s, n.shape[0], n.shape[1], n.shape[2], l, m, d, f, h, g, x, b, C, k), w;
}
-var JD = { kernelName: pn, backendName: "wasm", setupFunc: P9, kernelFunc: O9 };
+var _D = { kernelName: zo, backendName: "wasm", setupFunc: o9, kernelFunc: n9 };
function Mt(r) {
- let { inputs: e, attrs: t10 } = r, { x: o } = e, { shape: n } = t10, s = x.sizeFromShape(o.shape), a = x.inferFromImplicitShape(n, s);
- return x.assert(s === x.sizeFromShape(a), () => `new shape: ${a}, old shape: ${o.shape}. New shape and old shape must have the same number of elements.`), r.backend.incRef(o.dataId), { dataId: o.dataId, shape: a, dtype: o.dtype };
+ let { inputs: e, attrs: t6 } = r, { x: o } = e, { shape: n } = t6, s = y.sizeFromShape(o.shape), a = y.inferFromImplicitShape(n, s);
+ return y.assert(s === y.sizeFromShape(a), () => `new shape: ${a}, old shape: ${o.shape}. New shape and old shape must have the same number of elements.`), r.backend.incRef(o.dataId), { dataId: o.dataId, shape: a, dtype: o.dtype };
}
-var eP = { kernelName: Ss, backendName: "wasm", kernelFunc: Mt };
-var tP;
-function M9(r) {
- tP = r.wasm.cwrap(cn, null, ["number", "array", "number", "number", "array", "number", "number", "number", "number"]);
+var ED = { kernelName: Ns, backendName: "wasm", kernelFunc: Mt };
+var $D;
+function s9(r) {
+ $D = r.wasm.cwrap(Wo, null, ["number", "array", "number", "number", "array", "number", "number", "number", "number"]);
}
-function L9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { a: n, b: s } = e, { transposeA: a, transposeB: i } = o;
+function a9(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { a: n, b: s } = e, { transposeA: a, transposeB: i } = o;
if (n.dtype !== "float32" || s.dtype !== "float32")
throw new Error("BatchMatMul for non non-float32 tensors not yet supported.");
- let p = n.shape.length, u = s.shape.length, c = a ? n.shape[p - 2] : n.shape[p - 1], l = i ? s.shape[u - 1] : s.shape[u - 2], m = a ? n.shape[p - 1] : n.shape[p - 2], f = i ? s.shape[u - 2] : s.shape[u - 1], d = n.shape.slice(0, -2), h = s.shape.slice(0, -2), g = x.sizeFromShape(d), y = x.sizeFromShape(h), C = br.assertAndGetBroadcastShape(n.shape.slice(0, -2), s.shape.slice(0, -2)).concat([m, f]);
- x.assert(c === l, () => `Error in matMul: inner shapes (${c}) and (${l}) of Tensors with shapes ${n.shape} and ${s.shape} and transposeA=${a} and transposeB=${i} must match.`);
- let w = a ? [g, c, m] : [g, m, c], k = i ? [y, f, l] : [y, l, f], _ = Mt({ inputs: { x: n }, backend: t10, attrs: { shape: w } }), E = Mt({ inputs: { x: s }, backend: t10, attrs: { shape: k } }), R = t10.dataIdMap.get(_.dataId).id, A = t10.dataIdMap.get(E.dataId).id, D = a ? _.shape[2] : _.shape[1], O = i ? E.shape[1] : E.shape[2], M = Math.max(g, y), L = t10.makeOutput([M, D, O], _.dtype), W = t10.dataIdMap.get(L.dataId).id, V = new Uint8Array(new Int32Array(_.shape).buffer), G = new Uint8Array(new Int32Array(E.shape).buffer);
- return tP(R, V, _.shape.length, A, G, E.shape.length, a, i, W), t10.disposeData(_.dataId), t10.disposeData(E.dataId), L.shape = C, L;
+ let p = n.shape.length, u = s.shape.length, c = a ? n.shape[p - 2] : n.shape[p - 1], l = i ? s.shape[u - 1] : s.shape[u - 2], m = a ? n.shape[p - 1] : n.shape[p - 2], d = i ? s.shape[u - 2] : s.shape[u - 1], f = n.shape.slice(0, -2), h = s.shape.slice(0, -2), g = y.sizeFromShape(f), x = y.sizeFromShape(h), C = br.assertAndGetBroadcastShape(n.shape.slice(0, -2), s.shape.slice(0, -2)).concat([m, d]);
+ y.assert(c === l, () => `Error in matMul: inner shapes (${c}) and (${l}) of Tensors with shapes ${n.shape} and ${s.shape} and transposeA=${a} and transposeB=${i} must match.`);
+ let w = a ? [g, c, m] : [g, m, c], k = i ? [x, d, l] : [x, l, d], _ = Mt({ inputs: { x: n }, backend: t6, attrs: { shape: w } }), $ = Mt({ inputs: { x: s }, backend: t6, attrs: { shape: k } }), A = t6.dataIdMap.get(_.dataId).id, R = t6.dataIdMap.get($.dataId).id, D = a ? _.shape[2] : _.shape[1], P = i ? $.shape[1] : $.shape[2], M = Math.max(g, x), L = t6.makeOutput([M, D, P], _.dtype), W = t6.dataIdMap.get(L.dataId).id, V = new Uint8Array(new Int32Array(_.shape).buffer), U = new Uint8Array(new Int32Array($.shape).buffer);
+ return $D(A, V, _.shape.length, R, U, $.shape.length, a, i, W), t6.disposeData(_.dataId), t6.disposeData($.dataId), L.shape = C, L;
}
-var rP = { kernelName: cn, backendName: "wasm", setupFunc: M9, kernelFunc: L9 };
-function Xo(r) {
- let { inputs: { x: e }, attrs: { begin: t10, size: o }, backend: n } = r, [s, a] = et.parseSliceParams(e, t10, o), i = et.isSliceContinous(e.shape, s, a), p = n.readSync(e.dataId), u = n.makeOutput(a, e.dtype), c = x.computeStrides(e.shape), l = n.dataIdMap.get(u.dataId);
+var AD = { kernelName: Wo, backendName: "wasm", setupFunc: s9, kernelFunc: a9 };
+function Eo(r) {
+ let { inputs: { x: e }, attrs: { begin: t6, size: o }, backend: n } = r, [s, a] = ut.parseSliceParams(e, t6, o), i = ut.isSliceContinous(e.shape, s, a), p = n.readSync(e.dataId), u = n.makeOutput(a, e.dtype), c = y.computeStrides(e.shape), l = n.dataIdMap.get(u.dataId);
if (i) {
- let d = et.computeFlatOffset(s, c);
- return e.dtype === "string" ? l.stringBytes = p.slice(d, d + x.sizeFromShape(a)) : n.typedArrayFromHeap(u).set(p.subarray(d, d + x.sizeFromShape(a))), u;
+ let f = ut.computeFlatOffset(s, c);
+ return e.dtype === "string" ? l.stringBytes = p.slice(f, f + y.sizeFromShape(a)) : n.typedArrayFromHeap(u).set(p.subarray(f, f + y.sizeFromShape(a))), u;
}
if (e.dtype === "string") {
- let d = vu(p, s, a, e.shape, e.dtype);
- return l.stringBytes = d, u;
+ let f = vu(p, s, a, e.shape, e.dtype);
+ return l.stringBytes = f, u;
}
- let m = n.typedArrayFromHeap(u), f = e.shape.length;
- if (f === 2)
- B9(p, c[0], m, s, a);
- else if (f === 3)
- V9(p, c[0], c[1], m, s, a);
- else if (f === 4)
- z9(p, c[0], c[1], c[2], m, s, a);
+ let m = n.typedArrayFromHeap(u), d = e.shape.length;
+ if (d === 2)
+ i9(p, c[0], m, s, a);
+ else if (d === 3)
+ u9(p, c[0], c[1], m, s, a);
+ else if (d === 4)
+ p9(p, c[0], c[1], c[2], m, s, a);
else {
- let d = vu(p, s, a, e.shape, e.dtype);
- m.set(d);
+ let f = vu(p, s, a, e.shape, e.dtype);
+ m.set(f);
}
return u;
}
-function B9(r, e, t10, o, n) {
+function i9(r, e, t6, o, n) {
let s = 0, a = o[0], i = o[1], p = a + n[0];
for (let u = a; u < p; u++) {
let c = u * e + i;
- t10.set(r.subarray(c, c + n[1]), s), s += n[1];
+ t6.set(r.subarray(c, c + n[1]), s), s += n[1];
}
}
-function V9(r, e, t10, o, n, s) {
+function u9(r, e, t6, o, n, s) {
let a = 0, i = n[0], p = n[1], u = n[2], c = i + s[0], l = p + s[1];
for (let m = i; m < c; m++)
- for (let f = p; f < l; f++) {
- let d = m * e + f * t10 + u;
- o.set(r.subarray(d, d + s[2]), a), a += s[2];
+ for (let d = p; d < l; d++) {
+ let f = m * e + d * t6 + u;
+ o.set(r.subarray(f, f + s[2]), a), a += s[2];
}
}
-function z9(r, e, t10, o, n, s, a) {
- let i = 0, p = s[0], u = s[1], c = s[2], l = p + a[0], m = u + a[1], f = c + a[2], d = s[3];
+function p9(r, e, t6, o, n, s, a) {
+ let i = 0, p = s[0], u = s[1], c = s[2], l = p + a[0], m = u + a[1], d = c + a[2], f = s[3];
for (let h = p; h < l; h++)
for (let g = u; g < m; g++)
- for (let y = c; y < f; y++) {
- let b = h * e + g * t10 + y * o + d;
+ for (let x = c; x < d; x++) {
+ let b = h * e + g * t6 + x * o + f;
n.set(r.subarray(b, b + a[3]), i), i += a[3];
}
}
-var oP = { kernelName: qn, backendName: "wasm", kernelFunc: Xo };
-function W9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { blockShape: s, crops: a } = o, i = s.reduce((y, b) => y * b), p = I.getReshaped(n.shape, s, i), u = I.getPermuted(p.length, s.length), c = I.getReshapedPermuted(n.shape, s, i), l = I.getSliceBeginCoords(a, s.length), m = I.getSliceSize(c, a, s.length), f = Mt({ inputs: { x: n }, backend: t10, attrs: { shape: p } }), d = Eo({ inputs: { x: f }, backend: t10, attrs: { perm: u } }), h = Mt({ inputs: { x: d }, backend: t10, attrs: { shape: c } }), g = Xo({ inputs: { x: h }, backend: t10, attrs: { begin: l, size: m } });
- return t10.disposeData(f.dataId), t10.disposeData(d.dataId), t10.disposeData(f.dataId), g;
+var RD = { kernelName: _s, backendName: "wasm", kernelFunc: Eo };
+function c9(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { blockShape: s, crops: a } = o, i = s.reduce((x, b) => x * b), p = S.getReshaped(n.shape, s, i), u = S.getPermuted(p.length, s.length), c = S.getReshapedPermuted(n.shape, s, i), l = S.getSliceBeginCoords(a, s.length), m = S.getSliceSize(c, a, s.length), d = Mt({ inputs: { x: n }, backend: t6, attrs: { shape: p } }), f = uo({ inputs: { x: d }, backend: t6, attrs: { perm: u } }), h = Mt({ inputs: { x: f }, backend: t6, attrs: { shape: c } }), g = Eo({ inputs: { x: h }, backend: t6, attrs: { begin: l, size: m } });
+ return t6.disposeData(d.dataId), t6.disposeData(f.dataId), t6.disposeData(d.dataId), g;
}
-var nP = { kernelName: hs, backendName: "wasm", kernelFunc: W9 };
-function cs(r) {
- let { inputs: { x: e }, attrs: { dtype: t10 }, backend: o } = r, n = o.makeOutput(e.shape, t10), s = o.typedArrayFromHeap(e);
+var FD = { kernelName: xs, backendName: "wasm", kernelFunc: c9 };
+function ls(r) {
+ let { inputs: { x: e }, attrs: { dtype: t6 }, backend: o } = r, n = o.makeOutput(e.shape, t6), s = o.typedArrayFromHeap(e);
return o.typedArrayFromHeap(n).set(s), n;
}
-var sP = { kernelName: to, backendName: "wasm", kernelFunc: cs };
-var aP = Qe(ro);
-var iP;
-function U9(r) {
- iP = r.wasm.cwrap(Ro, null, ["number", "number", "number", "number"]);
+var DD = { kernelName: co, backendName: "wasm", kernelFunc: ls };
+var OD = Ve(Uo);
+var PD;
+function l9(r) {
+ PD = r.wasm.cwrap(lo, null, ["number", "number", "number", "number"]);
}
-function G9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { clipValueMin: s, clipValueMax: a } = o, i = t10.dataIdMap.get(n.dataId).id, p = t10.makeOutput(n.shape, n.dtype), u = t10.dataIdMap.get(p.dataId).id;
- return iP(i, s, a, u), p;
+function m9(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { clipValueMin: s, clipValueMax: a } = o, i = t6.dataIdMap.get(n.dataId).id, p = t6.makeOutput(n.shape, n.dtype), u = t6.dataIdMap.get(p.dataId).id;
+ return PD(i, s, a, u), p;
}
-var uP = { kernelName: Ro, backendName: "wasm", setupFunc: U9, kernelFunc: G9 };
-function qw(r) {
- let { inputs: e, backend: t10 } = r, o = x.parseAxisParam(r.attrs.axis, e[0].shape)[0], n = e.map((f) => f.shape);
- I.assertParamsConsistent(n, o);
- let s = I.computeOutShape(e.map((f) => f.shape), o), a = e.filter((f) => x.sizeFromShape(f.shape) > 0);
+var MD = { kernelName: lo, backendName: "wasm", setupFunc: l9, kernelFunc: m9 };
+function zw(r) {
+ let { inputs: e, backend: t6 } = r, o = y.parseAxisParam(r.attrs.axis, e[0].shape)[0], n = e.map((d) => d.shape);
+ S.assertParamsConsistent(n, o);
+ let s = S.computeOutShape(e.map((d) => d.shape), o), a = e.filter((d) => y.sizeFromShape(d.shape) > 0);
if (a.length === 1)
- return zu({ inputs: { x: a[0] }, backend: t10 });
- let i = t10.makeOutput(s, e[0].dtype);
- if (x.sizeFromShape(s) === 0)
+ return Vu({ inputs: { x: a[0] }, backend: t6 });
+ let i = t6.makeOutput(s, e[0].dtype);
+ if (y.sizeFromShape(s) === 0)
return i;
if (a[0].dtype === "string") {
- let f = a.map((C) => {
- let k = [-1, x.sizeFromShape(C.shape.slice(o))];
- return Mt({ inputs: { x: C }, backend: t10, attrs: { shape: k } });
- }), d = f.map((C) => ({ vals: t10.readSync(C.dataId), shape: C.shape }));
- s = I.computeOutShape(f.map((C) => C.shape), 1);
- let h = f[0].shape[0] === 1, g = Iu(d, s, e[0].dtype, h), y = I.computeOutShape(a.map((C) => C.shape), o);
- i.shape = y;
- let b = t10.dataIdMap.get(i.dataId);
- return b.stringBytes = I.fromStringArrayToUint8(g), f.forEach((C) => t10.disposeData(C.dataId)), i;
+ let d = a.map((C) => {
+ let k = [-1, y.sizeFromShape(C.shape.slice(o))];
+ return Mt({ inputs: { x: C }, backend: t6, attrs: { shape: k } });
+ }), f = d.map((C) => ({ vals: t6.readSync(C.dataId), shape: C.shape }));
+ s = S.computeOutShape(d.map((C) => C.shape), 1);
+ let h = d[0].shape[0] === 1, g = Su(f, s, e[0].dtype, h), x = S.computeOutShape(a.map((C) => C.shape), o);
+ i.shape = x;
+ let b = t6.dataIdMap.get(i.dataId);
+ return b.stringBytes = S.fromStringArrayToUint8(g), d.forEach((C) => t6.disposeData(C.dataId)), i;
}
- let p = x.sizeFromShape(a[0].shape.slice(0, o)), u = 0, c = a.map((f) => {
- let d = x.sizeFromShape(f.shape.slice(o));
- return u += d, d;
- }), l = a.map((f) => t10.typedArrayFromHeap(f)), m = t10.typedArrayFromHeap(i);
- for (let f = 0; f < p; f++) {
- let d = f * u;
+ let p = y.sizeFromShape(a[0].shape.slice(0, o)), u = 0, c = a.map((d) => {
+ let f = y.sizeFromShape(d.shape.slice(o));
+ return u += f, f;
+ }), l = a.map((d) => t6.typedArrayFromHeap(d)), m = t6.typedArrayFromHeap(i);
+ for (let d = 0; d < p; d++) {
+ let f = d * u;
for (let h = 0; h < l.length; h++) {
- let g = c[h], y = f * g, b = l[h].subarray(y, y + g);
- m.set(b, d), d += g;
+ let g = c[h], x = d * g, b = l[h].subarray(x, x + g);
+ m.set(b, f), f += g;
}
}
return i;
}
-var pP = { kernelName: gs, backendName: "wasm", kernelFunc: qw };
-var cP;
-function H9(r) {
- cP = r.wasm.cwrap(ln, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var LD = { kernelName: ys, backendName: "wasm", kernelFunc: zw };
+var BD;
+function d9(r) {
+ BD = r.wasm.cwrap(Go, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function q9(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { x: n, filter: s } = e, a = o.dataIdMap.get(n.dataId).id, i = o.dataIdMap.get(s.dataId).id, { strides: p, dilations: u, pad: c, dimRoundingMode: l, dataFormat: m } = t10, f = I.convertConv2DDataFormat(m), d = I.computeConv2DInfo(n.shape, s.shape, p, u, c, l, false, f), h = d.filterHeight, g = d.filterWidth, y = d.padInfo.top, b = d.padInfo.right, C = d.padInfo.bottom, w = d.padInfo.left, k = d.dilationHeight, _ = d.dilationWidth, E = d.strideHeight, R = d.strideWidth, A = d.inChannels, D = d.outChannels, O = d.padInfo.type === "SAME" ? 1 : 0;
- if (d.dataFormat !== "channelsLast")
- throw new Error(`wasm backend Conv2D does not support dataFormat:'${d.dataFormat}'. Please use 'channelsLast'.`);
- let M = o.makeOutput(d.outShape, "float32"), L = o.dataIdMap.get(M.dataId).id;
- return cP(a, n.shape[0], n.shape[1], n.shape[2], i, h, g, y, b, C, w, O, k, _, E, R, A, D, L), M;
+function f9(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { x: n, filter: s } = e, a = o.dataIdMap.get(n.dataId).id, i = o.dataIdMap.get(s.dataId).id, { strides: p, dilations: u, pad: c, dimRoundingMode: l, dataFormat: m } = t6, d = S.convertConv2DDataFormat(m), f = S.computeConv2DInfo(n.shape, s.shape, p, u, c, l, false, d), h = f.filterHeight, g = f.filterWidth, x = f.padInfo.top, b = f.padInfo.right, C = f.padInfo.bottom, w = f.padInfo.left, k = f.dilationHeight, _ = f.dilationWidth, $ = f.strideHeight, A = f.strideWidth, R = f.inChannels, D = f.outChannels, P = f.padInfo.type === "SAME" ? 1 : 0;
+ if (f.dataFormat !== "channelsLast")
+ throw new Error(`wasm backend Conv2D does not support dataFormat:'${f.dataFormat}'. Please use 'channelsLast'.`);
+ let M = o.makeOutput(f.outShape, "float32"), L = o.dataIdMap.get(M.dataId).id;
+ return BD(a, n.shape[0], n.shape[1], n.shape[2], i, h, g, x, b, C, w, P, k, _, $, A, R, D, L), M;
}
-var lP = { kernelName: ln, backendName: "wasm", setupFunc: H9, kernelFunc: q9 };
-var mP;
-function K9(r) {
- mP = r.wasm.cwrap(mn, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var VD = { kernelName: Go, backendName: "wasm", setupFunc: d9, kernelFunc: f9 };
+var zD;
+function h9(r) {
+ zD = r.wasm.cwrap(Ho, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function j9(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { dy: n, filter: s } = t10, { strides: a, pad: i, dataFormat: p, dimRoundingMode: u, inputShape: c } = o, l = 1, m = I.convertConv2DDataFormat(p), f = I.computeConv2DInfo(c, s.shape, a, l, i, u, false, m), { batchSize: d, filterHeight: h, filterWidth: g, inChannels: y, inHeight: b, inWidth: C, outChannels: w, outHeight: k, outWidth: _, strideHeight: E, strideWidth: R } = f, A = h - 1 - f.padInfo.top, D = g - 1 - f.padInfo.left, O = f.dataFormat === "channelsLast", M = x.computeStrides(f.inShape), L = x.computeStrides(n.shape), [W, V, G] = x.computeStrides(s.shape), q = M[0], H = O ? M[1] : M[2], j = O ? M[2] : 1, Y = O ? 1 : M[1], Z = L[0], ee = O ? L[1] : L[2], X = O ? L[2] : 1, Q = O ? 1 : L[1], se = e.makeOutput(f.inShape, "float32"), ie = e.dataIdMap.get(se.dataId).id, de = e.dataIdMap.get(n.dataId).id, Ie = e.dataIdMap.get(s.dataId).id;
- return mP(de, Ie, d, h, g, b, C, y, k, _, w, E, R, A, D, W, V, G, q, H, j, Y, Z, ee, X, Q, ie), se;
+function g9(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { dy: n, filter: s } = t6, { strides: a, pad: i, dataFormat: p, dimRoundingMode: u, inputShape: c } = o, l = 1, m = S.convertConv2DDataFormat(p), d = S.computeConv2DInfo(c, s.shape, a, l, i, u, false, m), { batchSize: f, filterHeight: h, filterWidth: g, inChannels: x, inHeight: b, inWidth: C, outChannels: w, outHeight: k, outWidth: _, strideHeight: $, strideWidth: A } = d, R = h - 1 - d.padInfo.top, D = g - 1 - d.padInfo.left, P = d.dataFormat === "channelsLast", M = y.computeStrides(d.inShape), L = y.computeStrides(n.shape), [W, V, U] = y.computeStrides(s.shape), q = M[0], H = P ? M[1] : M[2], j = P ? M[2] : 1, X = P ? 1 : M[1], Z = L[0], ee = P ? L[1] : L[2], Y = P ? L[2] : 1, J = P ? 1 : L[1], ie = e.makeOutput(d.inShape, "float32"), pe = e.dataIdMap.get(ie.dataId).id, he = e.dataIdMap.get(n.dataId).id, we = e.dataIdMap.get(s.dataId).id;
+ return zD(he, we, f, h, g, b, C, x, k, _, w, $, A, R, D, W, V, U, q, H, j, X, Z, ee, Y, J, pe), ie;
}
-var fP = { kernelName: mn, backendName: "wasm", setupFunc: K9, kernelFunc: j9 };
-var dP = Qe(fn);
-var hP = Qe(dn);
-var Kw;
+var WD = { kernelName: Ho, backendName: "wasm", setupFunc: h9, kernelFunc: g9 };
+var UD = Ve(qo);
+var GD = Ve(Ko);
+var Ww;
(function(r) {
r[r.bilinear = 0] = "bilinear", r[r.nearest = 1] = "nearest";
-})(Kw || (Kw = {}));
-var gP;
-function X9(r) {
- gP = r.wasm.cwrap(xn, null, ["number", "number", "number", "number", "array", "number", "number", "number", "number", "number"]);
+})(Ww || (Ww = {}));
+var HD;
+function x9(r) {
+ HD = r.wasm.cwrap(Yo, null, ["number", "number", "number", "number", "array", "number", "number", "number", "number", "number"]);
}
-function Y9(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { method: n, extrapolationValue: s, cropSize: a } = o, { image: i, boxes: p, boxInd: u } = t10, c = p.shape[0], [l, m] = a, f = [c, l, m, i.shape[3]], d = e.dataIdMap.get(i.dataId), h;
- i.dtype !== "float32" && (h = cs({ backend: e, inputs: { x: i }, attrs: { dtype: "float32" } }), d = e.dataIdMap.get(h.dataId));
- let g = d.id, y = e.dataIdMap.get(p.dataId).id, b = e.dataIdMap.get(u.dataId).id, C = e.makeOutput(f, "float32"), w = e.dataIdMap.get(C.dataId).id, k = new Uint8Array(new Int32Array(i.shape).buffer);
- return gP(g, y, b, c, k, l, m, Kw[n], s, w), h != null && e.disposeData(h.dataId), C;
+function y9(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { method: n, extrapolationValue: s, cropSize: a } = o, { image: i, boxes: p, boxInd: u } = t6, c = p.shape[0], [l, m] = a, d = [c, l, m, i.shape[3]], f = e.dataIdMap.get(i.dataId), h;
+ i.dtype !== "float32" && (h = ls({ backend: e, inputs: { x: i }, attrs: { dtype: "float32" } }), f = e.dataIdMap.get(h.dataId));
+ let g = f.id, x = e.dataIdMap.get(p.dataId).id, b = e.dataIdMap.get(u.dataId).id, C = e.makeOutput(d, "float32"), w = e.dataIdMap.get(C.dataId).id, k = new Uint8Array(new Int32Array(i.shape).buffer);
+ return HD(g, x, b, c, k, l, m, Ww[n], s, w), h != null && e.disposeData(h.dataId), C;
}
-var xP = { kernelName: xn, backendName: "wasm", setupFunc: X9, kernelFunc: Y9 };
-var yP;
-function Q9(r) {
- yP = r.wasm.cwrap(hn, null, ["number", "number", "number", "number", "number", "number"]);
+var qD = { kernelName: Yo, backendName: "wasm", setupFunc: x9, kernelFunc: y9 };
+var KD;
+function b9(r) {
+ KD = r.wasm.cwrap(jo, null, ["number", "number", "number", "number", "number", "number"]);
}
-function Z9(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o, p = n.shape.length;
- x.assert(n.dtype === "float32" || n.dtype === "int32", () => `cumprod does not support ${n.dtype} tensors in the WASM backend`);
- let u = I.getAxesPermutation([s], p), c = n;
- u !== null && (c = Eo({ inputs: { x: n }, attrs: { perm: u }, backend: t10 }));
- let l = I.getInnerMostAxes(1, p)[0];
- I.assertAxesAreInnerMostDims("cumprod", [l], p);
- let m = t10.makeOutput(c.shape, c.dtype), f = c.shape[l], d = t10.dataIdMap.get(c.dataId).id, h = t10.dataIdMap.get(m.dataId).id;
- yP(d, a ? 1 : 0, i ? 1 : 0, f, h, Ae[n.dtype]);
+function C9(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o, p = n.shape.length;
+ y.assert(n.dtype === "float32" || n.dtype === "int32", () => `cumprod does not support ${n.dtype} tensors in the WASM backend`);
+ let u = S.getAxesPermutation([s], p), c = n;
+ u !== null && (c = uo({ inputs: { x: n }, attrs: { perm: u }, backend: t6 }));
+ let l = S.getInnerMostAxes(1, p)[0];
+ S.assertAxesAreInnerMostDims("cumprod", [l], p);
+ let m = t6.makeOutput(c.shape, c.dtype), d = c.shape[l], f = t6.dataIdMap.get(c.dataId).id, h = t6.dataIdMap.get(m.dataId).id;
+ KD(f, a ? 1 : 0, i ? 1 : 0, d, h, Fe[n.dtype]);
let g = m;
if (u !== null) {
- let y = I.getUndoAxesPermutation(u);
- g = Eo({ inputs: { x: m }, attrs: { perm: y }, backend: t10 }), t10.disposeData(c.dataId), t10.disposeData(m.dataId);
+ let x = S.getUndoAxesPermutation(u);
+ g = uo({ inputs: { x: m }, attrs: { perm: x }, backend: t6 }), t6.disposeData(c.dataId), t6.disposeData(m.dataId);
}
return g;
}
-var bP = { kernelName: hn, backendName: "wasm", setupFunc: Q9, kernelFunc: Z9 };
-var CP;
-function J9(r) {
- CP = r.wasm.cwrap(gn, null, ["number", "number", "number", "number", "number", "number"]);
+var jD = { kernelName: jo, backendName: "wasm", setupFunc: b9, kernelFunc: C9 };
+var XD;
+function S9(r) {
+ XD = r.wasm.cwrap(Xo, null, ["number", "number", "number", "number", "number", "number"]);
}
-function eJ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o, p = n.shape.length;
- x.assert(n.dtype === "float32" || n.dtype === "int32", () => `cumsum does not support ${n.dtype} tensors in the WASM backend`);
- let u = I.getAxesPermutation([s], p), c = n;
- u !== null && (c = Eo({ inputs: { x: n }, attrs: { perm: u }, backend: t10 }));
- let l = I.getInnerMostAxes(1, p)[0];
- I.assertAxesAreInnerMostDims("cumsum", [l], p);
- let m = t10.makeOutput(c.shape, c.dtype), f = c.shape[l], d = t10.dataIdMap.get(c.dataId).id, h = t10.dataIdMap.get(m.dataId).id;
- CP(d, a ? 1 : 0, i ? 1 : 0, f, h, Ae[n.dtype]);
+function w9(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s, exclusive: a, reverse: i } = o, p = n.shape.length;
+ y.assert(n.dtype === "float32" || n.dtype === "int32", () => `cumsum does not support ${n.dtype} tensors in the WASM backend`);
+ let u = S.getAxesPermutation([s], p), c = n;
+ u !== null && (c = uo({ inputs: { x: n }, attrs: { perm: u }, backend: t6 }));
+ let l = S.getInnerMostAxes(1, p)[0];
+ S.assertAxesAreInnerMostDims("cumsum", [l], p);
+ let m = t6.makeOutput(c.shape, c.dtype), d = c.shape[l], f = t6.dataIdMap.get(c.dataId).id, h = t6.dataIdMap.get(m.dataId).id;
+ XD(f, a ? 1 : 0, i ? 1 : 0, d, h, Fe[n.dtype]);
let g = m;
if (u !== null) {
- let y = I.getUndoAxesPermutation(u);
- g = Eo({ inputs: { x: m }, attrs: { perm: y }, backend: t10 }), t10.disposeData(c.dataId), t10.disposeData(m.dataId);
+ let x = S.getUndoAxesPermutation(u);
+ g = uo({ inputs: { x: m }, attrs: { perm: x }, backend: t6 }), t6.disposeData(c.dataId), t6.disposeData(m.dataId);
}
return g;
}
-var IP = { kernelName: gn, backendName: "wasm", setupFunc: J9, kernelFunc: eJ };
-var wP;
-function tJ(r) {
- wP = r.wasm.cwrap(yn, null, ["number", "number", "number", "array", "number", "array", "array", "number", "number"]);
+var YD = { kernelName: Xo, backendName: "wasm", setupFunc: S9, kernelFunc: w9 };
+var QD;
+function I9(r) {
+ QD = r.wasm.cwrap(Qo, null, ["number", "number", "number", "array", "number", "array", "array", "number", "number"]);
}
-function rJ(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { x: n } = t10, { blockSize: s, dataFormat: a } = o, i = n.shape[0], p = a === "NHWC" ? n.shape[1] : n.shape[2], u = a === "NHWC" ? n.shape[2] : n.shape[3], c = a === "NHWC" ? n.shape[3] : n.shape[1], l = p * s, m = u * s, f = c / (s * s), d = a === "NHWC" ? [i, l, m, f] : [i, f, l, m], h = e.makeOutput(d, "float32"), y = e.dataIdMap.get(n.dataId).id, b = new Uint8Array(new Int32Array(x.computeStrides(n.shape)).buffer), C = new Uint8Array(new Int32Array(d).buffer), w = new Uint8Array(new Int32Array(x.computeStrides(d)).buffer), k = e.dataIdMap.get(h.dataId).id;
- return wP(y, s, a === "NHWC" ? 1 : 0, b, n.shape.length - 1, C, w, d.length, k), h;
+function v9(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { x: n } = t6, { blockSize: s, dataFormat: a } = o, i = n.shape[0], p = a === "NHWC" ? n.shape[1] : n.shape[2], u = a === "NHWC" ? n.shape[2] : n.shape[3], c = a === "NHWC" ? n.shape[3] : n.shape[1], l = p * s, m = u * s, d = c / (s * s), f = a === "NHWC" ? [i, l, m, d] : [i, d, l, m], h = e.makeOutput(f, "float32"), x = e.dataIdMap.get(n.dataId).id, b = new Uint8Array(new Int32Array(y.computeStrides(n.shape)).buffer), C = new Uint8Array(new Int32Array(f).buffer), w = new Uint8Array(new Int32Array(y.computeStrides(f)).buffer), k = e.dataIdMap.get(h.dataId).id;
+ return QD(x, s, a === "NHWC" ? 1 : 0, b, n.shape.length - 1, C, w, f.length, k), h;
}
-var SP = { kernelName: yn, backendName: "wasm", setupFunc: tJ, kernelFunc: rJ };
-var vP;
-function oJ(r) {
- vP = r.wasm.cwrap(bn, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var ZD = { kernelName: Qo, backendName: "wasm", setupFunc: I9, kernelFunc: v9 };
+var JD;
+function k9(r) {
+ JD = r.wasm.cwrap(Zo, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function nJ(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { x: n, filter: s } = e, a = o.dataIdMap.get(n.dataId).id, i = o.dataIdMap.get(s.dataId).id, { strides: p, dilations: u, pad: c, dimRoundingMode: l } = t10, m = u == null ? [1, 1] : u, f = I.computeConv2DInfo(n.shape, s.shape, p, m, c, l, true), d = f.filterHeight, h = f.filterWidth, g = f.padInfo.top, y = f.padInfo.right, b = f.padInfo.bottom, C = f.padInfo.left, w = f.dilationHeight, k = f.dilationWidth, _ = f.strideHeight, E = f.strideWidth, R = f.inChannels, A = f.outChannels, D = f.padInfo.type === "SAME" ? 1 : 0;
- if (f.dataFormat !== "channelsLast")
- throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${f.dataFormat}'. Please use 'channelsLast'.`);
- let O = o.makeOutput(f.outShape, "float32"), M = o.dataIdMap.get(O.dataId).id;
- return vP(a, n.shape[0], n.shape[1], n.shape[2], i, d, h, g, y, b, C, D, w, k, _, E, R, A, M), O;
+function N9(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { x: n, filter: s } = e, a = o.dataIdMap.get(n.dataId).id, i = o.dataIdMap.get(s.dataId).id, { strides: p, dilations: u, pad: c, dimRoundingMode: l } = t6, m = u == null ? [1, 1] : u, d = S.computeConv2DInfo(n.shape, s.shape, p, m, c, l, true), f = d.filterHeight, h = d.filterWidth, g = d.padInfo.top, x = d.padInfo.right, b = d.padInfo.bottom, C = d.padInfo.left, w = d.dilationHeight, k = d.dilationWidth, _ = d.strideHeight, $ = d.strideWidth, A = d.inChannels, R = d.outChannels, D = d.padInfo.type === "SAME" ? 1 : 0;
+ if (d.dataFormat !== "channelsLast")
+ throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${d.dataFormat}'. Please use 'channelsLast'.`);
+ let P = o.makeOutput(d.outShape, "float32"), M = o.dataIdMap.get(P.dataId).id;
+ return JD(a, n.shape[0], n.shape[1], n.shape[2], i, f, h, g, x, b, C, D, w, k, _, $, A, R, M), P;
}
-var kP = { kernelName: bn, backendName: "wasm", setupFunc: oJ, kernelFunc: nJ };
-var TP = Qe(In);
-var sJ = false;
-var NP = nt(oo, sJ, "bool");
-var _P = Qe(no, "float32");
-function Eg(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { input: n } = e, { dim: s } = t10, a = n.shape.length, i = n.shape.slice(), p = s;
- return s < 0 && (x.assert(-(a + 1) <= s, () => `Axis must be in the interval [${-(a + 1)}, ${a}]`), p = a + s + 1), i.splice(p, 0, 1), Mt({ inputs: { x: n }, backend: o, attrs: { shape: i } });
+var eO = { kernelName: Zo, backendName: "wasm", setupFunc: k9, kernelFunc: N9 };
+var tO = Ve(en);
+var T9 = false;
+var rO = rt(tn, T9, "bool");
+var oO = Ve(rn, "float32");
+function yg(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { input: n } = e, { dim: s } = t6, a = n.shape.length, i = n.shape.slice(), p = s;
+ return s < 0 && (y.assert(-(a + 1) <= s, () => `Axis must be in the interval [${-(a + 1)}, ${a}]`), p = a + s + 1), i.splice(p, 0, 1), Mt({ inputs: { x: n }, backend: o, attrs: { shape: i } });
}
-var EP = { kernelName: xs, backendName: "wasm", kernelFunc: Eg };
-function jw(r) {
- let { attrs: { shape: e, value: t10, dtype: o }, backend: n } = r, s = n.makeOutput(e, o);
- return n.typedArrayFromHeap(s).fill(t10), s;
+var nO = { kernelName: bs, backendName: "wasm", kernelFunc: yg };
+function Uw(r) {
+ let { attrs: { shape: e, value: t6, dtype: o }, backend: n } = r, s = n.makeOutput(e, o);
+ return n.typedArrayFromHeap(s).fill(t6), s;
}
-var $P = { kernelName: ys, backendName: "wasm", kernelFunc: jw };
-var RP;
-function aJ(r) {
- RP = r.wasm.cwrap(Sn, null, ["number", "number", "number", "number", "number", "number"]);
+var sO = { kernelName: Cs, backendName: "wasm", kernelFunc: Uw };
+var aO;
+function _9(r) {
+ aO = r.wasm.cwrap(on, null, ["number", "number", "number", "number", "number", "number"]);
}
-function iJ(r) {
- let { inputs: e, backend: t10 } = r, { image: o } = e, n = t10.makeOutput(o.shape, o.dtype), s = t10.dataIdMap.get(o.dataId).id, a = t10.dataIdMap.get(n.dataId).id, [i, p, u, c] = o.shape;
- return RP(s, i, p, u, c, a), n;
+function E9(r) {
+ let { inputs: e, backend: t6 } = r, { image: o } = e, n = t6.makeOutput(o.shape, o.dtype), s = t6.dataIdMap.get(o.dataId).id, a = t6.dataIdMap.get(n.dataId).id, [i, p, u, c] = o.shape;
+ return aO(s, i, p, u, c, a), n;
}
-var AP = { kernelName: Sn, backendName: "wasm", kernelFunc: iJ, setupFunc: aJ };
-var FP = Qe(so);
-var uJ = false;
-var DP = nt(vn, uJ);
-var PP;
-function pJ(r) {
- PP = r.wasm.cwrap(kn, null, ["number", "number", "number", "number", "number", "number", "number"]);
+var iO = { kernelName: on, backendName: "wasm", kernelFunc: E9, setupFunc: _9 };
+var uO = Ve(nn);
+var $9 = false;
+var pO = rt(sn, $9);
+var cO;
+function A9(r) {
+ cO = r.wasm.cwrap(an, null, ["number", "number", "number", "number", "number", "number", "number"]);
}
-function cJ(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { varianceEpsilon: n } = o, { x: s, mean: a, variance: i, offset: p, scale: u } = t10, c = e.dataIdMap.get(s.dataId).id, l = e.dataIdMap.get(a.dataId).id, m = e.dataIdMap.get(i.dataId).id, f = p != null ? e.dataIdMap.get(p.dataId).id : 0, d = u != null ? e.dataIdMap.get(u.dataId).id : 0, h = e.makeOutput(s.shape, s.dtype);
- if (x.sizeFromShape(s.shape) === 0)
+function R9(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { varianceEpsilon: n } = o, { x: s, mean: a, variance: i, offset: p, scale: u } = t6, c = e.dataIdMap.get(s.dataId).id, l = e.dataIdMap.get(a.dataId).id, m = e.dataIdMap.get(i.dataId).id, d = p != null ? e.dataIdMap.get(p.dataId).id : 0, f = u != null ? e.dataIdMap.get(u.dataId).id : 0, h = e.makeOutput(s.shape, s.dtype);
+ if (y.sizeFromShape(s.shape) === 0)
return h;
let g = e.dataIdMap.get(h.dataId).id;
- return PP(c, l, m, f, d, n, g), h;
+ return cO(c, l, m, d, f, n, g), h;
}
-var OP = { kernelName: kn, backendName: "wasm", setupFunc: pJ, kernelFunc: cJ };
-var MP;
-function lJ(r) {
- MP = r.wasm.cwrap(Do, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var lO = { kernelName: an, backendName: "wasm", setupFunc: A9, kernelFunc: R9 };
+var mO;
+function F9(r) {
+ mO = r.wasm.cwrap(ho, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function mJ(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dilations: c, dataFormat: l, dimRoundingMode: m, activation: f, leakyreluAlpha: d } = t10, h = I.computeConv2DInfo(n.shape, s.shape, p, c, u, m), g = $i[f];
+function D9(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dilations: c, dataFormat: l, dimRoundingMode: m, activation: d, leakyreluAlpha: f } = t6, h = S.computeConv2DInfo(n.shape, s.shape, p, c, u, m), g = Wi[d];
if (g == null)
- throw new Error(`${f} activation not yet supported for FusedConv2D in the wasm backend.`);
- let y = o.dataIdMap.get(n.dataId).id, b = o.dataIdMap.get(s.dataId).id, C = h.outChannels, w = 0;
+ throw new Error(`${d} activation not yet supported for FusedConv2D in the wasm backend.`);
+ let x = o.dataIdMap.get(n.dataId).id, b = o.dataIdMap.get(s.dataId).id, C = h.outChannels, w = 0;
if (a != null) {
- let X = o.dataIdMap.get(a.dataId);
- if (X.shape.length !== 1)
- throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${X.shape.length}.`);
- if (X.shape[0] !== C)
- throw new Error(`FusedConv2D bias shape (${X.shape}) does not match the number of output channels (${C})`);
- w = X.id;
+ let Y = o.dataIdMap.get(a.dataId);
+ if (Y.shape.length !== 1)
+ throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${Y.shape.length}.`);
+ if (Y.shape[0] !== C)
+ throw new Error(`FusedConv2D bias shape (${Y.shape}) does not match the number of output channels (${C})`);
+ w = Y.id;
}
- let k = h.filterHeight, _ = h.filterWidth, E = h.padInfo.top, R = h.padInfo.right, A = h.padInfo.bottom, D = h.padInfo.left, O = h.dilationHeight, M = h.dilationWidth, L = h.strideHeight, W = h.strideWidth, V = h.inChannels, G = h.padInfo.type === "SAME" ? 1 : 0, q = h.batchSize, H = h.inHeight, j = h.inWidth;
+ let k = h.filterHeight, _ = h.filterWidth, $ = h.padInfo.top, A = h.padInfo.right, R = h.padInfo.bottom, D = h.padInfo.left, P = h.dilationHeight, M = h.dilationWidth, L = h.strideHeight, W = h.strideWidth, V = h.inChannels, U = h.padInfo.type === "SAME" ? 1 : 0, q = h.batchSize, H = h.inHeight, j = h.inWidth;
if (l !== "NHWC")
throw new Error(`wasm backend FusedConv2D does not support dataFormat:'${l}'. Please use 'NHWC'.`);
- let Y = o.makeOutput(h.outShape, "float32"), Z = o.dataIdMap.get(Y.dataId).id, ee = i == null ? 0 : o.dataIdMap.get(i.dataId).id;
- return MP(y, q, H, j, b, k, _, w, E, R, A, D, G, O, M, L, W, V, C, g, ee, d || 0, Z), Y;
+ let X = o.makeOutput(h.outShape, "float32"), Z = o.dataIdMap.get(X.dataId).id, ee = i == null ? 0 : o.dataIdMap.get(i.dataId).id;
+ return mO(x, q, H, j, b, k, _, w, $, A, R, D, U, P, M, L, W, V, C, g, ee, f || 0, Z), X;
}
-var LP = { kernelName: Do, backendName: "wasm", setupFunc: lJ, kernelFunc: mJ };
-var BP;
-function fJ(r) {
- BP = r.wasm.cwrap(Po, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var dO = { kernelName: ho, backendName: "wasm", setupFunc: F9, kernelFunc: D9 };
+var fO;
+function O9(r) {
+ fO = r.wasm.cwrap(go, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function dJ(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dilations: c, dataFormat: l, dimRoundingMode: m, activation: f, leakyreluAlpha: d } = t10, h = I.computeConv2DInfo(n.shape, s.shape, p, c, u, m, true), g = $i[f];
+function P9(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { x: n, filter: s, bias: a, preluActivationWeights: i } = e, { strides: p, pad: u, dilations: c, dataFormat: l, dimRoundingMode: m, activation: d, leakyreluAlpha: f } = t6, h = S.computeConv2DInfo(n.shape, s.shape, p, c, u, m, true), g = Wi[d];
if (g == null)
- throw new Error(`${f} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);
- let y = o.dataIdMap.get(n.dataId).id, b = o.dataIdMap.get(s.dataId).id, C = h.outChannels, w = 0;
+ throw new Error(`${d} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);
+ let x = o.dataIdMap.get(n.dataId).id, b = o.dataIdMap.get(s.dataId).id, C = h.outChannels, w = 0;
if (a != null) {
- let X = o.dataIdMap.get(a.dataId);
- if (X.shape.length !== 1)
- throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${X.shape.length}.`);
- if (X.shape[0] !== C)
- throw new Error(`FusedDepthwiseConv2D bias shape (${X.shape}) does not match the number of output channels (${C})`);
- w = X.id;
+ let Y = o.dataIdMap.get(a.dataId);
+ if (Y.shape.length !== 1)
+ throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${Y.shape.length}.`);
+ if (Y.shape[0] !== C)
+ throw new Error(`FusedDepthwiseConv2D bias shape (${Y.shape}) does not match the number of output channels (${C})`);
+ w = Y.id;
}
- let k = h.filterHeight, _ = h.filterWidth, E = h.padInfo.top, R = h.padInfo.right, A = h.padInfo.bottom, D = h.padInfo.left, O = h.dilationHeight, M = h.dilationWidth, L = h.strideHeight, W = h.strideWidth, V = h.inChannels, G = h.padInfo.type === "SAME" ? 1 : 0, q = h.batchSize, H = h.inHeight, j = h.inWidth;
+ let k = h.filterHeight, _ = h.filterWidth, $ = h.padInfo.top, A = h.padInfo.right, R = h.padInfo.bottom, D = h.padInfo.left, P = h.dilationHeight, M = h.dilationWidth, L = h.strideHeight, W = h.strideWidth, V = h.inChannels, U = h.padInfo.type === "SAME" ? 1 : 0, q = h.batchSize, H = h.inHeight, j = h.inWidth;
if (l !== "NHWC")
throw new Error(`wasm backend FusedDepthwiseConv2D does not support dataFormat:'${l}'. Please use 'NHWC'.`);
- let Y = o.makeOutput(h.outShape, "float32"), Z = o.dataIdMap.get(Y.dataId).id, ee = i == null ? 0 : o.dataIdMap.get(i.dataId).id;
- return BP(y, q, H, j, b, k, _, w, E, R, A, D, G, O, M, L, W, V, C, g, ee, d || 0, Z), Y;
+ let X = o.makeOutput(h.outShape, "float32"), Z = o.dataIdMap.get(X.dataId).id, ee = i == null ? 0 : o.dataIdMap.get(i.dataId).id;
+ return fO(x, q, H, j, b, k, _, w, $, A, R, D, U, P, M, L, W, V, C, g, ee, f || 0, Z), X;
}
-var VP = { kernelName: Po, backendName: "wasm", setupFunc: fJ, kernelFunc: dJ };
-var zP;
-function hJ(r) {
- zP = r.wasm.cwrap(Tn, null, ["number", "number", "number", "number", "number", "number", "array", "number"]);
+var hO = { kernelName: go, backendName: "wasm", setupFunc: O9, kernelFunc: P9 };
+var gO;
+function M9(r) {
+ gO = r.wasm.cwrap(un, null, ["number", "number", "number", "number", "number", "number", "array", "number"]);
}
-function gJ(r) {
- let { backend: e, inputs: t10 } = r, { params: o, indices: n } = t10, [s, a, i, p] = af.prepareAndValidate(o, n), u = e.makeOutput(s, o.dtype);
+function L9(r) {
+ let { backend: e, inputs: t6 } = r, { params: o, indices: n } = t6, [s, a, i, p] = Ym.prepareAndValidate(o, n), u = e.makeOutput(s, o.dtype);
if (a === 0)
return u;
- let c = n.shape, l = c[c.length - 1], f = e.dataIdMap.get(o.dataId).id, h = e.dataIdMap.get(n.dataId).id, g = new Uint8Array(new Int32Array(p).buffer), y = e.dataIdMap.get(u.dataId).id;
- return zP(f, Ae[o.dtype], h, a, l, i, g, y), u;
+ let c = n.shape, l = c[c.length - 1], d = e.dataIdMap.get(o.dataId).id, h = e.dataIdMap.get(n.dataId).id, g = new Uint8Array(new Int32Array(p).buffer), x = e.dataIdMap.get(u.dataId).id;
+ return gO(d, Fe[o.dtype], h, a, l, i, g, x), u;
}
-var WP = { kernelName: Tn, backendName: "wasm", setupFunc: hJ, kernelFunc: gJ };
-var UP;
-function xJ(r) {
- UP = r.wasm.cwrap("Gather", null, ["number", "number", "array", "number", "number", "number", "array", "number"]);
+var xO = { kernelName: un, backendName: "wasm", setupFunc: M9, kernelFunc: L9 };
+var yO;
+function B9(r) {
+ yO = r.wasm.cwrap("Gather", null, ["number", "number", "array", "number", "number", "number", "array", "number"]);
}
-function yJ(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { x: n, indices: s } = t10, { axis: a, batchDims: i } = o, p = x.parseAxisParam(a, n.shape)[0], u = e.readSync(s.dataId), c = n.shape[p];
- for (let A = 0; A < u.length; ++A) {
- let D = u[A];
- x.assert(D <= c - 1 && D >= 0, () => `GatherV2: the index value ${D} is not in [0, ${c - 1}]`);
+function V9(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { x: n, indices: s } = t6, { axis: a, batchDims: i } = o, p = y.parseAxisParam(a, n.shape)[0], u = e.readSync(s.dataId), c = n.shape[p];
+ for (let R = 0; R < u.length; ++R) {
+ let D = u[R];
+ y.assert(D <= c - 1 && D >= 0, () => `GatherV2: the index value ${D} is not in [0, ${c - 1}]`);
}
- let l = I.segment_util.collectGatherOpShapeInfo(n, s, p, i), m = Mt({ inputs: { x: n }, attrs: { shape: [l.batchSize, l.outerSize, l.dimSize, l.sliceSize] }, backend: e }), f = x.sizeFromShape(s.shape), d = Mt({ inputs: { x: s }, attrs: { shape: [l.batchSize, f / l.batchSize] }, backend: e }), h = [l.batchSize, l.outerSize, f / l.batchSize, l.sliceSize], g = e.makeOutput(h, n.dtype);
- if (x.sizeFromShape(n.shape) === 0)
+ let l = S.segment_util.collectGatherOpShapeInfo(n, s, p, i), m = Mt({ inputs: { x: n }, attrs: { shape: [l.batchSize, l.outerSize, l.dimSize, l.sliceSize] }, backend: e }), d = y.sizeFromShape(s.shape), f = Mt({ inputs: { x: s }, attrs: { shape: [l.batchSize, d / l.batchSize] }, backend: e }), h = [l.batchSize, l.outerSize, d / l.batchSize, l.sliceSize], g = e.makeOutput(h, n.dtype);
+ if (y.sizeFromShape(n.shape) === 0)
return g;
- let y = m.shape.length - 1, C = e.dataIdMap.get(m.dataId).id, k = e.dataIdMap.get(d.dataId).id, _ = e.dataIdMap.get(g.dataId).id, E = new Uint8Array(new Int32Array(x.computeStrides(m.shape)).buffer), R = new Uint8Array(new Int32Array(x.computeStrides(h)).buffer);
- return UP(C, Ae[n.dtype], E, y, k, l.batchSize, R, _), e.disposeData(m.dataId), e.disposeData(d.dataId), g.shape = l.outputShape, g;
+ let x = m.shape.length - 1, C = e.dataIdMap.get(m.dataId).id, k = e.dataIdMap.get(f.dataId).id, _ = e.dataIdMap.get(g.dataId).id, $ = new Uint8Array(new Int32Array(y.computeStrides(m.shape)).buffer), A = new Uint8Array(new Int32Array(y.computeStrides(h)).buffer);
+ return yO(C, Fe[n.dtype], $, x, k, l.batchSize, A, _), e.disposeData(m.dataId), e.disposeData(f.dataId), g.shape = l.outputShape, g;
}
-var GP = { kernelName: bs, backendName: "wasm", setupFunc: xJ, kernelFunc: yJ };
-var bJ = false;
-var HP = nt(ao, bJ, "bool");
-var CJ = false;
-var qP = nt(io, CJ, "bool");
-var KP;
-function IJ(r) {
- KP = r.wasm.cwrap(Nn, null, ["number", "number", "number", "number"]);
+var bO = { kernelName: Ss, backendName: "wasm", setupFunc: B9, kernelFunc: V9 };
+var z9 = false;
+var CO = rt(pn, z9, "bool");
+var W9 = false;
+var SO = rt(cn, W9, "bool");
+var wO = Ve(ln, "bool");
+var IO;
+function U9(r) {
+ IO = r.wasm.cwrap(mn, null, ["number", "number", "number", "number"]);
}
-function wJ(r) {
- let { inputs: { x: e }, attrs: { alpha: t10 }, backend: o } = r, n = o.dataIdMap.get(e.dataId).id, s = o.makeOutput(e.shape, "float32");
- if (x.sizeFromShape(e.shape) !== 0) {
+function G9(r) {
+ let { inputs: { x: e }, attrs: { alpha: t6 }, backend: o } = r, n = o.dataIdMap.get(e.dataId).id, s = o.makeOutput(e.shape, "float32");
+ if (y.sizeFromShape(e.shape) !== 0) {
let a = o.dataIdMap.get(s.dataId).id;
- KP(n, Ae[e.dtype], t10, a);
+ IO(n, Fe[e.dtype], t6, a);
}
return s;
}
-var jP = { kernelName: Nn, backendName: "wasm", setupFunc: IJ, kernelFunc: wJ };
-var SJ = false;
-var XP = nt(po, SJ, "bool");
-var vJ = false;
-var YP = nt(co, vJ, "bool");
-var QP = Qe(lo);
-var kJ = false;
-var ZP = nt(_n, kJ, "bool");
-var JP = Qe(En);
-var TJ = false;
-var eO = nt(ua, TJ, "bool");
-var NJ = false;
-var tO = nt(g0, NJ, "bool");
-var rO;
-function _J(r) {
- rO = r.wasm.cwrap($n, null, ["number", "number", "number", "number"]);
+var vO = { kernelName: mn, backendName: "wasm", setupFunc: U9, kernelFunc: G9 };
+var H9 = false;
+var kO = rt(dn, H9, "bool");
+var q9 = false;
+var NO = rt(fn, q9, "bool");
+var TO = Ve(hn);
+var K9 = false;
+var _O = rt(gn, K9, "bool");
+var EO = Ve(xn);
+var j9 = false;
+var $O = rt(xa, j9, "bool");
+var X9 = false;
+var AO = rt(GI, X9, "bool");
+var RO;
+function Y9(r) {
+ RO = r.wasm.cwrap(yn, null, ["number", "number", "number", "number"]);
}
-function EJ(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { reductionIndices: n, keepDims: s } = o, { x: a } = t10, p = e.dataIdMap.get(a.dataId).id, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: f } = kr(a, n, e);
- if (f) {
+function Q9(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { reductionIndices: n, keepDims: s } = o, { x: a } = t6, p = e.dataIdMap.get(a.dataId).id, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: d } = kr(a, n, e);
+ if (d) {
let C = e.dataIdMap.get(c.dataId).id;
u = c, p = C;
}
- let d = u.shape.length;
- I.assertAxesAreInnerMostDims("max", l, d);
- let [h, g] = I.computeOutAndReduceShapes(u.shape, l), y = x.sizeFromShape(g), b = e.makeOutput(h, a.dtype);
- if (x.sizeFromShape(u.shape) !== 0) {
+ let f = u.shape.length;
+ S.assertAxesAreInnerMostDims("max", l, f);
+ let [h, g] = S.computeOutAndReduceShapes(u.shape, l), x = y.sizeFromShape(g), b = e.makeOutput(h, a.dtype);
+ if (y.sizeFromShape(u.shape) !== 0) {
let C = e.dataIdMap.get(b.dataId).id;
- rO(p, Ae[a.dtype], y, C);
+ RO(p, Fe[a.dtype], x, C);
}
- if (f && e.disposeData(c.dataId), s) {
- let C = I.expandShapeToKeepDim(b.shape, m);
+ if (d && e.disposeData(c.dataId), s) {
+ let C = S.expandShapeToKeepDim(b.shape, m);
b.shape = C;
}
return b;
}
-var oO = { kernelName: $n, backendName: "wasm", setupFunc: _J, kernelFunc: EJ };
-var $J = false;
-var nO = nt(mo, $J);
-var sO;
-function RJ(r) {
- sO = r.wasm.cwrap(Rn, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var FO = { kernelName: yn, backendName: "wasm", setupFunc: Y9, kernelFunc: Q9 };
+var Z9 = false;
+var DO = rt(bn, Z9);
+var OO;
+function J9(r) {
+ OO = r.wasm.cwrap(Cn, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function AJ(r) {
- let { inputs: e, attrs: t10, backend: o } = r, n = e.x, s = o.dataIdMap.get(n.dataId).id;
- x.assert(n.dtype === "float32", () => `Error in MaxPool: only float32 input is supported. Got ${n.dtype}.`);
- let { filterSize: a, strides: i, pad: p, dimRoundingMode: u } = t10, c = I.computePool2DInfo(n.shape, a, i, 1, p, u), l = c.filterHeight, m = c.filterWidth, f = c.padInfo.top, d = c.padInfo.right, h = c.padInfo.bottom, g = c.padInfo.left, y = c.dilationHeight, b = c.dilationWidth, C = c.strideHeight, w = c.strideWidth, k = c.inChannels, _ = c.outChannels;
+function eJ(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, n = e.x, s = o.dataIdMap.get(n.dataId).id;
+ y.assert(n.dtype === "float32", () => `Error in MaxPool: only float32 input is supported. Got ${n.dtype}.`);
+ let { filterSize: a, strides: i, pad: p, dimRoundingMode: u } = t6, c = S.computePool2DInfo(n.shape, a, i, 1, p, u), l = c.filterHeight, m = c.filterWidth, d = c.padInfo.top, f = c.padInfo.right, h = c.padInfo.bottom, g = c.padInfo.left, x = c.dilationHeight, b = c.dilationWidth, C = c.strideHeight, w = c.strideWidth, k = c.inChannels, _ = c.outChannels;
if (c.dataFormat !== "channelsLast")
throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);
- let E = o.makeOutput(c.outShape, "float32"), R = o.dataIdMap.get(E.dataId).id;
- return sO(s, n.shape[0], n.shape[1], n.shape[2], l, m, f, d, h, g, y, b, C, w, k, _, R), E;
+ let $ = o.makeOutput(c.outShape, "float32"), A = o.dataIdMap.get($.dataId).id;
+ return OO(s, n.shape[0], n.shape[1], n.shape[2], l, m, d, f, h, g, x, b, C, w, k, _, A), $;
}
-var aO = { kernelName: Rn, backendName: "wasm", setupFunc: RJ, kernelFunc: AJ };
-var iO;
-function FJ(r) {
- iO = r.wasm.cwrap(An, null, ["number, number, number"]);
+var PO = { kernelName: Cn, backendName: "wasm", setupFunc: J9, kernelFunc: eJ };
+var MO;
+function tJ(r) {
+ MO = r.wasm.cwrap(Sn, null, ["number, number, number"]);
}
-function DJ(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t10, i = e.dataIdMap.get(a.dataId).id, p = i, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: f } = kr(a, n, e), d = l;
- if (f) {
+function rJ(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t6, i = e.dataIdMap.get(a.dataId).id, p = i, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: d } = kr(a, n, e), f = l;
+ if (d) {
let w = e.dataIdMap.get(c.dataId).id;
- w !== i && (u = c, p = w, d = I.getInnerMostAxes(d.length, u.shape.length));
+ w !== i && (u = c, p = w, f = S.getInnerMostAxes(f.length, u.shape.length));
}
- I.assertAxesAreInnerMostDims("mean", d, u.shape.length);
- let [h, g] = I.computeOutAndReduceShapes(u.shape, d), y = x.sizeFromShape(g), b = u;
- u.dtype !== "float32" && (b = cs({ backend: e, inputs: { x: u }, attrs: { dtype: "float32" } }), p = e.dataIdMap.get(b.dataId).id);
+ S.assertAxesAreInnerMostDims("mean", f, u.shape.length);
+ let [h, g] = S.computeOutAndReduceShapes(u.shape, f), x = y.sizeFromShape(g), b = u;
+ u.dtype !== "float32" && (b = ls({ backend: e, inputs: { x: u }, attrs: { dtype: "float32" } }), p = e.dataIdMap.get(b.dataId).id);
let C = e.makeOutput(h, "float32");
- if (x.sizeFromShape(u.shape) !== 0) {
+ if (y.sizeFromShape(u.shape) !== 0) {
let w = e.dataIdMap.get(C.dataId).id;
- iO(p, y, w);
+ MO(p, x, w);
}
- if (f && e.disposeData(c.dataId), s) {
- let w = I.expandShapeToKeepDim(C.shape, m);
+ if (d && e.disposeData(c.dataId), s) {
+ let w = S.expandShapeToKeepDim(C.shape, m);
C.shape = w;
}
return u.dtype !== "float32" && e.disposeData(b.dataId), C;
}
-var uO = { kernelName: An, backendName: "wasm", setupFunc: FJ, kernelFunc: DJ };
-var pO;
-function PJ(r) {
- pO = r.wasm.cwrap(Fn, null, ["number", "number", "number", "number"]);
+var LO = { kernelName: Sn, backendName: "wasm", setupFunc: tJ, kernelFunc: rJ };
+var BO;
+function oJ(r) {
+ BO = r.wasm.cwrap(wn, null, ["number", "number", "number", "number"]);
}
-function OJ(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t10, i = e.dataIdMap.get(a.dataId).id, p = i, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: f } = kr(a, n, e);
- if (f) {
+function nJ(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t6, i = e.dataIdMap.get(a.dataId).id, p = i, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: d } = kr(a, n, e);
+ if (d) {
let C = e.dataIdMap.get(c.dataId).id;
C !== i && (u = c, p = C);
}
- let d = u.shape.length;
- I.assertAxesAreInnerMostDims("min", l, d);
- let [h, g] = I.computeOutAndReduceShapes(u.shape, l), y = x.sizeFromShape(g), b = e.makeOutput(h, u.dtype);
- if (x.sizeFromShape(u.shape) !== 0) {
+ let f = u.shape.length;
+ S.assertAxesAreInnerMostDims("min", l, f);
+ let [h, g] = S.computeOutAndReduceShapes(u.shape, l), x = y.sizeFromShape(g), b = e.makeOutput(h, u.dtype);
+ if (y.sizeFromShape(u.shape) !== 0) {
let C = e.dataIdMap.get(b.dataId).id;
- pO(p, Ae[a.dtype], y, C);
+ BO(p, Fe[a.dtype], x, C);
}
- if (f && e.disposeData(c.dataId), s) {
- let C = I.expandShapeToKeepDim(b.shape, m);
+ if (d && e.disposeData(c.dataId), s) {
+ let C = S.expandShapeToKeepDim(b.shape, m);
b.shape = C;
}
return b;
}
-var cO = { kernelName: Fn, backendName: "wasm", setupFunc: PJ, kernelFunc: OJ };
-var MJ = false;
-var lO = nt(fo, MJ);
-var Xw;
+var VO = { kernelName: wn, backendName: "wasm", setupFunc: oJ, kernelFunc: nJ };
+var sJ = false;
+var zO = rt(In, sJ);
+var Gw;
(function(r) {
r[r.reflect = 0] = "reflect", r[r.symmetric = 1] = "symmetric";
-})(Xw || (Xw = {}));
-var mO;
-function LJ(r) {
- mO = r.wasm.cwrap(Dn, null, ["number", "array", "number", "number", "array", "array", "number", "number"]);
+})(Gw || (Gw = {}));
+var WO;
+function aJ(r) {
+ WO = r.wasm.cwrap(vn, null, ["number", "array", "number", "number", "array", "array", "number", "number"]);
}
-function BJ(r) {
- let { inputs: { x: e }, backend: t10, attrs: { paddings: o, mode: n } } = r, s = o.map((d, h) => d[0] + e.shape[h] + d[1]), a = t10.dataIdMap.get(e.dataId).id, i = t10.makeOutput(s, e.dtype), p = t10.dataIdMap.get(i.dataId).id, u = new Uint8Array(new Int32Array(e.shape).buffer), c = o.map((d) => d[0]), l = o.map((d) => d[1]), m = new Uint8Array(new Int32Array(c).buffer), f = new Uint8Array(new Int32Array(l).buffer);
- return mO(a, u, e.shape.length, Ae[e.dtype], m, f, Xw[n], p), i;
+function iJ(r) {
+ let { inputs: { x: e }, backend: t6, attrs: { paddings: o, mode: n } } = r, s = o.map((f, h) => f[0] + e.shape[h] + f[1]), a = t6.dataIdMap.get(e.dataId).id, i = t6.makeOutput(s, e.dtype), p = t6.dataIdMap.get(i.dataId).id, u = new Uint8Array(new Int32Array(e.shape).buffer), c = o.map((f) => f[0]), l = o.map((f) => f[1]), m = new Uint8Array(new Int32Array(c).buffer), d = new Uint8Array(new Int32Array(l).buffer);
+ return WO(a, u, e.shape.length, Fe[e.dtype], m, d, Gw[n], p), i;
}
-var fO = { kernelName: Dn, backendName: "wasm", kernelFunc: BJ, setupFunc: LJ };
-var VJ = true;
-var dO = nt(ho, VJ);
-var hO = Qe(Pn);
-function kc(r, e) {
- let t10 = new Int32Array(r.wasm.HEAPU8.buffer, e, 4), o = t10[0], n = t10[1], s = t10[2], a = t10[3];
+var UO = { kernelName: vn, backendName: "wasm", kernelFunc: iJ, setupFunc: aJ };
+var uJ = true;
+var GO = rt(kn, uJ);
+var HO = Ve(ws);
+function Sc(r, e) {
+ let t6 = new Int32Array(r.wasm.HEAPU8.buffer, e, 4), o = t6[0], n = t6[1], s = t6[2], a = t6[3];
return r.wasm._free(e), { pSelectedIndices: o, selectedSize: n, pSelectedScores: s, pValidOutputs: a };
}
-var gO;
-function zJ(r) {
- gO = r.wasm.cwrap(On, "number", ["number", "number", "number", "number", "number"]);
+var qO;
+function pJ(r) {
+ qO = r.wasm.cwrap(Tn, "number", ["number", "number", "number", "number", "number"]);
}
-function WJ(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { iouThreshold: n, maxOutputSize: s, scoreThreshold: a } = o, { boxes: i, scores: p } = t10, u = e.dataIdMap.get(i.dataId).id, c = e.dataIdMap.get(p.dataId).id, l = gO(u, c, s, n, a), { pSelectedIndices: m, selectedSize: f, pSelectedScores: d, pValidOutputs: h } = kc(e, l);
- return e.wasm._free(d), e.wasm._free(h), e.makeOutput([f], "int32", m);
+function cJ(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { iouThreshold: n, maxOutputSize: s, scoreThreshold: a } = o, { boxes: i, scores: p } = t6, u = e.dataIdMap.get(i.dataId).id, c = e.dataIdMap.get(p.dataId).id, l = qO(u, c, s, n, a), { pSelectedIndices: m, selectedSize: d, pSelectedScores: f, pValidOutputs: h } = Sc(e, l);
+ return e.wasm._free(f), e.wasm._free(h), e.makeOutput([d], "int32", m);
}
-var xO = { kernelName: On, backendName: "wasm", setupFunc: zJ, kernelFunc: WJ };
-var yO;
-function UJ(r) {
- yO = r.wasm.cwrap(pa, "number", ["number", "number", "number", "number", "number", "bool"]);
+var KO = { kernelName: Tn, backendName: "wasm", setupFunc: pJ, kernelFunc: cJ };
+var jO;
+function lJ(r) {
+ jO = r.wasm.cwrap(ba, "number", ["number", "number", "number", "number", "number", "bool"]);
}
-function GJ(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { iouThreshold: n, maxOutputSize: s, scoreThreshold: a, padToMaxOutputSize: i } = o, { boxes: p, scores: u } = t10, c = e.dataIdMap.get(p.dataId).id, l = e.dataIdMap.get(u.dataId).id, m = yO(c, l, s, n, a, i), { pSelectedIndices: f, selectedSize: d, pSelectedScores: h, pValidOutputs: g } = kc(e, m);
+function mJ(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { iouThreshold: n, maxOutputSize: s, scoreThreshold: a, padToMaxOutputSize: i } = o, { boxes: p, scores: u } = t6, c = e.dataIdMap.get(p.dataId).id, l = e.dataIdMap.get(u.dataId).id, m = jO(c, l, s, n, a, i), { pSelectedIndices: d, selectedSize: f, pSelectedScores: h, pValidOutputs: g } = Sc(e, m);
e.wasm._free(h);
- let y = e.makeOutput([d], "int32", f), b = e.makeOutput([], "int32", g);
- return [y, b];
+ let x = e.makeOutput([f], "int32", d), b = e.makeOutput([], "int32", g);
+ return [x, b];
}
-var bO = { kernelName: pa, backendName: "wasm", setupFunc: UJ, kernelFunc: GJ };
-var CO;
-function HJ(r) {
- CO = r.wasm.cwrap(Mn, "number", ["number", "number", "number", "number", "number", "number"]);
+var XO = { kernelName: ba, backendName: "wasm", setupFunc: lJ, kernelFunc: mJ };
+var YO;
+function dJ(r) {
+ YO = r.wasm.cwrap(_n, "number", ["number", "number", "number", "number", "number", "number"]);
}
-function qJ(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { iouThreshold: n, maxOutputSize: s, scoreThreshold: a, softNmsSigma: i } = o, { boxes: p, scores: u } = t10, c = e.dataIdMap.get(p.dataId).id, l = e.dataIdMap.get(u.dataId).id, m = CO(c, l, s, n, a, i), { pSelectedIndices: f, selectedSize: d, pSelectedScores: h, pValidOutputs: g } = kc(e, m);
+function fJ(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { iouThreshold: n, maxOutputSize: s, scoreThreshold: a, softNmsSigma: i } = o, { boxes: p, scores: u } = t6, c = e.dataIdMap.get(p.dataId).id, l = e.dataIdMap.get(u.dataId).id, m = YO(c, l, s, n, a, i), { pSelectedIndices: d, selectedSize: f, pSelectedScores: h, pValidOutputs: g } = Sc(e, m);
e.wasm._free(g);
- let y = e.makeOutput([d], "int32", f), b = e.makeOutput([d], "float32", h);
- return [y, b];
+ let x = e.makeOutput([f], "int32", d), b = e.makeOutput([f], "float32", h);
+ return [x, b];
}
-var IO = { kernelName: Mn, backendName: "wasm", setupFunc: HJ, kernelFunc: qJ };
-var KJ = false;
-var wO = nt(go, KJ, "bool");
-var SO;
-function jJ(r) {
- SO = r.wasm.cwrap(ca, null, ["number", "number", "number", "number", "number"]);
+var QO = { kernelName: _n, backendName: "wasm", setupFunc: dJ, kernelFunc: fJ };
+var hJ = false;
+var ZO = rt(Nn, hJ, "bool");
+var JO;
+function gJ(r) {
+ JO = r.wasm.cwrap(En, null, ["number", "number", "number", "number", "number"]);
}
-function XJ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { indices: n } = e, { dtype: s, depth: a, onValue: i, offValue: p } = o, u = t10.makeOutput([...n.shape, a], s), c = t10.dataIdMap.get(u.dataId).id, m = t10.dataIdMap.get(n.dataId).id;
- return SO(m, a, i, p, c), u;
+function xJ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { indices: n } = e, { dtype: s, depth: a, onValue: i, offValue: p } = o, u = t6.makeOutput([...n.shape, a], s), c = t6.dataIdMap.get(u.dataId).id, m = t6.dataIdMap.get(n.dataId).id;
+ return JO(m, a, i, p, c), u;
}
-var vO = { kernelName: ca, backendName: "wasm", setupFunc: jJ, kernelFunc: XJ };
-function YJ(r) {
- let { inputs: { x: e }, backend: t10 } = r, o = t10.makeOutput(e.shape, e.dtype);
- return t10.typedArrayFromHeap(o).fill(1), o;
+var eP = { kernelName: En, backendName: "wasm", setupFunc: gJ, kernelFunc: xJ };
+function yJ(r) {
+ let { inputs: { x: e }, backend: t6 } = r, o = t6.makeOutput(e.shape, e.dtype);
+ return t6.typedArrayFromHeap(o).fill(1), o;
}
-var kO = { kernelName: Cs, backendName: "wasm", kernelFunc: YJ };
-function QJ(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { axis: n } = o;
+var tP = { kernelName: Is, backendName: "wasm", kernelFunc: yJ };
+function bJ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { axis: n } = o;
if (e.length === 1)
- return Eg({ inputs: { input: e[0] }, backend: t10, attrs: { dim: n } });
+ return yg({ inputs: { input: e[0] }, backend: t6, attrs: { dim: n } });
let s = e[0].shape, a = e[0].dtype;
e.forEach((c) => {
- x.assertShapesMatch(s, c.shape, "All tensors passed to stack must have matching shapes"), x.assert(a === c.dtype, () => "All tensors passed to stack must have matching dtypes");
+ y.assertShapesMatch(s, c.shape, "All tensors passed to stack must have matching shapes"), y.assert(a === c.dtype, () => "All tensors passed to stack must have matching dtypes");
});
let i = [], p = e.map((c) => {
- let l = Eg({ inputs: { input: c }, backend: t10, attrs: { dim: n } });
+ let l = yg({ inputs: { input: c }, backend: t6, attrs: { dim: n } });
return i.push(l), l;
- }), u = qw({ inputs: p, backend: t10, attrs: { axis: n } });
- return i.forEach((c) => t10.disposeData(c.dataId)), u;
+ }), u = zw({ inputs: p, backend: t6, attrs: { axis: n } });
+ return i.forEach((c) => t6.disposeData(c.dataId)), u;
}
-var TO = { kernelName: Is, backendName: "wasm", kernelFunc: QJ };
-var NO;
-function ZJ(r) {
- NO = r.wasm.cwrap(Ln, null, ["number", "array", "number", "number", "array", "array", "number", "number"]);
+var rP = { kernelName: vs, backendName: "wasm", kernelFunc: bJ };
+var oP;
+function CJ(r) {
+ oP = r.wasm.cwrap($n, null, ["number", "array", "number", "number", "array", "array", "number", "number"]);
}
-function JJ(r) {
- let { inputs: { x: e }, backend: t10, attrs: { paddings: o, constantValue: n } } = r, s = o.map((h, g) => h[0] + e.shape[g] + h[1]);
- if (x.sizeFromShape(e.shape) === 0)
- return jw({ backend: t10, attrs: { shape: s, value: n, dtype: e.dtype } });
- let a = t10.dataIdMap.get(e.dataId).id, i = t10.makeOutput(s, e.dtype), u = t10.dataIdMap.get(i.dataId).id, c = new Uint8Array(new Int32Array(e.shape).buffer), l = o.map((h) => h[0]), m = o.map((h) => h[1]), f = new Uint8Array(new Int32Array(l).buffer), d = new Uint8Array(new Int32Array(m).buffer);
- return NO(a, c, e.shape.length, Ae[e.dtype], f, d, n, u), i;
+function SJ(r) {
+ let { inputs: { x: e }, backend: t6, attrs: { paddings: o, constantValue: n } } = r, s = o.map((h, g) => h[0] + e.shape[g] + h[1]);
+ if (y.sizeFromShape(e.shape) === 0)
+ return Uw({ backend: t6, attrs: { shape: s, value: n, dtype: e.dtype } });
+ let a = t6.dataIdMap.get(e.dataId).id, i = t6.makeOutput(s, e.dtype), u = t6.dataIdMap.get(i.dataId).id, c = new Uint8Array(new Int32Array(e.shape).buffer), l = o.map((h) => h[0]), m = o.map((h) => h[1]), d = new Uint8Array(new Int32Array(l).buffer), f = new Uint8Array(new Int32Array(m).buffer);
+ return oP(a, c, e.shape.length, Fe[e.dtype], d, f, n, u), i;
}
-var $g = { kernelName: Ln, backendName: "wasm", kernelFunc: JJ, setupFunc: ZJ };
-var eee = false;
-var _O = nt(Bn, eee);
-var EO;
-function tee(r) {
- EO = r.wasm.cwrap(Vn, null, ["number", "number", "number"]);
+var bg = { kernelName: $n, backendName: "wasm", kernelFunc: SJ, setupFunc: CJ };
+var wJ = false;
+var nP = rt(An, wJ);
+var sP;
+function IJ(r) {
+ sP = r.wasm.cwrap(Rn, null, ["number", "number", "number"]);
}
-function ree(r) {
- let { inputs: e, backend: t10 } = r, { x: o, alpha: n } = e, s = t10.dataIdMap.get(o.dataId).id, a = t10.dataIdMap.get(n.dataId).id, i = s, p = o, u = p;
- p.dtype !== "float32" && (u = cs({ backend: t10, inputs: { x: o }, attrs: { dtype: "float32" } }), i = t10.dataIdMap.get(u.dataId).id);
- let c = t10.makeOutput(o.shape, "float32"), l = t10.dataIdMap.get(c.dataId).id;
- return EO(i, a, l), p.dtype !== "float32" && t10.disposeData(u.dataId), c;
+function vJ(r) {
+ let { inputs: e, backend: t6 } = r, { x: o, alpha: n } = e, s = t6.dataIdMap.get(o.dataId).id, a = t6.dataIdMap.get(n.dataId).id, i = s, p = o, u = p;
+ p.dtype !== "float32" && (u = ls({ backend: t6, inputs: { x: o }, attrs: { dtype: "float32" } }), i = t6.dataIdMap.get(u.dataId).id);
+ let c = t6.makeOutput(o.shape, "float32"), l = t6.dataIdMap.get(c.dataId).id;
+ return sP(i, a, l), p.dtype !== "float32" && t6.disposeData(u.dataId), c;
}
-var $O = { kernelName: Vn, backendName: "wasm", setupFunc: tee, kernelFunc: ree };
-var RO;
-function oee(r) {
- RO = r.wasm.cwrap(Ao, null, ["number", "number", "number", "number"]);
+var aP = { kernelName: Rn, backendName: "wasm", setupFunc: IJ, kernelFunc: vJ };
+var iP;
+function kJ(r) {
+ iP = r.wasm.cwrap(Fn, null, ["number", "number", "number", "number"]);
}
-function nee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t10, i = e.dataIdMap.get(a.dataId).id, p = i, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: f } = kr(a, n, e), d = l;
- if (f) {
+function NJ(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t6, i = e.dataIdMap.get(a.dataId).id, p = i, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: d } = kr(a, n, e), f = l;
+ if (d) {
let C = e.dataIdMap.get(c.dataId).id;
- C !== i && (u = c, p = C, d = I.getInnerMostAxes(d.length, u.shape.length));
+ C !== i && (u = c, p = C, f = S.getInnerMostAxes(f.length, u.shape.length));
}
- I.assertAxesAreInnerMostDims("prod", d, u.shape.length);
- let [h, g] = I.computeOutAndReduceShapes(u.shape, d), y = x.sizeFromShape(g), b = e.makeOutput(h, u.dtype);
- if (x.sizeFromShape(u.shape) !== 0) {
+ S.assertAxesAreInnerMostDims("prod", f, u.shape.length);
+ let [h, g] = S.computeOutAndReduceShapes(u.shape, f), x = y.sizeFromShape(g), b = e.makeOutput(h, u.dtype);
+ if (y.sizeFromShape(u.shape) !== 0) {
let C = e.dataIdMap.get(b.dataId).id;
- RO(p, y, Ae[b.dtype], C);
+ iP(p, x, Fe[b.dtype], C);
}
- if (f && e.disposeData(c.dataId), s) {
- let C = I.expandShapeToKeepDim(b.shape, m);
+ if (d && e.disposeData(c.dataId), s) {
+ let C = S.expandShapeToKeepDim(b.shape, m);
b.shape = C;
}
return b;
}
-var AO = { kernelName: Ao, backendName: "wasm", setupFunc: oee, kernelFunc: nee };
-var see = (r) => {
- let { backend: e, attrs: t10 } = r, { start: o, stop: n, step: s, dtype: a } = t10, i = Su(o, n, s, a), p = e.makeOutput([i.length], a);
+var uP = { kernelName: Fn, backendName: "wasm", setupFunc: kJ, kernelFunc: NJ };
+var TJ = (r) => {
+ let { backend: e, attrs: t6 } = r, { start: o, stop: n, step: s, dtype: a } = t6, i = Iu(o, n, s, a), p = e.makeOutput([i.length], a);
return e.typedArrayFromHeap(p).set(i), p;
};
-var FO = { kernelName: ws, backendName: "wasm", kernelFunc: see };
-var aee = true;
-var DO = nt(Cn, aee);
-var PO = Qe(zn);
-var OO = Qe(Gn);
-var MO;
-function iee(r) {
- MO = r.wasm.cwrap(Un, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var pP = { kernelName: ks, backendName: "wasm", kernelFunc: TJ };
+var _J = true;
+var cP = rt(Jo, _J);
+var lP = Ve(Dn);
+var mP = Ve(On);
+var dP = Ve(Ln);
+var fP;
+function EJ(r) {
+ fP = r.wasm.cwrap(Mn, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function uee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { images: n } = t10, { alignCorners: s, halfPixelCenters: a, size: i } = o, [p, u] = i, [c, l, m, f] = n.shape, d = [c, p, u, f], h = e.dataIdMap.get(n.dataId), g;
- h.dtype !== "float32" && (g = cs({ backend: e, inputs: { x: n }, attrs: { dtype: "float32" } }), h = e.dataIdMap.get(g.dataId));
- let y = h.id, b = e.makeOutput(d, "float32");
- if (x.sizeFromShape(n.shape) === 0)
+function $J(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { images: n } = t6, { alignCorners: s, halfPixelCenters: a, size: i } = o, [p, u] = i, [c, l, m, d] = n.shape, f = [c, p, u, d], h = e.dataIdMap.get(n.dataId), g;
+ h.dtype !== "float32" && (g = ls({ backend: e, inputs: { x: n }, attrs: { dtype: "float32" } }), h = e.dataIdMap.get(g.dataId));
+ let x = h.id, b = e.makeOutput(f, "float32");
+ if (y.sizeFromShape(n.shape) === 0)
return b;
let C = e.dataIdMap.get(b.dataId).id;
- return MO(y, c, l, m, f, p, u, s ? 1 : 0, a ? 1 : 0, C), g != null && e.disposeData(g.dataId), b;
+ return fP(x, c, l, m, d, p, u, s ? 1 : 0, a ? 1 : 0, C), g != null && e.disposeData(g.dataId), b;
}
-var LO = { kernelName: Un, backendName: "wasm", setupFunc: iee, kernelFunc: uee };
-var BO;
-function pee(r) {
- BO = r.wasm.cwrap(Wn, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var hP = { kernelName: Mn, backendName: "wasm", setupFunc: EJ, kernelFunc: $J };
+var gP;
+function AJ(r) {
+ gP = r.wasm.cwrap(Pn, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function cee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { images: n } = t10, { alignCorners: s, halfPixelCenters: a, size: i } = o, [p, u] = i, [c, l, m, f] = n.shape, d = [c, p, u, f], h = e.makeOutput(d, "float32");
- if (x.sizeFromShape(n.shape) === 0)
+function RJ(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { images: n } = t6, { alignCorners: s, halfPixelCenters: a, size: i } = o, [p, u] = i, [c, l, m, d] = n.shape, f = [c, p, u, d], h = e.makeOutput(f, "float32");
+ if (y.sizeFromShape(n.shape) === 0)
return h;
- let g = e.dataIdMap.get(n.dataId), y;
- g.dtype !== "float32" && (y = cs({ backend: e, inputs: { x: n }, attrs: { dtype: "float32" } }), g = e.dataIdMap.get(y.dataId));
+ let g = e.dataIdMap.get(n.dataId), x;
+ g.dtype !== "float32" && (x = ls({ backend: e, inputs: { x: n }, attrs: { dtype: "float32" } }), g = e.dataIdMap.get(x.dataId));
let b = g.id, C = e.dataIdMap.get(h.dataId).id;
- return BO(b, c, l, m, f, p, u, s ? 1 : 0, a ? 1 : 0, C), y != null && e.disposeData(y.dataId), h;
+ return gP(b, c, l, m, d, p, u, s ? 1 : 0, a ? 1 : 0, C), x != null && e.disposeData(x.dataId), h;
}
-var VO = { kernelName: Wn, backendName: "wasm", setupFunc: pee, kernelFunc: cee };
-var zO;
-function lee(r) {
- zO = r.wasm.cwrap(fa, null, ["number", "array", "number", "array", "number", "number"]);
+var xP = { kernelName: Pn, backendName: "wasm", setupFunc: AJ, kernelFunc: RJ };
+var yP;
+function FJ(r) {
+ yP = r.wasm.cwrap(Bn, null, ["number", "array", "number", "array", "number", "number"]);
}
-function mee(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { dims: s } = o, a = x.parseAxisParam(s, n.shape);
+function DJ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { dims: s } = o, a = y.parseAxisParam(s, n.shape);
if (n.shape.length === 0)
- return zu({ inputs: { x: n }, backend: t10 });
- let i = t10.makeOutput(n.shape, n.dtype), p = t10.dataIdMap.get(n.dataId).id, u = t10.dataIdMap.get(i.dataId).id, c = new Uint8Array(new Int32Array(a).buffer), l = new Uint8Array(new Int32Array(n.shape).buffer);
- zO(p, c, a.length, l, n.shape.length, u);
- let m = Mt({ inputs: { x: i }, attrs: { shape: n.shape }, backend: t10 });
- return t10.disposeData(i.dataId), m;
+ return Vu({ inputs: { x: n }, backend: t6 });
+ let i = t6.makeOutput(n.shape, n.dtype), p = t6.dataIdMap.get(n.dataId).id, u = t6.dataIdMap.get(i.dataId).id, c = new Uint8Array(new Int32Array(a).buffer), l = new Uint8Array(new Int32Array(n.shape).buffer);
+ yP(p, c, a.length, l, n.shape.length, u);
+ let m = Mt({ inputs: { x: i }, attrs: { shape: n.shape }, backend: t6 });
+ return t6.disposeData(i.dataId), m;
}
-var WO = { kernelName: fa, backendName: "wasm", kernelFunc: mee, setupFunc: lee };
-var UO;
-function fee(r) {
- UO = r.wasm.cwrap(es, null, ["number", "number", "number", "number", "number", "number", "number", "number", "array", "number", "number"]);
+var bP = { kernelName: Bn, backendName: "wasm", kernelFunc: DJ, setupFunc: FJ };
+var CP;
+function OJ(r) {
+ CP = r.wasm.cwrap(es, null, ["number", "number", "number", "number", "number", "number", "number", "number", "array", "number", "number"]);
}
-function dee(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { image: n } = e, { radians: s, fillValue: a, center: i } = o, p = t10.makeOutput(n.shape, n.dtype), u = t10.dataIdMap.get(n.dataId).id, c = t10.dataIdMap.get(p.dataId).id, [l, m, f, d] = n.shape, [h, g] = I.getImageCenter(i, m, f), y = a === 0, b = 255, C = typeof a == "number" ? [a, a, a, y ? 0 : b] : [...a, b], w = new Uint8Array(new Int32Array(C).buffer);
- return UO(u, l, m, f, d, s, h, g, w, C.length, c), p;
+function PJ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { image: n } = e, { radians: s, fillValue: a, center: i } = o, p = t6.makeOutput(n.shape, n.dtype), u = t6.dataIdMap.get(n.dataId).id, c = t6.dataIdMap.get(p.dataId).id, [l, m, d, f] = n.shape, [h, g] = S.getImageCenter(i, m, d), x = a === 0, b = 255, C = typeof a == "number" ? [a, a, a, x ? 0 : b] : [...a, b], w = new Uint8Array(new Int32Array(C).buffer);
+ return CP(u, l, m, d, f, s, h, g, w, C.length, c), p;
}
-var GO = { kernelName: es, backendName: "wasm", kernelFunc: dee, setupFunc: fee };
-var HO = Qe(da);
-var qO = Qe(xo);
-var KO;
-function hee(r) {
- KO = r.wasm.cwrap(Hn, null, ["number", "number", "number", "number", "number", "number", "array", "number", "number"]);
+var SP = { kernelName: es, backendName: "wasm", kernelFunc: PJ, setupFunc: OJ };
+var wP = Ve(Ca);
+var IP = Ve(Vn);
+var vP;
+function MJ(r) {
+ vP = r.wasm.cwrap(zn, null, ["number", "number", "number", "number", "number", "number", "array", "number", "number"]);
}
-function gee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { indices: n, updates: s } = t10, { shape: a } = o, i = e.makeOutput(a, s.dtype);
- if (x.sizeFromShape(a) === 0)
+function LJ(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { indices: n, updates: s } = t6, { shape: a } = o, i = e.makeOutput(a, s.dtype);
+ if (y.sizeFromShape(a) === 0)
return i;
- let { sliceRank: p, numUpdates: u, sliceSize: c, strides: l, outputSize: m } = cl.calculateShapes(s, n, a), d = e.dataIdMap.get(n.dataId).id, g = e.dataIdMap.get(s.dataId).id, y = new Uint8Array(new Int32Array(l).buffer), b = e.dataIdMap.get(i.dataId).id;
- return KO(d, g, Ae[s.dtype], p, u, c, y, m, b), i;
+ let { sliceRank: p, numUpdates: u, sliceSize: c, strides: l, outputSize: m } = rl.calculateShapes(s, n, a), f = e.dataIdMap.get(n.dataId).id, g = e.dataIdMap.get(s.dataId).id, x = new Uint8Array(new Int32Array(l).buffer), b = e.dataIdMap.get(i.dataId).id;
+ return vP(f, g, Fe[s.dtype], p, u, c, x, m, b), i;
}
-var jO = { kernelName: Hn, backendName: "wasm", setupFunc: hee, kernelFunc: gee };
-var XO;
-function xee(r) {
- XO = r.wasm.cwrap("SelectV2", null, ["number", "number", "number", "number", "number"]);
+var kP = { kernelName: zn, backendName: "wasm", setupFunc: MJ, kernelFunc: LJ };
+var NP;
+function BJ(r) {
+ NP = r.wasm.cwrap("SelectV2", null, ["number", "number", "number", "number", "number"]);
}
-function yee(r) {
- let { inputs: e, backend: t10 } = r, { condition: o, t: n, e: s } = e, a = t10.dataIdMap.get(o.dataId).id, i = t10.dataIdMap.get(n.dataId).id, p = t10.dataIdMap.get(s.dataId).id, u = t10.makeOutput(n.shape, n.dtype), c = t10.dataIdMap.get(u.dataId).id, l = o.shape.length, m = n.shape.length, f = l === 0 || l > 1 || m === 1 ? 1 : x.sizeFromShape(n.shape.slice(1));
- return XO(a, i, p, f, c), u;
+function VJ(r) {
+ let { inputs: e, backend: t6 } = r, { condition: o, t: n, e: s } = e, a = t6.dataIdMap.get(o.dataId).id, i = t6.dataIdMap.get(n.dataId).id, p = t6.dataIdMap.get(s.dataId).id, u = t6.makeOutput(n.shape, n.dtype), c = t6.dataIdMap.get(u.dataId).id, l = o.shape.length, m = n.shape.length, d = l === 0 || l > 1 || m === 1 ? 1 : y.sizeFromShape(n.shape.slice(1));
+ return NP(a, i, p, d, c), u;
}
-var YO = { kernelName: vs, backendName: "wasm", kernelFunc: yee, setupFunc: xee };
-var QO;
-function bee(r) {
- QO = r.wasm.cwrap(yo, null, ["number", "number"]);
+var TP = { kernelName: Ts, backendName: "wasm", kernelFunc: VJ, setupFunc: BJ };
+var _P;
+function zJ(r) {
+ _P = r.wasm.cwrap(Un, null, ["number", "number"]);
}
-function Cee(r) {
- let { backend: e, inputs: { x: t10 } } = r, o = e.dataIdMap.get(t10.dataId).id, n = e.makeOutput(t10.shape, t10.dtype), s = e.dataIdMap.get(n.dataId).id;
- return x.sizeFromShape(n.shape) === 0 || QO(o, s), n;
+function WJ(r) {
+ let { backend: e, inputs: { x: t6 } } = r, o = e.dataIdMap.get(t6.dataId).id, n = e.makeOutput(t6.shape, t6.dtype), s = e.dataIdMap.get(n.dataId).id;
+ return y.sizeFromShape(n.shape) === 0 || _P(o, s), n;
}
-var ZO = { kernelName: "Sigmoid", backendName: "wasm", setupFunc: bee, kernelFunc: Cee };
-var JO = Qe(Kn);
-var e3;
-function Iee(r) {
- e3 = r.wasm.cwrap(Xn, null, ["number", "number", "number", "number"]);
+var EP = { kernelName: "Sigmoid", backendName: "wasm", setupFunc: zJ, kernelFunc: WJ };
+var $P = Ve(Wn);
+var AP;
+function UJ(r) {
+ AP = r.wasm.cwrap(qn, null, ["number", "number", "number", "number"]);
}
-function wee(r) {
- let { backend: e, inputs: { logits: t10 }, attrs: { dim: o } } = r, n = e.dataIdMap.get(t10.dataId).id, s = e.makeOutput(t10.shape, t10.dtype), a = e.dataIdMap.get(s.dataId).id, i = t10.shape[o], p = x.sizeFromShape(t10.shape) / i;
- return x.sizeFromShape(s.shape) === 0 || e3(n, a, i, p), s;
+function GJ(r) {
+ let { backend: e, inputs: { logits: t6 }, attrs: { dim: o } } = r, n = e.dataIdMap.get(t6.dataId).id, s = e.makeOutput(t6.shape, t6.dtype), a = e.dataIdMap.get(s.dataId).id, i = t6.shape[o], p = y.sizeFromShape(t6.shape) / i;
+ return y.sizeFromShape(s.shape) === 0 || AP(n, a, i, p), s;
}
-var t3 = { kernelName: Xn, backendName: "wasm", setupFunc: Iee, kernelFunc: wee };
-function See(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { blockShape: s, paddings: a } = o, i = x.sizeFromShape(s), p = [[0, 0]];
+var RP = { kernelName: qn, backendName: "wasm", setupFunc: UJ, kernelFunc: GJ };
+function HJ(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { blockShape: s, paddings: a } = o, i = y.sizeFromShape(s), p = [[0, 0]];
p.push(...a);
for (let _ = 1 + s.length; _ < n.shape.length; ++_)
p.push([0, 0]);
- let u = $g.kernelFunc({ inputs: { x: n }, backend: t10, attrs: { paddings: p, constantValue: 0 } }), c = I.getReshaped(u.shape, s, i, false), l = I.getPermuted(c.length, s.length, false), m = I.getReshapedPermuted(u.shape, s, i, false), h = Mt({ inputs: { x: u }, backend: t10, attrs: { shape: c } }), b = Eo({ inputs: { x: h }, backend: t10, attrs: { perm: l } }), k = Mt({ inputs: { x: b }, backend: t10, attrs: { shape: m } });
- return t10.disposeData(u.dataId), t10.disposeData(h.dataId), t10.disposeData(b.dataId), k;
+ let u = bg.kernelFunc({ inputs: { x: n }, backend: t6, attrs: { paddings: p, constantValue: 0 } }), c = S.getReshaped(u.shape, s, i, false), l = S.getPermuted(c.length, s.length, false), m = S.getReshapedPermuted(u.shape, s, i, false), h = Mt({ inputs: { x: u }, backend: t6, attrs: { shape: c } }), b = uo({ inputs: { x: h }, backend: t6, attrs: { perm: l } }), k = Mt({ inputs: { x: b }, backend: t6, attrs: { shape: m } });
+ return t6.disposeData(u.dataId), t6.disposeData(h.dataId), t6.disposeData(b.dataId), k;
}
-var r3 = { kernelName: ks, backendName: "wasm", kernelFunc: See };
-var o3;
-function vee(r) {
- o3 = r.wasm.cwrap("SparseFillEmptyRows", "number", ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var FP = { kernelName: Es, backendName: "wasm", kernelFunc: HJ };
+var DP;
+function qJ(r) {
+ DP = r.wasm.cwrap("SparseFillEmptyRows", "number", ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function kee(r) {
- let { backend: e, inputs: t10 } = r, { indices: o, values: n, denseShape: s, defaultValue: a } = t10, i = o.shape[0], p = o.shape[1], u = e.readSync(s.dataId)[0], c = [i + u, p], l = e.dataIdMap.get(o.dataId).id, m = e.dataIdMap.get(n.dataId).id, f = e.dataIdMap.get(a.dataId).id, d = e.makeOutput(c, o.dtype), h = e.dataIdMap.get(d.dataId).id, g = e.makeOutput(c.slice(0, 1), n.dtype), y = e.dataIdMap.get(g.dataId).id, b = e.makeOutput([u], "bool"), C = e.dataIdMap.get(b.dataId).id, w = e.makeOutput([i], o.dtype), k = e.dataIdMap.get(w.dataId).id, _ = e.makeOutput([4], "int32"), E = e.dataIdMap.get(_.dataId).id, R = o3(l, m, Ae[n.dtype], i, u, p, f, h, y, C, k, E), A = e.readSync(_.dataId), D;
- switch (A[0]) {
+function KJ(r) {
+ let { backend: e, inputs: t6 } = r, { indices: o, values: n, denseShape: s, defaultValue: a } = t6, i = o.shape[0], p = o.shape[1], u = e.readSync(s.dataId)[0], c = [i + u, p], l = e.dataIdMap.get(o.dataId).id, m = e.dataIdMap.get(n.dataId).id, d = e.dataIdMap.get(a.dataId).id, f = e.makeOutput(c, o.dtype), h = e.dataIdMap.get(f.dataId).id, g = e.makeOutput(c.slice(0, 1), n.dtype), x = e.dataIdMap.get(g.dataId).id, b = e.makeOutput([u], "bool"), C = e.dataIdMap.get(b.dataId).id, w = e.makeOutput([i], o.dtype), k = e.dataIdMap.get(w.dataId).id, _ = e.makeOutput([4], "int32"), $ = e.dataIdMap.get(_.dataId).id, A = DP(l, m, Fe[n.dtype], i, u, p, d, h, x, C, k, $), R = e.readSync(_.dataId), D;
+ switch (R[0]) {
case 1: {
- D = I.getSparseFillEmptyRowsIndicesDenseShapeMismatch(A[1]);
+ D = S.getSparseFillEmptyRowsIndicesDenseShapeMismatch(R[1]);
break;
}
case 2: {
- D = I.getSparseFillEmptyRowsNegativeIndexErrorMessage(A[1], A[2]);
+ D = S.getSparseFillEmptyRowsNegativeIndexErrorMessage(R[1], R[2]);
break;
}
case 3:
- D = I.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(A[1], A[2], A[3]);
+ D = S.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(R[1], R[2], R[3]);
break;
default:
D = "";
}
if (e.disposeData(_.dataId), D)
- throw e.disposeData(d.dataId), e.disposeData(g.dataId), e.disposeData(b.dataId), e.disposeData(w.dataId), new Error(D);
- let O = d, M = g;
- return R !== c[0] && (O = Xo({ inputs: { x: d }, attrs: { begin: 0, size: [R, p] }, backend: e }), M = Xo({ inputs: { x: g }, attrs: { begin: 0, size: R }, backend: e }), e.disposeData(d.dataId), e.disposeData(g.dataId)), [O, M, b, w];
+ throw e.disposeData(f.dataId), e.disposeData(g.dataId), e.disposeData(b.dataId), e.disposeData(w.dataId), new Error(D);
+ let P = f, M = g;
+ return A !== c[0] && (P = Eo({ inputs: { x: f }, attrs: { begin: 0, size: [A, p] }, backend: e }), M = Eo({ inputs: { x: g }, attrs: { begin: 0, size: A }, backend: e }), e.disposeData(f.dataId), e.disposeData(g.dataId)), [P, M, b, w];
}
-var n3 = { kernelName: Qa, backendName: "wasm", setupFunc: vee, kernelFunc: kee };
-var s3;
-function Tee(r) {
- s3 = r.wasm.cwrap(ga, null, ["number", "number", "number", "number", "number", "number", "number"]);
+var OP = { kernelName: ui, backendName: "wasm", setupFunc: qJ, kernelFunc: KJ };
+var PP;
+function jJ(r) {
+ PP = r.wasm.cwrap(wa, null, ["number", "number", "number", "number", "number", "number", "number"]);
}
-function Nee(r) {
- let { backend: e, inputs: t10 } = r, { inputIndices: o, inputShape: n, newShape: s } = t10;
+function XJ(r) {
+ let { backend: e, inputs: t6 } = r, { inputIndices: o, inputShape: n, newShape: s } = t6;
if (o.shape.length !== 2)
throw new Error(`Input indices should be a matrix but received shape
${o.shape}`);
@@ -25065,201 +25133,201 @@ function Nee(r) {
${n.shape}`);
if (s.shape.length !== 1)
throw new Error(`Target shape should be a vector but received shape ${s.shape}`);
- let a = e.dataIdMap.get(o.dataId).id, i = e.dataIdMap.get(n.dataId).id, p = e.dataIdMap.get(s.dataId).id, u = o.shape[0], c = x.sizeFromShape(s.shape), l = e.makeOutput([u, c], o.dtype), m = e.dataIdMap.get(l.dataId).id, f = e.makeOutput([c], s.dtype), d = e.dataIdMap.get(f.dataId).id, h = e.makeOutput([3], "int32"), g = e.dataIdMap.get(h.dataId).id;
- s3(a, i, p, u, m, d, g);
- let y = e.readSync(h.dataId), b;
- switch (y[0]) {
+ let a = e.dataIdMap.get(o.dataId).id, i = e.dataIdMap.get(n.dataId).id, p = e.dataIdMap.get(s.dataId).id, u = o.shape[0], c = y.sizeFromShape(s.shape), l = e.makeOutput([u, c], o.dtype), m = e.dataIdMap.get(l.dataId).id, d = e.makeOutput([c], s.dtype), f = e.dataIdMap.get(d.dataId).id, h = e.makeOutput([3], "int32"), g = e.dataIdMap.get(h.dataId).id;
+ PP(a, i, p, u, m, f, g);
+ let x = e.readSync(h.dataId), b;
+ switch (x[0]) {
case 0: {
- b = I.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(y[1], y[2]);
+ b = S.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(x[1], x[2]);
break;
}
case 1: {
- b = I.getSparseReshapeNegativeOutputDimErrorMessage(y[1], y[2]);
+ b = S.getSparseReshapeNegativeOutputDimErrorMessage(x[1], x[2]);
break;
}
case 2:
- b = I.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage();
+ b = S.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage();
break;
case 3: {
- let C = Array.from(e.readSync(n.dataId)), w = Array.from(e.readSync(f.dataId));
- b = I.getSparseReshapeInputOutputMultipleErrorMessage(C, w);
+ let C = Array.from(e.readSync(n.dataId)), w = Array.from(e.readSync(d.dataId));
+ b = S.getSparseReshapeInputOutputMultipleErrorMessage(C, w);
break;
}
case 4: {
- let C = Array.from(e.readSync(n.dataId)), w = Array.from(e.readSync(f.dataId));
- b = I.getSparseReshapeInputOutputMismatchErrorMessage(C, w);
+ let C = Array.from(e.readSync(n.dataId)), w = Array.from(e.readSync(d.dataId));
+ b = S.getSparseReshapeInputOutputMismatchErrorMessage(C, w);
break;
}
default:
b = "";
}
if (e.disposeData(h.dataId), b)
- throw e.disposeData(l.dataId), e.disposeData(f.dataId), new Error(b);
- return [l, f];
+ throw e.disposeData(l.dataId), e.disposeData(d.dataId), new Error(b);
+ return [l, d];
}
-var a3 = { kernelName: ga, backendName: "wasm", setupFunc: Tee, kernelFunc: Nee };
-var i3;
-function Rg(r) {
- i3 = r.wasm.cwrap("SparseSegmentReduction", null, ["number", "number", "number", "number", "number", "number", "number", "number", "number"]);
+var MP = { kernelName: wa, backendName: "wasm", setupFunc: jJ, kernelFunc: XJ };
+var LP;
+function Cg(r) {
+ LP = r.wasm.cwrap("SparseSegmentReduction", null, ["number", "number", "number", "number", "number", "number", "number", "number", "number"]);
}
-function Ag(r, e) {
- let { backend: t10, inputs: o } = r, { data: n, indices: s, segmentIds: a } = o, i = s.shape[0], p = t10.readSync(a.dataId, i - 1, i)[0], c = i > 0 ? p + 1 : 0;
+function Sg(r, e) {
+ let { backend: t6, inputs: o } = r, { data: n, indices: s, segmentIds: a } = o, i = s.shape[0], p = t6.readSync(a.dataId, i - 1, i)[0], c = i > 0 ? p + 1 : 0;
if (c < 0)
- throw new Error(I.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
+ throw new Error(S.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
let l = n.shape.slice();
l[0] = c;
- let m = t10.dataIdMap.get(n.dataId).id, f = t10.dataIdMap.get(s.dataId).id, d = t10.dataIdMap.get(a.dataId).id, h = t10.makeOutput(l, n.dtype), g = t10.dataIdMap.get(h.dataId).id, y = t10.makeOutput([4], "int32"), b = t10.dataIdMap.get(y.dataId).id;
- i3(m, Ae[n.dtype], n.shape[0], f, d, g, b, e, 0);
- let C = t10.readSync(y.dataId), w;
+ let m = t6.dataIdMap.get(n.dataId).id, d = t6.dataIdMap.get(s.dataId).id, f = t6.dataIdMap.get(a.dataId).id, h = t6.makeOutput(l, n.dtype), g = t6.dataIdMap.get(h.dataId).id, x = t6.makeOutput([4], "int32"), b = t6.dataIdMap.get(x.dataId).id;
+ LP(m, Fe[n.dtype], n.shape[0], d, f, g, b, e, 0);
+ let C = t6.readSync(x.dataId), w;
switch (C[0]) {
case 0: {
- w = I.getSparseSegmentReductionNegativeSegmentIdsErrorMessage();
+ w = S.getSparseSegmentReductionNegativeSegmentIdsErrorMessage();
break;
}
case 1: {
- w = I.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage();
+ w = S.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage();
break;
}
case 2:
- w = I.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(C[1], C[2]);
+ w = S.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(C[1], C[2]);
break;
case 3:
- w = I.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(C[1], C[2], C[3]);
+ w = S.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(C[1], C[2], C[3]);
break;
default:
w = "";
}
- if (t10.disposeData(y.dataId), w)
- throw t10.disposeData(h.dataId), new Error(w);
+ if (t6.disposeData(x.dataId), w)
+ throw t6.disposeData(h.dataId), new Error(w);
return h;
}
-function _ee(r) {
- return Ag(r, true);
+function YJ(r) {
+ return Sg(r, true);
}
-var u3 = { kernelName: Za, backendName: "wasm", setupFunc: Rg, kernelFunc: _ee };
-function Eee(r) {
- return Ag(r, false);
+var BP = { kernelName: pi, backendName: "wasm", setupFunc: Cg, kernelFunc: YJ };
+function QJ(r) {
+ return Sg(r, false);
}
-var p3 = { kernelName: Ja, backendName: "wasm", setupFunc: Rg, kernelFunc: Eee };
-function $ee(r) {
- let { inputs: e, attrs: t10, backend: o } = r, { x: n } = e, { numOrSizeSplits: s, axis: a } = t10, i = x.parseAxisParam(a, n.shape)[0], p = I.prepareSplitSize(n, s, i), u = new Array(n.shape.length).fill(0), c = n.shape.slice();
+var VP = { kernelName: ci, backendName: "wasm", setupFunc: Cg, kernelFunc: QJ };
+function ZJ(r) {
+ let { inputs: e, attrs: t6, backend: o } = r, { x: n } = e, { numOrSizeSplits: s, axis: a } = t6, i = y.parseAxisParam(a, n.shape)[0], p = S.prepareSplitSize(n, s, i), u = new Array(n.shape.length).fill(0), c = n.shape.slice();
return p.map((l) => {
let m = [...c];
m[i] = l;
- let f = Xo({ inputs: { x: n }, attrs: { begin: u, size: m }, backend: o });
- return u[i] += l, f;
+ let d = Eo({ inputs: { x: n }, attrs: { begin: u, size: m }, backend: o });
+ return u[i] += l, d;
});
}
-var c3 = { kernelName: Ts, backendName: "wasm", kernelFunc: $ee };
-var l3 = Qe(bo);
-var m3 = Qe(ti);
-var Ree = true;
-var f3 = nt(Co, Ree);
-var d3;
-function Aee(r) {
- d3 = r.wasm.cwrap($s, null, ["number", "number", "number", "number"]);
+var zP = { kernelName: $s, backendName: "wasm", kernelFunc: ZJ };
+var WP = Ve(Gn);
+var UP = Ve(mi);
+var JJ = true;
+var GP = rt(Kn, JJ);
+var HP;
+function eee(r) {
+ HP = r.wasm.cwrap(Ds, null, ["number", "number", "number", "number"]);
}
-function Fee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { alpha: n } = o, { x: s } = t10, a = e.dataIdMap.get(s.dataId).id, i = e.makeOutput(s.shape, s.dtype), p = e.dataIdMap.get(i.dataId).id;
- return d3(a, n, Ae[s.dtype], p), i;
+function tee(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { alpha: n } = o, { x: s } = t6, a = e.dataIdMap.get(s.dataId).id, i = e.makeOutput(s.shape, s.dtype), p = e.dataIdMap.get(i.dataId).id;
+ return HP(a, n, Fe[s.dtype], p), i;
}
-var h3 = { kernelName: $s, backendName: "wasm", setupFunc: Aee, kernelFunc: Fee };
-var g3;
-function Dee(r) {
- g3 = r.wasm.cwrap(Yn, null, ["number", "array", "number", "array", "array", "array", "array", "array", "number", "number"]);
+var qP = { kernelName: Ds, backendName: "wasm", setupFunc: eee, kernelFunc: tee };
+var KP;
+function ree(r) {
+ KP = r.wasm.cwrap(jn, null, ["number", "array", "number", "array", "array", "array", "array", "array", "number", "number"]);
}
-function Pee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { x: n } = t10, { begin: s, end: a, strides: i, beginMask: p, endMask: u, ellipsisMask: c, newAxisMask: l, shrinkAxisMask: m } = o, { finalShapeSparse: f, finalShape: d, isIdentity: h, sliceDim0: g, isSimpleSlice: y, begin: b, end: C, strides: w } = et.sliceInfo(n.shape, s, a, i, p, u, c, l, m), k;
+function oee(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { x: n } = t6, { begin: s, end: a, strides: i, beginMask: p, endMask: u, ellipsisMask: c, newAxisMask: l, shrinkAxisMask: m } = o, { finalShapeSparse: d, finalShape: f, isIdentity: h, sliceDim0: g, isSimpleSlice: x, begin: b, end: C, strides: w } = ut.sliceInfo(n.shape, s, a, i, p, u, c, l, m), k;
if (h)
- k = Mt({ inputs: { x: n }, backend: e, attrs: { shape: d } });
- else if (g || y) {
- x.assert(n.shape.length >= 1, () => `Input must have rank at least 1, got: ${n.shape.length}`);
- let _ = et.computeOutShape(b, C, w), E = Xo({ inputs: { x: n }, backend: e, attrs: { begin: b, size: _ } });
- k = Mt({ inputs: { x: E }, backend: e, attrs: { shape: d } }), e.disposeData(E.dataId);
+ k = Mt({ inputs: { x: n }, backend: e, attrs: { shape: f } });
+ else if (g || x) {
+ y.assert(n.shape.length >= 1, () => `Input must have rank at least 1, got: ${n.shape.length}`);
+ let _ = ut.computeOutShape(b, C, w), $ = Eo({ inputs: { x: n }, backend: e, attrs: { begin: b, size: _ } });
+ k = Mt({ inputs: { x: $ }, backend: e, attrs: { shape: f } }), e.disposeData($.dataId);
} else {
- let _ = e.makeOutput(f, "float32"), E = e.dataIdMap.get(n.dataId).id, R = new Uint8Array(new Int32Array(x.computeStrides(n.shape)).buffer), A = new Uint8Array(new Int32Array(b).buffer), D = new Uint8Array(new Int32Array(C).buffer), O = new Uint8Array(new Int32Array(w).buffer), M = new Uint8Array(new Int32Array(f).buffer), L = new Uint8Array(new Int32Array(x.computeStrides(f)).buffer), W = e.dataIdMap.get(_.dataId).id;
- g3(E, R, n.shape.length, A, D, O, M, L, f.length, W), k = Mt({ inputs: { x: _ }, backend: e, attrs: { shape: d } }), e.disposeData(_.dataId);
+ let _ = e.makeOutput(d, "float32"), $ = e.dataIdMap.get(n.dataId).id, A = new Uint8Array(new Int32Array(y.computeStrides(n.shape)).buffer), R = new Uint8Array(new Int32Array(b).buffer), D = new Uint8Array(new Int32Array(C).buffer), P = new Uint8Array(new Int32Array(w).buffer), M = new Uint8Array(new Int32Array(d).buffer), L = new Uint8Array(new Int32Array(y.computeStrides(d)).buffer), W = e.dataIdMap.get(_.dataId).id;
+ KP($, A, n.shape.length, R, D, P, M, L, d.length, W), k = Mt({ inputs: { x: _ }, backend: e, attrs: { shape: f } }), e.disposeData(_.dataId);
}
return k;
}
-var x3 = { kernelName: Yn, backendName: "wasm", setupFunc: Dee, kernelFunc: Pee };
-function Oee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { data: n, dataSplits: s } = t10, { separator: a, nGramWidths: i, leftPad: p, rightPad: u, padWidth: c, preserveShortSequences: l } = o, m = e.readSync(n.dataId), f = e.readSync(s.dataId), [d, h] = ku(m, f, a, i, p, u, c, l), g = e.makeOutput([d.length], "string"), y = e.dataIdMap.get(g.dataId);
- y.stringBytes = d;
+var jP = { kernelName: jn, backendName: "wasm", setupFunc: ree, kernelFunc: oee };
+function nee(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { data: n, dataSplits: s } = t6, { separator: a, nGramWidths: i, leftPad: p, rightPad: u, padWidth: c, preserveShortSequences: l } = o, m = e.readSync(n.dataId), d = e.readSync(s.dataId), [f, h] = ku(m, d, a, i, p, u, c, l), g = e.makeOutput([f.length], "string"), x = e.dataIdMap.get(g.dataId);
+ x.stringBytes = f;
let b = e.makeOutput(s.shape, "int32");
return e.typedArrayFromHeap(b).set(h), [g, b];
}
-var y3 = { kernelName: Ns, backendName: "wasm", kernelFunc: Oee };
-function Mee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { input: n, delimiter: s } = t10, { skipEmpty: a } = o, i = e.readSync(n.dataId), p = e.readSync(s.dataId), [u, c, l] = Tu(i, p[0], a), m = c.length, f = e.makeOutput([m, 2], "int32");
- e.typedArrayFromHeap(f).set(u);
+var XP = { kernelName: As, backendName: "wasm", kernelFunc: nee };
+function see(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { input: n, delimiter: s } = t6, { skipEmpty: a } = o, i = e.readSync(n.dataId), p = e.readSync(s.dataId), [u, c, l] = Nu(i, p[0], a), m = c.length, d = e.makeOutput([m, 2], "int32");
+ e.typedArrayFromHeap(d).set(u);
let h = e.makeOutput([m], "string"), g = e.dataIdMap.get(h.dataId);
g.stringBytes = c;
- let y = e.makeOutput([2], "int32");
- return e.typedArrayFromHeap(y).set(l), [f, h, y];
+ let x = e.makeOutput([2], "int32");
+ return e.typedArrayFromHeap(x).set(l), [d, h, x];
}
-var b3 = { kernelName: ri, backendName: "wasm", kernelFunc: Mee };
-function Lee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { input: n } = t10, { numBuckets: s } = o, a = e.readSync(n.dataId), i = Nu(a, s), p = e.makeOutput(n.shape, "int32");
+var YP = { kernelName: di, backendName: "wasm", kernelFunc: see };
+function aee(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { input: n } = t6, { numBuckets: s } = o, a = e.readSync(n.dataId), i = Tu(a, s), p = e.makeOutput(n.shape, "int32");
return e.typedArrayFromHeap(p).set(i), p;
}
-var C3 = { kernelName: oi, backendName: "wasm", kernelFunc: Lee };
-var Bee = true;
-var I3 = nt(Io, Bee);
-var w3;
-function Vee(r) {
- w3 = r.wasm.cwrap(jn, null, ["number", "number", "number", "number"]);
+var QP = { kernelName: fi, backendName: "wasm", kernelFunc: aee };
+var iee = true;
+var ZP = rt(Xn, iee);
+var JP;
+function uee(r) {
+ JP = r.wasm.cwrap(Hn, null, ["number", "number", "number", "number"]);
}
-function zee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t10, i = e.dataIdMap.get(a.dataId).id, p = i, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: f } = kr(a, n, e), d = l;
- if (f) {
+function pee(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { axis: n, keepDims: s } = o, { x: a } = t6, i = e.dataIdMap.get(a.dataId).id, p = i, u = a, { transposed: c, axes: l, originalAxes: m, inputWasTransposed: d } = kr(a, n, e), f = l;
+ if (d) {
let C = e.dataIdMap.get(c.dataId).id;
- C !== i && (u = c, p = C, d = I.getInnerMostAxes(d.length, u.shape.length));
+ C !== i && (u = c, p = C, f = S.getInnerMostAxes(f.length, u.shape.length));
}
- I.assertAxesAreInnerMostDims("sum", d, u.shape.length);
- let [h, g] = I.computeOutAndReduceShapes(u.shape, d), y = x.sizeFromShape(g), b = e.makeOutput(h, u.dtype);
- if (x.sizeFromShape(u.shape) !== 0) {
+ S.assertAxesAreInnerMostDims("sum", f, u.shape.length);
+ let [h, g] = S.computeOutAndReduceShapes(u.shape, f), x = y.sizeFromShape(g), b = e.makeOutput(h, u.dtype);
+ if (y.sizeFromShape(u.shape) !== 0) {
let C = e.dataIdMap.get(b.dataId).id;
- w3(p, y, Ae[b.dtype], C);
+ JP(p, x, Fe[b.dtype], C);
}
- if (f && e.disposeData(c.dataId), s) {
- let C = I.expandShapeToKeepDim(b.shape, m);
+ if (d && e.disposeData(c.dataId), s) {
+ let C = S.expandShapeToKeepDim(b.shape, m);
b.shape = C;
}
return b;
}
-var S3 = { kernelName: jn, backendName: "wasm", setupFunc: Vee, kernelFunc: zee };
-var v3 = Qe(xa);
-var k3 = Qe(Qn);
-var T3;
-function Wee(r) {
- T3 = r.wasm.cwrap(wo, null, ["number", "array", "number", "array", "number", "number"]);
+var e3 = { kernelName: Hn, backendName: "wasm", setupFunc: uee, kernelFunc: pee };
+var t3 = Ve(Yn);
+var r3 = Ve(Qn);
+var o3;
+function cee(r) {
+ o3 = r.wasm.cwrap(to, null, ["number", "array", "number", "array", "number", "number"]);
}
-function Uee(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, s = t10.dataIdMap.get(n.dataId).id, { reps: a } = o, i = new Array(n.shape.length);
+function lee(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, s = t6.dataIdMap.get(n.dataId).id, { reps: a } = o, i = new Array(n.shape.length);
for (let m = 0; m < i.length; m++)
i[m] = n.shape[m] * a[m];
- let p = new Uint8Array(new Int32Array(n.shape).buffer), u = new Uint8Array(new Int32Array(i).buffer), c = t10.makeOutput(i, n.dtype), l = t10.dataIdMap.get(c.dataId).id;
- return T3(s, p, n.shape.length, u, i.length, Ae[c.dtype], l), c;
+ let p = new Uint8Array(new Int32Array(n.shape).buffer), u = new Uint8Array(new Int32Array(i).buffer), c = t6.makeOutput(i, n.dtype), l = t6.dataIdMap.get(c.dataId).id;
+ return o3(s, p, n.shape.length, u, i.length, Fe[c.dtype], l), c;
}
-var N3 = { kernelName: wo, backendName: "wasm", setupFunc: Wee, kernelFunc: Uee };
-var _3;
-function Gee(r) {
- _3 = r.wasm.cwrap(Zn, null, ["number", "array", "number", "number", "number", "bool", "number", "number"]);
+var n3 = { kernelName: to, backendName: "wasm", setupFunc: cee, kernelFunc: lee };
+var s3;
+function mee(r) {
+ s3 = r.wasm.cwrap(Zn, null, ["number", "array", "number", "number", "number", "bool", "number", "number"]);
}
-var Hee = ({ inputs: r, backend: e, attrs: t10 }) => {
- let { x: o } = r, { k: n, sorted: s } = t10, a = e.dataIdMap.get(o.dataId).id, i = new Uint8Array(new Int32Array(o.shape).buffer), p = o.shape.slice();
+var dee = ({ inputs: r, backend: e, attrs: t6 }) => {
+ let { x: o } = r, { k: n, sorted: s } = t6, a = e.dataIdMap.get(o.dataId).id, i = new Uint8Array(new Int32Array(o.shape).buffer), p = o.shape.slice();
p[p.length - 1] = n;
let u = e.makeOutput(p, o.dtype), c = e.dataIdMap.get(u.dataId).id, l = e.makeOutput(p, "int32"), m = e.dataIdMap.get(l.dataId).id;
- return _3(a, i, o.shape.length, Ae[o.dtype], n, s, c, m), [u, l];
+ return s3(a, i, o.shape.length, Fe[o.dtype], n, s, c, m), [u, l];
};
-var E3 = { kernelName: Zn, backendName: "wasm", setupFunc: Gee, kernelFunc: Hee };
-var $3;
-function qee(r) {
- $3 = r.wasm.cwrap(Jn, null, ["number", "number", "bool", "number", "number", "number", "number", "number", "number", "array", "number", "array", "number", "number", "number", "number", "number"]);
+var a3 = { kernelName: Zn, backendName: "wasm", setupFunc: mee, kernelFunc: dee };
+var i3;
+function fee(r) {
+ i3 = r.wasm.cwrap(Jn, null, ["number", "number", "bool", "number", "number", "number", "number", "number", "number", "array", "number", "array", "number", "number", "number", "number", "number"]);
}
-function Kee(r) {
- let { backend: e, inputs: t10, attrs: o } = r, { image: n, transforms: s } = t10, { interpolation: a, fillMode: i, fillValue: p, outputShape: u } = o, [c, l, m, f] = n.shape, [d, h] = u != null ? u : [l, m], g = [c, d, h, f], y = new Uint8Array(new Int32Array(x.computeStrides(n.shape)).buffer), b = new Uint8Array(new Int32Array(x.computeStrides(g)).buffer), C = e.makeOutput(g, n.dtype), w = e.dataIdMap.get(C.dataId).id, _ = e.dataIdMap.get(n.dataId).id, R = e.dataIdMap.get(s.dataId).id, A = a === "nearest" ? 1 : 2, D;
+function hee(r) {
+ let { backend: e, inputs: t6, attrs: o } = r, { image: n, transforms: s } = t6, { interpolation: a, fillMode: i, fillValue: p, outputShape: u } = o, [c, l, m, d] = n.shape, [f, h] = u != null ? u : [l, m], g = [c, f, h, d], x = new Uint8Array(new Int32Array(y.computeStrides(n.shape)).buffer), b = new Uint8Array(new Int32Array(y.computeStrides(g)).buffer), C = e.makeOutput(g, n.dtype), w = e.dataIdMap.get(C.dataId).id, _ = e.dataIdMap.get(n.dataId).id, A = e.dataIdMap.get(s.dataId).id, R = a === "nearest" ? 1 : 2, D;
switch (i) {
case "constant":
D = 1;
@@ -25277,40 +25345,40 @@ function Kee(r) {
D = 1;
break;
}
- return $3(_, R, s.shape[0] > 1, c, d, h, f, m, l, y, n.shape.length - 1, b, g.length - 1, A, D, p, w), C;
+ return i3(_, A, s.shape[0] > 1, c, f, h, d, m, l, x, n.shape.length - 1, b, g.length - 1, R, D, p, w), C;
}
-var R3 = { kernelName: Jn, backendName: "wasm", setupFunc: qee, kernelFunc: Kee };
-function jee(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { value: n } = e, { axis: s } = o;
+var u3 = { kernelName: Jn, backendName: "wasm", setupFunc: fee, kernelFunc: hee };
+function gee(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { value: n } = e, { axis: s } = o;
s < 0 && (s += n.shape.length);
let a = n.shape[s], i = n.shape.length, p = new Array(i - 1), u = 0;
- for (let f = 0; f < i; f++)
- f !== s && (p[u++] = n.shape[f]);
+ for (let d = 0; d < i; d++)
+ d !== s && (p[u++] = n.shape[d]);
let c = new Array(a), l = new Array(i).fill(0), m = n.shape.slice();
m[s] = 1;
- for (let f = 0; f < c.length; f++)
- l[s] = f, c[f] = Xo({ inputs: { x: n }, attrs: { begin: l, size: m }, backend: t10 });
- return c.map(({ dataId: f, dtype: d }) => ({ dataId: f, dtype: d, shape: p }));
+ for (let d = 0; d < c.length; d++)
+ l[s] = d, c[d] = Eo({ inputs: { x: n }, attrs: { begin: l, size: m }, backend: t6 });
+ return c.map(({ dataId: d, dtype: f }) => ({ dataId: d, dtype: f, shape: p }));
}
-var A3 = { kernelName: _s, backendName: "wasm", kernelFunc: jee };
-function Xee(r) {
- let { inputs: { x: e }, backend: t10 } = r, o = t10.makeOutput(e.shape, e.dtype);
- return t10.typedArrayFromHeap(o).fill(0), o;
+var p3 = { kernelName: Rs, backendName: "wasm", kernelFunc: gee };
+function xee(r) {
+ let { inputs: { x: e }, backend: t6 } = r, o = t6.makeOutput(e.shape, e.dtype);
+ return t6.typedArrayFromHeap(o).fill(0), o;
}
-var F3 = { kernelName: Es, backendName: "wasm", kernelFunc: Xee };
-var Yee = [LD, BD, VD, WD, KD, XD, QD, JD, rP, nP, sP, aP, uP, pP, lP, fP, dP, hP, xP, bP, IP, SP, kP, TP, NP, _P, EP, $P, AP, FP, DP, OP, LP, VP, WP, GP, HP, qP, UD, jP, XP, YP, QP, ZP, JP, eO, tO, oO, nO, aO, uO, cO, lO, fO, dO, hO, xO, bO, IO, wO, vO, kO, TO, $g, _O, $O, AO, FO, DO, PO, OO, eP, LO, VO, WO, GO, HO, qO, jO, YO, ZO, JO, oP, t3, r3, n3, a3, u3, p3, c3, l3, m3, f3, h3, x3, y3, b3, C3, I3, S3, v3, k3, N3, E3, R3, HD, A3, F3];
-for (let r of Yee)
- ya(r);
-var Yw = P();
-Yw.registerFlag("WASM_HAS_SIMD_SUPPORT", async () => {
+var c3 = { kernelName: Fs, backendName: "wasm", kernelFunc: xee };
+var yee = [dD, fD, hD, xD, wD, vD, ND, _D, AD, FD, DD, OD, MD, LD, VD, WD, UD, GD, qD, jD, YD, ZD, eO, tO, rO, oO, nO, sO, iO, uO, pO, lO, dO, hO, xO, bO, CO, SO, yD, wO, vO, kO, NO, TO, _O, EO, $O, AO, FO, DO, PO, LO, VO, zO, UO, GO, HO, KO, XO, QO, ZO, eP, tP, rP, bg, nP, aP, uP, pP, cP, lP, mP, dP, ED, hP, xP, bP, SP, wP, IP, kP, TP, EP, $P, RD, RP, FP, OP, MP, BP, VP, zP, WP, UP, GP, qP, jP, XP, YP, QP, ZP, e3, t3, r3, n3, a3, u3, CD, p3, c3];
+for (let r of yee)
+ Ia(r);
+var Hw = O();
+Hw.registerFlag("WASM_HAS_SIMD_SUPPORT", async () => {
try {
return WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]));
} catch (r) {
return false;
}
});
-Yw.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT", async () => {
- if (Yw.get("IS_NODE"))
+Hw.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT", async () => {
+ if (Hw.get("IS_NODE"))
return false;
try {
return new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)), WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 4, 1, 3, 1, 1, 10, 11, 1, 9, 0, 65, 0, 254, 16, 2, 0, 26, 11]));
@@ -25318,51 +25386,51 @@ Yw.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT", async () => {
return false;
}
});
-var oS = rp(M3());
-var U3 = rp(B3());
-var nS = rp(V3());
-var z3 = oS.default || oS;
-var Qee = nS.default || nS;
-var Gl = class extends Jr {
+var Zw = rp(f3());
+var C3 = rp(g3());
+var Jw = rp(x3());
+var y3 = Zw.default || Zw;
+var bee = Jw.default || Jw;
+var Pl = class extends Zr {
constructor(e) {
- super(), this.wasm = e, this.dataIdNextNumber = 1, this.wasm.tfjs.initWithThreadsCount(H3), rS = this.wasm.tfjs.getThreadsCount(), this.dataIdMap = new rn(this, cr());
+ super(), this.wasm = e, this.dataIdNextNumber = 1, this.wasm.tfjs.initWithThreadsCount(w3), Qw = this.wasm.tfjs.getThreadsCount(), this.dataIdMap = new Do(this, cr());
}
- write(e, t10, o) {
+ write(e, t6, o) {
let n = { id: this.dataIdNextNumber++ };
- return this.move(n, e, t10, o, 1), n;
+ return this.move(n, e, t6, o, 1), n;
}
numDataIds() {
return this.dataIdMap.numDataIds();
}
async time(e) {
- let t10 = x.now();
- return e(), { kernelMs: x.now() - t10 };
+ let t6 = y.now();
+ return e(), { kernelMs: y.now() - t6 };
}
- move(e, t10, o, n, s) {
+ move(e, t6, o, n, s) {
let a = this.dataIdNextNumber++;
if (n === "string") {
- let c = t10;
+ let c = t6;
this.dataIdMap.set(e, { id: a, stringBytes: c, shape: o, dtype: n, memoryOffset: null, refCount: s });
return;
}
- let i = x.sizeFromShape(o), p = i * x.bytesPerElement(n), u = this.wasm._malloc(p);
- this.dataIdMap.set(e, { id: a, memoryOffset: u, shape: o, dtype: n, refCount: s }), this.wasm.tfjs.registerTensor(a, i, u), t10 != null && this.wasm.HEAPU8.set(new Uint8Array(t10.buffer, t10.byteOffset, p), u);
+ let i = y.sizeFromShape(o), p = i * y.bytesPerElement(n), u = this.wasm._malloc(p);
+ this.dataIdMap.set(e, { id: a, memoryOffset: u, shape: o, dtype: n, refCount: s }), this.wasm.tfjs.registerTensor(a, i, u), t6 != null && this.wasm.HEAPU8.set(new Uint8Array(t6.buffer, t6.byteOffset, p), u);
}
async read(e) {
return this.readSync(e);
}
- readSync(e, t10, o) {
+ readSync(e, t6, o) {
let { memoryOffset: n, dtype: s, shape: a, stringBytes: i } = this.dataIdMap.get(e);
if (s === "string")
- return (t10 == null || t10 === 0) && (o == null || o >= i.length) ? i : i.slice(t10, o);
- t10 = t10 || 0, o = o || x.sizeFromShape(a);
- let p = x.bytesPerElement(s), u = this.wasm.HEAPU8.slice(n + t10 * p, n + o * p);
- return Jee(u.buffer, s);
+ return (t6 == null || t6 === 0) && (o == null || o >= i.length) ? i : i.slice(t6, o);
+ t6 = t6 || 0, o = o || y.sizeFromShape(a);
+ let p = y.bytesPerElement(s), u = this.wasm.HEAPU8.slice(n + t6 * p, n + o * p);
+ return See(u.buffer, s);
}
- disposeData(e, t10 = false) {
+ disposeData(e, t6 = false) {
if (this.dataIdMap.has(e)) {
let o = this.dataIdMap.get(e);
- if (o.refCount--, !t10 && o.refCount > 0)
+ if (o.refCount--, !t6 && o.refCount > 0)
return false;
this.wasm._free(o.memoryOffset), this.wasm.tfjs.disposeData(o.id), this.dataIdMap.delete(e);
}
@@ -25372,8 +25440,8 @@ var Gl = class extends Jr {
return this.dataIdMap.has(e) ? this.dataIdMap.get(e).refCount : 0;
}
incRef(e) {
- let t10 = this.dataIdMap.get(e);
- t10 != null && t10.refCount++;
+ let t6 = this.dataIdMap.get(e);
+ t6 != null && t6.refCount++;
}
floatPrecision() {
return 32;
@@ -25387,21 +25455,21 @@ var Gl = class extends Jr {
memory() {
return { unreliable: false };
}
- makeOutput(e, t10, o) {
+ makeOutput(e, t6, o) {
let n;
if (o == null)
- n = this.write(null, e, t10);
+ n = this.write(null, e, t6);
else {
let s = this.dataIdNextNumber++;
- n = { id: s }, this.dataIdMap.set(n, { id: s, memoryOffset: o, shape: e, dtype: t10, refCount: 1 });
- let a = x.sizeFromShape(e);
+ n = { id: s }, this.dataIdMap.set(n, { id: s, memoryOffset: o, shape: e, dtype: t6, refCount: 1 });
+ let a = y.sizeFromShape(e);
this.wasm.tfjs.registerTensor(s, a, o);
}
- return { dataId: n, shape: e, dtype: t10 };
+ return { dataId: n, shape: e, dtype: t6 };
}
- typedArrayFromHeap({ shape: e, dtype: t10, dataId: o }) {
- let n = this.wasm.HEAPU8.buffer, { memoryOffset: s } = this.dataIdMap.get(o), a = x.sizeFromShape(e);
- switch (t10) {
+ typedArrayFromHeap({ shape: e, dtype: t6, dataId: o }) {
+ let n = this.wasm.HEAPU8.buffer, { memoryOffset: s } = this.dataIdMap.get(o), a = y.sizeFromShape(e);
+ switch (t6) {
case "float32":
return new Float32Array(n, s, a);
case "int32":
@@ -25409,51 +25477,51 @@ var Gl = class extends Jr {
case "bool":
return new Uint8Array(n, s, a);
default:
- throw new Error(`Unknown dtype ${t10}`);
+ throw new Error(`Unknown dtype ${t6}`);
}
}
};
-function Zee(r) {
- return (e, t10) => (x.fetch(r, { credentials: "same-origin" }).then((o) => {
+function Cee(r) {
+ return (e, t6) => (y.fetch(r, { credentials: "same-origin" }).then((o) => {
o.ok || e.env.a(`failed to load wasm binary file at '${r}'`), o.arrayBuffer().then((n) => {
WebAssembly.instantiate(n, e).then((s) => {
- t10(s.instance, s.module);
+ t6(s.instance, s.module);
});
});
}), {});
}
-function W3(r, e, t10) {
- if (Pg != null)
- return Pg;
+function b3(r, e, t6) {
+ if (vg != null)
+ return vg;
let o = "tfjs-backend-wasm.wasm";
- return r && e ? o = "tfjs-backend-wasm-threaded-simd.wasm" : r && (o = "tfjs-backend-wasm-simd.wasm"), Wl != null && Wl[o] != null ? Wl[o] : t10 + o;
+ return r && e ? o = "tfjs-backend-wasm-threaded-simd.wasm" : r && (o = "tfjs-backend-wasm-simd.wasm"), Dl != null && Dl[o] != null ? Dl[o] : t6 + o;
}
-async function G3() {
- let [r, e] = await Promise.all([P().getAsync("WASM_HAS_SIMD_SUPPORT"), P().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);
- return new Promise((t10, o) => {
+async function S3() {
+ let [r, e] = await Promise.all([O().getAsync("WASM_HAS_SIMD_SUPPORT"), O().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);
+ return new Promise((t6, o) => {
let n = {};
n.locateFile = (i, p) => {
if (i.endsWith(".worker.js")) {
- let u = U3.wasmWorkerContents.replace(/\n/g, "\\n"), c = new Blob([u], { type: "application/javascript" });
+ let u = C3.wasmWorkerContents.replace(/\n/g, "\\n"), c = new Blob([u], { type: "application/javascript" });
return URL.createObjectURL(c);
}
- return i.endsWith(".wasm") ? W3(r, e, zl != null ? zl : p) : p + i;
- }, sS && (n.instantiateWasm = Zee(W3(r, e, zl != null ? zl : "")));
+ return i.endsWith(".wasm") ? b3(r, e, Fl != null ? Fl : p) : p + i;
+ }, eI && (n.instantiateWasm = Cee(b3(r, e, Fl != null ? Fl : "")));
let s = false;
n.onAbort = () => {
- if (s || Ul)
+ if (s || Ol)
return;
- Ul = true, o({ message: "Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers" });
+ Ol = true, o({ message: "Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers" });
};
let a;
- e && r && Pg == null ? (n.mainScriptUrlOrBlob = new Blob(["var WasmBackendModuleThreadedSimd = " + z3.toString()], { type: "text/javascript" }), a = z3(n)) : a = Qee(n), a.then((i) => {
- s = true, Ul = false;
+ e && r && vg == null ? (n.mainScriptUrlOrBlob = new Blob(["var WasmBackendModuleThreadedSimd = " + y3.toString()], { type: "text/javascript" }), a = y3(n)) : a = bee(n), a.then((i) => {
+ s = true, Ol = false;
let p = null;
- i.tfjs = { init: i.cwrap("init", null, []), initWithThreadsCount: i.cwrap("init_with_threads_count", null, ["number"]), getThreadsCount: i.cwrap("get_threads_count", "number", []), registerTensor: i.cwrap("register_tensor", null, ["number", "number", "number"]), disposeData: i.cwrap("dispose_data", p, ["number"]), dispose: i.cwrap("dispose", p, []) }, t10({ wasm: i });
+ i.tfjs = { init: i.cwrap("init", null, []), initWithThreadsCount: i.cwrap("init_with_threads_count", null, ["number"]), getThreadsCount: i.cwrap("get_threads_count", "number", []), registerTensor: i.cwrap("register_tensor", null, ["number", "number", "number"]), disposeData: i.cwrap("dispose_data", p, ["number"]), dispose: i.cwrap("dispose", p, []) }, t6({ wasm: i });
}).catch(o);
});
}
-function Jee(r, e) {
+function See(r, e) {
switch (e) {
case "float32":
return new Float32Array(r);
@@ -25465,95 +25533,106 @@ function Jee(r, e) {
throw new Error(`Unknown dtype ${e}`);
}
}
-var ete = ["tfjs-backend-wasm.wasm", "tfjs-backend-wasm-simd.wasm", "tfjs-backend-wasm-threaded-simd.wasm"];
-var Pg = null;
-var zl = null;
-var Wl = {};
-var Ul = false;
-var sS = false;
-function tte(r, e = false) {
- if (sC("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."), Ul)
+var wee = ["tfjs-backend-wasm.wasm", "tfjs-backend-wasm-simd.wasm", "tfjs-backend-wasm-threaded-simd.wasm"];
+var vg = null;
+var Fl = null;
+var Dl = {};
+var Ol = false;
+var eI = false;
+function Iee(r, e = false) {
+ if (eC("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."), Ol)
throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPath()` before you call `tf.setBackend()` or `tf.ready()`");
- Pg = r, sS = e;
+ vg = r, eI = e;
}
-function rte(r, e = false) {
- if (Ul)
+function vee(r, e = false) {
+ if (Ol)
throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPaths()` before you call `tf.setBackend()` or `tf.ready()`");
if (typeof r == "string")
- zl = r;
+ Fl = r;
else {
- Wl = r;
- let t10 = ete.filter((o) => Wl[o] == null);
- if (t10.length > 0)
- throw new Error(`There were no entries found for the following binaries: ${t10.join(",")}. Please either call setWasmPaths with a map providing a path for each binary, or with a string indicating the directory where all the binaries can be found.`);
+ Dl = r;
+ let t6 = wee.filter((o) => Dl[o] == null);
+ if (t6.length > 0)
+ throw new Error(`There were no entries found for the following binaries: ${t6.join(",")}. Please either call setWasmPaths with a map providing a path for each binary, or with a string indicating the directory where all the binaries can be found.`);
}
- sS = e;
+ eI = e;
}
-var H3 = -1;
-var rS = -1;
-function ote(r) {
- H3 = r;
+var w3 = -1;
+var Qw = -1;
+function kee(r) {
+ w3 = r;
}
-function nte() {
- if (rS === -1)
+function Nee() {
+ if (Qw === -1)
throw new Error("WASM backend not initialized.");
- return rS;
+ return Qw;
}
-var ste = "4.0.0";
-var ate = 2;
-pi("wasm", async () => {
- let { wasm: r } = await G3();
- return new Gl(r);
-}, ate);
-var Va = P();
-Va.registerFlag("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE", () => 15);
-Va.registerFlag("WEBGPU_CPU_FORWARD", () => true);
-Va.registerFlag("WEBGPU_MATMUL_PROGRAM_TYPE", () => -1);
-Va.registerFlag("WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE", () => false);
-Va.registerFlag("WEBGPU_USE_LOW_POWER_GPU", () => false);
-Va.registerFlag("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD", () => 1e3);
-Va.registerFlag("WEBGPU_USE_PROFILE_TOOL", () => false);
-Va.registerFlag("WEBGPU_IMPORT_EXTERNAL_TEXTURE", () => true);
-Va.registerFlag("WEBGPU_USE_NAIVE_CONV2D_DEBUG", () => false);
-var Og = class {
+var Tee = "4.1.0";
+var _ee = 2;
+Ci("wasm", async () => {
+ let { wasm: r } = await S3();
+ return new Pl(r);
+}, _ee);
+var ms = O();
+ms.registerFlag("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE", () => 15);
+ms.registerFlag("WEBGPU_CPU_FORWARD", () => true);
+ms.registerFlag("WEBGPU_MATMUL_PROGRAM_TYPE", () => -1);
+ms.registerFlag("WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE", () => false);
+ms.registerFlag("WEBGPU_USE_LOW_POWER_GPU", () => false);
+ms.registerFlag("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD", () => 1e3);
+ms.registerFlag("WEBGPU_USE_PROFILE_TOOL", () => false);
+ms.registerFlag("WEBGPU_IMPORT_EXTERNAL_TEXTURE", () => true);
+ms.registerFlag("WEBGPU_USE_NAIVE_CONV2D_DEBUG", () => false);
+ms.registerFlag("WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL", () => 0);
+ms.registerFlag("WEBGPU_CONV_SEPARATE_IM2COL_SHADER", () => false);
+var kg = class {
constructor(e) {
- e && (this.vendor = e.vendor);
+ e && (this.vendor = e.vendor, this.architecture = e.architecture, this.intelGPUGeneration = this.getIntelGPUGeneration());
+ }
+ getIntelGPUGeneration() {
+ if (this.isIntel()) {
+ if (this.architecture.startsWith("gen"))
+ return Number(this.architecture.match(/\d+/));
+ if (this.architecture.startsWith("xe"))
+ return 12;
+ }
+ return 0;
}
isIntel() {
return this.vendor === "intel";
}
};
-var Mg = class {
+var Ng = class {
constructor(e) {
this.device = e, this.numUsedBuffers = 0, this.numFreeBuffers = 0, this.freeBuffers = /* @__PURE__ */ new Map(), this.usedBuffers = /* @__PURE__ */ new Map(), this.numBytesUsed = 0, this.numBytesAllocated = 0;
}
- acquireUploadBuffer(e, t10) {
- return this.acquireBuffer(e, t10, true);
+ acquireUploadBuffer(e, t6) {
+ return this.acquireBuffer(e, t6, true);
}
- acquireBuffer(e, t10, o = false) {
- let n = q3(e, t10);
+ acquireBuffer(e, t6, o = false) {
+ let n = I3(e, t6);
if (this.freeBuffers.has(n) || this.freeBuffers.set(n, []), this.usedBuffers.has(n) || this.usedBuffers.set(n, []), this.numBytesUsed += e, this.numUsedBuffers++, this.freeBuffers.get(n).length > 0) {
this.numFreeBuffers--;
let a = this.freeBuffers.get(n).shift();
return this.usedBuffers.get(n).push(a), a;
}
this.numBytesAllocated += e;
- let s = this.device.createBuffer({ size: e, usage: t10, mappedAtCreation: o });
+ let s = this.device.createBuffer({ size: e, usage: t6, mappedAtCreation: o });
return this.usedBuffers.get(n).push(s), s;
}
- releaseBuffer(e, t10, o) {
+ releaseBuffer(e, t6, o) {
if (this.freeBuffers.size === 0)
return;
- let n = q3(t10, o);
+ let n = I3(t6, o);
this.freeBuffers.has(n) || this.freeBuffers.set(n, []), this.freeBuffers.get(n).push(e), this.numFreeBuffers++, this.numUsedBuffers--;
let s = this.usedBuffers.get(n), a = s.indexOf(e);
if (a < 0)
throw new Error("Cannot release a buffer that was never provided by this buffer manager");
- s.splice(a, 1), this.numBytesUsed -= t10;
+ s.splice(a, 1), this.numBytesUsed -= t6;
}
- releaseUploadBuffer(e, t10, o) {
+ releaseUploadBuffer(e, t6, o) {
e.mapAsync(GPUMapMode.WRITE).then(() => {
- this.releaseBuffer(e, t10, o);
+ this.releaseBuffer(e, t6, o);
}, (n) => {
});
}
@@ -25564,45 +25643,45 @@ var Mg = class {
return this.numFreeBuffers;
}
dispose() {
- this.freeBuffers.forEach((e, t10) => {
+ this.freeBuffers.forEach((e, t6) => {
e.forEach((o) => {
o.destroy();
});
- }), this.usedBuffers.forEach((e, t10) => {
+ }), this.usedBuffers.forEach((e, t6) => {
e.forEach((o) => {
o.destroy();
});
}), this.freeBuffers = /* @__PURE__ */ new Map(), this.usedBuffers = /* @__PURE__ */ new Map(), this.numUsedBuffers = 0, this.numFreeBuffers = 0, this.numBytesUsed = 0, this.numBytesAllocated = 0;
}
};
-function q3(r, e) {
+function I3(r, e) {
return `${r}_${e}`;
}
-var Lg = class {
+var Tg = class {
constructor(e) {
this.device = e, this.numUsedTextures = 0, this.numFreeTextures = 0, this.freeTextures = /* @__PURE__ */ new Map(), this.usedTextures = /* @__PURE__ */ new Map(), this.numBytesUsed = 0, this.numBytesAllocated = 0;
}
- acquireTexture(e, t10, o, n) {
- let s = j3(o), a = e * t10 * s, i = K3(e, t10, o, n);
+ acquireTexture(e, t6, o, n) {
+ let s = k3(o), a = e * t6 * s, i = v3(e, t6, o, n);
if (this.freeTextures.has(i) || this.freeTextures.set(i, []), this.usedTextures.has(i) || this.usedTextures.set(i, []), this.numBytesUsed += a, this.numUsedTextures++, this.freeTextures.get(i).length > 0) {
this.numFreeTextures--;
let u = this.freeTextures.get(i).shift();
return this.usedTextures.get(i).push(u), u;
}
this.numBytesAllocated += a;
- let p = this.device.createTexture({ size: [e, t10], format: o, usage: n });
+ let p = this.device.createTexture({ size: [e, t6], format: o, usage: n });
return this.usedTextures.get(i).push(p), p;
}
- releaseTexture(e, t10, o, n, s) {
+ releaseTexture(e, t6, o, n, s) {
if (this.freeTextures.size === 0)
return;
- let a = K3(t10, o, n, s);
+ let a = v3(t6, o, n, s);
this.freeTextures.has(a) || this.freeTextures.set(a, []), this.freeTextures.get(a).push(e), this.numFreeTextures++, this.numUsedTextures--;
let i = this.usedTextures.get(a), p = i.indexOf(e);
if (p < 0)
throw new Error("Cannot release a texture that was never provided by this texture manager");
i.splice(p, 1);
- let u = j3(n), c = t10 * o * u;
+ let u = k3(n), c = t6 * o * u;
this.numBytesUsed -= c;
}
getNumUsedTextures() {
@@ -25612,39 +25691,39 @@ var Lg = class {
return this.numFreeTextures;
}
dispose() {
- this.freeTextures.forEach((e, t10) => {
+ this.freeTextures.forEach((e, t6) => {
e.forEach((o) => {
o.destroy();
});
- }), this.usedTextures.forEach((e, t10) => {
+ }), this.usedTextures.forEach((e, t6) => {
e.forEach((o) => {
o.destroy();
});
}), this.freeTextures = /* @__PURE__ */ new Map(), this.usedTextures = /* @__PURE__ */ new Map(), this.numUsedTextures = 0, this.numFreeTextures = 0, this.numBytesUsed = 0, this.numBytesAllocated = 0;
}
};
-function K3(r, e, t10, o) {
- return `${r}_${e}_${t10}_${o}`;
+function v3(r, e, t6, o) {
+ return `${r}_${e}_${t6}_${o}`;
}
-function j3(r) {
+function k3(r) {
if (r === "rgba8unorm")
return 16;
throw new Error(`${r} is not supported!`);
}
-function X3(r, e) {
+function N3(r, e) {
if (Math.max(...r) > 3)
throw new Error("Cannot symbolically compute strides for rank > 4 tensor.");
- let t10 = r.length, o = r.map((s) => `${e}[${s}]`), n = new Array(t10 - 1);
- n[t10 - 2] = o[t10 - 1];
- for (let s = t10 - 3; s >= 0; --s)
+ let t6 = r.length, o = r.map((s) => `${e}[${s}]`), n = new Array(t6 - 1);
+ n[t6 - 2] = o[t6 - 1];
+ for (let s = t6 - 3; s >= 0; --s)
n[s] = `(${n[s + 1]} * ${o[s + 1]})`;
return n;
}
-var Z3 = (r, e, t10, o) => {
- let n = { dtype: o.dtype, shape: o.shape }, s = ite(t10, n, e), a = r.createShaderModule({ code: s, label: e.constructor.name });
+var A3 = (r, e, t6, o) => {
+ let n = { dtype: o.dtype, shape: o.shape }, s = $ee(t6, n, e), a = r.createShaderModule({ code: s, label: e.constructor.name });
return r.createComputePipeline({ compute: { module: a, entryPoint: "_start" }, label: e.constructor.name, layout: "auto" });
};
-function At(r) {
+function Rt(r) {
if (r <= 1)
return "i32";
if (r === 2)
@@ -25659,7 +25738,7 @@ function At(r) {
return "vec6";
throw Error(`GPU for rank ${r} is not yet supported`);
}
-function Yo(r) {
+function $o(r) {
if (r === 0)
return "x";
if (r === 1)
@@ -25674,36 +25753,16 @@ function Yo(r) {
return "v";
throw Error(`Index ${r} is not yet supported`);
}
-function ue(...r) {
+function se(...r) {
let e;
switch (r.length) {
case 0:
e = `
- ${Ri()}
- fn _start(@builtin(local_invocation_id) LocalId : vec3,
- @builtin(global_invocation_id) GlobalId : vec3,
- @builtin(num_workgroups) NumWorkgroups : vec3) {
- localId = LocalId;
- globalId = GlobalId;
- numWorkgroups = NumWorkgroups;
- main();
- }
-
fn main()
`;
break;
case 1:
e = `
- ${Ri()}
- fn _start(@builtin(local_invocation_id) LocalId : vec3,
- @builtin(global_invocation_id) GlobalId : vec3,
- @builtin(num_workgroups) NumWorkgroups : vec3) {
- localId = LocalId;
- globalId = GlobalId;
- numWorkgroups = NumWorkgroups;
- main(getGlobalIndex());
- }
-
fn main(${r[0]} : i32)
`;
break;
@@ -25712,84 +25771,103 @@ function ue(...r) {
}
return e;
}
-function Ri() {
+function T3(r) {
+ let e;
+ return e = `
+ ${Eee()}
+ fn _start(@builtin(local_invocation_id) LocalId : vec3,
+ @builtin(global_invocation_id) GlobalId : vec3,
+ @builtin(local_invocation_index) LocalIndex: u32,
+ @builtin(workgroup_id) WorkgroupId : vec3,
+ @builtin(num_workgroups) NumWorkgroups : vec3) {
+ localId = LocalId;
+ localIndex = LocalIndex;
+ globalId = GlobalId;
+ numWorkgroups = NumWorkgroups;
+ workgroupId = WorkgroupId;
+ ${r ? "main(getGlobalIndex());" : "main();"};
+ }
+ `, e;
+}
+function Eee() {
return `
- @compute @workgroup_size(workGroupSizeX, workGroupSizeY, workGroupSizeZ)
+ @compute @workgroup_size(workgroupSizeX, workgroupSizeY, workgroupSizeZ)
`;
}
-function ite(r, e, t10) {
- let o = [];
+function $ee(r, e, t6) {
+ let o = [], n = t6.workgroupSize[0] * t6.workgroupSize[1] * t6.workgroupSize[2];
if (o.push(`
- const workGroupSizeX = ${t10.workGroupSize[0]}u;
- const workGroupSizeY = ${t10.workGroupSize[1]}u;
- const workGroupSizeZ = ${t10.workGroupSize[2]}u;
+ const workgroupSizeX = ${t6.workgroupSize[0]}u;
+ const workgroupSizeY = ${t6.workgroupSize[1]}u;
+ const workgroupSizeZ = ${t6.workgroupSize[2]}u;
var localId: vec3;
+ var localIndex: u32;
var globalId: vec3;
var numWorkgroups: vec3;
+ var workgroupId: vec3;
// Only used when the y/z dimension of workgroup size is 1.
fn getGlobalIndex() -> i32 {
- ${eM(t10) ? " return i32(globalId.x);" : ` let localInvocationIndex = localId.z * workGroupSizeX * workGroupSizeY +
- localId.y * workGroupSizeX + localId.x;
- let workGroupID = (globalId - localId)/vec3(
- workGroupSizeX, workGroupSizeY, workGroupSizeZ);
-
- return i32((workGroupID.z * numWorkgroups.x * numWorkgroups.y +
- workGroupID.y * numWorkgroups.x + workGroupID.x) *
- (workGroupSizeX * workGroupSizeY * workGroupSizeZ) +
- localInvocationIndex);
+ ${F3(t6) ? " return i32(globalId.x);" : ` return i32((workgroupId.z * numWorkgroups.x * numWorkgroups.y +
+ workgroupId.y * numWorkgroups.x + workgroupId.x) * ${n} +
+ localIndex);
`}
}
- `), t10.isFromPixels)
- return o.push(`
+ `), t6.isFromPixels) {
+ o.push(`
struct Uniform {
size : i32,
numChannels : i32,
outShapeStrides : vec2,
};
- @group(0) @binding(0) var result: array<${Tc(e.dtype, t10.isVec4)}>;
+ @group(0) @binding(0) var result: array<${wc(e.dtype, t6.isVec4)}>;
@group(0) @binding(2) var uniforms: Uniform;
- `), [Y3, o.join(`
-`), Q3(e.shape), t10.getUserCode()].join(`
+ `);
+ let f = $3(t6);
+ return [_3, o.join(`
+`), E3(e.shape), t6.getUserCode(), T3(f)].join(`
`);
- let n = "struct Uniforms { NAN : f32, ";
- t10.variableNames.forEach((m, f) => {
- let d = At(r[f].shape.length);
- n += `${m.charAt(0).toLowerCase() + m.slice(1)}Shape : ${d}, `;
+ }
+ let s = "struct Uniforms { NAN : f32, INFINITY : f32, ";
+ t6.variableNames.forEach((f, h) => {
+ let g = Rt(r[h].shape.length);
+ s += `${f.charAt(0).toLowerCase() + f.slice(1)}Shape : ${g}, `;
});
- let s = At(e.shape.length);
- n += `outShape : ${s}, `;
- let a = e.shape.length - 1, i = At(a);
- n += `
- outShapeStrides: ${i}, `, t10.size && (n += "size : i32, "), t10.uniforms && (n += t10.uniforms), n += "};", n = dte(n), o.push(n), t10.atomic ? o.push(`
+ let a = Rt(e.shape.length);
+ s += `outShape : ${a}, `;
+ let i = e.shape.length - 1, p = Rt(i);
+ s += `
+ outShapeStrides: ${p}, `, t6.size && (s += "size : i32, "), t6.uniforms && (s += t6.uniforms), s += "};", s = Lee(s), o.push(s), t6.atomic ? o.push(`
@group(0) @binding(0) var result: array>;
`) : o.push(`
- @group(0) @binding(0) var result: array<${Tc(e.dtype, t10.isVec4)}>;
- `), t10.variableNames.forEach((m, f) => {
+ @group(0) @binding(0) var result: array<${wc(e.dtype, t6.isVec4)}>;
+ `), t6.variableNames.forEach((f, h) => {
o.push(`
- @group(0) @binding(${1 + f}) var ${m}: array<${t10.variableTypes ? t10.variableTypes[f] : Tc(r[f].dtype, t10.isVec4)}>;
+ @group(0) @binding(${1 + h}) var ${f}: array<${t6.variableTypes ? t6.variableTypes[h] : wc(r[h].dtype, t6.isVec4)}>;
`);
- }), n !== "" && o.push(`
- @group(0) @binding(${1 + t10.variableNames.length}) var uniforms: Uniforms;
+ }), s !== "" && o.push(`
+ @group(0) @binding(${1 + t6.variableNames.length}) var uniforms: Uniforms;
`);
- let p = lte(e.shape, t10.dispatchLayout), u = [Y3, o.join(`
-`), Q3(e.shape), p, mte(e.shape.length)];
- t10.atomic || u.push(fte(e.shape, e.dtype, t10.isVec4));
- let c = r.map((m, f) => cte(m, e.shape, t10.variableTypes ? t10.variableTypes[f] === "vec4" : t10.isVec4, t10.dispatchLayout.x.length === e.shape.length)).join(`
+ let u = Oee(e.shape, t6.dispatchLayout), c = [_3 + Aee, o.join(`
+`), E3(e.shape), u, Pee(e.shape.length)];
+ t6.atomic || c.push(Mee(e.shape, e.dtype, t6.isVec4));
+ let l = r.map((f, h) => Dee(f, e.shape, t6.variableTypes ? t6.variableTypes[h] === "vec4" : t6.isVec4, t6.dispatchLayout.x.length === e.shape.length)).join(`
`);
- return u.push(c), u.push(t10.getUserCode()), u.join(`
+ c.push(l), c.push(t6.getUserCode());
+ let m = $3(t6);
+ return c.push(T3(m)), c.join(`
`);
}
-function J3(r, e, t10, o) {
+function R3(r, e, t6, o) {
let n = r.shaderKey;
if (r.isFromPixels)
return n;
- let s = t10.map((c) => c.dtype).concat(o.dtype), a = t10.map((c) => I.getBroadcastDims(c.shape, o.shape)), i = t10.map((c) => x.arraysEqual(c.shape, o.shape)).join("_"), p = a.map((c) => c.join("_")).join(";"), u = eM(r) ? "flatDispatch" : "";
- return n += "_" + (r.workGroupSize ? r.workGroupSize.join(",") : "") + e.map((c) => c.length).join(",") + s.join(",") + r.variableNames.join(",") + p + i + u, n;
+ let s = t6.map((c) => c.dtype).concat(o.dtype), a = t6.map((c) => S.getBroadcastDims(c.shape, o.shape)), i = t6.map((c) => y.arraysEqual(c.shape, o.shape)).join("_"), p = a.map((c) => c.join("_")).join(";"), u = F3(r) ? "flatDispatch" : "";
+ return n += "_" + (r.workgroupSize ? r.workgroupSize.join(",") : "") + e.map((c) => c.length).join(",") + s.join(",") + r.variableNames.join(",") + p + i + u, n;
}
-var Y3 = `
+var _3 = `
struct vec5 {x: i32, y: i32, z: i32, w: i32, u: i32};
struct vec6 {x: i32, y: i32, z: i32, w: i32, u: i32, v: i32};
@@ -25848,21 +25926,26 @@ var Y3 = `
return vec4(isnan(val[0]), isnan(val[1]), isnan(val[2]), isnan(val[3]));
}
`;
-function Q3(r) {
+var Aee = `
+ fn isinf(val: f32) -> bool {
+ return abs(val) == uniforms.INFINITY;
+ }
+`;
+function E3(r) {
let e = r.length;
if (e <= 1)
return "fn getCoordsFromIndex(index : i32) -> i32 { return index; }";
- let t10 = x.computeStrides(r), o = At(e), n = [];
+ let t6 = y.computeStrides(r), o = Rt(e), n = [];
for (let a = 0; a < e; a++)
n.push(`d${a}`);
- if (t10.length === 1)
+ if (t6.length === 1)
return ` fn getCoordsFromIndex(index : i32) -> vec2 {
let d0 = index / uniforms.outShapeStrides; let d1 = index - d0 * uniforms.outShapeStrides;
return vec2(d0, d1);
}`;
let s;
- return s = "var index2 = index;" + t10.map((a, i) => {
- let p = `let ${n[i]} = index2 / uniforms.outShapeStrides.${Yo(i)}`, u = i === t10.length - 1 ? `let ${n[i + 1]} = index2 - ${n[i]} * uniforms.outShapeStrides.${Yo(i)}` : `index2 = index2 - ${n[i]} * uniforms.outShapeStrides.${Yo(i)}`;
+ return s = "var index2 = index;" + t6.map((a, i) => {
+ let p = `let ${n[i]} = index2 / uniforms.outShapeStrides.${$o(i)}`, u = i === t6.length - 1 ? `let ${n[i + 1]} = index2 - ${n[i]} * uniforms.outShapeStrides.${$o(i)}` : `index2 = index2 - ${n[i]} * uniforms.outShapeStrides.${$o(i)}`;
return `${p}; ${u};`;
}).join(""), `
fn getCoordsFromIndex(index : i32) -> ${o} {
@@ -25871,35 +25954,35 @@ function Q3(r) {
}
`;
}
-function ute(r, e) {
- let t10 = r.name, o = r.shape.length, n = At(o), s = "get" + t10.charAt(0).toUpperCase() + t10.slice(1), a = ["d0", "d1", "d2", "d3", "d4", "d5"].slice(0, o), i = a.map((c) => `${c} : i32`).join(", ");
+function Ree(r, e) {
+ let t6 = r.name, o = r.shape.length, n = Rt(o), s = "get" + t6.charAt(0).toUpperCase() + t6.slice(1), a = ["d0", "d1", "d2", "d3", "d4", "d5"].slice(0, o), i = a.map((c) => `${c} : i32`).join(", ");
if (o < 1)
return e ? `
fn ${s}() -> vec4 {
- return vec4(${t10}[0]);
+ return vec4(${t6}[0]);
}
` : `
fn ${s}() ->f32 {
- return f32(${t10}[0]);
+ return f32(${t6}[0]);
}
`;
- let p = `uniforms.${t10.charAt(0).toLowerCase() + t10.slice(1)}Shape`, u = `${o}D`;
+ let p = `uniforms.${t6.charAt(0).toLowerCase() + t6.slice(1)}Shape`, u = `${o}D`;
return o === 0 && (u = "1D"), e ? `
fn ${s}(${i}) -> vec4 {
- return vec4(${t10}[getIndexFromCoords${u}(${n}(${a.join(",")}),
+ return vec4(${t6}[getIndexFromCoords${u}(${n}(${a.join(",")}),
${p}) / 4]);
}
` : `
fn ${s}(${i}) -> f32 {
- return f32(${t10}[getIndexFromCoords${u}(${n}(${a.join(",")}),
+ return f32(${t6}[getIndexFromCoords${u}(${n}(${a.join(",")}),
${p})]);
}
`;
}
-function pte(r, e, t10, o) {
- let n = r.name, s = n.charAt(0).toUpperCase() + n.slice(1), a = "get" + s + "ByOutput", i = r.shape.length, p = e.length, u = At(p);
- if (x.arraysEqual(r.shape, e) && o)
- return t10 ? `
+function Fee(r, e, t6, o) {
+ let n = r.name, s = n.charAt(0).toUpperCase() + n.slice(1), a = "get" + s + "ByOutput", i = r.shape.length, p = e.length, u = Rt(p);
+ if (y.arraysEqual(r.shape, e) && o)
+ return t6 ? `
fn ${a}Index(globalIndex : i32) -> vec4 {
return vec4(${n}[globalIndex]);
}
@@ -25916,9 +25999,9 @@ function pte(r, e, t10, o) {
return f32(${n}[${p > 1 ? "getOutputIndexFromCoords(coords)" : "coords"}]);
}
`;
- let c = I.getBroadcastDims(r.shape, e), l = p - i, m = "";
+ let c = S.getBroadcastDims(r.shape, e), l = p - i, m = "";
if (i === 0)
- return t10 ? `
+ return t6 ? `
fn ${a}Index(globalIndex : i32) -> vec4 {
return get${s}();
}
@@ -25935,79 +26018,79 @@ function pte(r, e, t10, o) {
return get${s}();
}
`;
- p < 2 && c.length >= 1 ? m = "coords = 0;" : m = c.map((g) => `coords.${Yo(g + l)} = 0;`).join(`
+ p < 2 && c.length >= 1 ? m = "coords = 0;" : m = c.map((g) => `coords.${$o(g + l)} = 0;`).join(`
`);
- let f = "";
+ let d = "";
if (p < 2 && i > 0)
- f = "coords";
+ d = "coords";
else if (p > 1) {
- let g = At(i), y = r.shape.map((b, C) => `coords.${Yo(C + l)}`).join(", ");
- f = `${g}(${y})`;
+ let g = Rt(i), x = r.shape.map((b, C) => `coords.${$o(C + l)}`).join(", ");
+ d = `${g}(${x})`;
} else
- f = "coords";
- let d = `uniforms.${n.charAt(0).toLowerCase() + n.slice(1)}Shape`, h = `${i}D`;
- return t10 ? `
+ d = "coords";
+ let f = `uniforms.${n.charAt(0).toLowerCase() + n.slice(1)}Shape`, h = `${i}D`;
+ return t6 ? `
fn ${a}Index(globalIndex : i32) -> vec4 {
var coords = getCoordsFromIndex(globalIndex);
${m}
- return ${n}[getIndexFromCoords${h}(${f}, ${d}) / 4];
+ return ${n}[getIndexFromCoords${h}(${d}, ${f}) / 4];
}
fn ${a}Coords(coordsIn : ${u}) -> vec4 {
var coords = coordsIn;
${m}
- return ${n}[getIndexFromCoords${h}(${f}, ${d}) / 4];
+ return ${n}[getIndexFromCoords${h}(${d}, ${f}) / 4];
}
` : `
fn ${a}Index(globalIndex : i32) -> f32 {
var coords = getCoordsFromIndex(globalIndex);
${m}
- return f32(${n}[getIndexFromCoords${h}(${f}, ${d})]);
+ return f32(${n}[getIndexFromCoords${h}(${d}, ${f})]);
}
fn ${a}Coords(coordsIn : ${u}) -> f32 {
var coords = coordsIn;
${m}
- return f32(${n}[getIndexFromCoords${h}(${f}, ${d})]);
+ return f32(${n}[getIndexFromCoords${h}(${d}, ${f})]);
}
`;
}
-function cte(r, e, t10, o) {
- let n = ute(r, t10);
- return r.shape.length <= e.length && (n += pte(r, e, t10, o)), n;
+function Dee(r, e, t6, o) {
+ let n = Ree(r, t6);
+ return r.shape.length <= e.length && (n += Fee(r, e, t6, o)), n;
}
-function lte(r, e) {
- let { x: t10, y: o = [], z: n = [] } = e, s = r.length, a = t10.length + o.length + n.length;
+function Oee(r, e) {
+ let { x: t6, y: o = [], z: n = [] } = e, s = r.length, a = t6.length + o.length + n.length;
if (a !== s)
return "";
- if (t10.length === s)
- return `fn getOutputCoords() -> ${At(s)}{
+ if (t6.length === s)
+ return `fn getOutputCoords() -> ${Rt(s)}{
let globalIndex = getGlobalIndex();
return getCoordsFromIndex(globalIndex);
}
`;
- let i = "", p = [t10, o, n];
+ let i = "", p = [t6, o, n];
for (let m = 0; m < p.length; m++) {
- let f = p[m];
- if (f.length !== 0)
- if (f.length === 1)
- i += `let d${f[0]} = i32(globalId[${m}]);`;
+ let d = p[m];
+ if (d.length !== 0)
+ if (d.length === 1)
+ i += `let d${d[0]} = i32(globalId[${m}]);`;
else {
- let d = X3(f, "uniforms.outShape");
+ let f = N3(d, "uniforms.outShape");
i += `var index${m} = i32(globalId[${m}]);`;
- for (let h = 0; h < d.length; h++)
- i += `let d${f[h]} = index${m} / ${d[h]};`, h === d.length - 1 ? i += `let d${f[h + 1]} = index${m} - d${f[h]} * ${d[h]};` : i += `index${m} = index${m} - d${f[h]} * ${d[h]};`;
+ for (let h = 0; h < f.length; h++)
+ i += `let d${d[h]} = index${m} / ${f[h]};`, h === f.length - 1 ? i += `let d${d[h + 1]} = index${m} - d${d[h]} * ${f[h]};` : i += `index${m} = index${m} - d${d[h]} * ${f[h]};`;
}
}
let u = [];
for (let m = 0; m < a; m++)
u.push(`d${m}`);
- let c = At(a), l = `fn getOutputCoords() -> ${c} {
+ let c = Rt(a), l = `fn getOutputCoords() -> ${c} {
${i}
`;
return u.length === 0 ? l += `return ${c}(0); }` : l += `return ${c}(${u.join(",")}); }`, l;
}
-function mte(r) {
+function Pee(r) {
let e = "";
switch (r) {
case 0:
@@ -26064,20 +26147,20 @@ function mte(r) {
`;
break;
default:
- x.assert(false, () => `Unsupported ${r}D shape`);
+ y.assert(false, () => `Unsupported ${r}D shape`);
break;
}
return e;
}
-function eM(r) {
+function F3(r) {
return r.dispatch[1] === 1 && r.dispatch[2] === 1;
}
-function Tc(r, e) {
+function wc(r, e) {
return r === "float32" ? e ? "vec4" : "f32" : r === "int32" || r === "bool" ? e ? "vec4" : "i32" : r;
}
-function fte(r, e, t10) {
- let o = r.length, n = Tc(e, t10), s;
- if (t10 ? s = `fn setOutputAtIndex(flatIndex : i32, value : vec4) {
+function Mee(r, e, t6) {
+ let o = r.length, n = wc(e, t6), s;
+ if (t6 ? s = `fn setOutputAtIndex(flatIndex : i32, value : vec4) {
result[flatIndex] = ${n}(value);
}
fn setOutputAtIndexI32(flatIndex : i32, value : vec4) {
@@ -26088,8 +26171,8 @@ function fte(r, e, t10) {
fn setOutputAtIndexI32(flatIndex : i32, value : i32) {
result[flatIndex] = ${n}(value);
}`, o >= 2) {
- let a = ["d0", "d1", "d2", "d3", "d4", "d5"].slice(0, o), i = At(o);
- t10 ? s += `
+ let a = ["d0", "d1", "d2", "d3", "d4", "d5"].slice(0, o), i = Rt(o);
+ t6 ? s += `
fn setOutputAtCoords(${a.map((p) => `${p} : i32`).join(", ")}, value : vec4) {
let flatIndex = getOutputIndexFromCoords(${i}(${a.join(", ")}));
setOutputAtIndex(flatIndex / 4, value);
@@ -26111,56 +26194,59 @@ function fte(r, e, t10) {
}
return s;
}
-function dte(r) {
+function Lee(r) {
let e = /(\w+)\s*:\s*vec(5|6)/g;
r = r.replace(e, (o) => "@align(16) " + o);
- let t10 = /vec(5|6)\s*,\s*(\w+)/g;
- return r = r.replace(t10, (o, n, s) => `vec${n}, @align(16) ${s}`), r;
+ let t6 = /vec(5|6)\s*,\s*(\w+)/g;
+ return r = r.replace(t6, (o, n, s) => `vec${n}, @align(16) ${s}`), r;
}
-var pS = {};
-Be(pS, { ArrayBufferToTypedArray: () => uS, GPUBytesPerElement: () => iS, MatMulProgramType: () => Qo, computeDispatch: () => ae, computeWorkGroupInfoForMatMul: () => aS, computeWorkGroupSizeForConv2d: () => Hl, computeWorkPerThreadForConv2d: () => ql, flatDispatchLayout: () => fe, isWebGPUSupported: () => Kl, tilesFitEvenlyIntoShape: () => gte });
-var Wu = (r) => {
+function $3(r) {
+ return !(r.dispatchLayout.hasOwnProperty("y") && r.dispatchLayout.y.length !== 0 || r.dispatchLayout.hasOwnProperty("z") && r.dispatchLayout.z.length !== 0);
+}
+var nI = {};
+Ue(nI, { ArrayBufferToTypedArray: () => oI, GPUBytesPerElement: () => rI, MatMulProgramType: () => Ao, computeDispatch: () => re, computeWorkPerThreadForConv2d: () => Ll, computeWorkgroupInfoForMatMul: () => tI, computeWorkgroupSizeForConv2d: () => Ml, flatDispatchLayout: () => ue, isWebGPUSupported: () => Bl, tilesFitEvenlyIntoShape: () => Vee });
+var zu = (r) => {
let e = 1;
- for (let t10 = 0; t10 < r.length; t10++)
- e *= r[t10];
+ for (let t6 = 0; t6 < r.length; t6++)
+ e *= r[t6];
return e;
};
-function gte(r, e) {
+function Vee(r, e) {
if (r.length !== e.length)
throw new Error(`Cannot compute whether rank ${r.length} tiles fit evenly into rank ${e.length} shape - ranks must match.`);
- return e.every((t10, o) => t10 % r[o] === 0);
+ return e.every((t6, o) => t6 % r[o] === 0);
}
-function ae(r, e, t10 = [1, 1, 1], o = [1, 1, 1]) {
- let [n, s, a] = [Math.ceil(Wu(r.x.map((i) => e[i])) / (t10[0] * o[0])), r.y ? Math.ceil(Wu(r.y.map((i) => e[i])) / (t10[1] * o[1])) : 1, r.z ? Math.ceil(Wu(r.z.map((i) => e[i])) / (t10[2] * o[2])) : 1];
+function re(r, e, t6 = [1, 1, 1], o = [1, 1, 1]) {
+ let [n, s, a] = [Math.ceil(zu(r.x.map((i) => e[i])) / (t6[0] * o[0])), r.y ? Math.ceil(zu(r.y.map((i) => e[i])) / (t6[1] * o[1])) : 1, r.z ? Math.ceil(zu(r.z.map((i) => e[i])) / (t6[2] * o[2])) : 1];
return [n, s, a];
}
-function aS(r, e, t10, o = false) {
+function tI(r, e, t6, o = false) {
let n = [8, 8, 1], s = [4, 4, 1];
- return o || (r <= 8 && (s[1] = 1), e <= 16 && t10 <= 16 && (n[0] = 4)), { workGroupSize: n, elementsPerThread: s };
+ return o || (r <= 8 && (s[1] = 1), e <= 16 && t6 <= 16 && (n[0] = 4)), { workgroupSize: n, elementsPerThread: s };
}
-function Hl(r, e, t10 = false) {
- if (t10)
+function Ml(r, e, t6 = false) {
+ if (t6)
return [8, 8, 1];
- let o = Wu(r.x.map((s) => e[s])), n = Wu(r.y.map((s) => e[s]));
+ let o = zu(r.x.map((s) => e[s])), n = zu(r.y.map((s) => e[s]));
return o <= 4 ? [4, 16, 1] : n <= 4 ? [16, 4, 1] : [16, 16, 1];
}
-function ql(r, e, t10 = false) {
- if (t10)
+function Ll(r, e, t6 = false) {
+ if (t6)
return [4, 4, 1];
- let o = Wu(r.x.map((s) => e[s])), n = Wu(r.y.map((s) => e[s]));
+ let o = zu(r.x.map((s) => e[s])), n = zu(r.y.map((s) => e[s]));
return o <= 4 ? [1, 2, 1] : n <= 4 ? [2, 1, 1] : [2, 2, 1];
}
-function fe(r) {
- return { x: r.map((e, t10) => t10) };
+function ue(r) {
+ return { x: r.map((e, t6) => t6) };
}
-function iS(r) {
+function rI(r) {
if (r === "float32" || r === "int32" || r === "bool" || r === "string")
return 4;
if (r === "complex64")
return 8;
throw new Error(`Unknown dtype ${r}`);
}
-function uS(r, e) {
+function oI(r, e) {
if (e === "float32")
return new Float32Array(r);
if (e === "int32")
@@ -26169,30 +26255,30 @@ function uS(r, e) {
return Uint8Array.from(new Int32Array(r));
throw new Error(`Unknown dtype ${e}`);
}
-function Kl() {
+function Bl() {
return (typeof window != "undefined" || typeof WorkerGlobalScope != "undefined") && !!navigator.gpu;
}
-var Qo;
+var Ao;
(function(r) {
r[r.MatMulReduceProgram = 0] = "MatMulReduceProgram", r[r.MatMulSplitKProgram = 1] = "MatMulSplitKProgram", r[r.MatMulSmallOutputSizeProgram = 2] = "MatMulSmallOutputSizeProgram", r[r.MatMulPackedProgram = 3] = "MatMulPackedProgram", r[r.MatMulMax = 4] = "MatMulMax";
-})(Qo || (Qo = {}));
-var xte = P().getNumber("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD");
-var yte = (r, e) => {
- let t10 = r.limits.maxComputeWorkgroupsPerDimension, o = e.dispatchLayout, n = e.dispatch;
- if (n.every((a) => a <= t10))
+})(Ao || (Ao = {}));
+var zee = O().getNumber("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD");
+var Wee = (r, e) => {
+ let t6 = r.limits.maxComputeWorkgroupsPerDimension, o = e.dispatchLayout, n = e.dispatch;
+ if (n.every((a) => a <= t6))
return n;
- x.assert(n[0] > t10 && o.y === void 0 && o.z === void 0, () => "Dispatch size exceeds WebGPU limits in Y or Z dimension.");
+ y.assert(n[0] > t6 && o.y === void 0 && o.z === void 0, () => "Dispatch size exceeds WebGPU limits in Y or Z dimension.");
let s = Math.ceil(Math.sqrt(n[0]));
- return s > t10 ? (s = Math.ceil(Math.cbrt(n[0])), x.assert(s <= t10, () => "Total dispatch size exceeds WebGPU maximum."), [s, s, s]) : [s, s, 1];
+ return s > t6 ? (s = Math.ceil(Math.cbrt(n[0])), y.assert(s <= t6, () => "Total dispatch size exceeds WebGPU maximum."), [s, s, s]) : [s, s, 1];
};
-var Ai = class extends Jr {
- constructor(e, t10) {
- if (super(), this.commandQueueOwnedIds = /* @__PURE__ */ new WeakSet(), this.dispatchNumberInEncoder = 0, this.disposed = false, this.downloadWaitMs = 0, this.tensorDataPendingDisposal = [], this.stagingPendingDisposal = [], this.uniformPendingDisposal = [], this.uploadWaitMs = 0, !Kl())
+var Ui = class extends Zr {
+ constructor(e, t6) {
+ if (super(), this.commandQueueOwnedIds = /* @__PURE__ */ new WeakSet(), this.dispatchNumberInEncoder = 0, this.disposed = false, this.downloadWaitMs = 0, this.tensorDataPendingDisposal = [], this.stagingPendingDisposal = [], this.uniformPendingDisposal = [], this.uploadWaitMs = 0, !Bl())
throw new Error("WebGPU is not supported on this device");
- this.pipelineCache = {}, this.device = e, this.queue = e.queue, this.currentCommandEncoder = null, this.currentComputePass = null, this.supportTimeQuery = e.features.has("timestamp-query"), this.adapterInfo = new Og(t10), this.bufferManager = new Mg(this.device), this.textureManager = new Lg(this.device), this.tensorMap = new rn(this, cr()), this.supportTimeQuery && (this.querySet = this.device.createQuerySet({ type: "timestamp", count: 2 })), P().getBool("WEBGPU_USE_PROFILE_TOOL") && (this.dummyCanvas = document.createElement("canvas"), this.dummyCanvas.width = 1, this.dummyCanvas.height = 1, this.dummyContext = this.dummyCanvas.getContext("webgpu"), this.dummyContext.configure({ device: e, format: "bgra8unorm" }), document.body.appendChild(this.dummyCanvas));
+ this.pipelineCache = {}, this.device = e, this.queue = e.queue, this.currentCommandEncoder = null, this.currentComputePass = null, this.supportTimeQuery = e.features.has("timestamp-query-inside-passes"), this.adapterInfo = new kg(t6), this.thresholdToIncreaseWorkgroups = this.adapterInfo.intelGPUGeneration >= 12 ? 16 : 8, this.bufferManager = new Ng(this.device), this.textureManager = new Tg(this.device), this.tensorMap = new Do(this, cr()), this.supportTimeQuery && (this.querySet = this.device.createQuerySet({ type: "timestamp", count: 2 })), O().getBool("WEBGPU_USE_PROFILE_TOOL") && (this.dummyCanvas = document.createElement("canvas"), this.dummyCanvas.width = 1, this.dummyCanvas.height = 1, this.dummyContext = this.dummyCanvas.getContext("webgpu"), this.dummyContext.configure({ device: e, format: "bgra8unorm" }), document.body.appendChild(this.dummyCanvas));
}
nextDataId() {
- return Ai.nextDataId++;
+ return Ui.nextDataId++;
}
floatPrecision() {
return 32;
@@ -26200,58 +26286,58 @@ var Ai = class extends Jr {
defaultGpuBufferUsage() {
return GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST;
}
- disposeData(e, t10 = false) {
+ disposeData(e, t6 = false) {
if (this.tensorDataPendingDisposal.indexOf(e) >= 0)
return false;
if (!this.tensorMap.has(e))
return true;
let o = this.tensorMap.get(e);
- if (this.decRef(e), !t10 && o.refCount > 0)
+ if (this.decRef(e), !t6 && o.refCount > 0)
return false;
if (this.commandQueueOwnedIds.has(e))
return this.tensorDataPendingDisposal.push(e), false;
let { complexTensorInfos: n } = this.tensorMap.get(e);
- return n != null && (this.disposeData(n.real.dataId, t10), this.disposeData(n.imag.dataId, t10)), this.releaseResource(e), this.tensorMap.delete(e), true;
+ return n != null && (this.disposeData(n.real.dataId, t6), this.disposeData(n.imag.dataId, t6)), this.releaseResource(e), this.tensorMap.delete(e), true;
}
memory() {
return { numBytesInGPU: this.bufferManager.numBytesUsed, numBytesAllocatedInGPU: this.bufferManager.numBytesAllocated, unreliable: false };
}
releaseResource(e) {
- let t10 = this.tensorMap.get(e);
- if (!(!t10 || !t10.resourceInfo)) {
- if ("texture" in t10.resourceInfo) {
- let o = t10.resourceInfo;
+ let t6 = this.tensorMap.get(e);
+ if (!(!t6 || !t6.resourceInfo)) {
+ if ("texture" in t6.resourceInfo) {
+ let o = t6.resourceInfo;
o.texture instanceof GPUTexture && this.textureManager.releaseTexture(o.texture, o.width, o.height, o.format, o.usage), o.texture = null;
} else {
- let o = t10.resourceInfo;
+ let o = t6.resourceInfo;
this.bufferManager.releaseBuffer(o.buffer, o.size, o.usage), o.buffer = null;
}
- t10.resourceInfo = null;
+ t6.resourceInfo = null;
}
}
refCount(e) {
return this.tensorMap.has(e) ? this.tensorMap.get(e).refCount : 0;
}
incRef(e) {
- let t10 = this.tensorMap.get(e);
- t10.refCount++;
+ let t6 = this.tensorMap.get(e);
+ t6.refCount++;
}
decRef(e) {
if (this.tensorMap.has(e)) {
- let t10 = this.tensorMap.get(e);
- t10.refCount--;
+ let t6 = this.tensorMap.get(e);
+ t6.refCount--;
}
}
- write(e, t10, o) {
+ write(e, t6, o) {
if (o === "complex64" && e != null)
throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");
let n = { id: this.nextDataId() };
- return this.tensorMap.set(n, { dtype: o, shape: t10, values: e, refCount: 1 }), n;
+ return this.tensorMap.set(n, { dtype: o, shape: t6, values: e, refCount: 1 }), n;
}
- move(e, t10, o, n, s) {
+ move(e, t6, o, n, s) {
if (n === "complex64")
throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");
- this.tensorMap.set(e, { dtype: n, shape: o, values: t10, refCount: s });
+ this.tensorMap.set(e, { dtype: n, shape: o, values: t6, refCount: s });
}
submitQueue() {
this.ensureComputePassEnded(), this.queue.submit([this.currentCommandEncoder.finish()]), this.currentCommandEncoder = null, this.dispatchNumberInEncoder = 0, this.commandQueueOwnedIds = /* @__PURE__ */ new WeakSet(), this.tensorDataPendingDisposal.forEach((e) => {
@@ -26267,18 +26353,18 @@ var Ai = class extends Jr {
getComputePass() {
return this.currentComputePass || (this.currentComputePass = this.currentCommandEncoder.beginComputePass()), this.currentComputePass;
}
- async getBufferData(e, t10) {
- let o = this.bufferManager.acquireBuffer(t10, GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ);
- this.ensureCommandEncoderReady(), this.ensureComputePassEnded(), this.currentCommandEncoder.copyBufferToBuffer(e, 0, o, 0, t10), this.submitQueue(), await o.mapAsync(GPUMapMode.READ);
+ async getBufferData(e, t6) {
+ let o = this.bufferManager.acquireBuffer(t6, GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ);
+ this.ensureCommandEncoderReady(), this.ensureComputePassEnded(), this.currentCommandEncoder.copyBufferToBuffer(e, 0, o, 0, t6), this.submitQueue(), await o.mapAsync(GPUMapMode.READ);
let n = o.getMappedRange().slice(0);
- return o.unmap(), o != null && this.bufferManager.releaseBuffer(o, t10, GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ), P().getBool("WEBGPU_USE_PROFILE_TOOL") && (x.assert(this.dummyContext !== void 0, () => "Fail to get context for profiling tool"), this.dummyContext.getCurrentTexture()), n;
+ return o.unmap(), o != null && this.bufferManager.releaseBuffer(o, t6, GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ), O().getBool("WEBGPU_USE_PROFILE_TOOL") && (y.assert(this.dummyContext !== void 0, () => "Fail to get context for profiling tool"), this.dummyContext.getCurrentTexture()), n;
}
- convertAndCacheOnCPU(e, t10) {
+ convertAndCacheOnCPU(e, t6) {
let o = this.tensorMap.get(e);
- return this.releaseResource(e), o.values = t10, o.values;
+ return this.releaseResource(e), o.values = t6, o.values;
}
readSync(e) {
- let t10 = this.tensorMap.get(e), { values: o } = t10;
+ let t6 = this.tensorMap.get(e), { values: o } = t6;
if (o == null)
throw new Error("WebGPU readSync is only available for CPU-resident tensors.");
return o;
@@ -26286,21 +26372,21 @@ var Ai = class extends Jr {
async read(e) {
if (!this.tensorMap.has(e))
throw new Error(`Tensor ${e} was not registered!`);
- let t10 = this.tensorMap.get(e), { values: o } = t10;
+ let t6 = this.tensorMap.get(e), { values: o } = t6;
if (o != null)
return this.convertAndCacheOnCPU(e, o);
let n;
- if (t10.dtype === "complex64") {
- let s = await Promise.all([this.read(t10.complexTensorInfos.real.dataId), this.read(t10.complexTensorInfos.imag.dataId)]), a = s[0], i = s[1];
- n = I.mergeRealAndImagArrays(a, i);
+ if (t6.dtype === "complex64") {
+ let s = await Promise.all([this.read(t6.complexTensorInfos.real.dataId), this.read(t6.complexTensorInfos.imag.dataId)]), a = s[0], i = s[1];
+ n = S.mergeRealAndImagArrays(a, i);
} else {
- let s = t10.resourceInfo, a = await this.getBufferData(s.buffer, s.size);
- n = uS(a, t10.dtype);
+ let s = t6.resourceInfo, a = await this.getBufferData(s.buffer, s.size);
+ n = oI(a, t6.dtype);
}
return this.convertAndCacheOnCPU(e, n), n;
}
readToGPU(e) {
- let t10 = this.tensorMap.get(e), { values: o, dtype: n, shape: s, resourceInfo: a } = t10;
+ let t6 = this.tensorMap.get(e), { values: o, dtype: n, shape: s, resourceInfo: a } = t6;
if (n === "complex64")
throw new Error("Does not support reading buffer for complex64 dtype.");
if (a == null)
@@ -26311,56 +26397,56 @@ var Ai = class extends Jr {
return l.resourceInfo = { size: i, usage: this.defaultGpuBufferUsage(), buffer: p }, { tensorRef: c, buffer: p, bufSize: i };
}
bufferSync(e) {
- let t10 = this.readSync(e.dataId);
+ let t6 = this.readSync(e.dataId);
if (e.dtype === "string")
try {
- let o = t10.map((n) => x.decodeString(n));
- return ne(e.shape, e.dtype, o);
+ let o = t6.map((n) => y.decodeString(n));
+ return le(e.shape, e.dtype, o);
} catch (o) {
throw new Error("Failed to decode encoded string bytes into utf-8");
}
- return ne(e.shape, e.dtype, t10);
+ return le(e.shape, e.dtype, t6);
}
async time(e) {
- this.supportTimeQuery || console.warn("This device doesn't support timestamp-query extension. Start Chrome browser with flag --disable-dawn-features=disallow_unsafe_apis then try again. Otherwise, zero will be shown for the kernel time when profiling mode is enabled. Using performance.now is not workable for webgpu since it doesn't support synchronous data read from GPU.");
- let t10 = this.activeTimers, o = [], n = false;
+ this.supportTimeQuery || console.warn("This device doesn't support timestamp-query-inside-passes extension. Start Chrome browser with flag --disable-dawn-features=disallow_unsafe_apis then try again. Otherwise, zero will be shown for the kernel time when profiling mode is enabled. Using performance.now is not workable for webgpu since it doesn't support synchronous data read from GPU.");
+ let t6 = this.activeTimers, o = [], n = false;
this.programTimersStack == null ? (this.programTimersStack = o, n = true) : this.activeTimers.push(o), this.activeTimers = o, e();
- let s = x.flatten(this.activeTimers.map((u) => u.query)).filter((u) => u != null), a = x.flatten(this.activeTimers.map((u) => u.name)).filter((u) => u != null);
- this.activeTimers = t10, n && (this.programTimersStack = null);
+ let s = y.flatten(this.activeTimers.map((u) => u.query)).filter((u) => u != null), a = y.flatten(this.activeTimers.map((u) => u.name)).filter((u) => u != null);
+ this.activeTimers = t6, n && (this.programTimersStack = null);
let i = { uploadWaitMs: this.uploadWaitMs, downloadWaitMs: this.downloadWaitMs, kernelMs: null, wallMs: null }, p = await Promise.all(s);
- return i.kernelMs = x.sum(p), i.getExtraProfileInfo = () => p.map((u, c) => ({ name: a[c], ms: u })).map((u) => `${u.name}: ${u.ms}`).join(", "), this.uploadWaitMs = 0, this.downloadWaitMs = 0, i;
+ return i.kernelMs = y.sum(p), i.getExtraProfileInfo = () => p.map((u, c) => ({ name: a[c], ms: u })).map((u) => `${u.name}: ${u.ms}`).join(", "), this.uploadWaitMs = 0, this.downloadWaitMs = 0, i;
}
- makeTensorInfo(e, t10, o) {
- return t10 === "string" && o != null && o.length > 0 && x.isString(o[0]) && (o = o.map((s) => x.encodeString(s))), { dataId: this.write(o, e, t10), shape: e, dtype: t10 };
+ makeTensorInfo(e, t6, o) {
+ return t6 === "string" && o != null && o.length > 0 && y.isString(o[0]) && (o = o.map((s) => y.encodeString(s))), { dataId: this.write(o, e, t6), shape: e, dtype: t6 };
}
tensorToBinding(e) {
if (!e)
return null;
- let t10 = this.tensorMap.get(e.dataId);
- if ("texture" in t10.resourceInfo) {
- let n = t10.resourceInfo;
+ let t6 = this.tensorMap.get(e.dataId);
+ if ("texture" in t6.resourceInfo) {
+ let n = t6.resourceInfo;
return n.texture instanceof GPUExternalTexture ? n.texture : n.texture.createView();
}
- let o = t10.resourceInfo;
+ let o = t6.resourceInfo;
return { offset: 0, size: o.size, buffer: o.buffer };
}
async getQueryTime(e) {
return this.supportTimeQuery ? this.getTimeFromQuerySet(e) : 0;
}
uploadToGPU(e) {
- let t10 = this.tensorMap.get(e);
- if (t10.resourceInfo)
+ let t6 = this.tensorMap.get(e);
+ if (t6.resourceInfo)
return;
- let o = iS(t10.dtype) * x.sizeFromShape(t10.shape), n = this.bufferManager.acquireBuffer(o, this.defaultGpuBufferUsage());
- if (t10.resourceInfo = { size: o, usage: this.defaultGpuBufferUsage(), buffer: n }, t10.values) {
+ let o = rI(t6.dtype) * y.sizeFromShape(t6.shape), n = this.bufferManager.acquireBuffer(o, this.defaultGpuBufferUsage());
+ if (t6.resourceInfo = { size: o, usage: this.defaultGpuBufferUsage(), buffer: n }, t6.values) {
let s = this.bufferManager.acquireUploadBuffer(o, GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC), a = s.getMappedRange();
- t10.dtype === "int32" || t10.dtype === "bool" ? new Int32Array(a).set(t10.values) : new Float32Array(a).set(t10.values), s.unmap(), this.ensureCommandEncoderReady(), this.ensureComputePassEnded(), this.currentCommandEncoder.copyBufferToBuffer(s, 0, n, 0, o);
+ t6.dtype === "int32" || t6.dtype === "bool" ? new Int32Array(a).set(t6.values) : new Float32Array(a).set(t6.values), s.unmap(), this.ensureCommandEncoderReady(), this.ensureComputePassEnded(), this.currentCommandEncoder.copyBufferToBuffer(s, 0, n, 0, o);
let i = { size: o, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC, buffer: s };
this.stagingPendingDisposal.push(i);
}
}
makeUniforms(e) {
- let t10 = 0, o = 0, n = [];
+ let t6 = 0, o = 0, n = [];
e.forEach((p) => {
p.data.length === 0 && (p.data = [1]);
let u;
@@ -26384,58 +26470,58 @@ var Ai = class extends Jr {
u = 16;
break;
default:
- x.assert(false, () => `Unsupported ${p.data.length}D shape`);
+ y.assert(false, () => `Unsupported ${p.data.length}D shape`);
}
- (o === 5 || o === 6) && (u = 16), t10 = Math.ceil(t10 / u) * u, o = p.data.length, n.push(t10), t10 += p.data.length * 4;
+ (o === 5 || o === 6) && (u = 16), t6 = Math.ceil(t6 / u) * u, o = p.data.length, n.push(t6), t6 += p.data.length * 4;
});
- let s = new ArrayBuffer(t10);
+ let s = new ArrayBuffer(t6);
e.forEach((p, u) => {
let c = n[u];
p.type === "int32" ? new Int32Array(s, c, p.data.length).set(p.data) : p.type === "uint32" ? new Uint32Array(s, c, p.data.length).set(p.data) : new Float32Array(s, c, p.data.length).set(p.data);
});
- let a = this.bufferManager.acquireBuffer(t10, GPUBufferUsage.COPY_DST | GPUBufferUsage.UNIFORM);
- this.queue.writeBuffer(a, 0, s, 0, t10);
- let i = { size: t10, usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.UNIFORM, buffer: a };
- return this.uniformPendingDisposal.push(i), { offset: 0, size: t10, buffer: a };
+ let a = this.bufferManager.acquireBuffer(t6, GPUBufferUsage.COPY_DST | GPUBufferUsage.UNIFORM);
+ this.queue.writeBuffer(a, 0, s, 0, t6);
+ let i = { size: t6, usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.UNIFORM, buffer: a };
+ return this.uniformPendingDisposal.push(i), { offset: 0, size: t6, buffer: a };
}
- runWebGPUProgram(e, t10, o, n, s) {
- if (s || (s = this.makeTensorInfo(e.outputShape, o)), x.sizeFromShape(s.shape) === 0)
- return this.tensorMap.get(s.dataId).values = x.getTypedArrayFromDType(s.dtype, 0), s;
- this.uploadToGPU(s.dataId), e.dispatch = yte(this.device, e);
+ runWebGPUProgram(e, t6, o, n, s) {
+ if (s || (s = this.makeTensorInfo(e.outputShape, o)), y.sizeFromShape(s.shape) === 0)
+ return this.tensorMap.get(s.dataId).values = y.getTypedArrayFromDType(s.dtype, 0), s;
+ this.uploadToGPU(s.dataId), e.dispatch = Wee(this.device, e);
let a = [], i = [];
if (!e.isFromPixels) {
- a.push({ type: "float32", data: [NaN] }), i = t10.concat(s).map((y) => y.shape);
+ a.push({ type: "float32", data: [NaN] }, { type: "float32", data: [1 / 0] }), i = t6.concat(s).map((x) => x.shape);
let h = "int32";
- i.map((y) => {
- a.push({ type: h, data: y });
+ i.map((x) => {
+ a.push({ type: h, data: x });
});
- let g = x.computeStrides(s.shape);
+ let g = y.computeStrides(s.shape);
if (a.push({ type: h, data: g }), e.size) {
- let y = x.sizeFromShape(e.outputShape);
- a.push({ type: h, data: [e.isVec4 ? y / 4 : y] });
+ let x = y.sizeFromShape(e.outputShape);
+ a.push({ type: h, data: [e.isVec4 ? x / 4 : x] });
}
}
- let p = t10.map((h, g) => {
+ let p = t6.map((h, g) => {
if (h.dtype === "complex64")
throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");
return this.uploadToGPU(h.dataId), { dtype: this.tensorMap.get(h.dataId).dtype, shape: h.shape, name: e.variableNames[g] };
- }), u = J3(e, i, p, s), c;
- u in this.pipelineCache ? c = this.pipelineCache[u] : (c = Z3(this.device, e, p, s), this.pipelineCache[u] = c), n && (a = [...a, ...n]);
- let l = [this.tensorToBinding(s), ...t10.map((h) => this.tensorToBinding(h)), this.makeUniforms(a)], m = this.device.createBindGroup({ layout: c.getBindGroupLayout(0), entries: l.map((h, g) => ({ binding: g, resource: h })) });
+ }), u = R3(e, i, p, s), c;
+ u in this.pipelineCache ? c = this.pipelineCache[u] : (c = A3(this.device, e, p, s), this.pipelineCache[u] = c), n && (a = [...a, ...n]);
+ let l = [this.tensorToBinding(s), ...t6.map((h) => this.tensorToBinding(h)), this.makeUniforms(a)], m = this.device.createBindGroup({ layout: c.getBindGroupLayout(0), entries: l.map((h, g) => ({ binding: g, resource: h })) });
this.ensureCommandEncoderReady();
- let f = this.getComputePass(), d = this.activeTimers != null;
- return d && this.supportTimeQuery && f.writeTimestamp(this.querySet, 0), f.setPipeline(c), f.setBindGroup(0, m), f.dispatchWorkgroups(e.dispatch[0], e.dispatch[1], e.dispatch[2]), d && this.supportTimeQuery && f.writeTimestamp(this.querySet, 1), this.dispatchNumberInEncoder++, t10.forEach((h) => {
+ let d = this.getComputePass(), f = this.activeTimers != null;
+ return f && this.supportTimeQuery && d.writeTimestamp(this.querySet, 0), d.setPipeline(c), d.setBindGroup(0, m), d.dispatchWorkgroups(e.dispatch[0], e.dispatch[1], e.dispatch[2]), f && this.supportTimeQuery && d.writeTimestamp(this.querySet, 1), this.dispatchNumberInEncoder++, t6.forEach((h) => {
this.commandQueueOwnedIds.add(h.dataId);
- }), this.commandQueueOwnedIds.add(s.dataId), P().get("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE") <= this.dispatchNumberInEncoder && this.submitQueue(), d && this.activeTimers.push({ name: e.constructor.name, query: this.getQueryTime(this.querySet) }), s;
+ }), this.commandQueueOwnedIds.add(s.dataId), O().get("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE") <= this.dispatchNumberInEncoder && this.submitQueue(), f && this.activeTimers.push({ name: e.constructor.name, query: this.getQueryTime(this.querySet) }), s;
}
async getTimeFromQuerySet(e) {
- let t10 = this.bufferManager.acquireBuffer(16, GPUBufferUsage.COPY_SRC | GPUBufferUsage.QUERY_RESOLVE), o = this.bufferManager.acquireBuffer(16, GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST);
- this.ensureCommandEncoderReady(), this.ensureComputePassEnded(), this.currentCommandEncoder.resolveQuerySet(e, 0, 2, t10, 0), this.currentCommandEncoder.copyBufferToBuffer(t10, 0, o, 0, 16), this.submitQueue(), await o.mapAsync(GPUMapMode.READ);
+ let t6 = this.bufferManager.acquireBuffer(16, GPUBufferUsage.COPY_SRC | GPUBufferUsage.QUERY_RESOLVE), o = this.bufferManager.acquireBuffer(16, GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST);
+ this.ensureCommandEncoderReady(), this.ensureComputePassEnded(), this.currentCommandEncoder.resolveQuerySet(e, 0, 2, t6, 0), this.currentCommandEncoder.copyBufferToBuffer(t6, 0, o, 0, 16), this.submitQueue(), await o.mapAsync(GPUMapMode.READ);
let n = new BigUint64Array(o.getMappedRange()), s = Number(n[1] - n[0]);
- return o.unmap(), this.bufferManager.releaseBuffer(o, 16, GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST), this.bufferManager.releaseBuffer(t10, 16, GPUBufferUsage.COPY_SRC | GPUBufferUsage.QUERY_RESOLVE), s / 1e6;
+ return o.unmap(), this.bufferManager.releaseBuffer(o, 16, GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST), this.bufferManager.releaseBuffer(t6, 16, GPUBufferUsage.COPY_SRC | GPUBufferUsage.QUERY_RESOLVE), s / 1e6;
}
- shouldExecuteOnCPU(e, t10 = xte) {
- return P().getBool("WEBGPU_CPU_FORWARD") && e.every((o) => this.tensorMap.get(o.dataId).resourceInfo == null && x.sizeFromShape(o.shape) < t10);
+ shouldExecuteOnCPU(e, t6 = zee) {
+ return O().getBool("WEBGPU_CPU_FORWARD") && e.every((o) => this.tensorMap.get(o.dataId).resourceInfo == null && y.sizeFromShape(o.shape) < t6);
}
numDataIds() {
return this.tensorMap.numDataIds() - this.tensorDataPendingDisposal.length;
@@ -26444,23 +26530,25 @@ var Ai = class extends Jr {
this.disposed || (this.bufferManager.dispose(), this.textureManager.dispose(), this.disposed = true);
}
};
-Ai.nextDataId = 0;
-Kl() && pi("webgpu", async () => {
- P().set("CHECK_COMPUTATION_FOR_ERRORS", false);
- let r = { powerPreference: P().get("WEBGPU_USE_LOW_POWER_GPU") ? "low-power" : "high-performance" }, e = await navigator.gpu.requestAdapter(r), t10 = e.limits, o = {}, n = e.features.has("timestamp-query");
- o.requiredLimits = { maxComputeWorkgroupStorageSize: t10.maxComputeWorkgroupStorageSize, maxComputeWorkgroupsPerDimension: t10.maxComputeWorkgroupsPerDimension, maxStorageBufferBindingSize: t10.maxStorageBufferBindingSize }, n && (o.requiredFeatures = ["timestamp-query"]);
- let s = await e.requestDevice(o), a = await e.requestAdapterInfo();
- return new Ai(s, a);
+Ui.nextDataId = 0;
+Bl() && Ci("webgpu", async () => {
+ O().set("CHECK_COMPUTATION_FOR_ERRORS", false);
+ let r = { powerPreference: O().get("WEBGPU_USE_LOW_POWER_GPU") ? "low-power" : "high-performance" }, e = await navigator.gpu.requestAdapter(r), t6 = {};
+ e.features.has("timestamp-query-inside-passes") && (t6.requiredFeatures = ["timestamp-query-inside-passes"]);
+ let o = e.limits;
+ t6.requiredLimits = { maxComputeWorkgroupStorageSize: o.maxComputeWorkgroupStorageSize, maxComputeWorkgroupsPerDimension: o.maxComputeWorkgroupsPerDimension, maxStorageBufferBindingSize: o.maxStorageBufferBindingSize };
+ let n = await e.requestDevice(t6), s = await e.requestAdapterInfo();
+ return new Ui(n, s);
}, 3);
var ye;
(function(r) {
- r[r.MUL = 0] = "MUL", r[r.ADD = 1] = "ADD", r[r.ATAN2 = 2] = "ATAN2", r[r.SUB = 3] = "SUB", r[r.DIV = 4] = "DIV", r[r.EQUAL = 5] = "EQUAL", r[r.GREATER = 6] = "GREATER", r[r.GREATER_EQUAL = 7] = "GREATER_EQUAL", r[r.LESS = 8] = "LESS", r[r.LESS_EQUAL = 9] = "LESS_EQUAL", r[r.LOGICAL_AND = 10] = "LOGICAL_AND", r[r.NOT_EQUAL = 11] = "NOT_EQUAL", r[r.SQUARED_DIFFERENCE = 12] = "SQUARED_DIFFERENCE", r[r.INT_DIV = 13] = "INT_DIV", r[r.POW = 14] = "POW", r[r.PRELU = 15] = "PRELU", r[r.MAX = 16] = "MAX", r[r.MIN = 17] = "MIN", r[r.COMPLEX_MULTIPLY_REAL = 18] = "COMPLEX_MULTIPLY_REAL", r[r.COMPLEX_MULTIPLY_IMAG = 19] = "COMPLEX_MULTIPLY_IMAG";
+ r[r.ADD = 0] = "ADD", r[r.ATAN2 = 1] = "ATAN2", r[r.COMPLEX_MULTIPLY_IMAG = 2] = "COMPLEX_MULTIPLY_IMAG", r[r.COMPLEX_MULTIPLY_REAL = 3] = "COMPLEX_MULTIPLY_REAL", r[r.DIV = 4] = "DIV", r[r.EQUAL = 5] = "EQUAL", r[r.GREATER = 6] = "GREATER", r[r.GREATER_EQUAL = 7] = "GREATER_EQUAL", r[r.INT_DIV = 8] = "INT_DIV", r[r.LESS = 9] = "LESS", r[r.LESS_EQUAL = 10] = "LESS_EQUAL", r[r.LOGICAL_AND = 11] = "LOGICAL_AND", r[r.MAX = 12] = "MAX", r[r.MIN = 13] = "MIN", r[r.MOD = 14] = "MOD", r[r.MUL = 15] = "MUL", r[r.NOT_EQUAL = 16] = "NOT_EQUAL", r[r.POW = 17] = "POW", r[r.PRELU = 18] = "PRELU", r[r.SQUARED_DIFFERENCE = 19] = "SQUARED_DIFFERENCE", r[r.SUB = 20] = "SUB";
})(ye || (ye = {}));
-var bte = `
+var D3 = `
if (isnan(a)) { return a; }
if (isnan(b)) { return b; }
`;
-var tM = `
+var O3 = `
if (isNaN.r) {
resultTemp.r = valueForNaN;
}
@@ -26474,37 +26562,27 @@ var tM = `
resultTemp.a = valueForNaN;
}
`;
-var rM = `
+var aI = `
let isNaN = isnanVec4(a) | isnanVec4(b);
- ${tM}
+ ${O3}
`;
-var Cte = "return a + b;";
-var Ite = "return areal * breal - aimag * bimag;";
-var wte = "return areal * bimag + aimag * breal;";
-var Ste = "return a / b;";
-var vte = "return a * b;";
-var kte = "return (a - b) * (a - b);";
-var Tte = "return a - b;";
-var Nte = "return f32(a == b);";
-var _te = "return vec4(a == b);";
-var Ete = "return f32(a > b);";
-var $te = "return vec4(a > b);";
-var Rte = "return f32(a >= b);";
-var Ate = "return vec4(a >= b);";
-var Fte = "return f32(a < b);";
-var Dte = "return vec4(a < b);";
-var Pte = "return f32(a <= b);";
-var Ote = "return vec4(a <= b);";
-var Mte = "return f32(f32(a) >= 1.0 && f32(b) >= 1.0);";
-var Lte = `return (vec4(a >= vec4(1.0)) *
- vec4(b >= vec4(1.0)));`;
-var Bte = `
+var Uee = "return a + b;";
+var Gee = "return areal * breal - aimag * bimag;";
+var Hee = "return areal * bimag + aimag * breal;";
+var qee = "return a / b;";
+var Kee = "return f32(a == b);";
+var jee = "return vec4(a == b);";
+var Xee = "return f32(a > b);";
+var Yee = "return vec4(a > b);";
+var Qee = "return f32(a >= b);";
+var Zee = "return vec4(a >= b);";
+var Jee = `
let s = sign(a) * sign(b);
let ia = i32(round(a));
let ib = i32(round(b));
return f32(idiv(ia, ib, s));
- `;
-var Vte = `
+`;
+var ete = `
let ia = vec4(round(a));
let ib = vec4(round(b));
let cond = ib != vec4(0);
@@ -26525,21 +26603,74 @@ var Vte = `
resultTemp[3] = idiv(ia[3], ib[3], s[3]);
}
return vec4(resultTemp);
- `;
-var zte = `
+`;
+var tte = "return f32(a < b);";
+var rte = "return vec4(a < b);";
+var ote = "return f32(a <= b);";
+var nte = "return vec4(a <= b);";
+var ste = "return f32(f32(a) >= 1.0 && f32(b) >= 1.0);";
+var ate = `return (vec4(a >= vec4(1.0)) *
+ vec4(b >= vec4(1.0)));`;
+var ite = `
+ ${D3}
+ if (b == 0.) {
+ return uniforms.NAN;
+ }
+ var resultTemp = a % b;
+ if ((a < 0. && b < 0.) || (a >= 0. && b > 0.)) {
+ return resultTemp;
+ } else {
+ return (resultTemp + b) % b;
+ }
+`;
+var ute = `
+ let valueForNaN = uniforms.NAN;
+ var resultTemp = vec4(a % b);
+ ${aI}
+
+ if (b[0] == 0.) {
+ resultTemp[0] = uniforms.NAN;
+ }
+ if (b[1] == 0.) {
+ resultTemp[1] = uniforms.NAN;
+ }
+ if (b[2] == 0.) {
+ resultTemp[2] = uniforms.NAN;
+ }
+ if (b[3] == 0.) {
+ resultTemp[3] = uniforms.NAN;
+ }
+
+ if (!((a[0] < 0. && b[0] < 0.) || (a[0] >= 0. && b[0] > 0.))) {
+ resultTemp[0] = (resultTemp[0] + b[0]) % b[0];
+ }
+ if (!((a[1] < 0. && b[1] < 0.) || (a[1] >= 0. && b[1] > 0.))) {
+ resultTemp[1] = (resultTemp[1] + b[1]) % b[1];
+ }
+ if (!((a[2] < 0. && b[2] < 0.) || (a[2] >= 0. && b[2] > 0.))) {
+ resultTemp[2] = (resultTemp[2] + b[2]) % b[2];
+ }
+ if (!((a[3] < 0. && b[3] < 0.) || (a[3] >= 0. && b[3] > 0.))) {
+ resultTemp[3] = (resultTemp[3] + b[3]) % b[3];
+ }
+
+ return resultTemp;
+`;
+var pte = "return a * b;";
+var cte = `
if (isnan(a) || isnan(b)) {
return 1.0;
}
return f32(a != b);
`;
-var Wte = `
+var lte = `
var resultTemp = vec4(a != b);
let valueForNaN = 1.0;
- ${rM}
+ ${aI}
return resultTemp;
`;
-var Ute = `
+var mte = `
if(a < 0.0 && floor(b) < b) {
return uniforms.NAN;
}
@@ -26550,8 +26681,8 @@ var Ute = `
return pow(abs(a), b);
}
return sign(a) * pow(abs(a), b);
- `;
-var Gte = `
+`;
+var dte = `
let isModRound1Bool = vec4(round(abs(b) % vec4(2.0))) == vec4(1);
let isModRound1 = vec4(isModRound1Bool);
let multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);
@@ -26573,18 +26704,20 @@ var Gte = `
}
let isNaN = (a < vec4(0.0)) & (floor(b) < b);
let valueForNaN = uniforms.NAN;
- ${tM}
+ ${O3}
return resultTemp;
- `;
-var Hte = "if (a < 0.0) { return b * a; } return a;";
-var qte = `
+`;
+var fte = "if (a < 0.0) { return b * a; } return a;";
+var hte = `
let aLessThanZero = vec4(a < vec4(0.0));
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
- `;
-function cS(r, e, t10 = "uniforms.NAN") {
- let o = e ? rM : bte;
+`;
+var gte = "return (a - b) * (a - b);";
+var xte = "return a - b;";
+function sI(r, e, t6 = "uniforms.NAN") {
+ let o = e ? aI : D3;
return e ? `
- let valueForNaN = ${t10};
+ let valueForNaN = ${t6};
var resultTemp = vec4(${r}(a, b));
` + o + `
return resultTemp;
@@ -26592,66 +26725,105 @@ function cS(r, e, t10 = "uniforms.NAN") {
return ${r}(a, b);
`;
}
-function Nc(r, e) {
+function Ic(r, e) {
switch (r) {
- case ye.MUL:
- return vte;
case ye.ADD:
- return Cte;
+ return Uee;
case ye.ATAN2:
- return cS("atan2", e);
- case ye.SUB:
- return Tte;
- case ye.DIV:
- return Ste;
- case ye.EQUAL:
- return e ? _te : Nte;
- case ye.GREATER:
- return e ? $te : Ete;
- case ye.GREATER_EQUAL:
- return e ? Ate : Rte;
- case ye.LESS:
- return e ? Dte : Fte;
- case ye.LESS_EQUAL:
- return e ? Ote : Pte;
- case ye.LOGICAL_AND:
- return e ? Lte : Mte;
- case ye.NOT_EQUAL:
- return e ? Wte : zte;
- case ye.SQUARED_DIFFERENCE:
- return kte;
- case ye.INT_DIV:
- return e ? Vte : Bte;
- case ye.PRELU:
- return e ? qte : Hte;
- case ye.MAX:
- return cS("max", e);
- case ye.MIN:
- return cS("min", e);
- case ye.POW:
- return e ? Gte : Ute;
- case ye.COMPLEX_MULTIPLY_REAL:
- return Ite;
+ return sI("atan2", e);
case ye.COMPLEX_MULTIPLY_IMAG:
- return wte;
+ return Hee;
+ case ye.COMPLEX_MULTIPLY_REAL:
+ return Gee;
+ case ye.DIV:
+ return qee;
+ case ye.EQUAL:
+ return e ? jee : Kee;
+ case ye.GREATER:
+ return e ? Yee : Xee;
+ case ye.GREATER_EQUAL:
+ return e ? Zee : Qee;
+ case ye.INT_DIV:
+ return e ? ete : Jee;
+ case ye.LESS:
+ return e ? rte : tte;
+ case ye.LESS_EQUAL:
+ return e ? nte : ote;
+ case ye.LOGICAL_AND:
+ return e ? ate : ste;
+ case ye.MAX:
+ return sI("max", e);
+ case ye.MIN:
+ return sI("min", e);
+ case ye.MOD:
+ return e ? ute : ite;
+ case ye.MUL:
+ return pte;
+ case ye.NOT_EQUAL:
+ return e ? lte : cte;
+ case ye.POW:
+ return e ? dte : mte;
+ case ye.PRELU:
+ return e ? hte : fte;
+ case ye.SQUARED_DIFFERENCE:
+ return gte;
+ case ye.SUB:
+ return xte;
default:
throw new Error(`BinaryType ${r} is not implemented!`);
}
}
-var pe;
+var Q;
(function(r) {
- r[r.ABS = 0] = "ABS", r[r.CEIL = 1] = "CEIL", r[r.COS = 2] = "COS", r[r.COSH = 3] = "COSH", r[r.ELU = 4] = "ELU", r[r.EXP = 5] = "EXP", r[r.EXPM1 = 6] = "EXPM1", r[r.FLOOR = 7] = "FLOOR", r[r.IS_NAN = 8] = "IS_NAN", r[r.LINEAR = 9] = "LINEAR", r[r.LOG = 10] = "LOG", r[r.LOGICAL_NOT = 11] = "LOGICAL_NOT", r[r.NEG = 12] = "NEG", r[r.RELU = 13] = "RELU", r[r.RELU6 = 14] = "RELU6", r[r.LEAKYRELU = 15] = "LEAKYRELU", r[r.RECIPROCAL = 16] = "RECIPROCAL", r[r.RSQRT = 17] = "RSQRT", r[r.SIN = 18] = "SIN", r[r.SINH = 19] = "SINH", r[r.SIGMOID = 20] = "SIGMOID", r[r.SQRT = 21] = "SQRT", r[r.SQUARE = 22] = "SQUARE", r[r.TANH = 23] = "TANH", r[r.TO_INT = 24] = "TO_INT";
-})(pe || (pe = {}));
-var Kte = "return abs(a);";
-var jte = "return ceil(a);";
-var Xte = "return cos(a);";
-var Yte = `
+ r[r.ABS = 0] = "ABS", r[r.ACOS = 1] = "ACOS", r[r.ACOSH = 2] = "ACOSH", r[r.ASIN = 3] = "ASIN", r[r.ASINH = 4] = "ASINH", r[r.ATAN = 5] = "ATAN", r[r.ATANH = 6] = "ATANH", r[r.CEIL = 7] = "CEIL", r[r.COS = 8] = "COS", r[r.COSH = 9] = "COSH", r[r.ELU = 10] = "ELU", r[r.ERF = 11] = "ERF", r[r.EXP = 12] = "EXP", r[r.EXPM1 = 13] = "EXPM1", r[r.FLOOR = 14] = "FLOOR", r[r.IS_FINITE = 15] = "IS_FINITE", r[r.IS_INF = 16] = "IS_INF", r[r.IS_NAN = 17] = "IS_NAN", r[r.LINEAR = 18] = "LINEAR", r[r.LOG = 19] = "LOG", r[r.LOG1P = 20] = "LOG1P", r[r.LOGICAL_NOT = 21] = "LOGICAL_NOT", r[r.NEG = 22] = "NEG", r[r.RELU = 23] = "RELU", r[r.RELU6 = 24] = "RELU6", r[r.LEAKYRELU = 25] = "LEAKYRELU", r[r.RECIPROCAL = 26] = "RECIPROCAL", r[r.RSQRT = 27] = "RSQRT", r[r.SIN = 28] = "SIN", r[r.SINH = 29] = "SINH", r[r.SIGMOID = 30] = "SIGMOID", r[r.SQRT = 31] = "SQRT", r[r.SQUARE = 32] = "SQUARE", r[r.TAN = 33] = "TAN", r[r.TANH = 34] = "TANH", r[r.TO_INT = 35] = "TO_INT";
+})(Q || (Q = {}));
+var yte = "return abs(a);";
+var bte = `
+ if (abs(a) > 1.) {
+ return uniforms.NAN;
+ }
+ return acos(a);
+`;
+var Cte = `
+ if (a < 1.) {
+ return uniforms.NAN;
+ }
+ return acosh(a);
+`;
+var Ste = `
+ if (abs(a) > 1.) {
+ return uniforms.NAN;
+ }
+ return asin(a);
+`;
+var wte = "return asinh(a);";
+var Ite = `
+ if (isnan(a)) {
+ return uniforms.NAN;
+ }
+ return atan(a);
+`;
+var vte = `
+ if (abs(a) > 1.) {
+ return uniforms.NAN;
+ }
+ if (a == 1.) {
+ return uniforms.INFINITY;
+ }
+ if (a == -1.) {
+ return -uniforms.INFINITY;
+ }
+ return atanh(a);
+`;
+var kte = "return ceil(a);";
+var Nte = "return cos(a);";
+var Tte = `
let e2x = exp(-a);
return (e2x + 1.0 / e2x) / 2.0;
`;
-var Qte = "return exp(a) - 1.0;";
-var Zte = "if (a >= 0.0) { return a; } return (exp(a) - 1.0);";
-var Jte = `
+var _te = "return exp(a) - 1.0;";
+var Ete = "if (a >= 0.0) { return a; } return (exp(a) - 1.0);";
+var $te = `
var resFloat = exp(a) - vec4(1.0);
if (a.r >= 0.0) {
resFloat.r = a.r;
@@ -26667,97 +26839,142 @@ var Jte = `
}
return resFloat;
`;
-var ere = "return exp(a);";
-var tre = "return floor(a);";
-var rre = "return f32(isnan(a));";
-var ore = "return a;";
-var nre = `if (a < 0.0) { return uniforms.NAN; }
+var Ate = `
+ // Error function is calculated approximately with elementary function.
+ // See "Handbook of Mathematical Functions with Formulas,
+ // Graphs, and Mathematical Tables", Abramowitz and Stegun.
+ let p = ${S.ERF_P};
+ let a1 = ${S.ERF_A1};
+ let a2 = ${S.ERF_A2};
+ let a3 = ${S.ERF_A3};
+ let a4 = ${S.ERF_A4};
+ let a5 = ${S.ERF_A5};
+
+ let sign = sign(a);
+ let absA = abs(a);
+ let t = 1.0 / (1.0 + p * absA);
+ return sign * (1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * exp(-absA * absA));
+`;
+var Rte = "return exp(a);";
+var Fte = "return floor(a);";
+var Dte = "return f32(!isnan(a) && !isinf(a));";
+var Ote = "return f32(isinf(a));";
+var Pte = "return f32(isnan(a));";
+var Mte = "return a;";
+var Lte = `if (a < 0.0) { return uniforms.NAN; }
return log(a);`;
-var sre = "return f32(!(a >= 1.0));";
-var are = "return -a;";
-var ire = "if (a < 0.0) { return uniforms.alpha * a; } return a;";
-var ure = `
+var Bte = `
+ if (isnan(a)) { return a; }
+ return log(1.0 + a);
+`;
+var Vte = "return f32(!(a >= 1.0));";
+var zte = "return -a;";
+var Wte = "if (a < 0.0) { return uniforms.alpha * a; } return a;";
+var Ute = `
let aLessThanZero = vec4(a < vec4(0.0));
return (aLessThanZero * (uniforms.alpha * a)) + ((vec4(1.0) - aLessThanZero) * a);
`;
-var pre = "return 1.0 / a;";
-var cre = "return select(a, 0.0, a < 0.0);";
-var lre = "return clamp(a, 0.0, 6.0);";
-var mre = "return clamp(a, vec4(0.0, 0.0, 0.0, 0.0), vec4(6.0, 6.0, 6.0, 6.0));";
-var fre = `
+var Gte = "return 1.0 / a;";
+var Hte = "return select(a, 0.0, a < 0.0);";
+var qte = "return clamp(a, 0.0, 6.0);";
+var Kte = "return clamp(a, vec4(0.0, 0.0, 0.0, 0.0), vec4(6.0, 6.0, 6.0, 6.0));";
+var jte = `
return select(a, vec4(0.0), a < vec4(0.0));
`;
-var dre = "return 1.0/sqrt(a);";
-var hre = "return 1.0 / (1.0 + exp(-1.0 * a));";
-var gre = "return sin(a);";
-var xre = `
+var Xte = "return inverseSqrt(a);";
+var Yte = "return 1.0 / (1.0 + exp(-1.0 * a));";
+var Qte = "return sin(a);";
+var Zte = `
let e2x = exp(a);
return (e2x - 1.0 / e2x) / 2.0;
`;
-var yre = "return sqrt(a);";
-var bre = "return a * a;";
-var Cre = `
+var Jte = "return sqrt(a);";
+var ere = "return a * a;";
+var tre = "return tan(a);";
+var rre = `
let e2x = exp(-2.0 * abs(a));
return sign(a) * (1.0 - e2x) / (1.0 + e2x);
`;
-var Ire = "return f32(i32((a)));";
-function za(r, e) {
+var ore = "return f32(i32((a)));";
+function Ha(r, e) {
switch (r) {
- case pe.ABS:
- return Kte;
- case pe.COS:
+ case Q.ABS:
+ return yte;
+ case Q.ACOS:
+ return bte;
+ case Q.ACOSH:
+ return Cte;
+ case Q.ASIN:
+ return Ste;
+ case Q.ASINH:
+ return wte;
+ case Q.ATAN:
+ return Ite;
+ case Q.ATANH:
+ return vte;
+ case Q.COS:
+ return Nte;
+ case Q.COSH:
+ return Tte;
+ case Q.CEIL:
+ return kte;
+ case Q.ELU:
+ return e ? $te : Ete;
+ case Q.ERF:
+ return Ate;
+ case Q.EXP:
+ return Rte;
+ case Q.EXPM1:
+ return _te;
+ case Q.FLOOR:
+ return Fte;
+ case Q.IS_FINITE:
+ return Dte;
+ case Q.IS_INF:
+ return Ote;
+ case Q.IS_NAN:
+ return Pte;
+ case Q.LINEAR:
+ return Mte;
+ case Q.LOG:
+ return Lte;
+ case Q.LOG1P:
+ return Bte;
+ case Q.LOGICAL_NOT:
+ return Vte;
+ case Q.NEG:
+ return zte;
+ case Q.LEAKYRELU:
+ return e ? Ute : Wte;
+ case Q.RECIPROCAL:
+ return Gte;
+ case Q.RELU:
+ return e ? jte : Hte;
+ case Q.RELU6:
+ return e ? Kte : qte;
+ case Q.RSQRT:
return Xte;
- case pe.COSH:
+ case Q.SIGMOID:
return Yte;
- case pe.CEIL:
- return jte;
- case pe.ELU:
- return e ? Jte : Zte;
- case pe.EXP:
- return ere;
- case pe.EXPM1:
+ case Q.SIN:
return Qte;
- case pe.FLOOR:
+ case Q.SINH:
+ return Zte;
+ case Q.SQRT:
+ return Jte;
+ case Q.SQUARE:
+ return ere;
+ case Q.TAN:
return tre;
- case pe.IS_NAN:
+ case Q.TANH:
return rre;
- case pe.LINEAR:
+ case Q.TO_INT:
return ore;
- case pe.LOG:
- return nre;
- case pe.LOGICAL_NOT:
- return sre;
- case pe.NEG:
- return are;
- case pe.LEAKYRELU:
- return e ? ure : ire;
- case pe.RECIPROCAL:
- return pre;
- case pe.RELU:
- return e ? fre : cre;
- case pe.RELU6:
- return e ? mre : lre;
- case pe.RSQRT:
- return dre;
- case pe.SIGMOID:
- return hre;
- case pe.SIN:
- return gre;
- case pe.SINH:
- return xre;
- case pe.SQRT:
- return yre;
- case pe.SQUARE:
- return bre;
- case pe.TANH:
- return Cre;
- case pe.TO_INT:
- return Ire;
default:
throw new Error(`BinaryType ${r} is not implemented!`);
}
}
-var vt = (r) => {
+var kt = (r) => {
switch (r) {
case 1:
return "f32";
@@ -26771,27 +26988,27 @@ var vt = (r) => {
throw new Error(`${r}-component is not supported.`);
}
};
-function ur(r, e = false, t10 = false, o = 3) {
+function ur(r, e = false, t6 = false, o = 3) {
if (r === null)
return "";
let n = "";
if (r === "linear")
- n = za(pe.LINEAR);
+ n = Ha(Q.LINEAR);
else if (r === "relu")
- n = za(pe.RELU, t10);
+ n = Ha(Q.RELU, t6);
else if (r === "elu")
- n = za(pe.ELU, t10);
+ n = Ha(Q.ELU, t6);
else if (r === "relu6")
- n = za(pe.RELU6, t10);
+ n = Ha(Q.RELU6, t6);
else if (r === "prelu")
- n = Nc(ye.PRELU, t10);
+ n = Ic(ye.PRELU, t6);
else if (r === "sigmoid")
- n = za(pe.SIGMOID, t10);
+ n = Ha(Q.SIGMOID, t6);
else if (r === "leakyrelu")
- n = za(pe.LEAKYRELU, t10);
+ n = Ha(Q.LEAKYRELU, t6);
else
throw new Error(`Activation ${r} has not been implemented for the WebGPU backend.`);
- let a = vt(t10 ? 4 : 1), i = "";
+ let a = kt(t6 ? 4 : 1), i = "";
return e ? i = `
fn activation(a : ${a}, coords : vec${o}) -> ${a} {
let b = getPreluActivationWeightsByOutputCoords(coords);
@@ -26801,25 +27018,25 @@ function ur(r, e = false, t10 = false, o = 3) {
${n}
}`, i;
}
-function Kr(r, e) {
+function Hr(r, e) {
return `
${r ? "value = value + getBiasByOutputCoords(coords);" : ""}
${e ? "value = activation(value, coords);" : ""}
`;
}
-function lS(r, e, t10, o, n = false, s = false, a = false, i = 1) {
- x.assert(t10 && i === 1 || !t10, () => `transposeA ${t10} is not compatible with component size ${i}`);
+function iI(r, e, t6, o, n = false, s = false, a = false, i = 1) {
+ y.assert(t6 && i === 1 || !t6, () => `transposeA ${t6} is not compatible with component size ${i}`);
let p = `
let batch = ${r ? "0" : "batchIn"};
- ${t10 ? "value = getA(batch, col, row);" : "value = getA(batch, row, col);"}
+ ${t6 ? "value = getA(batch, col, row);" : "value = getA(batch, row, col);"}
`, u = o ? "value = getB(batch, col, row);" : "value = getB(batch, row, col);";
return `
- fn mm_readA(batchIn: i32, row: i32, colIn: i32) -> ${vt(i)} {
- var value = ${vt(i)}(0.0);
+ fn mm_readA(batchIn: i32, row: i32, colIn: i32) -> ${kt(i)} {
+ var value = ${kt(i)}(0.0);
let col = colIn * ${i};
${n && a ? p : `
- ${t10 ? "if(row < uniforms.dimAOuter && col < uniforms.dimInner)" : "if(row < uniforms.aShape[1] && col < uniforms.aShape[2])"}
+ ${t6 ? "if(row < uniforms.dimAOuter && col < uniforms.dimInner)" : "if(row < uniforms.aShape[1] && col < uniforms.aShape[2])"}
{
${p}
}
@@ -26827,101 +27044,93 @@ function lS(r, e, t10, o, n = false, s = false, a = false, i = 1) {
return value;
}
- fn mm_readB(batchIn: i32, row: i32, colIn: i32) -> ${vt(i)} {
+ fn mm_readB(batchIn: i32, row: i32, colIn: i32) -> ${kt(i)} {
let col = colIn * ${i};
let batch = ${e ? "0" : "batchIn"};
- var value = ${vt(i)}(0.0);
+ var value = ${kt(i)}(0.0);
${u}
return value;
}
`;
}
-function jl(r, e, t10, o, n, s, a = false, i = false, p = false, u = 1) {
+function Vl(r, e, t6, o, n, s, a = false, i = false, p = false, u = 1) {
return `
- ${lS(t10, o, n, s, a, i, p, u)}
- fn mm_write(batch: i32, row: i32, colIn: i32, valueIn: ${vt(u)}) {
+ ${iI(t6, o, n, s, a, i, p, u)}
+ fn mm_write(batch: i32, row: i32, colIn: i32, valueIn: ${kt(u)}) {
let col = colIn * ${u};
${a && i ? "" : "if (row < uniforms.dimAOuter && col < uniforms.dimBOuter)"}
{
var value = valueIn;
let coords = vec3(batch, row, col);
- ${Kr(r, e)}
+ ${Hr(r, e)}
setOutputAtCoords(coords[0], coords[1], coords[2], value);
}
}
`;
}
-var wre = (r) => r ? `
+var nre = (r) => r ? `
mm_Asub[inputRow][inputCol] = mm_readA(batch,
kStart + inputRow,
- globalRowStart / InnerElementSize + inputCol);
+ globalRowStart / innerElementSize + inputCol);
` : `
mm_Asub[inputRow][inputCol] = mm_readA(batch,
globalRow + innerRow,
- kStart / InnerElementSize + inputCol);
+ kStart / innerElementSize + inputCol);
`;
-var Sre = (r, e) => r ? `
- let ACached0 = mm_Asub[k * InnerElementSize][localRow];
- let ACached1 = mm_Asub[k * InnerElementSize + 1][localRow];
- let ACached2 = mm_Asub[k * InnerElementSize + 2][localRow];
- ${e === 3 ? "" : "let ACached3 = mm_Asub[k * InnerElementSize + 3][localRow];"}
- for (var i = 0; i < RowPerThread; i = i + 1) {
+var sre = (r, e) => r ? `
+ let ACached0 = mm_Asub[k * innerElementSize][localRow];
+ let ACached1 = mm_Asub[k * innerElementSize + 1][localRow];
+ let ACached2 = mm_Asub[k * innerElementSize + 2][localRow];
+ ${e === 3 ? "" : "let ACached3 = mm_Asub[k * innerElementSize + 3][localRow];"}
+ for (var i = 0; i < rowPerThread; i = i + 1) {
acc[i] = BCached0 * ACached0[i] + acc[i];
acc[i] = BCached1 * ACached1[i] + acc[i];
acc[i] = BCached2 * ACached2[i] + acc[i];
${e === 3 ? "" : "acc[i] = BCached3 * ACached3[i] + acc[i];"}
}` : `
- for (var i = 0; i < RowPerThread; i = i + 1) {
+ for (var i = 0; i < rowPerThread; i = i + 1) {
let ACached = mm_Asub[tileRow + i][k];
acc[i] = BCached0 * ACached.x + acc[i];
acc[i] = BCached1 * ACached.y + acc[i];
acc[i] = BCached2 * ACached.z + acc[i];
${e === 3 ? "" : "acc[i] = BCached3 * ACached.w + acc[i];"}
}`;
-function Uu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
- let i = e[1] * r[1], p = e[0] * r[0], u = t10 ? i : o, c = t10 ? o : i, l = u / e[0], m = o / e[1];
- return x.assert((t10 && l === 4 && r[1] === 4 || !t10 && (l === 3 || l === 4)) && u % e[0] === 0 && o % e[1] === 0 && r[0] === 4, () => `If transposeA ${t10} is true, innerElementSize ${l} and workPerThread[1] ${r[1]} must be 4.
+function Wu(r, e, t6 = false, o = 32, n = false, s = 32, a = false) {
+ let i = e[1] * r[1], p = e[0] * r[0], u = t6 ? i : o, c = t6 ? o : i, l = u / e[0], m = o / e[1];
+ return y.assert((t6 && l === 4 && r[1] === 4 || !t6 && (l === 3 || l === 4)) && u % e[0] === 0 && o % e[1] === 0 && r[0] === 4, () => `If transposeA ${t6} is true, innerElementSize ${l} and workPerThread[1] ${r[1]} must be 4.
Otherwise, innerElementSize ${l} must be 3 or 4.
- tileAWidth ${u} must be divisible by workGroupSize[0]${e[0]}. tileInner ${o} must be divisible by workGroupSize[1] ${e[1]}. ColPerThread ${r[0]} must be 4.`), `
+ tileAWidth ${u} must be divisible by workgroupSize[0]${e[0]}. tileInner ${o} must be divisible by workgroupSize[1] ${e[1]}. colPerThread ${r[0]} must be 4.`), `
var mm_Asub : array, ${u / l}>, ${c}>;
var mm_Bsub : array, ${p / r[0]}>, ${o}>;
- const RowPerThread = ${r[1]};
- const ColPerThread = ${r[0]};
- const InnerElementSize = ${l};
- const TileInner = ${o};
-
- @compute @workgroup_size(workGroupSizeX, workGroupSizeY, workGroupSizeZ)
- fn _start(@builtin(local_invocation_id) LocalId : vec3,
- @builtin(global_invocation_id) GlobalId : vec3,
- @builtin(num_workgroups) NumWorkgroups: vec3,
- @builtin(workgroup_id) workgroupId: vec3) {
- localId = LocalId;
- globalId = GlobalId;
- numWorkgroups = NumWorkgroups;
+ const rowPerThread = ${r[1]};
+ const colPerThread = ${r[0]};
+ const innerElementSize = ${l};
+ const tileInner = ${o};
+ ${se()} {
let localRow = i32(localId.y);
- let tileRow = ${a ? "0" : "localRow * RowPerThread"};
+ let tileRow = ${a ? "0" : "localRow * rowPerThread"};
let tileCol = i32(localId.x);
- let globalRow = ${a ? "0" : "i32(globalId.y) * RowPerThread"};
+ let globalRow = ${a ? "0" : "i32(globalId.y) * rowPerThread"};
let globalCol = i32(globalId.x);
let batch = ${n ? "0" : "i32(globalId.z)"};
let globalRowStart = i32(workgroupId.y) * ${i};
- let numTiles = ${n ? `${Math.ceil(s / o)}` : "(uniforms.dimInner - 1) / TileInner + 1"};
+ let numTiles = ${n ? `${Math.ceil(s / o)}` : "(uniforms.dimInner - 1) / tileInner + 1"};
var kStart = ${n ? `i32(globalId.z) * ${s}` : "0"};
- var acc: array, RowPerThread>;
+ var acc: array, rowPerThread>;
// Loop over shared dimension.
let tileRowB = localRow * ${m};
for (var t = 0; t < numTiles; t = t + 1) {
// Load one tile of A into local memory.
- for (var innerRow = 0; innerRow < RowPerThread; innerRow = innerRow + 1) {
+ for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
let inputRow = tileRow + innerRow;
let inputCol = tileCol;
- ${wre(t10)}
+ ${nre(t6)}
}
// Load one tile of B into local memory.
@@ -26930,28 +27139,28 @@ function Uu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
let inputCol = tileCol;
mm_Bsub[inputRow][inputCol] = mm_readB(batch, kStart + inputRow, globalCol);
}
- kStart = kStart + TileInner;
+ kStart = kStart + tileInner;
workgroupBarrier();
// Compute acc values for a single thread.
- for (var k = 0; k < TileInner / InnerElementSize; k = k + 1) {
- let BCached0 = mm_Bsub[k * InnerElementSize][tileCol];
- let BCached1 = mm_Bsub[k * InnerElementSize + 1][tileCol];
- let BCached2 = mm_Bsub[k * InnerElementSize + 2][tileCol];
- ${l === 3 ? "" : "let BCached3 = mm_Bsub[k * InnerElementSize + 3][tileCol];"}
+ for (var k = 0; k < tileInner / innerElementSize; k = k + 1) {
+ let BCached0 = mm_Bsub[k * innerElementSize][tileCol];
+ let BCached1 = mm_Bsub[k * innerElementSize + 1][tileCol];
+ let BCached2 = mm_Bsub[k * innerElementSize + 2][tileCol];
+ ${l === 3 ? "" : "let BCached3 = mm_Bsub[k * innerElementSize + 3][tileCol];"}
- ${Sre(t10, l)}
+ ${sre(t6, l)}
}
workgroupBarrier();
}
- for (var innerRow = 0; innerRow < RowPerThread; innerRow = innerRow + 1) {
+ for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
mm_write(batch, globalRow + innerRow, globalCol, acc[innerRow]);
}
}`;
}
-var oM = (r) => r ? `
+var P3 = (r) => r ? `
mm_Asub[inputRow][inputCol] = mm_readA(batch,
kStart + inputRow,
globalRowStart + inputCol);
@@ -26960,11 +27169,11 @@ var oM = (r) => r ? `
globalRowStart + inputRow,
kStart + inputCol);
`;
-var vre = (r) => r ? "let ACached = mm_Asub[k][tileRow + innerRow];" : "let ACached = mm_Asub[tileRow + innerRow][k];";
-function Gu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
- let i = r[1] * e[1], p = r[0] * e[0], u = t10 ? i : o, c = t10 ? o : i;
- x.assert(c % e[1] === 0 && u % e[0] === 0 && o % e[1] === 0, () => `tileAHight ${c} must be divisible by workGroupSize[1]${e[1]}, tileAWidth ${u} must be divisible by workGroupSize[0]${e[0]}, tileInner ${o} must be divisible by workGroupSize[1]${e[1]}`);
- let l = c / e[1], m = u / e[0], f = o / e[1], d = a ? `
+var are = (r) => r ? "let ACached = mm_Asub[k][tileRow + innerRow];" : "let ACached = mm_Asub[tileRow + innerRow][k];";
+function Uu(r, e, t6 = false, o = 32, n = false, s = 32, a = false) {
+ let i = r[1] * e[1], p = r[0] * e[0], u = t6 ? i : o, c = t6 ? o : i;
+ y.assert(c % e[1] === 0 && u % e[0] === 0 && o % e[1] === 0, () => `tileAHight ${c} must be divisible by workgroupSize[1]${e[1]}, tileAWidth ${u} must be divisible by workgroupSize[0]${e[0]}, tileInner ${o} must be divisible by workgroupSize[1]${e[1]}`);
+ let l = c / e[1], m = u / e[0], d = o / e[1], f = a ? `
let localRow = i32(localId.y);
let localCol = i32(localId.x);
let globalRowStart = i32(workgroupId.y) * ${i};
@@ -26975,7 +27184,7 @@ function Gu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
// Load one tile of A into local memory.
for (var inputRow = localRow; inputRow < ${c}; inputRow = inputRow + ${e[1]}) {
for (var inputCol = localCol; inputCol < ${u}; inputCol = inputCol + ${e[0]}) {
- ${oM(t10)}
+ ${P3(t6)}
}
}
// Load one tile of B into local memory.
@@ -26986,18 +27195,18 @@ function Gu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
globalColStart + inputCol);
}
}
- kStart = kStart + TileInner;
+ kStart = kStart + tileInner;
workgroupBarrier();
// Compute acc values for a single thread.
- var BCached : array;
- for (var k = 0; k < TileInner; k = k + 1) {
- for (var inner = 0; inner < ColPerThread; inner = inner + 1) {
+ var BCached : array;
+ for (var k = 0; k < tileInner; k = k + 1) {
+ for (var inner = 0; inner < colPerThread; inner = inner + 1) {
BCached[inner] = mm_Bsub[k][localCol + inner * ${e[0]}];
}
- for (var innerRow = 0; innerRow < RowPerThread; innerRow = innerRow + 1) {
- let ACached = ${t10 ? `mm_Asub[k][localRow + innerRow * ${e[1]}];` : `mm_Asub[localRow + innerRow * ${e[1]}][k];`}
- for (var innerCol = 0; innerCol < ColPerThread; innerCol = innerCol + 1) {
+ for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
+ let ACached = ${t6 ? `mm_Asub[k][localRow + innerRow * ${e[1]}];` : `mm_Asub[localRow + innerRow * ${e[1]}][k];`}
+ for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
acc[innerRow][innerCol] = acc[innerRow][innerCol] +
ACached * BCached[innerCol];
}
@@ -27005,24 +27214,24 @@ function Gu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
}
workgroupBarrier();
}
- for (var innerRow = 0; innerRow < RowPerThread; innerRow = innerRow + 1) {
+ for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
let gRow = globalRowStart + localRow + innerRow * ${e[1]};
- for (var innerCol = 0; innerCol < ColPerThread; innerCol = innerCol + 1) {
+ for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
let gCol = globalColStart + localCol + innerCol * ${e[0]};
mm_write(batch, gRow, gCol, acc[innerRow][innerCol]);
}
}
` : `
- let tileRow = i32(localId.y) * RowPerThread;
- let tileCol = i32(localId.x) * ColPerThread;
+ let tileRow = i32(localId.y) * rowPerThread;
+ let tileCol = i32(localId.x) * colPerThread;
- let globalRow = i32(globalId.y) * RowPerThread;
- let globalCol = i32(globalId.x) * ColPerThread;
+ let globalRow = i32(globalId.y) * rowPerThread;
+ let globalCol = i32(globalId.x) * colPerThread;
let globalRowStart = i32(workgroupId.y) * ${i};
let tileRowA = i32(localId.y) * ${l};
let tileColA = i32(localId.x) * ${m};
- let tileRowB = i32(localId.y) * ${f};
+ let tileRowB = i32(localId.y) * ${d};
// Loop over shared dimension.
for (var t = 0; t < numTiles; t = t + 1) {
// Load one tile of A into local memory.
@@ -27030,13 +27239,13 @@ function Gu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
for (var innerCol = 0; innerCol < ${m}; innerCol = innerCol + 1) {
let inputRow = tileRowA + innerRow;
let inputCol = tileColA + innerCol;
- ${oM(t10)}
+ ${P3(t6)}
}
}
// Load one tile of B into local memory.
- for (var innerRow = 0; innerRow < ${f}; innerRow = innerRow + 1) {
- for (var innerCol = 0; innerCol < ColPerThread; innerCol = innerCol + 1) {
+ for (var innerRow = 0; innerRow < ${d}; innerRow = innerRow + 1) {
+ for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
let inputRow = tileRowB + innerRow;
let inputCol = tileCol + innerCol;
mm_Bsub[inputRow][inputCol] = mm_readB(batch,
@@ -27044,19 +27253,19 @@ function Gu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
globalCol + innerCol);
}
}
- kStart = kStart + TileInner;
+ kStart = kStart + tileInner;
workgroupBarrier();
// Compute acc values for a single thread.
- var BCached : array;
- for (var k = 0; k < TileInner; k = k + 1) {
- for (var inner = 0; inner < ColPerThread; inner = inner + 1) {
+ var BCached : array;
+ for (var k = 0; k < tileInner; k = k + 1) {
+ for (var inner = 0; inner < colPerThread; inner = inner + 1) {
BCached[inner] = mm_Bsub[k][tileCol + inner];
}
- for (var innerRow = 0; innerRow < RowPerThread; innerRow = innerRow + 1) {
- ${vre(t10)}
- for (var innerCol = 0; innerCol < ColPerThread; innerCol = innerCol + 1) {
+ for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
+ ${are(t6)}
+ for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
acc[innerRow][innerCol] = acc[innerRow][innerCol] + ACached * BCached[innerCol];
}
}
@@ -27065,8 +27274,8 @@ function Gu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
workgroupBarrier();
}
- for (var innerRow = 0; innerRow < RowPerThread; innerRow = innerRow + 1) {
- for (var innerCol = 0; innerCol < ColPerThread; innerCol = innerCol + 1) {
+ for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
+ for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
mm_write(batch, globalRow + innerRow, globalCol + innerCol,
acc[innerRow][innerCol]);
}
@@ -27075,36 +27284,28 @@ function Gu(r, e, t10 = false, o = 32, n = false, s = 32, a = false) {
return `
var mm_Asub : array, ${c}>;
var mm_Bsub : array, ${o}>;
- const RowPerThread = ${r[1]};
- const ColPerThread = ${r[0]};
- const TileInner = ${o};
-
- @compute @workgroup_size(workGroupSizeX, workGroupSizeY, workGroupSizeZ)
- fn _start(@builtin(local_invocation_id) LocalId : vec3,
- @builtin(global_invocation_id) GlobalId : vec3,
- @builtin(num_workgroups) NumWorkgroups: vec3,
- @builtin(workgroup_id) workgroupId: vec3) {
- localId = LocalId;
- globalId = GlobalId;
- numWorkgroups = NumWorkgroups;
+ const rowPerThread = ${r[1]};
+ const colPerThread = ${r[0]};
+ const tileInner = ${o};
+ ${se()} {
let batch = ${n ? "0" : "i32(globalId.z)"};
- let numTiles = ${n ? `${Math.ceil(s / o)}` : "(uniforms.dimInner - 1) / TileInner + 1"};
+ let numTiles = ${n ? `${Math.ceil(s / o)}` : "(uniforms.dimInner - 1) / tileInner + 1"};
var kStart = ${n ? `i32(globalId.z) * ${s}` : "0"};
- var acc : array, RowPerThread>;
+ var acc : array, rowPerThread>;
// Without this initialization strange values show up in acc.
- for (var innerRow = 0; innerRow < RowPerThread; innerRow = innerRow + 1) {
- for (var innerCol = 0; innerCol < ColPerThread; innerCol = innerCol + 1) {
+ for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
+ for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
acc[innerRow][innerCol] = 0.0;
}
}
- ${d}
+ ${f}
}
`;
}
-var kre = (r) => r ? `
+var ire = (r) => r ? `
mm_readA(batch, colA, globalRow),
mm_readA(batch, colA + 1, globalRow),
mm_readA(batch, colA + 2, globalRow),
@@ -27115,17 +27316,17 @@ var kre = (r) => r ? `
mm_readA(batch, globalRow, colA + 2),
mm_readA(batch, globalRow, colA + 3)
`;
-function Tre(r, e = false) {
- return x.assert(r[1] === 1 && r[2] === 1, () => `A linear work group size is required. But got ${r}.`), `
- const TileSize = ${r[0] * 4};
+function ure(r, e = false) {
+ return y.assert(r[1] === 1 && r[2] === 1, () => `A linear work group size is required. But got ${r}.`), `
+ const tileSize = ${r[0] * 4};
var mm_Asub : array, ${r[0]}>;
- ${ue()} {
+ ${se()} {
let tileCol = i32(localId.x);
let globalCol = i32(globalId.x);
let globalRow = i32(globalId.y);
- let numTiles = (uniforms.dimInner - 1) / TileSize + 1;
+ let numTiles = (uniforms.dimInner - 1) / tileSize + 1;
let batch = i32(globalId.z);
// Without this initialization strange values show up in acc.
var acc = 0.0;
@@ -27133,13 +27334,13 @@ function Tre(r, e = false) {
// Loop over shared dimension.
for (var t = 0; t < numTiles; t = t + 1) {
// Load one tile of A into local memory.
- let colA = t * TileSize + tileCol * 4;
- mm_Asub[tileCol] = vec4(${kre(e)});
+ let colA = t * tileSize + tileCol * 4;
+ mm_Asub[tileCol] = vec4(${ire(e)});
workgroupBarrier();
// Compute acc values for a single thread.
- for (var k = 0; k < TileSize / 4; k = k + 1) {
- let rowB = t * TileSize + k * 4;
+ for (var k = 0; k < tileSize / 4; k = k + 1) {
+ let rowB = t * tileSize + k * 4;
let BCached = vec4(mm_readB(batch, rowB, globalCol),
mm_readB(batch, rowB + 1, globalCol),
mm_readB(batch, rowB + 2, globalCol),
@@ -27156,45 +27357,45 @@ function Tre(r, e = false) {
}
`;
}
-var Bg = class {
- constructor(e, t10, o, n, s = false, a = false, i = null, p = null, u = null, c = false) {
- this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.outputShape = t10, this.dispatchLayout = { x: [2], y: [1], z: [0] };
+var _g = class {
+ constructor(e, t6, o, n, s = false, a = false, i = null, p = null, u = null, c = false) {
+ this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.outputShape = t6, this.dispatchLayout = { x: [2], y: [1], z: [0] };
let l = s ? e[1] : e[2];
- if (this.isVec4 = (l % 4 === 0 && !s || t10[1] % 4 === 0 && s) && t10[2] % 4 === 0 && !a, this.isVectorA = t10[1] === 1 && !s, !this.isVec4 && this.isVectorA)
- this.elementsPerThread = [1, 1, 1], this.workGroupSize = [32, 1, 1];
+ if (this.isVec4 = (l % 4 === 0 && !s || t6[1] % 4 === 0 && s) && t6[2] % 4 === 0 && !a, this.isVectorA = t6[1] === 1 && !s, !this.isVec4 && this.isVectorA)
+ this.elementsPerThread = [1, 1, 1], this.workgroupSize = [32, 1, 1];
else {
- let d = aS(t10[1], l, t10[2], s);
- this.workGroupSize = d.workGroupSize, this.elementsPerThread = d.elementsPerThread;
+ let f = tI(t6[1], l, t6[2], s);
+ this.workgroupSize = f.workgroupSize, this.elementsPerThread = f.elementsPerThread;
}
- this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize, this.elementsPerThread);
- let m = i != null, f = u != null;
- m && this.variableNames.push("bias"), f && this.variableNames.push("preluActivationWeights"), this.sequentialAccessByThreads = c, this.transposeA = s, this.transposeB = a, this.addBias = m, this.activation = p, this.hasPreluActivationWeights = f, this.batchAEqualOne = o, this.batchBEqualOne = n, [this.fitAOuter, this.fitBOuter, this.fitInner] = this.getShapeFit(t10[1], t10[2], l), this.shaderKey = `matMulPacked_${this.elementsPerThread}_${s}_${a}_${this.activation}_${this.fitAOuter}_${this.fitBOuter}_${this.fitInner}_${this.isVec4}_${this.isVectorA}_${this.batchAEqualOne}_${this.batchBEqualOne}_${this.sequentialAccessByThreads}`;
+ this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize, this.elementsPerThread);
+ let m = i != null, d = u != null;
+ m && this.variableNames.push("bias"), d && this.variableNames.push("preluActivationWeights"), this.sequentialAccessByThreads = c, this.transposeA = s, this.transposeB = a, this.addBias = m, this.activation = p, this.hasPreluActivationWeights = d, this.batchAEqualOne = o, this.batchBEqualOne = n, [this.fitAOuter, this.fitBOuter, this.fitInner] = this.getShapeFit(t6[1], t6[2], l), this.shaderKey = `matMulPacked_${this.elementsPerThread}_${s}_${a}_${this.activation}_${this.fitAOuter}_${this.fitBOuter}_${this.fitInner}_${this.isVec4}_${this.isVectorA}_${this.batchAEqualOne}_${this.batchBEqualOne}_${this.sequentialAccessByThreads}`;
}
- getShapeFit(e, t10, o) {
- let n = this.workGroupSize[1] * this.elementsPerThread[1], s = this.workGroupSize[0] * this.elementsPerThread[0];
- !this.isVec4 && this.isVectorA ? this.tileInner = this.workGroupSize[0] * 4 : this.tileInner = s;
- let a = e % n === 0, i = t10 % s === 0, p = o % this.tileInner === 0;
+ getShapeFit(e, t6, o) {
+ let n = this.workgroupSize[1] * this.elementsPerThread[1], s = this.workgroupSize[0] * this.elementsPerThread[0];
+ !this.isVec4 && this.isVectorA ? this.tileInner = this.workgroupSize[0] * 4 : this.tileInner = s;
+ let a = e % n === 0, i = t6 % s === 0, p = o % this.tileInner === 0;
return [a, i, p];
}
getUserCode() {
return `
${ur(this.activation, this.hasPreluActivationWeights, this.isVec4)}
- ${jl(this.addBias, this.activation, this.batchAEqualOne, this.batchBEqualOne, false, this.transposeB, this.fitAOuter, this.fitBOuter, this.fitInner, this.isVec4 ? 4 : 1)}
- ${this.isVec4 ? Uu(this.elementsPerThread, this.workGroupSize, this.transposeA, this.tileInner, false, null, this.isVectorA) : this.isVectorA ? Tre(this.workGroupSize, this.transposeA) : Gu(this.elementsPerThread, this.workGroupSize, this.transposeA, this.tileInner, false, null, this.sequentialAccessByThreads)}
+ ${Vl(this.addBias, this.activation, this.batchAEqualOne, this.batchBEqualOne, false, this.transposeB, this.fitAOuter, this.fitBOuter, this.fitInner, this.isVec4 ? 4 : 1)}
+ ${this.isVec4 ? Wu(this.elementsPerThread, this.workgroupSize, this.transposeA, this.tileInner, false, null, this.isVectorA) : this.isVectorA ? ure(this.workgroupSize, this.transposeA) : Uu(this.elementsPerThread, this.workgroupSize, this.transposeA, this.tileInner, false, null, this.sequentialAccessByThreads)}
`;
}
};
-function Nre() {
+function pre() {
return `
- var sumValues : array;
- ${ue()} {
+ var sumValues : array;
+ ${se()} {
let coords = getOutputCoords();
let batch = coords[0];
let row = coords[1];
let col = coords[2];
var sum = 0.0;
let Length = uniforms.dimInner;
- for (var k = i32(localId.x); k < Length; k = k + i32(workGroupSizeX)) {
+ for (var k = i32(localId.x); k < Length; k = k + i32(workgroupSizeX)) {
let dataA = mm_readA(batch, row, k);
let dataB = mm_readB(batch, k, col);
sum = sum + dataA * dataB;
@@ -27202,7 +27403,7 @@ function Nre() {
sumValues[localId.x] = sum;
workgroupBarrier();
- for(var currentSize = workGroupSizeX / 2u; currentSize > 1u;
+ for(var currentSize = workgroupSizeX / 2u; currentSize > 1u;
currentSize = currentSize / 2u) {
if (localId.x < currentSize)
{
@@ -27218,25 +27419,25 @@ function Nre() {
}
`;
}
-var Vg = class {
- constructor(e, t10, o, n = false, s = false, a = null, i = null, p = null) {
- this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workGroupSize = [256, 1, 1], this.outputShape = e, this.dispatchLayout = { x: [], y: [1, 2], z: [0] }, this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize);
+var Eg = class {
+ constructor(e, t6, o, n = false, s = false, a = null, i = null, p = null) {
+ this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workgroupSize = [256, 1, 1], this.outputShape = e, this.dispatchLayout = { x: [], y: [1, 2], z: [0] }, this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize);
let u = a != null, c = p != null;
- u && this.variableNames.push("bias"), c && this.variableNames.push("preluActivationWeights"), this.transposeA = n, this.transposeB = s, this.addBias = u, this.activation = i, this.hasPreluActivationWeights = c, this.batchAEqualOne = t10, this.batchBEqualOne = o, this.shaderKey = `matMulReduce_${this.activation}_${n}_${s}_${this.batchAEqualOne}_${this.batchBEqualOne}`;
+ u && this.variableNames.push("bias"), c && this.variableNames.push("preluActivationWeights"), this.transposeA = n, this.transposeB = s, this.addBias = u, this.activation = i, this.hasPreluActivationWeights = c, this.batchAEqualOne = t6, this.batchBEqualOne = o, this.shaderKey = `matMulReduce_${this.activation}_${n}_${s}_${this.batchAEqualOne}_${this.batchBEqualOne}`;
}
getUserCode() {
return `
${ur(this.activation, this.hasPreluActivationWeights)}
- ${jl(this.addBias, this.activation, this.batchAEqualOne, this.batchBEqualOne, this.transposeA, this.transposeB)}
- ${Nre()}
+ ${Vl(this.addBias, this.activation, this.batchAEqualOne, this.batchBEqualOne, this.transposeA, this.transposeB)}
+ ${pre()}
`;
}
};
-function _re(r) {
- let e = r[1], t10 = r[0], o = e > t10 ? e : t10;
+function cre(r) {
+ let e = r[1], t6 = r[0], o = e > t6 ? e : t6;
return `
var mm_Asub : array, ${e}>;
- var mm_Bsub : array, ${o}>;
+ var mm_Bsub : array, ${o}>;
// If the output size is small for matrix multiplication, avoid to use vec4
// and handle some elements per thread to optimally utilize the ALU.
@@ -27244,7 +27445,7 @@ function _re(r) {
// shared memory, so it is instruction-Level parallelism for arithmetic
// operations and others handle IO operations between barrier api, makes ALU
// and load/store units work simultaneously, could improves the performance.
- ${ue()} {
+ ${se()} {
let tileRow = i32(localId.y);
let tileCol = i32(localId.x);
let globalRow = i32(globalId.y);
@@ -27286,25 +27487,25 @@ function _re(r) {
}
`;
}
-var zg = class {
- constructor(e, t10, o, n = false, s = false, a = null, i = null, p = null) {
- this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workGroupSize = [16, 8, 1], this.outputShape = o, this.dispatchLayout = { x: [2], y: [1], z: [0] }, this.dispatch = [Math.ceil(o[2] / this.workGroupSize[0]), Math.ceil(o[1] / this.workGroupSize[1]), o[0]];
+var $g = class {
+ constructor(e, t6, o, n = false, s = false, a = null, i = null, p = null) {
+ this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workgroupSize = [16, 8, 1], this.outputShape = o, this.dispatchLayout = { x: [2], y: [1], z: [0] }, this.dispatch = [Math.ceil(o[2] / this.workgroupSize[0]), Math.ceil(o[1] / this.workgroupSize[1]), o[0]];
let u = a != null;
u && this.variableNames.push("bias");
let c = p != null;
- c && this.variableNames.push("preluActivationWeights"), this.transposeA = n, this.transposeB = s, this.addBias = u, this.activation = i, this.hasPreluActivationWeights = c, this.batchAEqualOne = e[0] === 1, this.batchBEqualOne = t10[0] === 1, this.shaderKey = `matMulSmallOutputSize_${this.activation}_${n}_${s}_${this.batchAEqualOne}_${this.batchBEqualOne}`;
+ c && this.variableNames.push("preluActivationWeights"), this.transposeA = n, this.transposeB = s, this.addBias = u, this.activation = i, this.hasPreluActivationWeights = c, this.batchAEqualOne = e[0] === 1, this.batchBEqualOne = t6[0] === 1, this.shaderKey = `matMulSmallOutputSize_${this.activation}_${n}_${s}_${this.batchAEqualOne}_${this.batchBEqualOne}`;
}
getUserCode() {
return `
${ur(this.activation, this.hasPreluActivationWeights)}
- ${jl(this.addBias, this.activation, this.batchAEqualOne, this.batchBEqualOne, this.transposeA, this.transposeB)}
- ${_re(this.workGroupSize)}
+ ${Vl(this.addBias, this.activation, this.batchAEqualOne, this.batchBEqualOne, this.transposeA, this.transposeB)}
+ ${cre(this.workgroupSize)}
`;
}
};
-var Wg = class {
- constructor(e, t10, o, n, s = false, a = false) {
- this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workGroupSize = [8, 8, 1], this.atomic = true, this.isVec4 = false, this.splitedDimInner = 128, x.assert(e[0] === 1, () => "MatMulSplitKProgram only supports batch = 1."), this.outputShape = e, this.dispatchLayout = { x: [2], y: [1], z: [0, 3] }, this.isVec4 = (s && this.outputShape[1] % 4 === 0 || !s && t10 % 4 === 0) && this.outputShape[2] % 4 === 0, this.elementsPerThread = [4, 4, this.splitedDimInner], this.isVec4 || (this.outputShape[1] < 16 && (this.elementsPerThread[1] = 1), this.outputShape[2] < 16 && (this.elementsPerThread[0] = 1)), this.dispatch = ae(this.dispatchLayout, [this.outputShape[0], this.outputShape[1], this.outputShape[2], t10], this.workGroupSize, this.elementsPerThread), this.transposeA = s, this.transposeB = a, this.batchAEqualOne = o, this.batchBEqualOne = n, this.shaderKey = `matMulSplitK_${s}_${a}_${o}_${n}_${this.elementsPerThread}_${this.isVec4}`;
+var Ag = class {
+ constructor(e, t6, o, n, s = false, a = false) {
+ this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workgroupSize = [8, 8, 1], this.atomic = true, this.isVec4 = false, this.splitedDimInner = 128, y.assert(e[0] === 1, () => "MatMulSplitKProgram only supports batch = 1."), this.outputShape = e, this.dispatchLayout = { x: [2], y: [1], z: [0, 3] }, this.isVec4 = (s && this.outputShape[1] % 4 === 0 || !s && t6 % 4 === 0) && this.outputShape[2] % 4 === 0, this.elementsPerThread = [4, 4, this.splitedDimInner], this.isVec4 || (this.outputShape[1] < 16 && (this.elementsPerThread[1] = 1), this.outputShape[2] < 16 && (this.elementsPerThread[0] = 1)), this.dispatch = re(this.dispatchLayout, [this.outputShape[0], this.outputShape[1], this.outputShape[2], t6], this.workgroupSize, this.elementsPerThread), this.transposeA = s, this.transposeB = a, this.batchAEqualOne = o, this.batchBEqualOne = n, this.shaderKey = `matMulSplitK_${s}_${a}_${o}_${n}_${this.elementsPerThread}_${this.isVec4}`;
}
getUserCode() {
let e = (n) => `
@@ -27320,48 +27521,48 @@ var Wg = class {
exchanged = res.exchanged;
}
}
- `, t10 = this.isVec4 ? 4 : 1;
+ `, t6 = this.isVec4 ? 4 : 1;
return `
- ${lS(this.batchAEqualOne, this.batchBEqualOne, false, this.transposeB, false, false, false, t10)}
- fn mm_write(batch: i32, row : i32, colIn : i32, value : ${vt(t10)}) {
- let col = colIn * ${t10};
+ ${iI(this.batchAEqualOne, this.batchBEqualOne, false, this.transposeB, false, false, false, t6)}
+ fn mm_write(batch: i32, row : i32, colIn : i32, value : ${kt(t6)}) {
+ let col = colIn * ${t6};
if (row < uniforms.dimAOuter && col < uniforms.dimBOuter) {
let coords = vec3(batch, row, col);
let flatIndex = getOutputIndexFromCoords(coords);
// The problem is that we should initialize output to zero before using.
// Otherwise, the original value will be added to the result.
- ${e(t10)}
+ ${e(t6)}
}
}
- ${this.isVec4 ? Uu(this.elementsPerThread, this.workGroupSize, this.transposeA, 32, true, this.splitedDimInner) : Gu(this.elementsPerThread, this.workGroupSize, this.transposeA, 32, true, this.splitedDimInner)}
+ ${this.isVec4 ? Wu(this.elementsPerThread, this.workgroupSize, this.transposeA, 32, true, this.splitedDimInner) : Uu(this.elementsPerThread, this.workgroupSize, this.transposeA, 32, true, this.splitedDimInner)}
`;
}
};
-var Ug = class {
- constructor(e, t10 = null, o = null, n = null) {
- this.uniforms = "", this.variableNames = ["x"], this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = fe(this.outputShape), this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize), this.addBias = t10 != null, this.hasPreluActivationWeights = n != null, this.activation = o, this.addBias && this.variableNames.push("bias"), this.hasPreluActivationWeights && this.variableNames.push("preluActivationWeights"), this.shaderKey = `biasActivation_${o}`;
+var Rg = class {
+ constructor(e, t6 = null, o = null, n = null) {
+ this.uniforms = "", this.variableNames = ["x"], this.workgroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = ue(this.outputShape), this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize), this.addBias = t6 != null, this.hasPreluActivationWeights = n != null, this.activation = o, this.addBias && this.variableNames.push("bias"), this.hasPreluActivationWeights && this.variableNames.push("preluActivationWeights"), this.shaderKey = `biasActivation_${o}`;
}
getUserCode() {
return `
${ur(this.activation, this.hasPreluActivationWeights)}
- ${ue("index")} {
+ ${se("index")} {
if (index < uniforms.size) {
let coords = getCoordsFromIndex(index);
var value = getXByOutputIndex(index);
- ${Kr(this.addBias, this.activation)}
+ ${Hr(this.addBias, this.activation)}
setOutputAtIndex(index, value);
}
}
`;
}
};
-var Gg = class {
+var Fg = class {
constructor(e) {
- this.variableNames = [], this.outputShape = [], this.uniforms = "value : f32,", this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = fe(this.outputShape), this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = "fill";
+ this.variableNames = [], this.outputShape = [], this.uniforms = "value : f32,", this.workgroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = ue(this.outputShape), this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = "fill";
}
getUserCode() {
return `
- ${ue("index")} {
+ ${se("index")} {
if (index < uniforms.size) {
setOutputAtIndex(index, uniforms.value);
}
@@ -27369,79 +27570,83 @@ var Gg = class {
`;
}
};
-function $o(r) {
- let { backend: e, attrs: t10 } = r, { shape: o, value: n } = t10, { dtype: s } = t10;
- if (s = s || x.inferDtype(n), s === "string") {
- let a = x.getArrayFromDType(s, x.sizeFromShape(o));
+function dr(r) {
+ let { backend: e, attrs: t6 } = r, { shape: o, value: n } = t6, { dtype: s } = t6;
+ if (s = s || y.inferDtype(n), s === "string") {
+ let a = y.getArrayFromDType(s, y.sizeFromShape(o));
return a.fill(n), e.makeTensorInfo(o, s, a);
} else {
- let a = new Gg(o), i = [{ type: "float32", data: [n] }];
+ let a = new Fg(o), i = [{ type: "float32", data: [n] }];
return e.runWebGPUProgram(a, [], s, i);
}
}
-var nM = { kernelName: ys, backendName: "webgpu", kernelFunc: $o };
-function xe(r) {
- let { inputs: e, attrs: t10 } = r, { x: o } = e, { shape: n } = t10, s = x.sizeFromShape(o.shape), a = x.inferFromImplicitShape(n, s), i = x.sizeFromShape(a);
- return x.assert(s === i, () => `The new shape (${a}) has ${i} elements and the old shape (${o.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`), r.backend.incRef(o.dataId), { dataId: o.dataId, shape: a, dtype: o.dtype };
+var M3 = { kernelName: Cs, backendName: "webgpu", kernelFunc: dr };
+function de(r) {
+ let { inputs: e, attrs: t6 } = r, { x: o } = e, { shape: n } = t6, s = y.sizeFromShape(o.shape), a = y.inferFromImplicitShape(n, s), i = y.sizeFromShape(a);
+ return y.assert(s === i, () => `The new shape (${a}) has ${i} elements and the old shape (${o.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`), r.backend.incRef(o.dataId), { dataId: o.dataId, shape: a, dtype: o.dtype };
}
-var sM = { kernelName: Ss, backendName: "webgpu", kernelFunc: xe };
-function _c({ a: r, b: e, transposeA: t10, transposeB: o, backend: n, bias: s = null, preluActivationWeights: a = null, leakyreluAlpha: i = 0, activation: p = null }) {
- let u = r.shape.length, c = e.shape.length, l = t10 ? r.shape[u - 2] : r.shape[u - 1], m = o ? e.shape[c - 1] : e.shape[c - 2], f = t10 ? r.shape[u - 1] : r.shape[u - 2], d = o ? e.shape[c - 2] : e.shape[c - 1], h = r.shape.slice(0, -2), g = e.shape.slice(0, -2), y = x.sizeFromShape(h), b = x.sizeFromShape(g), w = br.assertAndGetBroadcastShape(r.shape.slice(0, -2), e.shape.slice(0, -2)).concat([f, d]);
- x.assert(l === m, () => `Error in matMul: inner shapes (${l}) and (${m}) of Tensors with shapes ${r.shape} and ${e.shape} and transposeA=${t10} and transposeB=${o} must match.`);
- let k = t10 ? [y, l, f] : [y, f, l], _ = o ? [b, d, m] : [b, m, d], E = xe({ inputs: { x: r }, backend: n, attrs: { shape: k } }), R = xe({ inputs: { x: e }, backend: n, attrs: { shape: _ } }), A = [E, R], D = Math.max(y, b), O = y === 1, M = b === 1, L = [E, R], W = [{ type: "int32", data: [f] }, { type: "int32", data: [d] }, { type: "int32", data: [l] }], V, G, q = [D, f, d], H = P().get("WEBGPU_MATMUL_PROGRAM_TYPE");
- switch (H < 0 && (f * d <= 128 ? H = Qo.MatMulReduceProgram : D === 1 && f <= 128 && d <= 48 && m >= 2e3 ? H = Qo.MatMulSplitKProgram : f <= 16 && (d <= 512 || m >= 2 * d) || d <= 16 && (f <= 512 || l >= 2 * f) ? H = Qo.MatMulSmallOutputSizeProgram : H = Qo.MatMulPackedProgram), H) {
- case Qo.MatMulReduceProgram:
- V = new Vg(q, O, M, t10, o, s, p, a);
+var L3 = { kernelName: Ns, backendName: "webgpu", kernelFunc: de };
+function Gu({ a: r, b: e, transposeA: t6, transposeB: o, backend: n, bias: s = null, preluActivationWeights: a = null, leakyreluAlpha: i = 0, activation: p = null }) {
+ let u = r.shape.length, c = e.shape.length, l = t6 ? r.shape[u - 2] : r.shape[u - 1], m = o ? e.shape[c - 1] : e.shape[c - 2], d = t6 ? r.shape[u - 1] : r.shape[u - 2], f = o ? e.shape[c - 2] : e.shape[c - 1], h = r.shape.slice(0, -2), g = e.shape.slice(0, -2), x = y.sizeFromShape(h), b = y.sizeFromShape(g), w = br.assertAndGetBroadcastShape(r.shape.slice(0, -2), e.shape.slice(0, -2)).concat([d, f]);
+ y.assert(l === m, () => `Error in matMul: inner shapes (${l}) and (${m}) of Tensors with shapes ${r.shape} and ${e.shape} and transposeA=${t6} and transposeB=${o} must match.`);
+ let k = t6 ? [x, l, d] : [x, d, l], _ = o ? [b, f, m] : [b, m, f], $ = de({ inputs: { x: r }, backend: n, attrs: { shape: k } }), A = de({ inputs: { x: e }, backend: n, attrs: { shape: _ } }), R = [$, A], D = Math.max(x, b), P = x === 1, M = b === 1, L = [$, A], W = [{ type: "int32", data: [d] }, { type: "int32", data: [f] }, { type: "int32", data: [l] }], V, U, q = [D, d, f], H = O().get("WEBGPU_MATMUL_PROGRAM_TYPE");
+ if (H < 0) {
+ let X = O().getNumber("WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL"), Z = X > 0 ? X : n.thresholdToIncreaseWorkgroups, ee = D * Math.ceil(d / 32) * Math.ceil(f / 32);
+ ee <= Z || d <= 8 && ee <= Z * 2 ? D * d * f <= 128 ? H = Ao.MatMulReduceProgram : D === 1 && m >= 2e3 ? H = Ao.MatMulSplitKProgram : H = Ao.MatMulSmallOutputSizeProgram : H = Ao.MatMulPackedProgram;
+ }
+ switch (H) {
+ case Ao.MatMulReduceProgram:
+ V = new Eg(q, P, M, t6, o, s, p, a);
break;
- case Qo.MatMulSplitKProgram: {
- if (G = $o({ backend: n, attrs: { shape: q, value: 0, dtype: r.dtype } }), V = new Wg(q, m, O, M, t10, o), s || p) {
- G = n.runWebGPUProgram(V, L, r.dtype, W, G);
- let Z = new Ug(G.shape, s, p, a), ee = null, X = [G];
- s && X.push(s), a && X.push(a), p === "leakyrelu" && (ee = [{ type: "float32", data: [i] }], Z.uniforms += " alpha : f32,");
- let Q = n.runWebGPUProgram(Z, X, G.dtype, ee);
- A.push(G);
- let se = xe({ inputs: { x: Q }, backend: n, attrs: { shape: w } });
- A.push(Q);
- for (let ie of A)
- n.disposeData(ie.dataId);
- return se;
+ case Ao.MatMulSplitKProgram: {
+ if (U = dr({ backend: n, attrs: { shape: q, value: 0, dtype: r.dtype } }), V = new Ag(q, m, P, M, t6, o), s || p) {
+ U = n.runWebGPUProgram(V, L, r.dtype, W, U);
+ let Z = new Rg(U.shape, s, p, a), ee = null, Y = [U];
+ s && Y.push(s), a && Y.push(a), p === "leakyrelu" && (ee = [{ type: "float32", data: [i] }], Z.uniforms += " alpha : f32,");
+ let J = n.runWebGPUProgram(Z, Y, U.dtype, ee);
+ R.push(U);
+ let ie = de({ inputs: { x: J }, backend: n, attrs: { shape: w } });
+ R.push(J);
+ for (let pe of R)
+ n.disposeData(pe.dataId);
+ return ie;
}
break;
}
- case Qo.MatMulSmallOutputSizeProgram:
- V = new zg(k, _, q, t10, o, s, p, a);
+ case Ao.MatMulSmallOutputSizeProgram:
+ V = new $g(k, _, q, t6, o, s, p, a);
break;
- case Qo.MatMulPackedProgram:
- let Y = n.adapterInfo.isIntel();
- V = new Bg(k, q, O, M, t10, o, s, p, a, Y);
+ case Ao.MatMulPackedProgram:
+ let X = n.adapterInfo.isIntel();
+ V = new _g(k, q, P, M, t6, o, s, p, a, X);
break;
default:
throw new Error(`Unsupported MatMulProgramType ${H}.`);
}
- s && L.push(s), a && L.push(a), p === "leakyrelu" && (W.push({ type: "float32", data: [i] }), V.uniforms += " alpha : f32,"), G = n.runWebGPUProgram(V, L, r.dtype, W, G);
- let j = xe({ inputs: { x: G }, backend: n, attrs: { shape: w } });
- A.push(G);
- for (let Y of A)
- n.disposeData(Y.dataId);
+ s && L.push(s), a && L.push(a), p === "leakyrelu" && (W.push({ type: "float32", data: [i] }), V.uniforms += " alpha : f32,"), U = n.runWebGPUProgram(V, L, r.dtype, W, U);
+ let j = de({ inputs: { x: U }, backend: n, attrs: { shape: w } });
+ R.push(U);
+ for (let X of R)
+ n.disposeData(X.dataId);
return j;
}
-function Ere(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { a: n, b: s, bias: a, preluActivationWeights: i } = e, { transposeA: p, transposeB: u, activation: c, leakyreluAlpha: l } = o;
- return _c({ a: n, b: s, transposeA: p, transposeB: u, backend: t10, bias: a, preluActivationWeights: i, leakyreluAlpha: l, activation: c });
+function lre(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { a: n, b: s, bias: a, preluActivationWeights: i } = e, { transposeA: p, transposeB: u, activation: c, leakyreluAlpha: l } = o;
+ return Gu({ a: n, b: s, transposeA: p, transposeB: u, backend: t6, bias: a, preluActivationWeights: i, leakyreluAlpha: l, activation: c });
}
-var aM = { kernelName: Fo, backendName: "webgpu", kernelFunc: Ere };
-var Xl = class {
- constructor(e, t10, o) {
- this.variableNames = ["AReal", "AImag", "BReal", "BImag"], this.workGroupSize = [128, 1, 1], this.size = true, this.outputShape = I.assertAndGetBroadcastShape(t10, o), this.dispatchLayout = fe(this.outputShape), this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = `binaryOpComplex_${e}`, this.op = e;
+var B3 = { kernelName: fo, backendName: "webgpu", kernelFunc: lre };
+var zl = class {
+ constructor(e, t6, o) {
+ this.variableNames = ["AReal", "AImag", "BReal", "BImag"], this.workgroupSize = [128, 1, 1], this.size = true, this.outputShape = S.assertAndGetBroadcastShape(t6, o), this.dispatchLayout = ue(this.outputShape), this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize), this.shaderKey = `binaryOpComplex_${e}`, this.op = e;
}
getUserCode() {
return `
fn binaryOpComplex(
areal : f32, aimag : f32, breal : f32, bimag : f32) -> f32 {
- ${Nc(this.op, false)}
+ ${Ic(this.op, false)}
}
- ${ue("index")} {
+ ${se("index")} {
if(index < uniforms.size) {
let areal = getARealByOutputIndex(index);
let aimag = getAImagByOutputIndex(index);
@@ -27454,13 +27659,13 @@ var Xl = class {
}
};
var Hu = class {
- constructor(e, t10, o) {
- this.size = true, this.variableNames = ["A", "B"], this.outputShape = I.assertAndGetBroadcastShape(t10, o), this.dispatchLayout = fe(this.outputShape), this.op = e, this.useSharedMemoryWithA = t10.length <= 1 && o.length > 1 && t10[0] < 128, this.useSharedMemoryWithB = o.length <= 1 && t10.length > 1 && o[0] < 128, this.useSharedMemoryWithA || this.useSharedMemoryWithB ? (this.isVec4 = false, this.lastDimensionSize = this.useSharedMemoryWithB ? o[0] : t10[0], this.shaderKey = `binary_${this.type}_${e}_${this.lastDimensionSize}_${this.useSharedMemoryWithB}`, this.type = "shared", this.workGroupSize = [256, 1, 1], this.workPerThread = 1) : (x.arraysEqual(t10, o) && x.sizeFromShape(t10) % 4 === 0 ? (this.isVec4 = true, this.type = "vec4", this.workPerThread = 4) : (this.isVec4 = false, this.type = "plain", this.workPerThread = 1), this.shaderKey = `binary_${this.type}_${e}`, this.workGroupSize = [128, 1, 1]), this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]);
+ constructor(e, t6, o) {
+ this.size = true, this.variableNames = ["A", "B"], this.outputShape = S.assertAndGetBroadcastShape(t6, o), this.dispatchLayout = ue(this.outputShape), this.op = e, this.useSharedMemoryWithA = t6.length <= 1 && o.length > 1 && t6[0] < 128, this.useSharedMemoryWithB = o.length <= 1 && t6.length > 1 && o[0] < 128, this.useSharedMemoryWithA || this.useSharedMemoryWithB ? (this.isVec4 = false, this.lastDimensionSize = this.useSharedMemoryWithB ? o[0] : t6[0], this.shaderKey = `binary_${this.type}_${e}_${this.lastDimensionSize}_${this.useSharedMemoryWithB}`, this.type = "shared", this.workgroupSize = [256, 1, 1], this.workPerThread = 1) : (y.arraysEqual(t6, o) && y.sizeFromShape(t6) % 4 === 0 ? (this.isVec4 = true, this.type = "vec4", this.workPerThread = 4) : (this.isVec4 = false, this.type = "plain", this.workPerThread = 1), this.shaderKey = `binary_${this.type}_${e}`, this.workgroupSize = [128, 1, 1]), this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.workPerThread, 1, 1]);
}
getUserCode() {
- let e, t10 = this.isVec4 ? "vec4" : "f32", o = `
- fn binaryOperation(a : ${t10}, b : ${t10}) -> ${t10} {
- ${Nc(this.op, this.isVec4)}
+ let e, t6 = this.isVec4 ? "vec4" : "f32", o = `
+ fn binaryOperation(a : ${t6}, b : ${t6}) -> ${t6} {
+ ${Ic(this.op, this.isVec4)}
};
`;
if (this.type === "shared") {
@@ -27470,7 +27675,7 @@ var Hu = class {
e = `
${o}
var sharedBuf : array;
- ${ue("index")} {
+ ${se("index")} {
// Fill in the shared memory buffer.
let localIndex = i32(localId.x);
if(localIndex < ${this.lastDimensionSize}) {
@@ -27488,7 +27693,7 @@ var Hu = class {
} else
e = `
${o}
- ${ue("index")} {
+ ${se("index")} {
if (index < uniforms.size) {
let a = getAByOutputIndex(index);
let b = getBByOutputIndex(index);
@@ -27499,28 +27704,28 @@ var Hu = class {
return e;
}
};
-function Lt(r) {
- let { inputs: e } = r, { x: t10 } = e;
- return r.backend.incRef(t10.dataId), { dataId: t10.dataId, shape: t10.shape, dtype: t10.dtype };
+function Ft(r) {
+ let { inputs: e } = r, { x: t6 } = e;
+ return r.backend.incRef(t6.dataId), { dataId: t6.dataId, shape: t6.shape, dtype: t6.dtype };
}
-var iM = { kernelName: uo, backendName: "webgpu", kernelFunc: Lt };
-function ls(r) {
- let { inputs: e, backend: t10 } = r, { real: o, imag: n } = e, s = t10.makeTensorInfo(o.shape, "complex64"), a = t10.tensorMap.get(s.dataId), i = Lt({ inputs: { x: o }, backend: t10 }), p = Lt({ inputs: { x: n }, backend: t10 });
+var V3 = { kernelName: mo, backendName: "webgpu", kernelFunc: Ft };
+function po(r) {
+ let { inputs: e, backend: t6 } = r, { real: o, imag: n } = e, s = t6.makeTensorInfo(o.shape, "complex64"), a = t6.tensorMap.get(s.dataId), i = Ft({ inputs: { x: o }, backend: t6 }), p = Ft({ inputs: { x: n }, backend: t6 });
return a.complexTensorInfos = { real: i, imag: p }, s;
}
-var uM = { kernelName: aa, backendName: "webgpu", kernelFunc: ls };
-var Zo = class {
- constructor(e, t10) {
+var z3 = { kernelName: ei, backendName: "webgpu", kernelFunc: po };
+var Ro = class {
+ constructor(e, t6) {
this.variableNames = ["A"], this.size = true;
let o = 128;
- this.workGroupSize = [o, 1, 1], this.outputShape = e, this.dispatchLayout = fe(this.outputShape), this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize), this.op = t10, this.shaderKey = `unary_${t10}`;
+ this.workgroupSize = [o, 1, 1], this.outputShape = e, this.dispatchLayout = ue(this.outputShape), this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize), this.op = t6, this.shaderKey = `unary_${t6}`;
}
getUserCode() {
return `
fn unaryOperation(a : f32) -> f32 {
- ${za(this.op, false)}
+ ${Ha(this.op, false)}
}
- ${ue("index")} {
+ ${se("index")} {
if (index < uniforms.size) {
let a = getAByOutputIndex(index);
setOutputAtIndex(index, unaryOperation(a));
@@ -27529,1100 +27734,279 @@ var Zo = class {
`;
}
};
-function Ge({ opType: r, cpuKernelImpl: e, dtype: t10 }) {
+function Se({ opType: r, cpuKernelImpl: e, dtype: t6 }) {
return ({ inputs: o, backend: n }) => {
- let { x: s } = o, a = n, i = t10 || s.dtype;
+ let { x: s } = o, a = n, i = t6 || s.dtype;
if (a.shouldExecuteOnCPU([s]) && e != null) {
let u = a.tensorMap.get(s.dataId), c = e(u.values, i);
return a.makeTensorInfo(s.shape, i, c);
}
- let p = new Zo(s.shape, r);
+ let p = new Ro(s.shape, r);
return a.runWebGPUProgram(p, [s], i);
};
}
-function it({ opType: r, cpuKernelImpl: e, supportsComplex: t10 = false, dtype: o }) {
+function ot({ opType: r, cpuKernelImpl: e, supportsComplex: t6 = false, dtype: o }) {
return ({ inputs: n, backend: s }) => {
let { a, b: i } = n, p = s;
- if (t10 && a.dtype === "complex64") {
- let l = p.tensorMap.get(a.dataId), m = p.tensorMap.get(i.dataId), f, d;
+ if (t6 && a.dtype === "complex64") {
+ let l = p.tensorMap.get(a.dataId), m = p.tensorMap.get(i.dataId), d, f;
if (r !== ye.MUL)
- [f, d] = [[l.complexTensorInfos.real, m.complexTensorInfos.real], [l.complexTensorInfos.imag, m.complexTensorInfos.imag]].map((g) => {
- let [y, b] = g, C = { dataId: y.dataId, dtype: y.dtype, shape: a.shape }, w = { dataId: b.dataId, dtype: b.dtype, shape: i.shape }, k = new Hu(r, a.shape, i.shape);
- return p.runWebGPUProgram(k, [C, w], ct(y.dtype, b.dtype));
+ [d, f] = [[l.complexTensorInfos.real, m.complexTensorInfos.real], [l.complexTensorInfos.imag, m.complexTensorInfos.imag]].map((g) => {
+ let [x, b] = g, C = { dataId: x.dataId, dtype: x.dtype, shape: a.shape }, w = { dataId: b.dataId, dtype: b.dtype, shape: i.shape }, k = new Hu(r, a.shape, i.shape);
+ return p.runWebGPUProgram(k, [C, w], dt(x.dtype, b.dtype));
});
else {
- let g = new Xl(ye.COMPLEX_MULTIPLY_REAL, a.shape, i.shape), y = new Xl(ye.COMPLEX_MULTIPLY_IMAG, a.shape, i.shape), b = [{ dataId: l.complexTensorInfos.real.dataId, dtype: l.complexTensorInfos.real.dtype, shape: a.shape }, { dataId: l.complexTensorInfos.imag.dataId, dtype: l.complexTensorInfos.imag.dtype, shape: a.shape }, { dataId: m.complexTensorInfos.real.dataId, dtype: m.complexTensorInfos.real.dtype, shape: i.shape }, { dataId: m.complexTensorInfos.imag.dataId, dtype: m.complexTensorInfos.imag.dtype, shape: i.shape }];
- f = p.runWebGPUProgram(g, b, "float32"), d = p.runWebGPUProgram(y, b, "float32");
+ let g = new zl(ye.COMPLEX_MULTIPLY_REAL, a.shape, i.shape), x = new zl(ye.COMPLEX_MULTIPLY_IMAG, a.shape, i.shape), b = [{ dataId: l.complexTensorInfos.real.dataId, dtype: l.complexTensorInfos.real.dtype, shape: a.shape }, { dataId: l.complexTensorInfos.imag.dataId, dtype: l.complexTensorInfos.imag.dtype, shape: a.shape }, { dataId: m.complexTensorInfos.real.dataId, dtype: m.complexTensorInfos.real.dtype, shape: i.shape }, { dataId: m.complexTensorInfos.imag.dataId, dtype: m.complexTensorInfos.imag.dtype, shape: i.shape }];
+ d = p.runWebGPUProgram(g, b, "float32"), f = p.runWebGPUProgram(x, b, "float32");
}
- let h = ls({ inputs: { real: f, imag: d }, backend: p });
- return p.disposeData(f.dataId), p.disposeData(d.dataId), h;
+ let h = po({ inputs: { real: d, imag: f }, backend: p });
+ return p.disposeData(d.dataId), p.disposeData(f.dataId), h;
}
- let u = o || ct(a.dtype, i.dtype);
+ let u = o || dt(a.dtype, i.dtype);
if ((a.dtype === "string" || i.dtype === "string" || p.shouldExecuteOnCPU([a, i])) && e != null) {
- let l = p.tensorMap.get(a.dataId).values, m = p.tensorMap.get(i.dataId).values, f = a.dtype === "string" ? I.fromUint8ToStringArray(l) : l, d = a.dtype === "string" ? I.fromUint8ToStringArray(m) : m, [h, g] = e(a.shape, i.shape, f, d, u);
+ let l = p.tensorMap.get(a.dataId).values, m = p.tensorMap.get(i.dataId).values, d = a.dtype === "string" ? S.fromUint8ToStringArray(l) : l, f = a.dtype === "string" ? S.fromUint8ToStringArray(m) : m, [h, g] = e(a.shape, i.shape, d, f, u);
return p.makeTensorInfo(g, u, h);
}
let c = new Hu(r, a.shape, i.shape);
return p.runWebGPUProgram(c, [a, i], u);
};
}
-var FS = {};
-Be(FS, { addImpl: () => dS, bincountImpl: () => lM, bincountReduceImpl: () => mM, castImpl: () => fS, ceilImpl: () => hS, concatImpl: () => fM, equalImpl: () => gS, expImpl: () => xS, expm1Impl: () => yS, floorImpl: () => bS, gatherNdImpl: () => dM, gatherV2Impl: () => hM, greaterEqualImpl: () => IS, greaterImpl: () => CS, lessEqualImpl: () => SS, lessImpl: () => wS, linSpaceImpl: () => gM, logImpl: () => vS, maxImpl: () => xM, maximumImpl: () => kS, minimumImpl: () => TS, multiplyImpl: () => Ql, negImpl: () => yM, notEqualImpl: () => NS, prodImpl: () => bM, raggedGatherImpl: () => IM, raggedTensorToTensorImpl: () => vM, rangeImpl: () => kM, rsqrtImpl: () => ES, scatterImpl: () => TM, sigmoidImpl: () => NM, simpleAbsImpl: () => pM, sliceImpl: () => _M, sparseFillEmptyRowsImpl: () => EM, sparseReshapeImpl: () => $M, sparseSegmentReductionImpl: () => RM, sqrtImpl: () => AM, squaredDifferenceImpl: () => $S, stridedSliceImpl: () => FM, stringNGramsImpl: () => DM, stringSplitImpl: () => PM, stringToHashBucketFastImpl: () => OM, subImpl: () => AS, tileImpl: () => MM, topKImpl: () => BM, transposeImpl: () => _S, uniqueImpl: () => VM });
-function Xs(r, e) {
- Array.isArray(r) || (r = [r]), r.forEach((t10) => {
- t10 != null && x.assert(t10.dtype !== "complex64", () => `${e} does not support complex64 tensors in the CPU backend.`);
- });
-}
-function pM(r) {
- let e = new Float32Array(r.length);
- for (let t10 = 0; t10 < r.length; ++t10)
- e[t10] = Math.abs(r[t10]);
- return e;
-}
-function kt(r) {
- return (e, t10, o, n, s) => {
- let a = I.assertAndGetBroadcastShape(e, t10), i = a.length, p = x.computeStrides(a), u = x.sizeFromShape(a), c = x.getTypedArrayFromDType(s, u), l = e.length, m = t10.length, f = x.computeStrides(e), d = x.computeStrides(t10), h = I.getBroadcastDims(e, a), g = I.getBroadcastDims(t10, a);
- if (h.length + g.length === 0)
- for (let y = 0; y < c.length; ++y)
- c[y] = r(o[y % o.length], n[y % n.length]);
- else
- for (let y = 0; y < c.length; ++y) {
- let b = x.indexToLoc(y, i, p), C = b.slice(-l);
- h.forEach((E) => C[E] = 0);
- let w = x.locToIndex(C, l, f), k = b.slice(-m);
- g.forEach((E) => k[E] = 0);
- let _ = x.locToIndex(k, m, d);
- c[y] = r(o[w], n[_]);
- }
- return [c, a];
- };
-}
-function Ec(r) {
- let { inputs: e, backend: t10 } = r, { real: o, imag: n } = e, s = t10.data.get(o.dataId).values, a = t10.data.get(n.dataId).values, i = t10.makeTensorInfo(o.shape, "complex64"), p = t10.data.get(i.dataId);
- return p.complexTensorInfos = { real: t10.makeTensorInfo(o.shape, "float32", s), imag: t10.makeTensorInfo(n.shape, "float32", a) }, i;
-}
-function Hg(r, e, t10 = "float32") {
- if (t10 === "complex64") {
- let n = Hg(r, e, "float32"), s = Hg(r, e, "float32");
- return Ec({ inputs: { real: n, imag: s }, backend: r });
- }
- let o = x.makeZerosTypedArray(x.sizeFromShape(e), t10);
- return r.makeTensorInfo(e, t10, o);
-}
-function mS(r) {
- let { inputs: e, backend: t10 } = r, { x: o } = e;
- return t10.incRef(o.dataId), { dataId: o.dataId, shape: o.shape, dtype: o.dtype };
-}
-function cM(r) {
- let { inputs: e, backend: t10 } = r, { input: o } = e, n = t10.data.get(o.dataId).complexTensorInfos.real, s = t10.data.get(n.dataId).values;
- return t10.makeTensorInfo(n.shape, n.dtype, s);
-}
-function fS(r, e, t10, o) {
- if (o === "int32") {
- let n = Int32Array.from(r);
- return [e, "int32", n];
- }
- if (o === "bool") {
- let n = x.toTypedArray([0], t10), [s, a] = kt((i, p) => i !== p ? 1 : 0)(e, [], r, n, "bool");
- return [a, "bool", s];
- }
- throw new Error(`Error in Cast: failed to cast ${t10} to ${o}`);
-}
-function Yl(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { dtype: s } = o;
- if (s === "complex64") {
- if (n.dtype === "complex64")
- return mS({ inputs: { x: n }, backend: t10 });
- let c = Hg(t10, n.shape, n.dtype), l = Yl({ inputs: { x: n }, backend: t10, attrs: { dtype: "float32" } }), m = Ec({ inputs: { real: l, imag: c }, backend: t10 });
- return t10.disposeIntermediateTensorInfo(c), t10.disposeIntermediateTensorInfo(l), m;
- }
- if (n.dtype === "complex64") {
- let c = cM({ inputs: { input: n }, backend: t10 }), l = Yl({ inputs: { x: c }, backend: t10, attrs: { dtype: s } });
- return t10.disposeIntermediateTensorInfo(c), l;
- }
- if (!x.hasEncodingLoss(n.dtype, s)) {
- let c = mS({ inputs: { x: n }, backend: t10 });
- return { dataId: c.dataId, shape: c.shape, dtype: s };
- }
- let a = t10.data.get(n.dataId).values, [i, p, u] = fS(a, n.shape, n.dtype, s);
- return t10.makeTensorInfo(i, p, u);
-}
-function Dt(r, e, t10, o) {
- return t10 == null ? ({ inputs: n, backend: s }) => {
- let { a, b: i } = n, p = s;
- Xs([a, i], r);
- let u = p.data.get(a.dataId).values, c = p.data.get(i.dataId).values, l = a.dtype === "string" ? I.fromUint8ToStringArray(u) : u, m = a.dtype === "string" ? I.fromUint8ToStringArray(c) : c, f = o || a.dtype, [d, h] = e(a.shape, i.shape, l, m, f);
- return p.makeTensorInfo(h, f, d);
- } : ({ inputs: n, backend: s }) => {
- let { a, b: i } = n, p = s;
- if (a.dtype === "complex64" || i.dtype === "complex64") {
- let u = Yl({ inputs: { x: a }, backend: p, attrs: { dtype: "complex64" } }), c = p.data.get(u.dataId), l = c.complexTensorInfos.real, m = c.complexTensorInfos.imag, f = p.data.get(l.dataId).values, d = p.data.get(m.dataId).values, h = Yl({ inputs: { x: i }, backend: p, attrs: { dtype: "complex64" } }), g = p.data.get(h.dataId), y = g.complexTensorInfos.real, b = g.complexTensorInfos.imag, C = p.data.get(y.dataId).values, w = p.data.get(b.dataId).values, [k, _, E] = t10(a.shape, i.shape, f, d, C, w), R = p.makeTensorInfo(E, "float32", k), A = p.makeTensorInfo(E, "float32", _), D = Ec({ inputs: { real: R, imag: A }, backend: p });
- return p.disposeIntermediateTensorInfo(u), p.disposeIntermediateTensorInfo(h), p.disposeIntermediateTensorInfo(R), p.disposeIntermediateTensorInfo(A), D;
- } else {
- let u = p.data.get(a.dataId).values, c = p.data.get(i.dataId).values, l = o || a.dtype, [m, f] = e(a.shape, i.shape, u, c, l);
- return p.makeTensorInfo(f, l, m);
- }
- };
-}
-function $c(r) {
- return (e, t10, o, n, s, a) => {
- let i = I.assertAndGetBroadcastShape(e, t10), p = x.sizeFromShape(i), u = i.length, c = x.computeStrides(i), l = x.getTypedArrayFromDType("float32", p), m = x.getTypedArrayFromDType("float32", p), f = I.getBroadcastDims(e, i), d = I.getBroadcastDims(t10, i), h = I.mergeRealAndImagArrays(o, n), g = I.mergeRealAndImagArrays(s, a), y = e.length, b = x.computeStrides(e), C = t10.length, w = x.computeStrides(t10);
- if (f.length + d.length === 0)
- for (let k = 0; k < l.length; k++) {
- let _ = k % h.length, E = k % g.length, R = r(h[_ * 2], h[_ * 2 + 1], g[E * 2], g[E * 2 + 1]);
- l[k] = R.real, m[k] = R.imag;
- }
- else
- for (let k = 0; k < l.length; k++) {
- let _ = x.indexToLoc(k, u, c), E = _.slice(-y);
- f.forEach((M) => E[M] = 0);
- let R = x.locToIndex(E, y, b), A = _.slice(-C);
- d.forEach((M) => A[M] = 0);
- let D = x.locToIndex(A, C, w), O = r(h[R * 2], h[R * 2 + 1], g[D * 2], g[D * 2 + 1]);
- l[k] = O.real, m[k] = O.imag;
- }
- return [l, m, i];
- };
-}
-var dS = kt((r, e) => r + e);
-var $re = $c((r, e, t10, o) => ({ real: r + t10, imag: e + o }));
-var LTt = Dt(_r, dS, $re);
-function lM(r, e, t10, o, n) {
- let s = x.sizeFromShape(o), a = x.makeZerosTypedArray(n, t10);
- for (let i = 0; i < r.length; i++) {
- let p = r[i];
- if (p < 0)
- throw new Error("Input x must be non-negative!");
- p >= n || (s > 0 ? a[p] += e[i] : a[p] += 1);
- }
- return a;
-}
-function mM(r, e, t10, o = false) {
- let n = r.shape[0], s = r.shape[1], a = ne([n, t10], e.dtype);
- for (let i = 0; i < n; i++)
- for (let p = 0; p < s; p++) {
- let u = r.get(i, p);
- if (u < 0)
- throw new Error("Input x must be non-negative!");
- u >= t10 || (o ? a.set(1, i, u) : e.size > 0 ? a.set(a.get(i, u) + e.get(i, p), i, u) : a.set(a.get(i, u) + 1, i, u));
- }
- return a;
-}
-function Tr(r) {
- return (e, t10, o) => {
- let n = x.getTypedArrayFromDType(t10, e.length);
- for (let s = 0; s < e.length; ++s)
- n[s] = r(e[s], o);
- return n;
- };
-}
-function qg(r, e, t10) {
- return ({ inputs: o, attrs: n, backend: s }) => {
- let { x: a } = o;
- if (Xs(a, r), a.dtype === "string" || t10 === "string")
- throw new Error("unaryKernelFunc does not support string input/output");
- let i = s, p = i.data.get(a.dataId).values, u = x.sizeFromShape(a.shape), c = t10 || a.dtype, l = x.getArrayFromDType(c, u);
- for (let m = 0; m < u; ++m)
- l[m] = e(p[m], n);
- return i.makeTensorInfo(a.shape, c, l);
- };
-}
-function Jo(r, e, t10) {
- return ({ inputs: o, attrs: n, backend: s }) => {
- let { x: a } = o;
- if (Xs(a, r), a.dtype === "string" || t10 === "string")
- throw new Error("unaryKernelFunc does not support string input/output");
- let i = s, p = i.data.get(a.dataId).values, u = t10 || a.dtype, c = e(p, u, n);
- return i.makeTensorInfo(a.shape, u, c);
- };
-}
-var hS = Tr((r) => Math.ceil(r));
-var YTt = Jo(ro, hS);
-function fM(r, e, t10, o) {
- let n = x.getArrayFromDType(t10, x.sizeFromShape(e));
- if (o && t10 !== "string") {
- let s = 0;
- r.forEach((a) => {
- let i = x.sizeFromShape(a.shape);
- n.set(a.vals, s), s += i;
- });
- } else {
- let s = 0;
- r.forEach((a) => {
- let i = t10 === "string" ? I.fromUint8ToStringArray(a.vals) : a.vals, p = 0;
- for (let u = 0; u < a.shape[0]; ++u) {
- let c = u * e[1] + s;
- for (let l = 0; l < a.shape[1]; ++l)
- n[c + l] = i[p++];
- }
- s += a.shape[1];
- });
- }
- return n;
-}
-var gS = kt((r, e) => r === e ? 1 : 0);
-var oNt = Dt(oo, gS, null, "bool");
-var xS = Tr((r) => Math.exp(r));
-var uNt = Jo(no, xS, "float32");
-var yS = Tr((r) => Math.expm1(r));
-var fNt = Jo(wn, yS);
-var bS = Tr((r) => Math.floor(r));
-var yNt = Jo(so, bS);
-function dM(r, e, t10, o, n, s, a, i, p) {
- let u = ne([o, s], t10);
- for (let c = 0; c < o; c++) {
- let l = [], m = 0;
- for (let f = 0; f < n; f++) {
- let d = r[c * n + f];
- m += d * a[f], l.push(d);
- }
- if (m < 0 || m >= p / s)
- throw new Error(`Invalid indices: ${l} does not index into ${i}`);
- for (let f = 0; f < s; f++)
- u.values[c * s + f] = e.get(...e.indexToLoc(m * s + f));
- }
- return u;
-}
-function hM(r, e, t10) {
- let o = ne(t10, r.dtype);
- for (let n = 0; n < o.size; ++n) {
- let a = o.indexToLoc(n).slice(), i = a[0], p = a[2], u = e.locToIndex([i, p]);
- a[2] = e.values[u];
- let c = r.locToIndex(a);
- 0 <= c && c < r.values.length && (o.values[n] = r.values[c]);
- }
- return o;
-}
-var CS = kt((r, e) => r > e ? 1 : 0);
-var NNt = Dt(ao, CS, null, "bool");
-var IS = kt((r, e) => r >= e ? 1 : 0);
-var ANt = Dt(io, IS, null, "bool");
-var wS = kt((r, e) => r < e ? 1 : 0);
-var MNt = Dt(po, wS, null, "bool");
-var SS = kt((r, e) => r <= e ? 1 : 0);
-var WNt = Dt(co, SS, null, "bool");
-function gM(r, e, t10) {
- let o = (e - r) / (t10 - 1), n = x.makeZerosTypedArray(t10, "float32");
- n[0] = r;
- for (let s = 1; s < n.length; s++)
- n[s] = n[s - 1] + o;
- return n;
-}
-var vS = Tr((r) => Math.log(r));
-var XNt = Jo(lo, vS);
-function xM(r, e, t10, o) {
- let n = x.getTypedArrayFromDType(o, x.sizeFromShape(t10));
- for (let s = 0; s < n.length; ++s) {
- let a = s * e, i = r[a];
- for (let p = 0; p < e; ++p) {
- let u = r[a + p];
- (Number.isNaN(u) || u > i) && (i = u);
- }
- n[s] = i;
- }
- return n;
-}
-var kS = kt((r, e) => Math.max(r, e));
-var r2t = Dt(mo, kS);
-var TS = kt((r, e) => Math.min(r, e));
-var i2t = Dt(fo, TS);
-var Ql = kt((r, e) => r * e);
-var Rre = $c((r, e, t10, o) => ({ real: r * t10 - e * o, imag: r * o + e * t10 }));
-var m2t = Dt(ho, Ql, Rre);
-function yM(r, e, t10) {
- let o = x.createScalarValue(-1, t10);
- return Ql([], e, o, r, t10);
-}
-var NS = kt((r, e) => r !== e ? 1 : 0);
-var I2t = Dt(go, NS, null, "bool");
-function _S(r, e, t10, o, n) {
- let s = e.length, a = x.sizeFromShape(e), i = x.computeStrides(e), p = x.computeStrides(n), u = x.getTypedArrayFromDType(t10, x.sizeFromShape(n));
- for (let c = 0; c < a; ++c) {
- let l = x.indexToLoc(c, s, i), m = new Array(l.length);
- for (let d = 0; d < m.length; d++)
- m[d] = l[o[d]];
- let f = x.locToIndex(m, s, p);
- u[f] = r[c];
- }
- return u;
-}
-function bM(r, e, t10, o) {
- let [n, s] = I.computeOutAndReduceShapes(r, o), a = ct(e, "int32"), i = x.makeZerosTypedArray(x.sizeFromShape(n), a), p = x.sizeFromShape(s);
- for (let u = 0; u < i.length; ++u) {
- let c = u * p, l = 1;
- for (let m = 0; m < p; ++m)
- l *= t10[c + m];
- i[u] = l;
- }
- return { outVals: i, outShape: n, outDtype: a };
-}
-function Are(r, e, t10) {
- r.forEach((o, n) => {
- if (o < 0 || o >= t10) {
- let s = x.indexToLoc(n, e.length, x.computeStrides(e)).join(",");
- throw new Error(`indices[${s}] = ${o} is not in [0, ${t10})`);
- }
- });
-}
-function Fre(r, e) {
- for (let t10 = 0; t10 < r.length; ++t10) {
- let o = r[t10], n = t10 === r.length - 1 ? e : r[t10 + 1].length;
- if (o.length === 0)
- throw new Error("Ragged splits may not be empty");
- if (o[0] < 0)
- throw new Error("Ragged splits must be non-negative");
- if (o[o.length - 1] > n)
- throw new Error("Ragged splits must not point past values");
- for (let s = 1; s < o.length; ++s)
- if (o[s - 1] > o[s])
- throw new Error("Ragged splits must be sorted in ascending order");
- }
-}
-function Dre(r, e, t10, o) {
- let n = [], s = 0, a = e.length - 1 + t10.length, i = new Array(a).fill(null).map(() => [0]);
- Fre(t10, o);
- let p = 1;
- for (let u = 0; u < e.length - 1; ++u) {
- p *= e[u];
- let c = e[u + 1];
- for (let l = 1; l < p + 1; ++l)
- i[u].push(l * c);
- }
- for (let u = 0; u < r.length; ++u) {
- let c = r[u], l = r[u] + 1;
- for (let m = 0; m < t10.length; ++m) {
- let f = t10[m], d = m + e.length - 1;
- if (d >= 0) {
- let h = i[d], g = h[h.length - 1] - f[c];
- for (let y = c; y < l; ++y)
- i[d].push(f[y + 1] + g);
- }
- c = f[c], l = f[l];
- }
- l !== c && (n.push([c, l]), s += l - c);
- }
- return { outSplits: i, valueSlices: n, numValues: s };
-}
-function Pre(r) {
- let e = [];
- for (let t10 = 0; t10 < r.length; ++t10) {
- let o = r[t10].length, n = x.getArrayFromDType("int32", o);
- e.push(n), r[t10].forEach((s, a) => n[a] = s);
- }
- return e;
-}
-function CM(r, e) {
- let t10 = r.slice(0, e);
- for (; t10.length < e; )
- t10.push(1);
- for (let o = e; o < r.length; o++)
- t10[e - 1] *= r[o];
- return t10;
-}
-function Ore(r, e, t10, o, n, s) {
- let a = CM(e, 2)[1], i = CM(s, 2)[1], p = 0;
- for (let u of t10)
- for (let c = u[0]; c < u[1]; ++c) {
- for (let l = 0; l < o; ++l)
- n[p * i + l] = r[c * a + l];
- ++p;
- }
-}
-function Mre(r, e, t10, o, n) {
- let s = e.slice();
- s[0] = n;
- let a = x.getArrayFromDType(t10, x.sizeFromShape(s)), i = r.length, p = i === 0 ? 0 : i / e[0];
- return Ore(r, e, o, p, a, s), [a, s];
-}
-function IM(r, e, t10, o, n, s, a, i) {
- if (r.length === 0)
- throw new Error("paramsNestedSplits must be non empty");
- if (e[0].length === 0)
- throw new Error("Split tensors must not be scalars");
- let p = e[0][0] - 1;
- if (Are(s, a, p), o.length === 0)
- throw new Error("params.rank must be nonzero");
- let u = o[0], { outSplits: c, valueSlices: l, numValues: m } = Dre(s, a, r, u), f = Pre(c), d = Mre(t10, o, n, l, m);
- return [f, d[0], d[1]];
-}
-var en = I.RowPartitionType;
-var Rc = class {
- constructor(e, t10, o, n, s, a, i, p, u, c) {
- this.shape = e, this.shapeShape = t10, this.values = o, this.valuesShape = n, this.valuesDType = s, this.defaultValue = a, this.defaultValueShape = i, this.rowPartitionValues = p, this.rowPartitionValuesShapes = u, this.rowPartitionTypes = I.getRowPartitionTypesHelper(c), this.raggedRank = I.getRaggedRank(this.rowPartitionTypes);
- }
- getRowPartitionTypeByDimension(e) {
- return this.rowPartitionTypes[0] === en.FIRST_DIM_SIZE ? this.rowPartitionTypes[e + 1] : this.rowPartitionTypes[e];
- }
- getRowPartitionTensor(e) {
- return this.rowPartitionTypes[0] === en.FIRST_DIM_SIZE ? this.rowPartitionValues[e + 1] : this.rowPartitionValues[e];
- }
- getMaxWidth(e) {
- let t10 = this.getRowPartitionTensor(e - 1);
- switch (this.getRowPartitionTypeByDimension(e - 1)) {
- case en.VALUE_ROWIDS:
- return Rc.getMaxWidthValueRowID(t10);
- case en.ROW_SPLITS:
- return Rc.getMaxWidthRowSplit(t10);
- default:
- throw new Error(`Cannot handle partition type ${en[this.getRowPartitionTypeByDimension(e - 1)]}`);
- }
- }
- static getMaxWidthRowSplit(e) {
- let t10 = e.length;
- if (t10 === 0 || t10 === 1)
- return 0;
- let o = 0;
- for (let n = 0; n < t10 - 1; ++n) {
- let s = e[n + 1] - e[n];
- s > o && (o = s);
- }
- return o;
- }
- static getMaxWidthValueRowID(e) {
- let t10 = e.length;
- if (t10 === 0)
- return 0;
- let o = 0, n = e[0], s = 0;
- for (let a = 1; a < t10; ++a) {
- let i = e[a];
- i !== n && (n = i, s = Math.max(a - o, s), o = a);
- }
- return Math.max(t10 - o, s);
- }
- tensorShapeFromTensor(e, t10, o = true) {
- if (t10.length === 0) {
- if (e[0] === -1)
- return [];
- throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.");
- }
- return SM(e, o);
- }
- calculateOutputSize(e) {
- let t10 = this.valuesShape, o = this.defaultValueShape;
- I.validateDefaultValueShape(o, t10);
- let n = this.tensorShapeFromTensor(this.shape, this.shapeShape), a = I.combineRaggedTensorToTensorShapes(this.raggedRank, n, t10);
- a[0] < 0 && (a[0] = e);
- for (let i = 1; i <= this.raggedRank; ++i)
- a[i] < 0 && (a[i] = this.getMaxWidth(i));
- return a;
- }
- calculateFirstParentOutputIndex(e, t10, o) {
- let n = Math.min(e, o), s = [], a = 0;
- for (let i = 0; i < n; ++i, a += t10)
- s.push(a);
- for (let i = n; i < e; ++i)
- s.push(-1);
- return x.assert(s.length === e, () => "Final length of result must be equal to firstDimension."), s;
- }
- calculateOutputIndexRowSplit(e, t10, o, n) {
- let s = e.length, a = [];
- for (let i = 0; i < s - 1; ++i) {
- let p = e[i + 1] - e[i], u = Math.min(n, p), c = t10[i];
- c === -1 && (u = 0);
- for (let l = 0; l < u; ++l)
- a.push(c), c += o;
- for (let l = 0; l < p - u; ++l)
- a.push(-1);
- }
- if (s > 0 && a.length !== e[s - 1])
- throw new Error("Invalid row split size.");
- return a;
- }
- calculateOutputIndexValueRowID(e, t10, o, n) {
- let s = e.length, a = [];
- if (s === 0)
- return [];
- let i = 0, p = e[0];
- if (p >= t10.length)
- throw new Error(`Got currentValueRowId=${p}, which is not less than ${t10.length}`);
- let u = t10[p];
- a.push(u);
- for (let c = 1; c < s; ++c) {
- let l = e[c];
- if (l === p)
- u >= 0 && (++i, i < n ? u += o : u = -1);
- else {
- if (i = 0, p = l, l >= t10.length)
- throw new Error(`Got nextValueRowId=${l} which is not less than ${t10.length}`);
- u = t10[l];
- }
- a.push(u);
- }
- if (a.length !== e.length)
- throw new Error("Invalid row ids.");
- return a;
- }
- calculateOutputIndex(e, t10, o, n) {
- let s = this.getRowPartitionTensor(e), a = this.getRowPartitionTypeByDimension(e);
- switch (a) {
- case en.VALUE_ROWIDS:
- return this.calculateOutputIndexValueRowID(s, t10, o, n);
- case en.ROW_SPLITS:
- if (s.length - 1 > t10.length)
- throw new Error(`Row partition size is greater than output size: ${s.length - 1} > ${t10.length}`);
- return this.calculateOutputIndexRowSplit(s, t10, o, n);
- default:
- throw new Error(`Unsupported partition type: ${en[a]}`);
- }
- }
- getFirstDimensionSize() {
- let e = this.rowPartitionValues[0];
- if (this.rowPartitionTypes.length === 0)
- throw new Error("No row_partition_types given.");
- let t10 = this.rowPartitionTypes[0];
- switch (t10) {
- case en.FIRST_DIM_SIZE:
- return e[0];
- case en.VALUE_ROWIDS:
- throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");
- case en.ROW_SPLITS:
- return this.rowPartitionValuesShapes[0][0] - 1;
- default:
- throw new Error(`Cannot handle type ${en[t10]}`);
- }
- }
- compute() {
- if (this.rowPartitionValues[0].length <= 0)
- throw new Error("Invalid first partition input. Tensor requires at least one element.");
- let t10 = this.getFirstDimensionSize(), o = this.calculateOutputSize(t10), n = new Array(this.raggedRank + 1);
- n[n.length - 1] = 1;
- for (let p = n.length - 2; p >= 0; --p)
- n[p] = n[p + 1] * o[p + 1];
- let s = SM(o, false), a = x.getArrayFromDType(this.valuesDType, x.sizeFromShape(s));
- if (n[0] * o[0] > 0) {
- let p = this.calculateFirstParentOutputIndex(t10, n[0], o[0]);
- for (let u = 1; u <= this.raggedRank; ++u)
- p = this.calculateOutputIndex(u - 1, p, n[u], o[u]);
- this.setOutput(this.raggedRank, p, a, s);
- }
- return [s, a];
- }
- setOutput(e, t10, o, n) {
- if (o.length === 0)
- return;
- let s = this.values, a = o, i = n.slice();
- i = i.slice(e + 1);
- let p = x.sizeFromShape(i), u = t10.length, c = this.defaultValue;
- if (c.length !== p && c.length !== 1) {
- let d = this.defaultValueShape;
- Ne(() => {
- let h = z(c, d);
- c = Ls(h, i).dataSync();
- });
- }
- let l = 0, m = 0, f = 0;
- for (let d = 0; d <= u; ++d) {
- let h = d < u ? t10[d] : -1;
- if (h === f) {
- ++f;
- continue;
- }
- if (m < f) {
- let g = s.subarray(l * p), y = a.subarray(m * p), b = (f - m) * p;
- wM(y, g, b);
- }
- if (d >= u) {
- let g = o.length;
- h = Math.floor(g / p);
- }
- if (h > f)
- if (this.defaultValue.length === 1)
- a.subarray(f * p, h * p).fill(this.defaultValue[0]), f = h;
- else
- for (; h > f; ) {
- let g = a.slice(f * p);
- wM(g, c, p), ++f;
- }
- h < 0 ? (l = d + 1, m = f) : (l = d, m = f, f = m + 1);
- }
- }
-};
-function wM(r, e, t10) {
- for (let o = 0; o < t10; o++)
- r[o] = e[o];
-}
-function SM(r, e) {
- let t10 = [];
- for (let o of r) {
- if (o < 0) {
- if (!e)
- throw new Error(`Dimension ${o} must be >= 0`);
- if (o < -1)
- throw new Error(`Dimension ${o} must be >= -1`);
- o = -1;
- }
- t10.push(o);
- }
- return t10;
-}
-function vM(r, e, t10, o, n, s, a, i, p, u) {
- return new Rc(r, e, t10, o, n, s, a, i, p, u).compute();
-}
-function kM(r, e, t10, o) {
- let n = r === e, s = r < e && t10 < 0, a = e < r && t10 > 1;
- if (n || s || a)
- return x.makeZerosTypedArray(0, o);
- let i = Math.abs(Math.ceil((e - r) / t10)), p = x.makeZerosTypedArray(i, o);
- e < r && t10 === 1 && (t10 = -1), p[0] = r;
- for (let u = 1; u < p.length; u++)
- p[u] = p[u - 1] + t10;
- return p;
-}
-var ES = Tr((r) => 1 / Math.sqrt(r));
-var U2t = Jo(xo, ES);
-function TM(r, e, t10, o, n, s, a, i, p, u) {
- let c = [o / n, n], l = r.values, m = e.values;
- if (o === 0)
- return ne(t10, e.dtype);
- let f = ne(c, e.dtype);
- typeof p == "string" || typeof p == "number" ? f.values.fill(p) : typeof p == "boolean" && f.values.fill(+p);
- for (let d = 0; d < s; d++) {
- let h = [], g = 0;
- for (let y = 0; y < a; y++) {
- let b = l[d * a + y];
- h.push(b), g += b * i[y];
- }
- if (g < 0 || g >= o / n)
- throw new Error(`Invalid indices: ${h} does not index into ${t10}`);
- for (let y = 0; y < n; y++)
- u ? f.values[g * n + y] += m[d * n + y] : f.values[g * n + y] = e.rank === 0 ? m[0] : m[d * n + y];
- }
- return f;
-}
-var NM = Tr((r) => 1 / (1 + Math.exp(-r)));
-var Y2t = qg(yo, (r) => 1 / (1 + Math.exp(-r)));
-function _M(r, e, t10, o, n) {
- let s = et.isSliceContinous(o, e, t10), a = x.sizeFromShape(t10), i = x.computeStrides(o);
- if (s) {
- let l = et.computeFlatOffset(e, i);
- return n === "string" ? r.slice(l, l + a) : r.subarray(l, l + a);
- }
- let p = n === "string" ? I.fromUint8ToStringArray(r) : r, u = ne(o, n, p), c = ne(t10, n);
- for (let l = 0; l < c.size; ++l) {
- let m = c.indexToLoc(l), f = m.map((d, h) => d + e[h]);
- c.set(u.get(...f), ...m);
- }
- return n === "string" ? I.fromStringArrayToUint8(c.values) : c.values;
-}
-function EM(r, e, t10, o, n, s, a) {
- let i = e[0], p = s[0], u = new Array(p), c = new Array(i), l = e[1];
- if (p === 0) {
- if (i !== 0)
- throw new Error(I.getSparseFillEmptyRowsIndicesDenseShapeMismatch(i));
- let g = x.getArrayFromDType(t10, 0), y = x.getArrayFromDType(n, 0);
- return [g, [0, l], y, u, c];
- }
- let m = true, f = 0, d = new Array(p).fill(0);
- for (let g = 0; g < i; ++g) {
- let y = r[g * l];
- if (y < 0)
- throw new Error(I.getSparseFillEmptyRowsNegativeIndexErrorMessage(g, y));
- if (y >= p)
- throw new Error(I.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(g, y, p));
- ++d[y], m = m && y >= f, f = y;
- }
- let h = true;
- for (let g = 0; g < p; ++g) {
- let y = d[g] === 0;
- u[g] = y, h = h && !y, d[g] = Math.max(d[g], 1), g > 0 && (d[g] += d[g - 1]);
- }
- if (h && m) {
- let g = r, y = o;
- for (let b = 0; b < i; ++b)
- c[b] = b;
- return [g, [i, l], y, u, c];
- } else {
- let g = d[p - 1], y = x.getArrayFromDType(t10, g * l), b = x.getArrayFromDType(n, g), C = new Array(p).fill(0);
- for (let w = 0; w < i; ++w) {
- let k = r[w * l], _ = C[k], E = (k === 0 ? 0 : d[k - 1]) + _;
- C[k]++;
- for (let R = 0; R < l; ++R)
- y[E * l + R] = r[w * l + R];
- b[E] = o[w], c[w] = E;
- }
- for (let w = 0; w < p; ++w)
- if (C[w] === 0) {
- let _ = w === 0 ? 0 : d[w - 1];
- y[_ * l + 0] = w;
- for (let E = 1; E < l; ++E)
- y[_ * l + E] = 0;
- b[_] = a;
- }
- return [y, [g, l], b, u, c];
- }
-}
-function $M(r, e, t10, o, n) {
- let s = x.sizeFromShape(o), a = e[0], i = n.length, p = [], u = 1, c = -1;
- for (let g = 0; g < i; ++g) {
- let y = n[g];
- if (y === -1) {
- if (c !== -1)
- throw new Error(I.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(c, g));
- c = g, p.push(1);
- } else {
- if (y < 0)
- throw new Error(I.getSparseReshapeNegativeOutputDimErrorMessage(g, y));
- u *= y, p.push(y);
- }
- }
- if (c !== -1) {
- if (u <= 0)
- throw new Error(I.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage());
- let g = Math.trunc(s / u);
- if (u * g !== s)
- throw new Error(I.getSparseReshapeInputOutputMultipleErrorMessage(o, p));
- p[c] = g;
- }
- if (x.sizeFromShape(p) !== s)
- throw new Error(I.getSparseReshapeInputOutputMismatchErrorMessage(o, p));
- let m = o.length, f = [];
- if (m > 0) {
- f[m - 1] = 1;
- for (let g = m - 2; g >= 0; --g)
- f[g] = f[g + 1] * o[g + 1];
- }
- let d = [];
- if (i > 0) {
- d[i - 1] = 1;
- for (let g = i - 2; g >= 0; --g)
- d[g] = d[g + 1] * p[g + 1];
- }
- let h = x.getArrayFromDType(t10, a * i);
- for (let g = 0; g < a; ++g) {
- let y = 0;
- for (let b = 0; b < m; ++b)
- y += r[g * m + b] * f[b];
- for (let b = 0; b < i; ++b)
- h[g * i + b] = Math.trunc(y / d[b]), y %= d[b];
- }
- return [h, [a, i], p];
-}
-function RM(r, e, t10, o, n, s = false, a = 0) {
- let i = o.length, p = [e[0], r.length / e[0]], u = p[1], l = i > 0 ? n[i - 1] + 1 : 0;
- if (l < 0)
- throw new Error(I.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
- let m = e.slice();
- m[0] = l;
- let f = m.reduce((C, w) => C * w, 1), d = x.getArrayFromDType(t10, f);
- if (i === 0)
- return l > 0 && d.fill(a), [d, m];
- if (l <= 0)
- throw new Error(I.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
- let h = 0, g = 1, y = 0, b = n[h];
- for (; ; ) {
- let C = 0;
- if (g < i) {
- if (C = n[g], b === C) {
- ++g;
- continue;
- }
- if (b >= C)
- throw new Error(I.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage());
- }
- if (b < 0 || b >= l)
- throw new Error(I.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(b, l));
- b > y && d.fill(a, y * u, b * u);
- for (let w = h; w < g; ++w) {
- let k = o[w];
- if (k < 0 || k >= p[0])
- throw new Error(I.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(w, o[w], p[0]));
- for (let _ = 0; _ < u; _++)
- d[b * u + _] += r[k * u + _];
- }
- if (s)
- for (let w = 0; w < u; w++)
- d[b * u + w] /= g - h;
- if (h = g, ++g, y = b + 1, b = C, g > i)
- break;
- }
- return y < l && d.fill(a, y * u, l * u), [d, m];
-}
-var AM = Tr((r) => Math.sqrt(r));
-var c_t = qg(bo, (r) => Math.sqrt(r));
-var $S = kt((r, e) => {
- let t10 = r - e;
- return t10 * t10;
-});
-var h_t = Dt(Co, $S);
-function FM(r, e, t10, o) {
- let n = ne(r, e.dtype);
- for (let s = 0; s < n.size; s++) {
- let a = n.indexToLoc(s), i = new Array(a.length);
- for (let p = 0; p < i.length; p++)
- i[p] = a[p] * t10[p] + o[p];
- n.set(e.get(...i), ...a);
- }
- return n;
-}
-var RS = class {
- constructor(e, t10, o, n, s, a) {
- this.separator = x.encodeString(e), this.nGramWidths = t10, this.leftPad = x.encodeString(o), this.rightPad = x.encodeString(n), this.padWidth = s, this.preserveShort = a;
- }
- getPadWidth(e) {
- return Math.min(this.padWidth < 0 ? e - 1 : this.padWidth, e - 1);
- }
- getNumNGrams(e, t10) {
- let o = this.getPadWidth(t10);
- return Math.max(0, e + 2 * o - t10 + 1);
- }
- createNGrams(e, t10, o, n, s, a) {
- for (let i = 0; i < s; ++i) {
- let p = this.getPadWidth(a), u = Math.max(0, p - i), c = Math.max(0, p - (s - (i + 1))), l = a - (u + c), m = t10 + (u > 0 ? 0 : i - p), f = 0;
- f += u * this.leftPad.length;
- for (let b = 0; b < l; ++b)
- f += e[m + b].length;
- f += c * this.rightPad.length;
- let d = u + c + l - 1;
- f += d * this.separator.length, o[n + i] = new Uint8Array(f);
- let h = o[n + i], g = 0, y = (b) => b.forEach((C) => h[g++] = C);
- for (let b = 0; b < u; ++b)
- y(this.leftPad), y(this.separator);
- for (let b = 0; b < l - 1; ++b)
- y(e[m + b]), y(this.separator);
- if (l > 0) {
- y(e[m + l - 1]);
- for (let b = 0; b < c; ++b)
- y(this.separator), y(this.rightPad);
- } else {
- for (let b = 0; b < c - 1; ++b)
- y(this.rightPad), y(this.separator);
- y(this.rightPad);
- }
- }
- }
- compute(e, t10) {
- let o = e.length, n = t10.length;
- if (n > 0) {
- let p = t10[0];
- if (p !== 0)
- throw new Error(`First split value must be 0, got ${p}`);
- for (let u = 1; u < n; ++u) {
- let c = t10[u] >= p;
- if (c = c && t10[u] <= o, !c)
- throw new Error(`Invalid split value ${t10[u]}, must be in [${p}, ${o}]`);
- p = t10[u];
- }
- if (p !== o)
- throw new Error(`Last split value must be data size. Expected ${o}, got ${p}`);
- }
- let s = n - 1, a = x.getArrayFromDType("int32", n);
- if (o === 0 || n === 0) {
- let p = new Array(o);
- for (let u = 0; u <= s; ++u)
- a[u] = 0;
- return [p, a];
- }
- a[0] = 0;
- for (let p = 1; p <= s; ++p) {
- let u = t10[p] - t10[p - 1], c = 0;
- this.nGramWidths.forEach((l) => {
- c += this.getNumNGrams(u, l);
- }), this.preserveShort && u > 0 && c === 0 && (c = 1), a[p] = a[p - 1] + c;
- }
- let i = new Array(a[s]);
- for (let p = 0; p < s; ++p) {
- let u = t10[p], c = a[p];
- if (this.nGramWidths.forEach((l) => {
- let m = t10[p + 1] - t10[p], f = this.getNumNGrams(m, l);
- this.createNGrams(e, u, i, c, f, l), c += f;
- }), this.preserveShort && c === a[p]) {
- let l = t10[p + 1] - t10[p];
- if (l === 0)
- continue;
- let m = l + 2 * this.padWidth, f = 1;
- this.createNGrams(e, u, i, c, f, m);
- }
- }
- return [i, a];
- }
-};
-function DM(r, e, t10, o, n, s, a, i) {
- return new RS(t10, o, n, s, a, i).compute(r, e);
-}
-function Lre(r, e, t10, o) {
- if (!r.length)
- return;
- if (e.length === 0) {
- for (let s = 0; s < r.length; ++s)
- o.push(r.subarray(s, s + 1));
- return;
- }
- if (e.length === 1) {
- let s = e[0], a = r.indexOf(s);
- for (; a !== -1; ) {
- let i = r.subarray(0, a);
- (!t10 || i.length !== 0) && o.push(i), r = r.subarray(a + 1), a = r.indexOf(s);
- }
- (!t10 || r.length !== 0) && o.push(r);
- return;
- }
- let n = 0;
- for (let s = 0; s < r.length + 1; s++)
- if (s === r.length || e.indexOf(r[s]) !== -1) {
- let a = r.subarray(n, s);
- (!t10 || a.length !== 0) && o.push(a), n = s + 1;
- }
-}
-function PM(r, e, t10) {
- let o = r.length, n = [], s = 0, a = 0, i = new Array(o);
- for (let m = 0; m < o; ++m) {
- let f = n.length;
- Lre(r[m], e, t10, n);
- let d = n.length - f;
- i[m] = d, s += d, a = Math.max(a, d);
- }
- let p = x.getArrayFromDType("int32", s * 2), u = new Array(s), c = [o, a], l = 0;
- for (let m = 0; m < o; ++m)
- for (let f = 0; f < i[m]; ++f)
- p[l * 2] = m, p[l * 2 + 1] = f, u[l] = n[l], ++l;
- return [p, u, c];
-}
-function OM(r, e) {
- let t10 = x.getArrayFromDType("int32", r.length);
- for (let o = 0; o < r.length; ++o)
- t10[o] = x.fingerPrint64(r[o]).modulo(e).getLowBitsUnsigned();
- return t10;
-}
-var AS = kt((r, e) => r - e);
-var Bre = $c((r, e, t10, o) => ({ real: r - t10, imag: e - o }));
-var __t = Dt(Io, AS, Bre);
-function MM(r, e) {
- let t10 = new Array(r.rank);
- for (let n = 0; n < t10.length; n++)
- t10[n] = r.shape[n] * e[n];
- let o = ne(t10, r.dtype);
- for (let n = 0; n < o.values.length; ++n) {
- let s = o.indexToLoc(n), a = new Array(r.rank);
- for (let p = 0; p < a.length; p++)
- a[p] = s[p] % r.shape[p];
- let i = r.locToIndex(a);
- o.values[n] = r.values[i];
- }
- return o;
-}
-var Zl = (r, e) => {
- let t10 = e.value - r.value;
- return t10 === 0 ? r.index - e.index : t10;
-};
-function LM(r, e, t10 = 0, o = r.length - 1) {
- for (; o > t10; ) {
- if (o - t10 > 600) {
- let i = o - t10 + 1, p = e - t10 + 1, u = Math.log(i), c = 0.5 * Math.exp(2 * u / 3), l = 0.5 * Math.sqrt(u * c * (i - c) / i) * Math.sign(p - i / 2), m = Math.max(t10, Math.floor(e - p * c / i + l)), f = Math.min(o, Math.floor(e + (i - p) * c / i + l));
- LM(r, e, m, f);
- }
- let n = r[e], s = t10, a = o;
- for (x.swap(r, t10, e), Zl(r[o], n) > 0 && x.swap(r, t10, o); s < a; ) {
- for (x.swap(r, s, a), s++, a--; Zl(r[s], n) < 0; )
- s = s + 1;
- for (; Zl(r[a], n) > 0; )
- a = a - 1;
- }
- Zl(r[t10], n) === 0 ? x.swap(r, t10, a) : (a = a + 1, x.swap(r, a, o)), a <= e && (t10 = a + 1), e <= a && (o = a - 1);
- }
-}
-function BM(r, e, t10, o, n) {
- let s = e[e.length - 1], [a, i] = [r.length / s, s], p = x.getTypedArrayFromDType(t10, a * o), u = x.getTypedArrayFromDType("int32", a * o);
- for (let l = 0; l < a; l++) {
- let m = l * i, f = r.subarray(m, m + i), d = new Array(f.length);
- f.forEach((b, C) => d[C] = { value: b, index: C }), o < d.length && (LM(d, o), d = d.slice(0, o)), n && d.sort(Zl);
- let h = l * o, g = p.subarray(h, h + o), y = u.subarray(h, h + o);
- for (let b = 0; b < o; b++)
- g[b] = d[b].value, y[b] = d[b].index;
- }
- let c = e.slice();
- return c[c.length - 1] = o, [ne(c, t10, p), ne(c, "int32", u)];
-}
-function VM(r, e, t10, o) {
- let n = x.parseAxisParam(e, t10)[0], s = [1, t10[0], 1];
- for (let d = 0; d < n; d++)
- s[0] *= t10[d];
- s[1] = t10[n];
- for (let d = n + 1; d < t10.length; d++)
- s[2] *= t10[d];
- let a = {}, i = new Int32Array(t10[n]), p = new je(s, o, r), u = [], c = s[0] === 1 && s[2] === 1;
- for (let d = 0; d < t10[n]; d++) {
- let h;
- if (c)
- h = r[d].toString();
- else {
- let g = [];
- for (let y = 0; y < s[0]; y++)
- for (let b = 0; b < s[2]; b++)
- g.push(p.get(y, d, b));
- h = g.join(",");
- }
- if (a[h] !== void 0)
- i[d] = a[h];
- else {
- let g = Object.keys(a).length;
- a[h] = g, i[d] = g, u.push(d);
- }
- }
- let l = s.slice();
- l[1] = Object.keys(a).length;
- let m = new je(l, o);
- u.forEach((d, h) => {
- for (let g = 0; g < s[0]; g++)
- for (let y = 0; y < s[2]; y++)
- m.set(p.get(g, d, y), g, h, y);
- });
- let f = t10.slice();
- return f[n] = l[1], { outputValues: m.values, outputShape: f, indices: i };
-}
-var { addImpl: zM, castImpl: WM, ceilImpl: UM, concatImpl: GM, equalImpl: HM, expImpl: qM, expm1Impl: KM, floorImpl: jM, gatherNdImpl: XM, gatherV2Impl: YM, greaterEqualImpl: QM, greaterImpl: ZM, lessEqualImpl: JM, lessImpl: eL, logImpl: tL, maxImpl: rL, maximumImpl: oL, minimumImpl: nL, multiplyImpl: sL, negImpl: aL, notEqualImpl: iL, prodImpl: uL, rangeImpl: pL, rsqrtImpl: cL, scatterImpl: lL, simpleAbsImpl: mL, sliceImpl: fL, stridedSliceImpl: dL, stringNGramsImpl: hL, subImpl: gL, tileImpl: xL, topKImpl: yL, transposeImpl: bL, uniqueImpl: _Et } = FS;
-var Vre = Ge({ opType: pe.ABS, cpuKernelImpl: mL });
-var CL = { kernelName: sn, backendName: "webgpu", kernelFunc: Vre };
-var zre = it({ opType: ye.ADD, cpuKernelImpl: zM, supportsComplex: true });
-var IL = { kernelName: _r, backendName: "webgpu", kernelFunc: zre };
-var Kg = class {
+var { addImpl: W3, castImpl: U3, ceilImpl: G3, concatImpl: H3, equalImpl: q3, expImpl: K3, expm1Impl: j3, floorImpl: X3, gatherNdImpl: Y3, gatherV2Impl: Q3, greaterEqualImpl: Z3, greaterImpl: J3, lessEqualImpl: eM, lessImpl: tM, logImpl: rM, maxImpl: oM, maximumImpl: nM, minimumImpl: sM, multiplyImpl: aM, negImpl: iM, notEqualImpl: uM, prodImpl: pM, rangeImpl: cM, rsqrtImpl: lM, scatterImpl: mM, simpleAbsImpl: dM, sliceImpl: fM, stridedSliceImpl: hM, stringNGramsImpl: gM, subImpl: xM, tileImpl: yM, topKImpl: bM, transposeImpl: CM, uniqueImpl: kNt } = Qp;
+var mre = Se({ opType: Q.ABS, cpuKernelImpl: dM });
+var SM = { kernelName: gs, backendName: "webgpu", kernelFunc: mre };
+var dre = Se({ opType: Q.ACOS });
+var wM = { kernelName: sa, backendName: "webgpu", kernelFunc: dre };
+var fre = Se({ opType: Q.ACOSH });
+var IM = { kernelName: aa, backendName: "webgpu", kernelFunc: fre };
+var hre = ot({ opType: ye.ADD, cpuKernelImpl: W3, supportsComplex: true });
+var vM = { kernelName: eo, backendName: "webgpu", kernelFunc: hre };
+var Dg = class {
constructor(e) {
- this.workPerThread = 1, this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e[0], this.variableNames = e.map((t10, o) => `T${o}`), this.dispatchLayout = fe(this.outputShape), this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]), this.shaderKey = "addN";
+ this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.size = true, this.outputShape = e[0], this.variableNames = e.map((t6, o) => `T${o}`), this.dispatchLayout = ue(this.outputShape), this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.workPerThread, 1, 1]), this.shaderKey = "addN";
}
getUserCode() {
let e = [];
this.variableNames.forEach((n) => {
e.push(`let v${n} = get${n}ByOutputCoords(coords);`);
});
- let t10 = this.variableNames.map((n) => `v${n}`).join(" + ");
+ let t6 = this.variableNames.map((n) => `v${n}`).join(" + ");
return `
- ${ue("index")} {
+ ${se("index")} {
for (var i = 0; i < ${this.workPerThread}; i = i + 1) {
let flatIndex = index * ${this.workPerThread} + i;
if (flatIndex < uniforms.size) {
let coords = getCoordsFromIndex(flatIndex);
${e.join(`
`)}
- setOutputAtIndex(flatIndex, ${t10});
+ setOutputAtIndex(flatIndex, ${t6});
}
}
}
`;
}
};
-function Wre(r) {
- let { inputs: e, backend: t10 } = r, o = e;
+function gre(r) {
+ let { inputs: e, backend: t6 } = r, o = e;
if (o.length === 1)
- return Lt({ inputs: { x: o[0] }, backend: t10 });
- let n = o.map((i) => i.dtype).reduce((i, p) => ct(i, p)), s = o.map((i) => i.shape), a = new Kg(s);
- return t10.runWebGPUProgram(a, o, n);
+ return Ft({ inputs: { x: o[0] }, backend: t6 });
+ let n = o.map((i) => i.dtype).reduce((i, p) => dt(i, p)), s = o.map((i) => i.shape), a = new Dg(s);
+ return t6.runWebGPUProgram(a, o, n);
}
-var wL = { kernelName: an, backendName: "webgpu", kernelFunc: Wre };
-var Ac = class {
- constructor(e, t10, o) {
- this.workGroupSize = [64, 1, 1], this.variableNames = ["x"], this.uniforms = "infinityValue : f32,", this.size = true;
- let n = [t10];
- this.op = o === "min" ? "<" : ">";
- let [s, a] = I.computeOutAndReduceShapes(e, n);
- this.outputShape = s.length === 0 ? [1] : s, this.dispatchLayout = fe(this.outputShape), x.sizeFromShape(a) < 32 || x.sizeFromShape(s) > 1e3 ? (this.type = "plain", this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize)) : (this.type = "shared", this.dispatch = ae(this.dispatchLayout, this.outputShape, [1, 1, 1])), this.inputShape = e, this.shaderKey = `argMinMax_${this.op}_${this.type}`;
+var kM = { kernelName: Mo, backendName: "webgpu", kernelFunc: gre };
+var Og = class {
+ constructor(e, t6) {
+ this.variableNames = ["A"], this.workgroupSize = [16, 16, 1];
+ let o = new Array(e.length);
+ for (let n = 0; n < o.length; n++)
+ o[n] = e[t6[n]];
+ this.outputShape = o, this.dispatchLayout = { x: [0], y: [1] }, this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize, [1, 1, 1]), this.shaderKey = "transposeShared";
}
getUserCode() {
- let e = () => this.inputShape.length === 1 ? "uniforms.xShape" : `uniforms.xShape.${Yo(this.inputShape.length - 1)}`, t10 = () => {
+ return y.assert(this.workgroupSize[0] === this.workgroupSize[1], () => `Must be a square tile, current tile shape is ${this.workgroupSize[0]} x ${this.workgroupSize[1]}`), `
+ const tileSize = ${this.workgroupSize[0]};
+ var tile : array, ${this.workgroupSize[0]}>;
+ ${se()} {
+ var x = i32(workgroupId.x) * tileSize + i32(localId.x);
+ var y = i32(workgroupId.y) * tileSize + i32(localId.y);
+ let width = uniforms.outShape[0];
+ let height = uniforms.outShape[1];
+ if (x < width && y < height) {
+ tile[localId.y][localId.x] = f32(A[y * width + x]);
+ }
+ workgroupBarrier();
+
+ x = i32(workgroupId.y) * tileSize + i32(localId.x);
+ y = i32(workgroupId.x) * tileSize + i32(localId.y);
+ if (x < height && y < width) {
+ setOutputAtIndex((y * height + x), tile[localId.x]
+ [localId.y]);
+ }
+ }
+ `;
+ }
+};
+var Pg = class {
+ constructor(e, t6) {
+ this.variableNames = ["A"], this.workPerThread = 1, this.workgroupSize = [64, 1, 1], this.size = true;
+ let o = new Array(e.length);
+ for (let n = 0; n < o.length; n++)
+ o[n] = e[t6[n]];
+ this.outputShape = o, this.dispatchLayout = ue(this.outputShape), this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize, [this.workPerThread, 1, 1]), this.newDim = t6, this.shaderKey = `transpose_${t6}`;
+ }
+ getUserCode() {
+ let e = Rt(this.outputShape.length), t6 = xre(this.newDim);
+ return `
+ ${se("index")} {
+ for(var i = 0; i < ${this.workPerThread}; i = i + 1) {
+ let flatIndex = index * ${this.workPerThread} + i;
+ if(flatIndex < uniforms.size) {
+ let resRC = getCoordsFromIndex(flatIndex);
+ setOutputAtIndex(flatIndex, A[getIndexFromCoords${this.outputShape.length}D(
+ ${e}(${t6}), uniforms.aShape)]);
+ }
+ }
+ }
+ `;
+ }
+};
+function xre(r) {
+ let e = r.length;
+ if (e > 6)
+ throw Error(`Transpose for rank ${e} is not yet supported`);
+ let t6 = new Array(e);
+ for (let o = 0; o < r.length; o++)
+ t6[r[o]] = `resRC.${$o(o)}`;
+ return t6.join();
+}
+function Nr(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { perm: s } = o, a = t6, i = n.shape.length, p = new Array(i);
+ for (let c = 0; c < p.length; c++)
+ p[c] = n.shape[s[c]];
+ if (t6.shouldExecuteOnCPU([n])) {
+ let l = a.tensorMap.get(n.dataId).values, m = CM(l, n.shape, n.dtype, s, p);
+ return t6.makeTensorInfo(p, n.dtype, m);
+ }
+ if (n.shape.length === 2 && y.arraysEqual(s, [1, 0])) {
+ let c = new Og(n.shape, s);
+ return a.runWebGPUProgram(c, [n], n.dtype);
+ }
+ let u = new Pg(n.shape, s);
+ return a.runWebGPUProgram(u, [n], n.dtype);
+}
+var NM = { kernelName: ro, backendName: "webgpu", kernelFunc: Nr };
+var Mg = class {
+ constructor(e, t6) {
+ this.workgroupSize = [64, 1, 1], this.variableNames = ["x"], this.uniforms = "reduceSize : i32,", this.size = true, this.inputShape = [e.batchSize, e.inSize];
+ let [o] = S.computeOutAndReduceShapes(this.inputShape, [1]);
+ this.outputShape = o.length === 0 ? [1] : o, this.dispatchLayout = ue(this.outputShape), this.dispatch = re(this.dispatchLayout, this.outputShape, [1, 1, 1]), this.reduceType = t6, this.shaderKey = `reduce_${t6}`;
+ }
+ getUserCode() {
+ let e = "", t6 = "0.0";
+ this.reduceType === "min" || this.reduceType === "max" ? (e = `
+ if (isnan(candidate)) {
+ bestValue = uniforms.NAN;
+ } else if (!isnan(bestValue) && candidate ${this.reduceType === "min" ? "<" : ">"} bestValue)
+ { bestValue = candidate; }`, t6 = "f32(x[offset])") : this.reduceType === "sum" || this.reduceType === "mean" ? e = " bestValue = bestValue + candidate; " : this.reduceType === "prod" ? (e = " bestValue = bestValue * candidate; ", t6 = "1.0") : this.reduceType === "all" ? (e = " bestValue = f32(bestValue >= 1.0 && candidate >= 1.0); ", t6 = "1.0") : this.reduceType === "any" && (e = " bestValue = f32(bestValue >= 1.0 || candidate >= 1.0); ", t6 = "0.0");
+ let o = this.reduceType === "mean" ? "setOutputAtIndex(outputIndex, bestValue / f32(uniforms.reduceSize));" : "setOutputAtIndex(outputIndex, bestValue);";
+ return `
+ fn DIV_CEIL(a : u32, b : u32) -> u32 {
+ return ((a - 1u) / b + 1u);
+ }
+
+ ${`
+ var xBestValues : array;
+ `}
+ fn getOffset(outputIndex : i32) -> i32 {
+ let outputCoords = getCoordsFromIndex(outputIndex);
+ let offset = ${this.outputShape.length === 1 ? "outputCoords" : "outputCoords[0]"} * uniforms.reduceSize;
+ return offset;
+ }
+ ${se("index")} {
+ let outputIndex = index / i32(workgroupSizeX);
+ let offset = getOffset(outputIndex);
+ var bestValue = ${t6};
+ let Length = uniforms.reduceSize;
+ let WorkPerThread = DIV_CEIL(u32(Length), workgroupSizeX);
+ for (var k = i32(localId.x); k < Length && outputIndex < uniforms.size;
+ k = k + i32(workgroupSizeX)) {
+ let candidate = f32(x[offset + k]);
+ ${e}
+ }
+ xBestValues[localId.x] = bestValue;
+ workgroupBarrier();
+
+ var reduceSize = min(u32(Length), workgroupSizeX);
+ for (var currentSize = reduceSize / 2u; reduceSize > 1u;
+ currentSize = reduceSize / 2u) {
+ let interval = DIV_CEIL(reduceSize, 2u);
+ if (localId.x < currentSize) {
+ let candidate = xBestValues[localId.x + interval];
+ ${e}
+ xBestValues[localId.x] = bestValue;
+ }
+ reduceSize = interval;
+ workgroupBarrier();
+ }
+
+ if (localId.x == 0u && outputIndex < uniforms.size) {
+ ${o}
+ }
+ }
+ `;
+ }
+};
+function qr(r, e, t6, o, n) {
+ let s = r.shape.length, a = [], i = y.parseAxisParam(e, r.shape), p = i, u = S.getAxesPermutation(p, s), c = r;
+ u != null && (c = Nr({ inputs: { x: r }, attrs: { perm: u }, backend: n }), p = S.getInnerMostAxes(p.length, s), a.push(c)), S.assertAxesAreInnerMostDims(o, p, s);
+ let [l, m] = S.computeOutAndReduceShapes(c.shape, p), d = l;
+ t6 && (d = S.expandShapeToKeepDim(l, i));
+ let f;
+ if ((o === "max" || o === "prod") && n.shouldExecuteOnCPU([c])) {
+ let h = n.tensorMap.get(c.dataId).values;
+ switch (o) {
+ case "max":
+ let g = oM(h, y.sizeFromShape(m), d, r.dtype);
+ f = n.makeTensorInfo(d, r.dtype, g);
+ break;
+ case "prod":
+ let { outVals: x, outShape: b, outDtype: C } = pM(c.shape, c.dtype, h, p);
+ f = n.makeTensorInfo(b, C, x);
+ break;
+ default:
+ throw new Error(`${o} CPU implementation is not yet supported.`);
+ }
+ } else {
+ let h = y.sizeFromShape(m), x = y.sizeFromShape(c.shape) / h, b = { windowSize: h, inSize: h, batchSize: x, outSize: 1 }, C = o === "mean" ? "float32" : ka(r.dtype), w = [{ type: "int32", data: [h] }], k = new Mg(b, o), _ = n.runWebGPUProgram(k, [c], C, w);
+ a.push(_), f = de({ inputs: { x: _ }, attrs: { shape: d }, backend: n });
+ }
+ return a.forEach((h) => n.disposeData(h.dataId)), f;
+}
+function yre(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { keepDims: s, axis: a } = o;
+ return qr(n, a, s, "all", t6);
+}
+var TM = { kernelName: Lo, backendName: "webgpu", kernelFunc: yre };
+function bre(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { keepDims: s, axis: a } = o;
+ return qr(n, a, s, "any", t6);
+}
+var _M = { kernelName: Bo, backendName: "webgpu", kernelFunc: bre };
+var vc = class {
+ constructor(e, t6, o) {
+ this.workgroupSize = [64, 1, 1], this.variableNames = ["x"], this.uniforms = "infinityValue : f32,", this.size = true;
+ let n = [t6];
+ this.op = o === "min" ? "<" : ">";
+ let [s, a] = S.computeOutAndReduceShapes(e, n);
+ this.outputShape = s.length === 0 ? [1] : s, this.dispatchLayout = ue(this.outputShape), y.sizeFromShape(a) < 32 || y.sizeFromShape(s) > 1e3 ? (this.type = "plain", this.dispatch = re(this.dispatchLayout, this.outputShape, this.workgroupSize)) : (this.type = "shared", this.dispatch = re(this.dispatchLayout, this.outputShape, [1, 1, 1])), this.inputShape = e, this.shaderKey = `argMinMax_${this.op}_${this.type}`;
+ }
+ getUserCode() {
+ let e = () => this.inputShape.length === 1 ? "uniforms.xShape" : `uniforms.xShape.${$o(this.inputShape.length - 1)}`, t6 = () => {
let o = "";
if (this.outputShape.length === 1)
this.inputShape.length !== 1 && (o += "outputCoords,");
else
for (let n = 0; n < this.outputShape.length; n++)
- o += `outputCoords.${Yo(n)},`;
+ o += `outputCoords.${$o(n)},`;
return o;
};
return this.type === "shared" ? `
@@ -28631,20 +28015,20 @@ var Ac = class {
}
${`
- var xBestIndices : array;
- var xBestValues : array;
+ var xBestIndices : array;
+ var xBestValues : array;
`}
- ${ue("index")} {
- let outputIndex = index / i32(workGroupSizeX);
+ ${se("index")} {
+ let outputIndex = index / i32(workgroupSizeX);
let reduceLength = ${e()};
var bestIndex = i32(localId.x);
var bestValue = uniforms.infinityValue;
let outputCoords = getCoordsFromIndex(outputIndex);
for (var k = i32(localId.x); k < reduceLength && outputIndex < uniforms.size;
- k = k + i32(workGroupSizeX)) {
- let candidate = getX(${t10()} k);
+ k = k + i32(workgroupSizeX)) {
+ let candidate = getX(${t6()} k);
if (!isnan(candidate) && candidate ${this.op} bestValue) {
bestValue = candidate;
bestIndex = k;
@@ -28654,7 +28038,7 @@ var Ac = class {
xBestIndices[localId.x] = bestIndex;
workgroupBarrier();
- var reduceSize = min(u32(reduceLength), workGroupSizeX);
+ var reduceSize = min(u32(reduceLength), workgroupSizeX);
for (var currentSize = reduceSize / 2u; reduceSize > 1u;
currentSize = reduceSize / 2u) {
let interval = DIV_CEIL(reduceSize, 2u);
@@ -28675,14 +28059,14 @@ var Ac = class {
}
}
` : `
- ${ue("index")} {
+ ${se("index")} {
if (index < uniforms.size) {
let outputCoords = getCoordsFromIndex(index);
var bestIndex = 0;
- var bestValue = getX(${t10()} 0);
+ var bestValue = getX(${t6()} 0);
let reduceLength = ${e()};
for (var i = 1; i < reduceLength; i++) {
- let candidate = getX(${t10()} i);
+ let candidate = getX(${t6()} i);
if (candidate ${this.op} bestValue) {
bestValue = candidate;
bestIndex = i;
@@ -28694,115 +28078,40 @@ var Ac = class {
`;
}
};
-var jg = class {
- constructor(e, t10) {
- this.variableNames = ["A"], this.workGroupSize = [16, 16, 1];
- let o = new Array(e.length);
- for (let n = 0; n < o.length; n++)
- o[n] = e[t10[n]];
- this.outputShape = o, this.dispatchLayout = { x: [0], y: [1] }, this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize, [1, 1, 1]), this.shaderKey = "transposeShared";
- }
- getUserCode() {
- return `
- const TILE_DIM = ${this.workGroupSize[0]};
- var tile : array, ${this.workGroupSize[0]}>;
- ${Ri()}
- fn _start(@builtin(local_invocation_id) localId : vec3,
- @builtin(workgroup_id) workgroupId : vec3) {
- var x = i32(workgroupId.x) * TILE_DIM + i32(localId.x);
- var y = i32(workgroupId.y) * TILE_DIM + i32(localId.y);
- let width = uniforms.outShape[0];
- let height = uniforms.outShape[1];
- if (x < width && y < height) {
- tile[localId.y][localId.x] = A[y * width + x];
- }
- workgroupBarrier();
-
- x = i32(workgroupId.y) * TILE_DIM + i32(localId.x);
- y = i32(workgroupId.x) * TILE_DIM + i32(localId.y);
- if (x < height && y < width) {
- setOutputAtIndex((y * height + x), tile[localId.x]
- [localId.y]);
- }
- }
- `;
- }
-};
-var Xg = class {
- constructor(e, t10) {
- this.variableNames = ["A"], this.workPerThread = 1, this.workGroupSize = [64, 1, 1], this.size = true;
- let o = new Array(e.length);
- for (let n = 0; n < o.length; n++)
- o[n] = e[t10[n]];
- this.outputShape = o, this.dispatchLayout = fe(this.outputShape), this.dispatch = ae(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]), this.newDim = t10, this.shaderKey = `transpose_${t10}`;
- }
- getUserCode() {
- let e = At(this.outputShape.length), t10 = Ure(this.newDim);
- return `
- ${ue("index")} {
- for(var i = 0; i < ${this.workPerThread}; i = i + 1) {
- let flatIndex = index * ${this.workPerThread} + i;
- if(flatIndex < uniforms.size) {
- let resRC = getCoordsFromIndex(flatIndex);
- setOutputAtIndex(flatIndex, A[getIndexFromCoords${this.outputShape.length}D(
- ${e}(${t10}), uniforms.aShape)]);
- }
- }
- }
- `;
- }
-};
-function Ure(r) {
- let e = r.length;
- if (e > 6)
- throw Error(`Transpose for rank ${e} is not yet supported`);
- let t10 = new Array(e);
- for (let o = 0; o < r.length; o++)
- t10[r[o]] = `resRC.${Yo(o)}`;
- return t10.join();
+function Cre(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s } = o, a = y.parseAxisParam(s, n.shape), i = S.getAxesPermutation(a, n.shape.length), p = n, u = [];
+ i != null && (p = Nr({ inputs: { x: n }, backend: t6, attrs: { perm: i } }), u.push(p), a = S.getInnerMostAxes(a.length, p.shape.length)), S.assertAxesAreInnerMostDims("argMax", [a[0]], p.shape.length);
+ let c = new vc(p.shape, a[0], "max"), l = [{ type: "float32", data: [Number.NEGATIVE_INFINITY] }], m = t6.runWebGPUProgram(c, [p], "int32", l);
+ return u.forEach((d) => t6.disposeData(d.dataId)), m;
}
-function Nr(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { perm: s } = o, a = t10, i = n.shape.length, p = new Array(i);
- for (let c = 0; c < p.length; c++)
- p[c] = n.shape[s[c]];
- if (t10.shouldExecuteOnCPU([n])) {
- let l = a.tensorMap.get(n.dataId).values, m = bL(l, n.shape, n.dtype, s, p);
- return t10.makeTensorInfo(p, n.dtype, m);
- }
- if (n.shape.length === 2 && x.arraysEqual(s, [1, 0])) {
- let c = new jg(n.shape, s);
- return a.runWebGPUProgram(c, [n], n.dtype);
- }
- let u = new Xg(n.shape, s);
- return a.runWebGPUProgram(u, [n], n.dtype);
+var EM = { kernelName: Vo, backendName: "webgpu", kernelFunc: Cre };
+function Sre(r) {
+ let { inputs: e, backend: t6, attrs: o } = r, { x: n } = e, { axis: s } = o, a = y.parseAxisParam(s, n.shape), i = S.getAxesPermutation(a, n.shape.length), p = n, u = [];
+ i != null && (p = Nr({ inputs: { x: n }, backend: t6, attrs: { perm: i } }), u.push(p), a = S.getInnerMostAxes(a.length, p.shape.length)), S.assertAxesAreInnerMostDims("argMin", [a[0]], p.shape.length);
+ let c = new vc(p.shape, a[0], "min"), l = [{ type: "float32", data: [Number.POSITIVE_INFINITY] }], m = t6.runWebGPUProgram(c, [p], "int32", l);
+ return u.forEach((d) => t6.disposeData(d.dataId)), m;
}
-var SL = { kernelName: Mr, backendName: "webgpu", kernelFunc: Nr };
-function Gre(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s } = o, a = x.parseAxisParam(s, n.shape), i = I.getAxesPermutation(a, n.shape.length), p = n, u = [];
- i != null && (p = Nr({ inputs: { x: n }, backend: t10, attrs: { perm: i } }), u.push(p), a = I.getInnerMostAxes(a.length, p.shape.length)), I.assertAxesAreInnerMostDims("argMax", [a[0]], p.shape.length);
- let c = new Ac(p.shape, a[0], "max"), l = [{ type: "float32", data: [Number.NEGATIVE_INFINITY] }], m = t10.runWebGPUProgram(c, [p], "int32", l);
- return u.forEach((f) => t10.disposeData(f.dataId)), m;
-}
-var vL = { kernelName: un, backendName: "webgpu", kernelFunc: Gre };
-function Hre(r) {
- let { inputs: e, backend: t10, attrs: o } = r, { x: n } = e, { axis: s } = o, a = x.parseAxisParam(s, n.shape), i = I.getAxesPermutation(a, n.shape.length), p = n, u = [];
- i != null && (p = Nr({ inputs: { x: n }, backend: t10, attrs: { perm: i } }), u.push(p), a = I.getInnerMostAxes(a.length, p.shape.length)), I.assertAxesAreInnerMostDims("argMin", [a[0]], p.shape.length);
- let c = new Ac(p.shape, a[0], "min"), l = [{ type: "float32", data: [Number.POSITIVE_INFINITY] }], m = t10.runWebGPUProgram(c, [p], "int32", l);
- return u.forEach((f) => t10.disposeData(f.dataId)), m;
-}
-var kL = { kernelName: ja, backendName: "webgpu", kernelFunc: Hre };
-var qre = it({ opType: ye.ATAN2 });
-var TL = { kernelName: sa, backendName: "webgpu", kernelFunc: qre };
-var Jl = class {
- constructor(e, t10) {
- this.variableNames = ["x"], this.uniforms = "stride : vec2, pad : vec2